hyperium / http

Rust HTTP types
Apache License 2.0
1.16k stars 292 forks source link

RFC: Add `parts_mut() -> &mut Parts` to allow mutate parts directly #712

Closed Xuanwo closed 3 months ago

Xuanwo commented 3 months ago

Hello, I plan to propose an RFC to add parts_mut() -> &mut Parts to enable direct mutation of Parts. We already have body_mut, headers_mut, etc., but we lack a function that allows us to simultaneously update headers, methods, and queries.

This change will will allos us to:

- let (mut parts, body) = req.into_parts();
- do_my_work(&mut parts);
- let req = Request::from_parts(parts, body);
+ do_my_work(req.parts_mut())
seanmonstar commented 3 months ago

This was brought up before: https://github.com/hyperium/http/issues/372#issuecomment-563548370 and the comments afterwards.