Replies: 1 comment
-
|
Also, I already implemented a workaround of some kind, detecting that I was given IP address and forcing def __init__(self, url: str ...):
_url = httpx.URL(url)
# avoid https 302 redirect issue on POST requests and SSL verification failed
if is_ip_v4(_url.host):
self.client = httpx.Client(
base_url=_url.copy_with(scheme="https"), verify=False
)
else:
self.client = httpx.Client(base_url=url)But the question still more about --post302 flag, since I think it can still be useful in cases when you can't really "predict" this kind of redirects. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
A little context first. So, I am trying to write some kind of CLI for Fastpanel that will "login" using url, username and password, and then be able to perform api requests to its backend.
Fastpanel can be deployed with actual domain name and url can look "normal": https://example.com, but some deployments may just use public IP address and I want my CLI support them as well. So the issue I encountered is that when I'm making POST request to
http://ip_address:8888/loginI guess due to some nginx config server responds with 302 Redirect tohttps://ip_address:8888/login, and in this case standard httpx behavior after 302 Redirect response is to change request method to a new location from POST to GET. As I said, this is standard behavior for 302, but it also breaks login, since request body will not be sent in GET request.Searching on how I can avoid changing the request method I found that curl had an option
--post302that does exactly what I need in this case:So yeah, is there a way to achieve similar behavior with httpx?
P.S. I do understand that sending unencrypted credentials over http is not very good idea. Also, I do understand that this is not "standard behavior." And still I am writing CLI that suppose "just work" if it can and print a warning, but not print the error message for user like "go and make your service standard compliant and safe to use, and only then come back" ahah. I mean, it's kinda reasonable at least for testing reasons when you don't really want to buy a domain name and configure SSL just to test a couple of things.
Beta Was this translation helpful? Give feedback.
All reactions