diff --git a/lib/adapters/http.js b/lib/adapters/http.js index 21b02ae1d2d7712b17e9aa070fd7ceb76634eb7a..bf0183103cb0db85642316c577bc228cf96122d6 100644 --- a/lib/adapters/http.js +++ b/lib/adapters/http.js @@ -62,6 +62,10 @@ module.exports = function httpAdapter(config) { auth = urlUsername + ':' + urlPassword; } + if (auth) { + delete headers.Authorization; + } + var isHttps = parsed.protocol === 'https:'; var agent = isHttps ? config.httpsAgent : config.httpAgent; diff --git a/test/unit/adapters/http.js b/test/unit/adapters/http.js index 4ef91b761bd501017180f4317bd0b20680d22006..36d734d2f5329d1f5f7c673288fbbaffa065df12 100644 --- a/test/unit/adapters/http.js +++ b/test/unit/adapters/http.js @@ -168,7 +168,8 @@ module.exports = { res.end(req.headers.authorization); }).listen(4444, function () { var user = 'foo'; - axios.get('http://' + user + '@localhost:4444/').then(function (res) { + var headers = { Authorization: 'Bearer 1234' }; + axios.get('http://' + user + '@localhost:4444/', { headers: headers }).then(function (res) { var base64 = new Buffer(user + ':', 'utf8').toString('base64'); test.equal(res.data, 'Basic ' + base64); test.done(); @@ -176,6 +177,20 @@ module.exports = { }); }, + testBasicAuthWithHeader: function (test) { + server = http.createServer(function (req, res) { + res.end(req.headers.authorization); + }).listen(4444, function () { + var auth = { username: 'foo', password: 'bar' }; + var headers = { Authorization: 'Bearer 1234' }; + axios.get('http://localhost:4444/', { auth: auth, headers: headers }).then(function (res) { + var base64 = new Buffer('foo:bar', 'utf8').toString('base64'); + test.equal(res.data, 'Basic ' + base64); + test.done(); + }); + }); + }, + testMaxContentLength: function(test) { var str = Array(100000).join('ж');