Skip to content
Myr

client.py

This file

Path

http3/client.py

895 lines · 25.6 KiB · Python

Last changed by

Minor tweaks in line with requests behavior (#110)Tom Christiebefore adoptionfe1f9ed

History of this file

Take it

Support WSGI and ASGI apps. (#94)Tom Christiebefore adoptionbb86970

line 1why, one step back
1import inspect

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 2–15why, one step back
2import typing
3from 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 back
16from .dispatch.asgi import ASGIDispatch

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 17–18why, one step back
17from .dispatch.connection_pool import ConnectionPool
18from .dispatch.threaded import ThreadedDispatcher

Support WSGI and ASGI apps. (#94)Tom Christiebefore adoptionbb86970

line 19why, one step back
19from .dispatch.wsgi import WSGIDispatch

Minor tweaks in line with requests behavior (#110)Tom Christiebefore adoptionfe1f9ed

lines 20–25why, one step back
20from .exceptions import (
21 InvalidURL,22 RedirectBodyUnavailable,23 RedirectLoop,24 TooManyRedirects,25)

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 26–40why, one step back
26from .interfaces import AsyncDispatcher, ConcurrencyBackend, Dispatcher
27from .models import (28 URL,29 AsyncRequest,30 AsyncRequestData,31 AsyncResponse,32 AsyncResponseContent,33 AuthTypes,34 Cookies,35 CookieTypes,36 Headers,37 HeaderTypes,38 QueryParamTypes,39 Request,40 RequestData,

Multipart support (#90)Tom Christiebefore adoption6a44b05

line 41why, one step back
41 RequestFiles,

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 42–58why, one step back
42 Response,
43 ResponseContent,44 URLTypes,45)46from .status_codes import codes474849class BaseClient:50 def __init__(51 self,52 auth: AuthTypes = None,53 cookies: CookieTypes = None,54 verify: VerifyTypes = True,55 cert: CertTypes = None,56 timeout: TimeoutTypes = DEFAULT_TIMEOUT_CONFIG,57 pool_limits: PoolLimits = DEFAULT_POOL_LIMITS,58 max_redirects: int = DEFAULT_MAX_REDIRECTS,

Support Client(base_url=...)Tom Christiebefore adoption9d5aaff

line 59why, one step back
59 base_url: URLTypes = None,

http3 (#86)Tom Christiebefore adoptionc9747aa

line 60why, one step back
60 dispatch: typing.Union[AsyncDispatcher, Dispatcher] = None,

Support WSGI and ASGI apps. (#94)Tom Christiebefore adoptionbb86970

line 61why, one step back
61 app: typing.Callable = None,

Include host header directly (#109)Tom Christiebefore adoption5539b69

line 62why, one step back
62 raise_app_exceptions: bool = True,

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 63–66why, one step back
63 backend: ConcurrencyBackend = None,
64 ):65 if backend is None:66 backend = AsyncioBackend()

Support WSGI and ASGI apps. (#94)Tom Christiebefore adoptionbb86970

lines 67–71why, one step back
67
68 if app is not None:69 param_count = len(inspect.signature(app).parameters)70 assert param_count in (2, 3)71 if param_count == 2:

Include host header directly (#109)Tom Christiebefore adoption5539b69

lines 72–74why, one step back
72 dispatch = WSGIDispatch(
73 app=app, raise_app_exceptions=raise_app_exceptions74 )

Support WSGI and ASGI apps. (#94)Tom Christiebefore adoptionbb86970

line 75why, one step back
75 else:

Include host header directly (#109)Tom Christiebefore adoption5539b69

lines 76–78why, one step back
76 dispatch = ASGIDispatch(
77 app=app, raise_app_exceptions=raise_app_exceptions78 )

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 79–92why, one step back
79
80 if dispatch is None:81 async_dispatch = ConnectionPool(82 verify=verify,83 cert=cert,84 timeout=timeout,85 pool_limits=pool_limits,86 backend=backend,87 ) # type: AsyncDispatcher88 elif isinstance(dispatch, Dispatcher):89 async_dispatch = ThreadedDispatcher(dispatch, backend)90 else:91 async_dispatch = dispatch92

Support Client(base_url=...)Tom Christiebefore adoption9d5aaff

line 93why, one step back
93 if base_url is None:

Handle early connection closes (#103)Tom Christiebefore adoptionb9c8a15

line 94why, one step back
94 self.base_url = URL("", allow_relative=True)

Support Client(base_url=...)Tom Christiebefore adoption9d5aaff

lines 95–97why, one step back
95 else:
96 self.base_url = URL(base_url)97

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 98–127why, one step back
98 self.auth = auth
99 self.cookies = Cookies(cookies)100 self.max_redirects = max_redirects101 self.dispatch = async_dispatch102 self.concurrency_backend = backend103104 def merge_cookies(105 self, cookies: CookieTypes = None106 ) -> typing.Optional[CookieTypes]:107 if cookies or self.cookies:108 merged_cookies = Cookies(self.cookies)109 merged_cookies.update(cookies)110 return merged_cookies111 return cookies112113 async def send(114 self,115 request: AsyncRequest,116 *,117 stream: bool = False,118 auth: AuthTypes = None,119 allow_redirects: bool = True,120 verify: VerifyTypes = None,121 cert: CertTypes = None,122 timeout: TimeoutTypes = None,123 ) -> AsyncResponse:124 if auth is None:125 auth = self.auth126127 url = request.url

Minor tweaks in line with requests behavior (#110)Tom Christiebefore adoptionfe1f9ed

lines 128–131why, one step back
128
129 if url.scheme not in ("http", "https"):130 raise InvalidURL('URL scheme must be "http" or "https".')131

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 132–179why, one step back
132 if auth is None and (url.username or url.password):
133 auth = HTTPBasicAuth(username=url.username, password=url.password)134135 if auth is not None:136 if isinstance(auth, tuple):137 auth = HTTPBasicAuth(username=auth[0], password=auth[1])138 request = auth(request)139140 response = await self.send_handling_redirects(141 request,142 verify=verify,143 cert=cert,144 timeout=timeout,145 allow_redirects=allow_redirects,146 )147148 if not stream:149 try:150 await response.read()151 finally:152 await response.close()153154 return response155156 async def send_handling_redirects(157 self,158 request: AsyncRequest,159 *,160 cert: CertTypes = None,161 verify: VerifyTypes = None,162 timeout: TimeoutTypes = None,163 allow_redirects: bool = True,164 history: typing.List[AsyncResponse] = None,165 ) -> AsyncResponse:166 if history is None:167 history = []168169 while True:170 # We perform these checks here, so that calls to `response.next()`171 # will raise redirect errors if appropriate.172 if len(history) > self.max_redirects:173 raise TooManyRedirects()174 if request.url in [response.url for response in history]:175 raise RedirectLoop()176177 response = await self.dispatch.send(178 request, verify=verify, cert=cert, timeout=timeout179 )

Close redirect responses (#88)Tom Christiebefore adoption3ca9a74

lines 180–184why, one step back
180 should_close_response = True
181 try:182 assert isinstance(response, AsyncResponse)183 response.history = list(history)184 self.cookies.extract_cookies(response)

Tweaks (#89)Tom Christiebefore adoption7c6fb5c

line 185why, one step back
185 history = history + [response]

http3 (#86)Tom Christiebefore adoptionc9747aa

line 186why, one step back
186

Close redirect responses (#88)Tom Christiebefore adoption3ca9a74

line 187why, one step back
187 if allow_redirects and response.is_redirect:

http3 (#86)Tom Christiebefore adoptionc9747aa

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

Close redirect responses (#88)Tom Christiebefore adoption3ca9a74

lines 189–194why, one step back
189 else:
190 should_close_response = False191 break192 finally:193 if should_close_response:194 await response.close()

http3 (#86)Tom Christiebefore adoptionc9747aa

line 195why, one step back
195

Close redirect responses (#88)Tom Christiebefore adoption3ca9a74

line 196why, one step back
196 if response.is_redirect:

Multipart support (#90)Tom Christiebefore adoption6a44b05

line 197why, one step back
197

Close redirect responses (#88)Tom Christiebefore adoption3ca9a74

lines 198–211why, one step back
198 async def send_next() -> AsyncResponse:
199 nonlocal request, response, verify, cert, allow_redirects, timeout, history200 request = self.build_redirect_request(request, response)201 response = await self.send_handling_redirects(202 request,203 allow_redirects=allow_redirects,204 verify=verify,205 cert=cert,206 timeout=timeout,207 history=history,208 )209 return response210211 response.next = send_next # type: ignore

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 212–260why, one step back
212
213 return response214215 def build_redirect_request(216 self, request: AsyncRequest, response: AsyncResponse217 ) -> AsyncRequest:218 method = self.redirect_method(request, response)219 url = self.redirect_url(request, response)220 headers = self.redirect_headers(request, url)221 content = self.redirect_content(request, method)222 cookies = self.merge_cookies(request.cookies)223 return AsyncRequest(224 method=method, url=url, headers=headers, data=content, cookies=cookies225 )226227 def redirect_method(self, request: AsyncRequest, response: AsyncResponse) -> str:228 """229 When being redirected we may want to change the method of the request230 based on certain specs or browser behavior.231 """232 method = request.method233234 # https://tools.ietf.org/html/rfc7231#section-6.4.4235 if response.status_code == codes.SEE_OTHER and method != "HEAD":236 method = "GET"237238 # Do what the browsers do, despite standards...239 # Turn 302s into GETs.240 if response.status_code == codes.FOUND and method != "HEAD":241 method = "GET"242243 # If a POST is responded to with a 301, turn it into a GET.244 # This bizarre behaviour is explained in 'requests' issue 1704.245 if response.status_code == codes.MOVED_PERMANENTLY and method == "POST":246 method = "GET"247248 return method249250 def redirect_url(self, request: AsyncRequest, response: AsyncResponse) -> URL:251 """252 Return the URL for the redirect to follow.253 """254 location = response.headers["Location"]255256 url = URL(location, allow_relative=True)257258 # Facilitate relative 'Location' headers, as allowed by RFC 7231.259 # (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')260 if url.is_relative_url:

Support Client(base_url=...)Tom Christiebefore adoption9d5aaff

line 261why, one step back
261 url = request.url.join(url)

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 262–378why, one step back
262
263 # Attach previous fragment if needed (RFC 7231 7.1.2)264 if request.url.fragment and not url.fragment:265 url = url.copy_with(fragment=request.url.fragment)266267 return url268269 def redirect_headers(self, request: AsyncRequest, url: URL) -> Headers:270 """271 Strip Authorization headers when responses are redirected away from272 the origin.273 """274 headers = Headers(request.headers)275 if url.origin != request.url.origin:276 del headers["Authorization"]277 return headers278279 def redirect_content(self, request: AsyncRequest, method: str) -> bytes:280 """281 Return the body that should be used for the redirect request.282 """283 if method != request.method and method == "GET":284 return b""285 if request.is_streaming:286 raise RedirectBodyUnavailable()287 return request.content288289290class AsyncClient(BaseClient):291 async def get(292 self,293 url: URLTypes,294 *,295 params: QueryParamTypes = None,296 headers: HeaderTypes = None,297 cookies: CookieTypes = None,298 stream: bool = False,299 auth: AuthTypes = None,300 allow_redirects: bool = True,301 cert: CertTypes = None,302 verify: VerifyTypes = None,303 timeout: TimeoutTypes = None,304 ) -> AsyncResponse:305 return await self.request(306 "GET",307 url,308 params=params,309 headers=headers,310 cookies=cookies,311 stream=stream,312 auth=auth,313 allow_redirects=allow_redirects,314 verify=verify,315 cert=cert,316 timeout=timeout,317 )318319 async def options(320 self,321 url: URLTypes,322 *,323 params: QueryParamTypes = None,324 headers: HeaderTypes = None,325 cookies: CookieTypes = None,326 stream: bool = False,327 auth: AuthTypes = None,328 allow_redirects: bool = True,329 cert: CertTypes = None,330 verify: VerifyTypes = None,331 timeout: TimeoutTypes = None,332 ) -> AsyncResponse:333 return await self.request(334 "OPTIONS",335 url,336 params=params,337 headers=headers,338 cookies=cookies,339 stream=stream,340 auth=auth,341 allow_redirects=allow_redirects,342 verify=verify,343 cert=cert,344 timeout=timeout,345 )346347 async def head(348 self,349 url: URLTypes,350 *,351 params: QueryParamTypes = None,352 headers: HeaderTypes = None,353 cookies: CookieTypes = None,354 stream: bool = False,355 auth: AuthTypes = None,356 allow_redirects: bool = False, #  Note: Differs to usual default.357 cert: CertTypes = None,358 verify: VerifyTypes = None,359 timeout: TimeoutTypes = None,360 ) -> AsyncResponse:361 return await self.request(362 "HEAD",363 url,364 params=params,365 headers=headers,366 cookies=cookies,367 stream=stream,368 auth=auth,369 allow_redirects=allow_redirects,370 verify=verify,371 cert=cert,372 timeout=timeout,373 )374375 async def post(376 self,377 url: URLTypes,378 *,

Multipart support (#90)Tom Christiebefore adoption6a44b05

lines 379–380why, one step back
379 data: AsyncRequestData = None,
380 files: RequestFiles = None,

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 381–395why, one step back
381 json: typing.Any = None,
382 params: QueryParamTypes = None,383 headers: HeaderTypes = None,384 cookies: CookieTypes = None,385 stream: bool = False,386 auth: AuthTypes = None,387 allow_redirects: bool = True,388 cert: CertTypes = None,389 verify: VerifyTypes = None,390 timeout: TimeoutTypes = None,391 ) -> AsyncResponse:392 return await self.request(393 "POST",394 url,395 data=data,

Multipart support (#90)Tom Christiebefore adoption6a44b05

line 396why, one step back
396 files=files,

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 397–412why, one step back
397 json=json,
398 params=params,399 headers=headers,400 cookies=cookies,401 stream=stream,402 auth=auth,403 allow_redirects=allow_redirects,404 verify=verify,405 cert=cert,406 timeout=timeout,407 )408409 async def put(410 self,411 url: URLTypes,412 *,

Multipart support (#90)Tom Christiebefore adoption6a44b05

lines 413–414why, one step back
413 data: AsyncRequestData = None,
414 files: RequestFiles = None,

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 415–429why, one step back
415 json: typing.Any = None,
416 params: QueryParamTypes = None,417 headers: HeaderTypes = None,418 cookies: CookieTypes = None,419 stream: bool = False,420 auth: AuthTypes = None,421 allow_redirects: bool = True,422 cert: CertTypes = None,423 verify: VerifyTypes = None,424 timeout: TimeoutTypes = None,425 ) -> AsyncResponse:426 return await self.request(427 "PUT",428 url,429 data=data,

Multipart support (#90)Tom Christiebefore adoption6a44b05

line 430why, one step back
430 files=files,

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 431–446why, one step back
431 json=json,
432 params=params,433 headers=headers,434 cookies=cookies,435 stream=stream,436 auth=auth,437 allow_redirects=allow_redirects,438 verify=verify,439 cert=cert,440 timeout=timeout,441 )442443 async def patch(444 self,445 url: URLTypes,446 *,

Multipart support (#90)Tom Christiebefore adoption6a44b05

lines 447–448why, one step back
447 data: AsyncRequestData = None,
448 files: RequestFiles = None,

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 449–463why, one step back
449 json: typing.Any = None,
450 params: QueryParamTypes = None,451 headers: HeaderTypes = None,452 cookies: CookieTypes = None,453 stream: bool = False,454 auth: AuthTypes = None,455 allow_redirects: bool = True,456 cert: CertTypes = None,457 verify: VerifyTypes = None,458 timeout: TimeoutTypes = None,459 ) -> AsyncResponse:460 return await self.request(461 "PATCH",462 url,463 data=data,

Multipart support (#90)Tom Christiebefore adoption6a44b05

line 464why, one step back
464 files=files,

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 465–480why, one step back
465 json=json,
466 params=params,467 headers=headers,468 cookies=cookies,469 stream=stream,470 auth=auth,471 allow_redirects=allow_redirects,472 verify=verify,473 cert=cert,474 timeout=timeout,475 )476477 async def delete(478 self,479 url: URLTypes,480 *,

Multipart support (#90)Tom Christiebefore adoption6a44b05

lines 481–482why, one step back
481 data: AsyncRequestData = None,
482 files: RequestFiles = None,

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 483–497why, one step back
483 json: typing.Any = None,
484 params: QueryParamTypes = None,485 headers: HeaderTypes = None,486 cookies: CookieTypes = None,487 stream: bool = False,488 auth: AuthTypes = None,489 allow_redirects: bool = True,490 cert: CertTypes = None,491 verify: VerifyTypes = None,492 timeout: TimeoutTypes = None,493 ) -> AsyncResponse:494 return await self.request(495 "DELETE",496 url,497 data=data,

Multipart support (#90)Tom Christiebefore adoption6a44b05

line 498why, one step back
498 files=files,

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 499–515why, one step back
499 json=json,
500 params=params,501 headers=headers,502 cookies=cookies,503 stream=stream,504 auth=auth,505 allow_redirects=allow_redirects,506 verify=verify,507 cert=cert,508 timeout=timeout,509 )510511 async def request(512 self,513 method: str,514 url: URLTypes,515 *,

Multipart support (#90)Tom Christiebefore adoption6a44b05

lines 516–517why, one step back
516 data: AsyncRequestData = None,
517 files: RequestFiles = None,

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 518–528why, one step back
518 json: typing.Any = None,
519 params: QueryParamTypes = None,520 headers: HeaderTypes = None,521 cookies: CookieTypes = None,522 stream: bool = False,523 auth: AuthTypes = None,524 allow_redirects: bool = True,525 cert: CertTypes = None,526 verify: VerifyTypes = None,527 timeout: TimeoutTypes = None,528 ) -> AsyncResponse:

Support Client(base_url=...)Tom Christiebefore adoption9d5aaff

lines 529–530why, one step back
529 url = self.base_url.join(url)
530 cookies = self.merge_cookies(cookies)

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 531–534why, one step back
531 request = AsyncRequest(
532 method,533 url,534 data=data,

Multipart support (#90)Tom Christiebefore adoption6a44b05

line 535why, one step back
535 files=files,

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 536–538why, one step back
536 json=json,
537 params=params,538 headers=headers,

Support Client(base_url=...)Tom Christiebefore adoption9d5aaff

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

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 540–567why, one step back
540 )
541 response = await self.send(542 request,543 stream=stream,544 auth=auth,545 allow_redirects=allow_redirects,546 verify=verify,547 cert=cert,548 timeout=timeout,549 )550 return response551552 async def close(self) -> None:553 await self.dispatch.close()554555 async def __aenter__(self) -> "AsyncClient":556 return self557558 async def __aexit__(559 self,560 exc_type: typing.Type[BaseException] = None,561 exc_value: BaseException = None,562 traceback: TracebackType = None,563 ) -> None:564 await self.close()565566567class Client(BaseClient):

Multipart support (#90)Tom Christiebefore adoption6a44b05

lines 568–570why, one step back
568 def _async_request_data(
569 self, data: RequestData = None570 ) -> typing.Optional[AsyncRequestData]:

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 571–574why, one step back
571 """
572 If the request data is an bytes iterator then return an async bytes573 iterator onto the request data.574 """

Include host header directly (#109)Tom Christiebefore adoption5539b69

line 575why, one step back
575 if data is None or isinstance(data, (str, bytes, dict)):

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 576–596why, one step back
576 return data
577578 # Coerce an iterator into an async iterator, with each item in the579 # iteration running as a thread-pooled operation.580 assert hasattr(data, "__iter__")581 return self.concurrency_backend.iterate_in_threadpool(data)582583 def _sync_data(self, data: AsyncResponseContent) -> ResponseContent:584 if isinstance(data, bytes):585 return data586587 # Coerce an async iterator into an iterator, with each item in the588 # iteration run within the event loop.589 assert hasattr(data, "__aiter__")590 return self.concurrency_backend.iterate(data)591592 def request(593 self,594 method: str,595 url: URLTypes,596 *,

Multipart support (#90)Tom Christiebefore adoption6a44b05

lines 597–598why, one step back
597 data: RequestData = None,
598 files: RequestFiles = None,

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 599–609why, one step back
599 json: typing.Any = None,
600 params: QueryParamTypes = None,601 headers: HeaderTypes = None,602 cookies: CookieTypes = None,603 stream: bool = False,604 auth: AuthTypes = None,605 allow_redirects: bool = True,606 cert: CertTypes = None,607 verify: VerifyTypes = None,608 timeout: TimeoutTypes = None,609 ) -> Response:

Support Client(base_url=...)Tom Christiebefore adoption9d5aaff

lines 610–611why, one step back
610 url = self.base_url.join(url)
611 cookies = self.merge_cookies(cookies)

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 612–615why, one step back
612 request = AsyncRequest(
613 method,614 url,615 data=self._async_request_data(data),

Multipart support (#90)Tom Christiebefore adoption6a44b05

line 616why, one step back
616 files=files,

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 617–619why, one step back
617 json=json,
618 params=params,619 headers=headers,

Support Client(base_url=...)Tom Christiebefore adoption9d5aaff

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

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 621–749why, one step back
621 )
622 concurrency_backend = self.concurrency_backend623624 coroutine = self.send625 args = [request]626 kwargs = dict(627 stream=True,628 auth=auth,629 allow_redirects=allow_redirects,630 verify=verify,631 cert=cert,632 timeout=timeout,633 )634 async_response = concurrency_backend.run(coroutine, *args, **kwargs)635636 content = getattr(637 async_response, "_raw_content", getattr(async_response, "_raw_stream", None)638 )639640 sync_content = self._sync_data(content)641642 def sync_on_close() -> None:643 nonlocal concurrency_backend, async_response644 concurrency_backend.run(async_response.on_close)645646 response = Response(647 status_code=async_response.status_code,648 protocol=async_response.protocol,649 headers=async_response.headers,650 content=sync_content,651 on_close=sync_on_close,652 request=async_response.request,653 history=async_response.history,654 )655 if not stream:656 try:657 response.read()658 finally:659 response.close()660 return response661662 def get(663 self,664 url: URLTypes,665 *,666 params: QueryParamTypes = None,667 headers: HeaderTypes = None,668 cookies: CookieTypes = None,669 stream: bool = False,670 auth: AuthTypes = None,671 allow_redirects: bool = True,672 cert: CertTypes = None,673 verify: VerifyTypes = None,674 timeout: TimeoutTypes = None,675 ) -> Response:676 return self.request(677 "GET",678 url,679 params=params,680 headers=headers,681 cookies=cookies,682 stream=stream,683 auth=auth,684 allow_redirects=allow_redirects,685 verify=verify,686 cert=cert,687 timeout=timeout,688 )689690 def options(691 self,692 url: URLTypes,693 *,694 params: QueryParamTypes = None,695 headers: HeaderTypes = None,696 cookies: CookieTypes = None,697 stream: bool = False,698 auth: AuthTypes = None,699 allow_redirects: bool = True,700 cert: CertTypes = None,701 verify: VerifyTypes = None,702 timeout: TimeoutTypes = None,703 ) -> Response:704 return self.request(705 "OPTIONS",706 url,707 params=params,708 headers=headers,709 cookies=cookies,710 stream=stream,711 auth=auth,712 allow_redirects=allow_redirects,713 verify=verify,714 cert=cert,715 timeout=timeout,716 )717718 def head(719 self,720 url: URLTypes,721 *,722 params: QueryParamTypes = None,723 headers: HeaderTypes = None,724 cookies: CookieTypes = None,725 stream: bool = False,726 auth: AuthTypes = None,727 allow_redirects: bool = False, #  Note: Differs to usual default.728 cert: CertTypes = None,729 verify: VerifyTypes = None,730 timeout: TimeoutTypes = None,731 ) -> Response:732 return self.request(733 "HEAD",734 url,735 params=params,736 headers=headers,737 cookies=cookies,738 stream=stream,739 auth=auth,740 allow_redirects=allow_redirects,741 verify=verify,742 cert=cert,743 timeout=timeout,744 )745746 def post(747 self,748 url: URLTypes,749 *,

Multipart support (#90)Tom Christiebefore adoption6a44b05

lines 750–751why, one step back
750 data: RequestData = None,
751 files: RequestFiles = None,

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 752–766why, one step back
752 json: typing.Any = None,
753 params: QueryParamTypes = None,754 headers: HeaderTypes = None,755 cookies: CookieTypes = None,756 stream: bool = False,757 auth: AuthTypes = None,758 allow_redirects: bool = True,759 cert: CertTypes = None,760 verify: VerifyTypes = None,761 timeout: TimeoutTypes = None,762 ) -> Response:763 return self.request(764 "POST",765 url,766 data=data,

Multipart support (#90)Tom Christiebefore adoption6a44b05

line 767why, one step back
767 files=files,

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 768–783why, one step back
768 json=json,
769 params=params,770 headers=headers,771 cookies=cookies,772 stream=stream,773 auth=auth,774 allow_redirects=allow_redirects,775 verify=verify,776 cert=cert,777 timeout=timeout,778 )779780 def put(781 self,782 url: URLTypes,783 *,

Multipart support (#90)Tom Christiebefore adoption6a44b05

lines 784–785why, one step back
784 data: RequestData = None,
785 files: RequestFiles = None,

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 786–800why, one step back
786 json: typing.Any = None,
787 params: QueryParamTypes = None,788 headers: HeaderTypes = None,789 cookies: CookieTypes = None,790 stream: bool = False,791 auth: AuthTypes = None,792 allow_redirects: bool = True,793 cert: CertTypes = None,794 verify: VerifyTypes = None,795 timeout: TimeoutTypes = None,796 ) -> Response:797 return self.request(798 "PUT",799 url,800 data=data,

Multipart support (#90)Tom Christiebefore adoption6a44b05

line 801why, one step back
801 files=files,

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 802–817why, one step back
802 json=json,
803 params=params,804 headers=headers,805 cookies=cookies,806 stream=stream,807 auth=auth,808 allow_redirects=allow_redirects,809 verify=verify,810 cert=cert,811 timeout=timeout,812 )813814 def patch(815 self,816 url: URLTypes,817 *,

Multipart support (#90)Tom Christiebefore adoption6a44b05

lines 818–819why, one step back
818 data: RequestData = None,
819 files: RequestFiles = None,

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 820–834why, one step back
820 json: typing.Any = None,
821 params: QueryParamTypes = None,822 headers: HeaderTypes = None,823 cookies: CookieTypes = None,824 stream: bool = False,825 auth: AuthTypes = None,826 allow_redirects: bool = True,827 cert: CertTypes = None,828 verify: VerifyTypes = None,829 timeout: TimeoutTypes = None,830 ) -> Response:831 return self.request(832 "PATCH",833 url,834 data=data,

Multipart support (#90)Tom Christiebefore adoption6a44b05

line 835why, one step back
835 files=files,

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 836–851why, one step back
836 json=json,
837 params=params,838 headers=headers,839 cookies=cookies,840 stream=stream,841 auth=auth,842 allow_redirects=allow_redirects,843 verify=verify,844 cert=cert,845 timeout=timeout,846 )847848 def delete(849 self,850 url: URLTypes,851 *,

Multipart support (#90)Tom Christiebefore adoption6a44b05

lines 852–853why, one step back
852 data: RequestData = None,
853 files: RequestFiles = None,

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 854–868why, one step back
854 json: typing.Any = None,
855 params: QueryParamTypes = None,856 headers: HeaderTypes = None,857 cookies: CookieTypes = None,858 stream: bool = False,859 auth: AuthTypes = None,860 allow_redirects: bool = True,861 cert: CertTypes = None,862 verify: VerifyTypes = None,863 timeout: TimeoutTypes = None,864 ) -> Response:865 return self.request(866 "DELETE",867 url,868 data=data,

Multipart support (#90)Tom Christiebefore adoption6a44b05

line 869why, one step back
869 files=files,

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 870–895why, one step back
870 json=json,
871 params=params,872 headers=headers,873 cookies=cookies,874 stream=stream,875 auth=auth,876 allow_redirects=allow_redirects,877 verify=verify,878 cert=cert,879 timeout=timeout,880 )881882 def close(self) -> None:883 coroutine = self.dispatch.close884 self.concurrency_backend.run(coroutine)885886 def __enter__(self) -> "Client":887 return self888889 def __exit__(890 self,891 exc_type: typing.Type[BaseException] = None,892 exc_value: BaseException = None,893 traceback: TracebackType = None,894 ) -> None:895 self.close()