Skip to content

Commit 1ccdde9

Browse files
committed
Revert "http/https: pass request to .createConnection()"
This reverts commit 53716eb.
1 parent 93d496a commit 1ccdde9

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

lib/http.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ Agent.prototype.addRequest = function(req, host, port, localAddress) {
10671067
}
10681068
if (this.sockets[name].length < this.maxSockets) {
10691069
// If we are under maxSockets create a new one.
1070-
req.onSocket(this.createSocket(name, host, port, localAddress, req));
1070+
req.onSocket(this.createSocket(name, host, port, localAddress));
10711071
} else {
10721072
// We are over limit so we'll add it to the queue.
10731073
if (!this.requests[name]) {
@@ -1076,13 +1076,13 @@ Agent.prototype.addRequest = function(req, host, port, localAddress) {
10761076
this.requests[name].push(req);
10771077
}
10781078
};
1079-
Agent.prototype.createSocket = function(name, host, port, localAddress, req) {
1079+
Agent.prototype.createSocket = function(name, host, port, localAddress) {
10801080
var self = this;
10811081
var options = util._extend({}, self.options);
10821082
options.port = port;
10831083
options.host = host;
10841084
options.localAddress = localAddress;
1085-
var s = self.createConnection.call(req, options);
1085+
var s = self.createConnection(options);
10861086
if (!self.sockets[name]) {
10871087
self.sockets[name] = [];
10881088
}
@@ -1123,11 +1123,7 @@ Agent.prototype.removeSocket = function(s, name, host, port, localAddress) {
11231123
}
11241124
if (this.requests[name] && this.requests[name].length) {
11251125
// If we have pending requests and a socket gets closed a new one
1126-
this.createSocket(name,
1127-
host,
1128-
port,
1129-
localAddress,
1130-
this.requests[name][0]).emit('free');
1126+
this.createSocket(name, host, port, localAddress).emit('free');
11311127
}
11321128
};
11331129

@@ -1139,7 +1135,6 @@ function ClientRequest(options, cb) {
11391135
var self = this;
11401136
OutgoingMessage.call(self);
11411137

1142-
this.options = util._extend({}, options);
11431138
self.agent = options.agent === undefined ? globalAgent : options.agent;
11441139

11451140
var defaultPort = options.defaultPort || 80;
@@ -1199,7 +1194,7 @@ function ClientRequest(options, cb) {
11991194
self._last = true;
12001195
self.shouldKeepAlive = false;
12011196
if (options.createConnection) {
1202-
self.onSocket(options.createConnection.call(self, self.socketPath));
1197+
self.onSocket(options.createConnection(self.socketPath));
12031198
} else {
12041199
self.onSocket(net.createConnection(self.socketPath));
12051200
}
@@ -1215,7 +1210,7 @@ function ClientRequest(options, cb) {
12151210
if (options.createConnection) {
12161211
options.port = port;
12171212
options.host = host;
1218-
var conn = options.createConnection.call(self, options);
1213+
var conn = options.createConnection(options);
12191214
} else {
12201215
var conn = net.createConnection({
12211216
port: port,

lib/https.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121

2222
var tls = require('tls');
2323
var http = require('http');
24-
var util = require('util');
25-
var inherits = util.inherits;
24+
var inherits = require('util').inherits;
2625

2726
function Server(opts, requestListener) {
2827
if (!(this instanceof Server)) return new Server(opts, requestListener);
@@ -53,15 +52,15 @@ exports.createServer = function(opts, requestListener) {
5352
// HTTPS agents.
5453

5554
function createConnection(/* [port, host, options] */) {
56-
var options = util._extend({}, this.options);
55+
var options = {};
5756

5857
if (typeof arguments[0] === 'object') {
59-
options = util._extend(options, arguments[0]);
58+
options = arguments[0];
6059
} else if (typeof arguments[1] === 'object') {
61-
options = util._extend(options, arguments[1]);
60+
options = arguments[1];
6261
options.port = arguments[0];
6362
} else if (typeof arguments[2] === 'object') {
64-
options = util._extend(options, arguments[2]);
63+
options = arguments[2];
6564
options.port = arguments[0];
6665
options.host = arguments[1];
6766
} else {

0 commit comments

Comments
 (0)