ResponseInfo class
constructor
The constructor of the ResponseInfo class requires one argument. The argument must be an instance of the NodeJS built-in HTTP ServerResponse class which provides the data for the ResponseInfo class.
Functions
setStatusCode
Sets the status code for the response which the client will receive.
Argument | Description |
---|---|
statusCode | A number which defines the status code the client will receive once the request has been handled and a response will be made. |
setHeaders
Sets custom response headers which the client will receive.
Argument | Description |
---|---|
headers | An object with the headers the client should receive. The key of the object must be the header name and the value of the object must be the value of the corresponding header name. |
send
Sends the response to the client.
Argument | Description |
---|---|
response | A string, instance of the Buffer class or undefined which defines the response the client should receive from the server. |
end
Identicial to the send function and sends a response to the client.
Argument | Description |
---|---|
response | A string, instance of the Buffer class or undefined which defines the response the client should receive from the server. |
write
Writes a response for the client, but doesn't send it yet. The response will be send once the send or end function gets called.
Argument | Description |
---|---|
chunk | A string, instance of the Buffer class or undefined which defines a part of the response the client should receive from the server. |
setStatus
Sets the status for the page the client made a request to.
Argument | |
---|---|
statusCode | A number which defines the status code the client will receive once the request has been handled and a response will be made. |
headers | An object with the headers the client should receive. The key of the object must be the header name and the value of the object must be the value of the corresponding header name. |
Last updated