mirror of
https://github.com/boostorg/beast.git
synced 2025-07-30 04:47:29 +02:00
message::body is a member function (API Change):
fix #778 * The body data member is replaced with accessor member functions. Actions Required: * Call member function message::body instead of accessing the data member at call sites.
This commit is contained in:
13
CHANGELOG.md
13
CHANGELOG.md
@ -1,3 +1,16 @@
|
|||||||
|
Version 116:
|
||||||
|
|
||||||
|
API Changes:
|
||||||
|
|
||||||
|
* message::body is a member function
|
||||||
|
|
||||||
|
Actions Required:
|
||||||
|
|
||||||
|
* Call member function message::body instead of accessing
|
||||||
|
the data member at call sites.
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
Version 115:
|
Version 115:
|
||||||
|
|
||||||
* Update README.md master doc link
|
* Update README.md master doc link
|
||||||
|
@ -124,7 +124,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = why.to_string();
|
res.body() = why.to_string();
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
@ -137,7 +137,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = "The resource '" + target.to_string() + "' was not found.";
|
res.body() = "The resource '" + target.to_string() + "' was not found.";
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
@ -150,7 +150,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = "An error occurred: '" + what.to_string() + "'";
|
res.body() = "An error occurred: '" + what.to_string() + "'";
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
@ -118,7 +118,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = why.to_string();
|
res.body() = why.to_string();
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
@ -131,7 +131,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = "The resource '" + target.to_string() + "' was not found.";
|
res.body() = "The resource '" + target.to_string() + "' was not found.";
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
@ -144,7 +144,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = "An error occurred: '" + what.to_string() + "'";
|
res.body() = "An error occurred: '" + what.to_string() + "'";
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
@ -210,8 +210,8 @@ send_cgi_response(
|
|||||||
// that it might be coming later. Otherwise the
|
// that it might be coming later. Otherwise the
|
||||||
// serializer::is_done would return true right after
|
// serializer::is_done would return true right after
|
||||||
// sending the header.
|
// sending the header.
|
||||||
res.body.data = nullptr;
|
res.body().data = nullptr;
|
||||||
res.body.more = true;
|
res.body().more = true;
|
||||||
|
|
||||||
// Create the serializer.
|
// Create the serializer.
|
||||||
response_serializer<buffer_body, fields> sr{res};
|
response_serializer<buffer_body, fields> sr{res};
|
||||||
@ -235,10 +235,10 @@ send_cgi_response(
|
|||||||
ec = {};
|
ec = {};
|
||||||
|
|
||||||
// `nullptr` indicates there is no buffer
|
// `nullptr` indicates there is no buffer
|
||||||
res.body.data = nullptr;
|
res.body().data = nullptr;
|
||||||
|
|
||||||
// `false` means no more data is coming
|
// `false` means no more data is coming
|
||||||
res.body.more = false;
|
res.body().more = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -248,9 +248,9 @@ send_cgi_response(
|
|||||||
// Point to our buffer with the bytes that
|
// Point to our buffer with the bytes that
|
||||||
// we received, and indicate that there may
|
// we received, and indicate that there may
|
||||||
// be some more data coming
|
// be some more data coming
|
||||||
res.body.data = buffer;
|
res.body().data = buffer;
|
||||||
res.body.size = bytes_transferred;
|
res.body().size = bytes_transferred;
|
||||||
res.body.more = true;
|
res.body().more = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write everything in the body buffer
|
// Write everything in the body buffer
|
||||||
@ -328,7 +328,7 @@ void do_server_head(
|
|||||||
// We deliver the same payload for GET requests
|
// We deliver the same payload for GET requests
|
||||||
// regardless of the target. A real server might
|
// regardless of the target. A real server might
|
||||||
// deliver a file based on the target.
|
// deliver a file based on the target.
|
||||||
res.body = payload;
|
res.body() = payload;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -339,7 +339,7 @@ void do_server_head(
|
|||||||
// we do not recognize the request method.
|
// we do not recognize the request method.
|
||||||
res.result(status::bad_request);
|
res.result(status::bad_request);
|
||||||
res.set(field::content_type, "text/plain");
|
res.set(field::content_type, "text/plain");
|
||||||
res.body = "Invalid request-method '" + req.method_string().to_string() + "'";
|
res.body() = "Invalid request-method '" + req.method_string().to_string() + "'";
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -520,8 +520,8 @@ relay(
|
|||||||
if(! p.is_done())
|
if(! p.is_done())
|
||||||
{
|
{
|
||||||
// Set up the body for writing into our small buffer
|
// Set up the body for writing into our small buffer
|
||||||
p.get().body.data = buf;
|
p.get().body().data = buf;
|
||||||
p.get().body.size = sizeof(buf);
|
p.get().body().size = sizeof(buf);
|
||||||
|
|
||||||
// Read as much as we can
|
// Read as much as we can
|
||||||
read(input, buffer, p, ec);
|
read(input, buffer, p, ec);
|
||||||
@ -534,14 +534,14 @@ relay(
|
|||||||
|
|
||||||
// Set up the body for reading.
|
// Set up the body for reading.
|
||||||
// This is how much was parsed:
|
// This is how much was parsed:
|
||||||
p.get().body.size = sizeof(buf) - p.get().body.size;
|
p.get().body().size = sizeof(buf) - p.get().body().size;
|
||||||
p.get().body.data = buf;
|
p.get().body().data = buf;
|
||||||
p.get().body.more = ! p.is_done();
|
p.get().body().more = ! p.is_done();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p.get().body.data = nullptr;
|
p.get().body().data = nullptr;
|
||||||
p.get().body.size = 0;
|
p.get().body().size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write everything in the buffer (which might be empty)
|
// Write everything in the buffer (which might be empty)
|
||||||
@ -1095,14 +1095,14 @@ read_and_print_body(
|
|||||||
while(! p.is_done())
|
while(! p.is_done())
|
||||||
{
|
{
|
||||||
char buf[512];
|
char buf[512];
|
||||||
p.get().body.data = buf;
|
p.get().body().data = buf;
|
||||||
p.get().body.size = sizeof(buf);
|
p.get().body().size = sizeof(buf);
|
||||||
read(stream, buffer, p, ec);
|
read(stream, buffer, p, ec);
|
||||||
if(ec == error::need_buffer)
|
if(ec == error::need_buffer)
|
||||||
ec.assign(0, ec.category());
|
ec.assign(0, ec.category());
|
||||||
if(ec)
|
if(ec)
|
||||||
return;
|
return;
|
||||||
os.write(buf, sizeof(buf) - p.get().body.size);
|
os.write(buf, sizeof(buf) - p.get().body().size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = why.to_string();
|
res.body() = why.to_string();
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
@ -132,7 +132,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = "The resource '" + target.to_string() + "' was not found.";
|
res.body() = "The resource '" + target.to_string() + "' was not found.";
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
@ -145,7 +145,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = "An error occurred: '" + what.to_string() + "'";
|
res.body() = "An error occurred: '" + what.to_string() + "'";
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
@ -115,7 +115,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = why.to_string();
|
res.body() = why.to_string();
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
@ -128,7 +128,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = "The resource '" + target.to_string() + "' was not found.";
|
res.body() = "The resource '" + target.to_string() + "' was not found.";
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
@ -141,7 +141,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = "An error occurred: '" + what.to_string() + "'";
|
res.body() = "An error occurred: '" + what.to_string() + "'";
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
@ -118,7 +118,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = why.to_string();
|
res.body() = why.to_string();
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
@ -131,7 +131,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = "The resource '" + target.to_string() + "' was not found.";
|
res.body() = "The resource '" + target.to_string() + "' was not found.";
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
@ -144,7 +144,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = "An error occurred: '" + what.to_string() + "'";
|
res.body() = "An error occurred: '" + what.to_string() + "'";
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
@ -114,7 +114,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = why.to_string();
|
res.body() = why.to_string();
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
@ -127,7 +127,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = "The resource '" + target.to_string() + "' was not found.";
|
res.body() = "The resource '" + target.to_string() + "' was not found.";
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
@ -140,7 +140,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = "An error occurred: '" + what.to_string() + "'";
|
res.body() = "An error occurred: '" + what.to_string() + "'";
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
@ -212,7 +212,7 @@ private:
|
|||||||
string_response_->set(http::field::server, "Beast");
|
string_response_->set(http::field::server, "Beast");
|
||||||
string_response_->set(http::field::connection, "close");
|
string_response_->set(http::field::connection, "close");
|
||||||
string_response_->set(http::field::content_type, "text/plain");
|
string_response_->set(http::field::content_type, "text/plain");
|
||||||
string_response_->body = error;
|
string_response_->body() = error;
|
||||||
string_response_->prepare_payload();
|
string_response_->prepare_payload();
|
||||||
|
|
||||||
string_serializer_.emplace(*string_response_);
|
string_serializer_.emplace(*string_response_);
|
||||||
@ -268,7 +268,7 @@ private:
|
|||||||
file_response_->set(http::field::server, "Beast");
|
file_response_->set(http::field::server, "Beast");
|
||||||
file_response_->set(http::field::connection, "close");
|
file_response_->set(http::field::connection, "close");
|
||||||
file_response_->set(http::field::content_type, mime_type(target.to_string()));
|
file_response_->set(http::field::content_type, mime_type(target.to_string()));
|
||||||
file_response_->body = std::move(file);
|
file_response_->body() = std::move(file);
|
||||||
file_response_->prepare_payload();
|
file_response_->prepare_payload();
|
||||||
|
|
||||||
file_serializer_.emplace(*file_response_);
|
file_serializer_.emplace(*file_response_);
|
||||||
|
@ -119,7 +119,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = why.to_string();
|
res.body() = why.to_string();
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
@ -132,7 +132,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = "The resource '" + target.to_string() + "' was not found.";
|
res.body() = "The resource '" + target.to_string() + "' was not found.";
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
@ -145,7 +145,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = "An error occurred: '" + what.to_string() + "'";
|
res.body() = "An error occurred: '" + what.to_string() + "'";
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
@ -116,7 +116,7 @@ private:
|
|||||||
// we do not recognize the request method.
|
// we do not recognize the request method.
|
||||||
response_.result(http::status::bad_request);
|
response_.result(http::status::bad_request);
|
||||||
response_.set(http::field::content_type, "text/plain");
|
response_.set(http::field::content_type, "text/plain");
|
||||||
boost::beast::ostream(response_.body)
|
boost::beast::ostream(response_.body())
|
||||||
<< "Invalid request-method '"
|
<< "Invalid request-method '"
|
||||||
<< request_.method_string().to_string()
|
<< request_.method_string().to_string()
|
||||||
<< "'";
|
<< "'";
|
||||||
@ -133,7 +133,7 @@ private:
|
|||||||
if(request_.target() == "/count")
|
if(request_.target() == "/count")
|
||||||
{
|
{
|
||||||
response_.set(http::field::content_type, "text/html");
|
response_.set(http::field::content_type, "text/html");
|
||||||
boost::beast::ostream(response_.body)
|
boost::beast::ostream(response_.body())
|
||||||
<< "<html>\n"
|
<< "<html>\n"
|
||||||
<< "<head><title>Request count</title></head>\n"
|
<< "<head><title>Request count</title></head>\n"
|
||||||
<< "<body>\n"
|
<< "<body>\n"
|
||||||
@ -147,7 +147,7 @@ private:
|
|||||||
else if(request_.target() == "/time")
|
else if(request_.target() == "/time")
|
||||||
{
|
{
|
||||||
response_.set(http::field::content_type, "text/html");
|
response_.set(http::field::content_type, "text/html");
|
||||||
boost::beast::ostream(response_.body)
|
boost::beast::ostream(response_.body())
|
||||||
<< "<html>\n"
|
<< "<html>\n"
|
||||||
<< "<head><title>Current time</title></head>\n"
|
<< "<head><title>Current time</title></head>\n"
|
||||||
<< "<body>\n"
|
<< "<body>\n"
|
||||||
@ -162,7 +162,7 @@ private:
|
|||||||
{
|
{
|
||||||
response_.result(http::status::not_found);
|
response_.result(http::status::not_found);
|
||||||
response_.set(http::field::content_type, "text/plain");
|
response_.set(http::field::content_type, "text/plain");
|
||||||
boost::beast::ostream(response_.body) << "File not found\r\n";
|
boost::beast::ostream(response_.body()) << "File not found\r\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ private:
|
|||||||
{
|
{
|
||||||
auto self = shared_from_this();
|
auto self = shared_from_this();
|
||||||
|
|
||||||
response_.set(http::field::content_length, response_.body.size());
|
response_.set(http::field::content_length, response_.body().size());
|
||||||
|
|
||||||
http::async_write(
|
http::async_write(
|
||||||
socket_,
|
socket_,
|
||||||
|
@ -120,7 +120,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = why.to_string();
|
res.body() = why.to_string();
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
@ -133,7 +133,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = "The resource '" + target.to_string() + "' was not found.";
|
res.body() = "The resource '" + target.to_string() + "' was not found.";
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
@ -146,7 +146,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = "An error occurred: '" + what.to_string() + "'";
|
res.body() = "An error occurred: '" + what.to_string() + "'";
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
@ -116,7 +116,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = why.to_string();
|
res.body() = why.to_string();
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
@ -129,7 +129,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = "The resource '" + target.to_string() + "' was not found.";
|
res.body() = "The resource '" + target.to_string() + "' was not found.";
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
@ -142,7 +142,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = "An error occurred: '" + what.to_string() + "'";
|
res.body() = "An error occurred: '" + what.to_string() + "'";
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
@ -115,7 +115,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = why.to_string();
|
res.body() = why.to_string();
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
@ -128,7 +128,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = "The resource '" + target.to_string() + "' was not found.";
|
res.body() = "The resource '" + target.to_string() + "' was not found.";
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
@ -141,7 +141,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = "An error occurred: '" + what.to_string() + "'";
|
res.body() = "An error occurred: '" + what.to_string() + "'";
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
@ -113,7 +113,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = why.to_string();
|
res.body() = why.to_string();
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
@ -126,7 +126,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = "The resource '" + target.to_string() + "' was not found.";
|
res.body() = "The resource '" + target.to_string() + "' was not found.";
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
@ -139,7 +139,7 @@ handle_request(
|
|||||||
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());
|
||||||
res.body = "An error occurred: '" + what.to_string() + "'";
|
res.body() = "An error occurred: '" + what.to_string() + "'";
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
@ -19,31 +19,32 @@ namespace beast {
|
|||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
struct empty_base_optimization_decide
|
struct is_empty_base_optimization_derived
|
||||||
: std::integral_constant<bool,
|
: std::integral_constant<bool,
|
||||||
std::is_empty<T>::value &&
|
std::is_empty<T>::value &&
|
||||||
! boost::is_final<T>::value>
|
! boost::is_final<T>::value>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
template<
|
template<class T, int UniqueID = 0,
|
||||||
class T,
|
bool isDerived =
|
||||||
int UniqueID = 0,
|
is_empty_base_optimization_derived<T>::value>
|
||||||
bool ShouldDeriveFrom =
|
|
||||||
empty_base_optimization_decide<T>::value
|
|
||||||
>
|
|
||||||
class empty_base_optimization : private T
|
class empty_base_optimization : private T
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
empty_base_optimization() = default;
|
empty_base_optimization() = default;
|
||||||
|
empty_base_optimization(empty_base_optimization&&) = default;
|
||||||
|
empty_base_optimization(empty_base_optimization const&) = default;
|
||||||
|
empty_base_optimization& operator=(empty_base_optimization&&) = default;
|
||||||
|
empty_base_optimization& operator=(empty_base_optimization const&) = default;
|
||||||
|
|
||||||
empty_base_optimization(T const& t)
|
template<class Arg1, class... ArgN>
|
||||||
: T (t)
|
explicit
|
||||||
{}
|
empty_base_optimization(Arg1&& arg1, ArgN&&... argn)
|
||||||
|
: T(std::forward<Arg1>(arg1),
|
||||||
empty_base_optimization(T&& t)
|
std::forward<ArgN>(argn)...)
|
||||||
: T (std::move (t))
|
{
|
||||||
{}
|
}
|
||||||
|
|
||||||
T& member() noexcept
|
T& member() noexcept
|
||||||
{
|
{
|
||||||
@ -64,29 +65,32 @@ template<
|
|||||||
>
|
>
|
||||||
class empty_base_optimization <T, UniqueID, false>
|
class empty_base_optimization <T, UniqueID, false>
|
||||||
{
|
{
|
||||||
|
T t_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
empty_base_optimization() = default;
|
empty_base_optimization() = default;
|
||||||
|
empty_base_optimization(empty_base_optimization&&) = default;
|
||||||
|
empty_base_optimization(empty_base_optimization const&) = default;
|
||||||
|
empty_base_optimization& operator=(empty_base_optimization&&) = default;
|
||||||
|
empty_base_optimization& operator=(empty_base_optimization const&) = default;
|
||||||
|
|
||||||
empty_base_optimization(T const& t)
|
template<class Arg1, class... ArgN>
|
||||||
: m_t (t)
|
explicit
|
||||||
{}
|
empty_base_optimization(Arg1&& arg1, ArgN&&... argn)
|
||||||
|
: t_(std::forward<Arg1>(arg1),
|
||||||
empty_base_optimization(T&& t)
|
std::forward<ArgN>(argn)...)
|
||||||
: m_t (std::move (t))
|
{
|
||||||
{}
|
}
|
||||||
|
|
||||||
T& member() noexcept
|
T& member() noexcept
|
||||||
{
|
{
|
||||||
return m_t;
|
return t_;
|
||||||
}
|
}
|
||||||
|
|
||||||
T const& member() const noexcept
|
T const& member() const noexcept
|
||||||
{
|
{
|
||||||
return m_t;
|
return t_;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
T m_t;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // detail
|
} // detail
|
||||||
|
@ -74,7 +74,7 @@ struct basic_dynamic_body
|
|||||||
explicit
|
explicit
|
||||||
reader(message<isRequest,
|
reader(message<isRequest,
|
||||||
basic_dynamic_body, Fields> const& m)
|
basic_dynamic_body, Fields> const& m)
|
||||||
: body_(m.body)
|
: body_(m.body())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ struct basic_dynamic_body
|
|||||||
explicit
|
explicit
|
||||||
writer(message<isRequest,
|
writer(message<isRequest,
|
||||||
basic_dynamic_body, Fields>& msg)
|
basic_dynamic_body, Fields>& msg)
|
||||||
: body_(msg.body)
|
: body_(msg.body())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ template<bool isRequest, class Fields>
|
|||||||
basic_file_body<File>::
|
basic_file_body<File>::
|
||||||
reader::
|
reader::
|
||||||
reader(message<isRequest, basic_file_body, Fields>& m)
|
reader(message<isRequest, basic_file_body, Fields>& m)
|
||||||
: body_(m.body)
|
: body_(m.body())
|
||||||
{
|
{
|
||||||
// The file must already be open
|
// The file must already be open
|
||||||
BOOST_ASSERT(body_.file_.is_open());
|
BOOST_ASSERT(body_.file_.is_open());
|
||||||
@ -442,7 +442,7 @@ template<bool isRequest, class Fields>
|
|||||||
basic_file_body<File>::
|
basic_file_body<File>::
|
||||||
writer::
|
writer::
|
||||||
writer(message<isRequest, basic_file_body, Fields>& m)
|
writer(message<isRequest, basic_file_body, Fields>& m)
|
||||||
: body_(m.body)
|
: body_(m.body())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ struct buffer_body
|
|||||||
explicit
|
explicit
|
||||||
reader(message<isRequest,
|
reader(message<isRequest,
|
||||||
buffer_body, Fields> const& msg)
|
buffer_body, Fields> const& msg)
|
||||||
: body_(msg.body)
|
: body_(msg.body())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +169,7 @@ struct buffer_body
|
|||||||
template<bool isRequest, class Fields>
|
template<bool isRequest, class Fields>
|
||||||
explicit
|
explicit
|
||||||
writer(message<isRequest, buffer_body, Fields>& m)
|
writer(message<isRequest, buffer_body, Fields>& m)
|
||||||
: body_(m.body)
|
: body_(m.body())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ struct basic_file_body<file_win32>
|
|||||||
template<bool isRequest, class Fields>
|
template<bool isRequest, class Fields>
|
||||||
reader(message<isRequest,
|
reader(message<isRequest,
|
||||||
basic_file_body<file_win32>, Fields>& m)
|
basic_file_body<file_win32>, Fields>& m)
|
||||||
: body_(m.body)
|
: body_(m.body())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ struct basic_file_body<file_win32>
|
|||||||
template<bool isRequest, class Fields>
|
template<bool isRequest, class Fields>
|
||||||
explicit
|
explicit
|
||||||
writer(message<isRequest, basic_file_body, Fields>& m)
|
writer(message<isRequest, basic_file_body, Fields>& m)
|
||||||
: body_(m.body)
|
: body_(m.body())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -437,7 +437,7 @@ operator()()
|
|||||||
ov.OffsetHigh = highPart(r.pos_);
|
ov.OffsetHigh = highPart(r.pos_);
|
||||||
auto const bSuccess = ::TransmitFile(
|
auto const bSuccess = ::TransmitFile(
|
||||||
sock_.native_handle(),
|
sock_.native_handle(),
|
||||||
sr_.get().body.file_.native_handle(),
|
sr_.get().body().file_.native_handle(),
|
||||||
nNumberOfBytesToWrite,
|
nNumberOfBytesToWrite,
|
||||||
0,
|
0,
|
||||||
overlapped.get(),
|
overlapped.get(),
|
||||||
|
@ -209,7 +209,9 @@ template<class... BodyArgs>
|
|||||||
message<isRequest, Body, Fields>::
|
message<isRequest, Body, Fields>::
|
||||||
message(header_type&& h, BodyArgs&&... body_args)
|
message(header_type&& h, BodyArgs&&... body_args)
|
||||||
: header_type(std::move(h))
|
: header_type(std::move(h))
|
||||||
, body(std::forward<BodyArgs>(body_args)...)
|
, beast::detail::empty_base_optimization<
|
||||||
|
typename Body::value_type>(
|
||||||
|
std::forward<BodyArgs>(body_args)...)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +220,9 @@ template<class... BodyArgs>
|
|||||||
message<isRequest, Body, Fields>::
|
message<isRequest, Body, Fields>::
|
||||||
message(header_type const& h, BodyArgs&&... body_args)
|
message(header_type const& h, BodyArgs&&... body_args)
|
||||||
: header_type(h)
|
: header_type(h)
|
||||||
, body(std::forward<BodyArgs>(body_args)...)
|
, beast::detail::empty_base_optimization<
|
||||||
|
typename Body::value_type>(
|
||||||
|
std::forward<BodyArgs>(body_args)...)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,7 +240,9 @@ message<isRequest, Body, Fields>::
|
|||||||
message(verb method, string_view target,
|
message(verb method, string_view target,
|
||||||
Version version, BodyArg&& body_arg)
|
Version version, BodyArg&& body_arg)
|
||||||
: header_type(method, target, version)
|
: header_type(method, target, version)
|
||||||
, body(std::forward<BodyArg>(body_arg))
|
, beast::detail::empty_base_optimization<
|
||||||
|
typename Body::value_type>(
|
||||||
|
std::forward<BodyArg>(body_arg))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +255,9 @@ message(
|
|||||||
FieldsArg&& fields_arg)
|
FieldsArg&& fields_arg)
|
||||||
: header_type(method, target, version,
|
: header_type(method, target, version,
|
||||||
std::forward<FieldsArg>(fields_arg))
|
std::forward<FieldsArg>(fields_arg))
|
||||||
, body(std::forward<BodyArg>(body_arg))
|
, beast::detail::empty_base_optimization<
|
||||||
|
typename Body::value_type>(
|
||||||
|
std::forward<BodyArg>(body_arg))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,7 +275,9 @@ message<isRequest, Body, Fields>::
|
|||||||
message(status result, Version version,
|
message(status result, Version version,
|
||||||
BodyArg&& body_arg)
|
BodyArg&& body_arg)
|
||||||
: header_type(result, version)
|
: header_type(result, version)
|
||||||
, body(std::forward<BodyArg>(body_arg))
|
, beast::detail::empty_base_optimization<
|
||||||
|
typename Body::value_type>(
|
||||||
|
std::forward<BodyArg>(body_arg))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,7 +288,9 @@ message(status result, Version version,
|
|||||||
BodyArg&& body_arg, FieldsArg&& fields_arg)
|
BodyArg&& body_arg, FieldsArg&& fields_arg)
|
||||||
: header_type(result, version,
|
: header_type(result, version,
|
||||||
std::forward<FieldsArg>(fields_arg))
|
std::forward<FieldsArg>(fields_arg))
|
||||||
, body(std::forward<BodyArg>(body_arg))
|
, beast::detail::empty_base_optimization<
|
||||||
|
typename Body::value_type>(
|
||||||
|
std::forward<BodyArg>(body_arg))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,7 +421,7 @@ swap(
|
|||||||
swap(
|
swap(
|
||||||
static_cast<header<isRequest, Fields>&>(m1),
|
static_cast<header<isRequest, Fields>&>(m1),
|
||||||
static_cast<header<isRequest, Fields>&>(m2));
|
static_cast<header<isRequest, Fields>&>(m2));
|
||||||
swap(m1.body, m2.body);
|
swap(m1.body(), m2.body());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // http
|
} // http
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include <boost/beast/http/status.hpp>
|
#include <boost/beast/http/status.hpp>
|
||||||
#include <boost/beast/http/type_traits.hpp>
|
#include <boost/beast/http/type_traits.hpp>
|
||||||
#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/integer_sequence.hpp>
|
#include <boost/beast/core/detail/integer_sequence.hpp>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <boost/throw_exception.hpp>
|
#include <boost/throw_exception.hpp>
|
||||||
@ -391,6 +392,14 @@ using request_header = header<true, Fields>;
|
|||||||
template<class Fields = fields>
|
template<class Fields = fields>
|
||||||
using response_header = header<false, Fields>;
|
using response_header = header<false, Fields>;
|
||||||
|
|
||||||
|
#if defined(BOOST_MSVC)
|
||||||
|
// Workaround for MSVC bug with private base classes
|
||||||
|
namespace detail {
|
||||||
|
template<class T>
|
||||||
|
using value_type_t = typename T::value_type;
|
||||||
|
} // detail
|
||||||
|
#endif
|
||||||
|
|
||||||
/** A container for a complete HTTP message.
|
/** A container for a complete HTTP message.
|
||||||
|
|
||||||
This container is derived from the `Fields` template type.
|
This container is derived from the `Fields` template type.
|
||||||
@ -421,7 +430,12 @@ using response_header = header<false, Fields>;
|
|||||||
field value pairs.
|
field value pairs.
|
||||||
*/
|
*/
|
||||||
template<bool isRequest, class Body, class Fields = fields>
|
template<bool isRequest, class Body, class Fields = fields>
|
||||||
struct message : header<isRequest, Fields>
|
struct message
|
||||||
|
: header<isRequest, Fields>
|
||||||
|
#if ! BOOST_BEAST_DOXYGEN
|
||||||
|
, beast::detail::empty_base_optimization<
|
||||||
|
typename Body::value_type>
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
/// The base class used to hold the header portion of the message.
|
/// The base class used to hold the header portion of the message.
|
||||||
using header_type = header<isRequest, Fields>;
|
using header_type = header<isRequest, Fields>;
|
||||||
@ -432,9 +446,6 @@ struct message : header<isRequest, Fields>
|
|||||||
*/
|
*/
|
||||||
using body_type = Body;
|
using body_type = Body;
|
||||||
|
|
||||||
/// A value representing the body.
|
|
||||||
typename Body::value_type body;
|
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
message() = default;
|
message() = default;
|
||||||
|
|
||||||
@ -736,7 +747,7 @@ struct message : header<isRequest, Fields>
|
|||||||
@code
|
@code
|
||||||
request<string_body> req{verb::post, "/"};
|
request<string_body> req{verb::post, "/"};
|
||||||
req.set(field::user_agent, "Beast");
|
req.set(field::user_agent, "Beast");
|
||||||
req.body = "Hello, world!";
|
req.body() = "Hello, world!";
|
||||||
req.prepare_payload();
|
req.prepare_payload();
|
||||||
@endcode
|
@endcode
|
||||||
*/
|
*/
|
||||||
@ -746,6 +757,28 @@ struct message : header<isRequest, Fields>
|
|||||||
prepare_payload(typename header_type::is_request{});
|
prepare_payload(typename header_type::is_request{});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the body
|
||||||
|
#if BOOST_BEAST_DOXYGEN || ! defined(BOOST_MSVC)
|
||||||
|
typename body_type::value_type&
|
||||||
|
#else
|
||||||
|
detail::value_type_t<Body>&
|
||||||
|
#endif
|
||||||
|
body() noexcept
|
||||||
|
{
|
||||||
|
return this->member();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the body
|
||||||
|
#if BOOST_BEAST_DOXYGEN || ! defined(BOOST_MSVC)
|
||||||
|
typename body_type::value_type const&
|
||||||
|
#else
|
||||||
|
detail::value_type_t<Body> const&
|
||||||
|
#endif
|
||||||
|
body() const noexcept
|
||||||
|
{
|
||||||
|
return this->member();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static_assert(is_body<Body>::value,
|
static_assert(is_body<Body>::value,
|
||||||
"Body requirements not met");
|
"Body requirements not met");
|
||||||
@ -757,8 +790,10 @@ private:
|
|||||||
std::piecewise_construct_t,
|
std::piecewise_construct_t,
|
||||||
std::tuple<BodyArgs...>& body_args,
|
std::tuple<BodyArgs...>& body_args,
|
||||||
beast::detail::index_sequence<IBodyArgs...>)
|
beast::detail::index_sequence<IBodyArgs...>)
|
||||||
: body(std::forward<BodyArgs>(
|
: beast::detail::empty_base_optimization<
|
||||||
std::get<IBodyArgs>(body_args))...)
|
typename Body::value_type>(
|
||||||
|
std::forward<BodyArgs>(
|
||||||
|
std::get<IBodyArgs>(body_args))...)
|
||||||
{
|
{
|
||||||
boost::ignore_unused(body_args);
|
boost::ignore_unused(body_args);
|
||||||
}
|
}
|
||||||
@ -776,8 +811,10 @@ private:
|
|||||||
beast::detail::index_sequence<IFieldsArgs...>)
|
beast::detail::index_sequence<IFieldsArgs...>)
|
||||||
: header_type(std::forward<FieldsArgs>(
|
: header_type(std::forward<FieldsArgs>(
|
||||||
std::get<IFieldsArgs>(fields_args))...)
|
std::get<IFieldsArgs>(fields_args))...)
|
||||||
, body(std::forward<BodyArgs>(
|
, beast::detail::empty_base_optimization<
|
||||||
std::get<IBodyArgs>(body_args))...)
|
typename Body::value_type>(
|
||||||
|
std::forward<BodyArgs>(
|
||||||
|
std::get<IBodyArgs>(body_args))...)
|
||||||
{
|
{
|
||||||
boost::ignore_unused(body_args);
|
boost::ignore_unused(body_args);
|
||||||
boost::ignore_unused(fields_args);
|
boost::ignore_unused(fields_args);
|
||||||
@ -786,7 +823,7 @@ private:
|
|||||||
boost::optional<std::uint64_t>
|
boost::optional<std::uint64_t>
|
||||||
payload_size(std::true_type) const
|
payload_size(std::true_type) const
|
||||||
{
|
{
|
||||||
return Body::size(body);
|
return Body::size(this->body());
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::optional<std::uint64_t>
|
boost::optional<std::uint64_t>
|
||||||
|
@ -78,7 +78,7 @@ public:
|
|||||||
explicit
|
explicit
|
||||||
reader(message<isRequest,
|
reader(message<isRequest,
|
||||||
span_body, Fields> const& msg)
|
span_body, Fields> const& msg)
|
||||||
: body_(msg.body)
|
: body_(msg.body())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ public:
|
|||||||
explicit
|
explicit
|
||||||
writer(message<isRequest,
|
writer(message<isRequest,
|
||||||
span_body, Fields>& m)
|
span_body, Fields>& m)
|
||||||
: body_(m.body)
|
: body_(m.body())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ public:
|
|||||||
explicit
|
explicit
|
||||||
reader(message<isRequest,
|
reader(message<isRequest,
|
||||||
basic_string_body, Fields> const& msg)
|
basic_string_body, Fields> const& msg)
|
||||||
: body_(msg.body)
|
: body_(msg.body())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ public:
|
|||||||
explicit
|
explicit
|
||||||
writer(message<isRequest,
|
writer(message<isRequest,
|
||||||
basic_string_body, Fields>& m)
|
basic_string_body, Fields>& m)
|
||||||
: body_(m.body)
|
: body_(m.body())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ public:
|
|||||||
explicit
|
explicit
|
||||||
reader(message<isRequest,
|
reader(message<isRequest,
|
||||||
vector_body, Fields> const& msg)
|
vector_body, Fields> const& msg)
|
||||||
: body_(msg.body)
|
: body_(msg.body())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ public:
|
|||||||
explicit
|
explicit
|
||||||
writer(message<isRequest,
|
writer(message<isRequest,
|
||||||
vector_body, Fields>& m)
|
vector_body, Fields>& m)
|
||||||
: body_(m.body)
|
: body_(m.body())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -577,7 +577,7 @@ build_response(http::request<Body,
|
|||||||
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;
|
||||||
|
@ -66,7 +66,7 @@ public:
|
|||||||
multi_buffer b;
|
multi_buffer b;
|
||||||
read(ts, b, p);
|
read(ts, b, p);
|
||||||
auto const& m = p.get();
|
auto const& m = p.get();
|
||||||
BEAST_EXPECT(to_string(m.body.data()) == "xyz");
|
BEAST_EXPECT(to_string(m.body().data()) == "xyz");
|
||||||
BEAST_EXPECT(to_string(m) == s);
|
BEAST_EXPECT(to_string(m) == s);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -475,7 +475,7 @@ public:
|
|||||||
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;
|
||||||
|
|
||||||
req.prepare_payload();
|
req.prepare_payload();
|
||||||
BEAST_EXPECT(req[field::content_length] == "50");
|
BEAST_EXPECT(req[field::content_length] == "50");
|
||||||
@ -515,7 +515,7 @@ public:
|
|||||||
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;
|
||||||
|
|
||||||
req.prepare_payload();
|
req.prepare_payload();
|
||||||
BEAST_EXPECT(req[field::content_length] == "50");
|
BEAST_EXPECT(req[field::content_length] == "50");
|
||||||
@ -580,7 +580,7 @@ public:
|
|||||||
{
|
{
|
||||||
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();
|
||||||
BEAST_EXPECT(res[field::content_length] == "50");
|
BEAST_EXPECT(res[field::content_length] == "50");
|
||||||
|
@ -54,7 +54,7 @@ public:
|
|||||||
response_parser<basic_file_body<File>> p;
|
response_parser<basic_file_body<File>> p;
|
||||||
p.eager(true);
|
p.eager(true);
|
||||||
|
|
||||||
p.get().body.open(
|
p.get().body().open(
|
||||||
temp.string<std::string>().c_str(), file_mode::write, ec);
|
temp.string<std::string>().c_str(), file_mode::write, ec);
|
||||||
BEAST_EXPECTS(! ec, ec.message());
|
BEAST_EXPECTS(! ec, ec.message());
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ public:
|
|||||||
{
|
{
|
||||||
response<basic_file_body<File>> res{status::ok, 11};
|
response<basic_file_body<File>> res{status::ok, 11};
|
||||||
res.set(field::server, "test");
|
res.set(field::server, "test");
|
||||||
res.body.open(temp.string<std::string>().c_str(),
|
res.body().open(temp.string<std::string>().c_str(),
|
||||||
file_mode::scan, ec);
|
file_mode::scan, ec);
|
||||||
BEAST_EXPECTS(! ec, ec.message());
|
BEAST_EXPECTS(! ec, ec.message());
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
|
@ -156,17 +156,17 @@ public:
|
|||||||
request<string_body> m1;
|
request<string_body> m1;
|
||||||
request<string_body> m2;
|
request<string_body> m2;
|
||||||
m1.target("u");
|
m1.target("u");
|
||||||
m1.body = "1";
|
m1.body() = "1";
|
||||||
m1.insert("h", "v");
|
m1.insert("h", "v");
|
||||||
m2.method_string("G");
|
m2.method_string("G");
|
||||||
m2.body = "2";
|
m2.body() = "2";
|
||||||
swap(m1, m2);
|
swap(m1, m2);
|
||||||
BEAST_EXPECT(m1.method_string() == "G");
|
BEAST_EXPECT(m1.method_string() == "G");
|
||||||
BEAST_EXPECT(m2.method_string().empty());
|
BEAST_EXPECT(m2.method_string().empty());
|
||||||
BEAST_EXPECT(m1.target().empty());
|
BEAST_EXPECT(m1.target().empty());
|
||||||
BEAST_EXPECT(m2.target() == "u");
|
BEAST_EXPECT(m2.target() == "u");
|
||||||
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"));
|
||||||
BEAST_EXPECT(m2.count("h"));
|
BEAST_EXPECT(m2.count("h"));
|
||||||
}
|
}
|
||||||
@ -231,7 +231,7 @@ public:
|
|||||||
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");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
request<string_body, test_fields> req{
|
request<string_body, test_fields> req{
|
||||||
@ -239,7 +239,7 @@ public:
|
|||||||
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;
|
||||||
@ -258,7 +258,7 @@ public:
|
|||||||
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");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
response<string_body, test_fields> res{
|
response<string_body, test_fields> res{
|
||||||
@ -266,7 +266,7 @@ public:
|
|||||||
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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,10 +277,10 @@ public:
|
|||||||
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);
|
||||||
@ -291,8 +291,8 @@ public:
|
|||||||
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"));
|
||||||
BEAST_EXPECT(m2.count("h"));
|
BEAST_EXPECT(m2.count("h"));
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ public:
|
|||||||
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");
|
||||||
BEAST_EXPECT(m.body == "Hello, world!");
|
BEAST_EXPECT(m.body() == "Hello, world!");
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
doMatrix<false>(
|
doMatrix<false>(
|
||||||
@ -165,7 +165,7 @@ public:
|
|||||||
BEAST_EXPECT(m["Transfer-Encoding"] == "chunked");
|
BEAST_EXPECT(m["Transfer-Encoding"] == "chunked");
|
||||||
BEAST_EXPECT(m["Expires"] == "never");
|
BEAST_EXPECT(m["Expires"] == "never");
|
||||||
BEAST_EXPECT(m["MD5-Fingerprint"] == "-");
|
BEAST_EXPECT(m["MD5-Fingerprint"] == "-");
|
||||||
BEAST_EXPECT(m.body == "*****--");
|
BEAST_EXPECT(m.body() == "*****--");
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
doMatrix<false>(
|
doMatrix<false>(
|
||||||
@ -177,7 +177,7 @@ public:
|
|||||||
[&](parser_type<false> const& p)
|
[&](parser_type<false> const& p)
|
||||||
{
|
{
|
||||||
auto const& m = p.get();
|
auto const& m = p.get();
|
||||||
BEAST_EXPECT(m.body == "*****");
|
BEAST_EXPECT(m.body() == "*****");
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
doMatrix<true>(
|
doMatrix<true>(
|
||||||
@ -228,7 +228,7 @@ public:
|
|||||||
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() == "*");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// test partial parsing of final chunk
|
// test partial parsing of final chunk
|
||||||
@ -247,7 +247,7 @@ public:
|
|||||||
b.consume(used);
|
b.consume(used);
|
||||||
BEAST_EXPECT(! ec);
|
BEAST_EXPECT(! ec);
|
||||||
BEAST_EXPECT(! p.is_done());
|
BEAST_EXPECT(! p.is_done());
|
||||||
BEAST_EXPECT(p.get().body == "*");
|
BEAST_EXPECT(p.get().body() == "*");
|
||||||
ostream(b) <<
|
ostream(b) <<
|
||||||
"\r\n"
|
"\r\n"
|
||||||
"0;d;e=3;f=\"4\"\r\n"
|
"0;d;e=3;f=\"4\"\r\n"
|
||||||
|
@ -102,7 +102,7 @@ public:
|
|||||||
lambda visit;
|
lambda visit;
|
||||||
error_code ec;
|
error_code ec;
|
||||||
response<string_body> res;
|
response<string_body> res;
|
||||||
res.body.append(1000, '*');
|
res.body().append(1000, '*');
|
||||||
serializer<false, string_body> sr{res};
|
serializer<false, string_body> sr{res};
|
||||||
sr.limit(limit);
|
sr.limit(limit);
|
||||||
for(;;)
|
for(;;)
|
||||||
|
@ -27,12 +27,12 @@ struct span_body_test
|
|||||||
using B = span_body<char const>;
|
using B = span_body<char const>;
|
||||||
request<B> req;
|
request<B> req;
|
||||||
|
|
||||||
BEAST_EXPECT(req.body.size() == 0);
|
BEAST_EXPECT(req.body().size() == 0);
|
||||||
BEAST_EXPECT(B::size(req.body) == 0);
|
BEAST_EXPECT(B::size(req.body()) == 0);
|
||||||
|
|
||||||
req.body = B::value_type("xyz", 3);
|
req.body() = B::value_type("xyz", 3);
|
||||||
BEAST_EXPECT(req.body.size() == 3);
|
BEAST_EXPECT(req.body().size() == 3);
|
||||||
BEAST_EXPECT(B::size(req.body) == 3);
|
BEAST_EXPECT(B::size(req.body()) == 3);
|
||||||
|
|
||||||
B::reader r{req};
|
B::reader r{req};
|
||||||
error_code ec;
|
error_code ec;
|
||||||
@ -49,7 +49,7 @@ struct span_body_test
|
|||||||
char buf[5];
|
char buf[5];
|
||||||
using B = span_body<char>;
|
using B = span_body<char>;
|
||||||
request<B> req;
|
request<B> req;
|
||||||
req.body = span<char>{buf, sizeof(buf)};
|
req.body() = span<char>{buf, sizeof(buf)};
|
||||||
B::writer w{req};
|
B::writer w{req};
|
||||||
error_code ec;
|
error_code ec;
|
||||||
w.init(boost::none, ec);
|
w.init(boost::none, ec);
|
||||||
|
@ -50,7 +50,7 @@ public:
|
|||||||
explicit
|
explicit
|
||||||
reader(message<isRequest,
|
reader(message<isRequest,
|
||||||
unsized_body, Allocator> const& msg)
|
unsized_body, Allocator> const& msg)
|
||||||
: body_(msg.body)
|
: body_(msg.body())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ public:
|
|||||||
explicit
|
explicit
|
||||||
reader(message<isRequest,
|
reader(message<isRequest,
|
||||||
test_body, Fields> const& msg)
|
test_body, Fields> const& msg)
|
||||||
: body_(msg.body)
|
: body_(msg.body())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,7 +232,7 @@ public:
|
|||||||
explicit
|
explicit
|
||||||
reader(message<isRequest,
|
reader(message<isRequest,
|
||||||
fail_body, Allocator> const& msg)
|
fail_body, Allocator> const& msg)
|
||||||
: body_(msg.body)
|
: body_(msg.body())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ public:
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
read(ts, b, m);
|
read(ts, b, m);
|
||||||
return m.body == body;
|
return m.body() == body;
|
||||||
}
|
}
|
||||||
catch(std::exception const& e)
|
catch(std::exception const& e)
|
||||||
{
|
{
|
||||||
@ -323,7 +323,7 @@ public:
|
|||||||
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");
|
||||||
m.body = "*****";
|
m.body() = "*****";
|
||||||
error_code ec;
|
error_code ec;
|
||||||
test::stream ts{ios_}, tr{ios_};
|
test::stream ts{ios_}, tr{ios_};
|
||||||
ts.connect(tr);
|
ts.connect(tr);
|
||||||
@ -342,7 +342,7 @@ public:
|
|||||||
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");
|
||||||
m.body = "*****";
|
m.body() = "*****";
|
||||||
error_code ec;
|
error_code ec;
|
||||||
test::stream ts{ios_}, tr{ios_};
|
test::stream ts{ios_}, tr{ios_};
|
||||||
ts.connect(tr);
|
ts.connect(tr);
|
||||||
@ -374,7 +374,7 @@ public:
|
|||||||
m.set(field::user_agent, "test");
|
m.set(field::user_agent, "test");
|
||||||
m.set(field::connection, "keep-alive");
|
m.set(field::connection, "keep-alive");
|
||||||
m.set(field::content_length, "5");
|
m.set(field::content_length, "5");
|
||||||
m.body = "*****";
|
m.body() = "*****";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
write(ts, m);
|
write(ts, m);
|
||||||
@ -403,7 +403,7 @@ public:
|
|||||||
request<fail_body> m{verb::get, "/", 10, fc};
|
request<fail_body> m{verb::get, "/", 10, fc};
|
||||||
m.set(field::user_agent, "test");
|
m.set(field::user_agent, "test");
|
||||||
m.set(field::transfer_encoding, "chunked");
|
m.set(field::transfer_encoding, "chunked");
|
||||||
m.body = "*****";
|
m.body() = "*****";
|
||||||
error_code ec = test::error::fail_error;
|
error_code ec = test::error::fail_error;
|
||||||
write(ts, m, ec);
|
write(ts, m, ec);
|
||||||
if(ec == error::end_of_stream)
|
if(ec == error::end_of_stream)
|
||||||
@ -433,7 +433,7 @@ public:
|
|||||||
request<fail_body> m{verb::get, "/", 10, fc};
|
request<fail_body> m{verb::get, "/", 10, fc};
|
||||||
m.set(field::user_agent, "test");
|
m.set(field::user_agent, "test");
|
||||||
m.set(field::transfer_encoding, "chunked");
|
m.set(field::transfer_encoding, "chunked");
|
||||||
m.body = "*****";
|
m.body() = "*****";
|
||||||
error_code ec = test::error::fail_error;
|
error_code ec = test::error::fail_error;
|
||||||
async_write(ts, m, do_yield[ec]);
|
async_write(ts, m, do_yield[ec]);
|
||||||
if(ec == error::end_of_stream)
|
if(ec == error::end_of_stream)
|
||||||
@ -464,7 +464,7 @@ public:
|
|||||||
m.set(field::user_agent, "test");
|
m.set(field::user_agent, "test");
|
||||||
m.set(field::connection, "keep-alive");
|
m.set(field::connection, "keep-alive");
|
||||||
m.set(field::content_length, "5");
|
m.set(field::content_length, "5");
|
||||||
m.body = "*****";
|
m.body() = "*****";
|
||||||
error_code ec = test::error::fail_error;
|
error_code ec = test::error::fail_error;
|
||||||
write(ts, m, ec);
|
write(ts, m, ec);
|
||||||
if(! ec)
|
if(! ec)
|
||||||
@ -491,7 +491,7 @@ public:
|
|||||||
m.set(field::user_agent, "test");
|
m.set(field::user_agent, "test");
|
||||||
m.set(field::connection, "keep-alive");
|
m.set(field::connection, "keep-alive");
|
||||||
m.set(field::content_length, "5");
|
m.set(field::content_length, "5");
|
||||||
m.body = "*****";
|
m.body() = "*****";
|
||||||
error_code ec = test::error::fail_error;
|
error_code ec = test::error::fail_error;
|
||||||
async_write(ts, m, do_yield[ec]);
|
async_write(ts, m, do_yield[ec]);
|
||||||
if(! ec)
|
if(! ec)
|
||||||
@ -520,7 +520,7 @@ public:
|
|||||||
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();
|
||||||
BEAST_EXPECT(str(m) ==
|
BEAST_EXPECT(str(m) ==
|
||||||
"GET / HTTP/1.0\r\n"
|
"GET / HTTP/1.0\r\n"
|
||||||
@ -537,7 +537,7 @@ public:
|
|||||||
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();
|
||||||
test::stream ts{ios_}, tr{ios_};
|
test::stream ts{ios_}, tr{ios_};
|
||||||
ts.connect(tr);
|
ts.connect(tr);
|
||||||
@ -558,7 +558,7 @@ public:
|
|||||||
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();
|
||||||
BEAST_EXPECT(str(m) ==
|
BEAST_EXPECT(str(m) ==
|
||||||
"GET / HTTP/1.1\r\n"
|
"GET / HTTP/1.1\r\n"
|
||||||
@ -575,7 +575,7 @@ public:
|
|||||||
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();
|
||||||
test::stream ts{ios_}, tr{ios_};
|
test::stream ts{ios_}, tr{ios_};
|
||||||
ts.connect(tr);
|
ts.connect(tr);
|
||||||
@ -601,7 +601,7 @@ public:
|
|||||||
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) ==
|
||||||
"GET / HTTP/1.1\r\nUser-Agent: test\r\n\r\n*");
|
"GET / HTTP/1.1\r\nUser-Agent: test\r\n\r\n*");
|
||||||
}
|
}
|
||||||
@ -631,7 +631,7 @@ public:
|
|||||||
m.version = 11;
|
m.version = 11;
|
||||||
m.target("/");
|
m.target("/");
|
||||||
m.set("Content-Length", 5);
|
m.set("Content-Length", 5);
|
||||||
m.body = "*****";
|
m.body() = "*****";
|
||||||
async_write(ts, m, handler{});
|
async_write(ts, m, handler{});
|
||||||
BEAST_EXPECT(handler::count() > 0);
|
BEAST_EXPECT(handler::count() > 0);
|
||||||
ios.stop();
|
ios.stop();
|
||||||
@ -654,7 +654,7 @@ public:
|
|||||||
m.version = 11;
|
m.version = 11;
|
||||||
m.target("/");
|
m.target("/");
|
||||||
m.set("Content-Length", 5);
|
m.set("Content-Length", 5);
|
||||||
m.body = "*****";
|
m.body() = "*****";
|
||||||
async_write(ts, m, handler{});
|
async_write(ts, m, handler{});
|
||||||
BEAST_EXPECT(handler::count() > 0);
|
BEAST_EXPECT(handler::count() > 0);
|
||||||
}
|
}
|
||||||
@ -716,7 +716,7 @@ public:
|
|||||||
m0.result(status::ok);
|
m0.result(status::ok);
|
||||||
m0.reason("OK");
|
m0.reason("OK");
|
||||||
m0.set(field::server, "test");
|
m0.set(field::server, "test");
|
||||||
m0.body.s = "Hello, world!\n";
|
m0.body().s = "Hello, world!\n";
|
||||||
|
|
||||||
{
|
{
|
||||||
std::string const result =
|
std::string const result =
|
||||||
@ -730,7 +730,7 @@ public:
|
|||||||
do_write(ts, m, ec);
|
do_write(ts, m, ec);
|
||||||
BEAST_EXPECT(tr.str() == result);
|
BEAST_EXPECT(tr.str() == result);
|
||||||
BEAST_EXPECT(equal_body<false>(
|
BEAST_EXPECT(equal_body<false>(
|
||||||
tr.str(), m.body.s));
|
tr.str(), m.body().s));
|
||||||
tr.clear();
|
tr.clear();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@ -739,7 +739,7 @@ public:
|
|||||||
do_async_write(ts, m, ec, yield);
|
do_async_write(ts, m, ec, yield);
|
||||||
BEAST_EXPECT(tr.str() == result);
|
BEAST_EXPECT(tr.str() == result);
|
||||||
BEAST_EXPECT(equal_body<false>(
|
BEAST_EXPECT(equal_body<false>(
|
||||||
tr.str(), m.body.s));
|
tr.str(), m.body().s));
|
||||||
tr.clear();
|
tr.clear();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@ -753,7 +753,7 @@ public:
|
|||||||
if(sr.is_header_done())
|
if(sr.is_header_done())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
BEAST_EXPECT(! m.body.read);
|
BEAST_EXPECT(! m.body().read);
|
||||||
tr.clear();
|
tr.clear();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@ -767,7 +767,7 @@ public:
|
|||||||
if(sr.is_header_done())
|
if(sr.is_header_done())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
BEAST_EXPECT(! m.body.read);
|
BEAST_EXPECT(! m.body().read);
|
||||||
tr.clear();
|
tr.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -778,7 +778,7 @@ public:
|
|||||||
error_code ec;
|
error_code ec;
|
||||||
do_write(ts, m, ec);
|
do_write(ts, m, ec);
|
||||||
BEAST_EXPECT(equal_body<false>(
|
BEAST_EXPECT(equal_body<false>(
|
||||||
tr.str(), m.body.s));
|
tr.str(), m.body().s));
|
||||||
tr.clear();
|
tr.clear();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@ -786,7 +786,7 @@ public:
|
|||||||
error_code ec;
|
error_code ec;
|
||||||
do_async_write(ts, m, ec, yield);
|
do_async_write(ts, m, ec, yield);
|
||||||
BEAST_EXPECT(equal_body<false>(
|
BEAST_EXPECT(equal_body<false>(
|
||||||
tr.str(), m.body.s));
|
tr.str(), m.body().s));
|
||||||
tr.clear();
|
tr.clear();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@ -800,7 +800,7 @@ public:
|
|||||||
if(sr.is_header_done())
|
if(sr.is_header_done())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
BEAST_EXPECT(! m.body.read);
|
BEAST_EXPECT(! m.body().read);
|
||||||
tr.clear();
|
tr.clear();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@ -814,7 +814,7 @@ public:
|
|||||||
if(sr.is_header_done())
|
if(sr.is_header_done())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
BEAST_EXPECT(! m.body.read);
|
BEAST_EXPECT(! m.body().read);
|
||||||
tr.clear();
|
tr.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ public:
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
read(ts, b, m);
|
read(ts, b, m);
|
||||||
return m.body == body;
|
return m.body() == body;
|
||||||
}
|
}
|
||||||
catch(std::exception const& e)
|
catch(std::exception const& e)
|
||||||
{
|
{
|
||||||
@ -109,7 +109,7 @@ public:
|
|||||||
req.method_string("POST");
|
req.method_string("POST");
|
||||||
req.target("/");
|
req.target("/");
|
||||||
req.insert(field::user_agent, "test");
|
req.insert(field::user_agent, "test");
|
||||||
req.body = "Hello, world!";
|
req.body() = "Hello, world!";
|
||||||
req.prepare_payload();
|
req.prepare_payload();
|
||||||
|
|
||||||
error_code ec;
|
error_code ec;
|
||||||
@ -142,7 +142,7 @@ public:
|
|||||||
req.method_string("POST");
|
req.method_string("POST");
|
||||||
req.target("/");
|
req.target("/");
|
||||||
req.insert(field::user_agent, "test");
|
req.insert(field::user_agent, "test");
|
||||||
req.body = "Hello, world!";
|
req.body() = "Hello, world!";
|
||||||
req.prepare_payload();
|
req.prepare_payload();
|
||||||
|
|
||||||
test::stream ds{ios_}, dsr{ios_};
|
test::stream ds{ios_}, dsr{ios_};
|
||||||
@ -167,7 +167,7 @@ public:
|
|||||||
});
|
});
|
||||||
BEAST_EXPECTS(! ec, ec.message());
|
BEAST_EXPECTS(! ec, ec.message());
|
||||||
BEAST_EXPECT(equal_body<true>(
|
BEAST_EXPECT(equal_body<true>(
|
||||||
usr.str(), req.body));
|
usr.str(), req.body()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -273,7 +273,7 @@ public:
|
|||||||
void
|
void
|
||||||
operator()(request<string_body>&& req)
|
operator()(request<string_body>&& req)
|
||||||
{
|
{
|
||||||
body = req.body;
|
body = req.body();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ void fxx() {
|
|||||||
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!";
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
|
|
||||||
//]
|
//]
|
||||||
@ -115,7 +115,7 @@ void fxx() {
|
|||||||
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!";
|
||||||
|
|
||||||
error_code ec;
|
error_code ec;
|
||||||
write(sock, res, ec);
|
write(sock, res, ec);
|
||||||
|
Reference in New Issue
Block a user