http: fix permanent deoptimizations
PR-URL: https://github.com/nodejs/node/pull/12456 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
7a5bac5d36
commit
e283319969
@ -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
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user