Repository navigation
httpx equivalent of curl's "--location-trusted" #3083
Replies: 2 comments
|
There isn’t a I verified those three cases on HTTPX 0.28.1 with a mock transport. If you control the routing, point |
|
By default, HTTPX follows RFC 7235 and strips the If you specifically need curl's import httpx
def trust_redirect_auth(request: httpx.Request) -> None:
# If a redirect happened and Authorization was stripped, re-inject it
if "Authorization" not in request.headers:
request.headers["Authorization"] = "Bearer your_token_here"
with httpx.Client(event_hooks={"request": [trust_redirect_auth]}, follow_redirects=True) as client:
resp = client.get("https://initial-domain.com/login")Alternatively, if you are using custom auth, subclass |
Uh oh!
There was an error while loading. Please reload this page.
I'm trying to use the new OpenAI python package. My environment is setup in such a way that there are redirects involved. So I'm following the suggestion to specifically manage the http client:
openai/openai-python#785 (comment)
This is working, except that the my authentication header isn't getting to the endpoint and I'm getting a permission denied.
But as soon as I add the
--location-trustedflag, it's working.Does HTTPX have an equivalent of this?
I did try passing along the headers:
All reactions