diff --git a/test/gzip.ts b/test/gzip.ts index 2b14e35e2..8f556dd24 100644 --- a/test/gzip.ts +++ b/test/gzip.ts @@ -3,6 +3,7 @@ import zlib = require('zlib'); import test from 'ava'; import getStream = require('get-stream'); import withServer from './helpers/with-server'; +import {HTTPError} from '../source'; const testContent = 'Compressible response content.\n'; const testContentUncompressed = 'Uncompressed response content.\n'; @@ -21,6 +22,18 @@ test('decompress content', withServer, async (t, server, got) => { t.is((await got('')).body, testContent); }); +test('decompress content on error', withServer, async (t, server, got) => { + server.get('/', (_request, response) => { + response.setHeader('Content-Encoding', 'gzip'); + response.status(404); + response.end(gzipData); + }); + + const error = await t.throwsAsync(got('')); + + t.is(error.response.body, testContent); +}); + test('decompress content - stream', withServer, async (t, server, got) => { server.get('/', (_request, response) => { response.setHeader('Content-Encoding', 'gzip');