koa-better-http-proxy
koa-better-http-proxy copied to clipboard
fix: Handle empty gzipped response body from proxy
A HEAD
method does not have a body. If the content-encoding
is gzip
, KBHP should NOT try to unzip the response if Buffer.byteLength
is zero, or else we see this:
Error: unexpected end of file
at Zlib.zlibOnError [as onerror] (node:zlib:190:17)
at Zlib.callbackTrampoline (node:internal/async_hooks:130:17)
at processChunkSync (node:zlib:456:12)
at zlibBufferSync (node:zlib:178:12)
at Object.syncBufferWrapper [as gunzipSync] (node:zlib:791:14)
at /Users/redacted/Code/contrib/koa-better-http-proxy/app/steps/decorateUserRes.js:13:46
at decorateProxyResBody (/Users/redacted/Code/contrib/koa-better-http-proxy/app/steps/decorateUserRes.js:45:22)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
@nsimmons Can you please consider merging this PR? Thanks!