fix(ext/http): apply automatic compression for zero-arg serve handlers#35490
Merged
nathanwhit merged 1 commit intoJun 25, 2026
Merged
Conversation
A serve handler that takes no arguments uses the native "no request" fast path, where the Request is never materialized for JS. On that path the H1 server discarded all request headers, but automatic compression is decided by reading `accept-encoding` from the stored request headers. With the headers gone, compression was always skipped for zero-arg handlers. Retain just the `accept-encoding` header on the fast path (when automatic compression is enabled) so responses are compressed as they are for handlers that take a Request.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A
Deno.servehandler that takes zero arguments uses the native "norequest" fast path, where the
Requestobject is never materialized for JS.On that path the HTTP/1.1 server discarded all request headers
(
RawRequestHeaders::empty()), but automatic compression is decided by readingaccept-encodingfrom the stored request headers. With the headers gone,raw_request_compressionalways returnedCompression::None, so responsesfrom zero-arg handlers were never compressed — even when the client supported
gzip/brotli and the body was compressible.
This retains just the
accept-encodingheader on the fast path (when automaticcompression is enabled), so the compression decision works while still avoiding
the full request-header copy /
Requestmaterialization. When automaticcompression is disabled, the headers are still skipped entirely as before.
Repro
Tests
The existing
httpServerAutomaticCompressionSkippedForNoRequestFastPathtestactually encoded the bug (it asserted compression was skipped). It's rewritten
as
httpServerAutomaticCompressionAppliesForNoRequestFastPath, assertingcontent-encoding: gzipandvary: Accept-Encoding. TheautomaticCompression: falsetests continue to assert no compression.