mirror of
https://github.com/tenrok/axios.git
synced 2026-06-08 17:22:34 +03:00
Adding config option to restrict based on the size of the response co…
This commit is contained in:
@@ -127,4 +127,31 @@ module.exports = {
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
testMaxContentLength: function(test) {
|
||||
var str = Array(100000).join('ж');
|
||||
|
||||
server = http.createServer(function (req, res) {
|
||||
res.setHeader('Content-Type', 'text/html; charset=UTF-8');
|
||||
res.end(str);
|
||||
}).listen(4444, function () {
|
||||
var success = false, failure = false, error;
|
||||
|
||||
axios.get('http://localhost:4444/', {
|
||||
maxContentLength: 2000
|
||||
}).then(function (res) {
|
||||
success = true;
|
||||
}).catch(function (res) {
|
||||
error = res;
|
||||
failure = true;
|
||||
});
|
||||
|
||||
setTimeout(function () {
|
||||
test.equal(success, false, 'request should not succeed');
|
||||
test.equal(failure, true, 'request should fail');
|
||||
test.equal(error.message, 'maxContentLength size of 2000 exceeded');
|
||||
test.done();
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user