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

Allow override of the HttpHeadersFactory for multi-address and partitioned clients #2135

Merged
merged 1 commit into from
Mar 9, 2022

Conversation

idelpivnitskiy
Copy link
Member

Motivation:

A client instance is also used to create a request object because it
implements a request-response factory. Users of multi-address and
partitioned clients always use DefaultHttpHeadersFactory.INSTANCE.
There is no easy way to override headers factory. Use-cases: change
header name/value validation, preset some headers, etc.

Modifications:

  • Add MultiAddressHttpClientBuilder#headersFactory(HttpHeadersFactory)
  • Add PartitionedHttpClientBuilder#headersFactory(HttpHeadersFactory)
  • Implement new methods;
  • Test new feature for MultiAddressHttpClientBuilder;

Result:

Users of multi-address and partitioned clients can override the default
HttpHeadersFactory.

…itioned clients

Motivation:

A client instance is also used to create a request object because it
implements request-response factory. Users of multi-address and
partitioned clients always use `DefaultHttpHeadersFactory.INSTANCE`.
There is no easy way to override headers factory. Use-cases: change
header name/value validation, preset some headers, etc.

Modifications:

- Add `MultiAddressHttpClientBuilder#headersFactory(HttpHeadersFactory)`
- Add `PartitionedHttpClientBuilder#headersFactory(HttpHeadersFactory)`
- Implement new methods;
- Test new feature for `MultiAddressHttpClientBuilder`;

Result:

Users of multi-address and partitioned clients can override the default
`HttpHeadersFactory`.
import static java.util.Objects.requireNonNull;
import static java.util.function.Function.identity;

final class DefaultPartitionedHttpClientBuilder<U, R> implements PartitionedHttpClientBuilder<U, R> {
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultMultiAddressUrlHttpClientBuilder.class);
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultPartitionedHttpClientBuilder.class);
Copy link
Contributor

Choose a reason for hiding this comment

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

good catch

@idelpivnitskiy idelpivnitskiy merged commit 310f6b5 into apple:main Mar 9, 2022
@idelpivnitskiy idelpivnitskiy deleted the headers-factory branch March 9, 2022 18:48
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