seanmonstar / httparse

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

How to parse body from request or response? #16

Closed lily-mara closed 8 years ago

lily-mara commented 8 years ago

I'm not sure if this is the right place to ask this, but I'm looking through the documentation, and I don't see how I could use this library to get the body of a request or a response. Neither of the two structs have a field for body, and the parse method just gives back an index, is that the starting byte-index of where the body should begin?

seanmonstar commented 8 years ago

Yes. Really, it's the length of the "head". Everything after is the body, whose parsing is likely dependent on the headers, such as if it's chunked, gzipped, etc.

On Fri, Jun 10, 2016, 6:40 PM Nate Mara notifications@github.com wrote:

I'm not sure if this is the right place to ask this, but I'm looking through the documentation, and I don't see how I could use this library to get the body of a request or a response. Neither of the two structs have a field for body, and the parse method just gives back an index, is that the starting byte-index of where the body should begin?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/seanmonstar/httparse/issues/16, or mute the thread https://github.com/notifications/unsubscribe/AADJF09vq0ywi1qjP3yMMJ4AcHzZnNW5ks5qKZOPgaJpZM4IzH5X .

seeekr commented 5 years ago

Sorry to necro an old issue, but I think (hope) this fits here:

So is it correct then to say that this crate does not concern itself, and neither does it want to concern itself, with parsing the HTTP message body? I would be happy to add a little bit of documentation stating that clearly in the right places, seeing as this is one of the first results that come up when one would be looking for crates that parse http messages.

Is there an explanation for the lack of support for the http body? I could imagine that a primary use case for this library is handling HTTP/1.0 and 1.1 without chunked encoding, and so finding the body is basically trivial to implement?