New constructors for message:

The message class now behaves like a pair with respect to the construction
of the body and headers. Additional constructors allow construction of
just the body portion from a tuple, leaving the headers default
constructed.

Previous constructors are removed as they were a notational convenience
for assembling HTTP/1 requests and responses. They are not necessary
as this library aims at library writers and not end users.
This commit is contained in:
Vinnie Falco
2016-05-07 15:18:22 -04:00
parent 3484996048
commit c49cde844b
13 changed files with 334 additions and 144 deletions

View File

@@ -127,8 +127,10 @@ private:
path = root_ + path;
if(! boost::filesystem::exists(path))
{
response_v1<string_body> resp(
{404, "Not Found", req_.version});
response_v1<string_body> resp;
resp.status = 404;
resp.reason = "Not Found";
resp.version = req_.version;
resp.headers.replace("Server", "http_async_server");
resp.body = "The file '" + path + "' was not found";
prepare(resp);
@@ -137,8 +139,10 @@ private:
asio::placeholders::error));
return;
}
resp_type resp(
{200, "OK", req_.version});
resp_type resp;
resp.status = 200;
resp.reason = "OK";
resp.version = req_.version;
resp.headers.replace("Server", "http_async_server");
resp.headers.replace("Content-Type", "text/html");
resp.body = path;