Skip to content
Myr

client.py

This file

Path

httpcore/client.py

808 lines · 22.6 KiB · Python

Last changed by

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

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–9why, one step back
6from .config import (
7 DEFAULT_MAX_REDIRECTS,8 DEFAULT_POOL_LIMITS,9 DEFAULT_TIMEOUT_CONFIG,

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

line 10why, one step back
10 CertTypes,

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

line 11why, one step back
11 PoolLimits,

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 12–13why, one step back
12 TimeoutTypes,
13 VerifyTypes,

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

lines 14–15why, one step back
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,

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 40–42why, one step back
40 verify: VerifyTypes = True,
41 cert: CertTypes = None,42 timeout: TimeoutTypes = DEFAULT_TIMEOUT_CONFIG,

Truckin' onTom Christiebefore adoption6b60d95

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

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

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

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

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

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

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

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

line 47why, one step back
47 ):

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

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

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

line 49why, one step back
49 dispatch = ConnectionPool(

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 50–54why, one step back
50 verify=verify,
51 cert=cert,52 timeout=timeout,53 pool_limits=pool_limits,54 backend=backend,

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

line 55why, one step back
55 )

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

line 56why, one step back
56

Auth (#65)Tom Christiebefore adoption5afa7dd

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

lines 59–60why, one step back
59 self.max_redirects = max_redirects
60 self.dispatch = dispatch

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

lines 61–63why, one step back
61
62 async def get(63 self,

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

line 65why, one step back
65 *,

query_params -> paramsTom Christiebefore adoptionbb70377

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 72–74why, one step back
72 cert: CertTypes = None,
73 verify: VerifyTypes = None,74 timeout: TimeoutTypes = None,

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

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

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 77–78why, one step back
77 "GET",
78 url,

query_params -> paramsTom Christiebefore adoptionbb70377

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 85–86why, one step back
85 verify=verify,
86 cert=cert,

Finessing interfaceTom Christiebefore adoptiond7619a9

line 87why, one step back
87 timeout=timeout,

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

lines 88–89why, one step back
88 )
89

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 90–93why, one step back
90 async def options(
91 self,92 url: URLTypes,93 *,

query_params -> paramsTom Christiebefore adoptionbb70377

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 100–102why, one step back
100 cert: CertTypes = None,
101 verify: VerifyTypes = None,102 timeout: TimeoutTypes = None,

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 103–106why, one step back
103 ) -> Response:
104 return await self.request(105 "OPTIONS",106 url,

query_params -> paramsTom Christiebefore adoptionbb70377

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 113–114why, one step back
113 verify=verify,
114 cert=cert,

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 115–121why, one step back
115 timeout=timeout,
116 )117118 async def head(119 self,120 url: URLTypes,121 *,

query_params -> paramsTom Christiebefore adoptionbb70377

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

Finessing interfaceTom Christiebefore adoptiond7619a9

line 127why, one step back
127 allow_redirects: bool = False, #  Note: Differs to usual default.

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 128–130why, one step back
128 cert: CertTypes = None,
129 verify: VerifyTypes = None,130 timeout: TimeoutTypes = None,

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 131–134why, one step back
131 ) -> Response:
132 return await self.request(133 "HEAD",134 url,

query_params -> paramsTom Christiebefore adoptionbb70377

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 141–142why, one step back
141 verify=verify,
142 cert=cert,

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 143–145why, one step back
143 timeout=timeout,
144 )145

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

lines 146–147why, one step back
146 async def post(
147 self,

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

line 149why, one step back
149 *,

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

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

Add json interfacesTom Christiebefore adoption5a63d31

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

query_params -> paramsTom Christiebefore adoptionbb70377

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 158–160why, one step back
158 cert: CertTypes = None,
159 verify: VerifyTypes = None,160 timeout: TimeoutTypes = None,

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

lines 161–164why, one step back
161 ) -> Response:
162 return await self.request(163 "POST",164 url,

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

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

Add json interfacesTom Christiebefore adoption5a63d31

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

query_params -> paramsTom Christiebefore adoptionbb70377

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

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 173–174why, one step back
173 verify=verify,
174 cert=cert,

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

lines 175–177why, one step back
175 timeout=timeout,
176 )177

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 178–181why, one step back
178 async def put(
179 self,180 url: URLTypes,181 *,

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

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

Add json interfacesTom Christiebefore adoption5a63d31

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

query_params -> paramsTom Christiebefore adoptionbb70377

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 190–192why, one step back
190 cert: CertTypes = None,
191 verify: VerifyTypes = None,192 timeout: TimeoutTypes = None,

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 193–196why, one step back
193 ) -> Response:
194 return await self.request(195 "PUT",196 url,

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

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

Add json interfacesTom Christiebefore adoption5a63d31

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

query_params -> paramsTom Christiebefore adoptionbb70377

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 205–206why, one step back
205 verify=verify,
206 cert=cert,

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 207–213why, one step back
207 timeout=timeout,
208 )209210 async def patch(211 self,212 url: URLTypes,213 *,

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

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

Add json interfacesTom Christiebefore adoption5a63d31

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

query_params -> paramsTom Christiebefore adoptionbb70377

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 222–224why, one step back
222 cert: CertTypes = None,
223 verify: VerifyTypes = None,224 timeout: TimeoutTypes = None,

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 225–228why, one step back
225 ) -> Response:
226 return await self.request(227 "PATCH",228 url,

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

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

Add json interfacesTom Christiebefore adoption5a63d31

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

query_params -> paramsTom Christiebefore adoptionbb70377

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 237–238why, one step back
237 verify=verify,
238 cert=cert,

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 239–245why, one step back
239 timeout=timeout,
240 )241242 async def delete(243 self,244 url: URLTypes,245 *,

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

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

Add json interfacesTom Christiebefore adoption5a63d31

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

query_params -> paramsTom Christiebefore adoptionbb70377

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 254–256why, one step back
254 cert: CertTypes = None,
255 verify: VerifyTypes = None,256 timeout: TimeoutTypes = None,

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 257–260why, one step back
257 ) -> Response:
258 return await self.request(259 "DELETE",260 url,

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

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

Add json interfacesTom Christiebefore adoption5a63d31

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

query_params -> paramsTom Christiebefore adoptionbb70377

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

Finessing interfaceTom Christiebefore adoptiond7619a9

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 269–270why, one step back
269 verify=verify,
270 cert=cert,

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 271–273why, one step back
271 timeout=timeout,
272 )273

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

lines 274–279why, one step back
274 async def request(
275 self,276 method: str,277 url: URLTypes,278 *,279 data: RequestData = b"",

Add json interfacesTom Christiebefore adoption5a63d31

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

query_params -> paramsTom Christiebefore adoptionbb70377

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

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

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 287–289why, one step back
287 cert: CertTypes = None,
288 verify: VerifyTypes = None,289 timeout: TimeoutTypes = None,

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

lines 290–291why, one step back
290 ) -> Response:
291 request = Request(

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

lines 292–294why, one step back
292 method,
293 url,294 data=data,

Add json interfacesTom Christiebefore adoption5a63d31

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

query_params -> paramsTom Christiebefore adoptionbb70377

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

lines 297–298why, one step back
297 headers=headers,
298 cookies=self.merge_cookies(cookies),

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

lines 299–303why, one step back
299 )
300 self.prepare_request(request)301 response = await self.send(302 request,303 stream=stream,

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 306–307why, one step back
306 verify=verify,
307 cert=cert,

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

lines 308–311why, one step back
308 timeout=timeout,
309 )310 return response311

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

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

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

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

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

line 314why, one step back
314

query_params -> paramsTom Christiebefore adoptionbb70377

lines 315–317why, one step back
315 def merge_cookies(
316 self, cookies: CookieTypes = None317 ) -> typing.Optional[CookieTypes]:

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

lines 318–323why, one step back
318 if cookies or self.cookies:
319 merged_cookies = Cookies(self.cookies)320 merged_cookies.update(cookies)321 return merged_cookies322 return cookies323

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

lines 324–328why, one step back
324 async def send(
325 self,326 request: Request,327 *,328 stream: bool = False,

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 331–333why, one step back
331 verify: VerifyTypes = None,
332 cert: CertTypes = None,333 timeout: TimeoutTypes = None,

Auth (#65)Tom Christiebefore adoption5afa7dd

lines 334–349why, one step back
334 ) -> Response:
335 if auth is None:336 auth = self.auth337338 url = request.url339 if auth is None and (url.username or url.password):340 auth = HTTPBasicAuth(username=url.username, password=url.password)341342 if auth is not None:343 if isinstance(auth, tuple):344 auth = HTTPBasicAuth(username=auth[0], password=auth[1])345 request = auth(request)346347 response = await self.send_handling_redirects(348 request,349 stream=stream,

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 350–351why, one step back
350 verify=verify,
351 cert=cert,

Auth (#65)Tom Christiebefore adoption5afa7dd

lines 352–361why, one step back
352 timeout=timeout,
353 allow_redirects=allow_redirects,354 )355 return response356357 async def send_handling_redirects(358 self,359 request: Request,360 *,361 stream: bool = False,

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 362–364why, one step back
362 cert: CertTypes = None,
363 verify: VerifyTypes = None,364 timeout: TimeoutTypes = None,

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

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

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

lines 368–369why, one step back
368 if history is None:
369 history = []

Finessing interfaceTom Christiebefore adoptiond7619a9

line 370why, one step back
370

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

lines 371–377why, one step back
371 while True:
372 # We perform these checks here, so that calls to `response.next()`373 # will raise redirect errors if appropriate.374 if len(history) > self.max_redirects:375 raise TooManyRedirects()376 if request.url in [response.url for response in history]:377 raise RedirectLoop()

Finessing interfaceTom Christiebefore adoptiond7619a9

line 378why, one step back
378

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

line 379why, one step back
379 response = await self.dispatch.send(

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

line 380why, one step back
380 request, stream=stream, verify=verify, cert=cert, timeout=timeout

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

lines 381–382why, one step back
381 )
382 response.history = list(history)

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

lines 384–386why, one step back
384 history = [response] + history
385 if not response.is_redirect:386 break

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

line 387why, one step back
387

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

lines 388–392why, one step back
388 if allow_redirects:
389 request = self.build_redirect_request(request, response)390 else:391392 async def send_next() -> Response:

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

line 393why, one step back
393 nonlocal request, response, verify, cert, allow_redirects, timeout, history

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

line 394why, one step back
394 request = self.build_redirect_request(request, response)

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

lines 396–398why, one step back
396 request,
397 stream=stream,398 allow_redirects=allow_redirects,

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 399–400why, one step back
399 verify=verify,
400 cert=cert,

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

lines 401–415why, one step back
401 timeout=timeout,
402 history=history,403 )404 return response405406 response.next = send_next # type: ignore407 break408409 return response410411 def build_redirect_request(self, request: Request, response: Response) -> Request:412 method = self.redirect_method(request, response)413 url = self.redirect_url(request, response)414 headers = self.redirect_headers(request, url)415 content = self.redirect_content(request, method)

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

query_params -> paramsTom Christiebefore adoptionbb70377

lines 417–419why, one step back
417 return Request(
418 method=method, url=url, headers=headers, data=content, cookies=cookies419 )

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

lines 420–428why, one step back
420
421 def redirect_method(self, request: Request, response: Response) -> str:422 """423 When being redirected we may want to change the method of the request424 based on certain specs or browser behavior.425 """426 method = request.method427428 # https://tools.ietf.org/html/rfc7231#section-6.4.4

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

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

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

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

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

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

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

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

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

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

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

lines 440–482why, one step back
440 method = "GET"
441442 return method443444 def redirect_url(self, request: Request, response: Response) -> URL:445 """446 Return the URL for the redirect to follow.447 """448 location = response.headers["Location"]449450 url = URL(location, allow_relative=True)451452 # Facilitate relative 'Location' headers, as allowed by RFC 7231.453 # (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')454 if url.is_relative_url:455 url = url.resolve_with(request.url)456457 # Attach previous fragment if needed (RFC 7231 7.1.2)458 if request.url.fragment and not url.fragment:459 url = url.copy_with(fragment=request.url.fragment)460461 return url462463 def redirect_headers(self, request: Request, url: URL) -> Headers:464 """465 Strip Authorization headers when responses are redirected away from466 the origin.467 """468 headers = Headers(request.headers)469 if url.origin != request.url.origin:470 del headers["Authorization"]471 return headers472473 def redirect_content(self, request: Request, method: str) -> bytes:474 """475 Return the body that should be used for the redirect request.476 """477 if method != request.method and method == "GET":478 return b""479 if request.is_streaming:480 raise RedirectBodyUnavailable()481 return request.content482

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

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

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

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

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

line 485why, one step back
485

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

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

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

lines 487–495why, one step back
487 return self
488489 async def __aexit__(490 self,491 exc_type: typing.Type[BaseException] = None,492 exc_value: BaseException = None,493 traceback: TracebackType = None,494 ) -> None:495 await self.close()

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

lines 496–500why, one step back
496
497498class Client:499 def __init__(500 self,

Auth (#65)Tom Christiebefore adoption5afa7dd

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 502–504why, one step back
502 cert: CertTypes = None,
503 verify: VerifyTypes = True,504 timeout: TimeoutTypes = DEFAULT_TIMEOUT_CONFIG,

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

lines 505–507why, one step back
505 pool_limits: PoolLimits = DEFAULT_POOL_LIMITS,
506 max_redirects: int = DEFAULT_MAX_REDIRECTS,507 dispatch: Dispatcher = None,

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

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 512–513why, one step back
512 verify=verify,
513 cert=cert,

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

lines 514–517why, one step back
514 timeout=timeout,
515 pool_limits=pool_limits,516 max_redirects=max_redirects,517 dispatch=dispatch,

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

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

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

lines 519–521why, one step back
519 )
520 self._loop = asyncio.new_event_loop()521

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

lines 522–525why, one step back
522 @property
523 def cookies(self) -> Cookies:524 return self._client.cookies525

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

lines 526–531why, one step back
526 def request(
527 self,528 method: str,529 url: URLTypes,530 *,531 data: RequestData = b"",

Add json interfacesTom Christiebefore adoption5a63d31

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

query_params -> paramsTom Christiebefore adoptionbb70377

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

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

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 539–541why, one step back
539 cert: CertTypes = None,
540 verify: VerifyTypes = None,541 timeout: TimeoutTypes = None,

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

lines 542–543why, one step back
542 ) -> SyncResponse:
543 request = Request(

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

lines 544–546why, one step back
544 method,
545 url,546 data=data,

Add json interfacesTom Christiebefore adoption5a63d31

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

query_params -> paramsTom Christiebefore adoptionbb70377

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

lines 551–555why, one step back
551 )
552 self.prepare_request(request)553 response = self.send(554 request,555 stream=stream,

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 558–559why, one step back
558 verify=verify,
559 cert=cert,

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

lines 560–567why, one step back
560 timeout=timeout,
561 )562 return response563564 def get(565 self,566 url: URLTypes,567 *,

query_params -> paramsTom Christiebefore adoptionbb70377

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

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

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 574–576why, one step back
574 cert: CertTypes = None,
575 verify: VerifyTypes = None,576 timeout: TimeoutTypes = None,

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

lines 577–581why, one step back
577 ) -> SyncResponse:
578 return self.request(579 "GET",580 url,581 headers=headers,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 586–587why, one step back
586 verify=verify,
587 cert=cert,

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

lines 588–594why, one step back
588 timeout=timeout,
589 )590591 def options(592 self,593 url: URLTypes,594 *,

query_params -> paramsTom Christiebefore adoptionbb70377

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

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

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 601–603why, one step back
601 cert: CertTypes = None,
602 verify: VerifyTypes = None,603 timeout: TimeoutTypes = None,

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

lines 604–608why, one step back
604 ) -> SyncResponse:
605 return self.request(606 "OPTIONS",607 url,608 headers=headers,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 613–614why, one step back
613 verify=verify,
614 cert=cert,

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

lines 615–621why, one step back
615 timeout=timeout,
616 )617618 def head(619 self,620 url: URLTypes,621 *,

query_params -> paramsTom Christiebefore adoptionbb70377

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

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

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

line 627why, one step back
627 allow_redirects: bool = False, #  Note: Differs to usual default.

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 628–630why, one step back
628 cert: CertTypes = None,
629 verify: VerifyTypes = None,630 timeout: TimeoutTypes = None,

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

lines 631–635why, one step back
631 ) -> SyncResponse:
632 return self.request(633 "HEAD",634 url,635 headers=headers,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 640–641why, one step back
640 verify=verify,
641 cert=cert,

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

lines 642–649why, one step back
642 timeout=timeout,
643 )644645 def post(646 self,647 url: URLTypes,648 *,649 data: RequestData = b"",

Add json interfacesTom Christiebefore adoption5a63d31

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

query_params -> paramsTom Christiebefore adoptionbb70377

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

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

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 657–659why, one step back
657 cert: CertTypes = None,
658 verify: VerifyTypes = None,659 timeout: TimeoutTypes = None,

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

lines 660–664why, one step back
660 ) -> SyncResponse:
661 return self.request(662 "POST",663 url,664 data=data,

Add json interfacesTom Christiebefore adoption5a63d31

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

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

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 671–672why, one step back
671 verify=verify,
672 cert=cert,

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

lines 673–680why, one step back
673 timeout=timeout,
674 )675676 def put(677 self,678 url: URLTypes,679 *,680 data: RequestData = b"",

Add json interfacesTom Christiebefore adoption5a63d31

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

query_params -> paramsTom Christiebefore adoptionbb70377

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

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

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 688–690why, one step back
688 cert: CertTypes = None,
689 verify: VerifyTypes = None,690 timeout: TimeoutTypes = None,

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

lines 691–695why, one step back
691 ) -> SyncResponse:
692 return self.request(693 "PUT",694 url,695 data=data,

Add json interfacesTom Christiebefore adoption5a63d31

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

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

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 702–703why, one step back
702 verify=verify,
703 cert=cert,

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

lines 704–711why, one step back
704 timeout=timeout,
705 )706707 def patch(708 self,709 url: URLTypes,710 *,711 data: RequestData = b"",

Add json interfacesTom Christiebefore adoption5a63d31

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

query_params -> paramsTom Christiebefore adoptionbb70377

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

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

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 719–721why, one step back
719 cert: CertTypes = None,
720 verify: VerifyTypes = None,721 timeout: TimeoutTypes = None,

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

lines 722–726why, one step back
722 ) -> SyncResponse:
723 return self.request(724 "PATCH",725 url,726 data=data,

Add json interfacesTom Christiebefore adoption5a63d31

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

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

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 733–734why, one step back
733 verify=verify,
734 cert=cert,

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

lines 735–742why, one step back
735 timeout=timeout,
736 )737738 def delete(739 self,740 url: URLTypes,741 *,742 data: RequestData = b"",

Add json interfacesTom Christiebefore adoption5a63d31

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

query_params -> paramsTom Christiebefore adoptionbb70377

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

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

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 750–752why, one step back
750 cert: CertTypes = None,
751 verify: VerifyTypes = None,752 timeout: TimeoutTypes = None,

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

lines 753–757why, one step back
753 ) -> SyncResponse:
754 return self.request(755 "DELETE",756 url,757 data=data,

Add json interfacesTom Christiebefore adoption5a63d31

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

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

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 764–765why, one step back
764 verify=verify,
765 cert=cert,

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

lines 766–776why, one step back
766 timeout=timeout,
767 )768769 def prepare_request(self, request: Request) -> None:770 self._client.prepare_request(request)771772 def send(773 self,774 request: Request,775 *,776 stream: bool = False,

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 779–781why, one step back
779 verify: VerifyTypes = None,
780 cert: CertTypes = None,781 timeout: TimeoutTypes = None,

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

lines 782–786why, one step back
782 ) -> SyncResponse:
783 response = self._loop.run_until_complete(784 self._client.send(785 request,786 stream=stream,

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 789–790why, one step back
789 verify=verify,
790 cert=cert,

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

lines 791–808why, one step back
791 timeout=timeout,
792 )793 )794 return SyncResponse(response, self._loop)795796 def close(self) -> None:797 self._loop.run_until_complete(self._client.close())798799 def __enter__(self) -> "Client":800 return self801802 def __exit__(803 self,804 exc_type: typing.Type[BaseException] = None,805 exc_value: BaseException = None,806 traceback: TracebackType = None,807 ) -> None:808 self.close()