Class HttpConnection

java.lang.Object
io.vertx.mutiny.core.http.HttpConnection
All Implemented Interfaces:
MutinyDelegate
Direct Known Subclasses:
HttpClientConnection

public class HttpConnection extends Object implements MutinyDelegate
Represents an HTTP connection.

HTTP/1.x connection provides a limited implementation, the following methods are implemented:

NOTE: This class has been automatically generated from the original non Mutiny-ified interface.

Author:
Julien Viet
See Also:
  • HttpConnection
  • Field Details

  • Constructor Details

    • HttpConnection

      public HttpConnection(io.vertx.core.http.HttpConnection delegate)
      Create a new instance of HttpConnection delegating to the given (non-null) instance of HttpConnection.
    • HttpConnection

      public HttpConnection(Object delegate)
  • Method Details

    • getDelegate

      public io.vertx.core.http.HttpConnection getDelegate()
      Get the delegate instance.

      This method returns the instance on which this shim is delegating the calls. And so, give you access to the bare API.

      Specified by:
      getDelegate in interface MutinyDelegate
      Returns:
      the delegate instance
    • shutdown

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> shutdown()
      Shutdown with a 30 seconds timeout (shutdown(30, TimeUnit.SECONDS)).

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • HttpConnection.shutdown()
    • shutdownAndAwait

      public void shutdownAndAwait()
      Shutdown with a 30 seconds timeout (shutdown(30, TimeUnit.SECONDS)).

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      See Also:
      • HttpConnection.shutdown()
    • shutdownAndForget

      public HttpConnection shutdownAndForget()
      Shutdown with a 30 seconds timeout (shutdown(30, TimeUnit.SECONDS)).

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Returns:
      The current instance to chain operations if needed.
      See Also:
      • HttpConnection.shutdown()
    • shutdown

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> shutdown(long timeout, TimeUnit unit)
      Calls shutdown(Duration)

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • HttpConnection.shutdown(long, TimeUnit)
    • shutdownAndAwait

      public void shutdownAndAwait(long timeout, TimeUnit unit)
      Calls shutdown(Duration)

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      See Also:
      • HttpConnection.shutdown(long, TimeUnit)
    • shutdownAndForget

      public HttpConnection shutdownAndForget(long timeout, TimeUnit unit)
      Calls shutdown(Duration)

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Returns:
      The current instance to chain operations if needed.
      See Also:
      • HttpConnection.shutdown(long, TimeUnit)
    • shutdown

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> shutdown(Duration timeout)
      Initiate a graceful connection shutdown, the connection is taken out of service and closed when all the inflight requests are processed, otherwise after a timeout 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 connection will be closed.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Parameters:
      timeout - the amount of time after which all resources are forcibly closed
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • HttpConnection.shutdown(Duration)
    • shutdownAndAwait

      public void shutdownAndAwait(Duration timeout)
      Initiate a graceful connection shutdown, the connection is taken out of service and closed when all the inflight requests are processed, otherwise after a timeout 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 connection will be closed.

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      timeout - the amount of time after which all resources are forcibly closed
      See Also:
      • HttpConnection.shutdown(Duration)
    • shutdownAndForget

      public HttpConnection shutdownAndForget(Duration timeout)
      Initiate a graceful connection shutdown, the connection is taken out of service and closed when all the inflight requests are processed, otherwise after a timeout 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 connection will be closed.

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Parameters:
      timeout - the amount of time after which all resources are forcibly closed
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • HttpConnection.shutdown(Duration)
    • close

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> close()
      Close immediately (shutdown(0, TimeUnit.SECONDS).

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • HttpConnection.close()
    • closeAndAwait

      public void closeAndAwait()
      Close immediately (shutdown(0, TimeUnit.SECONDS).

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      See Also:
      • HttpConnection.close()
    • closeAndForget

      public HttpConnection closeAndForget()
      Close immediately (shutdown(0, TimeUnit.SECONDS).

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Returns:
      The current instance to chain operations if needed.
      See Also:
      • HttpConnection.close()
    • updateSettings

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> updateSettings(io.vertx.core.http.HttpSettings settings)
      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.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Parameters:
      settings - the new settings
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • HttpConnection.updateSettings(HttpSettings)
    • updateSettingsAndAwait

      public void updateSettingsAndAwait(io.vertx.core.http.HttpSettings settings)
      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.

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      settings - the new settings
      See Also:
      • HttpConnection.updateSettings(HttpSettings)
    • updateSettingsAndForget

      public HttpConnection updateSettingsAndForget(io.vertx.core.http.HttpSettings settings)
      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.

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Parameters:
      settings - the new settings
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • HttpConnection.updateSettings(HttpSettings)
    • ping

      @CheckReturnValue public io.smallrye.mutiny.Uni<io.vertx.core.buffer.Buffer> ping(io.vertx.core.buffer.Buffer data)
      Send a PING frame to the remote endpoint.

      This is not implemented for HTTP/1.x.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Parameters:
      data - the 8 bytes data of the frame
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • HttpConnection.ping(Buffer)
    • pingAndAwait

      public io.vertx.core.buffer.Buffer pingAndAwait(io.vertx.core.buffer.Buffer data)
      Send a PING frame to the remote endpoint.

      This is not implemented for HTTP/1.x.

      Unlike the bare Vert.x variant, this method returns a Buffer. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      data - the 8 bytes data of the frame
      Returns:
      The operation result
      See Also:
      • HttpConnection.ping(Buffer)
    • pingAndForget

      public HttpConnection pingAndForget(io.vertx.core.buffer.Buffer data)
      Send a PING frame to the remote endpoint.

      This is not implemented for HTTP/1.x.

      Unlike the bare Vert.x variant, this method ignores the Buffer result or any failure.

      Parameters:
      data - the 8 bytes data of the frame
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • HttpConnection.ping(Buffer)
    • protocolVersion

      public io.vertx.core.http.HttpVersion protocolVersion()
      Returns:
      the version of the protocol of this connection
    • getWindowSize

      public int getWindowSize()
      Returns:
      the current connection window size or -1 for HTTP/1.x
    • setWindowSize

      public 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

      @Deprecated public HttpConnection goAway(long errorCode)
      Deprecated.
      instead use shutdown()
      Like goAway(long, int) with a last stream id -1 which means to disallow any new stream creation.
    • goAway

      @Deprecated public HttpConnection goAway(long errorCode, int lastStreamId)
      Deprecated.
      instead use shutdown()
      Like goAway(long, int, Buffer) with no buffer.
    • goAway

      @Deprecated public HttpConnection goAway(long errorCode, int lastStreamId, io.vertx.core.buffer.Buffer debugData)
      Deprecated.
      instead use shutdown()
      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

      public HttpConnection goAwayHandler(Consumer<io.vertx.core.http.GoAway> handler)
      Set an handler called when a GOAWAY frame is received.

      This is not implemented for HTTP/1.x.

      Parameters:
      handler - the handler. Can be null.
      Returns:
      a reference to this, so the API can be used fluently
    • shutdownHandler

      public HttpConnection shutdownHandler(Runnable handler)
      Set a handler notified when the HTTP connection is shutdown: the client or server will close the connection within a certain amount of time. This gives the opportunity to the handler to close the current requests in progress gracefully before the HTTP connection is forcefully closed.
      Parameters:
      handler - the handler. Can be null.
      Returns:
      a reference to this, so the API can be used fluently
    • closeHandler

      public HttpConnection closeHandler(Runnable 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
    • settings

      public io.vertx.core.http.HttpSettings settings()
      Returns:
      the latest server settings acknowledged by the remote endpoint - this is not implemented for HTTP/1.x
    • remoteSettings

      public io.vertx.core.http.HttpSettings remoteSettings()
      Returns:
      the current remote endpoint settings for this connection - this is not implemented for HTTP/1.x
    • remoteSettingsHandler

      public HttpConnection remoteSettingsHandler(Consumer<io.vertx.core.http.HttpSettings> handler)
      Set an handler that is called when remote endpoint HttpSettings 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
    • pingHandler

      public HttpConnection pingHandler(Consumer<io.vertx.core.buffer.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. Can be null.
      Returns:
      a reference to this, so the API can be used fluently
    • exceptionHandler

      public HttpConnection exceptionHandler(Consumer<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

      public io.vertx.core.net.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.
    • remoteAddress

      public io.vertx.core.net.SocketAddress remoteAddress(boolean real)
      Like remoteAddress() but returns the proxy remote address when real is true
    • localAddress

      public io.vertx.core.net.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.
    • localAddress

      public io.vertx.core.net.SocketAddress localAddress(boolean real)
      Like localAddress() ()} but returns the server local address when real is true
    • isSsl

      public boolean isSsl()
      Returns:
      true if this HttpConnection is encrypted via SSL/TLS.
    • sslSession

      public SSLSession sslSession()
      Returns:
      SSLSession associated with the underlying socket. Returns null if connection is not SSL.
      See Also:
    • indicatedServerName

      public String indicatedServerName()
      Returns the SNI server name presented during the SSL handshake by the client.
      Returns:
      the indicated server name
    • newInstance

      public static HttpConnection newInstance(io.vertx.core.http.HttpConnection delegate)
      Creates a new instance of the HttpConnection.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object