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:
@@ -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
@@ -59,5 +59,7 @@ module.exports = {
|
||||
timeout: 0,
|
||||
|
||||
xsrfCookieName: 'XSRF-TOKEN',
|
||||
xsrfHeaderName: 'X-XSRF-TOKEN'
|
||||
xsrfHeaderName: 'X-XSRF-TOKEN',
|
||||
|
||||
maxContentLength: -1
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user