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

#45 Fix Host header on forwarded requests #46

Merged
merged 1 commit into from
Mar 16, 2018

Conversation

RichardBradley
Copy link
Contributor

This fixes #45

The test "def "Should proxy HTTPS request"()" demonstrates that this fix works -- previously TLS requests that were being forwarded to https://github.com had a Host header of localhost, and were being rejected by GitHub's server. Now the request is succeeding.

headers.putAll(response.getHeaders());
response.setHeaders(headers);

headers.remove("Transfer-Encoding");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remote servers which use Chunked transfer encoding would fail to proxy correctly because line 85 causes Spring to buffer the remote body into a single entity, but we were previously passing over the remote Transfer-Encoding: Chunked header, confusing clients.

This fixes that issue. I have tested against a remote server with Chunked encoding, it works after this change but did not work before this change.

I have not added a unit test for this fix.

@@ -145,6 +145,7 @@ abstract class ProxyingRequestSpec extends BasicSpec {

then:
assertThat(response)
.hasStatus(MOVED_PERMANENTLY)
.hasStatus(OK)
.bodyContains("<link rel=\"canonical\" href=\"https://github.com/\"")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

See comment in the body of this PR -- the test was actually failing before, i.e. the old assertion was wrong.
After fixing the Host header issue, the request now works, so I have fixed the assertion.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.5%) to 92.308% when pulling 2e47684 on RichardBradley:45-host-header into eb0e381 on mkopylec:master.

@mkopylec mkopylec merged commit b4f18da into mkopylec:master Mar 16, 2018
@RichardBradley RichardBradley deleted the 45-host-header branch March 16, 2018 15:10
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.

Host header is not rewritten
3 participants