I was trying the http parser, and I'm getting into some weird issues that have no explanation in the documentation. Apparently you are supposed to reset the parser after it is first constructed, otherwise start() will throw, because the parser is constructed with state_ set to state::reset not state::start see:
impl(std::shared_ptr<parser_config_impl const> cfg, detail::kind k)
: cfg_(std::move(cfg))
, ws_(cfg_->space_needed)
, m_(ws_.data(), ws_.size())
, state_(state::reset)
, got_header_(false)
{
m_.h_ = detail::header(detail::empty{ k });
}
This is either a bug with the docs, or with the implementation, having to call reset on a newly constructed parser makes no sense. The only documentation for reset is "Prepare for a new stream" but it would be logical to assume a newly constructed parser is ready to accept a new stream. From an initial look I don't see a reason for this, maybe somewhere in the workspace actually needed work is being done, otherwise it seems like only the state enum is changed.
Also this might just be me not understaning what is meant by stream, but since reset must be called each time before start I don't really understand why these are not one function. And maybe there is being excess work done.
I was trying the http parser, and I'm getting into some weird issues that have no explanation in the documentation. Apparently you are supposed to reset the parser after it is first constructed, otherwise start() will throw, because the parser is constructed with state_ set to state::reset not state::start see:
This is either a bug with the docs, or with the implementation, having to call reset on a newly constructed parser makes no sense. The only documentation for reset is "Prepare for a new stream" but it would be logical to assume a newly constructed parser is ready to accept a new stream. From an initial look I don't see a reason for this, maybe somewhere in the workspace actually needed work is being done, otherwise it seems like only the state enum is changed.
Also this might just be me not understaning what is meant by stream, but since reset must be called each time before start I don't really understand why these are not one function. And maybe there is being excess work done.