mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
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:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user