From 0d4fca085b9b44e110f4c5a3dd7384c31abaf756 Mon Sep 17 00:00:00 2001 From: Gadzhi Gadzhiev Date: Tue, 7 May 2019 22:20:34 +0300 Subject: [PATCH] Destroy stream on exceeding maxContentLength (fixes #1098) (#1485) --- lib/adapters/http.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/adapters/http.js b/lib/adapters/http.js index d39a573..e302bc0 100755 --- a/lib/adapters/http.js +++ b/lib/adapters/http.js @@ -216,6 +216,7 @@ module.exports = function httpAdapter(config) { // make sure the content length is not over the maxContentLength if specified if (config.maxContentLength > -1 && Buffer.concat(responseBuffer).length > config.maxContentLength) { + stream.destroy(); reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded', config, null, lastRequest)); }