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 and 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
`void` `addCloseListener(org.xnio.ChannelListener<ClientConnection> listener)` Adds a close listener, than will be invoked with the connection is closed
`void` `close()`
`ByteBufferPool` `getBufferPool()`
`org.xnio.ChannelListener.Setter<? extends ClientConnection>` `getCloseSetter()`
`org.xnio.XnioIoThread` `getIoThread()`
`SocketAddress` `getLocalAddress()`
`<A extends SocketAddress> A` `getLocalAddress(Class<A> type)`
`<T> T` `getOption(org.xnio.Option<T> option)`
`SocketAddress` `getPeerAddress()`
`<A extends SocketAddress> A` `getPeerAddress(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)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### 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 the `ClientExchange`

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 interface `ClientConnection`
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 interface `ClientConnection`
Returns:
  The resulting StreamConnection
Throws:
  `IOException`

#### getBufferPool

    public ByteBufferPool getBufferPool()

Specified by:
  `getBufferPool` in interface `ClientConnection`
Returns:
  The buffer pool used by the client

#### getPeerAddress

    public SocketAddress getPeerAddress()

Specified by:
  `getPeerAddress` in interface `ClientConnection`

#### getPeerAddress

    public <A extends SocketAddress> A getPeerAddress(Class<A> type)

Specified by:
  `getPeerAddress` in interface `ClientConnection`

#### getCloseSetter

    public org.xnio.ChannelListener.Setter<? extends ClientConnection> getCloseSetter()

Specified by:
  `getCloseSetter` in interface `ClientConnection`

#### getLocalAddress

    public SocketAddress getLocalAddress()

Specified by:
  `getLocalAddress` in interface `ClientConnection`

#### getLocalAddress

    public <A extends SocketAddress> A getLocalAddress(Class<A> type)

Specified by:
  `getLocalAddress` in interface `ClientConnection`

#### getWorker

    public org.xnio.XnioWorker getWorker()

Specified by:
  `getWorker` in interface `ClientConnection`

#### getIoThread

    public org.xnio.XnioIoThread getIoThread()

Specified by:
  `getIoThread` in interface `ClientConnection`

#### isOpen

    public boolean isOpen()

Specified by:
  `isOpen` in interface `ClientConnection`
Specified by:
  `isOpen` in interface `Channel`

#### close

    public void close()
               throws IOException

Specified by:
  `close` in interface `Closeable`
Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Channel`
Throws:
  `IOException`

#### supportsOption

    public boolean supportsOption(org.xnio.Option<?> option)

Specified by:
  `supportsOption` in interface `ClientConnection`

#### getOption

    public <T> T getOption(org.xnio.Option<T> option)
                    throws IOException

Specified by:
  `getOption` in interface `ClientConnection`
Throws:
  `IOException`

#### setOption

    public <T> T setOption(org.xnio.Option<T> option,
                           T value)
                    throws IllegalArgumentException,
                           IOException

Specified by:
  `setOption` in interface `ClientConnection`
Throws:
  `IllegalArgumentException`
  `IOException`

#### isUpgraded

    public boolean isUpgraded()

Specified by:
  `isUpgraded` in interface `ClientConnection`

#### isPushSupported

    public boolean isPushSupported()

Specified by:
  `isPushSupported` in interface `ClientConnection`
Returns:
  `true` if this connection support server push

#### isMultiplexingSupported

    public boolean isMultiplexingSupported()

Specified by:
  `isMultiplexingSupported` in interface `ClientConnection`
Returns:
  `true` if this client supports multiplexing

#### getStatistics

    public ClientStatistics getStatistics()

Specified by:
  `getStatistics` in interface `ClientConnection`
Returns:
  the statistics information, or `null` if statistics are not supported or disabled

#### isUpgradeSupported

    public boolean isUpgradeSupported()

Specified by:
  `isUpgradeSupported` in interface `ClientConnection`

#### 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 interface `ClientConnection`
Parameters:
  `listener` - The close listener

#### isPingSupported

    public boolean isPingSupported()

Specified by:
  `isPingSupported` in interface `ClientConnection`
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 interface `ClientConnection`