HTTPServerResponse

Represents a HTTP response as sent from the server side.

final
class HTTPServerResponse : HTTPResponse {}

Constructors

this
this(Stream conn, ConnectionStream raw_connection, HTTPServerSettings settings, IAllocator req_alloc)
Undocumented in source.
this
this(InterfaceProxy!Stream conn, InterfaceProxy!ConnectionStream raw_connection, HTTPServerSettings settings, IAllocator req_alloc)
Undocumented in source.

Members

Functions

connectProxy
ConnectionStream connectProxy()
void connectProxy(void delegate(scope ConnectionStream) @(safe) del)

Special method for handling CONNECT proxy tunnel

finalize
void finalize()

Finalizes the response. This is usually called automatically by the server.

isHeadResponse
bool isHeadResponse()

Determines if the response does not need a body.

redirect
void redirect(string url, int status)
void redirect(URL url, int status)

Sends a redirect request to the client.

setCookie
Cookie setCookie(string name, string value, string path, Cookie.Encoding encoding)

Sets the specified cookie value.

startSession
Session startSession(string path)
Session startSession(string path, SessionOption options)

Initiates a new session.

switchProtocol
ConnectionStream switchProtocol(string protocol)
void switchProtocol(string protocol, void delegate(scope ConnectionStream) @(safe) del)

Special method sending a SWITCHING_PROTOCOLS response to the client.

terminateSession
void terminateSession()

Terminates the current session (if any).

tls
bool tls()

Determines if the response is sent over an encrypted connection.

waitForConnectionClose
bool waitForConnectionClose(Duration timeout)

Waits until either the connection closes, data arrives, or until the given timeout is reached.

writeBody
void writeBody(ubyte[] data, string content_type)
void writeBody(ubyte[] data, int status, string content_type)
void writeBody(InputStream data, string content_type)

Writes the entire response body at once.

writeBody
void writeBody(string data, string content_type)
void writeBody(string data, int status, string content_type)

Writes the entire response body as a single string.

writeJsonBody
void writeJsonBody(T data, int status, bool allow_chunked)
void writeJsonBody(T data, int status, string content_type, bool allow_chunked)
void writeJsonBody(T data, string content_type, bool allow_chunked)
void writeJsonBody(T data, bool allow_chunked)
writePrettyJsonBody
void writePrettyJsonBody(T data, bool allow_chunked)

Writes a JSON message with the specified status

writeRawBody
void writeRawBody(RandomAccessStream stream)
void writeRawBody(InputStream stream, size_t num_bytes)
void writeRawBody(RandomAccessStream stream, int status)
void writeRawBody(InputStream stream, int status, size_t num_bytes)

Writes the whole response body at once, without doing any further encoding.

writeVoidBody
void writeVoidBody()

Writes the response with no body.

Properties

bodyWriter
InterfaceProxy!OutputStream bodyWriter [@property getter]

A stream for writing the body of the HTTP response.

bytesWritten
ulong bytesWritten [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
connected
bool connected [@property getter]

Determines if the underlying connection is still alive.

headerWritten
bool headerWritten [@property getter]

Determines if the HTTP header has already been written.

timeFinalized
SysTime timeFinalized [@property getter]

Returns the time at which the request was finalized.

Meta