Skip to content

Close HTTP response bodies when loading compressed HTML - #83

Merged
zhengchun merged 1 commit into
antchfx:masterfrom
bensynapse:fix-response-body-close
Oct 14, 2026
Merged

zhengchun merged 1 commit into
antchfx:masterfrom
bensynapse:fix-response-body-close

Conversation

@bensynapse

Copy link
Copy Markdown
Contributor

I run Live Tennis API.

LoadURLWithClient closes the selected decompressor, which leaves the underlying HTTP response body open. Invalid compression and unsupported encodings also return without closing the body.

Close the response body after every successful client.Do call and close each decompressor separately. Plain responses still close once.

The regression test covers plain, gzip and deflate responses, invalid compression, unsupported encoding and a read failure. Successful cases also verify the parsed document.

Checks passed on Linux:

  • go test . -v -cover on Go 1.23.4 and 1.24.2.
  • go test -race ./... on Go 1.23.4.

Both coverage runs report 73.6%. go vet ./... reports an existing testing.T.Fatalf call from a goroutine at query_test.go:210. The unmodified upstream commit reports the same warning.

@zhengchun
zhengchun merged commit 078f635 into antchfx:master Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants