# Class: HttpServerResponse

## vertx-js/http_server_response~ HttpServerResponse

#### new HttpServerResponse()

  Represents a server-side HTTP response.

  An instance of this is created and associated to every instance of

  Source:
    - http_server_response.js, line 34

### Methods

#### bodyEndHandler(handler) → {HttpServerResponse}

  Provide a handler that will be called just before the last part of the body is written to the wire and the response is ended.

  This provides a hook allowing you to do any more operations before this occurs.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `handler` | function | the handler

  Source:
    - http_server_response.js, line 417

  ##### Returns:

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

#### close()

  Close the underlying TCP connection corresponding to the request.
  Source:
    - http_server_response.js, line 353

#### closeHandler(handler) → {HttpServerResponse}

  Set a close handler for the response. This will be called if the underlying connection closes before the response is complete.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `handler` | function | the handler

  Source:
    - http_server_response.js, line 293

  ##### Returns:

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

#### drainHandler(handler) → {HttpServerResponse}

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `handler` | function |

  Source:
    - http_server_response.js, line 112

  ##### Returns:

  Type
    HttpServerResponse

#### end(chunk, enc)

  Same as HttpServerResponse#end but writes a String with the specified encoding before ending the response.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `chunk` | string | the string to write before ending the response
  `enc` | string | the encoding to use

  Source:
    - http_server_response.js, line 308

#### ended() → {boolean}

  Source:
    - http_server_response.js, line 367

  ##### Returns:

  - has the response already ended?
  - Type
      boolean

#### exceptionHandler(handler) → {HttpServerResponse}

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `handler` | function |

  Source:
    - http_server_response.js, line 60

  ##### Returns:

  Type
    HttpServerResponse

#### getStatusCode() → {number}

  Source:
    - http_server_response.js, line 127

  ##### Returns:

  - the HTTP status code of the response. The default is `200` representing `OK`.
  - Type
      number

#### getStatusMessage() → {string}

  Source:
    - http_server_response.js, line 158

  ##### Returns:

  - the HTTP status message of the response. If this is not specified a default value will be used depending on what HttpServerResponse#setStatusCode has been set to.
  - Type
      string

#### headers() → {MultiMap}

  Source:
    - http_server_response.js, line 226

  ##### Returns:

  - The HTTP headers
  - Type
      MultiMap

#### headersEndHandler(handler) → {HttpServerResponse}

  Provide a handler that will be called just before the headers are written to the wire.

  This provides a hook allowing you to add any more headers or do any more operations before this occurs. The handler will be passed a future, when you've completed the work you want to do you should complete (or fail) the future. This can be done after the handler has returned.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `handler` | function | the handler

  Source:
    - http_server_response.js, line 398

  ##### Returns:

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

#### headWritten() → {boolean}

  Source:
    - http_server_response.js, line 381

  ##### Returns:

  - have the headers for the response already been written?
  - Type
      boolean

#### isChunked() → {boolean}

  Source:
    - http_server_response.js, line 212

  ##### Returns:

  - is the response chunked?
  - Type
      boolean

#### putHeader(name, value) → {HttpServerResponse}

  Put an HTTP header

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `name` | string | the header name
  `value` | string | the header value.

  Source:
    - http_server_response.js, line 244

  ##### Returns:

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

#### putTrailer(name, value) → {HttpServerResponse}

  Put an HTTP trailer

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `name` | string | the trailer name
  `value` | string | the trailer value

  Source:
    - http_server_response.js, line 277

  ##### Returns:

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

#### sendFile(filename, resultHandler) → {HttpServerResponse}

  Like HttpServerResponse#sendFile but providing a handler which will be notified once the file has been completely written to the wire.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `filename` | string | path to the file to serve
  `resultHandler` | function | handler that will be called on completion

  Source:
    - http_server_response.js, line 330

  ##### Returns:

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

#### setChunked(chunked) → {HttpServerResponse}

  If `chunked` is `true`, this response will use HTTP chunked encoding, and each call to write to the body will correspond to a new HTTP chunk sent on the wire.

  If chunked encoding is used the HTTP header `Transfer-Encoding` with a value of `Chunked` will be automatically inserted in the response.

  If `chunked` is `false`, this response will not use HTTP chunked encoding, and therefore the total size of any data that is written in the respone body must be set in the `Content-Length` header before any data is written out.

  An HTTP chunked response is typically used when you do not know the total size of the request body up front.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `chunked` | boolean |

  Source:
    - http_server_response.js, line 197

  ##### Returns:

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

#### setStatusCode(statusCode) → {HttpServerResponse}

  Set the status code. If the status message hasn't been explicitly set, a default status message corresponding to the code will be looked-up and used.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `statusCode` | number |

  Source:
    - http_server_response.js, line 142

  ##### Returns:

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

#### setStatusMessage(statusMessage) → {HttpServerResponse}

  Set the status message

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `statusMessage` | string |

  Source:
    - http_server_response.js, line 172

  ##### Returns:

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

#### setWriteQueueMaxSize(maxSize) → {HttpServerResponse}

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `maxSize` | number |

  Source:
    - http_server_response.js, line 98

  ##### Returns:

  Type
    HttpServerResponse

#### trailers() → {MultiMap}

  Source:
    - http_server_response.js, line 259

  ##### Returns:

  - The HTTP trailers
  - Type
      MultiMap

#### write(chunk, enc) → {HttpServerResponse}

  Write a String to the response body, encoded using the encoding `enc`.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `chunk` | string | the string to write
  `enc` | string | the encoding to use

  Source:
    - http_server_response.js, line 78

  ##### Returns:

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

#### writeQueueFull() → {boolean}

  This will return `true` if there are more bytes in the write queue than the value set using HttpServerResponse#setWriteQueueMaxSize
  Source:
    - http_server_response.js, line 47

  ##### Returns:

  true if write queue is full
  Type
    boolean