Class: HTTPResponse

server.HTTPResponse

Class representing a HTTP response.

Use the response method of server.HTTPServer.HTTPRequestEvent to create a response.

The setter methods of this class return the class instance itself, so method calls may be chained.

new server.HTTPResponse ()

Example
req.response(200, "OK")
.cookie("MyCookie", "42")
.body("Hello World", "text/html")
.send();

Methods

Sets the response body.

Name Type Description
s string

The response body.

mimetype string

The MIME type of the response body.

Returns:
Type Description
server.HTTPResponse The response object for chaining multiple methods.

Sets a HTTP cookie.

Name Type Description
name string

The cookie name.

value string

The cookie value.

Returns:
Type Description
server.HTTPResponse The response object for chaining multiple methods.

enableCrossOriginIsolation ()server.HTTPResponse

Enables Cross-Origin-Isolation by setting the appropriate HTTP headers.

Returns:
Type Description
server.HTTPResponse The response object for chaining multiple methods.

Sets a HTTP header.

Name Type Description
name string

The header name.

value string

The header value.

Returns:
Type Description
server.HTTPResponse The response object for chaining multiple methods.

Sends the response.

stream (s, mimetype, dataSize)server.HTTPResponse

Pipes a stream for chunked transfer.

Name Type Description
s ReadableStream

The stream.

mimetype string

The MIME type of the data.

dataSize number

The expected size of data in bytes, or -1 for unknown size.

Returns:
Type Description
server.HTTPResponse The response object for chaining multiple methods.