basic_parser: set state_ before calling on_finish_impl

This commit is contained in:
Mohammad Nejati
2024-08-20 17:47:03 +00:00
committed by Mohammad Nejati
parent a620d4175a
commit b1f377b2eb
2 changed files with 28 additions and 18 deletions

View File

@@ -363,6 +363,18 @@ public:
void
testCallbacks()
{
parsegrind<test_parser<true>>(
"GET / HTTP/1.1\r\n"
"\r\n",
[&](test_parser<true> const& p)
{
BEAST_EXPECT(p.got_on_begin == 1);
BEAST_EXPECT(p.got_on_field == 0);
BEAST_EXPECT(p.got_on_header == 1);
BEAST_EXPECT(p.got_on_body == 0);
BEAST_EXPECT(p.got_on_chunk == 0);
BEAST_EXPECT(p.got_on_complete == 1);
});
parsegrind<test_parser<true>>(
"GET / HTTP/1.1\r\n"
"User-Agent: test\r\n"
@@ -378,6 +390,18 @@ public:
BEAST_EXPECT(p.got_on_chunk == 0);
BEAST_EXPECT(p.got_on_complete == 1);
});
parsegrind<test_parser<false>>(
"HTTP/1.1 100 Continue\r\n"
"\r\n",
[&](test_parser<false> const& p)
{
BEAST_EXPECT(p.got_on_begin == 1);
BEAST_EXPECT(p.got_on_field == 0);
BEAST_EXPECT(p.got_on_header == 1);
BEAST_EXPECT(p.got_on_body == 0);
BEAST_EXPECT(p.got_on_chunk == 0);
BEAST_EXPECT(p.got_on_complete == 1);
});
parsegrind<test_parser<false>>(
"HTTP/1.1 200 OK\r\n"
"Server: test\r\n"