Interface ProxyConfigSelector
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Selects the
ProxyConfig
to use when connecting to a network
resource specified by the SessionProtocol
and Endpoint
parameter.
This class may be used to dynamically control what proxy configuration
to use for each request.
It should be noted that the only guarantee provided is for a single request,
the Endpoint
called with select(SessionProtocol, Endpoint)
will be equal to
the Endpoint
called with connectFailed(SessionProtocol, Endpoint,
SocketAddress, Throwable)
.
For instance, the actual SessionProtocol
of the connection may differ from
the originally requested SessionProtocol
depending on the result of protocol negotiation.
Similarly, the actual Endpoint
of the request may differ from the originally requested
Endpoint
.
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
connectFailed(SessionProtocol protocol, Endpoint endpoint, SocketAddress sa, Throwable throwable)
Called to indicate a connection attempt to the specifiedSessionProtocol
andEndpoint
has failed.static ProxyConfigSelector
of(ProxyConfig proxyConfig)
Returns aProxyConfigSelector
which selects a staticProxyConfig
for all requests.static ProxyConfigSelector
of(ProxySelector proxySelector)
Provides a way to reuse an existingProxySelector
with some limitations.select(SessionProtocol protocol, Endpoint endpoint)
Selects theProxyConfig
to use when connecting to a network resource specified by theSessionProtocol
andEndpoint
parameter.
-
Method Details
-
of
Provides a way to reuse an existingProxySelector
with some limitations.- Incompatibilities when used with JDK's default
ProxySelector
implementation:- Some properties like socksProxyVersion aren't respected
- This class doesn't attempt to resolve scheme format differences.
However, armeria uses some schemes such as "h1c", "h2" which aren't supported by JDK's
default
ProxySelector
. This may be a source of unexpected behavior.
- Selecting multiple
Proxy
isn't supported
- Incompatibilities when used with JDK's default
-
of
Returns aProxyConfigSelector
which selects a staticProxyConfig
for all requests. -
select
Selects theProxyConfig
to use when connecting to a network resource specified by theSessionProtocol
andEndpoint
parameter.- Parameters:
protocol
- the protocol associated with the endpointendpoint
- an endpoint containing the requested host and port- Returns:
- the selected proxy config which should be non-null
-
connectFailed
default void connectFailed(SessionProtocol protocol, Endpoint endpoint, SocketAddress sa, Throwable throwable)Called to indicate a connection attempt to the specifiedSessionProtocol
andEndpoint
has failed.- Parameters:
protocol
- the protocol associated with the endpointendpoint
- an endpoint containing the requested host and portsa
- the remote socket address of the proxy serverthrowable
- the cause of the failure
-