提交 f44d9ce6 编写于 作者: G Gary Chambers

Fixing redirect behaviour

上级 7ec97dd2
......@@ -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,
......
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',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册