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

Add an option to get the body out of request #66

Closed bmuddha closed 4 years ago

bmuddha commented 4 years ago

It would be nice, if one could (at least had an option to) get the body of request, while parsing. Body of HTTP request is a byte sequence anyway, so it just could be stored in Request struct as &[u8], and further manipulation could be left to the user.

maxuuell commented 4 years ago

I second this. Maybe I am missing something, but I don't see how to actually get the body from my request, parse it, and add it to the Request struct. Is there a way to do this?

seanmonstar commented 4 years ago

Exactly what constitutes the body depends on a few things, like if it is HTTP/1.0 or 1.1, if it is a request or response, and the existence of certain headers. Determining those things is out of scope of simply parsing headers, which this crate does.