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 9e4c4ad8e5
commit 14b439ce43
4 changed files with 63 additions and 26 deletions

View File

@@ -20,6 +20,7 @@
#include <beast/http/message.h>
#include <beast/http/parser.h>
#include <beast/unit_test/suite.h>
#include <utility>
namespace beast {
namespace http {
@@ -31,7 +32,8 @@ public:
request (std::string const& text)
{
message m;
parser p (m, true);
body b;
parser p (m, b, true);
auto result (p.write (boost::asio::buffer(text)));
p.write_eof();
return std::make_pair (std::move(m), result.first);
@@ -65,7 +67,8 @@ public:
"\r\n"
;
message m;
parser p (m, true);
body b;
parser p (m, b, true);
auto result (p.write (boost::asio::buffer(text)));
expect (! result.first);
auto result2 (p.write_eof());
@@ -80,7 +83,8 @@ public:
"\r\n"
;
message m;
parser p (m, true);
body b;
parser p (m, b, true);
auto result = p.write (boost::asio::buffer(text));
if (expect (result.first))
expect (result.first.message() == "invalid HTTP method");