Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Merge remote branch 'origin/v0.4'
Browse files Browse the repository at this point in the history
Conflicts:
	deps/http_parser/http_parser.c
	deps/http_parser/test.c
	lib/repl.js
  • Loading branch information
ry committed Sep 15, 2011
2 parents 1b15af9 + e06ce75 commit a1bafc5
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 6 deletions.
11 changes: 10 additions & 1 deletion lib/module.js
Expand Up @@ -25,6 +25,15 @@ var runInThisContext = Script.runInThisContext;
var runInNewContext = Script.runInNewContext;
var assert = require('assert').ok;


// If obj.hasOwnProperty has been overridden, then calling
// obj.hasOwnProperty(prop) will break.
// See: https://github.com/joyent/node/issues/1707
function hasOwnProperty(obj, prop) {
return Object.prototype.hasOwnProperty.call(obj, prop);
}


function Module(id, parent) {
this.id = id;
this.exports = {};
Expand Down Expand Up @@ -86,7 +95,7 @@ function statPath(path) {
var packageCache = {};

function readPackage(requestPath) {
if (packageCache.hasOwnProperty(requestPath)) {
if (hasOwnProperty(packageCache, requestPath)) {
return packageCache[requestPath];
}

Expand Down
10 changes: 9 additions & 1 deletion lib/querystring.js
Expand Up @@ -25,6 +25,14 @@ var QueryString = exports;
var urlDecode = process.binding('http_parser').urlDecode;


// If obj.hasOwnProperty has been overridden, then calling
// obj.hasOwnProperty(prop) will break.
// See: https://github.com/joyent/node/issues/1707
function hasOwnProperty(obj, prop) {
return Object.prototype.hasOwnProperty.call(obj, prop);
}


function charCode(c) {
return c.charCodeAt(0);
}
Expand Down Expand Up @@ -166,7 +174,7 @@ QueryString.parse = QueryString.decode = function(qs, sep, eq) {
var k = QueryString.unescape(x[0], true);
var v = QueryString.unescape(x.slice(1).join(eq), true);

if (!obj.hasOwnProperty(k)) {
if (!hasOwnProperty(obj, k)) {
obj[k] = v;
} else if (!Array.isArray(obj[k])) {
obj[k] = [obj[k], v];
Expand Down
10 changes: 9 additions & 1 deletion lib/repl.js
Expand Up @@ -46,6 +46,14 @@ var path = require('path');
var fs = require('fs');
var rl = require('readline');

// If obj.hasOwnProperty has been overridden, then calling
// obj.hasOwnProperty(prop) will break.
// See: https://github.com/joyent/node/issues/1707
function hasOwnProperty(obj, prop) {
return Object.prototype.hasOwnProperty.call(obj, prop);
}


var context;

var disableColors = true;
Expand Down Expand Up @@ -517,7 +525,7 @@ REPLServer.prototype.complete = function(line, callback) {
group.sort();
for (var j = 0; j < group.length; j++) {
c = group[j];
if (!uniq.hasOwnProperty(c)) {
if (!hasOwnProperty(c)) {
completions.push(c);
uniq[c] = true;
}
Expand Down
59 changes: 59 additions & 0 deletions test/simple/test-http-multi-line-headers.js
@@ -0,0 +1,59 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

var common = require('../common');
var assert = require('assert');

var http = require('http');
var net = require('net');

var gotResponse = false;

var server = net.createServer(function(conn) {
var body = "Yet another node.js server.";

var response =
"HTTP/1.1 200 OK\r\n" +
"Connection: close\r\n" +
"Content-Length: " + body.length + "\r\n" +
"Content-Type: text/plain;\r\n" +
" x-unix-mode=0600;\r\n" +
" name=\"hello.txt\"\r\n" +
"\r\n" +
body;

conn.write(response, function() {
conn.destroy();
server.close();
});
});

server.listen(common.PORT, function() {
http.get({host:'127.0.0.1', port:common.PORT}, function(res) {
assert.equal(res.headers['content-type'],
'text/plain;x-unix-mode=0600;name="hello.txt"');
gotResponse = true;
});
});

process.on('exit', function() {
assert.ok(gotResponse);
});
8 changes: 5 additions & 3 deletions test/simple/test-querystring.js
Expand Up @@ -49,9 +49,11 @@ var qsTestCases = [
[' foo = bar ', '%20foo%20=%20bar%20', {' foo ': ' bar '}],
['foo=%zx', 'foo=%25zx', {'foo': '%zx'}],
['foo=%EF%BF%BD', 'foo=%EF%BF%BD', {'foo': '\ufffd' }],
[ 'toString=foo&valueOf=bar&__defineGetter__=baz',
'toString=foo&valueOf=bar&__defineGetter__=baz',
{ toString: 'foo',
// See: https://github.com/joyent/node/issues/1707
[ 'hasOwnProperty=x&toString=foo&valueOf=bar&__defineGetter__=baz',
'hasOwnProperty=x&toString=foo&valueOf=bar&__defineGetter__=baz',
{ hasOwnProperty: 'x',
toString: 'foo',
valueOf: 'bar',
__defineGetter__: 'baz' } ]
];
Expand Down

0 comments on commit a1bafc5

Please sign in to comment.