HttpResponse

The data that the HTTP server will send back to clients.

Members

Functions

addHeader
HttpResponse addHeader(string name, string value)

Adds a header to the response. This can only be done before headers are flushed.

chunked
HttpResponse chunked()

Makes the response's body use "chunked" transfer-encoding. See here for more info: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Transfer-Encoding Only call this method if you have not flushed the response's headers yet and you haven't written anything to the response body.

flushHeaders
void flushHeaders()

Flushes the headers for this request. Once this is done, header information can no longer be modified.

isFlushed
bool isFlushed()

Tells whether the header of this response has already been flushed.

setStatus
HttpResponse setStatus(HttpStatus newStatus)

Sets the status of the response. This can only be done before headers are flushed.

writeBody
void writeBody(S stream, ulong size, string contentType)

Writes the given input stream of bytes to the response's body.

writeBodyBytes
void writeBodyBytes(ubyte[] data, string contentType)

Writes the given byte content to the body of the response. If this response has not yet written its status line and headers, it will do that first.

writeBodyString
void writeBodyString(string text, string contentType)

Writes the given text to the body of the response. It's a simple wrapper around writeBody(ubyte[], string).

Variables

headers
string[string] headers;

An associative array of headers.

outputStream
OutputStream!ubyte outputStream;

The output stream that the response body will be written to.

status
StatusInfo status;

The response status.