Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
With the new changes, the parser returns immediately after the header is parsed and does not begin parsing the body until the next call to `parse()`. In the case of bodiless messages and head responses, it directly transitions to the `complete_in_place` state after the header is parsed, making a call to `parse()` unnecessary (but still valid). This two-phase parsing brings a few benefits with almost no complications on the usage side of the API: - It introduces an optimization opportunity for users who want to attach a body. If they do so immediately after the header is parsed (which seems to be the case most of the time), there's no need for `cb1_` for elastic bodies and a small `cb1_` for sink bodies (as it will be used temporarily). This means all the extra space can be utilized for `cb0_`. - Because parsing the body might complete with an error, returning after the header is parsed allows users to access the header and on the next call to parse encounter the error. - Setting the body limit in the middle of parsing the body or after it doesn't make much sense, so returning right after the header is parsed provides a window for setting such limits. - If users want to attach a body, they will almost always do so immediately after the header is parsed. By not continuing the parsing of the body, we avoid the need for an extra buffer copy operation (in case the user wants to attach a buffer).
- Loading branch information