@@ -102,6 +102,7 @@ async def delete(
102
102
timeout : float = None ,
103
103
failOnStatusCode : bool = None ,
104
104
ignoreHTTPSErrors : bool = None ,
105
+ maxRedirects : int = None ,
105
106
) -> "APIResponse" :
106
107
return await self .fetch (
107
108
url ,
@@ -114,6 +115,7 @@ async def delete(
114
115
timeout = timeout ,
115
116
failOnStatusCode = failOnStatusCode ,
116
117
ignoreHTTPSErrors = ignoreHTTPSErrors ,
118
+ maxRedirects = maxRedirects ,
117
119
)
118
120
119
121
async def head (
@@ -124,6 +126,7 @@ async def head(
124
126
timeout : float = None ,
125
127
failOnStatusCode : bool = None ,
126
128
ignoreHTTPSErrors : bool = None ,
129
+ maxRedirects : int = None ,
127
130
) -> "APIResponse" :
128
131
return await self .fetch (
129
132
url ,
@@ -133,6 +136,7 @@ async def head(
133
136
timeout = timeout ,
134
137
failOnStatusCode = failOnStatusCode ,
135
138
ignoreHTTPSErrors = ignoreHTTPSErrors ,
139
+ maxRedirects = maxRedirects ,
136
140
)
137
141
138
142
async def get (
@@ -143,6 +147,7 @@ async def get(
143
147
timeout : float = None ,
144
148
failOnStatusCode : bool = None ,
145
149
ignoreHTTPSErrors : bool = None ,
150
+ maxRedirects : int = None ,
146
151
) -> "APIResponse" :
147
152
return await self .fetch (
148
153
url ,
@@ -152,6 +157,7 @@ async def get(
152
157
timeout = timeout ,
153
158
failOnStatusCode = failOnStatusCode ,
154
159
ignoreHTTPSErrors = ignoreHTTPSErrors ,
160
+ maxRedirects = maxRedirects ,
155
161
)
156
162
157
163
async def patch (
@@ -165,6 +171,7 @@ async def patch(
165
171
timeout : float = None ,
166
172
failOnStatusCode : bool = None ,
167
173
ignoreHTTPSErrors : bool = None ,
174
+ maxRedirects : int = None ,
168
175
) -> "APIResponse" :
169
176
return await self .fetch (
170
177
url ,
@@ -177,6 +184,7 @@ async def patch(
177
184
timeout = timeout ,
178
185
failOnStatusCode = failOnStatusCode ,
179
186
ignoreHTTPSErrors = ignoreHTTPSErrors ,
187
+ maxRedirects = maxRedirects ,
180
188
)
181
189
182
190
async def put (
@@ -190,6 +198,7 @@ async def put(
190
198
timeout : float = None ,
191
199
failOnStatusCode : bool = None ,
192
200
ignoreHTTPSErrors : bool = None ,
201
+ maxRedirects : int = None ,
193
202
) -> "APIResponse" :
194
203
return await self .fetch (
195
204
url ,
@@ -202,6 +211,7 @@ async def put(
202
211
timeout = timeout ,
203
212
failOnStatusCode = failOnStatusCode ,
204
213
ignoreHTTPSErrors = ignoreHTTPSErrors ,
214
+ maxRedirects = maxRedirects ,
205
215
)
206
216
207
217
async def post (
@@ -215,6 +225,7 @@ async def post(
215
225
timeout : float = None ,
216
226
failOnStatusCode : bool = None ,
217
227
ignoreHTTPSErrors : bool = None ,
228
+ maxRedirects : int = None ,
218
229
) -> "APIResponse" :
219
230
return await self .fetch (
220
231
url ,
@@ -227,6 +238,7 @@ async def post(
227
238
timeout = timeout ,
228
239
failOnStatusCode = failOnStatusCode ,
229
240
ignoreHTTPSErrors = ignoreHTTPSErrors ,
241
+ maxRedirects = maxRedirects ,
230
242
)
231
243
232
244
async def fetch (
@@ -241,6 +253,7 @@ async def fetch(
241
253
timeout : float = None ,
242
254
failOnStatusCode : bool = None ,
243
255
ignoreHTTPSErrors : bool = None ,
256
+ maxRedirects : int = None ,
244
257
) -> "APIResponse" :
245
258
request = (
246
259
cast (network .Request , to_impl (urlOrRequest ))
@@ -253,6 +266,9 @@ async def fetch(
253
266
assert (
254
267
(1 if data else 0 ) + (1 if form else 0 ) + (1 if multipart else 0 )
255
268
) <= 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'"
256
272
url = request .url if request else urlOrRequest
257
273
method = method or (request .method if request else "GET" )
258
274
# Cannot call allHeaders() here as the request may be paused inside route handler.
@@ -319,6 +335,7 @@ def filter_none(input: Dict) -> Dict:
319
335
"timeout" : timeout ,
320
336
"failOnStatusCode" : failOnStatusCode ,
321
337
"ignoreHTTPSErrors" : ignoreHTTPSErrors ,
338
+ "maxRedirects" : maxRedirects ,
322
339
}
323
340
),
324
341
)
0 commit comments