# 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 34

### 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 182

#### 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 166

##### 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 313

##### Returns:

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

Type
  HttpConnection

#### getWindowSize() → {number}

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

##### 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 88

##### 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 111

##### Returns:

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

Type
  HttpConnection

#### 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 273

##### 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 296

##### Returns:

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

Type
  HttpConnection

#### remoteSettings() → {Object}

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

##### 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 253

##### Returns:

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

Type
  HttpConnection

#### settings() → {Object}

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

##### 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 63

##### 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 148

##### 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 130

##### 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 214

##### Returns:

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

Type
  HttpConnection