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