Skip to content

HttpResponse

blackshadev edited this page Jan 13, 2015 · 2 revisions

HttpResponse instances are used to send data back to the user

Properties

Name Description
headers The HTTP headers send to the user, represented in a object eg { "Content-Type": "text/html" }. Http Headers
statusCode The Http status code send to the user, default 200. Http statuscodes
eos Boolean, whenever the stream has already been send to the user. (eos stands for EndOfStream)
_res Reference to the NodeJs Http Server response of this request
_data Data which will be send to the user when send() is called. Do not set this property, use the data(dat, bin) method described bellow. Defaults to an empty string.

Methods

Name Description
status(code) Sets the statusCode to the given code
header(name, value) Sets a header with the given name as key and the given value as value
data(dat) Sets the data property to dat. It can be a string, JSON object or a buffer. JSON objects are stringified automatically.
append(dat) Appends given data dat to the response data, this function will stringify the given data when dealing with objects. Buffers are appended to the already inplace data.
send() Sends the response to the user with the set headers and data. Errors when send is already called

Clone this wiki locally