From ed300a4c033d48f55575dc2654ff0a19b2960fee Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 27 Jun 2017 16:29:07 -0700 Subject: [PATCH] only set ALPNProtocols when the property does not already exist I guess maybe you could do `ALPNProtocols: null` to opt-out of this new behavior. Not sure if it's really necessary but hey. --- index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index dd22ec64..3448b71d 100644 --- a/index.js +++ b/index.js @@ -41,8 +41,10 @@ function HttpsProxyAgent(opts) { proxy.host = proxy.hostname || proxy.host; proxy.port = +proxy.port || (this.secureProxy ? 443 : 80); - if (this.secureProxy) { - proxy.ALPNProtocols = proxy.ALPNProtocols || ['http 1.1'] + // ALPN is supported by Node.js >= v5. + // attempt to negotiate http/1.1 for proxy servers that support http/2 + if (this.secureProxy && !('ALPNProtocols' in proxy)) { + proxy.ALPNProtocols = ['http 1.1'] } if (proxy.host && proxy.path) {