mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
Merge remote branch 'origin/v0.4'
Conflicts: deps/http_parser/http_parser.c deps/http_parser/test.c lib/repl.js
This commit is contained in:
@@ -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 = {};
|
||||
@@ -86,7 +95,7 @@ function statPath(path) {
|
||||
var packageCache = {};
|
||||
|
||||
function readPackage(requestPath) {
|
||||
if (packageCache.hasOwnProperty(requestPath)) {
|
||||
if (hasOwnProperty(packageCache, requestPath)) {
|
||||
return packageCache[requestPath];
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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];
|
||||
|
||||
10
lib/repl.js
10
lib/repl.js
@@ -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;
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
59
test/simple/test-http-multi-line-headers.js
Normal file
59
test/simple/test-http-multi-line-headers.js
Normal file
@@ -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);
|
||||
});
|
||||
@@ -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' } ]
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user