Skip to content

Centralize pass-through response relay handling #326

Description

@andrew

Several pass-through paths, including ProxyUpstream and ProxyFile, copy every upstream header to the downstream response and discard the error from io.Copy. Protocol handlers contain similar response-copy blocks.

This leaves three protocol cases inconsistent:

  • Headers named by Connection, plus the standard hop-by-hop headers, can be forwarded downstream.
  • Upstream trailers are not declared and copied to the downstream response.
  • A chunked upstream response that ends early can be emitted as a cleanly terminated downstream response because the copy error does not abort the response.

A shared response relay helper could strip hop-by-hop headers, declare and copy trailers, respect HEAD and bodiless statuses, and abort the downstream response after a post-header copy failure. Copy failures should record the upstream URL, status, and byte count.

A route-level test can use an httptest upstream which returns a connection-scoped header, a trailer, and a truncated chunked body, then make a real client request through the proxy.

Observed on v0.8.1 and current main at 94c11b4.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions