mirror of
https://github.com/boostorg/beast.git
synced 2025-07-31 21:34:46 +02:00
message::version is a member function (API Change):
fix #778 * The version data member is replaced with accessor member functions. Actions Required: * Call member function message::version instead of accessing the version member at call sites.
This commit is contained in:
@@ -3,12 +3,16 @@ Version 116:
|
|||||||
API Changes:
|
API Changes:
|
||||||
|
|
||||||
* message::body is a member function
|
* message::body is a member function
|
||||||
|
* message::version is a member function
|
||||||
|
|
||||||
Actions Required:
|
Actions Required:
|
||||||
|
|
||||||
* Call member function message::body instead of accessing
|
* Call member function message::body instead of accessing
|
||||||
the data member at call sites.
|
the data member at call sites.
|
||||||
|
|
||||||
|
* Call member function message::version instead of accessing
|
||||||
|
the version member at call sites.
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
Version 115:
|
Version 115:
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 43 KiB |
@@ -120,7 +120,7 @@ handle_request(
|
|||||||
auto const bad_request =
|
auto const bad_request =
|
||||||
[&req](boost::beast::string_view why)
|
[&req](boost::beast::string_view why)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::bad_request, req.version};
|
http::response<http::string_body> res{http::status::bad_request, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -133,7 +133,7 @@ handle_request(
|
|||||||
auto const not_found =
|
auto const not_found =
|
||||||
[&req](boost::beast::string_view target)
|
[&req](boost::beast::string_view target)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::not_found, req.version};
|
http::response<http::string_body> res{http::status::not_found, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -146,7 +146,7 @@ handle_request(
|
|||||||
auto const server_error =
|
auto const server_error =
|
||||||
[&req](boost::beast::string_view what)
|
[&req](boost::beast::string_view what)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::internal_server_error, req.version};
|
http::response<http::string_body> res{http::status::internal_server_error, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -187,7 +187,7 @@ handle_request(
|
|||||||
// Respond to HEAD request
|
// Respond to HEAD request
|
||||||
if(req.method() == http::verb::head)
|
if(req.method() == http::verb::head)
|
||||||
{
|
{
|
||||||
http::response<http::empty_body> res{http::status::ok, req.version};
|
http::response<http::empty_body> res{http::status::ok, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, mime_type(path));
|
res.set(http::field::content_type, mime_type(path));
|
||||||
res.content_length(body.size());
|
res.content_length(body.size());
|
||||||
@@ -199,7 +199,7 @@ handle_request(
|
|||||||
http::response<http::file_body> res{
|
http::response<http::file_body> res{
|
||||||
std::piecewise_construct,
|
std::piecewise_construct,
|
||||||
std::make_tuple(std::move(body)),
|
std::make_tuple(std::move(body)),
|
||||||
std::make_tuple(http::status::ok, req.version)};
|
std::make_tuple(http::status::ok, req.version())};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, mime_type(path));
|
res.set(http::field::content_type, mime_type(path));
|
||||||
res.content_length(body.size());
|
res.content_length(body.size());
|
||||||
|
@@ -114,7 +114,7 @@ handle_request(
|
|||||||
auto const bad_request =
|
auto const bad_request =
|
||||||
[&req](boost::beast::string_view why)
|
[&req](boost::beast::string_view why)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::bad_request, req.version};
|
http::response<http::string_body> res{http::status::bad_request, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -127,7 +127,7 @@ handle_request(
|
|||||||
auto const not_found =
|
auto const not_found =
|
||||||
[&req](boost::beast::string_view target)
|
[&req](boost::beast::string_view target)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::not_found, req.version};
|
http::response<http::string_body> res{http::status::not_found, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -140,7 +140,7 @@ handle_request(
|
|||||||
auto const server_error =
|
auto const server_error =
|
||||||
[&req](boost::beast::string_view what)
|
[&req](boost::beast::string_view what)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::internal_server_error, req.version};
|
http::response<http::string_body> res{http::status::internal_server_error, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -181,7 +181,7 @@ handle_request(
|
|||||||
// Respond to HEAD request
|
// Respond to HEAD request
|
||||||
if(req.method() == http::verb::head)
|
if(req.method() == http::verb::head)
|
||||||
{
|
{
|
||||||
http::response<http::empty_body> res{http::status::ok, req.version};
|
http::response<http::empty_body> res{http::status::ok, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, mime_type(path));
|
res.set(http::field::content_type, mime_type(path));
|
||||||
res.content_length(body.size());
|
res.content_length(body.size());
|
||||||
@@ -193,7 +193,7 @@ handle_request(
|
|||||||
http::response<http::file_body> res{
|
http::response<http::file_body> res{
|
||||||
std::piecewise_construct,
|
std::piecewise_construct,
|
||||||
std::make_tuple(std::move(body)),
|
std::make_tuple(std::move(body)),
|
||||||
std::make_tuple(http::status::ok, req.version)};
|
std::make_tuple(http::status::ok, req.version())};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, mime_type(path));
|
res.set(http::field::content_type, mime_type(path));
|
||||||
res.content_length(body.size());
|
res.content_length(body.size());
|
||||||
|
@@ -139,7 +139,7 @@ receive_expect_100_continue(
|
|||||||
{
|
{
|
||||||
// send 100 response
|
// send 100 response
|
||||||
response<empty_body> res;
|
response<empty_body> res;
|
||||||
res.version = 11;
|
res.version(11);
|
||||||
res.result(status::continue_);
|
res.result(status::continue_);
|
||||||
res.set(field::server, "test");
|
res.set(field::server, "test");
|
||||||
write(stream, res, ec);
|
write(stream, res, ec);
|
||||||
@@ -202,7 +202,7 @@ send_cgi_response(
|
|||||||
response<buffer_body> res;
|
response<buffer_body> res;
|
||||||
|
|
||||||
res.result(status::ok);
|
res.result(status::ok);
|
||||||
res.version = 11;
|
res.version(11);
|
||||||
res.set(field::server, "Beast");
|
res.set(field::server, "Beast");
|
||||||
res.set(field::transfer_encoding, "chunked");
|
res.set(field::transfer_encoding, "chunked");
|
||||||
|
|
||||||
@@ -307,7 +307,7 @@ void do_server_head(
|
|||||||
|
|
||||||
// Set up the response, starting with the common fields
|
// Set up the response, starting with the common fields
|
||||||
response<string_body> res;
|
response<string_body> res;
|
||||||
res.version = 11;
|
res.version(11);
|
||||||
res.set(field::server, "test");
|
res.set(field::server, "test");
|
||||||
|
|
||||||
// Now handle request-specific fields
|
// Now handle request-specific fields
|
||||||
@@ -396,7 +396,7 @@ do_head_request(
|
|||||||
|
|
||||||
// Build the HEAD request for the target
|
// Build the HEAD request for the target
|
||||||
request<empty_body> req;
|
request<empty_body> req;
|
||||||
req.version = 11;
|
req.version(11);
|
||||||
req.method(verb::head);
|
req.method(verb::head);
|
||||||
req.target(target);
|
req.target(target);
|
||||||
req.set(field::user_agent, "test");
|
req.set(field::user_agent, "test");
|
||||||
|
@@ -66,7 +66,7 @@ public:
|
|||||||
char const* target)
|
char const* target)
|
||||||
{
|
{
|
||||||
// Set up an HTTP GET request message
|
// Set up an HTTP GET request message
|
||||||
req_.version = 11;
|
req_.version(11);
|
||||||
req_.method(http::verb::get);
|
req_.method(http::verb::get);
|
||||||
req_.target(target);
|
req_.target(target);
|
||||||
req_.set(http::field::host, host);
|
req_.set(http::field::host, host);
|
||||||
|
@@ -62,7 +62,7 @@ public:
|
|||||||
char const* target)
|
char const* target)
|
||||||
{
|
{
|
||||||
// Set up an HTTP GET request message
|
// Set up an HTTP GET request message
|
||||||
req_.version = 11;
|
req_.version(11);
|
||||||
req_.method(http::verb::get);
|
req_.method(http::verb::get);
|
||||||
req_.target(target);
|
req_.target(target);
|
||||||
req_.set(http::field::host, host);
|
req_.set(http::field::host, host);
|
||||||
|
@@ -168,7 +168,7 @@ public:
|
|||||||
, strand_(ios)
|
, strand_(ios)
|
||||||
{
|
{
|
||||||
// Set up the common fields of the request
|
// Set up the common fields of the request
|
||||||
req_.version = 11;
|
req_.version(11);
|
||||||
req_.method(http::verb::get);
|
req_.method(http::verb::get);
|
||||||
req_.target("/");
|
req_.target("/");
|
||||||
req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING);
|
req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING);
|
||||||
|
@@ -115,7 +115,7 @@ handle_request(
|
|||||||
auto const bad_request =
|
auto const bad_request =
|
||||||
[&req](boost::beast::string_view why)
|
[&req](boost::beast::string_view why)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::bad_request, req.version};
|
http::response<http::string_body> res{http::status::bad_request, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -128,7 +128,7 @@ handle_request(
|
|||||||
auto const not_found =
|
auto const not_found =
|
||||||
[&req](boost::beast::string_view target)
|
[&req](boost::beast::string_view target)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::not_found, req.version};
|
http::response<http::string_body> res{http::status::not_found, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -141,7 +141,7 @@ handle_request(
|
|||||||
auto const server_error =
|
auto const server_error =
|
||||||
[&req](boost::beast::string_view what)
|
[&req](boost::beast::string_view what)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::internal_server_error, req.version};
|
http::response<http::string_body> res{http::status::internal_server_error, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -182,7 +182,7 @@ handle_request(
|
|||||||
// Respond to HEAD request
|
// Respond to HEAD request
|
||||||
if(req.method() == http::verb::head)
|
if(req.method() == http::verb::head)
|
||||||
{
|
{
|
||||||
http::response<http::empty_body> res{http::status::ok, req.version};
|
http::response<http::empty_body> res{http::status::ok, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, mime_type(path));
|
res.set(http::field::content_type, mime_type(path));
|
||||||
res.content_length(body.size());
|
res.content_length(body.size());
|
||||||
@@ -194,7 +194,7 @@ handle_request(
|
|||||||
http::response<http::file_body> res{
|
http::response<http::file_body> res{
|
||||||
std::piecewise_construct,
|
std::piecewise_construct,
|
||||||
std::make_tuple(std::move(body)),
|
std::make_tuple(std::move(body)),
|
||||||
std::make_tuple(http::status::ok, req.version)};
|
std::make_tuple(http::status::ok, req.version())};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, mime_type(path));
|
res.set(http::field::content_type, mime_type(path));
|
||||||
res.content_length(body.size());
|
res.content_length(body.size());
|
||||||
|
@@ -111,7 +111,7 @@ handle_request(
|
|||||||
auto const bad_request =
|
auto const bad_request =
|
||||||
[&req](boost::beast::string_view why)
|
[&req](boost::beast::string_view why)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::bad_request, req.version};
|
http::response<http::string_body> res{http::status::bad_request, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -124,7 +124,7 @@ handle_request(
|
|||||||
auto const not_found =
|
auto const not_found =
|
||||||
[&req](boost::beast::string_view target)
|
[&req](boost::beast::string_view target)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::not_found, req.version};
|
http::response<http::string_body> res{http::status::not_found, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -137,7 +137,7 @@ handle_request(
|
|||||||
auto const server_error =
|
auto const server_error =
|
||||||
[&req](boost::beast::string_view what)
|
[&req](boost::beast::string_view what)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::internal_server_error, req.version};
|
http::response<http::string_body> res{http::status::internal_server_error, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -178,7 +178,7 @@ handle_request(
|
|||||||
// Respond to HEAD request
|
// Respond to HEAD request
|
||||||
if(req.method() == http::verb::head)
|
if(req.method() == http::verb::head)
|
||||||
{
|
{
|
||||||
http::response<http::empty_body> res{http::status::ok, req.version};
|
http::response<http::empty_body> res{http::status::ok, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, mime_type(path));
|
res.set(http::field::content_type, mime_type(path));
|
||||||
res.content_length(body.size());
|
res.content_length(body.size());
|
||||||
@@ -190,7 +190,7 @@ handle_request(
|
|||||||
http::response<http::file_body> res{
|
http::response<http::file_body> res{
|
||||||
std::piecewise_construct,
|
std::piecewise_construct,
|
||||||
std::make_tuple(std::move(body)),
|
std::make_tuple(std::move(body)),
|
||||||
std::make_tuple(http::status::ok, req.version)};
|
std::make_tuple(http::status::ok, req.version())};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, mime_type(path));
|
res.set(http::field::content_type, mime_type(path));
|
||||||
res.content_length(body.size());
|
res.content_length(body.size());
|
||||||
|
@@ -114,7 +114,7 @@ handle_request(
|
|||||||
auto const bad_request =
|
auto const bad_request =
|
||||||
[&req](boost::beast::string_view why)
|
[&req](boost::beast::string_view why)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::bad_request, req.version};
|
http::response<http::string_body> res{http::status::bad_request, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -127,7 +127,7 @@ handle_request(
|
|||||||
auto const not_found =
|
auto const not_found =
|
||||||
[&req](boost::beast::string_view target)
|
[&req](boost::beast::string_view target)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::not_found, req.version};
|
http::response<http::string_body> res{http::status::not_found, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -140,7 +140,7 @@ handle_request(
|
|||||||
auto const server_error =
|
auto const server_error =
|
||||||
[&req](boost::beast::string_view what)
|
[&req](boost::beast::string_view what)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::internal_server_error, req.version};
|
http::response<http::string_body> res{http::status::internal_server_error, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -181,7 +181,7 @@ handle_request(
|
|||||||
// Respond to HEAD request
|
// Respond to HEAD request
|
||||||
if(req.method() == http::verb::head)
|
if(req.method() == http::verb::head)
|
||||||
{
|
{
|
||||||
http::response<http::empty_body> res{http::status::ok, req.version};
|
http::response<http::empty_body> res{http::status::ok, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, mime_type(path));
|
res.set(http::field::content_type, mime_type(path));
|
||||||
res.content_length(body.size());
|
res.content_length(body.size());
|
||||||
@@ -193,7 +193,7 @@ handle_request(
|
|||||||
http::response<http::file_body> res{
|
http::response<http::file_body> res{
|
||||||
std::piecewise_construct,
|
std::piecewise_construct,
|
||||||
std::make_tuple(std::move(body)),
|
std::make_tuple(std::move(body)),
|
||||||
std::make_tuple(http::status::ok, req.version)};
|
std::make_tuple(http::status::ok, req.version())};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, mime_type(path));
|
res.set(http::field::content_type, mime_type(path));
|
||||||
res.content_length(body.size());
|
res.content_length(body.size());
|
||||||
|
@@ -110,7 +110,7 @@ handle_request(
|
|||||||
auto const bad_request =
|
auto const bad_request =
|
||||||
[&req](boost::beast::string_view why)
|
[&req](boost::beast::string_view why)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::bad_request, req.version};
|
http::response<http::string_body> res{http::status::bad_request, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -123,7 +123,7 @@ handle_request(
|
|||||||
auto const not_found =
|
auto const not_found =
|
||||||
[&req](boost::beast::string_view target)
|
[&req](boost::beast::string_view target)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::not_found, req.version};
|
http::response<http::string_body> res{http::status::not_found, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -136,7 +136,7 @@ handle_request(
|
|||||||
auto const server_error =
|
auto const server_error =
|
||||||
[&req](boost::beast::string_view what)
|
[&req](boost::beast::string_view what)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::internal_server_error, req.version};
|
http::response<http::string_body> res{http::status::internal_server_error, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -177,7 +177,7 @@ handle_request(
|
|||||||
// Respond to HEAD request
|
// Respond to HEAD request
|
||||||
if(req.method() == http::verb::head)
|
if(req.method() == http::verb::head)
|
||||||
{
|
{
|
||||||
http::response<http::empty_body> res{http::status::ok, req.version};
|
http::response<http::empty_body> res{http::status::ok, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, mime_type(path));
|
res.set(http::field::content_type, mime_type(path));
|
||||||
res.content_length(body.size());
|
res.content_length(body.size());
|
||||||
@@ -189,7 +189,7 @@ handle_request(
|
|||||||
http::response<http::file_body> res{
|
http::response<http::file_body> res{
|
||||||
std::piecewise_construct,
|
std::piecewise_construct,
|
||||||
std::make_tuple(std::move(body)),
|
std::make_tuple(std::move(body)),
|
||||||
std::make_tuple(http::status::ok, req.version)};
|
std::make_tuple(http::status::ok, req.version())};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, mime_type(path));
|
res.set(http::field::content_type, mime_type(path));
|
||||||
res.content_length(body.size());
|
res.content_length(body.size());
|
||||||
|
@@ -115,7 +115,7 @@ handle_request(
|
|||||||
auto const bad_request =
|
auto const bad_request =
|
||||||
[&req](boost::beast::string_view why)
|
[&req](boost::beast::string_view why)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::bad_request, req.version};
|
http::response<http::string_body> res{http::status::bad_request, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -128,7 +128,7 @@ handle_request(
|
|||||||
auto const not_found =
|
auto const not_found =
|
||||||
[&req](boost::beast::string_view target)
|
[&req](boost::beast::string_view target)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::not_found, req.version};
|
http::response<http::string_body> res{http::status::not_found, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -141,7 +141,7 @@ handle_request(
|
|||||||
auto const server_error =
|
auto const server_error =
|
||||||
[&req](boost::beast::string_view what)
|
[&req](boost::beast::string_view what)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::internal_server_error, req.version};
|
http::response<http::string_body> res{http::status::internal_server_error, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -182,7 +182,7 @@ handle_request(
|
|||||||
// Respond to HEAD request
|
// Respond to HEAD request
|
||||||
if(req.method() == http::verb::head)
|
if(req.method() == http::verb::head)
|
||||||
{
|
{
|
||||||
http::response<http::empty_body> res{http::status::ok, req.version};
|
http::response<http::empty_body> res{http::status::ok, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, mime_type(path));
|
res.set(http::field::content_type, mime_type(path));
|
||||||
res.content_length(body.size());
|
res.content_length(body.size());
|
||||||
@@ -194,7 +194,7 @@ handle_request(
|
|||||||
http::response<http::file_body> res{
|
http::response<http::file_body> res{
|
||||||
std::piecewise_construct,
|
std::piecewise_construct,
|
||||||
std::make_tuple(std::move(body)),
|
std::make_tuple(std::move(body)),
|
||||||
std::make_tuple(http::status::ok, req.version)};
|
std::make_tuple(http::status::ok, req.version())};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, mime_type(path));
|
res.set(http::field::content_type, mime_type(path));
|
||||||
res.content_length(body.size());
|
res.content_length(body.size());
|
||||||
|
@@ -100,7 +100,7 @@ private:
|
|||||||
void
|
void
|
||||||
process_request()
|
process_request()
|
||||||
{
|
{
|
||||||
response_.version = 11;
|
response_.version(11);
|
||||||
response_.set(http::field::connection, "close");
|
response_.set(http::field::connection, "close");
|
||||||
|
|
||||||
switch(request_.method())
|
switch(request_.method())
|
||||||
|
@@ -116,7 +116,7 @@ handle_request(
|
|||||||
auto const bad_request =
|
auto const bad_request =
|
||||||
[&req](boost::beast::string_view why)
|
[&req](boost::beast::string_view why)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::bad_request, req.version};
|
http::response<http::string_body> res{http::status::bad_request, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -129,7 +129,7 @@ handle_request(
|
|||||||
auto const not_found =
|
auto const not_found =
|
||||||
[&req](boost::beast::string_view target)
|
[&req](boost::beast::string_view target)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::not_found, req.version};
|
http::response<http::string_body> res{http::status::not_found, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -142,7 +142,7 @@ handle_request(
|
|||||||
auto const server_error =
|
auto const server_error =
|
||||||
[&req](boost::beast::string_view what)
|
[&req](boost::beast::string_view what)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::internal_server_error, req.version};
|
http::response<http::string_body> res{http::status::internal_server_error, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -183,7 +183,7 @@ handle_request(
|
|||||||
// Respond to HEAD request
|
// Respond to HEAD request
|
||||||
if(req.method() == http::verb::head)
|
if(req.method() == http::verb::head)
|
||||||
{
|
{
|
||||||
http::response<http::empty_body> res{http::status::ok, req.version};
|
http::response<http::empty_body> res{http::status::ok, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, mime_type(path));
|
res.set(http::field::content_type, mime_type(path));
|
||||||
res.content_length(body.size());
|
res.content_length(body.size());
|
||||||
@@ -195,7 +195,7 @@ handle_request(
|
|||||||
http::response<http::file_body> res{
|
http::response<http::file_body> res{
|
||||||
std::piecewise_construct,
|
std::piecewise_construct,
|
||||||
std::make_tuple(std::move(body)),
|
std::make_tuple(std::move(body)),
|
||||||
std::make_tuple(http::status::ok, req.version)};
|
std::make_tuple(http::status::ok, req.version())};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, mime_type(path));
|
res.set(http::field::content_type, mime_type(path));
|
||||||
res.content_length(body.size());
|
res.content_length(body.size());
|
||||||
|
@@ -112,7 +112,7 @@ handle_request(
|
|||||||
auto const bad_request =
|
auto const bad_request =
|
||||||
[&req](boost::beast::string_view why)
|
[&req](boost::beast::string_view why)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::bad_request, req.version};
|
http::response<http::string_body> res{http::status::bad_request, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -125,7 +125,7 @@ handle_request(
|
|||||||
auto const not_found =
|
auto const not_found =
|
||||||
[&req](boost::beast::string_view target)
|
[&req](boost::beast::string_view target)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::not_found, req.version};
|
http::response<http::string_body> res{http::status::not_found, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -138,7 +138,7 @@ handle_request(
|
|||||||
auto const server_error =
|
auto const server_error =
|
||||||
[&req](boost::beast::string_view what)
|
[&req](boost::beast::string_view what)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::internal_server_error, req.version};
|
http::response<http::string_body> res{http::status::internal_server_error, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -179,7 +179,7 @@ handle_request(
|
|||||||
// Respond to HEAD request
|
// Respond to HEAD request
|
||||||
if(req.method() == http::verb::head)
|
if(req.method() == http::verb::head)
|
||||||
{
|
{
|
||||||
http::response<http::empty_body> res{http::status::ok, req.version};
|
http::response<http::empty_body> res{http::status::ok, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, mime_type(path));
|
res.set(http::field::content_type, mime_type(path));
|
||||||
res.content_length(body.size());
|
res.content_length(body.size());
|
||||||
@@ -191,7 +191,7 @@ handle_request(
|
|||||||
http::response<http::file_body> res{
|
http::response<http::file_body> res{
|
||||||
std::piecewise_construct,
|
std::piecewise_construct,
|
||||||
std::make_tuple(std::move(body)),
|
std::make_tuple(std::move(body)),
|
||||||
std::make_tuple(http::status::ok, req.version)};
|
std::make_tuple(http::status::ok, req.version())};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, mime_type(path));
|
res.set(http::field::content_type, mime_type(path));
|
||||||
res.content_length(body.size());
|
res.content_length(body.size());
|
||||||
|
@@ -111,7 +111,7 @@ handle_request(
|
|||||||
auto const bad_request =
|
auto const bad_request =
|
||||||
[&req](boost::beast::string_view why)
|
[&req](boost::beast::string_view why)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::bad_request, req.version};
|
http::response<http::string_body> res{http::status::bad_request, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -124,7 +124,7 @@ handle_request(
|
|||||||
auto const not_found =
|
auto const not_found =
|
||||||
[&req](boost::beast::string_view target)
|
[&req](boost::beast::string_view target)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::not_found, req.version};
|
http::response<http::string_body> res{http::status::not_found, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -137,7 +137,7 @@ handle_request(
|
|||||||
auto const server_error =
|
auto const server_error =
|
||||||
[&req](boost::beast::string_view what)
|
[&req](boost::beast::string_view what)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::internal_server_error, req.version};
|
http::response<http::string_body> res{http::status::internal_server_error, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -178,7 +178,7 @@ handle_request(
|
|||||||
// Respond to HEAD request
|
// Respond to HEAD request
|
||||||
if(req.method() == http::verb::head)
|
if(req.method() == http::verb::head)
|
||||||
{
|
{
|
||||||
http::response<http::empty_body> res{http::status::ok, req.version};
|
http::response<http::empty_body> res{http::status::ok, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, mime_type(path));
|
res.set(http::field::content_type, mime_type(path));
|
||||||
res.content_length(body.size());
|
res.content_length(body.size());
|
||||||
@@ -190,7 +190,7 @@ handle_request(
|
|||||||
http::response<http::file_body> res{
|
http::response<http::file_body> res{
|
||||||
std::piecewise_construct,
|
std::piecewise_construct,
|
||||||
std::make_tuple(std::move(body)),
|
std::make_tuple(std::move(body)),
|
||||||
std::make_tuple(http::status::ok, req.version)};
|
std::make_tuple(http::status::ok, req.version())};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, mime_type(path));
|
res.set(http::field::content_type, mime_type(path));
|
||||||
res.content_length(body.size());
|
res.content_length(body.size());
|
||||||
|
@@ -109,7 +109,7 @@ handle_request(
|
|||||||
auto const bad_request =
|
auto const bad_request =
|
||||||
[&req](boost::beast::string_view why)
|
[&req](boost::beast::string_view why)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::bad_request, req.version};
|
http::response<http::string_body> res{http::status::bad_request, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -122,7 +122,7 @@ handle_request(
|
|||||||
auto const not_found =
|
auto const not_found =
|
||||||
[&req](boost::beast::string_view target)
|
[&req](boost::beast::string_view target)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::not_found, req.version};
|
http::response<http::string_body> res{http::status::not_found, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -135,7 +135,7 @@ handle_request(
|
|||||||
auto const server_error =
|
auto const server_error =
|
||||||
[&req](boost::beast::string_view what)
|
[&req](boost::beast::string_view what)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::internal_server_error, req.version};
|
http::response<http::string_body> res{http::status::internal_server_error, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.keep_alive(req.keep_alive());
|
res.keep_alive(req.keep_alive());
|
||||||
@@ -176,7 +176,7 @@ handle_request(
|
|||||||
// Respond to HEAD request
|
// Respond to HEAD request
|
||||||
if(req.method() == http::verb::head)
|
if(req.method() == http::verb::head)
|
||||||
{
|
{
|
||||||
http::response<http::empty_body> res{http::status::ok, req.version};
|
http::response<http::empty_body> res{http::status::ok, req.version()};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, mime_type(path));
|
res.set(http::field::content_type, mime_type(path));
|
||||||
res.content_length(body.size());
|
res.content_length(body.size());
|
||||||
@@ -188,7 +188,7 @@ handle_request(
|
|||||||
http::response<http::file_body> res{
|
http::response<http::file_body> res{
|
||||||
std::piecewise_construct,
|
std::piecewise_construct,
|
||||||
std::make_tuple(std::move(body)),
|
std::make_tuple(std::move(body)),
|
||||||
std::make_tuple(http::status::ok, req.version)};
|
std::make_tuple(http::status::ok, req.version())};
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, mime_type(path));
|
res.set(http::field::content_type, mime_type(path));
|
||||||
res.content_length(body.size());
|
res.content_length(body.size());
|
||||||
|
@@ -100,7 +100,7 @@ swap(
|
|||||||
swap(
|
swap(
|
||||||
static_cast<Fields&>(h1),
|
static_cast<Fields&>(h1),
|
||||||
static_cast<Fields&>(h2));
|
static_cast<Fields&>(h2));
|
||||||
swap(h1.version, h2.version);
|
swap(h1.version_, h2.version_);
|
||||||
swap(h1.method_, h2.method_);
|
swap(h1.method_, h2.method_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,18 +115,6 @@ header(Arg1&& arg1, ArgN&&... argn)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
template<class Fields>
|
|
||||||
template<class... Args>
|
|
||||||
header<false, Fields>::
|
|
||||||
header(status result, unsigned version_, Args&&... args)
|
|
||||||
: Fields(std::forward<Args>(args)...)
|
|
||||||
, version(version_)
|
|
||||||
, result_(result)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<class Fields>
|
template<class Fields>
|
||||||
inline
|
inline
|
||||||
status
|
status
|
||||||
@@ -198,7 +186,7 @@ swap(
|
|||||||
swap(
|
swap(
|
||||||
static_cast<Fields&>(h1),
|
static_cast<Fields&>(h1),
|
||||||
static_cast<Fields&>(h2));
|
static_cast<Fields&>(h2));
|
||||||
swap(h1.version, h2.version);
|
swap(h1.version_, h2.version_);
|
||||||
swap(h1.result_, h2.result_);
|
swap(h1.result_, h2.result_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,7 +366,7 @@ prepare_payload(std::true_type)
|
|||||||
this->chunked(false);
|
this->chunked(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(this->version >= 11)
|
else if(this->version() >= 11)
|
||||||
{
|
{
|
||||||
this->chunked(true);
|
this->chunked(true);
|
||||||
}
|
}
|
||||||
|
@@ -27,7 +27,7 @@ void
|
|||||||
serializer<isRequest, Body, Fields>::
|
serializer<isRequest, Body, Fields>::
|
||||||
frdinit(std::true_type)
|
frdinit(std::true_type)
|
||||||
{
|
{
|
||||||
frd_.emplace(m_, m_.version, m_.method());
|
frd_.emplace(m_, m_.version(), m_.method());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<
|
template<
|
||||||
@@ -36,7 +36,7 @@ void
|
|||||||
serializer<isRequest, Body, Fields>::
|
serializer<isRequest, Body, Fields>::
|
||||||
frdinit(std::false_type)
|
frdinit(std::false_type)
|
||||||
{
|
{
|
||||||
frd_.emplace(m_, m_.version, m_.result_int());
|
frd_.emplace(m_, m_.version(), m_.result_int());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<
|
template<
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
#include <boost/beast/core/string.hpp>
|
#include <boost/beast/core/string.hpp>
|
||||||
#include <boost/beast/core/detail/empty_base_optimization.hpp>
|
#include <boost/beast/core/detail/empty_base_optimization.hpp>
|
||||||
#include <boost/beast/core/detail/integer_sequence.hpp>
|
#include <boost/beast/core/detail/integer_sequence.hpp>
|
||||||
|
#include <boost/assert.hpp>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <boost/throw_exception.hpp>
|
#include <boost/throw_exception.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -69,7 +70,22 @@ struct header<true, Fields> : Fields
|
|||||||
/// The type representing the fields.
|
/// The type representing the fields.
|
||||||
using fields_type = Fields;
|
using fields_type = Fields;
|
||||||
|
|
||||||
/** The HTTP-version.
|
/// COnstructor
|
||||||
|
header() = default;
|
||||||
|
|
||||||
|
/// Constructor
|
||||||
|
header(header&&) = default;
|
||||||
|
|
||||||
|
/// Constructor
|
||||||
|
header(header const&) = default;
|
||||||
|
|
||||||
|
/// Assignment
|
||||||
|
header& operator=(header&&) = default;
|
||||||
|
|
||||||
|
/// Assignment
|
||||||
|
header& operator=(header const&) = default;
|
||||||
|
|
||||||
|
/** Return the HTTP-version.
|
||||||
|
|
||||||
This holds both the major and minor version numbers,
|
This holds both the major and minor version numbers,
|
||||||
using these formulas:
|
using these formulas:
|
||||||
@@ -80,22 +96,29 @@ struct header<true, Fields> : Fields
|
|||||||
|
|
||||||
Newly constructed headers will use HTTP/1.1 by default.
|
Newly constructed headers will use HTTP/1.1 by default.
|
||||||
*/
|
*/
|
||||||
unsigned version = 11;
|
unsigned version() const noexcept
|
||||||
|
{
|
||||||
|
return version_;
|
||||||
|
}
|
||||||
|
|
||||||
/// Default constructor
|
/** Set the HTTP-version.
|
||||||
header() = default;
|
|
||||||
|
|
||||||
/// Move constructor
|
This holds both the major and minor version numbers,
|
||||||
header(header&&) = default;
|
using these formulas:
|
||||||
|
@code
|
||||||
|
unsigned major = version / 10;
|
||||||
|
unsigned minor = version % 10;
|
||||||
|
@endcode
|
||||||
|
|
||||||
/// Copy constructor
|
Newly constructed headers will use HTTP/1.1 by default.
|
||||||
header(header const&) = default;
|
|
||||||
|
|
||||||
/// Move assignment
|
@param value The version number to use
|
||||||
header& operator=(header&&) = default;
|
*/
|
||||||
|
void version(unsigned value) noexcept
|
||||||
/// Copy assignment
|
{
|
||||||
header& operator=(header const&) = default;
|
BOOST_ASSERT(value > 0 && value < 100);
|
||||||
|
version_ = value;
|
||||||
|
}
|
||||||
|
|
||||||
/** Return the request-method verb.
|
/** Return the request-method verb.
|
||||||
|
|
||||||
@@ -206,15 +229,16 @@ private:
|
|||||||
header(
|
header(
|
||||||
verb method,
|
verb method,
|
||||||
string_view target_,
|
string_view target_,
|
||||||
unsigned version_,
|
unsigned version_value,
|
||||||
FieldsArgs&&... fields_args)
|
FieldsArgs&&... fields_args)
|
||||||
: Fields(std::forward<FieldsArgs>(fields_args)...)
|
: Fields(std::forward<FieldsArgs>(fields_args)...)
|
||||||
, version(version_)
|
|
||||||
, method_(method)
|
, method_(method)
|
||||||
{
|
{
|
||||||
|
version(version_value);
|
||||||
target(target_);
|
target(target_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned version_ = 11;
|
||||||
verb method_ = verb::unknown;
|
verb method_ = verb::unknown;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -234,33 +258,19 @@ struct header<false, Fields> : Fields
|
|||||||
/// The type representing the fields.
|
/// The type representing the fields.
|
||||||
using fields_type = Fields;
|
using fields_type = Fields;
|
||||||
|
|
||||||
/** The HTTP version.
|
/// Constructor.
|
||||||
|
|
||||||
This holds both the major and minor version numbers,
|
|
||||||
using these formulas:
|
|
||||||
@code
|
|
||||||
unsigned major = version / 10;
|
|
||||||
unsigned minor = version % 10;
|
|
||||||
@endcode
|
|
||||||
|
|
||||||
Newly constructed headers will use HTTP/1.1 by default
|
|
||||||
unless otherwise specified.
|
|
||||||
*/
|
|
||||||
unsigned version = 11;
|
|
||||||
|
|
||||||
/// Default constructor.
|
|
||||||
header() = default;
|
header() = default;
|
||||||
|
|
||||||
/// Move constructor
|
/// Constructor
|
||||||
header(header&&) = default;
|
header(header&&) = default;
|
||||||
|
|
||||||
/// Copy constructor
|
/// Constructor
|
||||||
header(header const&) = default;
|
header(header const&) = default;
|
||||||
|
|
||||||
/// Move assignment
|
/// Assignment
|
||||||
header& operator=(header&&) = default;
|
header& operator=(header&&) = default;
|
||||||
|
|
||||||
/// Copy assignment
|
/// Assignment
|
||||||
header& operator=(header const&) = default;
|
header& operator=(header const&) = default;
|
||||||
|
|
||||||
/** Constructor
|
/** Constructor
|
||||||
@@ -282,6 +292,41 @@ struct header<false, Fields> : Fields
|
|||||||
>::type>
|
>::type>
|
||||||
explicit
|
explicit
|
||||||
header(Arg1&& arg1, ArgN&&... argn);
|
header(Arg1&& arg1, ArgN&&... argn);
|
||||||
|
|
||||||
|
/** Return the HTTP-version.
|
||||||
|
|
||||||
|
This holds both the major and minor version numbers,
|
||||||
|
using these formulas:
|
||||||
|
@code
|
||||||
|
unsigned major = version / 10;
|
||||||
|
unsigned minor = version % 10;
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
Newly constructed headers will use HTTP/1.1 by default.
|
||||||
|
*/
|
||||||
|
unsigned version() const noexcept
|
||||||
|
{
|
||||||
|
return version_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set the HTTP-version.
|
||||||
|
|
||||||
|
This holds both the major and minor version numbers,
|
||||||
|
using these formulas:
|
||||||
|
@code
|
||||||
|
unsigned major = version / 10;
|
||||||
|
unsigned minor = version % 10;
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
Newly constructed headers will use HTTP/1.1 by default.
|
||||||
|
|
||||||
|
@param value The version number to use
|
||||||
|
*/
|
||||||
|
void version(unsigned value) noexcept
|
||||||
|
{
|
||||||
|
BOOST_ASSERT(value > 0 && value < 100);
|
||||||
|
version_ = value;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** The response status-code result.
|
/** The response status-code result.
|
||||||
@@ -372,14 +417,15 @@ private:
|
|||||||
template<class... FieldsArgs>
|
template<class... FieldsArgs>
|
||||||
header(
|
header(
|
||||||
status result,
|
status result,
|
||||||
unsigned version_,
|
unsigned version_value,
|
||||||
FieldsArgs&&... fields_args)
|
FieldsArgs&&... fields_args)
|
||||||
: Fields(std::forward<FieldsArgs>(fields_args)...)
|
: Fields(std::forward<FieldsArgs>(fields_args)...)
|
||||||
, version(version_)
|
|
||||||
, result_(result)
|
, result_(result)
|
||||||
{
|
{
|
||||||
|
version(version_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned version_ = 11;
|
||||||
status result_ = status::ok;
|
status result_ = status::ok;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@@ -703,7 +749,7 @@ struct message
|
|||||||
bool
|
bool
|
||||||
keep_alive() const
|
keep_alive() const
|
||||||
{
|
{
|
||||||
return this->get_keep_alive_impl(this->version);
|
return this->get_keep_alive_impl(this->version());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set the keep-alive message semantic option
|
/** Set the keep-alive message semantic option
|
||||||
@@ -719,7 +765,7 @@ struct message
|
|||||||
void
|
void
|
||||||
keep_alive(bool value)
|
keep_alive(bool value)
|
||||||
{
|
{
|
||||||
this->set_keep_alive_impl(this->version, value);
|
this->set_keep_alive_impl(this->version(), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the payload size of the body in octets if possible.
|
/** Returns the payload size of the body in octets if possible.
|
||||||
|
@@ -324,7 +324,7 @@ private:
|
|||||||
{
|
{
|
||||||
ec = error::bad_alloc;
|
ec = error::bad_alloc;
|
||||||
}
|
}
|
||||||
m_.version = version;
|
m_.version(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -335,7 +335,7 @@ private:
|
|||||||
error_code& ec)
|
error_code& ec)
|
||||||
{
|
{
|
||||||
m_.result(code);
|
m_.result(code);
|
||||||
m_.version = version;
|
m_.version(version);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_.reason(reason);
|
m_.reason(reason);
|
||||||
|
@@ -22,7 +22,7 @@ bool
|
|||||||
is_upgrade(http::header<true,
|
is_upgrade(http::header<true,
|
||||||
http::basic_fields<Allocator>> const& req)
|
http::basic_fields<Allocator>> const& req)
|
||||||
{
|
{
|
||||||
if(req.version < 11)
|
if(req.version() < 11)
|
||||||
return false;
|
return false;
|
||||||
if(req.method() != http::verb::get)
|
if(req.method() != http::verb::get)
|
||||||
return false;
|
return false;
|
||||||
|
@@ -523,7 +523,7 @@ build_request(detail::sec_ws_key_type& key,
|
|||||||
{
|
{
|
||||||
request_type req;
|
request_type req;
|
||||||
req.target(target);
|
req.target(target);
|
||||||
req.version = 11;
|
req.version(11);
|
||||||
req.method(http::verb::get);
|
req.method(http::verb::get);
|
||||||
req.set(http::field::host, host);
|
req.set(http::field::host, host);
|
||||||
req.set(http::field::upgrade, "websocket");
|
req.set(http::field::upgrade, "websocket");
|
||||||
@@ -575,14 +575,14 @@ build_response(http::request<Body,
|
|||||||
[&](std::string const& text)
|
[&](std::string const& text)
|
||||||
{
|
{
|
||||||
response_type res;
|
response_type res;
|
||||||
res.version = req.version;
|
res.version(req.version());
|
||||||
res.result(http::status::bad_request);
|
res.result(http::status::bad_request);
|
||||||
res.body() = text;
|
res.body() = text;
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
decorate(res);
|
decorate(res);
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
if(req.version < 11)
|
if(req.version() < 11)
|
||||||
return err("HTTP version 1.1 required");
|
return err("HTTP version 1.1 required");
|
||||||
if(req.method() != http::verb::get)
|
if(req.method() != http::verb::get)
|
||||||
return err("Wrong method");
|
return err("Wrong method");
|
||||||
@@ -604,7 +604,7 @@ build_response(http::request<Body,
|
|||||||
{
|
{
|
||||||
response_type res;
|
response_type res;
|
||||||
res.result(http::status::upgrade_required);
|
res.result(http::status::upgrade_required);
|
||||||
res.version = req.version;
|
res.version(req.version());
|
||||||
res.set(http::field::sec_websocket_version, "13");
|
res.set(http::field::sec_websocket_version, "13");
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
decorate(res);
|
decorate(res);
|
||||||
@@ -620,7 +620,7 @@ build_response(http::request<Body,
|
|||||||
pmd_negotiate(res, unused, offer, pmd_opts_);
|
pmd_negotiate(res, unused, offer, pmd_opts_);
|
||||||
}
|
}
|
||||||
res.result(http::status::switching_protocols);
|
res.result(http::status::switching_protocols);
|
||||||
res.version = req.version;
|
res.version(req.version());
|
||||||
res.set(http::field::upgrade, "websocket");
|
res.set(http::field::upgrade, "websocket");
|
||||||
res.set(http::field::connection, "upgrade");
|
res.set(http::field::connection, "upgrade");
|
||||||
{
|
{
|
||||||
@@ -640,7 +640,7 @@ on_response(response_type const& res,
|
|||||||
{
|
{
|
||||||
bool const success = [&]()
|
bool const success = [&]()
|
||||||
{
|
{
|
||||||
if(res.version < 11)
|
if(res.version() < 11)
|
||||||
return false;
|
return false;
|
||||||
if(res.result() != http::status::switching_protocols)
|
if(res.result() != http::status::switching_protocols)
|
||||||
return false;
|
return false;
|
||||||
|
@@ -3329,12 +3329,14 @@ public:
|
|||||||
|
|
||||||
@param fin `true` if this is the last part of the message.
|
@param fin `true` if this is the last part of the message.
|
||||||
|
|
||||||
|
@param buffers The input buffer sequence holding the data to write.
|
||||||
|
|
||||||
|
@param ec Set to indicate what error occurred, if any.
|
||||||
|
|
||||||
@return The number of bytes written from the buffers.
|
@return The number of bytes written from the buffers.
|
||||||
If an error occurred, this will be less than the sum
|
If an error occurred, this will be less than the sum
|
||||||
of the buffer sizes.
|
of the buffer sizes.
|
||||||
|
|
||||||
@param ec Set to indicate what error occurred, if any.
|
|
||||||
|
|
||||||
@return The number of bytes consumed in the input buffers.
|
@return The number of bytes consumed in the input buffers.
|
||||||
*/
|
*/
|
||||||
template<class ConstBufferSequence>
|
template<class ConstBufferSequence>
|
||||||
|
@@ -445,7 +445,7 @@ public:
|
|||||||
// GET, empty
|
// GET, empty
|
||||||
{
|
{
|
||||||
request<empty_body> req;
|
request<empty_body> req;
|
||||||
req.version = 11;
|
req.version(11);
|
||||||
req.method(verb::get);
|
req.method(verb::get);
|
||||||
|
|
||||||
req.prepare_payload();
|
req.prepare_payload();
|
||||||
@@ -473,7 +473,7 @@ public:
|
|||||||
// GET, sized
|
// GET, sized
|
||||||
{
|
{
|
||||||
request<sized_body> req;
|
request<sized_body> req;
|
||||||
req.version = 11;
|
req.version(11);
|
||||||
req.method(verb::get);
|
req.method(verb::get);
|
||||||
req.body() = 50;
|
req.body() = 50;
|
||||||
|
|
||||||
@@ -496,7 +496,7 @@ public:
|
|||||||
// PUT, empty
|
// PUT, empty
|
||||||
{
|
{
|
||||||
request<empty_body> req;
|
request<empty_body> req;
|
||||||
req.version = 11;
|
req.version(11);
|
||||||
req.method(verb::put);
|
req.method(verb::put);
|
||||||
|
|
||||||
req.prepare_payload();
|
req.prepare_payload();
|
||||||
@@ -513,7 +513,7 @@ public:
|
|||||||
// PUT, sized
|
// PUT, sized
|
||||||
{
|
{
|
||||||
request<sized_body> req;
|
request<sized_body> req;
|
||||||
req.version = 11;
|
req.version(11);
|
||||||
req.method(verb::put);
|
req.method(verb::put);
|
||||||
req.body() = 50;
|
req.body() = 50;
|
||||||
|
|
||||||
@@ -531,7 +531,7 @@ public:
|
|||||||
// POST, unsized
|
// POST, unsized
|
||||||
{
|
{
|
||||||
request<unsized_body> req;
|
request<unsized_body> req;
|
||||||
req.version = 11;
|
req.version(11);
|
||||||
req.method(verb::post);
|
req.method(verb::post);
|
||||||
|
|
||||||
req.prepare_payload();
|
req.prepare_payload();
|
||||||
@@ -547,7 +547,7 @@ public:
|
|||||||
// POST, unsized HTTP/1.0
|
// POST, unsized HTTP/1.0
|
||||||
{
|
{
|
||||||
request<unsized_body> req;
|
request<unsized_body> req;
|
||||||
req.version = 10;
|
req.version(10);
|
||||||
req.method(verb::post);
|
req.method(verb::post);
|
||||||
|
|
||||||
req.prepare_payload();
|
req.prepare_payload();
|
||||||
@@ -563,7 +563,7 @@ public:
|
|||||||
// OK, empty
|
// OK, empty
|
||||||
{
|
{
|
||||||
response<empty_body> res;
|
response<empty_body> res;
|
||||||
res.version = 11;
|
res.version(11);
|
||||||
|
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
BEAST_EXPECT(res[field::content_length] == "0");
|
BEAST_EXPECT(res[field::content_length] == "0");
|
||||||
@@ -579,7 +579,7 @@ public:
|
|||||||
// OK, sized
|
// OK, sized
|
||||||
{
|
{
|
||||||
response<sized_body> res;
|
response<sized_body> res;
|
||||||
res.version = 11;
|
res.version(11);
|
||||||
res.body() = 50;
|
res.body() = 50;
|
||||||
|
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
@@ -596,7 +596,7 @@ public:
|
|||||||
// OK, unsized
|
// OK, unsized
|
||||||
{
|
{
|
||||||
response<unsized_body> res;
|
response<unsized_body> res;
|
||||||
res.version = 11;
|
res.version(11);
|
||||||
|
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
BEAST_EXPECT(res.count(field::content_length) == 0);
|
BEAST_EXPECT(res.count(field::content_length) == 0);
|
||||||
@@ -621,7 +621,7 @@ public:
|
|||||||
std::string const big(4096 + 1, 'a');
|
std::string const big(4096 + 1, 'a');
|
||||||
|
|
||||||
// HTTP/1.0
|
// HTTP/1.0
|
||||||
res.version = 10;
|
res.version(10);
|
||||||
res.erase(field::connection);
|
res.erase(field::connection);
|
||||||
|
|
||||||
keep_alive(false);
|
keep_alive(false);
|
||||||
@@ -695,7 +695,7 @@ public:
|
|||||||
test10(big);
|
test10(big);
|
||||||
|
|
||||||
// HTTP/1.1
|
// HTTP/1.1
|
||||||
res.version = 11;
|
res.version(11);
|
||||||
|
|
||||||
res.erase(field::connection);
|
res.erase(field::connection);
|
||||||
keep_alive(true);
|
keep_alive(true);
|
||||||
|
@@ -149,7 +149,7 @@ public:
|
|||||||
BEAST_EXPECT(h.count(http::field::user_agent) == 0);
|
BEAST_EXPECT(h.count(http::field::user_agent) == 0);
|
||||||
BEAST_EXPECT(m.method() == verb::get);
|
BEAST_EXPECT(m.method() == verb::get);
|
||||||
BEAST_EXPECT(m.target() == "/");
|
BEAST_EXPECT(m.target() == "/");
|
||||||
BEAST_EXPECT(m.version == 10);
|
BEAST_EXPECT(m.version() == 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
// swap
|
// swap
|
||||||
@@ -216,19 +216,19 @@ public:
|
|||||||
{
|
{
|
||||||
{
|
{
|
||||||
request<empty_body> req;
|
request<empty_body> req;
|
||||||
BEAST_EXPECT(req.version == 11);
|
BEAST_EXPECT(req.version() == 11);
|
||||||
BEAST_EXPECT(req.method() == verb::unknown);
|
BEAST_EXPECT(req.method() == verb::unknown);
|
||||||
BEAST_EXPECT(req.target() == "");
|
BEAST_EXPECT(req.target() == "");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
request<empty_body> req{verb::get, "/", 11};
|
request<empty_body> req{verb::get, "/", 11};
|
||||||
BEAST_EXPECT(req.version == 11);
|
BEAST_EXPECT(req.version() == 11);
|
||||||
BEAST_EXPECT(req.method() == verb::get);
|
BEAST_EXPECT(req.method() == verb::get);
|
||||||
BEAST_EXPECT(req.target() == "/");
|
BEAST_EXPECT(req.target() == "/");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
request<string_body> req{verb::get, "/", 11, "Hello"};
|
request<string_body> req{verb::get, "/", 11, "Hello"};
|
||||||
BEAST_EXPECT(req.version == 11);
|
BEAST_EXPECT(req.version() == 11);
|
||||||
BEAST_EXPECT(req.method() == verb::get);
|
BEAST_EXPECT(req.method() == verb::get);
|
||||||
BEAST_EXPECT(req.target() == "/");
|
BEAST_EXPECT(req.target() == "/");
|
||||||
BEAST_EXPECT(req.body() == "Hello");
|
BEAST_EXPECT(req.body() == "Hello");
|
||||||
@@ -236,26 +236,26 @@ public:
|
|||||||
{
|
{
|
||||||
request<string_body, test_fields> req{
|
request<string_body, test_fields> req{
|
||||||
verb::get, "/", 11, "Hello", token{}};
|
verb::get, "/", 11, "Hello", token{}};
|
||||||
BEAST_EXPECT(req.version == 11);
|
BEAST_EXPECT(req.version() == 11);
|
||||||
BEAST_EXPECT(req.method() == verb::get);
|
BEAST_EXPECT(req.method() == verb::get);
|
||||||
BEAST_EXPECT(req.target() == "/");
|
BEAST_EXPECT(req.target() == "/");
|
||||||
BEAST_EXPECT(req.body() == "Hello");
|
BEAST_EXPECT(req.body() == "Hello");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
response<string_body> res;
|
response<string_body> res;
|
||||||
BEAST_EXPECT(res.version == 11);
|
BEAST_EXPECT(res.version() == 11);
|
||||||
BEAST_EXPECT(res.result() == status::ok);
|
BEAST_EXPECT(res.result() == status::ok);
|
||||||
BEAST_EXPECT(res.reason() == "OK");
|
BEAST_EXPECT(res.reason() == "OK");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
response<string_body> res{status::bad_request, 10};
|
response<string_body> res{status::bad_request, 10};
|
||||||
BEAST_EXPECT(res.version == 10);
|
BEAST_EXPECT(res.version() == 10);
|
||||||
BEAST_EXPECT(res.result() == status::bad_request);
|
BEAST_EXPECT(res.result() == status::bad_request);
|
||||||
BEAST_EXPECT(res.reason() == "Bad Request");
|
BEAST_EXPECT(res.reason() == "Bad Request");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
response<string_body> res{status::bad_request, 10, "Hello"};
|
response<string_body> res{status::bad_request, 10, "Hello"};
|
||||||
BEAST_EXPECT(res.version == 10);
|
BEAST_EXPECT(res.version() == 10);
|
||||||
BEAST_EXPECT(res.result() == status::bad_request);
|
BEAST_EXPECT(res.result() == status::bad_request);
|
||||||
BEAST_EXPECT(res.reason() == "Bad Request");
|
BEAST_EXPECT(res.reason() == "Bad Request");
|
||||||
BEAST_EXPECT(res.body() == "Hello");
|
BEAST_EXPECT(res.body() == "Hello");
|
||||||
@@ -263,7 +263,7 @@ public:
|
|||||||
{
|
{
|
||||||
response<string_body, test_fields> res{
|
response<string_body, test_fields> res{
|
||||||
status::bad_request, 10, "Hello", token{}};
|
status::bad_request, 10, "Hello", token{}};
|
||||||
BEAST_EXPECT(res.version == 10);
|
BEAST_EXPECT(res.version() == 10);
|
||||||
BEAST_EXPECT(res.result() == status::bad_request);
|
BEAST_EXPECT(res.result() == status::bad_request);
|
||||||
BEAST_EXPECT(res.reason() == "Bad Request");
|
BEAST_EXPECT(res.reason() == "Bad Request");
|
||||||
BEAST_EXPECT(res.body() == "Hello");
|
BEAST_EXPECT(res.body() == "Hello");
|
||||||
@@ -276,12 +276,12 @@ public:
|
|||||||
response<string_body> m1;
|
response<string_body> m1;
|
||||||
response<string_body> m2;
|
response<string_body> m2;
|
||||||
m1.result(status::ok);
|
m1.result(status::ok);
|
||||||
m1.version = 10;
|
m1.version(10);
|
||||||
m1.body() = "1";
|
m1.body() = "1";
|
||||||
m1.insert("h", "v");
|
m1.insert("h", "v");
|
||||||
m2.result(status::not_found);
|
m2.result(status::not_found);
|
||||||
m2.body() = "2";
|
m2.body() = "2";
|
||||||
m2.version = 11;
|
m2.version(11);
|
||||||
swap(m1, m2);
|
swap(m1, m2);
|
||||||
BEAST_EXPECT(m1.result() == status::not_found);
|
BEAST_EXPECT(m1.result() == status::not_found);
|
||||||
BEAST_EXPECT(m1.result_int() == 404);
|
BEAST_EXPECT(m1.result_int() == 404);
|
||||||
@@ -289,8 +289,8 @@ public:
|
|||||||
BEAST_EXPECT(m2.result_int() == 200);
|
BEAST_EXPECT(m2.result_int() == 200);
|
||||||
BEAST_EXPECT(m1.reason() == "Not Found");
|
BEAST_EXPECT(m1.reason() == "Not Found");
|
||||||
BEAST_EXPECT(m2.reason() == "OK");
|
BEAST_EXPECT(m2.reason() == "OK");
|
||||||
BEAST_EXPECT(m1.version == 11);
|
BEAST_EXPECT(m1.version() == 11);
|
||||||
BEAST_EXPECT(m2.version == 10);
|
BEAST_EXPECT(m2.version() == 10);
|
||||||
BEAST_EXPECT(m1.body() == "2");
|
BEAST_EXPECT(m1.body() == "2");
|
||||||
BEAST_EXPECT(m2.body() == "1");
|
BEAST_EXPECT(m2.body() == "1");
|
||||||
BEAST_EXPECT(! m1.count("h"));
|
BEAST_EXPECT(! m1.count("h"));
|
||||||
|
@@ -131,7 +131,7 @@ public:
|
|||||||
BEAST_EXPECT(! p.is_chunked());
|
BEAST_EXPECT(! p.is_chunked());
|
||||||
BEAST_EXPECT(p.need_eof());
|
BEAST_EXPECT(p.need_eof());
|
||||||
BEAST_EXPECT(p.content_length() == boost::none);
|
BEAST_EXPECT(p.content_length() == boost::none);
|
||||||
BEAST_EXPECT(m.version == 10);
|
BEAST_EXPECT(m.version() == 10);
|
||||||
BEAST_EXPECT(m.result() == status::ok);
|
BEAST_EXPECT(m.result() == status::ok);
|
||||||
BEAST_EXPECT(m.reason() == "OK");
|
BEAST_EXPECT(m.reason() == "OK");
|
||||||
BEAST_EXPECT(m["Server"] == "test");
|
BEAST_EXPECT(m["Server"] == "test");
|
||||||
@@ -158,7 +158,7 @@ public:
|
|||||||
BEAST_EXPECT(! p.need_eof());
|
BEAST_EXPECT(! p.need_eof());
|
||||||
BEAST_EXPECT(p.is_chunked());
|
BEAST_EXPECT(p.is_chunked());
|
||||||
BEAST_EXPECT(p.content_length() == boost::none);
|
BEAST_EXPECT(p.content_length() == boost::none);
|
||||||
BEAST_EXPECT(m.version == 11);
|
BEAST_EXPECT(m.version() == 11);
|
||||||
BEAST_EXPECT(m.result() == status::ok);
|
BEAST_EXPECT(m.result() == status::ok);
|
||||||
BEAST_EXPECT(m.reason() == "OK");
|
BEAST_EXPECT(m.reason() == "OK");
|
||||||
BEAST_EXPECT(m["Server"] == "test");
|
BEAST_EXPECT(m["Server"] == "test");
|
||||||
@@ -189,7 +189,7 @@ public:
|
|||||||
auto const& m = p.get();
|
auto const& m = p.get();
|
||||||
BEAST_EXPECT(m.method() == verb::get);
|
BEAST_EXPECT(m.method() == verb::get);
|
||||||
BEAST_EXPECT(m.target() == "/");
|
BEAST_EXPECT(m.target() == "/");
|
||||||
BEAST_EXPECT(m.version == 11);
|
BEAST_EXPECT(m.version() == 11);
|
||||||
BEAST_EXPECT(! p.need_eof());
|
BEAST_EXPECT(! p.need_eof());
|
||||||
BEAST_EXPECT(! p.is_chunked());
|
BEAST_EXPECT(! p.is_chunked());
|
||||||
BEAST_EXPECT(p.content_length() == boost::none);
|
BEAST_EXPECT(p.content_length() == boost::none);
|
||||||
@@ -226,7 +226,7 @@ public:
|
|||||||
BEAST_EXPECT(! p.need_eof());
|
BEAST_EXPECT(! p.need_eof());
|
||||||
BEAST_EXPECT(m.method() == verb::get);
|
BEAST_EXPECT(m.method() == verb::get);
|
||||||
BEAST_EXPECT(m.target() == "/");
|
BEAST_EXPECT(m.target() == "/");
|
||||||
BEAST_EXPECT(m.version == 11);
|
BEAST_EXPECT(m.version() == 11);
|
||||||
BEAST_EXPECT(m["User-Agent"] == "test");
|
BEAST_EXPECT(m["User-Agent"] == "test");
|
||||||
BEAST_EXPECT(m.body() == "*");
|
BEAST_EXPECT(m.body() == "*");
|
||||||
}
|
}
|
||||||
|
@@ -319,7 +319,7 @@ public:
|
|||||||
{
|
{
|
||||||
{
|
{
|
||||||
response<string_body> m;
|
response<string_body> m;
|
||||||
m.version = 10;
|
m.version(10);
|
||||||
m.result(status::ok);
|
m.result(status::ok);
|
||||||
m.set(field::server, "test");
|
m.set(field::server, "test");
|
||||||
m.set(field::content_length, "5");
|
m.set(field::content_length, "5");
|
||||||
@@ -338,7 +338,7 @@ public:
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
response<string_body> m;
|
response<string_body> m;
|
||||||
m.version = 11;
|
m.version(11);
|
||||||
m.result(status::ok);
|
m.result(status::ok);
|
||||||
m.set(field::server, "test");
|
m.set(field::server, "test");
|
||||||
m.set(field::transfer_encoding, "chunked");
|
m.set(field::transfer_encoding, "chunked");
|
||||||
@@ -518,7 +518,7 @@ public:
|
|||||||
request<string_body> m;
|
request<string_body> m;
|
||||||
m.method(verb::get);
|
m.method(verb::get);
|
||||||
m.target("/");
|
m.target("/");
|
||||||
m.version = 10;
|
m.version(10);
|
||||||
m.set(field::user_agent, "test");
|
m.set(field::user_agent, "test");
|
||||||
m.body() = "*";
|
m.body() = "*";
|
||||||
m.prepare_payload();
|
m.prepare_payload();
|
||||||
@@ -535,7 +535,7 @@ public:
|
|||||||
request<unsized_body> m;
|
request<unsized_body> m;
|
||||||
m.method(verb::get);
|
m.method(verb::get);
|
||||||
m.target("/");
|
m.target("/");
|
||||||
m.version = 10;
|
m.version(10);
|
||||||
m.set(field::user_agent, "test");
|
m.set(field::user_agent, "test");
|
||||||
m.body() = "*";
|
m.body() = "*";
|
||||||
m.prepare_payload();
|
m.prepare_payload();
|
||||||
@@ -556,7 +556,7 @@ public:
|
|||||||
request<string_body> m;
|
request<string_body> m;
|
||||||
m.method(verb::get);
|
m.method(verb::get);
|
||||||
m.target("/");
|
m.target("/");
|
||||||
m.version = 11;
|
m.version(11);
|
||||||
m.set(field::user_agent, "test");
|
m.set(field::user_agent, "test");
|
||||||
m.body() = "*";
|
m.body() = "*";
|
||||||
m.prepare_payload();
|
m.prepare_payload();
|
||||||
@@ -573,7 +573,7 @@ public:
|
|||||||
request<unsized_body> m;
|
request<unsized_body> m;
|
||||||
m.method(verb::get);
|
m.method(verb::get);
|
||||||
m.target("/");
|
m.target("/");
|
||||||
m.version = 11;
|
m.version(11);
|
||||||
m.set(field::user_agent, "test");
|
m.set(field::user_agent, "test");
|
||||||
m.body() = "*";
|
m.body() = "*";
|
||||||
m.prepare_payload();
|
m.prepare_payload();
|
||||||
@@ -599,7 +599,7 @@ public:
|
|||||||
request<string_body> m;
|
request<string_body> m;
|
||||||
m.method(verb::get);
|
m.method(verb::get);
|
||||||
m.target("/");
|
m.target("/");
|
||||||
m.version = 11;
|
m.version(11);
|
||||||
m.set(field::user_agent, "test");
|
m.set(field::user_agent, "test");
|
||||||
m.body() = "*";
|
m.body() = "*";
|
||||||
BEAST_EXPECT(to_string(m) ==
|
BEAST_EXPECT(to_string(m) ==
|
||||||
@@ -628,7 +628,7 @@ public:
|
|||||||
BEAST_EXPECT(handler::count() == 0);
|
BEAST_EXPECT(handler::count() == 0);
|
||||||
request<string_body> m;
|
request<string_body> m;
|
||||||
m.method(verb::get);
|
m.method(verb::get);
|
||||||
m.version = 11;
|
m.version(11);
|
||||||
m.target("/");
|
m.target("/");
|
||||||
m.set("Content-Length", 5);
|
m.set("Content-Length", 5);
|
||||||
m.body() = "*****";
|
m.body() = "*****";
|
||||||
@@ -651,7 +651,7 @@ public:
|
|||||||
BEAST_EXPECT(handler::count() == 0);
|
BEAST_EXPECT(handler::count() == 0);
|
||||||
request<string_body> m;
|
request<string_body> m;
|
||||||
m.method(verb::get);
|
m.method(verb::get);
|
||||||
m.version = 11;
|
m.version(11);
|
||||||
m.target("/");
|
m.target("/");
|
||||||
m.set("Content-Length", 5);
|
m.set("Content-Length", 5);
|
||||||
m.body() = "*****";
|
m.body() = "*****";
|
||||||
@@ -712,7 +712,7 @@ public:
|
|||||||
ts.write_size(3);
|
ts.write_size(3);
|
||||||
|
|
||||||
response<Body> m0;
|
response<Body> m0;
|
||||||
m0.version = 11;
|
m0.version(11);
|
||||||
m0.result(status::ok);
|
m0.result(status::ok);
|
||||||
m0.reason("OK");
|
m0.reason("OK");
|
||||||
m0.set(field::server, "test");
|
m0.set(field::server, "test");
|
||||||
|
@@ -327,7 +327,7 @@ public:
|
|||||||
request_type req;
|
request_type req;
|
||||||
req.method(http::verb::get);
|
req.method(http::verb::get);
|
||||||
req.target("/");
|
req.target("/");
|
||||||
req.version = 11;
|
req.version(11);
|
||||||
req.insert(http::field::host, "localhost");
|
req.insert(http::field::host, "localhost");
|
||||||
req.insert(http::field::upgrade, "websocket");
|
req.insert(http::field::upgrade, "websocket");
|
||||||
req.insert(http::field::connection, "upgrade");
|
req.insert(http::field::connection, "upgrade");
|
||||||
@@ -344,7 +344,7 @@ public:
|
|||||||
request_type req;
|
request_type req;
|
||||||
req.method(http::verb::get);
|
req.method(http::verb::get);
|
||||||
req.target("/");
|
req.target("/");
|
||||||
req.version = 11;
|
req.version(11);
|
||||||
req.insert(http::field::host, "localhost");
|
req.insert(http::field::host, "localhost");
|
||||||
req.insert(http::field::upgrade, "websocket");
|
req.insert(http::field::upgrade, "websocket");
|
||||||
req.insert(http::field::connection, "upgrade");
|
req.insert(http::field::connection, "upgrade");
|
||||||
@@ -364,7 +364,7 @@ public:
|
|||||||
request_type req;
|
request_type req;
|
||||||
req.method(http::verb::get);
|
req.method(http::verb::get);
|
||||||
req.target("/");
|
req.target("/");
|
||||||
req.version = 11;
|
req.version(11);
|
||||||
req.insert(http::field::host, "localhost");
|
req.insert(http::field::host, "localhost");
|
||||||
req.insert(http::field::upgrade, "websocket");
|
req.insert(http::field::upgrade, "websocket");
|
||||||
req.insert(http::field::connection, "upgrade");
|
req.insert(http::field::connection, "upgrade");
|
||||||
|
@@ -24,9 +24,9 @@ public:
|
|||||||
test_is_upgrade()
|
test_is_upgrade()
|
||||||
{
|
{
|
||||||
http::header<true> req;
|
http::header<true> req;
|
||||||
req.version = 10;
|
req.version(10);
|
||||||
BEAST_EXPECT(! is_upgrade(req));
|
BEAST_EXPECT(! is_upgrade(req));
|
||||||
req.version = 11;
|
req.version(11);
|
||||||
req.method(http::verb::post);
|
req.method(http::verb::post);
|
||||||
req.target("/");
|
req.target("/");
|
||||||
BEAST_EXPECT(! is_upgrade(req));
|
BEAST_EXPECT(! is_upgrade(req));
|
||||||
|
@@ -105,7 +105,7 @@ public:
|
|||||||
{
|
{
|
||||||
flat_buffer buffer;
|
flat_buffer buffer;
|
||||||
request<string_body> req;
|
request<string_body> req;
|
||||||
req.version = 11;
|
req.version(11);
|
||||||
req.method_string("POST");
|
req.method_string("POST");
|
||||||
req.target("/");
|
req.target("/");
|
||||||
req.insert(field::user_agent, "test");
|
req.insert(field::user_agent, "test");
|
||||||
@@ -138,7 +138,7 @@ public:
|
|||||||
doRelay()
|
doRelay()
|
||||||
{
|
{
|
||||||
request<string_body> req;
|
request<string_body> req;
|
||||||
req.version = 11;
|
req.version(11);
|
||||||
req.method_string("POST");
|
req.method_string("POST");
|
||||||
req.target("/");
|
req.target("/");
|
||||||
req.insert(field::user_agent, "test");
|
req.insert(field::user_agent, "test");
|
||||||
@@ -192,7 +192,7 @@ public:
|
|||||||
{
|
{
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
request<string_body> req;
|
request<string_body> req;
|
||||||
req.version = 11;
|
req.version(11);
|
||||||
req.method(verb::get);
|
req.method(verb::get);
|
||||||
req.target("/");
|
req.target("/");
|
||||||
req.insert(field::user_agent, "test");
|
req.insert(field::user_agent, "test");
|
||||||
|
@@ -45,7 +45,7 @@ void fxx() {
|
|||||||
//[http_snippet_2
|
//[http_snippet_2
|
||||||
|
|
||||||
request<empty_body> req;
|
request<empty_body> req;
|
||||||
req.version = 11; // HTTP/1.1
|
req.version(11); // HTTP/1.1
|
||||||
req.method(verb::get);
|
req.method(verb::get);
|
||||||
req.target("/index.htm");
|
req.target("/index.htm");
|
||||||
req.set(field::accept, "text/html");
|
req.set(field::accept, "text/html");
|
||||||
@@ -58,7 +58,7 @@ void fxx() {
|
|||||||
//[http_snippet_3
|
//[http_snippet_3
|
||||||
|
|
||||||
response<string_body> res;
|
response<string_body> res;
|
||||||
res.version = 11; // HTTP/1.1
|
res.version(11); // HTTP/1.1
|
||||||
res.result(status::ok);
|
res.result(status::ok);
|
||||||
res.set(field::server, "Beast");
|
res.set(field::server, "Beast");
|
||||||
res.body() = "Hello, world!";
|
res.body() = "Hello, world!";
|
||||||
@@ -112,7 +112,7 @@ void fxx() {
|
|||||||
//[http_snippet_7
|
//[http_snippet_7
|
||||||
|
|
||||||
response<string_body> res;
|
response<string_body> res;
|
||||||
res.version = 11;
|
res.version(11);
|
||||||
res.result(status::ok);
|
res.result(status::ok);
|
||||||
res.set(field::server, "Beast");
|
res.set(field::server, "Beast");
|
||||||
res.body() = "Hello, world!";
|
res.body() = "Hello, world!";
|
||||||
|
Reference in New Issue
Block a user