diff --git a/index.js b/index.js index 516b35e7c..f450cd221 100755 --- a/index.js +++ b/index.js @@ -46,7 +46,7 @@ function initParams (uri, options, callback) { } // Disable flow when running in browser - if (!tls.connect) { + if (typeof window !== 'undefined' && window.XMLHttpRequest) { params.protocolVersion = 'http1' } diff --git a/lib/http2/http2Agent.js b/lib/http2/agent.js similarity index 100% rename from lib/http2/http2Agent.js rename to lib/http2/agent.js diff --git a/lib/http2/index.js b/lib/http2/index.js index 1807d6e27..9e85d7d29 100644 --- a/lib/http2/index.js +++ b/lib/http2/index.js @@ -1,4 +1,4 @@ -const { Http2Agent, globalAgent } = require('./http2Agent') +const { Http2Agent, globalAgent } = require('./agent') const { request } = require('./request') module.exports = { diff --git a/lib/http2/request.js b/lib/http2/request.js index 33521a082..5890bed70 100644 --- a/lib/http2/request.js +++ b/lib/http2/request.js @@ -1,7 +1,7 @@ const url = require('url') const http2 = require('http2') const { EventEmitter } = require('events') -const { globalAgent } = require('./http2Agent') +const { globalAgent } = require('./agent') const { assertValidPseudoHeader, checkIsHttpToken } = require('../autohttp/utils/headers') function httpOptionsToUri (options) { diff --git a/lib/redirect.js b/lib/redirect.js index 6a78c6eff..aeaa6bd90 100644 --- a/lib/redirect.js +++ b/lib/redirect.js @@ -210,8 +210,6 @@ Redirect.prototype.onResponse = function (response) { request.emit('redirect') - options.protocolVersion = this.request.protocolVersion - // Wait for request to end before firing redirect request request._redirectPromise .then(() => {