Skip to content

Fix stale Content-Encoding header in ProxyServlet after HttpClient bump - #7937

Open
labkey-tchad wants to merge 2 commits into
release26.7-SNAPSHOTfrom
26.7_fb_httpClientUpgrade
Open

Fix stale Content-Encoding header in ProxyServlet after HttpClient bump#7937
labkey-tchad wants to merge 2 commits into
release26.7-SNAPSHOTfrom
26.7_fb_httpClientUpgrade

Conversation

@labkey-tchad

Copy link
Copy Markdown
Member

Rationale

Apache HttpClient5 5.6+ no longer strips the Content-Encoding/Content-Length headers it leaves behind after auto-decompressing a response entity (5.5.x stripped them via ContentCompressionExec). This surfaced while updating our httpclient5 dependency from 5.5.2 to 5.6.4: ProxyServlet.copyResponseHeaders() forwards those stale headers verbatim, so a gzip-compressed backend response arrives at the browser with an already-decompressed body but a Content-Encoding: gzip header still attached — browsers reject this as an invalid/unsupported compression form (surfaced via the RStudio Workbench auth-sign-in proxy path).

Related Pull Requests

Changes

  • Disable HttpClient's automatic content-decompression on the shared proxyClient in ProxyServlet.createHttpClient(), so ProxyServlet always streams the backend's original bytes and headers through unmodified.

HttpClient5 5.6+ stopped stripping Content-Encoding/Content-Length after auto-decompressing responses, so ProxyServlet forwarded a decompressed body under a stale compressed-encoding header. Disable auto-decompression so bytes and headers always stay consistent.
@labkey-tchad
labkey-tchad requested a review from XingY August 15, 2026 01:35
@labkey-tchad

Copy link
Copy Markdown
Member Author

Verifying with RStudio on TeamCity: https://teamcity.labkey.org/buildConfiguration/LabKey_267Release_Premium_ModulesSuites_RStudioPostgres/4134256
Not sure how this will interact with the doHandleCompression flag added for AWS.

@XingY XingY left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems our ProxyServlet diverged from the original implementation:
https://github.com/mitre/HTTP-Proxy-Servlet/blame/9a522c5c021e6941cd951941ed49d96ff996f1eb/src/main/java/org/mitre/dsmiley/httpproxy/ProxyServlet.java#L286

Based on the original code, if should check doHandleCompression to set the config.

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