Request.parse

Parses a string and returns a Request. If the request is successfully parsed Request.valid will be true. Please note that every key in the header is converted to lowercase for an easier search in the associative array.

class Request
bool
parse
(
string data
)

Examples

auto request = Request.parse("GET /index.html HTTP/1.1\r\nHost: 127.0.0.1\r\nConnection: Keep-Alive\r\n");
assert(request.valid);
assert(request.method == Request.GET);
assert(request.headers["Host"] == "127.0.0.1");
assert(request.headers["Connection"] == "Keep-Alive");

Meta