mirror of
https://github.com/tenrok/axios.git
synced 2026-06-14 18:42:33 +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() {
|
||||
|
||||
Reference in New Issue
Block a user