Response.parse

Parses a string and returns a Response. If the response is successfully parsed Response.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 Response
bool
parse
(
string str
)

Examples

auto response = Response.parse("HTTP/1.1 200 OK\r\nContent-Type: plain/text\r\nContent-Length: 4\r\n\r\ntest");
assert(response.valid);
assert(response.status == 200);
assert(response.headers["content-type"] == "text/plain");
assert(response.headers["content-length"] == "4");
assert(response.content == "test");

Meta