HttpRequest

The data which the server provides to HttpRequestHandlers so that they can formulate a response.

Members

Functions

getHeaderAs
T getHeaderAs(string name, T defaultValue)

Gets a header as the specified type, or returns the default value if the header with the given name doesn't exist or is of an invalid format.

getParamAs
T getParamAs(string name, T defaultValue)

Gets a URL parameter as the specified type, or returns the default value if the parameter with the given name doesn't exist or is of an invalid format.

getPathParamAs
T getPathParamAs(string name, T defaultValue)

Gets a path parameter as the specified type, or returns the default value if the path parameter with the given name doesn't exist or is of an invalid format.

readBody
ulong readBody(S outputStream, bool allowInfiniteRead)

Reads the entirety of the request body, and passes it to the given output stream.

readBodyAsBytes
ubyte[] readBodyAsBytes(bool allowInfiniteRead)

Convenience method for reading the entire request body as an array of bytes.

readBodyAsFormUrlEncoded
StringMultiValueMap readBodyAsFormUrlEncoded(bool allowInfiniteRead, bool stripWhitespace)

Convenience method for reading the entire request body as a series of form-urlencoded key-value pairs.

readBodyAsJson
auto readBodyAsJson(bool allowInfiniteRead)

Convenience method for reading the entire request body as a JSON node. An exception will be thrown if the body cannot be parsed as JSON.

readBodyAsString
string readBodyAsString(bool allowInfiniteRead)

Convenience method for reading the entire request body as a string.

readBodyToFile
ulong readBodyToFile(string filename, bool allowInfiniteRead)

Convenience method for reading the entire request body to a file.

Variables

headers
const(CaseInsensitiveStringMultiValueMap) headers;

A list of all request headers.

inputStream
InputStream!ubyte inputStream;

The input stream for the request's body. This may be null if the request doesn't have a body.

method
Method method;

The HTTP method verb, such as GET, POST, PUT, etc. This is internally defined as a bit-shifted 1, for efficient matching logic. See the Method enum in this module for more information.

pathParams
string[string] pathParams;

An associative array containing any path parameters obtained from the request url. These are only populated in cases where it is possible to parse path parameters, such as with a PathHandler.

pathPattern
string pathPattern;

If this request was processed by a PathHandler, then this will be set to the path pattern that was matched when it chose a handler to handle this request.

queryParams
const(StringMultiValueMap) queryParams;

A list of parsed query parameters from the request's URL.

receiveBuffer
ubyte[] receiveBuffer;

The pre-allocated buffer that we'll use when receiving the rest of this request's body, if it has one. This buffer belongs to the worker that is handling the request.

remoteAddress
Address remoteAddress;

The remote address that this request was received from.

url
string url;

The url of the request, excluding query parameters.

ver
int ver;

The request version.