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

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

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

#### closed() → {boolean}

  Source:
    - http_server_response.js, line 422

  ##### Returns:

  - has the underlying TCP connection corresponding to the request already been closed?
  - Type
      boolean

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

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

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

#### ended() → {boolean}

  Source:
    - http_server_response.js, line 408

  ##### Returns:

  - has the response already ended?
  - Type
      boolean

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

  ##### Parameters:

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

  Source:
    - http_server_response.js, line 59

  ##### Returns:

  Type
    HttpServerResponse

#### getStatusCode() → {number}

  Source:
    - http_server_response.js, line 126

  ##### Returns:

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

#### getStatusMessage() → {string}

  Source:
    - http_server_response.js, line 157

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

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

  ##### Parameters:

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

  Source:
    - http_server_response.js, line 451

  ##### Returns:

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

#### headWritten() → {boolean}

  Source:
    - http_server_response.js, line 436

  ##### Returns:

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

#### isChunked() → {boolean}

  Source:
    - http_server_response.js, line 211

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

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

  ##### Returns:

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

#### sendFile(filename, offset, length, 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
  `offset` | number | the offset to serve from
  `length` | number | the length to serve to
  `resultHandler` | function | handler that will be called on completion

  Source:
    - http_server_response.js, line 347

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

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

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

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

  ##### Returns:

  Type
    HttpServerResponse

#### trailers() → {MultiMap}

  Source:
    - http_server_response.js, line 258

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

  ##### Returns:

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

#### writeContinue() → {HttpServerResponse}

  Used to write an interim 100 Continue response to signify that the client should send the rest of the request. Must only be used if the request contains an "Expect:100-Continue" header
  Source:
    - http_server_response.js, line 308

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

  ##### Returns:

  true if write queue is full
  Type
    boolean