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

DefaultSingleAddressHttpClient may add incorrect host header by default #1301

Conversation

idelpivnitskiy
Copy link
Member

Motivation:

Existing approach for adding HostHeaderHttpRequesterFilter in
DefaultSingleAddressHttpClientBuilder keeps reference to the
hostToCharSequenceFunction at the time of class initialization. However,
hostToCharSequenceFunction can be changed later (in a proxy ctor or
unresolvedAddressToHost builder method). In these cases,
hostHeaderFilterFactoryFunction keeps the reference to the old
hostToCharSequenceFunction.

Modifications:

  • Use a boolean to know when HostHeaderHttpRequesterFilter should be
    applied;
  • When HostHeaderHttpRequesterFilter is added, use the latest reference to
    the hostToCharSequenceFunction;

Result:

HostHeaderHttpRequesterFilter uses the latest version of
hostToCharSequenceFunction to determine the fallback value for the host
header.

…efault

Motivation:

Existing approach for adding `HostHeaderHttpRequesterFilter` in
`DefaultSingleAddressHttpClientBuilder` keeps reference to the
`hostToCharSequenceFunction` at the time of class initialization. However,
`hostToCharSequenceFunction` can be changed later (in a proxy ctor or
`unresolvedAddressToHost` builder method). In these cases,
`hostHeaderFilterFactoryFunction` keeps the reference to the old
`hostToCharSequenceFunction`.

Modifications:

- Use a `boolean` to know when `HostHeaderHttpRequesterFilter` should be
applied;
- When `HostHeaderHttpRequesterFilter` is added, use the latest reference to
the `hostToCharSequenceFunction`;

Result:

`HostHeaderHttpRequesterFilter` uses the latest version of
`hostToCharSequenceFunction` to determine the fallback value for the `host`
header.
@idelpivnitskiy idelpivnitskiy merged commit 046c7cc into apple:main Jan 7, 2021
@idelpivnitskiy idelpivnitskiy deleted the DefaultSingleAddressHttpClientBuilder branch January 7, 2021 22:26
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