@@ -120,6 +120,7 @@ def __init__(
120120 metrics_callback : MetricsCallback | None = None ,
121121 proxy : str | None = None ,
122122 retryable_status_codes : set [int ] | None = None ,
123+ max_redirects : int | None = None ,
123124 ):
124125 """
125126 Initialize the HTTP client.
@@ -141,6 +142,8 @@ def __init__(
141142 Supports http, https, and socks5 protocols.
142143 retryable_status_codes: HTTP status codes that trigger retry.
143144 If None, uses config value or DEFAULT_RETRYABLE_STATUS_CODES.
145+ max_redirects: Maximum number of redirects to follow.
146+ If None, uses config value (default 10).
144147 """
145148 config = get_config ().http
146149
@@ -171,6 +174,9 @@ def __init__(
171174 resolved_follow_redirects = (
172175 config .follow_redirects if follow_redirects is None else follow_redirects
173176 )
177+ resolved_max_redirects = (
178+ config .max_redirects if max_redirects is None else max_redirects
179+ )
174180
175181 resolved_proxy = proxy
176182 if resolved_proxy is None and config .proxy is not None :
@@ -206,6 +212,7 @@ def __init__(
206212 http2 = resolved_http2 ,
207213 verify = resolved_verify ,
208214 follow_redirects = resolved_follow_redirects ,
215+ max_redirects = resolved_max_redirects ,
209216 headers = default_headers ,
210217 proxy = resolved_proxy ,
211218 )
0 commit comments