seanmonstar / httparse

A push parser for the HTTP 1.x protocol in Rust.
https://docs.rs/httparse
Apache License 2.0
584 stars 114 forks source link

Test and fix a regression in parsing partial requests in the 1.9.x series #176

Closed bearcage closed 3 months ago

bearcage commented 3 months ago

A regression was introduced in this bit of the SWAR changeset which manifests as incorrectly classifying a read() with the contents GET as a token error (because there's no characters yet to parse for the path part) rather than as an Ok(Status::Partial).

This diff is three independent commits to:

  1. Add specific regression tests covering this and similar situations
  2. Add a general regression test checking all permutations of a partial one-line request
  3. Fix the behavior of the parse_uri() function to disambiguate between an empty path followed by a space, versus a partial read that ends at the start of the path.

NB. This'll conflict with #175 — not in a material way, they'll work fine together, just a note.