Package io.servicetalk.http.netty
Class HttpClients
- java.lang.Object
-
- io.servicetalk.http.netty.HttpClients
-
public final class HttpClients extends java.lang.ObjectFactory methods for buildingHttpClient(and other API variations) instances.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static MultiAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress>forMultiAddressUrl()Creates aMultiAddressHttpClientBuilderfor clients capable of parsing an absolute-form URL, connecting to multiple addresses with defaultLoadBalancerand DNSServiceDiscoverer.static MultiAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress>forMultiAddressUrl(ServiceDiscoverer<HostAndPort,java.net.InetSocketAddress,ServiceDiscovererEvent<java.net.InetSocketAddress>> serviceDiscoverer)Creates aMultiAddressHttpClientBuilderfor clients capable of parsing an absolute-form URL, connecting to multiple addresses with defaultLoadBalancerand user providedServiceDiscoverer.static <U,R>
PartitionedHttpClientBuilder<U,R>forPartitionedAddress(ServiceDiscoverer<U,R,PartitionedServiceDiscovererEvent<R>> serviceDiscoverer, U address, java.util.function.Function<HttpRequestMetaData,PartitionAttributesBuilder> partitionAttributesBuilderFactory)Creates aPartitionedHttpClientBuilderfor a custom address type with defaultLoadBalancerand user providedServiceDiscoverer.static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress>forResolvedAddress(HostAndPort address)Creates aSingleAddressHttpClientBuilderfor an address with defaultLoadBalancer.static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress>forResolvedAddress(java.lang.String host, int port)Creates aSingleAddressHttpClientBuilderfor a resolved address with defaultLoadBalancer.static <T extends java.net.SocketAddress>
SingleAddressHttpClientBuilder<T,T>forResolvedAddress(T address)Creates aSingleAddressHttpClientBuilderfor an address with defaultLoadBalancer.static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress>forResolvedAddressViaProxy(HostAndPort address, HostAndPort proxyAddress)Creates aSingleAddressHttpClientBuilderfor an address via a proxy, with defaultLoadBalancer.static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress>forResolvedAddressViaProxy(java.lang.String host, int port, java.lang.String proxyHost, int proxyPort)Creates aSingleAddressHttpClientBuilderfor a resolved address via a proxy, with defaultLoadBalancer.static SingleAddressHttpClientBuilder<java.net.InetSocketAddress,java.net.InetSocketAddress>forResolvedAddressViaProxy(java.net.InetSocketAddress address, java.net.InetSocketAddress proxyAddress)Creates aSingleAddressHttpClientBuilderfor an address via a proxy, with defaultLoadBalancer.static SingleAddressHttpClientBuilder<java.lang.String,java.net.InetSocketAddress>forServiceAddress(java.lang.String serviceName)Creates aSingleAddressHttpClientBuilderfor the passedserviceNamewith defaultLoadBalancerand a DNSServiceDiscovererusing SRV record lookups.static <U,R>
SingleAddressHttpClientBuilder<U,R>forSingleAddress(ServiceDiscoverer<U,R,ServiceDiscovererEvent<R>> serviceDiscoverer, U address)Creates aSingleAddressHttpClientBuilderfor a custom address type with defaultLoadBalancerand user providedServiceDiscoverer.static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress>forSingleAddress(HostAndPort address)Creates aSingleAddressHttpClientBuilderfor an address with defaultLoadBalancerand DNSServiceDiscoverer.static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress>forSingleAddress(java.lang.String host, int port)Creates aSingleAddressHttpClientBuilderfor an address with defaultLoadBalancerand DNSServiceDiscoverer.static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress>forSingleAddressViaProxy(HostAndPort address, HostAndPort proxyAddress)Creates aSingleAddressHttpClientBuilderfor an address via a proxy, with defaultLoadBalancerand DNSServiceDiscoverer.static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress>forSingleAddressViaProxy(java.lang.String host, int port, java.lang.String proxyHost, int proxyPort)Creates aSingleAddressHttpClientBuilderfor an address via a proxy, with defaultLoadBalancerand DNSServiceDiscoverer.
-
-
-
Method Detail
-
forMultiAddressUrl
public static MultiAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forMultiAddressUrl()
Creates aMultiAddressHttpClientBuilderfor clients capable of parsing an absolute-form URL, connecting to multiple addresses with defaultLoadBalancerand DNSServiceDiscoverer.When a relative URL is passed in the
StreamingHttpRequest.requestTarget(String)this client requires aHttpHeaderNames.HOSTpresent in order to infer the remote address.- Returns:
- new builder with default configuration
-
forMultiAddressUrl
public static MultiAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forMultiAddressUrl(ServiceDiscoverer<HostAndPort,java.net.InetSocketAddress,ServiceDiscovererEvent<java.net.InetSocketAddress>> serviceDiscoverer)
Creates aMultiAddressHttpClientBuilderfor clients capable of parsing an absolute-form URL, connecting to multiple addresses with defaultLoadBalancerand user providedServiceDiscoverer.When a relative URL is passed in the
StreamingHttpRequest.requestTarget(String)this client requires aHttpHeaderNames.HOSTpresent in order to infer the remote address.- Parameters:
serviceDiscoverer- TheServiceDiscovererto resolve addresses of remote servers to connect to. The lifecycle of the providedServiceDiscoverershould be managed by the caller.- Returns:
- new builder with default configuration
-
forSingleAddress
public static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forSingleAddress(java.lang.String host, int port)
Creates aSingleAddressHttpClientBuilderfor an address with defaultLoadBalancerand DNSServiceDiscoverer.- Parameters:
host- host to connect to, resolved by default using a DNSServiceDiscoverer. This will also be used for theHttpHeaderNames.HOSTtogether with theport. UseSingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)if you want to override that value orSingleAddressHttpClientBuilder.disableHostHeaderFallback()if you want to disable this behavior.port- port to connect to- Returns:
- new builder for the address
-
forSingleAddressViaProxy
public static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forSingleAddressViaProxy(java.lang.String host, int port, java.lang.String proxyHost, int proxyPort)
Creates aSingleAddressHttpClientBuilderfor an address via a proxy, with defaultLoadBalancerand DNSServiceDiscoverer.- Parameters:
host- host to connect to via the proxy. This will also be used for theHttpHeaderNames.HOSTtogether with theport. UseSingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)if you want to override that value orSingleAddressHttpClientBuilder.disableHostHeaderFallback()if you want to disable this behavior.port- port to connect toproxyHost- the proxy host to connect to, resolved by default using a DNSServiceDiscoverer.proxyPort- The proxy port to connect.- Returns:
- new builder for the address
-
forSingleAddress
public static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forSingleAddress(HostAndPort address)
Creates aSingleAddressHttpClientBuilderfor an address with defaultLoadBalancerand DNSServiceDiscoverer.- Parameters:
address- theUnresolvedAddressto connect to, resolved by default using a DNSServiceDiscoverer. This address will also be used for theHttpHeaderNames.HOST. UseSingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)if you want to override that value orSingleAddressHttpClientBuilder.disableHostHeaderFallback()if you want to disable this behavior.- Returns:
- new builder for the address
-
forServiceAddress
public static SingleAddressHttpClientBuilder<java.lang.String,java.net.InetSocketAddress> forServiceAddress(java.lang.String serviceName)
Creates aSingleAddressHttpClientBuilderfor the passedserviceNamewith defaultLoadBalancerand a DNSServiceDiscovererusing SRV record lookups.- Parameters:
serviceName- The service name to resolve with SRV DNS.- Returns:
- new builder for the address
-
forSingleAddressViaProxy
public static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forSingleAddressViaProxy(HostAndPort address, HostAndPort proxyAddress)
Creates aSingleAddressHttpClientBuilderfor an address via a proxy, with defaultLoadBalancerand DNSServiceDiscoverer.- Parameters:
address- theUnresolvedAddressto connect to via the proxy. This address will also be used for theHttpHeaderNames.HOST. UseSingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)if you want to override that value orSingleAddressHttpClientBuilder.disableHostHeaderFallback()if you want to disable this behavior.proxyAddress- the proxyUnresolvedAddressto connect to, resolved by default using a DNSServiceDiscoverer.- Returns:
- new builder for the address
-
forResolvedAddress
public static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forResolvedAddress(java.lang.String host, int port)
Creates aSingleAddressHttpClientBuilderfor a resolved address with defaultLoadBalancer.- Parameters:
host- resolved host address to connect. This will also be used for theHttpHeaderNames.HOSTtogether with theport. UseSingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)if you want to override that value orSingleAddressHttpClientBuilder.disableHostHeaderFallback()if you want to disable this behavior.port- port to connect to- Returns:
- new builder for the address
-
forResolvedAddressViaProxy
public static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forResolvedAddressViaProxy(java.lang.String host, int port, java.lang.String proxyHost, int proxyPort)
Creates aSingleAddressHttpClientBuilderfor a resolved address via a proxy, with defaultLoadBalancer.- Parameters:
host- resolved host address to connect via the proxy. This will also be used for theHttpHeaderNames.HOSTtogether with theport. UseSingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)if you want to override that value orSingleAddressHttpClientBuilder.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.- Returns:
- new builder for the address
-
forResolvedAddress
public static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forResolvedAddress(HostAndPort address)
Creates aSingleAddressHttpClientBuilderfor an address with defaultLoadBalancer.- Parameters:
address- theResolvedAddressto connect. This address will also be used for theHttpHeaderNames.HOST. UseSingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)if you want to override that value orSingleAddressHttpClientBuilder.disableHostHeaderFallback()if you want to disable this behavior.- Returns:
- new builder for the address
-
forResolvedAddressViaProxy
public static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forResolvedAddressViaProxy(HostAndPort address, HostAndPort proxyAddress)
Creates aSingleAddressHttpClientBuilderfor an address via a proxy, with defaultLoadBalancer.- Parameters:
address- theResolvedAddressto connect to via the proxy. This address will also be used for theHttpHeaderNames.HOST. UseSingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)if you want to override that value orSingleAddressHttpClientBuilder.disableHostHeaderFallback()if you want to disable this behavior.proxyAddress- The proxyResolvedAddressto connect.- Returns:
- new builder for the address
-
forResolvedAddress
public static <T extends java.net.SocketAddress> SingleAddressHttpClientBuilder<T,T> forResolvedAddress(T address)
Creates aSingleAddressHttpClientBuilderfor an address with defaultLoadBalancer.- Type Parameters:
T- The type ofSocketAddress.- Parameters:
address- theResolvedAddressto connect. This address will also be used for theHttpHeaderNames.HOST. UseSingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)if you want to override that value orSingleAddressHttpClientBuilder.disableHostHeaderFallback()if you want to disable this behavior.- Returns:
- new builder for the address
-
forResolvedAddressViaProxy
public static SingleAddressHttpClientBuilder<java.net.InetSocketAddress,java.net.InetSocketAddress> forResolvedAddressViaProxy(java.net.InetSocketAddress address, java.net.InetSocketAddress proxyAddress)
Creates aSingleAddressHttpClientBuilderfor an address via a proxy, with defaultLoadBalancer.- Parameters:
address- theResolvedAddressto connect to via the proxy. This address will also be used for theHttpHeaderNames.HOST. UseSingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)if you want to override that value orSingleAddressHttpClientBuilder.disableHostHeaderFallback()if you want to disable this behavior.proxyAddress- The proxyResolvedAddressto connect.- Returns:
- new builder for the address
-
forSingleAddress
public static <U,R> SingleAddressHttpClientBuilder<U,R> forSingleAddress(ServiceDiscoverer<U,R,ServiceDiscovererEvent<R>> serviceDiscoverer, U address)
Creates aSingleAddressHttpClientBuilderfor a custom address type with defaultLoadBalancerand user providedServiceDiscoverer.- Type Parameters:
U- the type of address before resolution (unresolved address)R- the type of address after resolution (resolved address)- Parameters:
serviceDiscoverer- TheServiceDiscovererto resolve addresses of remote servers to connect to. The lifecycle of the providedServiceDiscoverershould be managed by the caller.address- theUnresolvedAddressto connect to resolved using the providedserviceDiscoverer. This address will also be used for theHttpHeaderNames.HOSTusing a best effort conversion. UseSingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)if you want to override that value orSingleAddressHttpClientBuilder.disableHostHeaderFallback()if you want to disable this behavior.- Returns:
- new builder with provided configuration
-
forPartitionedAddress
public static <U,R> PartitionedHttpClientBuilder<U,R> forPartitionedAddress(ServiceDiscoverer<U,R,PartitionedServiceDiscovererEvent<R>> serviceDiscoverer, U address, java.util.function.Function<HttpRequestMetaData,PartitionAttributesBuilder> partitionAttributesBuilderFactory)
Creates aPartitionedHttpClientBuilderfor a custom address type with defaultLoadBalancerand user providedServiceDiscoverer.- Type Parameters:
U- the type of address before resolution (unresolved address)R- the type of address after resolution (resolved address)- Parameters:
serviceDiscoverer- TheServiceDiscovererto resolve addresses of remote servers to connect to. The lifecycle of the providedServiceDiscoverershould be managed by the caller.address- theUnresolvedAddressto resolve using the providedserviceDiscoverer. This address will also be used for theHttpHeaderNames.HOSTusing a best effort conversion. UsePartitionedHttpClientBuilder.unresolvedAddressToHost(Function)if you want to override that value orPartitionedHttpClientBuilder.disableHostHeaderFallback()if you want to disable this behavior.partitionAttributesBuilderFactory- The factoryFunctionused to buildPartitionAttributesfromHttpRequestMetaData.- Returns:
- new builder with provided configuration
-
-