vertx / io.vertx.core.http / HttpConnection

HttpConnection

interface HttpConnection

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

Author
Julien Viet

Functions

close

abstract fun close(): Unit

Close the connection and all the currently active streams. An HTTP/2 connection will send a GOAWAY frame before.

closeHandler

abstract fun closeHandler(handler: Handler<Void>): HttpConnection

Set a close handler. The handler will get notified when the connection is closed.

exceptionHandler

abstract fun exceptionHandler(handler: Handler<Throwable>): HttpConnection

Set an handler called when a connection error happens

getWindowSize

open fun getWindowSize(): Int

goAway

open fun goAway(errorCode: Long): HttpConnection

Like #goAway(long, int) with a last stream id 2^31-1.

open fun goAway(errorCode: Long, lastStreamId: Int): HttpConnection

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

abstract fun goAway(errorCode: Long, lastStreamId: Int, debugData: Buffer): HttpConnection

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.

goAwayHandler

abstract fun goAwayHandler(handler: Handler<GoAway>): HttpConnection

Set an handler called when a GOAWAY frame is received. This is not implemented for HTTP/1.x.

indicatedServerName

abstract fun indicatedServerName(): String

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

isSsl

abstract fun isSsl(): Boolean

localAddress

abstract fun localAddress(): SocketAddress

peerCertificateChain

abstract fun peerCertificateChain(): Array<X509Certificate>

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.

ping

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

Send a PING frame to the remote endpoint. This is not implemented for HTTP/1.x.

pingHandler

abstract fun pingHandler(handler: Handler<Buffer>): HttpConnection

Set an handler notified when a PING frame is received from the remote endpoint. This is not implemented for HTTP/1.x.

remoteAddress

abstract fun remoteAddress(): SocketAddress

remoteSettings

abstract fun remoteSettings(): Http2Settings

remoteSettingsHandler

abstract fun remoteSettingsHandler(handler: Handler<Http2Settings>): HttpConnection

Set an handler that is called when remote endpoint Http2Settings are updated. This is not implemented for HTTP/1.x.

setWindowSize

open fun setWindowSize(windowSize: Int): HttpConnection

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.

settings

abstract fun settings(): Http2Settings

shutdown

abstract fun shutdown(): HttpConnection

Initiate a connection shutdown, a go away frame is sent and the connection is closed when all current active streams are closed or after a time out of 30 seconds. This is not implemented for HTTP/1.x.

abstract fun shutdown(timeoutMs: Long): HttpConnection

Initiate a connection shutdown, a go away frame is sent and the connection is closed when all current streams will be closed or the timeout is fired. This is not implemented for HTTP/1.x.

shutdownHandler

abstract fun shutdownHandler(handler: Handler<Void>): HttpConnection

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.

sslSession

abstract fun sslSession(): SSLSession

updateSettings

abstract fun updateSettings(settings: Http2Settings): HttpConnection

Send to the remote endpoint an update of the server settings. This is not implemented for HTTP/1.x.

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

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.