From 79a1ed204f4c2971b573edde816b3a43b25240da Mon Sep 17 00:00:00 2001 From: Gadzhi Gadzhiev Date: Sun, 15 Apr 2018 17:03:38 +0300 Subject: [PATCH] Destroy stream on exceeding maxContentLength (fixes #1098) --- lib/adapters/http.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/adapters/http.js b/lib/adapters/http.js index 0fe6a7dc79..42b2cb39a2 100755 --- a/lib/adapters/http.js +++ b/lib/adapters/http.js @@ -185,6 +185,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)); }