Fix Correctly follow same-domain redirects
This commit is contained in:
parent
572548716a
commit
f44dbeec01
1 changed files with 4 additions and 2 deletions
|
@ -243,10 +243,12 @@ def preview_url(
|
||||||
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0"
|
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0"
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
response.raise_for_status()
|
if response.status_code not in range(200, 400):
|
||||||
|
response.raise_for_status()
|
||||||
while response.next_request and response.next_request.url.host == response.url.host:
|
while response.next_request and response.next_request.url.host == response.url.host:
|
||||||
response = client.send(response.next_request)
|
response = client.send(response.next_request)
|
||||||
response.raise_for_status()
|
if response.status_code not in range(200, 400):
|
||||||
|
response.raise_for_status()
|
||||||
except httpx.HTTPError as e:
|
except httpx.HTTPError as e:
|
||||||
raise HTTPException(500, f"Failed to fetch URL: {e!r}")
|
raise HTTPException(500, f"Failed to fetch URL: {e!r}")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue