Skip to content
Myr

client.py

This file

Path

httpcore/client.py

763 lines · 21.2 KiB · Python

Last changed by

Add json interfacesTom Christiebefore adoption5a63d31

History of this file

Take it

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 1why, one step back
1import asyncio

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

lines 2–4why, one step back
2import typing
3from types import TracebackType4

Auth (#65)Tom Christiebefore adoption5afa7dd

line 5why, one step back
5from .auth import HTTPBasicAuth

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

lines 6–15why, one step back
6from .config import (
7 DEFAULT_MAX_REDIRECTS,8 DEFAULT_POOL_LIMITS,9 DEFAULT_SSL_CONFIG,10 DEFAULT_TIMEOUT_CONFIG,11 PoolLimits,12 SSLConfig,13 TimeoutConfig,14)15from .dispatch.connection_pool import ConnectionPool

Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144

line 16why, one step back
16from .exceptions import RedirectBodyUnavailable, RedirectLoop, TooManyRedirects

Merge pull request #60 from encode/concurrency-backend-classTom Christiebefore adoption3d997af

line 17why, one step back
17from .interfaces import ConcurrencyBackend, Dispatcher

Merge pull request #42 from encode/query-paramsTom Christiebefore adoption3de0425

lines 18–19why, one step back
18from .models import (
19 URL,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 20why, one step back
20 AuthTypes,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

lines 21–22why, one step back
21 Cookies,
22 CookieTypes,

Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144

line 23why, one step back
23 Headers,

Merge pull request #42 from encode/query-paramsTom Christiebefore adoption3de0425

lines 24–26why, one step back
24 HeaderTypes,
25 QueryParamTypes,26 Request,

Merge pull request #44 from encode/request-dataTom Christiebefore adoption39a5c53

line 27why, one step back
27 RequestData,

Merge pull request #42 from encode/query-paramsTom Christiebefore adoption3de0425

line 28why, one step back
28 Response,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 29why, one step back
29 SyncResponse,

Merge pull request #42 from encode/query-paramsTom Christiebefore adoption3de0425

lines 30–31why, one step back
30 URLTypes,
31)

Merge pull request #59 from encode/use-stdlib-status-codesTom Christiebefore adoptionafc8369

line 32why, one step back
32from .status_codes import codes

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

lines 33–34why, one step back
33
34

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 35why, one step back
35class AsyncClient:

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

lines 36–37why, one step back
36 def __init__(
37 self,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 38why, one step back
38 auth: AuthTypes = None,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 39why, one step back
39 cookies: CookieTypes = None,

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

lines 40–41why, one step back
40 ssl: SSLConfig = DEFAULT_SSL_CONFIG,
41 timeout: TimeoutConfig = DEFAULT_TIMEOUT_CONFIG,

Truckin' onTom Christiebefore adoption6b60d95

line 42why, one step back
42 pool_limits: PoolLimits = DEFAULT_POOL_LIMITS,

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

line 43why, one step back
43 max_redirects: int = DEFAULT_MAX_REDIRECTS,

Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144

line 44why, one step back
44 dispatch: Dispatcher = None,

Merge pull request #60 from encode/concurrency-backend-classTom Christiebefore adoption3d997af

line 45why, one step back
45 backend: ConcurrencyBackend = None,

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

line 46why, one step back
46 ):

Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144

line 47why, one step back
47 if dispatch is None:

Merge pull request #60 from encode/concurrency-backend-classTom Christiebefore adoption3d997af

lines 48–50why, one step back
48 dispatch = ConnectionPool(
49 ssl=ssl, timeout=timeout, pool_limits=pool_limits, backend=backend50 )

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

line 51why, one step back
51

Auth (#65)Tom Christiebefore adoption5afa7dd

line 52why, one step back
52 self.auth = auth

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 53why, one step back
53 self.cookies = Cookies(cookies)

Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144

lines 54–55why, one step back
54 self.max_redirects = max_redirects
55 self.dispatch = dispatch

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

lines 56–58why, one step back
56
57 async def get(58 self,

Finessing interfaceTom Christiebefore adoptiond7619a9

line 59why, one step back
59 url: URLTypes,

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

line 60why, one step back
60 *,

query_params -> paramsTom Christiebefore adoptionbb70377

line 61why, one step back
61 params: QueryParamTypes = None,

Finessing interfaceTom Christiebefore adoptiond7619a9

line 62why, one step back
62 headers: HeaderTypes = None,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 63why, one step back
63 cookies: CookieTypes = None,

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

line 64why, one step back
64 stream: bool = False,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 65why, one step back
65 auth: AuthTypes = None,

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 66–68why, one step back
66 allow_redirects: bool = True,
67 ssl: SSLConfig = None,68 timeout: TimeoutConfig = None,

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

lines 69–70why, one step back
69 ) -> Response:
70 return await self.request(

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 71–72why, one step back
71 "GET",
72 url,

query_params -> paramsTom Christiebefore adoptionbb70377

line 73why, one step back
73 params=params,

Finessing interfaceTom Christiebefore adoptiond7619a9

line 74why, one step back
74 headers=headers,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 75why, one step back
75 cookies=cookies,

Finessing interfaceTom Christiebefore adoptiond7619a9

line 76why, one step back
76 stream=stream,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 77why, one step back
77 auth=auth,

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 78–80why, one step back
78 allow_redirects=allow_redirects,
79 ssl=ssl,80 timeout=timeout,

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

lines 81–82why, one step back
81 )
82

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 83–86why, one step back
83 async def options(
84 self,85 url: URLTypes,86 *,

query_params -> paramsTom Christiebefore adoptionbb70377

line 87why, one step back
87 params: QueryParamTypes = None,

Finessing interfaceTom Christiebefore adoptiond7619a9

line 88why, one step back
88 headers: HeaderTypes = None,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 89why, one step back
89 cookies: CookieTypes = None,

Finessing interfaceTom Christiebefore adoptiond7619a9

line 90why, one step back
90 stream: bool = False,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 91why, one step back
91 auth: AuthTypes = None,

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 92–98why, one step back
92 allow_redirects: bool = True,
93 ssl: SSLConfig = None,94 timeout: TimeoutConfig = None,95 ) -> Response:96 return await self.request(97 "OPTIONS",98 url,

query_params -> paramsTom Christiebefore adoptionbb70377

line 99why, one step back
99 params=params,

Finessing interfaceTom Christiebefore adoptiond7619a9

line 100why, one step back
100 headers=headers,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 101why, one step back
101 cookies=cookies,

Finessing interfaceTom Christiebefore adoptiond7619a9

line 102why, one step back
102 stream=stream,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 103why, one step back
103 auth=auth,

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 104–112why, one step back
104 allow_redirects=allow_redirects,
105 ssl=ssl,106 timeout=timeout,107 )108109 async def head(110 self,111 url: URLTypes,112 *,

query_params -> paramsTom Christiebefore adoptionbb70377

line 113why, one step back
113 params: QueryParamTypes = None,

Finessing interfaceTom Christiebefore adoptiond7619a9

line 114why, one step back
114 headers: HeaderTypes = None,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 115why, one step back
115 cookies: CookieTypes = None,

Finessing interfaceTom Christiebefore adoptiond7619a9

line 116why, one step back
116 stream: bool = False,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 117why, one step back
117 auth: AuthTypes = None,

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 118–124why, one step back
118 allow_redirects: bool = False, #  Note: Differs to usual default.
119 ssl: SSLConfig = None,120 timeout: TimeoutConfig = None,121 ) -> Response:122 return await self.request(123 "HEAD",124 url,

query_params -> paramsTom Christiebefore adoptionbb70377

line 125why, one step back
125 params=params,

Finessing interfaceTom Christiebefore adoptiond7619a9

line 126why, one step back
126 headers=headers,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 127why, one step back
127 cookies=cookies,

Finessing interfaceTom Christiebefore adoptiond7619a9

line 128why, one step back
128 stream=stream,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 129why, one step back
129 auth=auth,

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 130–134why, one step back
130 allow_redirects=allow_redirects,
131 ssl=ssl,132 timeout=timeout,133 )134

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

lines 135–136why, one step back
135 async def post(
136 self,

Finessing interfaceTom Christiebefore adoptiond7619a9

line 137why, one step back
137 url: URLTypes,

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

line 138why, one step back
138 *,

Merge pull request #44 from encode/request-dataTom Christiebefore adoption39a5c53

line 139why, one step back
139 data: RequestData = b"",

Add json interfacesTom Christiebefore adoption5a63d31

line 140why, one step back
140 json: typing.Any = None,

query_params -> paramsTom Christiebefore adoptionbb70377

line 141why, one step back
141 params: QueryParamTypes = None,

Finessing interfaceTom Christiebefore adoptiond7619a9

line 142why, one step back
142 headers: HeaderTypes = None,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 143why, one step back
143 cookies: CookieTypes = None,

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

line 144why, one step back
144 stream: bool = False,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 145why, one step back
145 auth: AuthTypes = None,

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 146–148why, one step back
146 allow_redirects: bool = True,
147 ssl: SSLConfig = None,148 timeout: TimeoutConfig = None,

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

lines 149–152why, one step back
149 ) -> Response:
150 return await self.request(151 "POST",152 url,

Merge pull request #44 from encode/request-dataTom Christiebefore adoption39a5c53

line 153why, one step back
153 data=data,

Add json interfacesTom Christiebefore adoption5a63d31

line 154why, one step back
154 json=json,

query_params -> paramsTom Christiebefore adoptionbb70377

line 155why, one step back
155 params=params,

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

line 156why, one step back
156 headers=headers,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 157why, one step back
157 cookies=cookies,

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

line 158why, one step back
158 stream=stream,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 159why, one step back
159 auth=auth,

Finessing interfaceTom Christiebefore adoptiond7619a9

line 160why, one step back
160 allow_redirects=allow_redirects,

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

lines 161–164why, one step back
161 ssl=ssl,
162 timeout=timeout,163 )164

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 165–168why, one step back
165 async def put(
166 self,167 url: URLTypes,168 *,

Merge pull request #44 from encode/request-dataTom Christiebefore adoption39a5c53

line 169why, one step back
169 data: RequestData = b"",

Add json interfacesTom Christiebefore adoption5a63d31

line 170why, one step back
170 json: typing.Any = None,

query_params -> paramsTom Christiebefore adoptionbb70377

line 171why, one step back
171 params: QueryParamTypes = None,

Finessing interfaceTom Christiebefore adoptiond7619a9

line 172why, one step back
172 headers: HeaderTypes = None,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 173why, one step back
173 cookies: CookieTypes = None,

Finessing interfaceTom Christiebefore adoptiond7619a9

line 174why, one step back
174 stream: bool = False,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 175why, one step back
175 auth: AuthTypes = None,

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 176–182why, one step back
176 allow_redirects: bool = True,
177 ssl: SSLConfig = None,178 timeout: TimeoutConfig = None,179 ) -> Response:180 return await self.request(181 "PUT",182 url,

Merge pull request #44 from encode/request-dataTom Christiebefore adoption39a5c53

line 183why, one step back
183 data=data,

Add json interfacesTom Christiebefore adoption5a63d31

line 184why, one step back
184 json=json,

query_params -> paramsTom Christiebefore adoptionbb70377

line 185why, one step back
185 params=params,

Finessing interfaceTom Christiebefore adoptiond7619a9

line 186why, one step back
186 headers=headers,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 187why, one step back
187 cookies=cookies,

Finessing interfaceTom Christiebefore adoptiond7619a9

line 188why, one step back
188 stream=stream,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 189why, one step back
189 auth=auth,

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 190–198why, one step back
190 allow_redirects=allow_redirects,
191 ssl=ssl,192 timeout=timeout,193 )194195 async def patch(196 self,197 url: URLTypes,198 *,

Merge pull request #44 from encode/request-dataTom Christiebefore adoption39a5c53

line 199why, one step back
199 data: RequestData = b"",

Add json interfacesTom Christiebefore adoption5a63d31

line 200why, one step back
200 json: typing.Any = None,

query_params -> paramsTom Christiebefore adoptionbb70377

line 201why, one step back
201 params: QueryParamTypes = None,

Finessing interfaceTom Christiebefore adoptiond7619a9

line 202why, one step back
202 headers: HeaderTypes = None,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 203why, one step back
203 cookies: CookieTypes = None,

Finessing interfaceTom Christiebefore adoptiond7619a9

line 204why, one step back
204 stream: bool = False,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 205why, one step back
205 auth: AuthTypes = None,

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 206–212why, one step back
206 allow_redirects: bool = True,
207 ssl: SSLConfig = None,208 timeout: TimeoutConfig = None,209 ) -> Response:210 return await self.request(211 "PATCH",212 url,

Merge pull request #44 from encode/request-dataTom Christiebefore adoption39a5c53

line 213why, one step back
213 data=data,

Add json interfacesTom Christiebefore adoption5a63d31

line 214why, one step back
214 json=json,

query_params -> paramsTom Christiebefore adoptionbb70377

line 215why, one step back
215 params=params,

Finessing interfaceTom Christiebefore adoptiond7619a9

line 216why, one step back
216 headers=headers,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 217why, one step back
217 cookies=cookies,

Finessing interfaceTom Christiebefore adoptiond7619a9

line 218why, one step back
218 stream=stream,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 219why, one step back
219 auth=auth,

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 220–228why, one step back
220 allow_redirects=allow_redirects,
221 ssl=ssl,222 timeout=timeout,223 )224225 async def delete(226 self,227 url: URLTypes,228 *,

Merge pull request #44 from encode/request-dataTom Christiebefore adoption39a5c53

line 229why, one step back
229 data: RequestData = b"",

Add json interfacesTom Christiebefore adoption5a63d31

line 230why, one step back
230 json: typing.Any = None,

query_params -> paramsTom Christiebefore adoptionbb70377

line 231why, one step back
231 params: QueryParamTypes = None,

Finessing interfaceTom Christiebefore adoptiond7619a9

line 232why, one step back
232 headers: HeaderTypes = None,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 233why, one step back
233 cookies: CookieTypes = None,

Finessing interfaceTom Christiebefore adoptiond7619a9

line 234why, one step back
234 stream: bool = False,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 235why, one step back
235 auth: AuthTypes = None,

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 236–242why, one step back
236 allow_redirects: bool = True,
237 ssl: SSLConfig = None,238 timeout: TimeoutConfig = None,239 ) -> Response:240 return await self.request(241 "DELETE",242 url,

Merge pull request #44 from encode/request-dataTom Christiebefore adoption39a5c53

line 243why, one step back
243 data=data,

Add json interfacesTom Christiebefore adoption5a63d31

line 244why, one step back
244 json=json,

query_params -> paramsTom Christiebefore adoptionbb70377

line 245why, one step back
245 params=params,

Finessing interfaceTom Christiebefore adoptiond7619a9

line 246why, one step back
246 headers=headers,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 247why, one step back
247 cookies=cookies,

Finessing interfaceTom Christiebefore adoptiond7619a9

line 248why, one step back
248 stream=stream,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 249why, one step back
249 auth=auth,

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 250–254why, one step back
250 allow_redirects=allow_redirects,
251 ssl=ssl,252 timeout=timeout,253 )254

Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144

lines 255–260why, one step back
255 async def request(
256 self,257 method: str,258 url: URLTypes,259 *,260 data: RequestData = b"",

Add json interfacesTom Christiebefore adoption5a63d31

line 261why, one step back
261 json: typing.Any = None,

query_params -> paramsTom Christiebefore adoptionbb70377

line 262why, one step back
262 params: QueryParamTypes = None,

Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144

line 263why, one step back
263 headers: HeaderTypes = None,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 264why, one step back
264 cookies: CookieTypes = None,

Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144

line 265why, one step back
265 stream: bool = False,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 266why, one step back
266 auth: AuthTypes = None,

Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144

lines 267–271why, one step back
267 allow_redirects: bool = True,
268 ssl: SSLConfig = None,269 timeout: TimeoutConfig = None,270 ) -> Response:271 request = Request(

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

lines 272–274why, one step back
272 method,
273 url,274 data=data,

Add json interfacesTom Christiebefore adoption5a63d31

line 275why, one step back
275 json=json,

query_params -> paramsTom Christiebefore adoptionbb70377

line 276why, one step back
276 params=params,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

lines 277–278why, one step back
277 headers=headers,
278 cookies=self.merge_cookies(cookies),

Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144

lines 279–283why, one step back
279 )
280 self.prepare_request(request)281 response = await self.send(282 request,283 stream=stream,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 284why, one step back
284 auth=auth,

Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144

lines 285–290why, one step back
285 allow_redirects=allow_redirects,
286 ssl=ssl,287 timeout=timeout,288 )289 return response290

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

line 291why, one step back
291 def prepare_request(self, request: Request) -> None:

Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144

line 292why, one step back
292 request.prepare()

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

line 293why, one step back
293

query_params -> paramsTom Christiebefore adoptionbb70377

lines 294–296why, one step back
294 def merge_cookies(
295 self, cookies: CookieTypes = None296 ) -> typing.Optional[CookieTypes]:

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

lines 297–302why, one step back
297 if cookies or self.cookies:
298 merged_cookies = Cookies(self.cookies)299 merged_cookies.update(cookies)300 return merged_cookies301 return cookies302

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

lines 303–307why, one step back
303 async def send(
304 self,305 request: Request,306 *,307 stream: bool = False,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 308why, one step back
308 auth: AuthTypes = None,

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 309–310why, one step back
309 ssl: SSLConfig = None,
310 timeout: TimeoutConfig = None,

Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144

line 311why, one step back
311 allow_redirects: bool = True,

Auth (#65)Tom Christiebefore adoption5afa7dd

lines 312–341why, one step back
312 ) -> Response:
313 if auth is None:314 auth = self.auth315316 url = request.url317 if auth is None and (url.username or url.password):318 auth = HTTPBasicAuth(username=url.username, password=url.password)319320 if auth is not None:321 if isinstance(auth, tuple):322 auth = HTTPBasicAuth(username=auth[0], password=auth[1])323 request = auth(request)324325 response = await self.send_handling_redirects(326 request,327 stream=stream,328 ssl=ssl,329 timeout=timeout,330 allow_redirects=allow_redirects,331 )332 return response333334 async def send_handling_redirects(335 self,336 request: Request,337 *,338 stream: bool = False,339 ssl: SSLConfig = None,340 timeout: TimeoutConfig = None,341 allow_redirects: bool = True,

Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144

line 342why, one step back
342 history: typing.List[Response] = None,

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

line 343why, one step back
343 ) -> Response:

Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144

lines 344–345why, one step back
344 if history is None:
345 history = []

Finessing interfaceTom Christiebefore adoptiond7619a9

line 346why, one step back
346

Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144

lines 347–353why, one step back
347 while True:
348 # We perform these checks here, so that calls to `response.next()`349 # will raise redirect errors if appropriate.350 if len(history) > self.max_redirects:351 raise TooManyRedirects()352 if request.url in [response.url for response in history]:353 raise RedirectLoop()

Finessing interfaceTom Christiebefore adoptiond7619a9

line 354why, one step back
354

Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144

lines 355–358why, one step back
355 response = await self.dispatch.send(
356 request, stream=stream, ssl=ssl, timeout=timeout357 )358 response.history = list(history)

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 359why, one step back
359 self.cookies.extract_cookies(response)

Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144

lines 360–362why, one step back
360 history = [response] + history
361 if not response.is_redirect:362 break

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

line 363why, one step back
363

Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144

lines 364–370why, one step back
364 if allow_redirects:
365 request = self.build_redirect_request(request, response)366 else:367368 async def send_next() -> Response:369 nonlocal request, response, ssl, allow_redirects, timeout, history370 request = self.build_redirect_request(request, response)

Auth (#65)Tom Christiebefore adoption5afa7dd

line 371why, one step back
371 response = await self.send_handling_redirects(

Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144

lines 372–390why, one step back
372 request,
373 stream=stream,374 allow_redirects=allow_redirects,375 ssl=ssl,376 timeout=timeout,377 history=history,378 )379 return response380381 response.next = send_next # type: ignore382 break383384 return response385386 def build_redirect_request(self, request: Request, response: Response) -> Request:387 method = self.redirect_method(request, response)388 url = self.redirect_url(request, response)389 headers = self.redirect_headers(request, url)390 content = self.redirect_content(request, method)

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 391why, one step back
391 cookies = self.merge_cookies(request.cookies)

query_params -> paramsTom Christiebefore adoptionbb70377

lines 392–394why, one step back
392 return Request(
393 method=method, url=url, headers=headers, data=content, cookies=cookies394 )

Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144

lines 395–403why, one step back
395
396 def redirect_method(self, request: Request, response: Response) -> str:397 """398 When being redirected we may want to change the method of the request399 based on certain specs or browser behavior.400 """401 method = request.method402403 # https://tools.ietf.org/html/rfc7231#section-6.4.4

Merge pull request #59 from encode/use-stdlib-status-codesTom Christiebefore adoptionafc8369

line 404why, one step back
404 if response.status_code == codes.SEE_OTHER and method != "HEAD":

Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144

lines 405–408why, one step back
405 method = "GET"
406407 # Do what the browsers do, despite standards...408 # Turn 302s into GETs.

Merge pull request #59 from encode/use-stdlib-status-codesTom Christiebefore adoptionafc8369

line 409why, one step back
409 if response.status_code == codes.FOUND and method != "HEAD":

Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144

lines 410–413why, one step back
410 method = "GET"
411412 # If a POST is responded to with a 301, turn it into a GET.413 # This bizarre behaviour is explained in 'requests' issue 1704.

Merge pull request #59 from encode/use-stdlib-status-codesTom Christiebefore adoptionafc8369

line 414why, one step back
414 if response.status_code == codes.MOVED_PERMANENTLY and method == "POST":

Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144

lines 415–457why, one step back
415 method = "GET"
416417 return method418419 def redirect_url(self, request: Request, response: Response) -> URL:420 """421 Return the URL for the redirect to follow.422 """423 location = response.headers["Location"]424425 url = URL(location, allow_relative=True)426427 # Facilitate relative 'Location' headers, as allowed by RFC 7231.428 # (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')429 if url.is_relative_url:430 url = url.resolve_with(request.url)431432 # Attach previous fragment if needed (RFC 7231 7.1.2)433 if request.url.fragment and not url.fragment:434 url = url.copy_with(fragment=request.url.fragment)435436 return url437438 def redirect_headers(self, request: Request, url: URL) -> Headers:439 """440 Strip Authorization headers when responses are redirected away from441 the origin.442 """443 headers = Headers(request.headers)444 if url.origin != request.url.origin:445 del headers["Authorization"]446 return headers447448 def redirect_content(self, request: Request, method: str) -> bytes:449 """450 Return the body that should be used for the redirect request.451 """452 if method != request.method and method == "GET":453 return b""454 if request.is_streaming:455 raise RedirectBodyUnavailable()456 return request.content457

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

line 458why, one step back
458 async def close(self) -> None:

Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144

line 459why, one step back
459 await self.dispatch.close()

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

line 460why, one step back
460

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 461why, one step back
461 async def __aenter__(self) -> "AsyncClient":

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

lines 462–470why, one step back
462 return self
463464 async def __aexit__(465 self,466 exc_type: typing.Type[BaseException] = None,467 exc_value: BaseException = None,468 traceback: TracebackType = None,469 ) -> None:470 await self.close()

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

lines 471–475why, one step back
471
472473class Client:474 def __init__(475 self,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 476why, one step back
476 auth: AuthTypes = None,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

lines 477–481why, one step back
477 ssl: SSLConfig = DEFAULT_SSL_CONFIG,
478 timeout: TimeoutConfig = DEFAULT_TIMEOUT_CONFIG,479 pool_limits: PoolLimits = DEFAULT_POOL_LIMITS,480 max_redirects: int = DEFAULT_MAX_REDIRECTS,481 dispatch: Dispatcher = None,

Merge pull request #60 from encode/concurrency-backend-classTom Christiebefore adoption3d997af

line 482why, one step back
482 backend: ConcurrencyBackend = None,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

lines 483–484why, one step back
483 ) -> None:
484 self._client = AsyncClient(

Auth (#65)Tom Christiebefore adoption5afa7dd

line 485why, one step back
485 auth=auth,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

lines 486–490why, one step back
486 ssl=ssl,
487 timeout=timeout,488 pool_limits=pool_limits,489 max_redirects=max_redirects,490 dispatch=dispatch,

Merge pull request #60 from encode/concurrency-backend-classTom Christiebefore adoption3d997af

line 491why, one step back
491 backend=backend,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

lines 492–494why, one step back
492 )
493 self._loop = asyncio.new_event_loop()494

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

lines 495–498why, one step back
495 @property
496 def cookies(self) -> Cookies:497 return self._client.cookies498

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

lines 499–504why, one step back
499 def request(
500 self,501 method: str,502 url: URLTypes,503 *,504 data: RequestData = b"",

Add json interfacesTom Christiebefore adoption5a63d31

line 505why, one step back
505 json: typing.Any = None,

query_params -> paramsTom Christiebefore adoptionbb70377

line 506why, one step back
506 params: QueryParamTypes = None,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 507why, one step back
507 headers: HeaderTypes = None,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 508why, one step back
508 cookies: CookieTypes = None,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 509why, one step back
509 stream: bool = False,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 510why, one step back
510 auth: AuthTypes = None,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

lines 511–515why, one step back
511 allow_redirects: bool = True,
512 ssl: SSLConfig = None,513 timeout: TimeoutConfig = None,514 ) -> SyncResponse:515 request = Request(

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

lines 516–518why, one step back
516 method,
517 url,518 data=data,

Add json interfacesTom Christiebefore adoption5a63d31

line 519why, one step back
519 json=json,

query_params -> paramsTom Christiebefore adoptionbb70377

line 520why, one step back
520 params=params,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

lines 521–522why, one step back
521 headers=headers,
522 cookies=self._client.merge_cookies(cookies),

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

lines 523–527why, one step back
523 )
524 self.prepare_request(request)525 response = self.send(526 request,527 stream=stream,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 528why, one step back
528 auth=auth,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

lines 529–538why, one step back
529 allow_redirects=allow_redirects,
530 ssl=ssl,531 timeout=timeout,532 )533 return response534535 def get(536 self,537 url: URLTypes,538 *,

query_params -> paramsTom Christiebefore adoptionbb70377

line 539why, one step back
539 params: QueryParamTypes = None,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 540why, one step back
540 headers: HeaderTypes = None,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 541why, one step back
541 cookies: CookieTypes = None,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 542why, one step back
542 stream: bool = False,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 543why, one step back
543 auth: AuthTypes = None,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

lines 544–551why, one step back
544 allow_redirects: bool = True,
545 ssl: SSLConfig = None,546 timeout: TimeoutConfig = None,547 ) -> SyncResponse:548 return self.request(549 "GET",550 url,551 headers=headers,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 552why, one step back
552 cookies=cookies,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 553why, one step back
553 stream=stream,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 554why, one step back
554 auth=auth,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

lines 555–563why, one step back
555 allow_redirects=allow_redirects,
556 ssl=ssl,557 timeout=timeout,558 )559560 def options(561 self,562 url: URLTypes,563 *,

query_params -> paramsTom Christiebefore adoptionbb70377

line 564why, one step back
564 params: QueryParamTypes = None,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 565why, one step back
565 headers: HeaderTypes = None,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 566why, one step back
566 cookies: CookieTypes = None,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 567why, one step back
567 stream: bool = False,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 568why, one step back
568 auth: AuthTypes = None,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

lines 569–576why, one step back
569 allow_redirects: bool = True,
570 ssl: SSLConfig = None,571 timeout: TimeoutConfig = None,572 ) -> SyncResponse:573 return self.request(574 "OPTIONS",575 url,576 headers=headers,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 577why, one step back
577 cookies=cookies,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 578why, one step back
578 stream=stream,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 579why, one step back
579 auth=auth,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

lines 580–588why, one step back
580 allow_redirects=allow_redirects,
581 ssl=ssl,582 timeout=timeout,583 )584585 def head(586 self,587 url: URLTypes,588 *,

query_params -> paramsTom Christiebefore adoptionbb70377

line 589why, one step back
589 params: QueryParamTypes = None,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 590why, one step back
590 headers: HeaderTypes = None,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 591why, one step back
591 cookies: CookieTypes = None,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 592why, one step back
592 stream: bool = False,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 593why, one step back
593 auth: AuthTypes = None,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

lines 594–601why, one step back
594 allow_redirects: bool = False, #  Note: Differs to usual default.
595 ssl: SSLConfig = None,596 timeout: TimeoutConfig = None,597 ) -> SyncResponse:598 return self.request(599 "HEAD",600 url,601 headers=headers,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 602why, one step back
602 cookies=cookies,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 603why, one step back
603 stream=stream,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 604why, one step back
604 auth=auth,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

lines 605–614why, one step back
605 allow_redirects=allow_redirects,
606 ssl=ssl,607 timeout=timeout,608 )609610 def post(611 self,612 url: URLTypes,613 *,614 data: RequestData = b"",

Add json interfacesTom Christiebefore adoption5a63d31

line 615why, one step back
615 json: typing.Any = None,

query_params -> paramsTom Christiebefore adoptionbb70377

line 616why, one step back
616 params: QueryParamTypes = None,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 617why, one step back
617 headers: HeaderTypes = None,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 618why, one step back
618 cookies: CookieTypes = None,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 619why, one step back
619 stream: bool = False,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 620why, one step back
620 auth: AuthTypes = None,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

lines 621–628why, one step back
621 allow_redirects: bool = True,
622 ssl: SSLConfig = None,623 timeout: TimeoutConfig = None,624 ) -> SyncResponse:625 return self.request(626 "POST",627 url,628 data=data,

Add json interfacesTom Christiebefore adoption5a63d31

line 629why, one step back
629 json=json,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 630why, one step back
630 headers=headers,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 631why, one step back
631 cookies=cookies,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 632why, one step back
632 stream=stream,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 633why, one step back
633 auth=auth,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

lines 634–643why, one step back
634 allow_redirects=allow_redirects,
635 ssl=ssl,636 timeout=timeout,637 )638639 def put(640 self,641 url: URLTypes,642 *,643 data: RequestData = b"",

Add json interfacesTom Christiebefore adoption5a63d31

line 644why, one step back
644 json: typing.Any = None,

query_params -> paramsTom Christiebefore adoptionbb70377

line 645why, one step back
645 params: QueryParamTypes = None,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 646why, one step back
646 headers: HeaderTypes = None,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 647why, one step back
647 cookies: CookieTypes = None,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 648why, one step back
648 stream: bool = False,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 649why, one step back
649 auth: AuthTypes = None,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

lines 650–657why, one step back
650 allow_redirects: bool = True,
651 ssl: SSLConfig = None,652 timeout: TimeoutConfig = None,653 ) -> SyncResponse:654 return self.request(655 "PUT",656 url,657 data=data,

Add json interfacesTom Christiebefore adoption5a63d31

line 658why, one step back
658 json=json,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 659why, one step back
659 headers=headers,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 660why, one step back
660 cookies=cookies,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 661why, one step back
661 stream=stream,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 662why, one step back
662 auth=auth,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

lines 663–672why, one step back
663 allow_redirects=allow_redirects,
664 ssl=ssl,665 timeout=timeout,666 )667668 def patch(669 self,670 url: URLTypes,671 *,672 data: RequestData = b"",

Add json interfacesTom Christiebefore adoption5a63d31

line 673why, one step back
673 json: typing.Any = None,

query_params -> paramsTom Christiebefore adoptionbb70377

line 674why, one step back
674 params: QueryParamTypes = None,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 675why, one step back
675 headers: HeaderTypes = None,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 676why, one step back
676 cookies: CookieTypes = None,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 677why, one step back
677 stream: bool = False,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 678why, one step back
678 auth: AuthTypes = None,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

lines 679–686why, one step back
679 allow_redirects: bool = True,
680 ssl: SSLConfig = None,681 timeout: TimeoutConfig = None,682 ) -> SyncResponse:683 return self.request(684 "PATCH",685 url,686 data=data,

Add json interfacesTom Christiebefore adoption5a63d31

line 687why, one step back
687 json=json,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 688why, one step back
688 headers=headers,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 689why, one step back
689 cookies=cookies,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 690why, one step back
690 stream=stream,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 691why, one step back
691 auth=auth,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

lines 692–701why, one step back
692 allow_redirects=allow_redirects,
693 ssl=ssl,694 timeout=timeout,695 )696697 def delete(698 self,699 url: URLTypes,700 *,701 data: RequestData = b"",

Add json interfacesTom Christiebefore adoption5a63d31

line 702why, one step back
702 json: typing.Any = None,

query_params -> paramsTom Christiebefore adoptionbb70377

line 703why, one step back
703 params: QueryParamTypes = None,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 704why, one step back
704 headers: HeaderTypes = None,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 705why, one step back
705 cookies: CookieTypes = None,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 706why, one step back
706 stream: bool = False,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 707why, one step back
707 auth: AuthTypes = None,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

lines 708–715why, one step back
708 allow_redirects: bool = True,
709 ssl: SSLConfig = None,710 timeout: TimeoutConfig = None,711 ) -> SyncResponse:712 return self.request(713 "DELETE",714 url,715 data=data,

Add json interfacesTom Christiebefore adoption5a63d31

line 716why, one step back
716 json=json,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 717why, one step back
717 headers=headers,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 718why, one step back
718 cookies=cookies,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 719why, one step back
719 stream=stream,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 720why, one step back
720 auth=auth,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

lines 721–733why, one step back
721 allow_redirects=allow_redirects,
722 ssl=ssl,723 timeout=timeout,724 )725726 def prepare_request(self, request: Request) -> None:727 self._client.prepare_request(request)728729 def send(730 self,731 request: Request,732 *,733 stream: bool = False,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 734why, one step back
734 auth: AuthTypes = None,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

lines 735–742why, one step back
735 allow_redirects: bool = True,
736 ssl: SSLConfig = None,737 timeout: TimeoutConfig = None,738 ) -> SyncResponse:739 response = self._loop.run_until_complete(740 self._client.send(741 request,742 stream=stream,

Auth (#65)Tom Christiebefore adoption5afa7dd

line 743why, one step back
743 auth=auth,

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

lines 744–763why, one step back
744 allow_redirects=allow_redirects,
745 ssl=ssl,746 timeout=timeout,747 )748 )749 return SyncResponse(response, self._loop)750751 def close(self) -> None:752 self._loop.run_until_complete(self._client.close())753754 def __enter__(self) -> "Client":755 return self756757 def __exit__(758 self,759 exc_type: typing.Type[BaseException] = None,760 exc_value: BaseException = None,761 traceback: TracebackType = None,762 ) -> None:763 self.close()