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