-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Per-Request RedirectPolicy #353
Comments
How about a |
Is it not possible to inspect the |
No, I don't think so. |
What sort of information determines whether you can follow redirects? Can it be encoded in some other value that is shared into the closure of |
In my case: no. |
(what would you do if the redirect policy depended on the response body of the previous request?) |
If redirecting depended on the response body, then even a per-request policy wouldn't be able to handle that. |
you're right, bad argument, nvm. |
It'd probably be useful to also see some prior-art in other HTTP clients. I so far feel like this is also very niche, as it seems surprising that a server would sometimes return acceptable redirects and sometimes not. |
Hm. In python on the other hand you pass a boolean directly to the request function (probably because there isn't an instance of a client which could store such settings) You're probably right with the assumption that this usecase is not that common - even though I need it in the first project I use this library for. (; |
An other implication of the this is that a crate which wraps a rest api is required to always create its own Example:
would be impossible to implement safely. Instead, I would need to write
just to make sure that the client I use for the request has the right redirect policy. This doesn't only have implications on performance and simplicity, but also on testability |
I stumbled over this too. My use case is logging in to a site and retrieving the cookies. I think per-request redirect policy is pretty common in other clients. |
I'd just like to chime in and say that this is something I'd like to see as well. In my library, I sometimes send a |
@seanmonstar as far as prior art goes, there's very little in the way of this kind of fine grained support, but there is support for the concept of middleware in the Request -> Response chain. The concept of default headers is a Request -> Request middleware, and cookies is Request -> Request for writing Viewed this way, we've already taken the plunge into adding this kind of functionality, except in an ad-hoc manner. Given the existence of these existing hooks, I think that allowing |
When each request is a on behalf of a different "customer", different policies are required on a per-request basis (connection pooling only within a request, redirect policy, insecure TLS, root CAs, client certificates, DNS cache). |
I have a similar situation where I only don't want to follow redirects for specific requests: |
Since reusing
Client
s is a good idea it should be possible use aRedirectPolicy
only for a certain request. Right now, I need to create a newClient
for everyRedirectPolicy
which seems sub-optimal.The text was updated successfully, but these errors were encountered: