compress() should honour content-coding tokens: skip compression on Accept-Encoding: gzip;q=0, and compress on Accept-Encoding: gzip, identity. Both are currently inverted.
shouldCompress in packages/event-handler/src/http/middleware/compress.ts tests the raw header with String.prototype.includes, so 'gzip;q=0'.includes('gzip') is true and the q=0 exclusion is ignored, while 'gzip, identity'.includes('identity') is true and suppresses compression the client explicitly accepted. Per RFC 9110 a q=0 coding is not acceptable.
To reproduce, send either header to any route on a Router using compress() and read content-encoding on the response:
app.use(compress());
// Accept-Encoding: gzip;q=0 -> content-encoding: gzip (should be absent)
// Accept-Encoding: gzip, identity -> content-encoding: absent (should be gzip)
One fix is to parse the header into tokens and honour qvalues, reusing the existing encoding constants. Glad to open a PR if you want it done that way.
Version 2.35.0, npm, Node 22.x. Header parsing only, so runtime-independent.
compress()should honour content-coding tokens: skip compression onAccept-Encoding: gzip;q=0, and compress onAccept-Encoding: gzip, identity. Both are currently inverted.shouldCompressinpackages/event-handler/src/http/middleware/compress.tstests the raw header withString.prototype.includes, so'gzip;q=0'.includes('gzip')istrueand theq=0exclusion is ignored, while'gzip, identity'.includes('identity')istrueand suppresses compression the client explicitly accepted. Per RFC 9110 aq=0coding is not acceptable.To reproduce, send either header to any route on a Router using
compress()and readcontent-encodingon the response:One fix is to parse the header into tokens and honour qvalues, reusing the existing encoding constants. Glad to open a PR if you want it done that way.
Version 2.35.0, npm, Node 22.x. Header parsing only, so runtime-independent.