Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gzip encoding breaks proxy #661

Open
pdf opened this issue Oct 11, 2024 · 0 comments
Open

gzip encoding breaks proxy #661

pdf opened this issue Oct 11, 2024 · 0 comments

Comments

@pdf
Copy link

pdf commented Oct 11, 2024

When sending a request through the proxy, and the target server supports gzip encoding, and the requesting client accepts gzip, then the proxy will produce no output.

When the Accept-Encoding header is not explicitly set on a request, the default http.Transport will add the header itself and transparently decode the resulting response body. However if the request explicitly sets the Accept-Encoding header, the response is not automatically decoded.

Because the proxy copies all headers from the client request to the proxied request, if the client is a browser it is very likely that the Accept-Encoding header will be explicitly set by the copy, with the result being that the proxy receives compressed data back from the server and barfs on it.

There are a couple of potential ways I can see to solve this:

  • Omit the Accept-Encoding header when copying headers from client req to proxied req to allow transparent decompression. This approach may introduce some surprise if users expect to be able to specify some alternative encoding and have it honored.
  • Handle decompression explicitly in the presence of Content-Encoding: gzip in the server response.

A similar issue exists on the proxied response, since the Content-Encoding header is copied to the outbound response but the response is not correctly encoded. I suspect that honoring the Content-Encoding header on the response side is likely to be rather more complicated, since the correct encoding on the response would have to be generated (gzip / compress / whatever).

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

No branches or pull requests

2 participants
@pdf and others