Add pause option to on_headers interface:

* on_headers returns enum body_what
* body_what::pause lets caller receive headers during the parse
This commit is contained in:
Vinnie Falco
2016-10-14 14:12:42 -04:00
parent c59bd53f48
commit d81234435f
10 changed files with 90 additions and 48 deletions
+8 -7
View File
@@ -899,21 +899,22 @@ write(boost::asio::const_buffer const& buffer, error_code& ec)
return err(parse_error::illegal_content_length);
upgrade_ = ((flags_ & (parse_flag::upgrade | parse_flag::connection_upgrade)) ==
(parse_flag::upgrade | parse_flag::connection_upgrade)) /*|| method == "connect"*/;
auto const maybe_skip = call_on_headers(ec);
auto const what = call_on_headers(ec);
if(ec)
return errc();
switch(maybe_skip)
switch(what)
{
case 0:
case body_what::normal:
break;
case 2:
case body_what::upgrade:
upgrade_ = true;
// fall through
case 1:
case body_what::skip:
flags_ |= parse_flag::skipbody;
break;
default:
return err(parse_error::bad_on_headers_rv);
case body_what::pause:
s_ = s_headers_done;
return used();
}
s_ = s_headers_done;
// fall through