Package io.undertow.client.http2
Class Http2ClientConnection
- java.lang.Object
-
- io.undertow.client.http2.Http2ClientConnection
-
- All Implemented Interfaces:
ClientConnection
,Closeable
,AutoCloseable
,Channel
public class Http2ClientConnection extends Object implements ClientConnection
- Author:
- Stuart Douglas
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.undertow.client.ClientConnection
ClientConnection.PingListener
-
-
Constructor Summary
Constructors Constructor Description Http2ClientConnection(Http2Channel http2Channel, boolean initialUpgradeRequest, String defaultHost, ClientStatistics clientStatistics, boolean secure)
Http2ClientConnection(Http2Channel http2Channel, ClientCallback<ClientExchange> upgradeReadyCallback, ClientRequest clientRequest, String defaultHost, ClientStatistics clientStatistics, boolean secure)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCloseListener(org.xnio.ChannelListener<ClientConnection> listener)
Adds a close listener, than will be invoked with the connection is closedvoid
close()
ByteBufferPool
getBufferPool()
org.xnio.ChannelListener.Setter<? extends ClientConnection>
getCloseSetter()
org.xnio.XnioIoThread
getIoThread()
SocketAddress
getLocalAddress()
<A extends SocketAddress>
AgetLocalAddress(Class<A> type)
<T> T
getOption(org.xnio.Option<T> option)
SocketAddress
getPeerAddress()
<A extends SocketAddress>
AgetPeerAddress(Class<A> type)
ClientStatistics
getStatistics()
org.xnio.XnioWorker
getWorker()
boolean
isMultiplexingSupported()
boolean
isOpen()
boolean
isPingSupported()
boolean
isPushSupported()
boolean
isUpgraded()
boolean
isUpgradeSupported()
org.xnio.StreamConnection
performUpgrade()
Upgrade the connection, if the underlying protocol supports it.void
sendPing(ClientConnection.PingListener listener, long timeout, TimeUnit timeUnit)
void
sendRequest(ClientRequest request, ClientCallback<ClientExchange> clientCallback)
Sends a client request.<T> T
setOption(org.xnio.Option<T> option, T value)
boolean
supportsOption(org.xnio.Option<?> option)
-
-
-
Constructor Detail
-
Http2ClientConnection
public Http2ClientConnection(Http2Channel http2Channel, boolean initialUpgradeRequest, String defaultHost, ClientStatistics clientStatistics, boolean secure)
-
Http2ClientConnection
public Http2ClientConnection(Http2Channel http2Channel, ClientCallback<ClientExchange> upgradeReadyCallback, ClientRequest clientRequest, String defaultHost, ClientStatistics clientStatistics, boolean secure)
-
-
Method Detail
-
sendRequest
public void sendRequest(ClientRequest request, ClientCallback<ClientExchange> clientCallback)
Description copied from interface:ClientConnection
Sends a client request. The request object should not be modified after it has been submitted to the connection.Request objects can be queued. Once the request is in a state that it is ready to be sent the
clientCallback
is invoked to provide the caller with theClientExchange
If
ClientConnection.isMultiplexingSupported()
returns true then multiple requests may be active at the same time, and a later request may complete before an earlier one.Note that the request header may not be written out until after the callback has been invoked. This allows the client to write out a header with a gathering write if the request contains content.
- Specified by:
sendRequest
in interfaceClientConnection
- Parameters:
request
- The request to send.
-
performUpgrade
public org.xnio.StreamConnection performUpgrade() throws IOException
Description copied from interface:ClientConnection
Upgrade the connection, if the underlying protocol supports it. This should only be called after an upgrade request has been submitted and the target server has accepted the upgrade.- Specified by:
performUpgrade
in interfaceClientConnection
- Returns:
- The resulting StreamConnection
- Throws:
IOException
-
getBufferPool
public ByteBufferPool getBufferPool()
- Specified by:
getBufferPool
in interfaceClientConnection
- Returns:
- The buffer pool used by the client
-
getPeerAddress
public SocketAddress getPeerAddress()
- Specified by:
getPeerAddress
in interfaceClientConnection
-
getPeerAddress
public <A extends SocketAddress> A getPeerAddress(Class<A> type)
- Specified by:
getPeerAddress
in interfaceClientConnection
-
getCloseSetter
public org.xnio.ChannelListener.Setter<? extends ClientConnection> getCloseSetter()
- Specified by:
getCloseSetter
in interfaceClientConnection
-
getLocalAddress
public SocketAddress getLocalAddress()
- Specified by:
getLocalAddress
in interfaceClientConnection
-
getLocalAddress
public <A extends SocketAddress> A getLocalAddress(Class<A> type)
- Specified by:
getLocalAddress
in interfaceClientConnection
-
getWorker
public org.xnio.XnioWorker getWorker()
- Specified by:
getWorker
in interfaceClientConnection
-
getIoThread
public org.xnio.XnioIoThread getIoThread()
- Specified by:
getIoThread
in interfaceClientConnection
-
isOpen
public boolean isOpen()
- Specified by:
isOpen
in interfaceChannel
- Specified by:
isOpen
in interfaceClientConnection
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceChannel
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
supportsOption
public boolean supportsOption(org.xnio.Option<?> option)
- Specified by:
supportsOption
in interfaceClientConnection
-
getOption
public <T> T getOption(org.xnio.Option<T> option) throws IOException
- Specified by:
getOption
in interfaceClientConnection
- Throws:
IOException
-
setOption
public <T> T setOption(org.xnio.Option<T> option, T value) throws IllegalArgumentException, IOException
- Specified by:
setOption
in interfaceClientConnection
- Throws:
IllegalArgumentException
IOException
-
isUpgraded
public boolean isUpgraded()
- Specified by:
isUpgraded
in interfaceClientConnection
-
isPushSupported
public boolean isPushSupported()
- Specified by:
isPushSupported
in interfaceClientConnection
- Returns:
true
if this connection support server push
-
isMultiplexingSupported
public boolean isMultiplexingSupported()
- Specified by:
isMultiplexingSupported
in interfaceClientConnection
- Returns:
true
if this client supports multiplexing
-
getStatistics
public ClientStatistics getStatistics()
- Specified by:
getStatistics
in interfaceClientConnection
- Returns:
- the statistics information, or
null
if statistics are not supported or disabled
-
isUpgradeSupported
public boolean isUpgradeSupported()
- Specified by:
isUpgradeSupported
in interfaceClientConnection
-
addCloseListener
public void addCloseListener(org.xnio.ChannelListener<ClientConnection> listener)
Description copied from interface:ClientConnection
Adds a close listener, than will be invoked with the connection is closed- Specified by:
addCloseListener
in interfaceClientConnection
- Parameters:
listener
- The close listener
-
isPingSupported
public boolean isPingSupported()
- Specified by:
isPingSupported
in interfaceClientConnection
- Returns:
true
if the underlying protocol supports sending a ping
-
sendPing
public void sendPing(ClientConnection.PingListener listener, long timeout, TimeUnit timeUnit)
- Specified by:
sendPing
in interfaceClientConnection
-
-