# 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:
  - vertx-js/http_connection.js, line 35

### Methods

#### close()

Close the connection and all the currently active streams.

An HTTP/2 connection will send a frame before.

Source:
  - vertx-js/http_connection.js, line 183

#### 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:
  - vertx-js/http_connection.js, line 167

##### 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:
  - vertx-js/http_connection.js, line 314

##### Returns:

a reference to this, so the API can be used fluently

Type
  HttpConnection

#### getWindowSize() → {number}

Source:
  - vertx-js/http_connection.js, line 46

##### 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:
  - vertx-js/http_connection.js, line 89

##### 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:
  - vertx-js/http_connection.js, line 112

##### 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:
  - vertx-js/http_connection.js, line 376

##### Returns:

the indicated server name

Type
  string

#### isSsl() → {boolean}

Source:
  - vertx-js/http_connection.js, line 362

##### Returns:

true if this HttpConnection is encrypted via SSL/TLS.

Type
  boolean

#### localAddress() → {SocketAddress}

Source:
  - vertx-js/http_connection.js, line 346

##### 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:
  - vertx-js/http_connection.js, line 274

##### 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:
  - vertx-js/http_connection.js, line 297

##### Returns:

a reference to this, so the API can be used fluently

Type
  HttpConnection

#### remoteAddress() → {SocketAddress}

Source:
  - vertx-js/http_connection.js, line 330

##### Returns:

the remote address for this connection

Type
  SocketAddress

#### remoteSettings() → {Object}

Source:
  - vertx-js/http_connection.js, line 238

##### 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:
  - vertx-js/http_connection.js, line 254

##### Returns:

a reference to this, so the API can be used fluently

Type
  HttpConnection

#### settings() → {Object}

Source:
  - vertx-js/http_connection.js, line 196

##### 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:
  - vertx-js/http_connection.js, line 64

##### 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:
  - vertx-js/http_connection.js, line 149

##### 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:
  - vertx-js/http_connection.js, line 131

##### 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:
  - vertx-js/http_connection.js, line 215

##### Returns:

a reference to this, so the API can be used fluently

Type
  HttpConnection