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

http-netty: Properly set the host header for MultiAddressUrlClient #2868

Conversation

bryce-anderson
Copy link
Contributor

Motivation:

Users of the MultiAddressHttpClientBuilder are expected to put in a request target that includes the authority, which may or may not include the port. The authority should be directly reflected in the Host header but right now we will add both host and port regardless of what was specified. This is described in https://datatracker.ietf.org/doc/html/rfc7230#section-5.4.

Modifications:

Set the host header correctly right before we overwrite the requestTarget to relative form.
Note that this overrides the behavior of the SingleClientAddressBuilder.hostHeaderFallback(..).

See #2856 for an alternative that is more correct wrt user configured behavior but a lot more complex to follow.

Motivation:

Users of the MultiAddressHttpClientBuilder are expected to put in
a request target that includes the authority, which may or may not
include the port. The authority should be directly reflected in the
`Host` header but right now we will add both host and port
regardless of what was specified.

Modifications:

Copy the authority information directly from the request when
overrides haven't been specified.
Copy link
Member

@idelpivnitskiy idelpivnitskiy left a comment

Choose a reason for hiding this comment

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

This approach looks much better to me!
Thanks for implementing it

@bryce-anderson bryce-anderson merged commit d4012e6 into apple:main Mar 13, 2024
15 checks passed
@bryce-anderson bryce-anderson deleted the bl_anderson/bl_anderson/HostHeaderMultiBuilder_opt2 branch March 13, 2024 17:55
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.

None yet

3 participants