Skip to content

Commit 074fdd3

Browse files
Fix http2 agent doesn't work with http2.get
1 parent 202d32e commit 074fdd3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/http.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,12 @@ function getTLS(options, callback) {
861861
if (options.protocol && options.protocol !== "https:") {
862862
throw new Error('This interface only supports https-schemed URLs');
863863
}
864-
return (options.agent || exports.globalAgent).get(options, callback);
864+
if (options.agent && typeof(options.agent.get) === 'function') {
865+
var agentOptions = util._extend({}, options);
866+
delete agentOptions.agent;
867+
return options.agent.get(agentOptions, callback);
868+
}
869+
return exports.globalAgent.get(options, callback);
865870
}
866871

867872
// Agent class

0 commit comments

Comments
 (0)