org.apache.hc.core5.http.impl.nio

## Class ClientHttp1StreamDuplexer

- java.lang.Object
- - org.apache.hc.core5.http.impl.nio.ClientHttp1StreamDuplexer

- All Implemented Interfaces:
    Closeable, AutoCloseable, HttpConnection, SocketModalCloseable, ModalCloseable, ProtocolLayer, Identifiable

      @Internal
      public class ClientHttp1StreamDuplexer
      extends Object

  I/O event handler for events fired by `ProtocolIOSession` that implements client side HTTP/1.1 messaging protocol with full support for duplexed message transmission and message pipelining.
  Since:
    5.0

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClientHttp1StreamDuplexer(ProtocolIOSession ioSession, HttpProcessor httpProcessor, Http1Config http1Config, CharCodingConfig charCodingConfig, ConnectionReuseStrategy connectionReuseStrategy, NHttpMessageParser<HttpResponse> incomingMessageParser, NHttpMessageWriter<HttpRequest> outgoingMessageWriter, ContentLengthStrategy incomingContentStrategy, ContentLengthStrategy outgoingContentStrategy, Http1StreamListener streamListener)`
    `ClientHttp1StreamDuplexer(ProtocolIOSession ioSession, HttpProcessor httpProcessor, Http1Config http1Config, CharCodingConfig charCodingConfig, ConnectionReuseStrategy connectionReuseStrategy, NHttpMessageParser<HttpResponse> incomingMessageParser, NHttpMessageWriter<HttpRequest> outgoingMessageWriter, ContentLengthStrategy incomingContentStrategy, ContentLengthStrategy outgoingContentStrategy, Lookup<ProtocolUpgradeHandler> protocolUpgradeHandlerLookup, Http1StreamListener streamListener)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Closes this connection gracefully.
    `void` | `close(CloseMode closeMode)` Closes this process or endpoint and releases any system resources associated with it.
    `protected ContentDecoder` | `createContentDecoder(long len, ReadableByteChannel channel, SessionInputBuffer buffer, BasicHttpTransportMetrics metrics)`
    `protected ContentEncoder` | `createContentEncoder(long len, WritableByteChannel channel, SessionOutputBuffer buffer, BasicHttpTransportMetrics metrics)`
    `EndpointDetails` | `getEndpointDetails()` Returns this connection's endpoint details.
    `String` | `getId()`
    `SocketAddress` | `getLocalAddress()` Returns this connection's local address or `null` if it is not bound yet.
    `ProtocolVersion` | `getProtocolVersion()` Returns this connection's protocol version or `null` if unknown.
    `SocketAddress` | `getRemoteAddress()` Returns this connection's remote address or `null` if it is not connected yet or unconnected.
    `Timeout` | `getSocketTimeout()` Returns the socket timeout value.
    `SSLSession` | `getSSLSession()` Returns this connection's SSL session or `null` if TLS has not been activated.
    `protected boolean` | `handleIncomingMessage(HttpResponse response)`
    `protected boolean` | `handleOutgoingMessage(HttpRequest request)`
    `boolean` | `isOpen()` Checks if this connection is open.
    `void` | `onConnect()`
    `void` | `onDisconnect()`
    `void` | `onException(Exception ex)`
    `void` | `onInput(ByteBuffer src)`
    `void` | `onOutput()`
    `void` | `onTimeout(Timeout timeout)`
    `void` | `setSocketTimeout(Timeout timeout)` Sets the socket timeout value.
    `String` | `toString()`
    `void` | `upgrade(ProtocolUpgradeHandler upgradeHandler, EndpointParameters parameters)` Switches to the given application protocol.
    `void` | `upgrade(String id, EndpointParameters parameters)` Switches to the application protocol with the given protocol id.

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

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

- - ### Constructor Detail

    - #### ClientHttp1StreamDuplexer

          public ClientHttp1StreamDuplexer(ProtocolIOSession ioSession,
                                   HttpProcessor httpProcessor,
                                   Http1Config http1Config,
                                   CharCodingConfig charCodingConfig,
                                   ConnectionReuseStrategy connectionReuseStrategy,
                                   NHttpMessageParser<HttpResponse> incomingMessageParser,
                                   NHttpMessageWriter<HttpRequest> outgoingMessageWriter,
                                   ContentLengthStrategy incomingContentStrategy,
                                   ContentLengthStrategy outgoingContentStrategy,
                                   Http1StreamListener streamListener)

    - #### ClientHttp1StreamDuplexer

          public ClientHttp1StreamDuplexer(ProtocolIOSession ioSession,
                                   HttpProcessor httpProcessor,
                                   Http1Config http1Config,
                                   CharCodingConfig charCodingConfig,
                                   ConnectionReuseStrategy connectionReuseStrategy,
                                   NHttpMessageParser<HttpResponse> incomingMessageParser,
                                   NHttpMessageWriter<HttpRequest> outgoingMessageWriter,
                                   ContentLengthStrategy incomingContentStrategy,
                                   ContentLengthStrategy outgoingContentStrategy,
                                   Lookup<ProtocolUpgradeHandler> protocolUpgradeHandlerLookup,
                                   Http1StreamListener streamListener)

      Since:
        5.1

  - ### Method Detail

    - #### handleIncomingMessage

          protected boolean handleIncomingMessage(HttpResponse response)
                                           throws HttpException

      Throws:
        `HttpException`

    - #### createContentDecoder

          protected ContentDecoder createContentDecoder(long len,
                                            ReadableByteChannel channel,
                                            SessionInputBuffer buffer,
                                            BasicHttpTransportMetrics metrics)
                                                 throws HttpException

      Throws:
        `HttpException`

    - #### handleOutgoingMessage

          protected boolean handleOutgoingMessage(HttpRequest request)
                                           throws HttpException

      Throws:
        `HttpException`

    - #### createContentEncoder

          protected ContentEncoder createContentEncoder(long len,
                                            WritableByteChannel channel,
                                            SessionOutputBuffer buffer,
                                            BasicHttpTransportMetrics metrics)
                                                 throws HttpException

      Throws:
        `HttpException`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### getId

          public String getId()

      Specified by:
        `getId` in interface `Identifiable`

    - #### onConnect

          public final void onConnect()
                               throws HttpException,
                                      IOException

      Throws:
        `HttpException`
        `IOException`

    - #### onInput

          public final void onInput(ByteBuffer src)
                             throws HttpException,
                                    IOException

      Throws:
        `HttpException`
        `IOException`

    - #### onOutput

          public final void onOutput()
                              throws IOException,
                                     HttpException

      Throws:
        `IOException`
        `HttpException`

    - #### onTimeout

          public final void onTimeout(Timeout timeout)
                               throws IOException,
                                      HttpException

      Throws:
        `IOException`
        `HttpException`

    - #### onException

          public final void onException(Exception ex)

    - #### onDisconnect

          public final void onDisconnect()

    - #### close

          public void close()
                     throws IOException

      Description copied from interface: `HttpConnection`
      Closes this connection gracefully. This method will attempt to flush the internal output buffer prior to closing the underlying socket. This method MUST NOT be called from a different thread to force shutdown of the connection. Use `shutdown` instead.
      Specified by:
        `close` in interface `Closeable`
      Specified by:
        `close` in interface `AutoCloseable`
      Specified by:
        `close` in interface `HttpConnection`
      Throws:
        `IOException`

    - #### close

          public void close(CloseMode closeMode)

      Description copied from interface: `ModalCloseable`
      Closes this process or endpoint and releases any system resources associated with it. If the endpoint or the process is already closed then invoking this method has no effect.
      Specified by:
        `close` in interface `ModalCloseable`
      Parameters:
        `closeMode` - How to close the receiver.

    - #### isOpen

          public boolean isOpen()

      Description copied from interface: `HttpConnection`
      Checks if this connection is open.
      Specified by:
        `isOpen` in interface `HttpConnection`
      Returns:
        true if it is open, false if it is closed.

    - #### getSocketTimeout

          public Timeout getSocketTimeout()

      Description copied from interface: `SocketModalCloseable`
      Returns the socket timeout value.
      Specified by:
        `getSocketTimeout` in interface `SocketModalCloseable`
      Returns:
        timeout value.

    - #### setSocketTimeout

          public void setSocketTimeout(Timeout timeout)

      Description copied from interface: `SocketModalCloseable`
      Sets the socket timeout value.
      Specified by:
        `setSocketTimeout` in interface `SocketModalCloseable`
      Parameters:
        `timeout` - timeout value

    - #### getEndpointDetails

          public EndpointDetails getEndpointDetails()

      Description copied from interface: `HttpConnection`
      Returns this connection's endpoint details.
      Specified by:
        `getEndpointDetails` in interface `HttpConnection`
      Returns:
        this connection's endpoint details.

    - #### getProtocolVersion

          public ProtocolVersion getProtocolVersion()

      Description copied from interface: `HttpConnection`
      Returns this connection's protocol version or `null` if unknown.
      Specified by:
        `getProtocolVersion` in interface `HttpConnection`
      Returns:
        this connection's protocol version or `null` if unknown.

    - #### getRemoteAddress

          public SocketAddress getRemoteAddress()

      Description copied from interface: `HttpConnection`
      Returns this connection's remote address or `null` if it is not connected yet or unconnected.
      Specified by:
        `getRemoteAddress` in interface `HttpConnection`
      Returns:
        this connection's remote address or `null` if it is not connected yet or unconnected.

    - #### getLocalAddress

          public SocketAddress getLocalAddress()

      Description copied from interface: `HttpConnection`
      Returns this connection's local address or `null` if it is not bound yet.
      Specified by:
        `getLocalAddress` in interface `HttpConnection`
      Returns:
        this connection's local address or `null` if it is not bound yet.

    - #### getSSLSession

          public SSLSession getSSLSession()

      Description copied from interface: `HttpConnection`
      Returns this connection's SSL session or `null` if TLS has not been activated.
      Specified by:
        `getSSLSession` in interface `HttpConnection`
      Returns:
        this connection's SSL session or `null` if TLS has not been activated.

    - #### upgrade

          public void upgrade(ProtocolUpgradeHandler upgradeHandler,
                     EndpointParameters parameters)
                       throws UnsupportedOperationException

      Description copied from interface: `ProtocolLayer`
      Switches to the given application protocol.
      Specified by:
        `upgrade` in interface `ProtocolLayer`
      Throws:
        `UnsupportedOperationException`

    - #### upgrade

          public void upgrade(String id,
                     EndpointParameters parameters)
                       throws UnsupportedOperationException

      Description copied from interface: `ProtocolLayer`
      Switches to the application protocol with the given protocol id.
      Specified by:
        `upgrade` in interface `ProtocolLayer`
      Throws:
        `UnsupportedOperationException`

Copyright © 2005–2020 The Apache Software Foundation. All rights reserved.