2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-11 18:02:32 +03:00

Adding config option to restrict based on the size of the response co…

This commit is contained in:
bomsy
2016-03-22 18:28:51 +00:00
parent 104276ffa7
commit fefa23a8dd
4 changed files with 39 additions and 2 deletions
+5
View File
@@ -90,6 +90,11 @@ module.exports = function httpAdapter(resolve, reject, config) {
var responseBuffer = [];
stream.on('data', function handleStreamData(chunk) {
responseBuffer.push(chunk);
// make sure the content length is not over the maxContentLength if specified
if (config.maxContentLength > -1 && Buffer.concat(responseBuffer).length > config.maxContentLength) {
reject(new Error('maxContentLength size of ' + config.maxContentLength + ' exceeded'));
}
});
stream.on('end', function handleStreamEnd() {
+3 -1
View File
@@ -59,5 +59,7 @@ module.exports = {
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN'
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1
};