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:
@@ -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,
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user