feat: Add request level redirect policy config
This PR is part of https://github.com/seanmonstar/reqwest/issues/2641, and will close https://github.com/seanmonstar/reqwest/pull/2440 and https://github.com/seanmonstar/reqwest/issues/353, maybe relate to https://github.com/seanmonstar/reqwest/pull/2617
- close https://github.com/seanmonstar/reqwest/pull/2440
- close https://github.com/seanmonstar/reqwest/issues/353
This PR has the following changes:
- Change
PolicyKind::CustomfromBoxtoArcto make itClone. That's required by inserting intohttp::Extensions - Introduce
config::RedirectPolicy - Add public API
Request::redirectandRequest::redirect_mut
There are some chore changes (I'm open to move them to a seperate PR)
- Change all usage of config from
Xxxtoconfig::Xxxto make it more clear. - Move
Request::versionto front for better API organization.
Just noting that this might conflict with #2576 that someone else is actively working on.
Just noting that this might conflict with #2576 that someone else is actively working on.
Thank you for your note.
My motivation for choosing to work on redirect::Policy is that it's a complex struct rather than a simple Duration. By using this struct, I can evaluate whether my previous configuration design is effective.
Another reason is that this is a feature request that others have also asked for. If we can merge this first, it will help us address those related issues.
I'm fine to begin this work once https://github.com/seanmonstar/reqwest/issues/2576 has been resolved if you prefer. It's clear that if https://github.com/seanmonstar/reqwest/pull/2617 is merged as it currently stands, incorporating it at the request level could become more complicated.
@Xuanwo Do you have any new ideas for integrating https://github.com/seanmonstar/reqwest/pull/2617? HyperClient and RedirectPolicy are wrapped into FollowRedirect. If RedirectPolicy is set at the request level, it means that the FollowRedirect wrapper needs to be recreated every time
@Xuanwo Do you have any new ideas for integrating #2617? HyperClient and RedirectPolicy are wrapped into FollowRedirect. If RedirectPolicy is set at the request level, it means that the FollowRedirect wrapper needs to be recreated every time
I'll take another look when I have some time. However, since the wrapper itself doesn't add much overhead, it may be acceptable to recreate it each time.