Separate beast::http::body from beast::http::message (RIPD-660):

This changes the http::message object to no longer contain a body. It modifies
the parser to store the body in a separate object, or to pass the body data
to a functor. This allows the body to be stored in more flexible ways. For
example, in HTTP responses the body can be generated procedurally instead
of being required to exist entirely in memory at once.
This commit is contained in:
Vinnie Falco
2014-10-29 13:22:57 -07:00
parent c1a5e88752
commit acaa1098f7
10 changed files with 92 additions and 37 deletions

View File

@@ -413,7 +413,9 @@ PeerImp::on_write_http_request (error_code ec, std::size_t bytes_transferred)
{
// done sending request, now read the response
http_message_ = boost::in_place ();
http_parser_ = boost::in_place (std::ref(*http_message_), false);
http_body_.clear();
http_parser_ = boost::in_place (std::ref(*http_message_),
std::ref(http_body_), false);
on_read_http_response (error_code(), 0);
return;
}
@@ -559,7 +561,9 @@ PeerImp::on_read_http_detect (error_code ec, std::size_t bytes_transferred)
else if (! is_peer_protocol)
{
http_message_ = boost::in_place ();
http_parser_ = boost::in_place (std::ref(*http_message_), true);
http_body_.clear();
http_parser_ = boost::in_place (std::ref(*http_message_),
std::ref(http_body_), true);
on_read_http_request (error_code(), 0);
return;
}