Refactor header and message constructors:

fix #581

* request and response headers now have convenience
  constructors so important fields like method, target,
  result, and version may be set upon construction.

Actions Required:

* Evaluate each message constructor call site and
  adjust the constructor argument list as needed.
This commit is contained in:
Vinnie Falco
2017-07-03 20:33:54 -07:00
parent 2ee088de5f
commit b0e52dd246
11 changed files with 487 additions and 210 deletions

View File

@@ -60,8 +60,7 @@ private:
http::response<http::string_view_body>
client_error(http::status result, beast::string_view text)
{
http::response<http::string_view_body> res;
res.result(result);
http::response<http::string_view_body> res{result, 11};
res.set(http::field::server, BEAST_VERSION_STRING);
res.set(http::field::content_type, "text/plain");
res.set(http::field::connection, "close");
@@ -75,8 +74,7 @@ private:
beast::http::response<beast::http::string_body>
not_found() const
{
beast::http::response<beast::http::string_body> res;
res.result(beast::http::status::not_found);
beast::http::response<beast::http::string_body> res{beast::http::status::not_found, 11};
res.set(beast::http::field::server, BEAST_VERSION_STRING);
res.set(beast::http::field::content_type, "text/html");
res.set(http::field::connection, "close");
@@ -90,8 +88,7 @@ private:
beast::http::response<beast::http::string_body>
server_error(beast::error_code const& ec) const
{
beast::http::response<beast::http::string_body> res;
res.result(beast::http::status::internal_server_error);
beast::http::response<beast::http::string_body> res{beast::http::status::internal_server_error, 11};
res.set(beast::http::field::server, BEAST_VERSION_STRING);
res.set(beast::http::field::content_type, "text/html");
res.set(http::field::connection, "close");