2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-05 16:42:32 +03:00

Fixing redirect behaviour

This commit is contained in:
Gary Chambers
2016-01-19 14:51:14 +00:00
parent 7ec97dd26b
commit f44d9ce677
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',