Skip to content
Myr

client.py

This file

Path

httpcore/client.py

800 lines · 22.3 KiB · Python

Last changed by

Drop prepare_requestTom Christiebefore adoption37da9ed

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–302why, one step back
299 )
300 response = await self.send(301 request,302 stream=stream,

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

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

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

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

lines 307–310why, one step back
307 timeout=timeout,
308 )309 return response310

query_params -> paramsTom Christiebefore adoptionbb70377

lines 311–313why, one step back
311 def merge_cookies(
312 self, cookies: CookieTypes = None313 ) -> typing.Optional[CookieTypes]:

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

lines 314–319why, one step back
314 if cookies or self.cookies:
315 merged_cookies = Cookies(self.cookies)316 merged_cookies.update(cookies)317 return merged_cookies318 return cookies319

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

lines 320–324why, one step back
320 async def send(
321 self,322 request: Request,323 *,324 stream: bool = False,

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

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

lines 327–329why, one step back
327 verify: VerifyTypes = None,
328 cert: CertTypes = None,329 timeout: TimeoutTypes = None,

Auth (#65)Tom Christiebefore adoption5afa7dd

lines 330–345why, one step back
330 ) -> Response:
331 if auth is None:332 auth = self.auth333334 url = request.url335 if auth is None and (url.username or url.password):336 auth = HTTPBasicAuth(username=url.username, password=url.password)337338 if auth is not None:339 if isinstance(auth, tuple):340 auth = HTTPBasicAuth(username=auth[0], password=auth[1])341 request = auth(request)342343 response = await self.send_handling_redirects(344 request,345 stream=stream,

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

lines 346–347why, one step back
346 verify=verify,
347 cert=cert,

Auth (#65)Tom Christiebefore adoption5afa7dd

lines 348–357why, one step back
348 timeout=timeout,
349 allow_redirects=allow_redirects,350 )351 return response352353 async def send_handling_redirects(354 self,355 request: Request,356 *,357 stream: bool = False,

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

lines 358–360why, one step back
358 cert: CertTypes = None,
359 verify: VerifyTypes = None,360 timeout: TimeoutTypes = None,

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

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

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

lines 364–365why, one step back
364 if history is None:
365 history = []

Finessing interfaceTom Christiebefore adoptiond7619a9

line 366why, one step back
366

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

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

Finessing interfaceTom Christiebefore adoptiond7619a9

line 374why, one step back
374

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

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

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

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

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

lines 377–378why, one step back
377 )
378 response.history = list(history)

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

lines 380–382why, one step back
380 history = [response] + history
381 if not response.is_redirect:382 break

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

line 383why, one step back
383

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

lines 384–388why, one step back
384 if allow_redirects:
385 request = self.build_redirect_request(request, response)386 else:387388 async def send_next() -> Response:

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

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

lines 392–394why, one step back
392 request,
393 stream=stream,394 allow_redirects=allow_redirects,

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

lines 395–396why, one step back
395 verify=verify,
396 cert=cert,

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

lines 397–411why, one step back
397 timeout=timeout,
398 history=history,399 )400 return response401402 response.next = send_next # type: ignore403 break404405 return response406407 def build_redirect_request(self, request: Request, response: Response) -> Request:408 method = self.redirect_method(request, response)409 url = self.redirect_url(request, response)410 headers = self.redirect_headers(request, url)411 content = self.redirect_content(request, method)

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

query_params -> paramsTom Christiebefore adoptionbb70377

lines 413–415why, one step back
413 return Request(
414 method=method, url=url, headers=headers, data=content, cookies=cookies415 )

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

lines 416–424why, one step back
416
417 def redirect_method(self, request: Request, response: Response) -> str:418 """419 When being redirected we may want to change the method of the request420 based on certain specs or browser behavior.421 """422 method = request.method423424 # https://tools.ietf.org/html/rfc7231#section-6.4.4

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

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

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

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

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

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

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

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

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

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

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

lines 436–478why, one step back
436 method = "GET"
437438 return method439440 def redirect_url(self, request: Request, response: Response) -> URL:441 """442 Return the URL for the redirect to follow.443 """444 location = response.headers["Location"]445446 url = URL(location, allow_relative=True)447448 # Facilitate relative 'Location' headers, as allowed by RFC 7231.449 # (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')450 if url.is_relative_url:451 url = url.resolve_with(request.url)452453 # Attach previous fragment if needed (RFC 7231 7.1.2)454 if request.url.fragment and not url.fragment:455 url = url.copy_with(fragment=request.url.fragment)456457 return url458459 def redirect_headers(self, request: Request, url: URL) -> Headers:460 """461 Strip Authorization headers when responses are redirected away from462 the origin.463 """464 headers = Headers(request.headers)465 if url.origin != request.url.origin:466 del headers["Authorization"]467 return headers468469 def redirect_content(self, request: Request, method: str) -> bytes:470 """471 Return the body that should be used for the redirect request.472 """473 if method != request.method and method == "GET":474 return b""475 if request.is_streaming:476 raise RedirectBodyUnavailable()477 return request.content478

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

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

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

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

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

line 481why, one step back
481

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

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

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

lines 483–491why, one step back
483 return self
484485 async def __aexit__(486 self,487 exc_type: typing.Type[BaseException] = None,488 exc_value: BaseException = None,489 traceback: TracebackType = None,490 ) -> None:491 await self.close()

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

lines 492–496why, one step back
492
493494class Client:495 def __init__(496 self,

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

lines 498–500why, one step back
498 cert: CertTypes = None,
499 verify: VerifyTypes = True,500 timeout: TimeoutTypes = DEFAULT_TIMEOUT_CONFIG,

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

lines 501–503why, one step back
501 pool_limits: PoolLimits = DEFAULT_POOL_LIMITS,
502 max_redirects: int = DEFAULT_MAX_REDIRECTS,503 dispatch: Dispatcher = None,

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

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

lines 508–509why, one step back
508 verify=verify,
509 cert=cert,

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

lines 510–513why, one step back
510 timeout=timeout,
511 pool_limits=pool_limits,512 max_redirects=max_redirects,513 dispatch=dispatch,

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

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

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

lines 515–517why, one step back
515 )
516 self._loop = asyncio.new_event_loop()517

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

lines 518–521why, one step back
518 @property
519 def cookies(self) -> Cookies:520 return self._client.cookies521

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

lines 522–527why, one step back
522 def request(
523 self,524 method: str,525 url: URLTypes,526 *,527 data: RequestData = b"",

Add json interfacesTom Christiebefore adoption5a63d31

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

query_params -> paramsTom Christiebefore adoptionbb70377

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

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

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

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

lines 535–537why, one step back
535 cert: CertTypes = None,
536 verify: VerifyTypes = None,537 timeout: TimeoutTypes = None,

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

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

lines 540–542why, one step back
540 method,
541 url,542 data=data,

Add json interfacesTom Christiebefore adoption5a63d31

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

query_params -> paramsTom Christiebefore adoptionbb70377

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

lines 547–550why, one step back
547 )
548 response = self.send(549 request,550 stream=stream,

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

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

lines 553–554why, one step back
553 verify=verify,
554 cert=cert,

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

lines 555–562why, one step back
555 timeout=timeout,
556 )557 return response558559 def get(560 self,561 url: URLTypes,562 *,

query_params -> paramsTom Christiebefore adoptionbb70377

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

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

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

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

lines 569–571why, one step back
569 cert: CertTypes = None,
570 verify: VerifyTypes = None,571 timeout: TimeoutTypes = None,

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

lines 572–576why, one step back
572 ) -> SyncResponse:
573 return self.request(574 "GET",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

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

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

lines 581–582why, one step back
581 verify=verify,
582 cert=cert,

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

lines 583–589why, one step back
583 timeout=timeout,
584 )585586 def options(587 self,588 url: URLTypes,589 *,

query_params -> paramsTom Christiebefore adoptionbb70377

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

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

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

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

lines 596–598why, one step back
596 cert: CertTypes = None,
597 verify: VerifyTypes = None,598 timeout: TimeoutTypes = None,

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

lines 599–603why, one step back
599 ) -> SyncResponse:
600 return self.request(601 "OPTIONS",602 url,603 headers=headers,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

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

lines 608–609why, one step back
608 verify=verify,
609 cert=cert,

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

lines 610–616why, one step back
610 timeout=timeout,
611 )612613 def head(614 self,615 url: URLTypes,616 *,

query_params -> paramsTom Christiebefore adoptionbb70377

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

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

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

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

lines 623–625why, one step back
623 cert: CertTypes = None,
624 verify: VerifyTypes = None,625 timeout: TimeoutTypes = None,

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

lines 626–630why, one step back
626 ) -> SyncResponse:
627 return self.request(628 "HEAD",629 url,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

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

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

lines 635–636why, one step back
635 verify=verify,
636 cert=cert,

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

lines 637–644why, one step back
637 timeout=timeout,
638 )639640 def post(641 self,642 url: URLTypes,643 *,644 data: RequestData = b"",

Add json interfacesTom Christiebefore adoption5a63d31

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

query_params -> paramsTom Christiebefore adoptionbb70377

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

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

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

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

lines 652–654why, one step back
652 cert: CertTypes = None,
653 verify: VerifyTypes = None,654 timeout: TimeoutTypes = None,

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

lines 655–659why, one step back
655 ) -> SyncResponse:
656 return self.request(657 "POST",658 url,659 data=data,

Add json interfacesTom Christiebefore adoption5a63d31

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

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

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

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

lines 666–667why, one step back
666 verify=verify,
667 cert=cert,

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

lines 668–675why, one step back
668 timeout=timeout,
669 )670671 def put(672 self,673 url: URLTypes,674 *,675 data: RequestData = b"",

Add json interfacesTom Christiebefore adoption5a63d31

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

query_params -> paramsTom Christiebefore adoptionbb70377

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

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

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

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

lines 683–685why, one step back
683 cert: CertTypes = None,
684 verify: VerifyTypes = None,685 timeout: TimeoutTypes = None,

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

lines 686–690why, one step back
686 ) -> SyncResponse:
687 return self.request(688 "PUT",689 url,690 data=data,

Add json interfacesTom Christiebefore adoption5a63d31

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

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

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

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

lines 697–698why, one step back
697 verify=verify,
698 cert=cert,

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

lines 699–706why, one step back
699 timeout=timeout,
700 )701702 def patch(703 self,704 url: URLTypes,705 *,706 data: RequestData = b"",

Add json interfacesTom Christiebefore adoption5a63d31

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

query_params -> paramsTom Christiebefore adoptionbb70377

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

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

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

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

lines 714–716why, one step back
714 cert: CertTypes = None,
715 verify: VerifyTypes = None,716 timeout: TimeoutTypes = None,

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

lines 717–721why, one step back
717 ) -> SyncResponse:
718 return self.request(719 "PATCH",720 url,721 data=data,

Add json interfacesTom Christiebefore adoption5a63d31

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

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

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

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

lines 728–729why, one step back
728 verify=verify,
729 cert=cert,

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

lines 730–737why, one step back
730 timeout=timeout,
731 )732733 def delete(734 self,735 url: URLTypes,736 *,737 data: RequestData = b"",

Add json interfacesTom Christiebefore adoption5a63d31

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

query_params -> paramsTom Christiebefore adoptionbb70377

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

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

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

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

lines 745–747why, one step back
745 cert: CertTypes = None,
746 verify: VerifyTypes = None,747 timeout: TimeoutTypes = None,

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

lines 748–752why, one step back
748 ) -> SyncResponse:
749 return self.request(750 "DELETE",751 url,752 data=data,

Add json interfacesTom Christiebefore adoption5a63d31

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

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

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

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

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

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

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

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

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

lines 759–760why, one step back
759 verify=verify,
760 cert=cert,

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

lines 761–768why, one step back
761 timeout=timeout,
762 )763764 def send(765 self,766 request: Request,767 *,768 stream: bool = False,

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

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

lines 771–773why, one step back
771 verify: VerifyTypes = None,
772 cert: CertTypes = None,773 timeout: TimeoutTypes = None,

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

lines 774–778why, one step back
774 ) -> SyncResponse:
775 response = self._loop.run_until_complete(776 self._client.send(777 request,778 stream=stream,

Auth (#65)Tom Christiebefore adoption5afa7dd

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

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

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

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

lines 781–782why, one step back
781 verify=verify,
782 cert=cert,

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

lines 783–800why, one step back
783 timeout=timeout,
784 )785 )786 return SyncResponse(response, self._loop)787788 def close(self) -> None:789 self._loop.run_until_complete(self._client.close())790791 def __enter__(self) -> "Client":792 return self793794 def __exit__(795 self,796 exc_type: typing.Type[BaseException] = None,797 exc_value: BaseException = None,798 traceback: TracebackType = None,799 ) -> None:800 self.close()