Browse Source

Lint

v0.7.4-release
seebees 13 years ago
committed by koichik
parent
commit
216570b5e1
  1. 14
      lib/http.js
  2. 8
      lib/url.js
  3. 3
      test/simple/test-http-url.parse-auth-with-header-in-request.js
  4. 3
      test/simple/test-http-url.parse-auth.js
  5. 2
      test/simple/test-http-url.parse-https.request.js
  6. 3
      test/simple/test-http-url.parse-path.js
  7. 16
      test/simple/test-http-url.parse-post.js
  8. 2
      test/simple/test-http-url.parse-search.js
  9. 2
      test/simple/test-url.js

14
lib/http.js

@ -1015,7 +1015,7 @@ function ClientRequest(options, cb) {
if (options.port && +options.port !== options.defaultPort) { if (options.port && +options.port !== options.defaultPort) {
hostHeader += ':' + options.port; hostHeader += ':' + options.port;
} }
this.setHeader("Host", hostHeader); this.setHeader('Host', hostHeader);
} }
} }
@ -1032,9 +1032,11 @@ function ClientRequest(options, cb) {
} }
if (Array.isArray(options.headers)) { if (Array.isArray(options.headers)) {
self._storeHeader(self.method + ' ' + self.path + ' HTTP/1.1\r\n', options.headers); self._storeHeader(self.method + ' ' + self.path + ' HTTP/1.1\r\n',
options.headers);
} else if (self.getHeader('expect')) { } else if (self.getHeader('expect')) {
self._storeHeader(self.method + ' ' + self.path + ' HTTP/1.1\r\n', self._renderHeaders()); self._storeHeader(self.method + ' ' + self.path + ' HTTP/1.1\r\n',
self._renderHeaders());
} }
if (self.socketPath) { if (self.socketPath) {
self._last = true; self._last = true;
@ -1060,9 +1062,9 @@ function ClientRequest(options, cb) {
} }
} }
self._deferToConnect(null, null, function () { self._deferToConnect(null, null, function() {
self._flush(); self._flush();
}) });
} }
util.inherits(ClientRequest, OutgoingMessage); util.inherits(ClientRequest, OutgoingMessage);
@ -1095,7 +1097,7 @@ function createHangUpError() {
ClientRequest.prototype.onSocket = function(socket) { ClientRequest.prototype.onSocket = function(socket) {
var req = this; var req = this;
process.nextTick(function () { process.nextTick(function() {
var parser = parsers.alloc(); var parser = parsers.alloc();
req.socket = socket; req.socket = socket;
req.connection = socket; req.connection = socket;

8
lib/url.js

@ -234,7 +234,7 @@ function urlParse(url, parseQueryString, slashesDenoteHost) {
} }
out.hostname = newOut.join('.'); out.hostname = newOut.join('.');
out.host = (out.hostname || '') + out.host = (out.hostname || '') +
((out.port) ? ':' + out.port : ''); ((out.port) ? ':' + out.port : '');
out.href += out.host; out.href += out.host;
} }
@ -419,7 +419,7 @@ function urlResolveObject(source, relative) {
//to support http.request //to support http.request
if (source.pathname !== undefined || source.search !== undefined) { if (source.pathname !== undefined || source.search !== undefined) {
source.path = (source.pathname ? source.pathname : '') + source.path = (source.pathname ? source.pathname : '') +
(source.search ? source.search : ''); (source.search ? source.search : '');
} }
source.slashes = source.slashes || relative.slashes; source.slashes = source.slashes || relative.slashes;
source.href = urlFormat(source); source.href = urlFormat(source);
@ -504,7 +504,7 @@ function urlResolveObject(source, relative) {
//to support http.request //to support http.request
if (source.pathname !== undefined || source.search !== undefined) { if (source.pathname !== undefined || source.search !== undefined) {
source.path = (source.pathname ? source.pathname : '') + source.path = (source.pathname ? source.pathname : '') +
(source.search ? source.search : ''); (source.search ? source.search : '');
} }
source.href = urlFormat(source); source.href = urlFormat(source);
return source; return source;
@ -590,7 +590,7 @@ function urlResolveObject(source, relative) {
//to support request.http //to support request.http
if (source.pathname !== undefined || source.search !== undefined) { if (source.pathname !== undefined || source.search !== undefined) {
source.path = (source.pathname ? source.pathname : '') + source.path = (source.pathname ? source.pathname : '') +
(source.search ? source.search : ''); (source.search ? source.search : '');
} }
source.auth = relative.auth || source.auth; source.auth = relative.auth || source.auth;
source.slashes = source.slashes || relative.slashes; source.slashes = source.slashes || relative.slashes;

3
test/simple/test-http-url.parse-auth-with-header-in-request.js

@ -22,7 +22,6 @@
var common = require('../common'); var common = require('../common');
var assert = require('assert'); var assert = require('assert');
var http = require('http'); var http = require('http');
var https = require('https');
var url = require('url'); var url = require('url');
var testURL = url.parse('http://asdf:qwer@localhost:' + common.PORT); var testURL = url.parse('http://asdf:qwer@localhost:' + common.PORT);
@ -45,7 +44,7 @@ var server = http.createServer(function(request, response) {
server.close(); server.close();
}); });
server.listen(common.PORT, function () { server.listen(common.PORT, function() {
// make the request // make the request
http.request(testURL).end(); http.request(testURL).end();
}); });

3
test/simple/test-http-url.parse-auth.js

@ -22,7 +22,6 @@
var common = require('../common'); var common = require('../common');
var assert = require('assert'); var assert = require('assert');
var http = require('http'); var http = require('http');
var https = require('https');
var url = require('url'); var url = require('url');
var testURL = url.parse('http://asdf:qwer@localhost:' + common.PORT); var testURL = url.parse('http://asdf:qwer@localhost:' + common.PORT);
@ -40,7 +39,7 @@ var server = http.createServer(function(request, response) {
server.close(); server.close();
}); });
server.listen(common.PORT, function () { server.listen(common.PORT, function() {
// make the request // make the request
http.request(testURL).end(); http.request(testURL).end();
}); });

2
test/simple/test-http-url.parse-https.request.js

@ -47,7 +47,7 @@ var server = https.createServer(httpsOptions, function(request, response) {
server.close(); server.close();
}); });
server.listen(common.PORT, function () { server.listen(common.PORT, function() {
// make the request // make the request
var clientRequest = https.request(testURL); var clientRequest = https.request(testURL);
// since there is a little magic with the agent // since there is a little magic with the agent

3
test/simple/test-http-url.parse-path.js

@ -22,7 +22,6 @@
var common = require('../common'); var common = require('../common');
var assert = require('assert'); var assert = require('assert');
var http = require('http'); var http = require('http');
var https = require('https');
var url = require('url'); var url = require('url');
var testURL = url.parse('http://localhost:' + common.PORT + '/asdf'); var testURL = url.parse('http://localhost:' + common.PORT + '/asdf');
@ -40,7 +39,7 @@ var server = http.createServer(function(request, response) {
server.close(); server.close();
}); });
server.listen(common.PORT, function () { server.listen(common.PORT, function() {
// make the request // make the request
http.request(testURL).end(); http.request(testURL).end();
}); });

16
test/simple/test-http-url.parse-post.js

@ -29,13 +29,13 @@ var testURL = url.parse('http://localhost:' + common.PORT + '/asdf?qwer=zxcv');
testURL.method = 'POST'; testURL.method = 'POST';
function check(request) { function check(request) {
//url.parse should not mess with the method //url.parse should not mess with the method
assert.strictEqual(request.method, 'POST'); assert.strictEqual(request.method, 'POST');
//everything else should be right //everything else should be right
assert.strictEqual(request.url, '/asdf?qwer=zxcv'); assert.strictEqual(request.url, '/asdf?qwer=zxcv');
//the host header should use the url.parse.hostname //the host header should use the url.parse.hostname
assert.strictEqual(request.headers.host, assert.strictEqual(request.headers.host,
testURL.hostname + ':' + testURL.port); testURL.hostname + ':' + testURL.port);
} }
var server = http.createServer(function(request, response) { var server = http.createServer(function(request, response) {
@ -46,7 +46,7 @@ var server = http.createServer(function(request, response) {
server.close(); server.close();
}); });
server.listen(common.PORT, function () { server.listen(common.PORT, function() {
// make the request // make the request
http.request(testURL).end(); http.request(testURL).end();
}); });

2
test/simple/test-http-url.parse-search.js

@ -40,7 +40,7 @@ var server = http.createServer(function(request, response) {
server.close(); server.close();
}); });
server.listen(common.PORT, function () { server.listen(common.PORT, function() {
// make the request // make the request
http.request(testURL).end(); http.request(testURL).end();
}); });

2
test/simple/test-url.js

@ -989,7 +989,7 @@ relativeTests.forEach(function(relativeTest) {
if (relativeTests2[181][0] === './/g' && if (relativeTests2[181][0] === './/g' &&
relativeTests2[181][1] === 'f:/a' && relativeTests2[181][1] === 'f:/a' &&
relativeTests2[181][2] === 'f://g') { relativeTests2[181][2] === 'f://g') {
relativeTests2.splice(181,1); relativeTests2.splice(181, 1);
} }
relativeTests2.forEach(function(relativeTest) { relativeTests2.forEach(function(relativeTest) {
var actual = url.resolveObject(url.parse(relativeTest[1]), relativeTest[0]), var actual = url.resolveObject(url.parse(relativeTest[1]), relativeTest[0]),

Loading…
Cancel
Save