mirror of
https://github.com/boostorg/beast.git
synced 2025-08-02 06:15:24 +02:00
basic_parser: set state_
before calling on_finish_impl
This commit is contained in:
committed by
Mohammad Nejati
parent
a620d4175a
commit
b1f377b2eb
@@ -172,13 +172,11 @@ loop:
|
|||||||
|
|
||||||
case state::trailer_fields:
|
case state::trailer_fields:
|
||||||
parse_fields(p, n, ec);
|
parse_fields(p, n, ec);
|
||||||
if(ec)
|
|
||||||
goto done;
|
|
||||||
this->on_finish_impl(ec);
|
|
||||||
if(ec)
|
if(ec)
|
||||||
goto done;
|
goto done;
|
||||||
state_ = state::complete;
|
state_ = state::complete;
|
||||||
break;
|
this->on_finish_impl(ec);
|
||||||
|
goto done;
|
||||||
|
|
||||||
case state::chunk_body:
|
case state::chunk_body:
|
||||||
parse_chunk_body(p, n, ec);
|
parse_chunk_body(p, n, ec);
|
||||||
@@ -221,11 +219,9 @@ put_eof(error_code& ec)
|
|||||||
ec = {};
|
ec = {};
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
state_ = state::complete;
|
||||||
ec = {};
|
ec = {};
|
||||||
this->on_finish_impl(ec);
|
this->on_finish_impl(ec);
|
||||||
if(ec)
|
|
||||||
return;
|
|
||||||
state_ = state::complete;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<bool isRequest>
|
template<bool isRequest>
|
||||||
@@ -464,11 +460,7 @@ finish_header(error_code& ec, std::true_type)
|
|||||||
if(ec)
|
if(ec)
|
||||||
return;
|
return;
|
||||||
if(state_ == state::complete)
|
if(state_ == state::complete)
|
||||||
{
|
|
||||||
this->on_finish_impl(ec);
|
this->on_finish_impl(ec);
|
||||||
if(ec)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<bool isRequest>
|
template<bool isRequest>
|
||||||
@@ -525,11 +517,7 @@ finish_header(error_code& ec, std::false_type)
|
|||||||
if(ec)
|
if(ec)
|
||||||
return;
|
return;
|
||||||
if(state_ == state::complete)
|
if(state_ == state::complete)
|
||||||
{
|
|
||||||
this->on_finish_impl(ec);
|
this->on_finish_impl(ec);
|
||||||
if(ec)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<bool isRequest>
|
template<bool isRequest>
|
||||||
@@ -547,10 +535,8 @@ parse_body(char const*& p,
|
|||||||
return;
|
return;
|
||||||
if(len_ > 0)
|
if(len_ > 0)
|
||||||
return;
|
return;
|
||||||
this->on_finish_impl(ec);
|
|
||||||
if(ec)
|
|
||||||
return;
|
|
||||||
state_ = state::complete;
|
state_ = state::complete;
|
||||||
|
this->on_finish_impl(ec);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<bool isRequest>
|
template<bool isRequest>
|
||||||
|
@@ -363,6 +363,18 @@ public:
|
|||||||
void
|
void
|
||||||
testCallbacks()
|
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>>(
|
parsegrind<test_parser<true>>(
|
||||||
"GET / HTTP/1.1\r\n"
|
"GET / HTTP/1.1\r\n"
|
||||||
"User-Agent: test\r\n"
|
"User-Agent: test\r\n"
|
||||||
@@ -378,6 +390,18 @@ public:
|
|||||||
BEAST_EXPECT(p.got_on_chunk == 0);
|
BEAST_EXPECT(p.got_on_chunk == 0);
|
||||||
BEAST_EXPECT(p.got_on_complete == 1);
|
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>>(
|
parsegrind<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"
|
||||||
|
Reference in New Issue
Block a user