Repository navigation
fix(http): close response bodies on rejected statuses - #157
Merged
rvagg merged 1 commit intoOct 5, 2026
Merged
Conversation
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.
I run Live Tennis API.
HTTP status errors return before the client schedules response body cleanup. Repeated 401 or 429 responses can therefore leave bodies open.
Move the existing close defer immediately after a successful Do call. This covers ordinary calls and notifications. Status handling stays the same.
All 12 rejected response cases fail on the original code and pass with the fix. Five controls cover successful responses and error decoding.
I ran
go test -shuffle=on -race -v -count=1 ./...in Docker on Go 1.25.14 and 1.26.8. Both pass 112 tests and subtests. The existing large result test skips unlessI_HAVE_A_LOT_OF_MEMORY_AND_TIME=1is set.Build and vet pass on both versions. Formatting, module tidiness and the workflow's pinned staticcheck pass.