Skip to content
Prev Previous commit
Next Next commit
[Download] Bound redirect following at httpx's default of 20
  • Loading branch information
hanouticelina committed Aug 25, 2026
commit 47e964f3fcb956e0ca4ce41f65731b199096ea35
4 changes: 3 additions & 1 deletion src/huggingface_hub/utils/_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ def _httpx_follow_hub_redirects_with_backoff(
{} if retry_on_errors else {"retry_on_exceptions": (), "retry_on_status_codes": ()}
)

while True:
for _ in range(20): # same bound as httpx's default max_redirects
response = http_backoff(
method=method,
url=url,
Expand All @@ -743,6 +743,8 @@ def _httpx_follow_hub_redirects_with_backoff(

url = target

raise httpx.TooManyRedirects(f"Exceeded 20 redirects while resolving '{url}'.")


def _is_same_or_hub_host(url: str, target: str) -> bool:
"""Whether `target` is served by the same host as `url`, or by a known Hub host."""
Expand Down
Loading