2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-24 14:04:14 +03:00

Merge pull request #198 from gschambers/redirect-hostname

Fixes redirect behavior to correctly set host
/port
This commit is contained in:
Matt Zabriskie
2016-01-19 08:32:08 -07:00
2 changed files with 23 additions and 1 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ module.exports = function httpAdapter(resolve, reject, config) {
// Parse url
var parsed = url.parse(config.url);
var options = {
host: parsed.hostname,
hostname: parsed.hostname,
port: parsed.port,
path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
method: config.method,
+22
View File
@@ -1,5 +1,6 @@
var axios = require('../../../index');
var http = require('http');
var url = require('url');
var zlib = require('zlib');
var server;
@@ -28,6 +29,27 @@ module.exports = {
});
},
testRedirect: function (test) {
var str = 'test response';
server = http.createServer(function (req, res) {
var parsed = url.parse(req.url);
if (parsed.pathname === '/one') {
res.setHeader('Location', '/two');
res.statusCode = 302;
res.end();
} else {
res.end(str);
}
}).listen(4444, function () {
axios.get('http://localhost:4444/one').then(function (res) {
test.equal(res.data, str);
test.done();
});
});
},
testTransparentGunzip: function (test) {
var data = {
firstName: 'Fred',