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
ClientConnection implementation for HTTP2 protocol.- Author:
- Stuart Douglas, Flavia Rainone
-
-
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 voidaddCloseListener(org.xnio.ChannelListener<ClientConnection> listener)Adds a close listener, than will be invoked with the connection is closedvoidclose()ByteBufferPoolgetBufferPool()org.xnio.ChannelListener.Setter<? extends ClientConnection>getCloseSetter()org.xnio.XnioIoThreadgetIoThread()SocketAddressgetLocalAddress()<A extends SocketAddress>
AgetLocalAddress(Class<A> type)<T> TgetOption(org.xnio.Option<T> option)SocketAddressgetPeerAddress()<A extends SocketAddress>
AgetPeerAddress(Class<A> type)ClientStatisticsgetStatistics()org.xnio.XnioWorkergetWorker()booleanisMultiplexingSupported()booleanisOpen()booleanisPingSupported()booleanisPushSupported()booleanisUpgraded()booleanisUpgradeSupported()org.xnio.StreamConnectionperformUpgrade()Upgrade the connection, if the underlying protocol supports it.voidsendPing(ClientConnection.PingListener listener, long timeout, TimeUnit timeUnit)voidsendRequest(ClientRequest request, ClientCallback<ClientExchange> clientCallback)Sends a client request.<T> TsetOption(org.xnio.Option<T> option, T value)booleansupportsOption(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:ClientConnectionSends 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
clientCallbackis invoked to provide the caller with theClientExchangeIf
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:
sendRequestin interfaceClientConnection- Parameters:
request- The request to send.
-
performUpgrade
public org.xnio.StreamConnection performUpgrade() throws IOExceptionDescription copied from interface:ClientConnectionUpgrade 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:
performUpgradein interfaceClientConnection- Returns:
- The resulting StreamConnection
- Throws:
IOException
-
getBufferPool
public ByteBufferPool getBufferPool()
- Specified by:
getBufferPoolin interfaceClientConnection- Returns:
- The buffer pool used by the client
-
getPeerAddress
public SocketAddress getPeerAddress()
- Specified by:
getPeerAddressin interfaceClientConnection
-
getPeerAddress
public <A extends SocketAddress> A getPeerAddress(Class<A> type)
- Specified by:
getPeerAddressin interfaceClientConnection
-
getCloseSetter
public org.xnio.ChannelListener.Setter<? extends ClientConnection> getCloseSetter()
- Specified by:
getCloseSetterin interfaceClientConnection
-
getLocalAddress
public SocketAddress getLocalAddress()
- Specified by:
getLocalAddressin interfaceClientConnection
-
getLocalAddress
public <A extends SocketAddress> A getLocalAddress(Class<A> type)
- Specified by:
getLocalAddressin interfaceClientConnection
-
getWorker
public org.xnio.XnioWorker getWorker()
- Specified by:
getWorkerin interfaceClientConnection
-
getIoThread
public org.xnio.XnioIoThread getIoThread()
- Specified by:
getIoThreadin interfaceClientConnection
-
isOpen
public boolean isOpen()
- Specified by:
isOpenin interfaceChannel- Specified by:
isOpenin interfaceClientConnection
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceChannel- Specified by:
closein interfaceCloseable- Throws:
IOException
-
supportsOption
public boolean supportsOption(org.xnio.Option<?> option)
- Specified by:
supportsOptionin interfaceClientConnection
-
getOption
public <T> T getOption(org.xnio.Option<T> option) throws IOException- Specified by:
getOptionin interfaceClientConnection- Throws:
IOException
-
setOption
public <T> T setOption(org.xnio.Option<T> option, T value) throws IllegalArgumentException, IOException- Specified by:
setOptionin interfaceClientConnection- Throws:
IllegalArgumentExceptionIOException
-
isUpgraded
public boolean isUpgraded()
- Specified by:
isUpgradedin interfaceClientConnection
-
isPushSupported
public boolean isPushSupported()
- Specified by:
isPushSupportedin interfaceClientConnection- Returns:
trueif this connection support server push
-
isMultiplexingSupported
public boolean isMultiplexingSupported()
- Specified by:
isMultiplexingSupportedin interfaceClientConnection- Returns:
trueif this client supports multiplexing
-
getStatistics
public ClientStatistics getStatistics()
- Specified by:
getStatisticsin interfaceClientConnection- Returns:
- the statistics information, or
nullif statistics are not supported or disabled
-
isUpgradeSupported
public boolean isUpgradeSupported()
- Specified by:
isUpgradeSupportedin interfaceClientConnection
-
addCloseListener
public void addCloseListener(org.xnio.ChannelListener<ClientConnection> listener)
Description copied from interface:ClientConnectionAdds a close listener, than will be invoked with the connection is closed- Specified by:
addCloseListenerin interfaceClientConnection- Parameters:
listener- The close listener
-
isPingSupported
public boolean isPingSupported()
- Specified by:
isPingSupportedin interfaceClientConnection- Returns:
trueif the underlying protocol supports sending a ping
-
sendPing
public void sendPing(ClientConnection.PingListener listener, long timeout, TimeUnit timeUnit)
- Specified by:
sendPingin interfaceClientConnection
-
-