diff --git a/server/providers/common/compress.js b/server/providers/common/compress.js index d9938b87e..cbce21c6e 100644 --- a/server/providers/common/compress.js +++ b/server/providers/common/compress.js @@ -54,8 +54,7 @@ export function acceptsGzip(request) { * @returns {Promise} */ export async function gzipBody(body) { - if (body == null) return null; - const raw = Buffer.isBuffer(body) ? body : Buffer.from(String(body)); + const raw = Buffer.isBuffer(body) ? body : Buffer.from(body); if (raw.byteLength < MIN_COMPRESSED_BYTES) return null; const compressed = await gzipAsync(raw); return compressed.byteLength < raw.byteLength ? compressed : null; diff --git a/src/tooling/responseCompression.test.mjs b/src/tooling/responseCompression.test.mjs index 6fbd53193..011d767c3 100644 --- a/src/tooling/responseCompression.test.mjs +++ b/src/tooling/responseCompression.test.mjs @@ -81,8 +81,6 @@ test('accept-encoding is read the way clients actually write it', () => { }); test('a body is only compressed when compression pays for itself', async () => { - assert.equal(await gzipBody(null), null); - assert.equal(await gzipBody(undefined), null); assert.equal(await gzipBody(''), null); assert.equal( await gzipBody('{"states":[]}'),