mirror of
https://github.com/boostorg/beast.git
synced 2025-07-29 20:37:31 +02:00
Check trailers in test
This commit is contained in:
@ -4,6 +4,7 @@ Version 71:
|
||||
* Documentation revision
|
||||
* Fix spurious on_chunk invocation
|
||||
* Call prepare_payload in HTTP example
|
||||
* Check trailers in test
|
||||
|
||||
WebSockets:
|
||||
|
||||
|
@ -1099,7 +1099,7 @@ public:
|
||||
bufgrind<test_parser<false>>(
|
||||
"HTTP/1.1 200 OK\r\n"
|
||||
"Server: test\r\n"
|
||||
"Expect: Expires, MD5-Fingerprint\r\n"
|
||||
"Trailer: Expires, MD5-Fingerprint\r\n"
|
||||
"Transfer-Encoding: chunked\r\n"
|
||||
"\r\n"
|
||||
"5\r\n"
|
||||
@ -1110,9 +1110,11 @@ public:
|
||||
"Expires: never\r\n"
|
||||
"MD5-Fingerprint: -\r\n"
|
||||
"\r\n"
|
||||
,[&](test_parser<false> const& p)
|
||||
,[&](test_parser<false>& p)
|
||||
{
|
||||
BEAST_EXPECT(p.body == "*****--");
|
||||
BEAST_EXPECT(p.fields["Expires"] == "never");
|
||||
BEAST_EXPECT(p.fields["MD5-Fingerprint"] == "-");
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
#include <beast/http/basic_parser.hpp>
|
||||
#include <beast/test/fail_counter.hpp>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace beast {
|
||||
namespace http {
|
||||
@ -37,6 +39,8 @@ public:
|
||||
bool got_content_length = false;
|
||||
bool got_on_chunk = false;
|
||||
bool got_on_complete = false;
|
||||
std::unordered_map<
|
||||
std::string, std::string> fields;
|
||||
|
||||
test_parser() = default;
|
||||
|
||||
@ -79,14 +83,15 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
on_field(field, string_view,
|
||||
string_view, error_code& ec)
|
||||
on_field(field, string_view name,
|
||||
string_view value, error_code& ec)
|
||||
{
|
||||
got_on_field = true;
|
||||
if(fc_)
|
||||
fc_->fail(ec);
|
||||
else
|
||||
ec.assign(0, ec.category());
|
||||
fields[name.to_string()] = value.to_string();
|
||||
}
|
||||
|
||||
void
|
||||
|
Reference in New Issue
Block a user