From e25457da16a6dc74656945bd54cf39d4b3be9a5c Mon Sep 17 00:00:00 2001 From: Kevin Martensson Date: Tue, 6 Sep 2016 19:30:24 +0200 Subject: [PATCH] Add test for unexpected EOF when decompressing content --- test/gzip.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/gzip.js b/test/gzip.js index 4aeba09..33f17bc 100644 --- a/test/gzip.js +++ b/test/gzip.js @@ -31,6 +31,13 @@ test.before('setup', async () => { res.end('Not gzipped content'); }); + s.on('/missing-data', (req, res) => { + res.statusCode = 200; + res.setHeader('Content-Type', 'text/plain'); + res.setHeader('Content-Encoding', 'gzip'); + zlib.gzip(testContent, (_, data) => res.end(data.slice(0, -1))); + }); + await s.listen(s.port); }); @@ -61,6 +68,10 @@ test('do not break HEAD responses', async t => { t.is((await got.head(s.url)).body, ''); }); +test('ignore missing data', async t => { + t.is((await got(`${s.url}/missing-data`)).body, testContent); +}); + test.after('cleanup', async () => { await s.close(); });