client.py
This file
Path
http3/client.py
871 lines · 25.0 KiB · Python
Last changed by
Support WSGI and ASGI apps. (#94)Tom Christiebefore adoptionbb86970
History of this fileTake it
Support WSGI and ASGI apps. (#94)Tom Christiebefore adoptionbb86970
line 1why, one step back1import inspecthttp3 (#86)Tom Christiebefore adoptionc9747aa
lines 2–15why, one step back2import typing3from types import TracebackType45from .auth import HTTPBasicAuth6from .concurrency import AsyncioBackend7from .config import (8 DEFAULT_MAX_REDIRECTS,9 DEFAULT_POOL_LIMITS,10 DEFAULT_TIMEOUT_CONFIG,11 CertTypes,12 PoolLimits,13 TimeoutTypes,14 VerifyTypes,15)Support WSGI and ASGI apps. (#94)Tom Christiebefore adoptionbb86970
line 16why, one step back16from .dispatch.asgi import ASGIDispatchhttp3 (#86)Tom Christiebefore adoptionc9747aa
lines 17–18why, one step back17from .dispatch.connection_pool import ConnectionPool18from .dispatch.threaded import ThreadedDispatcherSupport WSGI and ASGI apps. (#94)Tom Christiebefore adoptionbb86970
line 19why, one step back19from .dispatch.wsgi import WSGIDispatchhttp3 (#86)Tom Christiebefore adoptionc9747aa
lines 20–35why, one step back20from .exceptions import RedirectBodyUnavailable, RedirectLoop, TooManyRedirects21from .interfaces import AsyncDispatcher, ConcurrencyBackend, Dispatcher22from .models import (23 URL,24 AsyncRequest,25 AsyncRequestData,26 AsyncResponse,27 AsyncResponseContent,28 AuthTypes,29 Cookies,30 CookieTypes,31 Headers,32 HeaderTypes,33 QueryParamTypes,34 Request,35 RequestData,Multipart support (#90)Tom Christiebefore adoption6a44b05
line 36why, one step back36 RequestFiles,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 37–54why, one step back37 Response,38 ResponseContent,39 URLTypes,40)41from .status_codes import codes424344class BaseClient:45 def __init__(46 self,47 auth: AuthTypes = None,48 cookies: CookieTypes = None,49 verify: VerifyTypes = True,50 cert: CertTypes = None,51 timeout: TimeoutTypes = DEFAULT_TIMEOUT_CONFIG,52 pool_limits: PoolLimits = DEFAULT_POOL_LIMITS,53 max_redirects: int = DEFAULT_MAX_REDIRECTS,54 dispatch: typing.Union[AsyncDispatcher, Dispatcher] = None,Support WSGI and ASGI apps. (#94)Tom Christiebefore adoptionbb86970
line 55why, one step back55 app: typing.Callable = None,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 56–59why, one step back56 backend: ConcurrencyBackend = None,57 ):58 if backend is None:59 backend = AsyncioBackend()Support WSGI and ASGI apps. (#94)Tom Christiebefore adoptionbb86970
lines 60–67why, one step back6061 if app is not None:62 param_count = len(inspect.signature(app).parameters)63 assert param_count in (2, 3)64 if param_count == 2:65 dispatch = WSGIDispatch(app=app)66 else:67 dispatch = ASGIDispatch(app=app)http3 (#86)Tom Christiebefore adoptionc9747aa
lines 68–159why, one step back6869 if dispatch is None:70 async_dispatch = ConnectionPool(71 verify=verify,72 cert=cert,73 timeout=timeout,74 pool_limits=pool_limits,75 backend=backend,76 ) # type: AsyncDispatcher77 elif isinstance(dispatch, Dispatcher):78 async_dispatch = ThreadedDispatcher(dispatch, backend)79 else:80 async_dispatch = dispatch8182 self.auth = auth83 self.cookies = Cookies(cookies)84 self.max_redirects = max_redirects85 self.dispatch = async_dispatch86 self.concurrency_backend = backend8788 def merge_cookies(89 self, cookies: CookieTypes = None90 ) -> typing.Optional[CookieTypes]:91 if cookies or self.cookies:92 merged_cookies = Cookies(self.cookies)93 merged_cookies.update(cookies)94 return merged_cookies95 return cookies9697 async def send(98 self,99 request: AsyncRequest,100 *,101 stream: bool = False,102 auth: AuthTypes = None,103 allow_redirects: bool = True,104 verify: VerifyTypes = None,105 cert: CertTypes = None,106 timeout: TimeoutTypes = None,107 ) -> AsyncResponse:108 if auth is None:109 auth = self.auth110111 url = request.url112 if auth is None and (url.username or url.password):113 auth = HTTPBasicAuth(username=url.username, password=url.password)114115 if auth is not None:116 if isinstance(auth, tuple):117 auth = HTTPBasicAuth(username=auth[0], password=auth[1])118 request = auth(request)119120 response = await self.send_handling_redirects(121 request,122 verify=verify,123 cert=cert,124 timeout=timeout,125 allow_redirects=allow_redirects,126 )127128 if not stream:129 try:130 await response.read()131 finally:132 await response.close()133134 return response135136 async def send_handling_redirects(137 self,138 request: AsyncRequest,139 *,140 cert: CertTypes = None,141 verify: VerifyTypes = None,142 timeout: TimeoutTypes = None,143 allow_redirects: bool = True,144 history: typing.List[AsyncResponse] = None,145 ) -> AsyncResponse:146 if history is None:147 history = []148149 while True:150 # We perform these checks here, so that calls to `response.next()`151 # will raise redirect errors if appropriate.152 if len(history) > self.max_redirects:153 raise TooManyRedirects()154 if request.url in [response.url for response in history]:155 raise RedirectLoop()156157 response = await self.dispatch.send(158 request, verify=verify, cert=cert, timeout=timeout159 )Close redirect responses (#88)Tom Christiebefore adoption3ca9a74
lines 160–164why, one step back160 should_close_response = True161 try:162 assert isinstance(response, AsyncResponse)163 response.history = list(history)164 self.cookies.extract_cookies(response)Tweaks (#89)Tom Christiebefore adoption7c6fb5c
line 165why, one step back165 history = history + [response]http3 (#86)Tom Christiebefore adoptionc9747aa
line 166why, one step back166Close redirect responses (#88)Tom Christiebefore adoption3ca9a74
line 167why, one step back167 if allow_redirects and response.is_redirect:http3 (#86)Tom Christiebefore adoptionc9747aa
line 168why, one step back168 request = self.build_redirect_request(request, response)Close redirect responses (#88)Tom Christiebefore adoption3ca9a74
lines 169–174why, one step back169 else:170 should_close_response = False171 break172 finally:173 if should_close_response:174 await response.close()http3 (#86)Tom Christiebefore adoptionc9747aa
line 175why, one step back175Close redirect responses (#88)Tom Christiebefore adoption3ca9a74
line 176why, one step back176 if response.is_redirect:Multipart support (#90)Tom Christiebefore adoption6a44b05
line 177why, one step back177Close redirect responses (#88)Tom Christiebefore adoption3ca9a74
lines 178–191why, one step back178 async def send_next() -> AsyncResponse:179 nonlocal request, response, verify, cert, allow_redirects, timeout, history180 request = self.build_redirect_request(request, response)181 response = await self.send_handling_redirects(182 request,183 allow_redirects=allow_redirects,184 verify=verify,185 cert=cert,186 timeout=timeout,187 history=history,188 )189 return response190191 response.next = send_next # type: ignorehttp3 (#86)Tom Christiebefore adoptionc9747aa
lines 192–358why, one step back192193 return response194195 def build_redirect_request(196 self, request: AsyncRequest, response: AsyncResponse197 ) -> AsyncRequest:198 method = self.redirect_method(request, response)199 url = self.redirect_url(request, response)200 headers = self.redirect_headers(request, url)201 content = self.redirect_content(request, method)202 cookies = self.merge_cookies(request.cookies)203 return AsyncRequest(204 method=method, url=url, headers=headers, data=content, cookies=cookies205 )206207 def redirect_method(self, request: AsyncRequest, response: AsyncResponse) -> str:208 """209 When being redirected we may want to change the method of the request210 based on certain specs or browser behavior.211 """212 method = request.method213214 # https://tools.ietf.org/html/rfc7231#section-6.4.4215 if response.status_code == codes.SEE_OTHER and method != "HEAD":216 method = "GET"217218 # Do what the browsers do, despite standards...219 # Turn 302s into GETs.220 if response.status_code == codes.FOUND and method != "HEAD":221 method = "GET"222223 # If a POST is responded to with a 301, turn it into a GET.224 # This bizarre behaviour is explained in 'requests' issue 1704.225 if response.status_code == codes.MOVED_PERMANENTLY and method == "POST":226 method = "GET"227228 return method229230 def redirect_url(self, request: AsyncRequest, response: AsyncResponse) -> URL:231 """232 Return the URL for the redirect to follow.233 """234 location = response.headers["Location"]235236 url = URL(location, allow_relative=True)237238 # Facilitate relative 'Location' headers, as allowed by RFC 7231.239 # (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')240 if url.is_relative_url:241 url = url.resolve_with(request.url)242243 # Attach previous fragment if needed (RFC 7231 7.1.2)244 if request.url.fragment and not url.fragment:245 url = url.copy_with(fragment=request.url.fragment)246247 return url248249 def redirect_headers(self, request: AsyncRequest, url: URL) -> Headers:250 """251 Strip Authorization headers when responses are redirected away from252 the origin.253 """254 headers = Headers(request.headers)255 if url.origin != request.url.origin:256 del headers["Authorization"]257 return headers258259 def redirect_content(self, request: AsyncRequest, method: str) -> bytes:260 """261 Return the body that should be used for the redirect request.262 """263 if method != request.method and method == "GET":264 return b""265 if request.is_streaming:266 raise RedirectBodyUnavailable()267 return request.content268269270class AsyncClient(BaseClient):271 async def get(272 self,273 url: URLTypes,274 *,275 params: QueryParamTypes = None,276 headers: HeaderTypes = None,277 cookies: CookieTypes = None,278 stream: bool = False,279 auth: AuthTypes = None,280 allow_redirects: bool = True,281 cert: CertTypes = None,282 verify: VerifyTypes = None,283 timeout: TimeoutTypes = None,284 ) -> AsyncResponse:285 return await self.request(286 "GET",287 url,288 params=params,289 headers=headers,290 cookies=cookies,291 stream=stream,292 auth=auth,293 allow_redirects=allow_redirects,294 verify=verify,295 cert=cert,296 timeout=timeout,297 )298299 async def options(300 self,301 url: URLTypes,302 *,303 params: QueryParamTypes = None,304 headers: HeaderTypes = None,305 cookies: CookieTypes = None,306 stream: bool = False,307 auth: AuthTypes = None,308 allow_redirects: bool = True,309 cert: CertTypes = None,310 verify: VerifyTypes = None,311 timeout: TimeoutTypes = None,312 ) -> AsyncResponse:313 return await self.request(314 "OPTIONS",315 url,316 params=params,317 headers=headers,318 cookies=cookies,319 stream=stream,320 auth=auth,321 allow_redirects=allow_redirects,322 verify=verify,323 cert=cert,324 timeout=timeout,325 )326327 async def head(328 self,329 url: URLTypes,330 *,331 params: QueryParamTypes = None,332 headers: HeaderTypes = None,333 cookies: CookieTypes = None,334 stream: bool = False,335 auth: AuthTypes = None,336 allow_redirects: bool = False, # Note: Differs to usual default.337 cert: CertTypes = None,338 verify: VerifyTypes = None,339 timeout: TimeoutTypes = None,340 ) -> AsyncResponse:341 return await self.request(342 "HEAD",343 url,344 params=params,345 headers=headers,346 cookies=cookies,347 stream=stream,348 auth=auth,349 allow_redirects=allow_redirects,350 verify=verify,351 cert=cert,352 timeout=timeout,353 )354355 async def post(356 self,357 url: URLTypes,358 *,Multipart support (#90)Tom Christiebefore adoption6a44b05
lines 359–360why, one step back359 data: AsyncRequestData = None,360 files: RequestFiles = None,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 361–375why, one step back361 json: typing.Any = None,362 params: QueryParamTypes = None,363 headers: HeaderTypes = None,364 cookies: CookieTypes = None,365 stream: bool = False,366 auth: AuthTypes = None,367 allow_redirects: bool = True,368 cert: CertTypes = None,369 verify: VerifyTypes = None,370 timeout: TimeoutTypes = None,371 ) -> AsyncResponse:372 return await self.request(373 "POST",374 url,375 data=data,Multipart support (#90)Tom Christiebefore adoption6a44b05
line 376why, one step back376 files=files,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 377–392why, one step back377 json=json,378 params=params,379 headers=headers,380 cookies=cookies,381 stream=stream,382 auth=auth,383 allow_redirects=allow_redirects,384 verify=verify,385 cert=cert,386 timeout=timeout,387 )388389 async def put(390 self,391 url: URLTypes,392 *,Multipart support (#90)Tom Christiebefore adoption6a44b05
lines 393–394why, one step back393 data: AsyncRequestData = None,394 files: RequestFiles = None,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 395–409why, one step back395 json: typing.Any = None,396 params: QueryParamTypes = None,397 headers: HeaderTypes = None,398 cookies: CookieTypes = None,399 stream: bool = False,400 auth: AuthTypes = None,401 allow_redirects: bool = True,402 cert: CertTypes = None,403 verify: VerifyTypes = None,404 timeout: TimeoutTypes = None,405 ) -> AsyncResponse:406 return await self.request(407 "PUT",408 url,409 data=data,Multipart support (#90)Tom Christiebefore adoption6a44b05
line 410why, one step back410 files=files,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 411–426why, one step back411 json=json,412 params=params,413 headers=headers,414 cookies=cookies,415 stream=stream,416 auth=auth,417 allow_redirects=allow_redirects,418 verify=verify,419 cert=cert,420 timeout=timeout,421 )422423 async def patch(424 self,425 url: URLTypes,426 *,Multipart support (#90)Tom Christiebefore adoption6a44b05
lines 427–428why, one step back427 data: AsyncRequestData = None,428 files: RequestFiles = None,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 429–443why, one step back429 json: typing.Any = None,430 params: QueryParamTypes = None,431 headers: HeaderTypes = None,432 cookies: CookieTypes = None,433 stream: bool = False,434 auth: AuthTypes = None,435 allow_redirects: bool = True,436 cert: CertTypes = None,437 verify: VerifyTypes = None,438 timeout: TimeoutTypes = None,439 ) -> AsyncResponse:440 return await self.request(441 "PATCH",442 url,443 data=data,Multipart support (#90)Tom Christiebefore adoption6a44b05
line 444why, one step back444 files=files,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 445–460why, one step back445 json=json,446 params=params,447 headers=headers,448 cookies=cookies,449 stream=stream,450 auth=auth,451 allow_redirects=allow_redirects,452 verify=verify,453 cert=cert,454 timeout=timeout,455 )456457 async def delete(458 self,459 url: URLTypes,460 *,Multipart support (#90)Tom Christiebefore adoption6a44b05
lines 461–462why, one step back461 data: AsyncRequestData = None,462 files: RequestFiles = None,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 463–477why, one step back463 json: typing.Any = None,464 params: QueryParamTypes = None,465 headers: HeaderTypes = None,466 cookies: CookieTypes = None,467 stream: bool = False,468 auth: AuthTypes = None,469 allow_redirects: bool = True,470 cert: CertTypes = None,471 verify: VerifyTypes = None,472 timeout: TimeoutTypes = None,473 ) -> AsyncResponse:474 return await self.request(475 "DELETE",476 url,477 data=data,Multipart support (#90)Tom Christiebefore adoption6a44b05
line 478why, one step back478 files=files,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 479–495why, one step back479 json=json,480 params=params,481 headers=headers,482 cookies=cookies,483 stream=stream,484 auth=auth,485 allow_redirects=allow_redirects,486 verify=verify,487 cert=cert,488 timeout=timeout,489 )490491 async def request(492 self,493 method: str,494 url: URLTypes,495 *,Multipart support (#90)Tom Christiebefore adoption6a44b05
lines 496–497why, one step back496 data: AsyncRequestData = None,497 files: RequestFiles = None,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 498–512why, one step back498 json: typing.Any = None,499 params: QueryParamTypes = None,500 headers: HeaderTypes = None,501 cookies: CookieTypes = None,502 stream: bool = False,503 auth: AuthTypes = None,504 allow_redirects: bool = True,505 cert: CertTypes = None,506 verify: VerifyTypes = None,507 timeout: TimeoutTypes = None,508 ) -> AsyncResponse:509 request = AsyncRequest(510 method,511 url,512 data=data,Multipart support (#90)Tom Christiebefore adoption6a44b05
line 513why, one step back513 files=files,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 514–545why, one step back514 json=json,515 params=params,516 headers=headers,517 cookies=self.merge_cookies(cookies),518 )519 response = await self.send(520 request,521 stream=stream,522 auth=auth,523 allow_redirects=allow_redirects,524 verify=verify,525 cert=cert,526 timeout=timeout,527 )528 return response529530 async def close(self) -> None:531 await self.dispatch.close()532533 async def __aenter__(self) -> "AsyncClient":534 return self535536 async def __aexit__(537 self,538 exc_type: typing.Type[BaseException] = None,539 exc_value: BaseException = None,540 traceback: TracebackType = None,541 ) -> None:542 await self.close()543544545class Client(BaseClient):Multipart support (#90)Tom Christiebefore adoption6a44b05
lines 546–548why, one step back546 def _async_request_data(547 self, data: RequestData = None548 ) -> typing.Optional[AsyncRequestData]:http3 (#86)Tom Christiebefore adoptionc9747aa
lines 549–552why, one step back549 """550 If the request data is an bytes iterator then return an async bytes551 iterator onto the request data.552 """Multipart support (#90)Tom Christiebefore adoption6a44b05
line 553why, one step back553 if data is None or isinstance(data, (bytes, dict)):http3 (#86)Tom Christiebefore adoptionc9747aa
lines 554–574why, one step back554 return data555556 # Coerce an iterator into an async iterator, with each item in the557 # iteration running as a thread-pooled operation.558 assert hasattr(data, "__iter__")559 return self.concurrency_backend.iterate_in_threadpool(data)560561 def _sync_data(self, data: AsyncResponseContent) -> ResponseContent:562 if isinstance(data, bytes):563 return data564565 # Coerce an async iterator into an iterator, with each item in the566 # iteration run within the event loop.567 assert hasattr(data, "__aiter__")568 return self.concurrency_backend.iterate(data)569570 def request(571 self,572 method: str,573 url: URLTypes,574 *,Multipart support (#90)Tom Christiebefore adoption6a44b05
lines 575–576why, one step back575 data: RequestData = None,576 files: RequestFiles = None,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 577–591why, one step back577 json: typing.Any = None,578 params: QueryParamTypes = None,579 headers: HeaderTypes = None,580 cookies: CookieTypes = None,581 stream: bool = False,582 auth: AuthTypes = None,583 allow_redirects: bool = True,584 cert: CertTypes = None,585 verify: VerifyTypes = None,586 timeout: TimeoutTypes = None,587 ) -> Response:588 request = AsyncRequest(589 method,590 url,591 data=self._async_request_data(data),Multipart support (#90)Tom Christiebefore adoption6a44b05
line 592why, one step back592 files=files,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 593–725why, one step back593 json=json,594 params=params,595 headers=headers,596 cookies=self.merge_cookies(cookies),597 )598 concurrency_backend = self.concurrency_backend599600 coroutine = self.send601 args = [request]602 kwargs = dict(603 stream=True,604 auth=auth,605 allow_redirects=allow_redirects,606 verify=verify,607 cert=cert,608 timeout=timeout,609 )610 async_response = concurrency_backend.run(coroutine, *args, **kwargs)611612 content = getattr(613 async_response, "_raw_content", getattr(async_response, "_raw_stream", None)614 )615616 sync_content = self._sync_data(content)617618 def sync_on_close() -> None:619 nonlocal concurrency_backend, async_response620 concurrency_backend.run(async_response.on_close)621622 response = Response(623 status_code=async_response.status_code,624 protocol=async_response.protocol,625 headers=async_response.headers,626 content=sync_content,627 on_close=sync_on_close,628 request=async_response.request,629 history=async_response.history,630 )631 if not stream:632 try:633 response.read()634 finally:635 response.close()636 return response637638 def get(639 self,640 url: URLTypes,641 *,642 params: QueryParamTypes = None,643 headers: HeaderTypes = None,644 cookies: CookieTypes = None,645 stream: bool = False,646 auth: AuthTypes = None,647 allow_redirects: bool = True,648 cert: CertTypes = None,649 verify: VerifyTypes = None,650 timeout: TimeoutTypes = None,651 ) -> Response:652 return self.request(653 "GET",654 url,655 params=params,656 headers=headers,657 cookies=cookies,658 stream=stream,659 auth=auth,660 allow_redirects=allow_redirects,661 verify=verify,662 cert=cert,663 timeout=timeout,664 )665666 def options(667 self,668 url: URLTypes,669 *,670 params: QueryParamTypes = None,671 headers: HeaderTypes = None,672 cookies: CookieTypes = None,673 stream: bool = False,674 auth: AuthTypes = None,675 allow_redirects: bool = True,676 cert: CertTypes = None,677 verify: VerifyTypes = None,678 timeout: TimeoutTypes = None,679 ) -> Response:680 return self.request(681 "OPTIONS",682 url,683 params=params,684 headers=headers,685 cookies=cookies,686 stream=stream,687 auth=auth,688 allow_redirects=allow_redirects,689 verify=verify,690 cert=cert,691 timeout=timeout,692 )693694 def head(695 self,696 url: URLTypes,697 *,698 params: QueryParamTypes = None,699 headers: HeaderTypes = None,700 cookies: CookieTypes = None,701 stream: bool = False,702 auth: AuthTypes = None,703 allow_redirects: bool = False, # Note: Differs to usual default.704 cert: CertTypes = None,705 verify: VerifyTypes = None,706 timeout: TimeoutTypes = None,707 ) -> Response:708 return self.request(709 "HEAD",710 url,711 params=params,712 headers=headers,713 cookies=cookies,714 stream=stream,715 auth=auth,716 allow_redirects=allow_redirects,717 verify=verify,718 cert=cert,719 timeout=timeout,720 )721722 def post(723 self,724 url: URLTypes,725 *,Multipart support (#90)Tom Christiebefore adoption6a44b05
lines 726–727why, one step back726 data: RequestData = None,727 files: RequestFiles = None,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 728–742why, one step back728 json: typing.Any = None,729 params: QueryParamTypes = None,730 headers: HeaderTypes = None,731 cookies: CookieTypes = None,732 stream: bool = False,733 auth: AuthTypes = None,734 allow_redirects: bool = True,735 cert: CertTypes = None,736 verify: VerifyTypes = None,737 timeout: TimeoutTypes = None,738 ) -> Response:739 return self.request(740 "POST",741 url,742 data=data,Multipart support (#90)Tom Christiebefore adoption6a44b05
line 743why, one step back743 files=files,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 744–759why, one step back744 json=json,745 params=params,746 headers=headers,747 cookies=cookies,748 stream=stream,749 auth=auth,750 allow_redirects=allow_redirects,751 verify=verify,752 cert=cert,753 timeout=timeout,754 )755756 def put(757 self,758 url: URLTypes,759 *,Multipart support (#90)Tom Christiebefore adoption6a44b05
lines 760–761why, one step back760 data: RequestData = None,761 files: RequestFiles = None,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 762–776why, one step back762 json: typing.Any = None,763 params: QueryParamTypes = None,764 headers: HeaderTypes = None,765 cookies: CookieTypes = None,766 stream: bool = False,767 auth: AuthTypes = None,768 allow_redirects: bool = True,769 cert: CertTypes = None,770 verify: VerifyTypes = None,771 timeout: TimeoutTypes = None,772 ) -> Response:773 return self.request(774 "PUT",775 url,776 data=data,Multipart support (#90)Tom Christiebefore adoption6a44b05
line 777why, one step back777 files=files,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 778–793why, one step back778 json=json,779 params=params,780 headers=headers,781 cookies=cookies,782 stream=stream,783 auth=auth,784 allow_redirects=allow_redirects,785 verify=verify,786 cert=cert,787 timeout=timeout,788 )789790 def patch(791 self,792 url: URLTypes,793 *,Multipart support (#90)Tom Christiebefore adoption6a44b05
lines 794–795why, one step back794 data: RequestData = None,795 files: RequestFiles = None,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 796–810why, one step back796 json: typing.Any = None,797 params: QueryParamTypes = None,798 headers: HeaderTypes = None,799 cookies: CookieTypes = None,800 stream: bool = False,801 auth: AuthTypes = None,802 allow_redirects: bool = True,803 cert: CertTypes = None,804 verify: VerifyTypes = None,805 timeout: TimeoutTypes = None,806 ) -> Response:807 return self.request(808 "PATCH",809 url,810 data=data,Multipart support (#90)Tom Christiebefore adoption6a44b05
line 811why, one step back811 files=files,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 812–827why, one step back812 json=json,813 params=params,814 headers=headers,815 cookies=cookies,816 stream=stream,817 auth=auth,818 allow_redirects=allow_redirects,819 verify=verify,820 cert=cert,821 timeout=timeout,822 )823824 def delete(825 self,826 url: URLTypes,827 *,Multipart support (#90)Tom Christiebefore adoption6a44b05
lines 828–829why, one step back828 data: RequestData = None,829 files: RequestFiles = None,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 830–844why, one step back830 json: typing.Any = None,831 params: QueryParamTypes = None,832 headers: HeaderTypes = None,833 cookies: CookieTypes = None,834 stream: bool = False,835 auth: AuthTypes = None,836 allow_redirects: bool = True,837 cert: CertTypes = None,838 verify: VerifyTypes = None,839 timeout: TimeoutTypes = None,840 ) -> Response:841 return self.request(842 "DELETE",843 url,844 data=data,Multipart support (#90)Tom Christiebefore adoption6a44b05
line 845why, one step back845 files=files,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 846–871why, one step back846 json=json,847 params=params,848 headers=headers,849 cookies=cookies,850 stream=stream,851 auth=auth,852 allow_redirects=allow_redirects,853 verify=verify,854 cert=cert,855 timeout=timeout,856 )857858 def close(self) -> None:859 coroutine = self.dispatch.close860 self.concurrency_backend.run(coroutine)861862 def __enter__(self) -> "Client":863 return self864865 def __exit__(866 self,867 exc_type: typing.Type[BaseException] = None,868 exc_value: BaseException = None,869 traceback: TracebackType = None,870 ) -> None:871 self.close()