From 34ce5babfdadb77b4d0825de4244e031c7d97f26 Mon Sep 17 00:00:00 2001 From: Harold Thetiot Date: Tue, 13 Jun 2017 15:26:50 -0700 Subject: [PATCH] replace options.createConnection by options.transport and Re-use transportUrl endPoint if specified --- lib/http.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/http.js b/lib/http.js index 4d4d948d..1cb5a464 100644 --- a/lib/http.js +++ b/lib/http.js @@ -982,11 +982,21 @@ Agent.prototype.request = function request(options, callback) { request.on('response', callback); } - var key = [ - !!options.plain, - options.host, - options.port - ].join(':'); + // Re-use transportUrl endPoint if specified + if (options.transportUrl && options.transport) { + key = ([ + options.transportUrl + ]).join(':'); + + // Re-use host:port endPoint + } else { + key = ([ + !!options.plain, + options.host, + options.port + ]).join(':'); + } + var self = this; // * There's an existing HTTP/2 connection to this host @@ -996,9 +1006,9 @@ Agent.prototype.request = function request(options, callback) { } // * HTTP/2 over generic stream transport - else if(options.createConnection) { + else if(options.transport) { endpoint = new Endpoint(this._log, 'CLIENT', this._settings); - endpoint.socket = options.createConnection(options); + endpoint.socket = options.transport; endpoint.socket.on('error', function (error) { self._log.error('Socket error: ' + error.toString());