Repository navigation
Send single JSON responses with a Content-Length - #10700
Merged
michaelstaib merged 4 commits intoOct 26, 2026
Merged
Conversation
DefaultHttpResponseFormatter now formats single application/json and application/graphql-response+json results into an internal pooled buffer, sets Content-Length, starts the response and copies the body into the response pipe (flushing at most every 1 MB). Kestrel then sends the body without chunk framing and without the separate chunk terminator send. A formatter exception still aborts the request instead of producing a 500. OnStarting callbacks now run after the body is formatted. Batch, stream, multipart, SSE and JSONL responses stay chunked.
Removes two comments that explained implementation details instead of contracts.
This was referenced Oct 28, 2026
Open
Merged
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.
Single GraphQL JSON responses were sent with chunked encoding, so after the body Kestrel had to send the closing chunk in a second, separate network write on every request. The server now formats the whole response into a pooled buffer first, sets the Content-Length header and writes the body in one go, so each response leaves in a single send and the separate end-of-response write is gone. Batched, streamed (defer, subscriptions, SSE, JSON lines) and multipart responses are unchanged, and a formatting error still aborts the request instead of sending a partial body.
Measured on the federation benchmark twin machine with the benchmark's deep-recursion query (constant 50 VUs, gateway pinned to 4 logical cores), median of 4 interleaved 60 s runs against main. This applies to every HotChocolate server, not only the Fusion gateway: single JSON responses now carry a Content-Length header instead of Transfer-Encoding: chunked.