@@ -102,6 +102,7 @@ async def delete(
102102 timeout : float = None ,
103103 failOnStatusCode : bool = None ,
104104 ignoreHTTPSErrors : bool = None ,
105+ maxRedirects : int = None ,
105106 ) -> "APIResponse" :
106107 return await self .fetch (
107108 url ,
@@ -114,6 +115,7 @@ async def delete(
114115 timeout = timeout ,
115116 failOnStatusCode = failOnStatusCode ,
116117 ignoreHTTPSErrors = ignoreHTTPSErrors ,
118+ maxRedirects = maxRedirects ,
117119 )
118120
119121 async def head (
@@ -124,6 +126,7 @@ async def head(
124126 timeout : float = None ,
125127 failOnStatusCode : bool = None ,
126128 ignoreHTTPSErrors : bool = None ,
129+ maxRedirects : int = None ,
127130 ) -> "APIResponse" :
128131 return await self .fetch (
129132 url ,
@@ -133,6 +136,7 @@ async def head(
133136 timeout = timeout ,
134137 failOnStatusCode = failOnStatusCode ,
135138 ignoreHTTPSErrors = ignoreHTTPSErrors ,
139+ maxRedirects = maxRedirects ,
136140 )
137141
138142 async def get (
@@ -143,6 +147,7 @@ async def get(
143147 timeout : float = None ,
144148 failOnStatusCode : bool = None ,
145149 ignoreHTTPSErrors : bool = None ,
150+ maxRedirects : int = None ,
146151 ) -> "APIResponse" :
147152 return await self .fetch (
148153 url ,
@@ -152,6 +157,7 @@ async def get(
152157 timeout = timeout ,
153158 failOnStatusCode = failOnStatusCode ,
154159 ignoreHTTPSErrors = ignoreHTTPSErrors ,
160+ maxRedirects = maxRedirects ,
155161 )
156162
157163 async def patch (
@@ -165,6 +171,7 @@ async def patch(
165171 timeout : float = None ,
166172 failOnStatusCode : bool = None ,
167173 ignoreHTTPSErrors : bool = None ,
174+ maxRedirects : int = None ,
168175 ) -> "APIResponse" :
169176 return await self .fetch (
170177 url ,
@@ -177,6 +184,7 @@ async def patch(
177184 timeout = timeout ,
178185 failOnStatusCode = failOnStatusCode ,
179186 ignoreHTTPSErrors = ignoreHTTPSErrors ,
187+ maxRedirects = maxRedirects ,
180188 )
181189
182190 async def put (
@@ -190,6 +198,7 @@ async def put(
190198 timeout : float = None ,
191199 failOnStatusCode : bool = None ,
192200 ignoreHTTPSErrors : bool = None ,
201+ maxRedirects : int = None ,
193202 ) -> "APIResponse" :
194203 return await self .fetch (
195204 url ,
@@ -202,6 +211,7 @@ async def put(
202211 timeout = timeout ,
203212 failOnStatusCode = failOnStatusCode ,
204213 ignoreHTTPSErrors = ignoreHTTPSErrors ,
214+ maxRedirects = maxRedirects ,
205215 )
206216
207217 async def post (
@@ -215,6 +225,7 @@ async def post(
215225 timeout : float = None ,
216226 failOnStatusCode : bool = None ,
217227 ignoreHTTPSErrors : bool = None ,
228+ maxRedirects : int = None ,
218229 ) -> "APIResponse" :
219230 return await self .fetch (
220231 url ,
@@ -227,6 +238,7 @@ async def post(
227238 timeout = timeout ,
228239 failOnStatusCode = failOnStatusCode ,
229240 ignoreHTTPSErrors = ignoreHTTPSErrors ,
241+ maxRedirects = maxRedirects ,
230242 )
231243
232244 async def fetch (
@@ -241,6 +253,7 @@ async def fetch(
241253 timeout : float = None ,
242254 failOnStatusCode : bool = None ,
243255 ignoreHTTPSErrors : bool = None ,
256+ maxRedirects : int = None ,
244257 ) -> "APIResponse" :
245258 request = (
246259 cast (network .Request , to_impl (urlOrRequest ))
@@ -253,6 +266,9 @@ async def fetch(
253266 assert (
254267 (1 if data else 0 ) + (1 if form else 0 ) + (1 if multipart else 0 )
255268 ) <= 1 , "Only one of 'data', 'form' or 'multipart' can be specified"
269+ assert (
270+ maxRedirects is None or maxRedirects >= 0
271+ ), "'max_redirects' must be greater than or equal to '0'"
256272 url = request .url if request else urlOrRequest
257273 method = method or (request .method if request else "GET" )
258274 # Cannot call allHeaders() here as the request may be paused inside route handler.
@@ -319,6 +335,7 @@ def filter_none(input: Dict) -> Dict:
319335 "timeout" : timeout ,
320336 "failOnStatusCode" : failOnStatusCode ,
321337 "ignoreHTTPSErrors" : ignoreHTTPSErrors ,
338+ "maxRedirects" : maxRedirects ,
322339 }
323340 ),
324341 )
0 commit comments