seanmonstar / httparse

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

A way to ignore headers completely #63

Closed Fedcomp closed 4 years ago

Fedcomp commented 4 years ago

For my purpose i need to completely ignore headers, i am only interested in request method and path.

Is there a way to ignore TooManyHeaders error and get all other request data?

seanmonstar commented 4 years ago

Yes, of course. I've done it this way before: create a Request with a 0-length headers slice, call req.parse(data), and then match on the result. If you got an Err(TooManyHeaders), you know it parsed the method, path, and version. Those fields will be set to Some.

Fedcomp commented 4 years ago

Oh sorry! i did the same but forgot i could still access the request. I am sorry.