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

Prevent Content-Length and Host headers from being copied by default #3313

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

jkuipers
Copy link
Contributor

This PR introduces an additional property to skip copying certain headers from the incoming request.
Because the use case is different, it's bad to force users to add headers like Host and Content-Length to the list of sensitive headers when they need to override that (e.g. for adding smth like an X-APIKey header), so having a separate configuration setting for this is preferable.

Fixes gh-3154

Also remove the bogus spring.cloud.gateway.proxy.auto-forward setting from the tests.
Fixes spring-cloudgh-3154
@jkuipers jkuipers force-pushed the exclude-content-length branch from 482690b to 310d7d5 Compare March 21, 2024 21:24
@spencergibb spencergibb merged commit b435ce3 into spring-cloud:main Jul 3, 2024
2 checks passed
spencergibb added a commit that referenced this pull request Jul 3, 2024
@spencergibb
Copy link
Member

I've added back removed/renamed fields and methods as we can't have breaking changes outside of a major. See b30188e

@artemkutishevsky
Copy link

Hello @spencergibb @jkuipers,

Just wanted to let you know that a breaking change still was introduced here. "Host" and "content-length" headers were not treated in any special way before those two commits and now they are excluded by default. Which results in a failure of course if someone relies on the "host" header being set for example.

@jkuipers
Copy link
Contributor Author

jkuipers commented Aug 21, 2024

Hello @spencergibb @jkuipers,

Just wanted to let you know that a breaking change still was introduced here. "Host" and "content-length" headers were not treated in any special way before those two commits and now they are excluded by default. Which results in a failure of course if someone relies on the "host" header being set for example.

The RestTemplate (or rather its underlying HTTP client, in case of the host header) should set those values itself to the values appropriate for its own request. It makes no sense to copy these headers from the original request, since they can/will be wrong (host is almost always wrong, the content-length case is described in this issue in detail).
This is indeed different from the old behavior, but the old behavior wasn’t a feature but a bug as far as I’m concerned.

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

Successfully merging this pull request may close these issues.

ProxyExchange fails with "IOException: insufficient data written" with boot 3.2
4 participants