diff --git a/lib/_http_agent.js b/lib/_http_agent.js index 351417a7ba6a74..88f4df402a9b80 100644 --- a/lib/_http_agent.js +++ b/lib/_http_agent.js @@ -130,13 +130,14 @@ Agent.prototype.getName = function getName(options) { return name; }; -Agent.prototype.addRequest = function addRequest(req, options) { +Agent.prototype.addRequest = function addRequest(req, options, port/*legacy*/, + localAddress/*legacy*/) { // Legacy API: addRequest(req, host, port, localAddress) if (typeof options === 'string') { options = { host: options, - port: arguments[2], - localAddress: arguments[3] + port, + localAddress }; } diff --git a/lib/_http_client.js b/lib/_http_client.js index 42387d0930b583..e1f064e832d224 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -127,8 +127,8 @@ function ClientRequest(options, cb) { 'Expected "' + expectedProtocol + '"'); } - const defaultPort = options.defaultPort || - this.agent && this.agent.defaultPort; + var defaultPort = options.defaultPort || + this.agent && this.agent.defaultPort; var port = options.port = options.port || defaultPort || 80; var host = options.host = validateHost(options.hostname, 'hostname') || @@ -226,7 +226,7 @@ function ClientRequest(options, cb) { var called = false; - const oncreate = (err, socket) => { + var oncreate = (err, socket) => { if (called) return; called = true; @@ -238,14 +238,15 @@ function ClientRequest(options, cb) { this._deferToConnect(null, null, () => this._flush()); }; + var newSocket; if (this.socketPath) { this._last = true; this.shouldKeepAlive = false; - const optionsPath = { + var optionsPath = { path: this.socketPath, timeout: this.timeout }; - const newSocket = this.agent.createConnection(optionsPath, oncreate); + newSocket = this.agent.createConnection(optionsPath, oncreate); if (newSocket && !called) { called = true; this.onSocket(newSocket); @@ -270,7 +271,7 @@ function ClientRequest(options, cb) { this._last = true; this.shouldKeepAlive = false; if (typeof options.createConnection === 'function') { - const newSocket = options.createConnection(options, oncreate); + newSocket = options.createConnection(options, oncreate); if (newSocket && !called) { called = true; this.onSocket(newSocket);