Skip to content

fix: centralize pass-through response relaying - #380

Open
abhinavgautam01 wants to merge 1 commit into
git-pkgs:mainfrom
abhinavgautam01:fix/response-relay-326
Open

abhinavgautam01 wants to merge 1 commit into
git-pkgs:mainfrom
abhinavgautam01:fix/response-relay-326

Conversation

@abhinavgautam01

Copy link
Copy Markdown
Contributor

Closes #326

Summary

Centralize pass-through response handling so connection-scoped headers are not forwarded, upstream trailers are preserved and incomplete downloads are not presented as successfully completed responses.

Changes

  • Add a shared response relay for ProxyUpstream, ProxyFile, streaming metadata and protocol-specific pass-through paths.
  • Strip standard hop-by-hop headers and headers named by Connection.
  • Declare and forward valid trailers, including trailers discovered only after reading the body.
  • Respect HEAD requests and bodiless response statuses.
  • Log copy failures with the upstream URL, status and byte count.
  • Abort failed transfers with http.ErrAbortHandler, closing HTTP/1 connections or resetting HTTP/2 streams.
  • Expose response-writer unwrapping so late-trailer flushing works through the logging middleware.
  • Preserve existing header allowlists, PyPI’s Vary: Accept and Swift URL rewriting.

Scope and limitations

  • Applies to unmodified upstream response relaying.
  • Cached artifact serving and metadata body transformations remain unchanged.
  • Does not add protocol-upgrade or WebSocket support.

Validation

Added regression coverage for route-level header stripping, declared and late trailers, truncated chunked responses, HEAD and bodiless statuses, invalid trailers, copy-error logging and upstream body cleanup.

Real-client tests verify late trailers and interrupted responses through the production middleware over HTTP/1.1 and HTTP/2.

Local checks passed:

  • Formatting and git diff --check
  • go tool golangci-lint run ./... — 0 issues
  • go test -race ./...
  • Relay regression tests repeated 10 times
  • go vet ./...
  • go build ./...
  • go mod tidy -diff

Cross-platform validation is left to CI.

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.

Centralize pass-through response relay handling

1 participant