client.py
This file
Path
httpcore/client.py
824 lines · 23.6 KiB · Python
Last changed by
Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
History of this fileTake it
Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
lines 1–3why, one step back1import typing2from types import TracebackType3Auth (#65)Tom Christiebefore adoption5afa7dd
line 4why, one step back4from .auth import HTTPBasicAuthSync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 5why, one step back5from .concurrency import AsyncioBackendMerge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
lines 6–9why, one step back6from .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 back10 CertTypes,Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
line 11why, one step back11 PoolLimits,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 12–13why, one step back12 TimeoutTypes,13 VerifyTypes,Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
lines 14–15why, one step back14)15from .dispatch.connection_pool import ConnectionPoolSync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 16why, one step back16from .dispatch.threaded import ThreadedDispatcherMerge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144
line 17why, one step back17from .exceptions import RedirectBodyUnavailable, RedirectLoop, TooManyRedirectsSync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 18why, one step back18from .interfaces import AsyncDispatcher, ConcurrencyBackend, DispatcherMerge pull request #42 from encode/query-paramsTom Christiebefore adoption3de0425
lines 19–20why, one step back19from .models import (20 URL,Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
lines 21–24why, one step back21 AsyncRequest,22 AsyncRequestData,23 AsyncResponse,24 AsyncResponseContent,Auth (#65)Tom Christiebefore adoption5afa7dd
line 25why, one step back25 AuthTypes,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
lines 26–27why, one step back26 Cookies,27 CookieTypes,Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144
line 28why, one step back28 Headers,Merge pull request #42 from encode/query-paramsTom Christiebefore adoption3de0425
lines 29–31why, one step back29 HeaderTypes,30 QueryParamTypes,31 Request,Merge pull request #44 from encode/request-dataTom Christiebefore adoption39a5c53
line 32why, one step back32 RequestData,Merge pull request #42 from encode/query-paramsTom Christiebefore adoption3de0425
line 33why, one step back33 Response,Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 34why, one step back34 ResponseContent,Merge pull request #42 from encode/query-paramsTom Christiebefore adoption3de0425
lines 35–36why, one step back35 URLTypes,36)Merge pull request #59 from encode/use-stdlib-status-codesTom Christiebefore adoptionafc8369
line 37why, one step back37from .status_codes import codesMerge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
lines 38–39why, one step back3839Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 40why, one step back40class BaseClient:Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
lines 41–42why, one step back41 def __init__(42 self,Auth (#65)Tom Christiebefore adoption5afa7dd
line 43why, one step back43 auth: AuthTypes = None,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 44why, one step back44 cookies: CookieTypes = None,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 45–47why, one step back45 verify: VerifyTypes = True,46 cert: CertTypes = None,47 timeout: TimeoutTypes = DEFAULT_TIMEOUT_CONFIG,Truckin' onTom Christiebefore adoption6b60d95
line 48why, one step back48 pool_limits: PoolLimits = DEFAULT_POOL_LIMITS,Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
line 49why, one step back49 max_redirects: int = DEFAULT_MAX_REDIRECTS,Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 50why, one step back50 dispatch: typing.Union[AsyncDispatcher, Dispatcher] = None,Merge pull request #60 from encode/concurrency-backend-classTom Christiebefore adoption3d997af
line 51why, one step back51 backend: ConcurrencyBackend = None,Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
line 52why, one step back52 ):Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
lines 53–55why, one step back53 if backend is None:54 backend = AsyncioBackend()55Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144
line 56why, one step back56 if dispatch is None:Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 57why, one step back57 async_dispatch = ConnectionPool(Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 58–62why, one step back58 verify=verify,59 cert=cert,60 timeout=timeout,61 pool_limits=pool_limits,62 backend=backend,Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
lines 63–67why, one step back63 ) # type: AsyncDispatcher64 elif isinstance(dispatch, Dispatcher):65 async_dispatch = ThreadedDispatcher(dispatch, backend)66 else:67 async_dispatch = dispatchMerge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
line 68why, one step back68Auth (#65)Tom Christiebefore adoption5afa7dd
line 69why, one step back69 self.auth = authCookie support (#73)Tom Christiebefore adoptionfeae0a8
line 70why, one step back70 self.cookies = Cookies(cookies)Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144
line 71why, one step back71 self.max_redirects = max_redirectsSync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
lines 72–73why, one step back72 self.dispatch = async_dispatch73 self.concurrency_backend = backendMerge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
line 74why, one step back74Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
lines 75–251why, one step back75 def merge_cookies(76 self, cookies: CookieTypes = None77 ) -> typing.Optional[CookieTypes]:78 if cookies or self.cookies:79 merged_cookies = Cookies(self.cookies)80 merged_cookies.update(cookies)81 return merged_cookies82 return cookies8384 async def send(85 self,86 request: AsyncRequest,87 *,88 stream: bool = False,89 auth: AuthTypes = None,90 allow_redirects: bool = True,91 verify: VerifyTypes = None,92 cert: CertTypes = None,93 timeout: TimeoutTypes = None,94 ) -> AsyncResponse:95 if auth is None:96 auth = self.auth9798 url = request.url99 if auth is None and (url.username or url.password):100 auth = HTTPBasicAuth(username=url.username, password=url.password)101102 if auth is not None:103 if isinstance(auth, tuple):104 auth = HTTPBasicAuth(username=auth[0], password=auth[1])105 request = auth(request)106107 response = await self.send_handling_redirects(108 request,109 verify=verify,110 cert=cert,111 timeout=timeout,112 allow_redirects=allow_redirects,113 )114115 if not stream:116 try:117 await response.read()118 finally:119 await response.close()120121 return response122123 async def send_handling_redirects(124 self,125 request: AsyncRequest,126 *,127 cert: CertTypes = None,128 verify: VerifyTypes = None,129 timeout: TimeoutTypes = None,130 allow_redirects: bool = True,131 history: typing.List[AsyncResponse] = None,132 ) -> AsyncResponse:133 if history is None:134 history = []135136 while True:137 # We perform these checks here, so that calls to `response.next()`138 # will raise redirect errors if appropriate.139 if len(history) > self.max_redirects:140 raise TooManyRedirects()141 if request.url in [response.url for response in history]:142 raise RedirectLoop()143144 response = await self.dispatch.send(145 request, verify=verify, cert=cert, timeout=timeout146 )147 assert isinstance(response, AsyncResponse)148 response.history = list(history)149 self.cookies.extract_cookies(response)150 history = [response] + history151 if not response.is_redirect:152 break153154 if allow_redirects:155 request = self.build_redirect_request(request, response)156 else:157158 async def send_next() -> AsyncResponse:159 nonlocal request, response, verify, cert, allow_redirects, timeout, history160 request = self.build_redirect_request(request, response)161 response = await self.send_handling_redirects(162 request,163 allow_redirects=allow_redirects,164 verify=verify,165 cert=cert,166 timeout=timeout,167 history=history,168 )169 return response170171 response.next = send_next # type: ignore172 break173174 return response175176 def build_redirect_request(177 self, request: AsyncRequest, response: AsyncResponse178 ) -> AsyncRequest:179 method = self.redirect_method(request, response)180 url = self.redirect_url(request, response)181 headers = self.redirect_headers(request, url)182 content = self.redirect_content(request, method)183 cookies = self.merge_cookies(request.cookies)184 return AsyncRequest(185 method=method, url=url, headers=headers, data=content, cookies=cookies186 )187188 def redirect_method(self, request: AsyncRequest, response: AsyncResponse) -> str:189 """190 When being redirected we may want to change the method of the request191 based on certain specs or browser behavior.192 """193 method = request.method194195 # https://tools.ietf.org/html/rfc7231#section-6.4.4196 if response.status_code == codes.SEE_OTHER and method != "HEAD":197 method = "GET"198199 # Do what the browsers do, despite standards...200 # Turn 302s into GETs.201 if response.status_code == codes.FOUND and method != "HEAD":202 method = "GET"203204 # If a POST is responded to with a 301, turn it into a GET.205 # This bizarre behaviour is explained in 'requests' issue 1704.206 if response.status_code == codes.MOVED_PERMANENTLY and method == "POST":207 method = "GET"208209 return method210211 def redirect_url(self, request: AsyncRequest, response: AsyncResponse) -> URL:212 """213 Return the URL for the redirect to follow.214 """215 location = response.headers["Location"]216217 url = URL(location, allow_relative=True)218219 # Facilitate relative 'Location' headers, as allowed by RFC 7231.220 # (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')221 if url.is_relative_url:222 url = url.resolve_with(request.url)223224 # Attach previous fragment if needed (RFC 7231 7.1.2)225 if request.url.fragment and not url.fragment:226 url = url.copy_with(fragment=request.url.fragment)227228 return url229230 def redirect_headers(self, request: AsyncRequest, url: URL) -> Headers:231 """232 Strip Authorization headers when responses are redirected away from233 the origin.234 """235 headers = Headers(request.headers)236 if url.origin != request.url.origin:237 del headers["Authorization"]238 return headers239240 def redirect_content(self, request: AsyncRequest, method: str) -> bytes:241 """242 Return the body that should be used for the redirect request.243 """244 if method != request.method and method == "GET":245 return b""246 if request.is_streaming:247 raise RedirectBodyUnavailable()248 return request.content249250251class AsyncClient(BaseClient):Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
lines 252–253why, one step back252 async def get(253 self,Finessing interfaceTom Christiebefore adoptiond7619a9
line 254why, one step back254 url: URLTypes,Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
line 255why, one step back255 *,query_params -> paramsTom Christiebefore adoptionbb70377
line 256why, one step back256 params: QueryParamTypes = None,Finessing interfaceTom Christiebefore adoptiond7619a9
line 257why, one step back257 headers: HeaderTypes = None,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 258why, one step back258 cookies: CookieTypes = None,Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
line 259why, one step back259 stream: bool = False,Auth (#65)Tom Christiebefore adoption5afa7dd
line 260why, one step back260 auth: AuthTypes = None,Finessing interfaceTom Christiebefore adoptiond7619a9
line 261why, one step back261 allow_redirects: bool = True,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 262–264why, one step back262 cert: CertTypes = None,263 verify: VerifyTypes = None,264 timeout: TimeoutTypes = None,Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 265why, one step back265 ) -> AsyncResponse:Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
line 266why, one step back266 return await self.request(Finessing interfaceTom Christiebefore adoptiond7619a9
lines 267–268why, one step back267 "GET",268 url,query_params -> paramsTom Christiebefore adoptionbb70377
line 269why, one step back269 params=params,Finessing interfaceTom Christiebefore adoptiond7619a9
line 270why, one step back270 headers=headers,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 271why, one step back271 cookies=cookies,Finessing interfaceTom Christiebefore adoptiond7619a9
line 272why, one step back272 stream=stream,Auth (#65)Tom Christiebefore adoption5afa7dd
line 273why, one step back273 auth=auth,Finessing interfaceTom Christiebefore adoptiond7619a9
line 274why, one step back274 allow_redirects=allow_redirects,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 275–276why, one step back275 verify=verify,276 cert=cert,Finessing interfaceTom Christiebefore adoptiond7619a9
line 277why, one step back277 timeout=timeout,Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
lines 278–279why, one step back278 )279Finessing interfaceTom Christiebefore adoptiond7619a9
lines 280–283why, one step back280 async def options(281 self,282 url: URLTypes,283 *,query_params -> paramsTom Christiebefore adoptionbb70377
line 284why, one step back284 params: QueryParamTypes = None,Finessing interfaceTom Christiebefore adoptiond7619a9
line 285why, one step back285 headers: HeaderTypes = None,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 286why, one step back286 cookies: CookieTypes = None,Finessing interfaceTom Christiebefore adoptiond7619a9
line 287why, one step back287 stream: bool = False,Auth (#65)Tom Christiebefore adoption5afa7dd
line 288why, one step back288 auth: AuthTypes = None,Finessing interfaceTom Christiebefore adoptiond7619a9
line 289why, one step back289 allow_redirects: bool = True,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 290–292why, one step back290 cert: CertTypes = None,291 verify: VerifyTypes = None,292 timeout: TimeoutTypes = None,Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 293why, one step back293 ) -> AsyncResponse:Finessing interfaceTom Christiebefore adoptiond7619a9
lines 294–296why, one step back294 return await self.request(295 "OPTIONS",296 url,query_params -> paramsTom Christiebefore adoptionbb70377
line 297why, one step back297 params=params,Finessing interfaceTom Christiebefore adoptiond7619a9
line 298why, one step back298 headers=headers,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 299why, one step back299 cookies=cookies,Finessing interfaceTom Christiebefore adoptiond7619a9
line 300why, one step back300 stream=stream,Auth (#65)Tom Christiebefore adoption5afa7dd
line 301why, one step back301 auth=auth,Finessing interfaceTom Christiebefore adoptiond7619a9
line 302why, one step back302 allow_redirects=allow_redirects,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 303–304why, one step back303 verify=verify,304 cert=cert,Finessing interfaceTom Christiebefore adoptiond7619a9
lines 305–311why, one step back305 timeout=timeout,306 )307308 async def head(309 self,310 url: URLTypes,311 *,query_params -> paramsTom Christiebefore adoptionbb70377
line 312why, one step back312 params: QueryParamTypes = None,Finessing interfaceTom Christiebefore adoptiond7619a9
line 313why, one step back313 headers: HeaderTypes = None,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 314why, one step back314 cookies: CookieTypes = None,Finessing interfaceTom Christiebefore adoptiond7619a9
line 315why, one step back315 stream: bool = False,Auth (#65)Tom Christiebefore adoption5afa7dd
line 316why, one step back316 auth: AuthTypes = None,Finessing interfaceTom Christiebefore adoptiond7619a9
line 317why, one step back317 allow_redirects: bool = False, # Note: Differs to usual default.Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 318–320why, one step back318 cert: CertTypes = None,319 verify: VerifyTypes = None,320 timeout: TimeoutTypes = None,Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 321why, one step back321 ) -> AsyncResponse:Finessing interfaceTom Christiebefore adoptiond7619a9
lines 322–324why, one step back322 return await self.request(323 "HEAD",324 url,query_params -> paramsTom Christiebefore adoptionbb70377
line 325why, one step back325 params=params,Finessing interfaceTom Christiebefore adoptiond7619a9
line 326why, one step back326 headers=headers,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 327why, one step back327 cookies=cookies,Finessing interfaceTom Christiebefore adoptiond7619a9
line 328why, one step back328 stream=stream,Auth (#65)Tom Christiebefore adoption5afa7dd
line 329why, one step back329 auth=auth,Finessing interfaceTom Christiebefore adoptiond7619a9
line 330why, one step back330 allow_redirects=allow_redirects,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 331–332why, one step back331 verify=verify,332 cert=cert,Finessing interfaceTom Christiebefore adoptiond7619a9
lines 333–335why, one step back333 timeout=timeout,334 )335Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
lines 336–337why, one step back336 async def post(337 self,Finessing interfaceTom Christiebefore adoptiond7619a9
line 338why, one step back338 url: URLTypes,Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
line 339why, one step back339 *,Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 340why, one step back340 data: AsyncRequestData = b"",Add json interfacesTom Christiebefore adoption5a63d31
line 341why, one step back341 json: typing.Any = None,query_params -> paramsTom Christiebefore adoptionbb70377
line 342why, one step back342 params: QueryParamTypes = None,Finessing interfaceTom Christiebefore adoptiond7619a9
line 343why, one step back343 headers: HeaderTypes = None,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 344why, one step back344 cookies: CookieTypes = None,Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
line 345why, one step back345 stream: bool = False,Auth (#65)Tom Christiebefore adoption5afa7dd
line 346why, one step back346 auth: AuthTypes = None,Finessing interfaceTom Christiebefore adoptiond7619a9
line 347why, one step back347 allow_redirects: bool = True,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 348–350why, one step back348 cert: CertTypes = None,349 verify: VerifyTypes = None,350 timeout: TimeoutTypes = None,Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 351why, one step back351 ) -> AsyncResponse:Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
lines 352–354why, one step back352 return await self.request(353 "POST",354 url,Merge pull request #44 from encode/request-dataTom Christiebefore adoption39a5c53
line 355why, one step back355 data=data,Add json interfacesTom Christiebefore adoption5a63d31
line 356why, one step back356 json=json,query_params -> paramsTom Christiebefore adoptionbb70377
line 357why, one step back357 params=params,Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
line 358why, one step back358 headers=headers,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 359why, one step back359 cookies=cookies,Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
line 360why, one step back360 stream=stream,Auth (#65)Tom Christiebefore adoption5afa7dd
line 361why, one step back361 auth=auth,Finessing interfaceTom Christiebefore adoptiond7619a9
line 362why, one step back362 allow_redirects=allow_redirects,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 363–364why, one step back363 verify=verify,364 cert=cert,Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
lines 365–367why, one step back365 timeout=timeout,366 )367Finessing interfaceTom Christiebefore adoptiond7619a9
lines 368–371why, one step back368 async def put(369 self,370 url: URLTypes,371 *,Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 372why, one step back372 data: AsyncRequestData = b"",Add json interfacesTom Christiebefore adoption5a63d31
line 373why, one step back373 json: typing.Any = None,query_params -> paramsTom Christiebefore adoptionbb70377
line 374why, one step back374 params: QueryParamTypes = None,Finessing interfaceTom Christiebefore adoptiond7619a9
line 375why, one step back375 headers: HeaderTypes = None,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 376why, one step back376 cookies: CookieTypes = None,Finessing interfaceTom Christiebefore adoptiond7619a9
line 377why, one step back377 stream: bool = False,Auth (#65)Tom Christiebefore adoption5afa7dd
line 378why, one step back378 auth: AuthTypes = None,Finessing interfaceTom Christiebefore adoptiond7619a9
line 379why, one step back379 allow_redirects: bool = True,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 380–382why, one step back380 cert: CertTypes = None,381 verify: VerifyTypes = None,382 timeout: TimeoutTypes = None,Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 383why, one step back383 ) -> AsyncResponse:Finessing interfaceTom Christiebefore adoptiond7619a9
lines 384–386why, one step back384 return await self.request(385 "PUT",386 url,Merge pull request #44 from encode/request-dataTom Christiebefore adoption39a5c53
line 387why, one step back387 data=data,Add json interfacesTom Christiebefore adoption5a63d31
line 388why, one step back388 json=json,query_params -> paramsTom Christiebefore adoptionbb70377
line 389why, one step back389 params=params,Finessing interfaceTom Christiebefore adoptiond7619a9
line 390why, one step back390 headers=headers,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 391why, one step back391 cookies=cookies,Finessing interfaceTom Christiebefore adoptiond7619a9
line 392why, one step back392 stream=stream,Auth (#65)Tom Christiebefore adoption5afa7dd
line 393why, one step back393 auth=auth,Finessing interfaceTom Christiebefore adoptiond7619a9
line 394why, one step back394 allow_redirects=allow_redirects,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 395–396why, one step back395 verify=verify,396 cert=cert,Finessing interfaceTom Christiebefore adoptiond7619a9
lines 397–403why, one step back397 timeout=timeout,398 )399400 async def patch(401 self,402 url: URLTypes,403 *,Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 404why, one step back404 data: AsyncRequestData = b"",Add json interfacesTom Christiebefore adoption5a63d31
line 405why, one step back405 json: typing.Any = None,query_params -> paramsTom Christiebefore adoptionbb70377
line 406why, one step back406 params: QueryParamTypes = None,Finessing interfaceTom Christiebefore adoptiond7619a9
line 407why, one step back407 headers: HeaderTypes = None,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 408why, one step back408 cookies: CookieTypes = None,Finessing interfaceTom Christiebefore adoptiond7619a9
line 409why, one step back409 stream: bool = False,Auth (#65)Tom Christiebefore adoption5afa7dd
line 410why, one step back410 auth: AuthTypes = None,Finessing interfaceTom Christiebefore adoptiond7619a9
line 411why, one step back411 allow_redirects: bool = True,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 412–414why, one step back412 cert: CertTypes = None,413 verify: VerifyTypes = None,414 timeout: TimeoutTypes = None,Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 415why, one step back415 ) -> AsyncResponse:Finessing interfaceTom Christiebefore adoptiond7619a9
lines 416–418why, one step back416 return await self.request(417 "PATCH",418 url,Merge pull request #44 from encode/request-dataTom Christiebefore adoption39a5c53
line 419why, one step back419 data=data,Add json interfacesTom Christiebefore adoption5a63d31
line 420why, one step back420 json=json,query_params -> paramsTom Christiebefore adoptionbb70377
line 421why, one step back421 params=params,Finessing interfaceTom Christiebefore adoptiond7619a9
line 422why, one step back422 headers=headers,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 423why, one step back423 cookies=cookies,Finessing interfaceTom Christiebefore adoptiond7619a9
line 424why, one step back424 stream=stream,Auth (#65)Tom Christiebefore adoption5afa7dd
line 425why, one step back425 auth=auth,Finessing interfaceTom Christiebefore adoptiond7619a9
line 426why, one step back426 allow_redirects=allow_redirects,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 427–428why, one step back427 verify=verify,428 cert=cert,Finessing interfaceTom Christiebefore adoptiond7619a9
lines 429–435why, one step back429 timeout=timeout,430 )431432 async def delete(433 self,434 url: URLTypes,435 *,Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 436why, one step back436 data: AsyncRequestData = b"",Add json interfacesTom Christiebefore adoption5a63d31
line 437why, one step back437 json: typing.Any = None,query_params -> paramsTom Christiebefore adoptionbb70377
line 438why, one step back438 params: QueryParamTypes = None,Finessing interfaceTom Christiebefore adoptiond7619a9
line 439why, one step back439 headers: HeaderTypes = None,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 440why, one step back440 cookies: CookieTypes = None,Finessing interfaceTom Christiebefore adoptiond7619a9
line 441why, one step back441 stream: bool = False,Auth (#65)Tom Christiebefore adoption5afa7dd
line 442why, one step back442 auth: AuthTypes = None,Finessing interfaceTom Christiebefore adoptiond7619a9
line 443why, one step back443 allow_redirects: bool = True,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 444–446why, one step back444 cert: CertTypes = None,445 verify: VerifyTypes = None,446 timeout: TimeoutTypes = None,Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 447why, one step back447 ) -> AsyncResponse:Finessing interfaceTom Christiebefore adoptiond7619a9
lines 448–450why, one step back448 return await self.request(449 "DELETE",450 url,Merge pull request #44 from encode/request-dataTom Christiebefore adoption39a5c53
line 451why, one step back451 data=data,Add json interfacesTom Christiebefore adoption5a63d31
line 452why, one step back452 json=json,query_params -> paramsTom Christiebefore adoptionbb70377
line 453why, one step back453 params=params,Finessing interfaceTom Christiebefore adoptiond7619a9
line 454why, one step back454 headers=headers,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 455why, one step back455 cookies=cookies,Finessing interfaceTom Christiebefore adoptiond7619a9
line 456why, one step back456 stream=stream,Auth (#65)Tom Christiebefore adoption5afa7dd
line 457why, one step back457 auth=auth,Finessing interfaceTom Christiebefore adoptiond7619a9
line 458why, one step back458 allow_redirects=allow_redirects,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 459–460why, one step back459 verify=verify,460 cert=cert,Finessing interfaceTom Christiebefore adoptiond7619a9
lines 461–463why, one step back461 timeout=timeout,462 )463Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144
lines 464–468why, one step back464 async def request(465 self,466 method: str,467 url: URLTypes,468 *,Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 469why, one step back469 data: AsyncRequestData = b"",Add json interfacesTom Christiebefore adoption5a63d31
line 470why, one step back470 json: typing.Any = None,query_params -> paramsTom Christiebefore adoptionbb70377
line 471why, one step back471 params: QueryParamTypes = None,Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144
line 472why, one step back472 headers: HeaderTypes = None,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 473why, one step back473 cookies: CookieTypes = None,Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144
line 474why, one step back474 stream: bool = False,Auth (#65)Tom Christiebefore adoption5afa7dd
line 475why, one step back475 auth: AuthTypes = None,Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144
line 476why, one step back476 allow_redirects: bool = True,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 477–479why, one step back477 cert: CertTypes = None,478 verify: VerifyTypes = None,479 timeout: TimeoutTypes = None,Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
lines 480–481why, one step back480 ) -> AsyncResponse:481 request = AsyncRequest(Cookie support (#73)Tom Christiebefore adoptionfeae0a8
lines 482–484why, one step back482 method,483 url,484 data=data,Add json interfacesTom Christiebefore adoption5a63d31
line 485why, one step back485 json=json,query_params -> paramsTom Christiebefore adoptionbb70377
line 486why, one step back486 params=params,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
lines 487–488why, one step back487 headers=headers,488 cookies=self.merge_cookies(cookies),Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144
lines 489–492why, one step back489 )490 response = await self.send(491 request,492 stream=stream,Auth (#65)Tom Christiebefore adoption5afa7dd
line 493why, one step back493 auth=auth,Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144
line 494why, one step back494 allow_redirects=allow_redirects,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 495–496why, one step back495 verify=verify,496 cert=cert,Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144
lines 497–500why, one step back497 timeout=timeout,498 )499 return response500Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
line 501why, one step back501 async def close(self) -> None:Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144
line 502why, one step back502 await self.dispatch.close()Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
line 503why, one step back503Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 504why, one step back504 async def __aenter__(self) -> "AsyncClient":Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
lines 505–513why, one step back505 return self506507 async def __aexit__(508 self,509 exc_type: typing.Type[BaseException] = None,510 exc_value: BaseException = None,511 traceback: TracebackType = None,512 ) -> None:513 await self.close()Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
lines 514–515why, one step back514515Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
lines 516–523why, one step back516class Client(BaseClient):517 def _async_request_data(self, data: RequestData) -> AsyncRequestData:518 """519 If the request data is an bytes iterator then return an async bytes520 iterator onto the request data.521 """522 if isinstance(data, (bytes, dict)):523 return dataMerge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 524why, one step back524Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
lines 525–528why, one step back525 # Coerce an iterator into an async iterator, with each item in the526 # iteration running as a thread-pooled operation.527 assert hasattr(data, "__iter__")528 return self.concurrency_backend.iterate_in_threadpool(data)Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 529why, one step back529Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
lines 530–538why, one step back530 def _sync_data(self, data: AsyncResponseContent) -> ResponseContent:531 if isinstance(data, bytes):532 return data533534 # Coerce an async iterator into an iterator, with each item in the535 # iteration run within the event loop.536 assert hasattr(data, "__aiter__")537 return self.concurrency_backend.iterate(data)538Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
lines 539–544why, one step back539 def request(540 self,541 method: str,542 url: URLTypes,543 *,544 data: RequestData = b"",Add json interfacesTom Christiebefore adoption5a63d31
line 545why, one step back545 json: typing.Any = None,query_params -> paramsTom Christiebefore adoptionbb70377
line 546why, one step back546 params: QueryParamTypes = None,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 547why, one step back547 headers: HeaderTypes = None,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 548why, one step back548 cookies: CookieTypes = None,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 549why, one step back549 stream: bool = False,Auth (#65)Tom Christiebefore adoption5afa7dd
line 550why, one step back550 auth: AuthTypes = None,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 551why, one step back551 allow_redirects: bool = True,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 552–554why, one step back552 cert: CertTypes = None,553 verify: VerifyTypes = None,554 timeout: TimeoutTypes = None,Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
lines 555–556why, one step back555 ) -> Response:556 request = AsyncRequest(Cookie support (#73)Tom Christiebefore adoptionfeae0a8
lines 557–558why, one step back557 method,558 url,Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 559why, one step back559 data=self._async_request_data(data),Add json interfacesTom Christiebefore adoption5a63d31
line 560why, one step back560 json=json,query_params -> paramsTom Christiebefore adoptionbb70377
line 561why, one step back561 params=params,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 562why, one step back562 headers=headers,Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 563why, one step back563 cookies=self.merge_cookies(cookies),Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 564why, one step back564 )Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
lines 565–570why, one step back565 concurrency_backend = self.concurrency_backend566567 coroutine = self.send568 args = [request]569 kwargs = dict(570 stream=True,Auth (#65)Tom Christiebefore adoption5afa7dd
line 571why, one step back571 auth=auth,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 572why, one step back572 allow_redirects=allow_redirects,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 573–574why, one step back573 verify=verify,574 cert=cert,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
lines 575–576why, one step back575 timeout=timeout,576 )Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
lines 577–603why, one step back577 async_response = concurrency_backend.run(coroutine, *args, **kwargs)578579 content = getattr(580 async_response, "_raw_content", getattr(async_response, "_raw_stream", None)581 )582583 sync_content = self._sync_data(content)584585 def sync_on_close() -> None:586 nonlocal concurrency_backend, async_response587 concurrency_backend.run(async_response.on_close)588589 response = Response(590 status_code=async_response.status_code,591 reason_phrase=async_response.reason_phrase,592 protocol=async_response.protocol,593 headers=async_response.headers,594 content=sync_content,595 on_close=sync_on_close,596 request=async_response.request,597 history=async_response.history,598 )599 if not stream:600 try:601 response.read()602 finally:603 response.close()Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
lines 604–609why, one step back604 return response605606 def get(607 self,608 url: URLTypes,609 *,query_params -> paramsTom Christiebefore adoptionbb70377
line 610why, one step back610 params: QueryParamTypes = None,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 611why, one step back611 headers: HeaderTypes = None,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 612why, one step back612 cookies: CookieTypes = None,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 613why, one step back613 stream: bool = False,Auth (#65)Tom Christiebefore adoption5afa7dd
line 614why, one step back614 auth: AuthTypes = None,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 615why, one step back615 allow_redirects: bool = True,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 616–618why, one step back616 cert: CertTypes = None,617 verify: VerifyTypes = None,618 timeout: TimeoutTypes = None,Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 619why, one step back619 ) -> Response:Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
lines 620–623why, one step back620 return self.request(621 "GET",622 url,623 headers=headers,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 624why, one step back624 cookies=cookies,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 625why, one step back625 stream=stream,Auth (#65)Tom Christiebefore adoption5afa7dd
line 626why, one step back626 auth=auth,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 627why, one step back627 allow_redirects=allow_redirects,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 628–629why, one step back628 verify=verify,629 cert=cert,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
lines 630–636why, one step back630 timeout=timeout,631 )632633 def options(634 self,635 url: URLTypes,636 *,query_params -> paramsTom Christiebefore adoptionbb70377
line 637why, one step back637 params: QueryParamTypes = None,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 638why, one step back638 headers: HeaderTypes = None,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 639why, one step back639 cookies: CookieTypes = None,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 640why, one step back640 stream: bool = False,Auth (#65)Tom Christiebefore adoption5afa7dd
line 641why, one step back641 auth: AuthTypes = None,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 642why, one step back642 allow_redirects: bool = True,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 643–645why, one step back643 cert: CertTypes = None,644 verify: VerifyTypes = None,645 timeout: TimeoutTypes = None,Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 646why, one step back646 ) -> Response:Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
lines 647–650why, one step back647 return self.request(648 "OPTIONS",649 url,650 headers=headers,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 651why, one step back651 cookies=cookies,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 652why, one step back652 stream=stream,Auth (#65)Tom Christiebefore adoption5afa7dd
line 653why, one step back653 auth=auth,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 654why, one step back654 allow_redirects=allow_redirects,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 655–656why, one step back655 verify=verify,656 cert=cert,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
lines 657–663why, one step back657 timeout=timeout,658 )659660 def head(661 self,662 url: URLTypes,663 *,query_params -> paramsTom Christiebefore adoptionbb70377
line 664why, one step back664 params: QueryParamTypes = None,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 665why, one step back665 headers: HeaderTypes = None,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 666why, one step back666 cookies: CookieTypes = None,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 667why, one step back667 stream: bool = False,Auth (#65)Tom Christiebefore adoption5afa7dd
line 668why, one step back668 auth: AuthTypes = None,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 669why, one step back669 allow_redirects: bool = False, # Note: Differs to usual default.Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 670–672why, one step back670 cert: CertTypes = None,671 verify: VerifyTypes = None,672 timeout: TimeoutTypes = None,Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 673why, one step back673 ) -> Response:Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
lines 674–677why, one step back674 return self.request(675 "HEAD",676 url,677 headers=headers,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 678why, one step back678 cookies=cookies,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 679why, one step back679 stream=stream,Auth (#65)Tom Christiebefore adoption5afa7dd
line 680why, one step back680 auth=auth,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 681why, one step back681 allow_redirects=allow_redirects,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 682–683why, one step back682 verify=verify,683 cert=cert,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
lines 684–691why, one step back684 timeout=timeout,685 )686687 def post(688 self,689 url: URLTypes,690 *,691 data: RequestData = b"",Add json interfacesTom Christiebefore adoption5a63d31
line 692why, one step back692 json: typing.Any = None,query_params -> paramsTom Christiebefore adoptionbb70377
line 693why, one step back693 params: QueryParamTypes = None,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 694why, one step back694 headers: HeaderTypes = None,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 695why, one step back695 cookies: CookieTypes = None,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 696why, one step back696 stream: bool = False,Auth (#65)Tom Christiebefore adoption5afa7dd
line 697why, one step back697 auth: AuthTypes = None,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 698why, one step back698 allow_redirects: bool = True,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 699–701why, one step back699 cert: CertTypes = None,700 verify: VerifyTypes = None,701 timeout: TimeoutTypes = None,Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 702why, one step back702 ) -> Response:Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
lines 703–706why, one step back703 return self.request(704 "POST",705 url,706 data=data,Add json interfacesTom Christiebefore adoption5a63d31
line 707why, one step back707 json=json,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 708why, one step back708 headers=headers,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 709why, one step back709 cookies=cookies,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 710why, one step back710 stream=stream,Auth (#65)Tom Christiebefore adoption5afa7dd
line 711why, one step back711 auth=auth,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 712why, one step back712 allow_redirects=allow_redirects,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 713–714why, one step back713 verify=verify,714 cert=cert,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
lines 715–722why, one step back715 timeout=timeout,716 )717718 def put(719 self,720 url: URLTypes,721 *,722 data: RequestData = b"",Add json interfacesTom Christiebefore adoption5a63d31
line 723why, one step back723 json: typing.Any = None,query_params -> paramsTom Christiebefore adoptionbb70377
line 724why, one step back724 params: QueryParamTypes = None,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 725why, one step back725 headers: HeaderTypes = None,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 726why, one step back726 cookies: CookieTypes = None,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 727why, one step back727 stream: bool = False,Auth (#65)Tom Christiebefore adoption5afa7dd
line 728why, one step back728 auth: AuthTypes = None,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 729why, one step back729 allow_redirects: bool = True,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 730–732why, one step back730 cert: CertTypes = None,731 verify: VerifyTypes = None,732 timeout: TimeoutTypes = None,Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 733why, one step back733 ) -> Response:Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
lines 734–737why, one step back734 return self.request(735 "PUT",736 url,737 data=data,Add json interfacesTom Christiebefore adoption5a63d31
line 738why, one step back738 json=json,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 739why, one step back739 headers=headers,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 740why, one step back740 cookies=cookies,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 741why, one step back741 stream=stream,Auth (#65)Tom Christiebefore adoption5afa7dd
line 742why, one step back742 auth=auth,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 743why, one step back743 allow_redirects=allow_redirects,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 744–745why, one step back744 verify=verify,745 cert=cert,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
lines 746–753why, one step back746 timeout=timeout,747 )748749 def patch(750 self,751 url: URLTypes,752 *,753 data: RequestData = b"",Add json interfacesTom Christiebefore adoption5a63d31
line 754why, one step back754 json: typing.Any = None,query_params -> paramsTom Christiebefore adoptionbb70377
line 755why, one step back755 params: QueryParamTypes = None,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 756why, one step back756 headers: HeaderTypes = None,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 757why, one step back757 cookies: CookieTypes = None,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 758why, one step back758 stream: bool = False,Auth (#65)Tom Christiebefore adoption5afa7dd
line 759why, one step back759 auth: AuthTypes = None,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 760why, one step back760 allow_redirects: bool = True,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 761–763why, one step back761 cert: CertTypes = None,762 verify: VerifyTypes = None,763 timeout: TimeoutTypes = None,Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 764why, one step back764 ) -> Response:Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
lines 765–768why, one step back765 return self.request(766 "PATCH",767 url,768 data=data,Add json interfacesTom Christiebefore adoption5a63d31
line 769why, one step back769 json=json,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 770why, one step back770 headers=headers,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 771why, one step back771 cookies=cookies,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 772why, one step back772 stream=stream,Auth (#65)Tom Christiebefore adoption5afa7dd
line 773why, one step back773 auth=auth,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 774why, one step back774 allow_redirects=allow_redirects,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 775–776why, one step back775 verify=verify,776 cert=cert,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
lines 777–784why, one step back777 timeout=timeout,778 )779780 def delete(781 self,782 url: URLTypes,783 *,784 data: RequestData = b"",Add json interfacesTom Christiebefore adoption5a63d31
line 785why, one step back785 json: typing.Any = None,query_params -> paramsTom Christiebefore adoptionbb70377
line 786why, one step back786 params: QueryParamTypes = None,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 787why, one step back787 headers: HeaderTypes = None,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 788why, one step back788 cookies: CookieTypes = None,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 789why, one step back789 stream: bool = False,Auth (#65)Tom Christiebefore adoption5afa7dd
line 790why, one step back790 auth: AuthTypes = None,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 791why, one step back791 allow_redirects: bool = True,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 792–794why, one step back792 cert: CertTypes = None,793 verify: VerifyTypes = None,794 timeout: TimeoutTypes = None,Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 795why, one step back795 ) -> Response:Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
lines 796–799why, one step back796 return self.request(797 "DELETE",798 url,799 data=data,Add json interfacesTom Christiebefore adoption5a63d31
line 800why, one step back800 json=json,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 801why, one step back801 headers=headers,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 802why, one step back802 cookies=cookies,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 803why, one step back803 stream=stream,Auth (#65)Tom Christiebefore adoption5afa7dd
line 804why, one step back804 auth=auth,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 805why, one step back805 allow_redirects=allow_redirects,Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 806–807why, one step back806 verify=verify,807 cert=cert,Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
lines 808–811why, one step back808 timeout=timeout,809 )810811 def close(self) -> None:Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
lines 812–813why, one step back812 coroutine = self.dispatch.close813 self.concurrency_backend.run(coroutine)Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
lines 814–824why, one step back814815 def __enter__(self) -> "Client":816 return self817818 def __exit__(819 self,820 exc_type: typing.Type[BaseException] = None,821 exc_value: BaseException = None,822 traceback: TracebackType = None,823 ) -> None:824 self.close()