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());