Skip to content

Commit e283319

Browse files
committed
http: fix permanent deoptimizations
PR-URL: #12456 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 7a5bac5 commit e283319

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

lib/_http_agent.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,14 @@ Agent.prototype.getName = function getName(options) {
130130
return name;
131131
};
132132

133-
Agent.prototype.addRequest = function addRequest(req, options) {
133+
Agent.prototype.addRequest = function addRequest(req, options, port/*legacy*/,
134+
localAddress/*legacy*/) {
134135
// Legacy API: addRequest(req, host, port, localAddress)
135136
if (typeof options === 'string') {
136137
options = {
137138
host: options,
138-
port: arguments[2],
139-
localAddress: arguments[3]
139+
port,
140+
localAddress
140141
};
141142
}
142143

lib/_http_client.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ function ClientRequest(options, cb) {
127127
'Expected "' + expectedProtocol + '"');
128128
}
129129

130-
const defaultPort = options.defaultPort ||
131-
this.agent && this.agent.defaultPort;
130+
var defaultPort = options.defaultPort ||
131+
this.agent && this.agent.defaultPort;
132132

133133
var port = options.port = options.port || defaultPort || 80;
134134
var host = options.host = validateHost(options.hostname, 'hostname') ||
@@ -226,7 +226,7 @@ function ClientRequest(options, cb) {
226226

227227
var called = false;
228228

229-
const oncreate = (err, socket) => {
229+
var oncreate = (err, socket) => {
230230
if (called)
231231
return;
232232
called = true;
@@ -238,14 +238,15 @@ function ClientRequest(options, cb) {
238238
this._deferToConnect(null, null, () => this._flush());
239239
};
240240

241+
var newSocket;
241242
if (this.socketPath) {
242243
this._last = true;
243244
this.shouldKeepAlive = false;
244-
const optionsPath = {
245+
var optionsPath = {
245246
path: this.socketPath,
246247
timeout: this.timeout
247248
};
248-
const newSocket = this.agent.createConnection(optionsPath, oncreate);
249+
newSocket = this.agent.createConnection(optionsPath, oncreate);
249250
if (newSocket && !called) {
250251
called = true;
251252
this.onSocket(newSocket);
@@ -270,7 +271,7 @@ function ClientRequest(options, cb) {
270271
this._last = true;
271272
this.shouldKeepAlive = false;
272273
if (typeof options.createConnection === 'function') {
273-
const newSocket = options.createConnection(options, oncreate);
274+
newSocket = options.createConnection(options, oncreate);
274275
if (newSocket && !called) {
275276
called = true;
276277
this.onSocket(newSocket);

0 commit comments

Comments
 (0)