new HttpServerResponse()
An instance of this is created and associated to every instance of
- Source:
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 handlerfunction the handler - Source:
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:
-
closed() → {boolean}
-
- Source:
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 handlerfunction the handler - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- HttpServerResponse
-
drainHandler(handler) → {HttpServerResponse}
-
Parameters:
Name Type Description handlerfunction - Source:
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 chunkstring the string to write before ending the response encstring the encoding to use - Source:
-
ended() → {boolean}
-
- Source:
Returns:
-
has the response already ended?
-
- Type
- boolean
-
exceptionHandler(handler) → {HttpServerResponse}
-
Parameters:
Name Type Description handlerfunction - Source:
Returns:
- Type
- HttpServerResponse
-
getStatusCode() → {number}
-
- Source:
Returns:
-
the HTTP status code of the response. The default is
200representingOK. -
- Type
- number
-
getStatusMessage() → {string}
-
- Source:
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:
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 handlerfunction the handler - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- HttpServerResponse
-
headWritten() → {boolean}
-
- Source:
Returns:
-
have the headers for the response already been written?
-
- Type
- boolean
-
isChunked() → {boolean}
-
- Source:
Returns:
-
is the response chunked?
-
- Type
- boolean
-
putHeader(name, value) → {HttpServerResponse}
-
Put an HTTP header
Parameters:
Name Type Description namestring the header name valuestring the header value. - Source:
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 namestring the trailer name valuestring the trailer value - Source:
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 filenamestring path to the file to serve offsetnumber the offset to serve from lengthnumber the length to serve to resultHandlerfunction handler that will be called on completion - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- HttpServerResponse
-
setChunked(chunked) → {HttpServerResponse}
-
If
chunkedistrue, 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-Encodingwith a value ofChunkedwill be automatically inserted in the response.If
chunkedisfalse, 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 theContent-Lengthheader 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 chunkedboolean - Source:
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 statusCodenumber - Source:
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 statusMessagestring - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- HttpServerResponse
-
setWriteQueueMaxSize(maxSize) → {HttpServerResponse}
-
Parameters:
Name Type Description maxSizenumber - Source:
Returns:
- Type
- HttpServerResponse
-
trailers() → {MultiMap}
-
- Source:
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 chunkstring the string to write encstring the encoding to use - Source:
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:
Returns:
a reference to this, so the API can be used fluently- Type
- HttpServerResponse
-
writeQueueFull() → {boolean}
-
This will return
trueif there are more bytes in the write queue than the value set using HttpServerResponse#setWriteQueueMaxSize- Source:
Returns:
true if write queue is full- Type
- boolean