Class: HttpConnection

vertx-js/http_connection~ HttpConnection

new HttpConnection()

Represents an HTTP connection.

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

Source:

Methods

close()

Close the connection and all the currently active streams.

An HTTP/2 connection will send a frame before.

Source:

closeHandler(handler) → {HttpConnection}

Set a close handler. The handler will get notified when the connection is closed.
Parameters:
Name Type Description
handler function the handler to be notified
Source:
Returns:
a reference to this, so the API can be used fluently
Type
HttpConnection

exceptionHandler(handler) → {HttpConnection}

Set an handler called when a connection error happens
Parameters:
Name Type Description
handler function the handler
Source:
Returns:
a reference to this, so the API can be used fluently
Type
HttpConnection

getWindowSize() → {number}

Source:
Returns:
the current connection window size or -1 for HTTP/1.x
Type
number

goAway(errorCode, lastStreamId, debugData) → {HttpConnection}

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

  • a 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 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:
Name Type Description
errorCode number the error code
lastStreamId number the last stream id
debugData Buffer additional debug data sent to the remote endpoint
Source:
Returns:
a reference to this, so the API can be used fluently
Type
HttpConnection

goAwayHandler(handler) → {HttpConnection}

Set an handler called when a frame is received.

This is not implemented for HTTP/1.x.

Parameters:
Name Type Description
handler function the handler
Source:
Returns:
a reference to this, so the API can be used fluently
Type
HttpConnection

indicatedServerName() → {string}

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

isSsl() → {boolean}

Source:
Returns:
true if this HttpConnection is encrypted via SSL/TLS.
Type
boolean

localAddress() → {SocketAddress}

Source:
Returns:
the remote address for this connection
Type
SocketAddress

ping(data, pongHandler) → {HttpConnection}

Send a frame to the remote endpoint.

This is not implemented for HTTP/1.x.

Parameters:
Name Type Description
data Buffer the 8 bytes data of the frame
pongHandler function an async result handler notified with pong reply or the failure
Source:
Returns:
a reference to this, so the API can be used fluently
Type
HttpConnection

pingHandler(handler) → {HttpConnection}

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

This is not implemented for HTTP/1.x.

Parameters:
Name Type Description
handler function the handler to be called when a is received
Source:
Returns:
a reference to this, so the API can be used fluently
Type
HttpConnection

remoteAddress() → {SocketAddress}

Source:
Returns:
the remote address for this connection
Type
SocketAddress

remoteSettings() → {Object}

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

remoteSettingsHandler(handler) → {HttpConnection}

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

This is not implemented for HTTP/1.x.

Parameters:
Name Type Description
handler function the handler for remote endpoint settings
Source:
Returns:
a reference to this, so the API can be used fluently
Type
HttpConnection

settings() → {Object}

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

setWindowSize(windowSize) → {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.

Parameters:
Name Type Description
windowSize number the new window size
Source:
Returns:
a reference to this, so the API can be used fluently
Type
HttpConnection

shutdown(timeoutMs) → {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.

Parameters:
Name Type Description
timeoutMs number the timeout in milliseconds
Source:
Returns:
a reference to this, so the API can be used fluently
Type
HttpConnection

shutdownHandler(handler) → {HttpConnection}

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

This is not implemented for HTTP/1.x.

Parameters:
Name Type Description
handler function the handler
Source:
Returns:
a reference to this, so the API can be used fluently
Type
HttpConnection

updateSettings(settings, completionHandler) → {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.

Parameters:
Name Type Description
settings Object the new settings
completionHandler function the handler notified when the settings have been acknowledged by the remote endpoint
Source:
Returns:
a reference to this, so the API can be used fluently
Type
HttpConnection