66 lines
1.4 KiB
D
66 lines
1.4 KiB
D
|
module http_primitives.request;
|
||
|
|
||
|
import http_primitives.multivalue_map;
|
||
|
import http_primitives.ranges;
|
||
|
|
||
|
import std.socket : Address;
|
||
|
|
||
|
/**
|
||
|
* A struct describing the contents of an HTTP request.
|
||
|
*/
|
||
|
struct HttpRequest {
|
||
|
/**
|
||
|
* The HTTP method, or verb, which was requested.
|
||
|
*/
|
||
|
Method method = Method.GET;
|
||
|
|
||
|
/**
|
||
|
* The URL that was requested.
|
||
|
*/
|
||
|
string url = "";
|
||
|
|
||
|
/**
|
||
|
* The HTTP version of this request.
|
||
|
*/
|
||
|
ubyte httpVersion = 1;
|
||
|
|
||
|
/**
|
||
|
* A multi-valued map of headers that were provided to this request.
|
||
|
*/
|
||
|
StringMultiValueMap headers;
|
||
|
|
||
|
/**
|
||
|
* A multi-valued map of query parameters that were provided to this
|
||
|
* request, as parsed from the request's URL.
|
||
|
*/
|
||
|
StringMultiValueMap queryParams;
|
||
|
|
||
|
/**
|
||
|
* The remote address that this request came from.
|
||
|
*/
|
||
|
Address remoteAddress;
|
||
|
|
||
|
/**
|
||
|
* The input range from which the request body can be read.
|
||
|
*/
|
||
|
RequestInputRange inputRange;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Enumeration of all possible HTTP request methods as unsigned integer values
|
||
|
* for efficient logic.
|
||
|
*
|
||
|
* https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods
|
||
|
*/
|
||
|
enum Method : ushort {
|
||
|
GET = 1 << 0,
|
||
|
HEAD = 1 << 1,
|
||
|
POST = 1 << 2,
|
||
|
PUT = 1 << 3,
|
||
|
DELETE = 1 << 4,
|
||
|
CONNECT = 1 << 5,
|
||
|
OPTIONS = 1 << 6,
|
||
|
TRACE = 1 << 7,
|
||
|
PATCH = 1 << 8
|
||
|
}
|