Skip to content

Commit 4549d87

Browse files
abidlabsclaude
andauthored
Accept permanent redirects (301, 308) in networking.url_ok (#13514)
www.gradio.app now serves a 301 to gradio.app after the domain migration, which made url_ok return False and broke test_networking.py::TestURLs::test_url_ok. Co-authored-by: Claude Fable 5 <[email protected]>
1 parent a6141ee commit 4549d87

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎.changeset/shiny-llamas-wave.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"gradio": patch
3+
---
4+
5+
fix:Accept permanent redirects (301, 308) in `networking.url_ok`

‎gradio/networking.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ def url_ok(url: str) -> bool:
7474
warnings.filterwarnings("ignore")
7575
r = httpx.head(url, timeout=3, verify=False)
7676
if (
77-
r.status_code in (200, 401, 302, 303, 307)
78-
): # 401 or 302 if auth is set; 303 or 307 are alternatives to 302 for temporary redirects
77+
r.status_code in (200, 401, 301, 302, 303, 307, 308)
78+
): # 401 or 302 if auth is set; 303 or 307 are alternatives to 302 for temporary redirects; 301 and 308 are permanent redirects
7979
return True
8080
time.sleep(0.500)
8181
except (ConnectionError, httpx.ConnectError, httpx.TimeoutException):

0 commit comments

Comments
 (0)