org.apache.http.nio

## Interface NHttpConnection

- All Superinterfaces:
    AutoCloseable, Closeable, HttpConnection, IOControl
  All Known Subinterfaces:
    NHttpClientConnection, NHttpClientIOTarget, NHttpServerConnection, NHttpServerIOTarget
  All Known Implementing Classes:
    DefaultNHttpClientConnection, DefaultNHttpServerConnection, NHttpConnectionBase

      public interface NHttpConnection
      extends HttpConnection, IOControl

  Abstract non-blocking HTTP connection interface. Each connection contains an HTTP execution context, which can be used to maintain a processing state, as well as the actual `HttpRequest` and `HttpResponse` that are being transmitted over this connection. Both the request and the response objects can be `null` if there is no incoming or outgoing message currently being transferred.

  Please note non-blocking HTTP connections are stateful and not thread safe. Input / output operations on non-blocking HTTP connections should be restricted to the dispatch events triggered by the I/O event dispatch thread. However, the `IOControl` interface is fully threading safe and can be manipulated from any thread.

  Since:
    4.0

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `ACTIVE`
    `static int` | `CLOSED`
    `static int` | `CLOSING`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `HttpContext` | `getContext()` Returns an HTTP execution context associated with this connection.
    `HttpRequest` | `getHttpRequest()` Returns the current HTTP request if one is being received / transmitted.
    `HttpResponse` | `getHttpResponse()` Returns the current HTTP response if one is being received / transmitted.
    `int` | `getStatus()` Returns status of the connection:

    - ### Methods inherited from interface org.apache.http.HttpConnection

      `close, getMetrics, getSocketTimeout, isOpen, isStale, setSocketTimeout, shutdown`

    - ### Methods inherited from interface org.apache.http.nio.IOControl

      `requestInput, requestOutput, shutdown, suspendInput, suspendOutput`

- - ### Field Detail

    - #### ACTIVE

          static final int ACTIVE

      See Also:
        Constant Field Values

    - #### CLOSING

          static final int CLOSING

      See Also:
        Constant Field Values

    - #### CLOSED

          static final int CLOSED

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### getStatus

          int getStatus()

      Returns status of the connection:

      `ACTIVE`: connection is active.

      `CLOSING`: connection is being closed.

      `CLOSED`: connection has been closed.

      Returns:
        connection status.

    - #### getHttpRequest

          HttpRequest getHttpRequest()

      Returns the current HTTP request if one is being received / transmitted. Otherwise returns `null`.
      Returns:
        HTTP request, if available, `null` otherwise.

    - #### getHttpResponse

          HttpResponse getHttpResponse()

      Returns the current HTTP response if one is being received / transmitted. Otherwise returns `null`.
      Returns:
        HTTP response, if available, `null` otherwise.

    - #### getContext

          HttpContext getContext()

      Returns an HTTP execution context associated with this connection.
      Returns:
        HTTP context

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