Reconsidering auto-redirects? #1785
Replies: 6 comments 2 replies
-
I'm not an expert in this, but you've convinced me :) |
Beta Was this translation helpful? Give feedback.
-
I always forget that both |
Beta Was this translation helpful? Give feedback.
-
I personally prefer |
Beta Was this translation helpful? Give feedback.
-
Yes, following redirects by default will also make debugging difficult. I always set |
Beta Was this translation helpful? Give feedback.
-
Came here from Twitter where the conversation mentioned that following redirects in production makes sense, but during development you might want to know about it. What about adding something like a (Could also be styled something like |
Beta Was this translation helpful? Give feedback.
-
+1 to |
Beta Was this translation helpful? Give feedback.
-
Prompted way back by this thread... https://twitter.com/EWDurbin/status/1315581317627744257
It hadn't ever really significantly occurred to me before that auto-redirects might not be such a wonderful default, but actually there's some pretty good reasons we might want to diverge from requests here.
Auto-redirect by default can easily mean your codebase is needlessly having to send multiple requests over and over. This means your client code will be far slower than it needs to be, and the server side is working much harder than it needs.
We could perfectly well choose to diverge from requests here, and opt out from auto-redirects, except if they're explicitly enabled. Either per-request, or at the client level...
I actually think it'd be a decent feature to be able to promote "doesn't implicitly hide the fact that it might make multiple requests, unless you actually ask it too".
One other consideration here from my point of view is that I'd very much like to add a command line client as part of HTTPX at some point. Being able to seamlessly switch between HTTPX on the consol, and HTTPX in your codebase would be a fantastic feature for us. Other HTTP command line clients (curl, httpie) don't follow redirects by default, and I don't particularly think it'd make sense for an
httpx
command line client to do so either. We really want the behaviour between the console and client library cases to match up neatly.Beta Was this translation helpful? Give feedback.
All reactions