tomaka / rouille

Web framework in Rust
Apache License 2.0
1.12k stars 106 forks source link

Any way to use the body of a request twice? #187

Open droundy opened 6 years ago

droundy commented 6 years ago

I found it confusing that the body is consumed when it is accessed, which means that after a post_input! fails there is no way to see what the form input was, and if I access the form input before post_input!, then the latter fails.

I would love to just see the body stored in memory, or perhaps cached in memory, although I guess there exist massive posts that this would cause trouble for... but something more friendly would be lovely. I'd also like to be able to call post_input! twice on the same request.

jonas-schievink commented 5 years ago

This is especially annoying for me when trying to write a PATCH endpoint that can accept data in different formats. Ideally I'd like to be able to just try a bunch of post_input! calls in a row and accept the first one that matches the input.

Diggsey commented 4 years ago

Another motivation for this is to implement Digest header validation, which is required for HTTP request signing. It's necessary to be able to buffer the request body in memory and calculate its hash before handing it off to the actual request handler.