seanmonstar / reqwest

An easy and powerful Rust HTTP Client
https://docs.rs/reqwest
Apache License 2.0
9.91k stars 1.12k forks source link

Redirect response history #2314

Open wolfv opened 5 months ago

wolfv commented 5 months ago

The Python requests library has a "redirect history" feature. That can be useful to get access to previous headers, or other response data that was sent along with a 30x status code. Here are the Python docs: https://requests.readthedocs.io/en/latest/user/quickstart/#redirection-and-history

Would you be open such a feature in reqwest?

Thanks for this wonderful library, by the way!

ovnicraft commented 5 months ago

I think reqwest already supported it, ref: https://docs.rs/reqwest/latest/reqwest/redirect/struct.Policy.html You can check redirect tests https://github.com/seanmonstar/reqwest/blob/master/src/redirect.rs#L259

seanmonstar commented 4 months ago

It seems like it wouldn't be too hard to add. It it worth the additional storage?

wolfv commented 4 months ago

Maybe it's something that could be enabled / disabled on the client or request level? I think the storage cost is negligible for 99% of 30x redirects (just a few headers, maybe a bit of content).