HTTPServerResponseData

Undocumented in source.
struct HTTPServerResponseData {}

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.

Postblit

this(this)
this(this)
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.

sendBadRequest
void sendBadRequest()
Undocumented in source. Be warned that the author may not have intended to support it.
setCookie
Cookie setCookie(string name, string value, string path, Cookie.Encoding encoding)

Sets the specified cookie value.

startSession
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.

switchToHTTP2
void switchToHTTP2(HANDLER handler, HTTP2ServerContext context)
Undocumented in source. Be warned that the author may not have intended to support it.
terminateSession
void terminateSession()

Terminates the current session (if any).

tls
bool tls()

Determines if the response is sent over an encrypted connection.

toString
string toString()
Undocumented in source. Be warned that the author may not have intended to support it.
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()
void writeVoidBody(Stream stream)

Writes the response with no body.

Properties

bodyWriter
InterfaceProxy!OutputStream bodyWriter [@property getter]

A stream for writing the body of the HTTP response.

bodyWriterH2
void bodyWriterH2(T writer, bool writeH)
Undocumented in source. Be warned that the author may not have intended to support it.
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.

contentType
string contentType [@property getter]
string contentType [@property setter]

Shortcut to the "Content-Type" header

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.

Variables

cookies
Cookie[string] cookies;

All cookies that shall be set on the client for this request

headers
InetHeaderMap headers;

The response header fields

httpVersion
HTTPVersion httpVersion;

The protocol version of the response - should not be changed

statusCode
int statusCode;

The status code of the response, 200 by default

statusPhrase
string statusPhrase;

The status phrase of the response

Meta