2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-15 11:59:42 +03:00

Add test for redirecting with too large response (#2695)

This commit is contained in:
Xianming Zhong
2020-02-29 19:54:41 +08:00
committed by GitHub
parent ac777b13b0
commit 5214445139
+35
View File
@@ -261,6 +261,41 @@ describe('supports http with nodejs', function () {
});
});
it('should support max content length for redirected', function (done) {
var str = Array(100000).join('ж');
server = http.createServer(function (req, res) {
var parsed = url.parse(req.url);
if (parsed.pathname === '/two') {
res.setHeader('Content-Type', 'text/html; charset=UTF-8');
res.end(str);
} else {
res.setHeader('Location', '/two');
res.statusCode = 302;
res.end();
}
}).listen(4444, function () {
var success = false, failure = false, error;
axios.get('http://localhost:4444/one', {
maxContentLength: 2000
}).then(function (res) {
success = true;
}).catch(function (err) {
error = err;
failure = true;
});
setTimeout(function () {
assert.equal(success, false, 'request should not succeed');
assert.equal(failure, true, 'request should fail');
assert.equal(error.message, 'maxContentLength size of 2000 exceeded');
done();
}, 100);
});
});
it.skip('should support sockets', function (done) {
server = net.createServer(function (socket) {
socket.on('data', function () {