client.py
This file
Path
http3/client.py
881 lines · 25.2 KiB · Python
Last changed by
Support Client(base_url=...)Tom Christiebefore adoption9d5aaff
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–53why, 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,Support Client(base_url=...)Tom Christiebefore adoption9d5aaff
line 54why, one step back54 base_url: URLTypes = None,http3 (#86)Tom Christiebefore adoptionc9747aa
line 55why, one step back55 dispatch: typing.Union[AsyncDispatcher, Dispatcher] = None,Support WSGI and ASGI apps. (#94)Tom Christiebefore adoptionbb86970
line 56why, one step back56 app: typing.Callable = None,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 57–60why, one step back57 backend: ConcurrencyBackend = None,58 ):59 if backend is None:60 backend = AsyncioBackend()Support WSGI and ASGI apps. (#94)Tom Christiebefore adoptionbb86970
lines 61–68why, one step back6162 if app is not None:63 param_count = len(inspect.signature(app).parameters)64 assert param_count in (2, 3)65 if param_count == 2:66 dispatch = WSGIDispatch(app=app)67 else:68 dispatch = ASGIDispatch(app=app)http3 (#86)Tom Christiebefore adoptionc9747aa
lines 69–82why, one step back6970 if dispatch is None:71 async_dispatch = ConnectionPool(72 verify=verify,73 cert=cert,74 timeout=timeout,75 pool_limits=pool_limits,76 backend=backend,77 ) # type: AsyncDispatcher78 elif isinstance(dispatch, Dispatcher):79 async_dispatch = ThreadedDispatcher(dispatch, backend)80 else:81 async_dispatch = dispatch82Support Client(base_url=...)Tom Christiebefore adoption9d5aaff
lines 83–87why, one step back83 if base_url is None:84 self.base_url = URL('', allow_relative=True)85 else:86 self.base_url = URL(base_url)87http3 (#86)Tom Christiebefore adoptionc9747aa
lines 88–165why, one step back88 self.auth = auth89 self.cookies = Cookies(cookies)90 self.max_redirects = max_redirects91 self.dispatch = async_dispatch92 self.concurrency_backend = backend9394 def merge_cookies(95 self, cookies: CookieTypes = None96 ) -> typing.Optional[CookieTypes]:97 if cookies or self.cookies:98 merged_cookies = Cookies(self.cookies)99 merged_cookies.update(cookies)100 return merged_cookies101 return cookies102103 async def send(104 self,105 request: AsyncRequest,106 *,107 stream: bool = False,108 auth: AuthTypes = None,109 allow_redirects: bool = True,110 verify: VerifyTypes = None,111 cert: CertTypes = None,112 timeout: TimeoutTypes = None,113 ) -> AsyncResponse:114 if auth is None:115 auth = self.auth116117 url = request.url118 if auth is None and (url.username or url.password):119 auth = HTTPBasicAuth(username=url.username, password=url.password)120121 if auth is not None:122 if isinstance(auth, tuple):123 auth = HTTPBasicAuth(username=auth[0], password=auth[1])124 request = auth(request)125126 response = await self.send_handling_redirects(127 request,128 verify=verify,129 cert=cert,130 timeout=timeout,131 allow_redirects=allow_redirects,132 )133134 if not stream:135 try:136 await response.read()137 finally:138 await response.close()139140 return response141142 async def send_handling_redirects(143 self,144 request: AsyncRequest,145 *,146 cert: CertTypes = None,147 verify: VerifyTypes = None,148 timeout: TimeoutTypes = None,149 allow_redirects: bool = True,150 history: typing.List[AsyncResponse] = None,151 ) -> AsyncResponse:152 if history is None:153 history = []154155 while True:156 # We perform these checks here, so that calls to `response.next()`157 # will raise redirect errors if appropriate.158 if len(history) > self.max_redirects:159 raise TooManyRedirects()160 if request.url in [response.url for response in history]:161 raise RedirectLoop()162163 response = await self.dispatch.send(164 request, verify=verify, cert=cert, timeout=timeout165 )Close redirect responses (#88)Tom Christiebefore adoption3ca9a74
lines 166–170why, one step back166 should_close_response = True167 try:168 assert isinstance(response, AsyncResponse)169 response.history = list(history)170 self.cookies.extract_cookies(response)Tweaks (#89)Tom Christiebefore adoption7c6fb5c
line 171why, one step back171 history = history + [response]http3 (#86)Tom Christiebefore adoptionc9747aa
line 172why, one step back172Close redirect responses (#88)Tom Christiebefore adoption3ca9a74
line 173why, one step back173 if allow_redirects and response.is_redirect:http3 (#86)Tom Christiebefore adoptionc9747aa
line 174why, one step back174 request = self.build_redirect_request(request, response)Close redirect responses (#88)Tom Christiebefore adoption3ca9a74
lines 175–180why, one step back175 else:176 should_close_response = False177 break178 finally:179 if should_close_response:180 await response.close()http3 (#86)Tom Christiebefore adoptionc9747aa
line 181why, one step back181Close redirect responses (#88)Tom Christiebefore adoption3ca9a74
line 182why, one step back182 if response.is_redirect:Multipart support (#90)Tom Christiebefore adoption6a44b05
line 183why, one step back183Close redirect responses (#88)Tom Christiebefore adoption3ca9a74
lines 184–197why, one step back184 async def send_next() -> AsyncResponse:185 nonlocal request, response, verify, cert, allow_redirects, timeout, history186 request = self.build_redirect_request(request, response)187 response = await self.send_handling_redirects(188 request,189 allow_redirects=allow_redirects,190 verify=verify,191 cert=cert,192 timeout=timeout,193 history=history,194 )195 return response196197 response.next = send_next # type: ignorehttp3 (#86)Tom Christiebefore adoptionc9747aa
lines 198–246why, one step back198199 return response200201 def build_redirect_request(202 self, request: AsyncRequest, response: AsyncResponse203 ) -> AsyncRequest:204 method = self.redirect_method(request, response)205 url = self.redirect_url(request, response)206 headers = self.redirect_headers(request, url)207 content = self.redirect_content(request, method)208 cookies = self.merge_cookies(request.cookies)209 return AsyncRequest(210 method=method, url=url, headers=headers, data=content, cookies=cookies211 )212213 def redirect_method(self, request: AsyncRequest, response: AsyncResponse) -> str:214 """215 When being redirected we may want to change the method of the request216 based on certain specs or browser behavior.217 """218 method = request.method219220 # https://tools.ietf.org/html/rfc7231#section-6.4.4221 if response.status_code == codes.SEE_OTHER and method != "HEAD":222 method = "GET"223224 # Do what the browsers do, despite standards...225 # Turn 302s into GETs.226 if response.status_code == codes.FOUND and method != "HEAD":227 method = "GET"228229 # If a POST is responded to with a 301, turn it into a GET.230 # This bizarre behaviour is explained in 'requests' issue 1704.231 if response.status_code == codes.MOVED_PERMANENTLY and method == "POST":232 method = "GET"233234 return method235236 def redirect_url(self, request: AsyncRequest, response: AsyncResponse) -> URL:237 """238 Return the URL for the redirect to follow.239 """240 location = response.headers["Location"]241242 url = URL(location, allow_relative=True)243244 # Facilitate relative 'Location' headers, as allowed by RFC 7231.245 # (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')246 if url.is_relative_url:Support Client(base_url=...)Tom Christiebefore adoption9d5aaff
line 247why, one step back247 url = request.url.join(url)http3 (#86)Tom Christiebefore adoptionc9747aa
lines 248–364why, one step back248249 # Attach previous fragment if needed (RFC 7231 7.1.2)250 if request.url.fragment and not url.fragment:251 url = url.copy_with(fragment=request.url.fragment)252253 return url254255 def redirect_headers(self, request: AsyncRequest, url: URL) -> Headers:256 """257 Strip Authorization headers when responses are redirected away from258 the origin.259 """260 headers = Headers(request.headers)261 if url.origin != request.url.origin:262 del headers["Authorization"]263 return headers264265 def redirect_content(self, request: AsyncRequest, method: str) -> bytes:266 """267 Return the body that should be used for the redirect request.268 """269 if method != request.method and method == "GET":270 return b""271 if request.is_streaming:272 raise RedirectBodyUnavailable()273 return request.content274275276class AsyncClient(BaseClient):277 async def get(278 self,279 url: URLTypes,280 *,281 params: QueryParamTypes = None,282 headers: HeaderTypes = None,283 cookies: CookieTypes = None,284 stream: bool = False,285 auth: AuthTypes = None,286 allow_redirects: bool = True,287 cert: CertTypes = None,288 verify: VerifyTypes = None,289 timeout: TimeoutTypes = None,290 ) -> AsyncResponse:291 return await self.request(292 "GET",293 url,294 params=params,295 headers=headers,296 cookies=cookies,297 stream=stream,298 auth=auth,299 allow_redirects=allow_redirects,300 verify=verify,301 cert=cert,302 timeout=timeout,303 )304305 async def options(306 self,307 url: URLTypes,308 *,309 params: QueryParamTypes = None,310 headers: HeaderTypes = None,311 cookies: CookieTypes = None,312 stream: bool = False,313 auth: AuthTypes = None,314 allow_redirects: bool = True,315 cert: CertTypes = None,316 verify: VerifyTypes = None,317 timeout: TimeoutTypes = None,318 ) -> AsyncResponse:319 return await self.request(320 "OPTIONS",321 url,322 params=params,323 headers=headers,324 cookies=cookies,325 stream=stream,326 auth=auth,327 allow_redirects=allow_redirects,328 verify=verify,329 cert=cert,330 timeout=timeout,331 )332333 async def head(334 self,335 url: URLTypes,336 *,337 params: QueryParamTypes = None,338 headers: HeaderTypes = None,339 cookies: CookieTypes = None,340 stream: bool = False,341 auth: AuthTypes = None,342 allow_redirects: bool = False, # Note: Differs to usual default.343 cert: CertTypes = None,344 verify: VerifyTypes = None,345 timeout: TimeoutTypes = None,346 ) -> AsyncResponse:347 return await self.request(348 "HEAD",349 url,350 params=params,351 headers=headers,352 cookies=cookies,353 stream=stream,354 auth=auth,355 allow_redirects=allow_redirects,356 verify=verify,357 cert=cert,358 timeout=timeout,359 )360361 async def post(362 self,363 url: URLTypes,364 *,Multipart support (#90)Tom Christiebefore adoption6a44b05
lines 365–366why, one step back365 data: AsyncRequestData = None,366 files: RequestFiles = None,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 367–381why, one step back367 json: typing.Any = None,368 params: QueryParamTypes = None,369 headers: HeaderTypes = None,370 cookies: CookieTypes = None,371 stream: bool = False,372 auth: AuthTypes = None,373 allow_redirects: bool = True,374 cert: CertTypes = None,375 verify: VerifyTypes = None,376 timeout: TimeoutTypes = None,377 ) -> AsyncResponse:378 return await self.request(379 "POST",380 url,381 data=data,Multipart support (#90)Tom Christiebefore adoption6a44b05
line 382why, one step back382 files=files,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 383–398why, one step back383 json=json,384 params=params,385 headers=headers,386 cookies=cookies,387 stream=stream,388 auth=auth,389 allow_redirects=allow_redirects,390 verify=verify,391 cert=cert,392 timeout=timeout,393 )394395 async def put(396 self,397 url: URLTypes,398 *,Multipart support (#90)Tom Christiebefore adoption6a44b05
lines 399–400why, one step back399 data: AsyncRequestData = None,400 files: RequestFiles = None,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 401–415why, one step back401 json: typing.Any = None,402 params: QueryParamTypes = None,403 headers: HeaderTypes = None,404 cookies: CookieTypes = None,405 stream: bool = False,406 auth: AuthTypes = None,407 allow_redirects: bool = True,408 cert: CertTypes = None,409 verify: VerifyTypes = None,410 timeout: TimeoutTypes = None,411 ) -> AsyncResponse:412 return await self.request(413 "PUT",414 url,415 data=data,Multipart support (#90)Tom Christiebefore adoption6a44b05
line 416why, one step back416 files=files,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 417–432why, one step back417 json=json,418 params=params,419 headers=headers,420 cookies=cookies,421 stream=stream,422 auth=auth,423 allow_redirects=allow_redirects,424 verify=verify,425 cert=cert,426 timeout=timeout,427 )428429 async def patch(430 self,431 url: URLTypes,432 *,Multipart support (#90)Tom Christiebefore adoption6a44b05
lines 433–434why, one step back433 data: AsyncRequestData = None,434 files: RequestFiles = None,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 435–449why, one step back435 json: typing.Any = None,436 params: QueryParamTypes = None,437 headers: HeaderTypes = None,438 cookies: CookieTypes = None,439 stream: bool = False,440 auth: AuthTypes = None,441 allow_redirects: bool = True,442 cert: CertTypes = None,443 verify: VerifyTypes = None,444 timeout: TimeoutTypes = None,445 ) -> AsyncResponse:446 return await self.request(447 "PATCH",448 url,449 data=data,Multipart support (#90)Tom Christiebefore adoption6a44b05
line 450why, one step back450 files=files,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 451–466why, one step back451 json=json,452 params=params,453 headers=headers,454 cookies=cookies,455 stream=stream,456 auth=auth,457 allow_redirects=allow_redirects,458 verify=verify,459 cert=cert,460 timeout=timeout,461 )462463 async def delete(464 self,465 url: URLTypes,466 *,Multipart support (#90)Tom Christiebefore adoption6a44b05
lines 467–468why, one step back467 data: AsyncRequestData = None,468 files: RequestFiles = None,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 469–483why, one step back469 json: typing.Any = None,470 params: QueryParamTypes = None,471 headers: HeaderTypes = None,472 cookies: CookieTypes = None,473 stream: bool = False,474 auth: AuthTypes = None,475 allow_redirects: bool = True,476 cert: CertTypes = None,477 verify: VerifyTypes = None,478 timeout: TimeoutTypes = None,479 ) -> AsyncResponse:480 return await self.request(481 "DELETE",482 url,483 data=data,Multipart support (#90)Tom Christiebefore adoption6a44b05
line 484why, one step back484 files=files,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 485–501why, one step back485 json=json,486 params=params,487 headers=headers,488 cookies=cookies,489 stream=stream,490 auth=auth,491 allow_redirects=allow_redirects,492 verify=verify,493 cert=cert,494 timeout=timeout,495 )496497 async def request(498 self,499 method: str,500 url: URLTypes,501 *,Multipart support (#90)Tom Christiebefore adoption6a44b05
lines 502–503why, one step back502 data: AsyncRequestData = None,503 files: RequestFiles = None,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 504–514why, one step back504 json: typing.Any = None,505 params: QueryParamTypes = None,506 headers: HeaderTypes = None,507 cookies: CookieTypes = None,508 stream: bool = False,509 auth: AuthTypes = None,510 allow_redirects: bool = True,511 cert: CertTypes = None,512 verify: VerifyTypes = None,513 timeout: TimeoutTypes = None,514 ) -> AsyncResponse:Support Client(base_url=...)Tom Christiebefore adoption9d5aaff
lines 515–516why, one step back515 url = self.base_url.join(url)516 cookies = self.merge_cookies(cookies)http3 (#86)Tom Christiebefore adoptionc9747aa
lines 517–520why, one step back517 request = AsyncRequest(518 method,519 url,520 data=data,Multipart support (#90)Tom Christiebefore adoption6a44b05
line 521why, one step back521 files=files,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 522–524why, one step back522 json=json,523 params=params,524 headers=headers,Support Client(base_url=...)Tom Christiebefore adoption9d5aaff
line 525why, one step back525 cookies=cookies,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 526–553why, one step back526 )527 response = await self.send(528 request,529 stream=stream,530 auth=auth,531 allow_redirects=allow_redirects,532 verify=verify,533 cert=cert,534 timeout=timeout,535 )536 return response537538 async def close(self) -> None:539 await self.dispatch.close()540541 async def __aenter__(self) -> "AsyncClient":542 return self543544 async def __aexit__(545 self,546 exc_type: typing.Type[BaseException] = None,547 exc_value: BaseException = None,548 traceback: TracebackType = None,549 ) -> None:550 await self.close()551552553class Client(BaseClient):Multipart support (#90)Tom Christiebefore adoption6a44b05
lines 554–556why, one step back554 def _async_request_data(555 self, data: RequestData = None556 ) -> typing.Optional[AsyncRequestData]:http3 (#86)Tom Christiebefore adoptionc9747aa
lines 557–560why, one step back557 """558 If the request data is an bytes iterator then return an async bytes559 iterator onto the request data.560 """Multipart support (#90)Tom Christiebefore adoption6a44b05
line 561why, one step back561 if data is None or isinstance(data, (bytes, dict)):http3 (#86)Tom Christiebefore adoptionc9747aa
lines 562–582why, one step back562 return data563564 # Coerce an iterator into an async iterator, with each item in the565 # iteration running as a thread-pooled operation.566 assert hasattr(data, "__iter__")567 return self.concurrency_backend.iterate_in_threadpool(data)568569 def _sync_data(self, data: AsyncResponseContent) -> ResponseContent:570 if isinstance(data, bytes):571 return data572573 # Coerce an async iterator into an iterator, with each item in the574 # iteration run within the event loop.575 assert hasattr(data, "__aiter__")576 return self.concurrency_backend.iterate(data)577578 def request(579 self,580 method: str,581 url: URLTypes,582 *,Multipart support (#90)Tom Christiebefore adoption6a44b05
lines 583–584why, one step back583 data: RequestData = None,584 files: RequestFiles = None,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 585–595why, one step back585 json: typing.Any = None,586 params: QueryParamTypes = None,587 headers: HeaderTypes = None,588 cookies: CookieTypes = None,589 stream: bool = False,590 auth: AuthTypes = None,591 allow_redirects: bool = True,592 cert: CertTypes = None,593 verify: VerifyTypes = None,594 timeout: TimeoutTypes = None,595 ) -> Response:Support Client(base_url=...)Tom Christiebefore adoption9d5aaff
lines 596–597why, one step back596 url = self.base_url.join(url)597 cookies = self.merge_cookies(cookies)http3 (#86)Tom Christiebefore adoptionc9747aa
lines 598–601why, one step back598 request = AsyncRequest(599 method,600 url,601 data=self._async_request_data(data),Multipart support (#90)Tom Christiebefore adoption6a44b05
line 602why, one step back602 files=files,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 603–605why, one step back603 json=json,604 params=params,605 headers=headers,Support Client(base_url=...)Tom Christiebefore adoption9d5aaff
line 606why, one step back606 cookies=cookies,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 607–735why, one step back607 )608 concurrency_backend = self.concurrency_backend609610 coroutine = self.send611 args = [request]612 kwargs = dict(613 stream=True,614 auth=auth,615 allow_redirects=allow_redirects,616 verify=verify,617 cert=cert,618 timeout=timeout,619 )620 async_response = concurrency_backend.run(coroutine, *args, **kwargs)621622 content = getattr(623 async_response, "_raw_content", getattr(async_response, "_raw_stream", None)624 )625626 sync_content = self._sync_data(content)627628 def sync_on_close() -> None:629 nonlocal concurrency_backend, async_response630 concurrency_backend.run(async_response.on_close)631632 response = Response(633 status_code=async_response.status_code,634 protocol=async_response.protocol,635 headers=async_response.headers,636 content=sync_content,637 on_close=sync_on_close,638 request=async_response.request,639 history=async_response.history,640 )641 if not stream:642 try:643 response.read()644 finally:645 response.close()646 return response647648 def get(649 self,650 url: URLTypes,651 *,652 params: QueryParamTypes = None,653 headers: HeaderTypes = None,654 cookies: CookieTypes = None,655 stream: bool = False,656 auth: AuthTypes = None,657 allow_redirects: bool = True,658 cert: CertTypes = None,659 verify: VerifyTypes = None,660 timeout: TimeoutTypes = None,661 ) -> Response:662 return self.request(663 "GET",664 url,665 params=params,666 headers=headers,667 cookies=cookies,668 stream=stream,669 auth=auth,670 allow_redirects=allow_redirects,671 verify=verify,672 cert=cert,673 timeout=timeout,674 )675676 def options(677 self,678 url: URLTypes,679 *,680 params: QueryParamTypes = None,681 headers: HeaderTypes = None,682 cookies: CookieTypes = None,683 stream: bool = False,684 auth: AuthTypes = None,685 allow_redirects: bool = True,686 cert: CertTypes = None,687 verify: VerifyTypes = None,688 timeout: TimeoutTypes = None,689 ) -> Response:690 return self.request(691 "OPTIONS",692 url,693 params=params,694 headers=headers,695 cookies=cookies,696 stream=stream,697 auth=auth,698 allow_redirects=allow_redirects,699 verify=verify,700 cert=cert,701 timeout=timeout,702 )703704 def head(705 self,706 url: URLTypes,707 *,708 params: QueryParamTypes = None,709 headers: HeaderTypes = None,710 cookies: CookieTypes = None,711 stream: bool = False,712 auth: AuthTypes = None,713 allow_redirects: bool = False, # Note: Differs to usual default.714 cert: CertTypes = None,715 verify: VerifyTypes = None,716 timeout: TimeoutTypes = None,717 ) -> Response:718 return self.request(719 "HEAD",720 url,721 params=params,722 headers=headers,723 cookies=cookies,724 stream=stream,725 auth=auth,726 allow_redirects=allow_redirects,727 verify=verify,728 cert=cert,729 timeout=timeout,730 )731732 def post(733 self,734 url: URLTypes,735 *,Multipart support (#90)Tom Christiebefore adoption6a44b05
lines 736–737why, one step back736 data: RequestData = None,737 files: RequestFiles = None,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 738–752why, one step back738 json: typing.Any = None,739 params: QueryParamTypes = None,740 headers: HeaderTypes = None,741 cookies: CookieTypes = None,742 stream: bool = False,743 auth: AuthTypes = None,744 allow_redirects: bool = True,745 cert: CertTypes = None,746 verify: VerifyTypes = None,747 timeout: TimeoutTypes = None,748 ) -> Response:749 return self.request(750 "POST",751 url,752 data=data,Multipart support (#90)Tom Christiebefore adoption6a44b05
line 753why, one step back753 files=files,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 754–769why, one step back754 json=json,755 params=params,756 headers=headers,757 cookies=cookies,758 stream=stream,759 auth=auth,760 allow_redirects=allow_redirects,761 verify=verify,762 cert=cert,763 timeout=timeout,764 )765766 def put(767 self,768 url: URLTypes,769 *,Multipart support (#90)Tom Christiebefore adoption6a44b05
lines 770–771why, one step back770 data: RequestData = None,771 files: RequestFiles = None,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 772–786why, one step back772 json: typing.Any = None,773 params: QueryParamTypes = None,774 headers: HeaderTypes = None,775 cookies: CookieTypes = None,776 stream: bool = False,777 auth: AuthTypes = None,778 allow_redirects: bool = True,779 cert: CertTypes = None,780 verify: VerifyTypes = None,781 timeout: TimeoutTypes = None,782 ) -> Response:783 return self.request(784 "PUT",785 url,786 data=data,Multipart support (#90)Tom Christiebefore adoption6a44b05
line 787why, one step back787 files=files,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 788–803why, one step back788 json=json,789 params=params,790 headers=headers,791 cookies=cookies,792 stream=stream,793 auth=auth,794 allow_redirects=allow_redirects,795 verify=verify,796 cert=cert,797 timeout=timeout,798 )799800 def patch(801 self,802 url: URLTypes,803 *,Multipart support (#90)Tom Christiebefore adoption6a44b05
lines 804–805why, one step back804 data: RequestData = None,805 files: RequestFiles = None,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 806–820why, one step back806 json: typing.Any = None,807 params: QueryParamTypes = None,808 headers: HeaderTypes = None,809 cookies: CookieTypes = None,810 stream: bool = False,811 auth: AuthTypes = None,812 allow_redirects: bool = True,813 cert: CertTypes = None,814 verify: VerifyTypes = None,815 timeout: TimeoutTypes = None,816 ) -> Response:817 return self.request(818 "PATCH",819 url,820 data=data,Multipart support (#90)Tom Christiebefore adoption6a44b05
line 821why, one step back821 files=files,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 822–837why, one step back822 json=json,823 params=params,824 headers=headers,825 cookies=cookies,826 stream=stream,827 auth=auth,828 allow_redirects=allow_redirects,829 verify=verify,830 cert=cert,831 timeout=timeout,832 )833834 def delete(835 self,836 url: URLTypes,837 *,Multipart support (#90)Tom Christiebefore adoption6a44b05
lines 838–839why, one step back838 data: RequestData = None,839 files: RequestFiles = None,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 840–854why, one step back840 json: typing.Any = None,841 params: QueryParamTypes = None,842 headers: HeaderTypes = None,843 cookies: CookieTypes = None,844 stream: bool = False,845 auth: AuthTypes = None,846 allow_redirects: bool = True,847 cert: CertTypes = None,848 verify: VerifyTypes = None,849 timeout: TimeoutTypes = None,850 ) -> Response:851 return self.request(852 "DELETE",853 url,854 data=data,Multipart support (#90)Tom Christiebefore adoption6a44b05
line 855why, one step back855 files=files,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 856–881why, one step back856 json=json,857 params=params,858 headers=headers,859 cookies=cookies,860 stream=stream,861 auth=auth,862 allow_redirects=allow_redirects,863 verify=verify,864 cert=cert,865 timeout=timeout,866 )867868 def close(self) -> None:869 coroutine = self.dispatch.close870 self.concurrency_backend.run(coroutine)871872 def __enter__(self) -> "Client":873 return self874875 def __exit__(876 self,877 exc_type: typing.Type[BaseException] = None,878 exc_value: BaseException = None,879 traceback: TracebackType = None,880 ) -> None:881 self.close()