Fix caching of bodyless HTTP responses - #194
Conversation
Bumps [github.com/elazarl/goproxy](https://github.com/elazarl/goproxy) from 0.0.0-20240726154733-8b0c20506380 to 1.9.0. - [Release notes](https://github.com/elazarl/goproxy/releases) - [Commits](https://github.com/elazarl/goproxy/commits/v1.9.0) --- updated-dependencies: - dependency-name: github.com/elazarl/goproxy dependency-version: 1.9.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
There was a problem hiding this comment.
Pull request overview
Fixes caching of bodyless responses while upgrading goproxy to v1.9.0.
Changes:
- Preserves
http.NoBodyfor HEAD, 204, and 304 responses. - Adds regression coverage for bodyless responses.
- Vendors goproxy v1.9.0 and its HTTP/2-related changes.
Show a summary per file
| File | Description |
|---|---|
internal/cache/handlers.go |
Bypasses caching for bodyless responses. |
internal/cache/handlers_test.go |
Tests body preservation and cleanup. |
go.mod |
Upgrades goproxy. |
go.sum |
Updates dependency checksums. |
vendor/modules.txt |
Updates vendored module metadata. |
vendor/github.com/elazarl/goproxy/.golangci.yml |
Adds upstream lint configuration. |
vendor/github.com/elazarl/goproxy/README.md |
Updates upstream documentation. |
vendor/github.com/elazarl/goproxy/actions.go |
Updates handler documentation. |
vendor/github.com/elazarl/goproxy/certs.go |
Updates CA initialization. |
vendor/github.com/elazarl/goproxy/chunked.go |
Removes obsolete chunk writer. |
vendor/github.com/elazarl/goproxy/ctx.go |
Extends proxy context behavior. |
vendor/github.com/elazarl/goproxy/dispatcher.go |
Updates request conditions. |
vendor/github.com/elazarl/goproxy/doc.go |
Updates package examples. |
vendor/github.com/elazarl/goproxy/h2.go |
Removes legacy HTTP/2 transport. |
vendor/github.com/elazarl/goproxy/http.go |
Adds HTTP response forwarding logic. |
vendor/github.com/elazarl/goproxy/http2.go |
Adds HTTP/2 MITM support. |
vendor/github.com/elazarl/goproxy/https.go |
Updates CONNECT and MITM handling. |
vendor/github.com/elazarl/goproxy/internal/http1parser/header.go |
Adds HTTP/1 header parsing. |
vendor/github.com/elazarl/goproxy/internal/http1parser/request.go |
Adds request parsing support. |
vendor/github.com/elazarl/goproxy/internal/signer/counterecryptor.go |
Moves and extends signer utilities. |
vendor/github.com/elazarl/goproxy/internal/signer/signer.go |
Adds internal certificate signing. |
vendor/github.com/elazarl/goproxy/logger.go |
Updates logger documentation and types. |
vendor/github.com/elazarl/goproxy/proxy.go |
Refactors proxy dispatch and configuration. |
vendor/github.com/elazarl/goproxy/responses.go |
Modernizes response construction. |
vendor/github.com/elazarl/goproxy/signer.go |
Removes superseded signer implementation. |
vendor/github.com/elazarl/goproxy/websocket.go |
Refactors WebSocket proxying. |
Review details
Tip
Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 3/26 changed files
- Comments generated: 1
- Review effort level: Balanced
kbukum1
left a comment
There was a problem hiding this comment.
Before this we need to understand breaking change happened in the goproxy so accordingly we should be able to check the root cause of this error happening
@thavaahariharangit My concern is that the real problem most likely isn't that we're legitimately receiving bodyless/empty responses. It seems more likely that something in the new proxy behavior is causing crates.io to return these responses in the first place — possibly because our implementation is now generating far more requests than before, triggering rate limiting or similar server-side behavior. So instead of defensively wrapping/skipping these responses, we should understand what actually changed in In summary, I think we need to:
|
|
closing this PR, as this implementation is covered here: #200 |
What are you trying to accomplish?
Prevent the proxy cache from turning bodyless HTTP responses into responses with a wrapped body.
When using newer versions of
goproxy(https://github.com/elazarl/goproxy), wrapping the body of a 304 Not Modified response can cause it to be serialized with chunked body data. This corrupts persistent HTTP connections and causes clients such as Cargo to fail with:The change preserves
http.NoBodyfor HEAD requests and responses with statuses that do not permit a body, including1xx,204, and304.Anything you want to highlight for special attention from reviewers?
This is a defensive fix at the cache boundary. Although
goproxyshould enforce bodyless response semantics during serialization, the cache should not wrap or cache a body that HTTP semantics prohibit.The response’s original body is still closed so resources are released correctly.
How will you know you've accomplished your goal?
Regression tests verify that bodyless responses:
http.NoBodyThe focused cache tests and full Go test suite pass.
The original failure was reproduced using Dependabot job
1404166863. After applying this change and rerunning the same job with the updated proxy image, the Cargo update completed without theInvalid status lineerror.using this PR Branch: #184
set -o pipefail && dependabot update -f input.yml --proxy-image=my-proxy-fix -o output.yml 2>&1 | tee tofile.txtAfter fix:
Checklist