public final class HttpClients
extends java.lang.Object
HttpClient
(and other API variations) instances.Modifier and Type | Method and Description |
---|---|
static MultiAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> |
forMultiAddressUrl()
Creates a
MultiAddressHttpClientBuilder for clients capable of parsing an absolute-form URL, connecting to multiple addresses
with default LoadBalancer and DNS ServiceDiscoverer . |
static MultiAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> |
forMultiAddressUrl(ServiceDiscoverer<HostAndPort,java.net.InetSocketAddress,? extends ServiceDiscovererEvent<java.net.InetSocketAddress>> serviceDiscoverer)
Creates a
MultiAddressHttpClientBuilder for clients capable of parsing an absolute-form URL, connecting to multiple addresses
with default LoadBalancer and user provided ServiceDiscoverer . |
static <U,R> PartitionedHttpClientBuilder<U,R> |
forPartitionedAddress(ServiceDiscoverer<U,R,? extends PartitionedServiceDiscovererEvent<R>> serviceDiscoverer,
U address,
java.util.function.Function<HttpRequestMetaData,PartitionAttributesBuilder> partitionAttributesBuilderFactory)
Creates a
PartitionedHttpClientBuilder for a custom address type with default LoadBalancer and
user provided ServiceDiscoverer . |
static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> |
forResolvedAddress(HostAndPort address)
Creates a
SingleAddressHttpClientBuilder for an address with default LoadBalancer and DNS ServiceDiscoverer . |
static SingleAddressHttpClientBuilder<java.net.InetSocketAddress,java.net.InetSocketAddress> |
forResolvedAddress(java.net.InetSocketAddress address)
Creates a
SingleAddressHttpClientBuilder for an address with default LoadBalancer and DNS ServiceDiscoverer . |
static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> |
forResolvedAddress(java.lang.String host,
int port)
Creates a
SingleAddressHttpClientBuilder for a resolved address with default LoadBalancer . |
static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> |
forResolvedAddressViaProxy(HostAndPort address,
HostAndPort proxyAddress)
Creates a
SingleAddressHttpClientBuilder for an address via a proxy, with default LoadBalancer
and DNS ServiceDiscoverer . |
static SingleAddressHttpClientBuilder<java.net.InetSocketAddress,java.net.InetSocketAddress> |
forResolvedAddressViaProxy(java.net.InetSocketAddress address,
java.net.InetSocketAddress proxyAddress)
Creates a
SingleAddressHttpClientBuilder for an address via a proxy, with default LoadBalancer
and DNS ServiceDiscoverer . |
static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> |
forResolvedAddressViaProxy(java.lang.String host,
int port,
java.lang.String proxyHost,
int proxyPort)
Creates a
SingleAddressHttpClientBuilder for a resolved address via a proxy, with default
LoadBalancer . |
static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> |
forSingleAddress(HostAndPort address)
Creates a
SingleAddressHttpClientBuilder for an address with default LoadBalancer and DNS ServiceDiscoverer . |
static <U,R> SingleAddressHttpClientBuilder<U,R> |
forSingleAddress(ServiceDiscoverer<U,R,? extends ServiceDiscovererEvent<R>> serviceDiscoverer,
U address)
Creates a
SingleAddressHttpClientBuilder for a custom address type with default LoadBalancer and
user provided ServiceDiscoverer . |
static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> |
forSingleAddress(java.lang.String host,
int port)
Creates a
SingleAddressHttpClientBuilder for an address with default LoadBalancer and DNS ServiceDiscoverer . |
static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> |
forSingleAddressViaProxy(HostAndPort address,
HostAndPort proxyAddress)
Creates a
SingleAddressHttpClientBuilder for an address via a proxy, with default LoadBalancer
and DNS ServiceDiscoverer . |
static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> |
forSingleAddressViaProxy(java.lang.String host,
int port,
java.lang.String proxyHost,
int proxyPort)
Creates a
SingleAddressHttpClientBuilder for an address via a proxy, with default LoadBalancer
and DNS ServiceDiscoverer . |
public static MultiAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forMultiAddressUrl()
MultiAddressHttpClientBuilder
for clients capable of parsing an absolute-form URL, connecting to multiple addresses
with default LoadBalancer
and DNS ServiceDiscoverer
.
When a relative URL is passed in the StreamingHttpRequest.requestTarget(String)
this client requires a HttpHeaderNames.HOST
present in
order to infer the remote address.
public static MultiAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forMultiAddressUrl(ServiceDiscoverer<HostAndPort,java.net.InetSocketAddress,? extends ServiceDiscovererEvent<java.net.InetSocketAddress>> serviceDiscoverer)
MultiAddressHttpClientBuilder
for clients capable of parsing an absolute-form URL, connecting to multiple addresses
with default LoadBalancer
and user provided ServiceDiscoverer
.
When a relative URL is passed in the StreamingHttpRequest.requestTarget(String)
this client requires a HttpHeaderNames.HOST
present in
order to infer the remote address.
serviceDiscoverer
- The ServiceDiscoverer
to resolve addresses of remote servers to connect to.
The lifecycle of the provided ServiceDiscoverer
should be managed by the caller.public static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forSingleAddress(java.lang.String host, int port)
SingleAddressHttpClientBuilder
for an address with default LoadBalancer
and DNS ServiceDiscoverer
.host
- host to connect to, resolved by default using a DNS ServiceDiscoverer
. This will also be
used for the HttpHeaderNames.HOST
together with the port
. Use
SingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)
if you want to override that value
or SingleAddressHttpClientBuilder.disableHostHeaderFallback()
if you want to disable this behavior.port
- port to connect topublic static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forSingleAddressViaProxy(java.lang.String host, int port, java.lang.String proxyHost, int proxyPort)
SingleAddressHttpClientBuilder
for an address via a proxy, with default LoadBalancer
and DNS ServiceDiscoverer
.host
- host to connect to via the proxy. This will also be used for the HttpHeaderNames.HOST
together with the port
. Use
SingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)
if you want to override that value
or SingleAddressHttpClientBuilder.disableHostHeaderFallback()
if you want to disable this behavior.port
- port to connect toproxyHost
- the proxy host to connect to, resolved by default using a DNS ServiceDiscoverer
.proxyPort
- The proxy port to connect.public static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forSingleAddress(HostAndPort address)
SingleAddressHttpClientBuilder
for an address with default LoadBalancer
and DNS ServiceDiscoverer
.address
- the UnresolvedAddress
to connect to, resolved by default using a DNS ServiceDiscoverer
. This address will also be used for the HttpHeaderNames.HOST
.
Use SingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)
if you want to override that
value or SingleAddressHttpClientBuilder.disableHostHeaderFallback()
if you want to disable this behavior.public static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forSingleAddressViaProxy(HostAndPort address, HostAndPort proxyAddress)
SingleAddressHttpClientBuilder
for an address via a proxy, with default LoadBalancer
and DNS ServiceDiscoverer
.address
- the UnresolvedAddress
to connect to via the proxy. This address will also be used for the
HttpHeaderNames.HOST
. Use SingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)
if you want to override that value or SingleAddressHttpClientBuilder.disableHostHeaderFallback()
if you
want to disable this behavior.proxyAddress
- the proxy UnresolvedAddress
to connect to, resolved by default using a DNS ServiceDiscoverer
.public static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forResolvedAddress(java.lang.String host, int port)
SingleAddressHttpClientBuilder
for a resolved address with default LoadBalancer
.host
- resolved host address to connect. This will also be used for the HttpHeaderNames.HOST
together with the port
. Use SingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)
if you want to override that value or SingleAddressHttpClientBuilder.disableHostHeaderFallback()
if you want to disable this behavior.port
- port to connect topublic static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forResolvedAddressViaProxy(java.lang.String host, int port, java.lang.String proxyHost, int proxyPort)
SingleAddressHttpClientBuilder
for a resolved address via a proxy, with default
LoadBalancer
.host
- resolved host address to connect via the proxy. This will also be used for the
HttpHeaderNames.HOST
together with the port
. Use
SingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)
if you want to override that value
or SingleAddressHttpClientBuilder.disableHostHeaderFallback()
if you want to disable this behavior.port
- port to connect to via the proxyproxyHost
- The proxy resolved host address to connect.proxyPort
- The proxy port to connect.public static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forResolvedAddress(HostAndPort address)
SingleAddressHttpClientBuilder
for an address with default LoadBalancer
and DNS ServiceDiscoverer
.address
- the ResolvedAddress
to connect. This address will also be used for the
HttpHeaderNames.HOST
. Use SingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)
if you want to override that value or SingleAddressHttpClientBuilder.disableHostHeaderFallback()
if you
want to disable this behavior.public static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forResolvedAddressViaProxy(HostAndPort address, HostAndPort proxyAddress)
SingleAddressHttpClientBuilder
for an address via a proxy, with default LoadBalancer
and DNS ServiceDiscoverer
.address
- the ResolvedAddress
to connect to via the proxy. This address will also be used for the
HttpHeaderNames.HOST
. Use SingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)
if you want to override that value or SingleAddressHttpClientBuilder.disableHostHeaderFallback()
if you
want to disable this behavior.proxyAddress
- The proxy ResolvedAddress
to connect.public static SingleAddressHttpClientBuilder<java.net.InetSocketAddress,java.net.InetSocketAddress> forResolvedAddress(java.net.InetSocketAddress address)
SingleAddressHttpClientBuilder
for an address with default LoadBalancer
and DNS ServiceDiscoverer
.address
- the ResolvedAddress
to connect. This address will also be used for the
HttpHeaderNames.HOST
. Use SingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)
if you want to override that value or SingleAddressHttpClientBuilder.disableHostHeaderFallback()
if you
want to disable this behavior.public static SingleAddressHttpClientBuilder<java.net.InetSocketAddress,java.net.InetSocketAddress> forResolvedAddressViaProxy(java.net.InetSocketAddress address, java.net.InetSocketAddress proxyAddress)
SingleAddressHttpClientBuilder
for an address via a proxy, with default LoadBalancer
and DNS ServiceDiscoverer
.address
- the ResolvedAddress
to connect to via the proxy. This address will also be used for the
HttpHeaderNames.HOST
. Use SingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)
if you want to override that value or SingleAddressHttpClientBuilder.disableHostHeaderFallback()
if you
want to disable this behavior.proxyAddress
- The proxy ResolvedAddress
to connect.public static <U,R> SingleAddressHttpClientBuilder<U,R> forSingleAddress(ServiceDiscoverer<U,R,? extends ServiceDiscovererEvent<R>> serviceDiscoverer, U address)
SingleAddressHttpClientBuilder
for a custom address type with default LoadBalancer
and
user provided ServiceDiscoverer
.U
- the type of address before resolution (unresolved address)R
- the type of address after resolution (resolved address)serviceDiscoverer
- The ServiceDiscoverer
to resolve addresses of remote servers to connect to.
The lifecycle of the provided ServiceDiscoverer
should be managed by the caller.address
- the UnresolvedAddress
to connect to resolved using the provided serviceDiscoverer
.
This address will also be used for the HttpHeaderNames.HOST
using a best effort conversion. Use SingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)
if you want to override that value or
SingleAddressHttpClientBuilder.disableHostHeaderFallback()
if you want to disable this behavior.public static <U,R> PartitionedHttpClientBuilder<U,R> forPartitionedAddress(ServiceDiscoverer<U,R,? extends PartitionedServiceDiscovererEvent<R>> serviceDiscoverer, U address, java.util.function.Function<HttpRequestMetaData,PartitionAttributesBuilder> partitionAttributesBuilderFactory)
PartitionedHttpClientBuilder
for a custom address type with default LoadBalancer
and
user provided ServiceDiscoverer
.U
- the type of address before resolution (unresolved address)R
- the type of address after resolution (resolved address)serviceDiscoverer
- The ServiceDiscoverer
to resolve addresses of remote servers to connect to.
The lifecycle of the provided ServiceDiscoverer
should be managed by the caller.address
- the UnresolvedAddress
to resolve using the provided serviceDiscoverer
.
This address will also be used for the HttpHeaderNames.HOST
using a best effort conversion. Use PartitionedHttpClientBuilder.unresolvedAddressToHost(Function)
if you want to override that value or
PartitionedHttpClientBuilder.disableHostHeaderFallback()
if you want to disable this behavior.partitionAttributesBuilderFactory
- The factory Function
used to build PartitionAttributes
from HttpRequestMetaData
.