From bbfa7bfaccff368dd3666f32fb47773f863ec242 Mon Sep 17 00:00:00 2001 From: Tim Garthwaite Date: Wed, 10 Jan 2018 19:01:56 -0500 Subject: [PATCH 1/3] Fixing maxBodyLength exceeded error form follow-redirects when axios's maxContentLength is not exceeded --- lib/adapters/http.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/adapters/http.js b/lib/adapters/http.js index f6d7067240..22b9878015 100644 --- a/lib/adapters/http.js +++ b/lib/adapters/http.js @@ -128,6 +128,10 @@ module.exports = function httpAdapter(config) { transport = isHttps ? httpsFollow : httpFollow; } + if (config.maxContentLength) { + options.maxBodyLength = config.maxContentLength; + } + // Create the request var req = transport.request(options, function handleResponse(res) { if (req.aborted) return; From e452f761f7c9edbd9e4e73493373f427b0fb5141 Mon Sep 17 00:00:00 2001 From: Tim Garthwaite Date: Thu, 11 Jan 2018 10:44:40 -0500 Subject: [PATCH 2/3] Don't set maxBodyLength in follow-redirects if maxContentLength is -1 --- lib/adapters/http.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/adapters/http.js b/lib/adapters/http.js index 22b9878015..ce9137f037 100644 --- a/lib/adapters/http.js +++ b/lib/adapters/http.js @@ -128,7 +128,7 @@ module.exports = function httpAdapter(config) { transport = isHttps ? httpsFollow : httpFollow; } - if (config.maxContentLength) { + if (config.maxContentLength && maxBodyLength > -1) { options.maxBodyLength = config.maxContentLength; } From 89bf42b946a6bf5344801cf72a60b0a15cab49e1 Mon Sep 17 00:00:00 2001 From: Tim Garthwaite Date: Thu, 11 Jan 2018 12:54:29 -0500 Subject: [PATCH 3/3] Fix typo --- lib/adapters/http.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/adapters/http.js b/lib/adapters/http.js index ce9137f037..69e8e7474d 100644 --- a/lib/adapters/http.js +++ b/lib/adapters/http.js @@ -128,7 +128,7 @@ module.exports = function httpAdapter(config) { transport = isHttps ? httpsFollow : httpFollow; } - if (config.maxContentLength && maxBodyLength > -1) { + if (config.maxContentLength && config.maxContentLength > -1) { options.maxBodyLength = config.maxContentLength; }