Repository navigation
fix(net): preserve response status before decoding gzip - #2903
Open
pcbeingused33 wants to merge 1 commit into
Open
pcbeingused33 wants to merge 1 commit into
pcbeingused33 wants to merge 1 commit into
Conversation
Author
|
Hi, just a gentle ping on this one in case it slipped through. Happy to adjust anything if needed. Thanks! |
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.
Preserve the HTTP status and response headers when a gzip response cannot be initialized.
Dispatcher.docurrently records response metadata after constructing the gzip reader. If the endpoint sendsContent-Encoding: gzipwith an invalid gzip header (for example a non-gzip or empty body), or the response size limit truncates the gzip header, it returns an error withStatusCodestill zero despite receiving an HTTP response. At-most-once delivery treats that zero as no response and can retry a delivery the endpoint already accepted.Capture the status and headers as soon as
client.Dosucceeds, before decoding the body. Decoding errors still propagate; successful responses and transport errors retain their existing handling. No configuration or API changes are required.Testing and validation
go test ./net -run '^TestDispatcherDoPreservesHeadersOnInvalidGzip$' -count=1: both cases fail before the fix (status 0) and pass afterward.go test ./net -count=1: passes.go test -race ./net -count=1: passes (includes the default vet checks).AI assistance: this change and regression tests were prepared using Codex.