From 521444513969a08ec5ef943c41ba0812845ed4f9 Mon Sep 17 00:00:00 2001 From: Xianming Zhong Date: Sat, 29 Feb 2020 19:54:41 +0800 Subject: [PATCH] Add test for redirecting with too large response (#2695) --- test/unit/adapters/http.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test/unit/adapters/http.js b/test/unit/adapters/http.js index 7e02c79..2623173 100644 --- a/test/unit/adapters/http.js +++ b/test/unit/adapters/http.js @@ -261,6 +261,41 @@ describe('supports http with nodejs', function () { }); }); + it('should support max content length for redirected', function (done) { + var str = Array(100000).join('ж'); + + server = http.createServer(function (req, res) { + var parsed = url.parse(req.url); + + if (parsed.pathname === '/two') { + res.setHeader('Content-Type', 'text/html; charset=UTF-8'); + res.end(str); + } else { + res.setHeader('Location', '/two'); + res.statusCode = 302; + res.end(); + } + }).listen(4444, function () { + var success = false, failure = false, error; + + axios.get('http://localhost:4444/one', { + maxContentLength: 2000 + }).then(function (res) { + success = true; + }).catch(function (err) { + error = err; + failure = true; + }); + + setTimeout(function () { + assert.equal(success, false, 'request should not succeed'); + assert.equal(failure, true, 'request should fail'); + assert.equal(error.message, 'maxContentLength size of 2000 exceeded'); + done(); + }, 100); + }); + }); + it.skip('should support sockets', function (done) { server = net.createServer(function (socket) { socket.on('data', function () {