io.vertx.core.http

## Interface HttpConnection

-     public interface HttpConnection

  Represents an HTTP connection.

  HTTP/1.x connection provides an limited implementation, the following methods are implemented:
  - `close()`
  - `closeHandler(io.vertx.core.Handler<java.lang.Void>)`
  - `exceptionHandler(io.vertx.core.Handler<java.lang.Throwable>)`
  Author:
    Julien Viet

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `Future<Void>` | `close()` Close the connection and all the currently active streams.
    `HttpConnection` | `closeHandler(Handler<Void> handler)` Set a close handler.
    `HttpConnection` | `exceptionHandler(Handler<Throwable> handler)` Set an handler called when a connection error happens
    `default int` | `getWindowSize()`
    `default HttpConnection` | `goAway(long errorCode)` Like `goAway(long, int)` with a last stream id `-1` which means to disallow any new stream creation.
    `default HttpConnection` | `goAway(long errorCode, int lastStreamId)` Like `goAway(long, int, Buffer)` with no buffer.
    `HttpConnection` | `goAway(long errorCode, int lastStreamId, Buffer debugData)` Send a go away frame to the remote endpoint of the connection.
    `HttpConnection` | `goAwayHandler(Handler<GoAway> handler)` Set an handler called when a GOAWAY frame is received.
    `String` | `indicatedServerName()` Returns the SNI server name presented during the SSL handshake by the client.
    `boolean` | `isSsl()`
    `SocketAddress` | `localAddress()`
    `X509Certificate[]` | `peerCertificateChain()` Note: Java SE 5+ recommends to use javax.net.ssl.SSLSession#getPeerCertificates() instead of of javax.net.ssl.SSLSession#getPeerCertificateChain() which this method is based on.
    `Future<Buffer>` | `ping(Buffer data)` Same as `ping(Buffer, Handler)` but returns a `Future` of the asynchronous result
    `HttpConnection` | `ping(Buffer data, Handler<AsyncResult<Buffer>> pongHandler)` Send a PING frame to the remote endpoint.
    `HttpConnection` | `pingHandler(Handler<Buffer> handler)` Set an handler notified when a PING frame is received from the remote endpoint.
    `SocketAddress` | `remoteAddress()`
    `Http2Settings` | `remoteSettings()`
    `HttpConnection` | `remoteSettingsHandler(Handler<Http2Settings> handler)` Set an handler that is called when remote endpoint `Http2Settings` are updated.
    `Http2Settings` | `settings()`
    `default HttpConnection` | `setWindowSize(int windowSize)` Update the current connection wide window size to a new size.
    `default Future<Void>` | `shutdown()` Like `shutdown(Handler)` but returns a `Future` of the asynchronous result
    `default void` | `shutdown(Handler<AsyncResult<Void>> handler)` Initiate a graceful connection shutdown, the connection is taken out of service and closed when all current requests are processed, otherwise after 30 seconds the connection will be closed.
    `Future<Void>` | `shutdown(long timeoutMs)` Like `shutdown(long, Handler)` but returns a `Future` of the asynchronous result
    `void` | `shutdown(long timeout, Handler<AsyncResult<Void>> handler)` Like `shutdown(Handler)` but with a specific `timeout` in milliseconds.
    `HttpConnection` | `shutdownHandler(Handler<Void> handler)` Set an handler called when a GOAWAY frame has been sent or received and all connections are closed.
    `SSLSession` | `sslSession()`
    `Future<Void>` | `updateSettings(Http2Settings settings)` Send to the remote endpoint an update of the server settings.
    `HttpConnection` | `updateSettings(Http2Settings settings, Handler<AsyncResult<Void>> completionHandler)` Send to the remote endpoint an update of this endpoint settings The `completionHandler` will be notified when the remote endpoint has acknowledged the settings.

- - ### Method Detail

    - #### getWindowSize

          default int getWindowSize()

      Returns:
        the current connection window size or `-1` for HTTP/1.x

    - #### setWindowSize

          default HttpConnection setWindowSize(int windowSize)

      Update the current connection wide window size to a new size.

      Increasing this value, gives better performance when several data streams are multiplexed

      This is not implemented for HTTP/1.x.
      Parameters:
        `windowSize` - the new window size
      Returns:
        a reference to this, so the API can be used fluently

    - #### goAway

          default HttpConnection goAway(long errorCode)

      Like `goAway(long, int)` with a last stream id `-1` which means to disallow any new stream creation.

    - #### goAway

          default HttpConnection goAway(long errorCode,
                                        int lastStreamId)

      Like `goAway(long, int, Buffer)` with no buffer.

    - #### goAway

          HttpConnection goAway(long errorCode,
                                int lastStreamId,
                                Buffer debugData)

      Send a go away frame to the remote endpoint of the connection.

      - a GOAWAY frame is sent to the to the remote endpoint with the `errorCode` and `debugData`
      - any stream created after the stream identified by `lastStreamId` will be closed
      - for an errorCode is different than `0` when all the remaining streams are closed this connection will be closed automatically

      This is not implemented for HTTP/1.x.
      Parameters:
        `errorCode` - the GOAWAY error code
        `lastStreamId` - the last stream id
        `debugData` - additional debug data sent to the remote endpoint
      Returns:
        a reference to this, so the API can be used fluently

    - #### goAwayHandler

          HttpConnection goAwayHandler(Handler<GoAway> handler)

      Set an handler called when a GOAWAY frame is received.

      This is not implemented for HTTP/1.x.
      Parameters:
        `handler` - the handler
      Returns:
        a reference to this, so the API can be used fluently

    - #### shutdownHandler

          HttpConnection shutdownHandler(Handler<Void> handler)

      Set an handler called when a GOAWAY frame has been sent or received and all connections are closed.

      This is not implemented for HTTP/1.x.
      Parameters:
        `handler` - the handler
      Returns:
        a reference to this, so the API can be used fluently

    - #### shutdown

          default void shutdown(Handler<AsyncResult<Void>> handler)

      Initiate a graceful connection shutdown, the connection is taken out of service and closed when all current requests are processed, otherwise after 30 seconds the connection will be closed. Client connection are immediately removed from the pool.
      - HTTP/2 connections will send a go away frame immediately to signal the other side the connection will close
      - HTTP/1.x client connection supports this feature
      - HTTP/1.x server connections do not support this feature
      Parameters:
        `handler` - the handler called when shutdown has completed

    - #### shutdown

          default Future<Void> shutdown()

      Like `shutdown(Handler)` but returns a `Future` of the asynchronous result

    - #### shutdown

          void shutdown(long timeout,
                        Handler<AsyncResult<Void>> handler)

      Like `shutdown(Handler)` but with a specific `timeout` in milliseconds.

    - #### shutdown

          Future<Void> shutdown(long timeoutMs)

      Like `shutdown(long, Handler)` but returns a `Future` of the asynchronous result

    - #### closeHandler

          HttpConnection closeHandler(Handler<Void> handler)

      Set a close handler. The handler will get notified when the connection is closed.
      Parameters:
        `handler` - the handler to be notified
      Returns:
        a reference to this, so the API can be used fluently

    - #### close

          Future<Void> close()

      Close the connection and all the currently active streams.

      An HTTP/2 connection will send a GOAWAY frame before.
      Returns:
        a future completed with the result

    - #### settings

          Http2Settings settings()

      Returns:
        the latest server settings acknowledged by the remote endpoint - this is not implemented for HTTP/1.x

    - #### updateSettings

          Future<Void> updateSettings(Http2Settings settings)

      Send to the remote endpoint an update of the server settings.

      This is not implemented for HTTP/1.x.
      Parameters:
        `settings` - the new settings
      Returns:
        a future completed with the result

    - #### updateSettings

          HttpConnection updateSettings(Http2Settings settings,
                                        Handler<AsyncResult<Void>> completionHandler)

      Send to the remote endpoint an update of this endpoint settings

      The `completionHandler` will be notified when the remote endpoint has acknowledged the settings.

      This is not implemented for HTTP/1.x.
      Parameters:
        `settings` - the new settings
        `completionHandler` - the handler notified when the settings have been acknowledged by the remote endpoint
      Returns:
        a reference to this, so the API can be used fluently

    - #### remoteSettings

          Http2Settings remoteSettings()

      Returns:
        the current remote endpoint settings for this connection - this is not implemented for HTTP/1.x

    - #### remoteSettingsHandler

          HttpConnection remoteSettingsHandler(Handler<Http2Settings> handler)

      Set an handler that is called when remote endpoint `Http2Settings` are updated.

      This is not implemented for HTTP/1.x.
      Parameters:
        `handler` - the handler for remote endpoint settings
      Returns:
        a reference to this, so the API can be used fluently

    - #### ping

          HttpConnection ping(Buffer data,
                              Handler<AsyncResult<Buffer>> pongHandler)

      Send a PING frame to the remote endpoint.

      This is not implemented for HTTP/1.x.
      Parameters:
        `data` - the 8 bytes data of the frame
        `pongHandler` - an async result handler notified with pong reply or the failure
      Returns:
        a reference to this, so the API can be used fluently

    - #### ping

          Future<Buffer> ping(Buffer data)

      Same as `ping(Buffer, Handler)` but returns a `Future` of the asynchronous result

    - #### pingHandler

          HttpConnection pingHandler(Handler<Buffer> handler)

      Set an handler notified when a PING frame is received from the remote endpoint.

      This is not implemented for HTTP/1.x.
      Parameters:
        `handler` - the handler to be called when a PING is received
      Returns:
        a reference to this, so the API can be used fluently

    - #### exceptionHandler

          HttpConnection exceptionHandler(Handler<Throwable> handler)

      Set an handler called when a connection error happens
      Parameters:
        `handler` - the handler
      Returns:
        a reference to this, so the API can be used fluently

    - #### remoteAddress

          SocketAddress remoteAddress()

      Returns:
        the remote address for this connection, possibly `null` (e.g a server bound on a domain socket). If `useProxyProtocol` is set to `true`, the address returned will be of the actual connecting client.

    - #### localAddress

          SocketAddress localAddress()

      Returns:
        the local address for this connection, possibly `null` (e.g a server bound on a domain socket) If `useProxyProtocol` is set to `true`, the address returned will be of the proxy.

    - #### isSsl

          boolean isSsl()

      Returns:
        true if this `HttpConnection` is encrypted via SSL/TLS.

    - #### sslSession

          SSLSession sslSession()

      Returns:
        SSLSession associated with the underlying socket. Returns null if connection is not SSL.
      See Also:
        `SSLSession`

    - #### peerCertificateChain

          X509Certificate[] peerCertificateChain()
                                          throws SSLPeerUnverifiedException

      Note: Java SE 5+ recommends to use javax.net.ssl.SSLSession#getPeerCertificates() instead of of javax.net.ssl.SSLSession#getPeerCertificateChain() which this method is based on. Use `sslSession()` to access that method.
      Returns:
        an ordered array of the peer certificates. Returns null if connection is not SSL.
      Throws:
        `SSLPeerUnverifiedException` - SSL peer's identity has not been verified.
      See Also:
        `SSLSession.getPeerCertificateChain()`, `sslSession()`

    - #### indicatedServerName

          String indicatedServerName()

      Returns the SNI server name presented during the SSL handshake by the client.
      Returns:
        the indicated server name

Copyright © 2020 Eclipse. All rights reserved.