xjD'ddlmZddlZddlZddlZddlZddlZddlZddlm Z m Z ddl m Z m Z ddlmZddlmZddlmZmZmZdd lmZmZmZmZmZmZmZmZmZmZm Z dd l!m"Z"dd l#m$Z$m%Z%m&Z&m'Z'dd l(m)Z)m*Z*m+Z+m,Z,dd l-m.Z.ddl/m0Z0ddl1m2Z2m3Z3ddl4m5Z5m6Z6ddl7m8Z8m9Z9m:Z:m;Z;mZ>m?Z?m@Z@mAZAmBZBmCZCmDZDddlEmFZFmGZGddlHmIZImJZJejr ddlLZLddlMmNZNmOZOgdZPejddZRejddZSd/dZTd0dZUd1dZVGddZWeWZXejd ZZd!eZ[d"je"jDcgc] }|d#k7s | c}Z^Gd$d%ejZ`Gd&d'eCZaGd(d)e8Zbejd*ejfZeGd+d,ZfGd-defZgGd.defZhycc}w)2) annotationsN)AsyncGenerator Generator)asynccontextmanagercontextmanager) TracebackType) __version__)Auth BasicAuth FunctionAuth) 'DEFAULT_KEEPALIVE_PING_INTERVAL_SECONDS&DEFAULT_KEEPALIVE_PING_TIMEOUT_SECONDSDEFAULT_LIMITSDEFAULT_MAX_EVENT_SIZE_BYTESDEFAULT_MAX_MESSAGE_SIZE_BYTESDEFAULT_MAX_REDIRECTSDEFAULT_QUEUE_SIZEDEFAULT_TIMEOUT_CONFIGLimitsProxyTimeout)SUPPORTED_DECODERS) InvalidURLRemoteProtocolErrorTooManyRedirectsrequest_context)CookiesHeadersRequestResponse) EventSource)codes)AsyncHTTPTransport HTTPTransport)AsyncBaseTransport BaseTransport) AsyncByteStream AuthTypes CertTypes CookieTypes HeaderTypes ProxyTypesQueryParamTypesRequestContent RequestDataRequestExtensions RequestFilesSyncByteStream TimeoutTypes)URL QueryParams) URLPatternget_environment_proxies)AsyncWebSocketSessionWebSocketSession)USE_CLIENT_DEFAULT AsyncClientClientTr=)boundUr<c|j|jk7ry|jdk(xr/t|dk(xr|jdk(xrt|dk(S)zA Return 'True' if 'location' is a HTTPS upgrade of 'url' FhttpPhttps)hostscheme_port_or_default)urllocations b/mnt/ssd/data/Dropbox/adrian/sandbox/mcp-query/venv/lib/python3.12/site-packages/httpx2/_client.py_is_https_redirectrLGsa xx8==  f . S !R ' . OOw & . X &# - cn|j |jSdddj|jS)NrCrE)rBrD)portgetrGrIs rKrHrHVs/ xxxx % ) )#** 55rMc|j|jk(xr2|j|jk(xrt|t|k(S)z@ Return 'True' if the given URLs share the same origin. )rGrFrH)rIothers rK _same_originrT\sA :: % u#((ejj*@ uEUVYEZ^not^uEuurMceZdZdZy)UseClientDefaulta< For some parameters such as `auth=...` and `timeout=...` we need to be able to indicate the default "unset" state, in a way that is distinctly different to using `None`. The default "unset" state indicates that whatever default is set on the client should be used. This is different to setting `None`, which explicitly disables the parameter, possibly overriding a client default. For example we use `timeout=USE_CLIENT_DEFAULT` in the `request()` signature. Omitting the `timeout` parameter will send a request using whatever default timeout has been configured on the client. Including `timeout=None` will ensure no timeout is used. Note that user code shouldn't need to use the `USE_CLIENT_DEFAULT` constant, but it is used internally when a parameter is not included. N)__name__ __module__ __qualname____doc__rMrKrVrVcsrMrVhttpx2zpython-httpx2/z, identityceZdZdZdZdZy) ClientStater N)rWrXrYUNOPENEDOPENEDCLOSEDr[rMrKr_r_sHFFrMr_c(eZdZdZddZddZddZy) BoundSyncStreamz A byte stream that tracks elapsed time for a response. Once closed, the elapsed time is available via the `elapsed` attribute, and the response can read it back from `response.stream.elapsed`. c.||_||_d|_yN_stream_startelapsedselfstreamstarts rK__init__zBoundSyncStream.__init__  26 rMc#8K|jEd{y7wrhrjrns rK__iter__zBoundSyncStream.__iter__s<<s ctjtj|jz |_|j jyN)seconds)datetime timedeltatime perf_counterrkrlrjcloserus rKr~zBoundSyncStream.closes6))$2C2C2E 2ST  rMN)ror3rpfloatreturnNone)rztyping.Iterator[bytes]rr)rWrXrYrZrqrvr~r[rMrKrfrfs 7  rMrfc(eZdZdZddZddZddZy) BoundAsyncStreamz An async byte stream that tracks elapsed time for a response. Once closed, the elapsed time is available via the `elapsed` attribute, and the response can read it back from `response.stream.elapsed`. c.||_||_d|_yrhrirms rKrqzBoundAsyncStream.__init__rrrMcHK|j23d{}|7 6ywrhrt)rnchunks rK __aiter__zBoundAsyncStream.__aiter__s&<<  %K dZd|r:tjDcic]\}}||dn t|c}}SiSt|tt fr t|n|}d|iScc}}w)NrQzall://)r8itemsr isinstancestrr5)rnproxyallow_env_proxieskeyrIs rK_get_proxy_mapzBaseClient._get_proxy_mapsi = UlUnUtUtUvwcS[TenDwwI(253*(EEe$5Ee$ $ xsA)c|jSrh)rrus rKrzBaseClient.timeouts }}rMc$t||_yrh)rr)rnrs rKrzBaseClient.timeout( rMc|jSrh)rrus rKrzBaseClient.event_hookss   rMc|t|jdgt|jdgd|_yr)rrPr)rnrs rKrzBaseClient.event_hookss4KOOIr:;[__Z<= rMc|jS)z Authentication class used when none is passed at the request-level. See also [Authentication][0]. [0]: /quickstart/#authentication )rrus rKrzBaseClient.auth szzrMc0|j||_yrh)rrrnrs rKrzBaseClient.auths%%d+ rMc|jS)zK Base URL to use when sending requests with relative URLs. )rrus rKrzBaseClient.base_urls ~~rMcB|jt||_yrh)rr5rrs rKrzBaseClient.base_urls55c#h?rMc|jS)z@ HTTP headers to include when sending requests. )_headersrus rKrzBaseClient.headers# }}rMctdtjddtjdd}|j |||_y)Ns*/*asciis keep-alive)sAcceptsAccept-Encodings Connections User-Agent)rACCEPT_ENCODINGencode USER_AGENTupdater)rnrclient_headerss rKrzBaseClient.headers*sJ !$3$:$:7$C,)009    g&& rMc|jS)zA Cookie values to include when sending requests. )rrus rKrzBaseClient.cookies7rrMc$t||_yrh)rr)rnrs rKrzBaseClient.cookies>rrMc|jS)zO Query parameters to include in the URL when sending requests. )rrus rKrzBaseClient.paramsBs ||rMc$t||_yrh)r6r)rnrs rKrzBaseClient.paramsIs"6* rM) contentdatafilesjsonrrrr extensionsc P|j|}|j|}|j| } |j|}| in| } d| vrDt | t r |j n t| } tdi| d| ji} t||||||||| |  S)aR Build and return a request instance. * The `params`, `headers` and `cookies` arguments are merged with any values set on the client. * The `url` argument is merged with any `base_url` set on the client. See also: [Request instances][0] [0]: /advanced/clients/#request-instances r)rrrrrrrrr[) _merge_url_merge_headers_merge_cookies_merge_queryparamsrrVrrdictas_dictr ) rnmethodrIrrrrrrrrrs rK build_requestzBaseClient.build_requestMs4ooc"%%g.%%g.((0%-R: J &&0:J&KdllQXY`QaGF FGOO4EFJ  !  rMct|}|jrN|jj|jj dz}|jj |S|S)z Merge a URL argument together with any 'base_url' on the client, to create the URL used for the outgoing request. rr)r5is_relative_urlrrlstripr)rnrI merge_urlmerge_raw_paths rKrzBaseClient._merge_url|s\ H  $ $"]]33i6H6H6O6OPT6UUN==**N*C CrMcr|s |jr(t|j}|j||S|S)z Merge a cookies argument together with any cookies on the client, to create the cookies used for the outgoing request. )rrr)rnrmerged_cookiess rKrzBaseClient._merge_cookiess4 dll$T\\2N  ! !' *! !rMcRt|j}|j||S)z Merge a headers argument together with any headers on the client, to create the headers used for the outgoing request. )rrr)rnrmerged_headerss rKrzBaseClient._merge_headerss& !.g&rMcn|s |jr&t|j}|j|S|S)z Merge a queryparams argument together with any queryparams on the client, to create the queryparams used for the outgoing request. )rr6merge)rnrmerged_queryparamss rKrzBaseClient._merge_queryparamss2 T[[!,T[[!9 %++F3 3 rMc|yt|trt|d|dSt|tr|St |r t |St d|)Nrr usernamepassword)funczInvalid "auth" argument: )rtupler r callabler TypeErrorrs rKrzBaseClient._build_auths] < e $d1gQ@ @ d #K d^T* *7x@A ArMct|tr |jn|j|}||S|jj |jj }}|s|r t||StS)Nr) rrVrrrIrrr r )rnrrrrs rK_build_request_authzBaseClient._build_request_authsf (.>?tzzTEUEUVZE[  K$[[117;;3G3G( xhB Bv rMc|j||}|j||}|j|||}|j||}t |j }t ||||||jS)z Given a request and a redirect response, return a new request that should be used to effect the redirect. )rrIrrror)_redirect_method _redirect_url_redirect_headers_redirect_streamrrr r)rnrrrrIrrors rK_build_redirect_requestz"BaseClient._build_redirect_requests &&w9  (3((#v>&&w7$,,'))   rMc|j}|jtjk(r|dk7rd}|jtjk(r|dvrd}|jtj k(r|dk(rd}|S)z When being redirected we may want to change the method of the request based on certain specs or browser behavior. HEADGET)rQUERYPOST)r status_coder# SEE_OTHERFOUNDMOVED_PERMANENTLY)rnrrrs rKrzBaseClient._redirect_methodsu    5?? 2v7GF   5;; .6AR3RF   5#:#: :v?OF rMc|jd} t|}|jr2|j s&|j |jj }|jr|jj|}|jjr2|js&|j |jj}|S#t$r}td|d|dd}~wwxYw)z< Return the URL for the redirect to follow. Locationz Invalid URL in location header: .rN)rF)fragment) rr5rrrGrFrrIrjoinr )rnrrrJrIexcs rKrzBaseClient._redirect_urls##J/ lh-C ::chh--W[[%5%5-6C   ++""3'C ;;   --)=)=->C # l%(HQ&OY`agk k ls C C+C&&C+c|t|j}t||jsFt |j|s|j dd|j jd|d<||jk7r)|dk(r$|j dd|j dd|j dd|S) zR Return the headers that should be used for the redirect request. AuthorizationNrHostrzContent-LengthzTransfer-EncodingCookie) rrrTrIrLpopnetlocdecoder)rnrrIrrs rKrzBaseClient._redirect_headerss'//*C-%gkk37 OT2"jj//8GFO W^^ #% KK($ / KK+T 2  Hd#rMcD||jk7r|dk(ry|jS)zO Return the body that should be used for the redirect request. rN)rro)rnrrs rKrzBaseClient._redirect_stream.s# W^^ #%~~rMcd|jvrht|jtr |jnt |j}t di|jd|j i|_yy)Nrr[)rrrrVrrr)rnrrs rK _set_timeoutzBaseClient._set_timeout7s] G.. .&0?O&PdllV]^b^j^jVkG!%!V(:(:!VGOODU!VG  /rM)rAuthTypes | NonerQueryParamTypes | NonerHeaderTypes | NonerCookieTypes | Nonerr4rboolrintr+None | typing.Mapping[str, list[EventHook]]r URL | strrrr*str | typing.Callable[[bytes], str | None]rr)rr)rIr5rr5)rProxyTypes | Nonerrrzdict[str, Proxy | None])rr)rr4rr)rdict[str, list[EventHook]])rr#rr)r Auth | None)rr)rr)rr5)rIr rr)rr)rr,rr)rr)rr+rr)rr6)rr.rr)rrrIr rRequestContent | NonerRequestData | NonerRequestFiles | Nonertyping.Any | NonerrrrrrrTimeoutTypes | UseClientDefaultrRequestExtensions | Nonerr )rIr rr5rh)rrrr)rrrr)rrrr)rrrr$)rr r#AuthTypes | UseClientDefault | Nonerr )rr rr!rr )rr rr!rr)rr rr!rr5)rr rIr5rrrr)rr rrrz'SyncByteStream | AsyncByteStream | None)rr rr)!rWrXrYrrrqpropertyrrrrrsetterrrrrrrr;rrrrrrrrrrrrrr[rMrKrrs"&)-&*&* 6!&2EI GN + +' + $ + $ + + + +C + + +E +  +D11 ; % ^^))!!   [[,, __@@  ^^ ' '  ^^))  ]]++*.#'%)"&)-&*&*3E/3- - - ' - ! - #-  - '- $- $- 1- --  - ^,  B5G2    &266WrMrcdeZdZdZdddddddddddedeeddddd d%fdZdddddedf d&d Zdddddef d'd Z d(d Z ddddddde e e dd d)d Z e ddddddde e e dd d*dZe dddddddde e e ded d+dZe eeeedddde e e dd d,dZde e d d-dZ d.dZ d/dZd0dZddde e e dd d1dZddde e e dd d2dZddde e e dd d2dZddddddde e e dd d3dZddddddde e e dd d3dZddddddde e e dd d3dZddde e e dd d2d Z ddddddde e e dd d3d!Z!d4d"Z"d5d#Z# d6 d7d$Z$xZ%S)8r=a An HTTP client, with connection pooling, HTTP/2, redirects, cookie persistence, etc. It can be shared between threads. Usage: ```python >>> client = httpx2.Client() >>> response = client.get('https://example.org') ``` **Parameters:** * **auth** - *(optional)* An authentication class to use when sending requests. * **params** - *(optional)* Query parameters to include in request URLs, as a string, dictionary, or sequence of two-tuples. * **headers** - *(optional)* Dictionary of HTTP headers to include when sending requests. * **cookies** - *(optional)* Dictionary of Cookie items to include when sending requests. * **verify** - *(optional)* Either `True` to use an SSL context with the default CA bundle, `False` to disable verification, or an instance of `ssl.SSLContext` to use a custom context. * **http2** - *(optional)* A boolean indicating if HTTP/2 support should be enabled. Defaults to `False`. * **proxy** - *(optional)* A proxy URL where all the traffic should be routed. * **mounts** - *(optional)* A dictionary mapping URL patterns to transports, used to route requests through specific transports based on the URL. * **timeout** - *(optional)* The timeout configuration to use when sending requests. * **limits** - *(optional)* The limits configuration to use. * **max_redirects** - *(optional)* The maximum number of redirect responses that should be followed. * **base_url** - *(optional)* A URL to use as the base when building request URLs. * **transport** - *(optional)* A transport class to use for sending requests over the network. * **trust_env** - *(optional)* Enables or disables usage of environment variables for configuration. * **default_encoding** - *(optional)* The default encoding to use for decoding response text, if no charset information is included in a response Content-Type header. Set to a callable for automatic character set detection. Default: "utf-8". NTFrr)rrrrverifycertrhttp1http2rmountsrrlimitsrrr transportrct|||||| | ||||| | r ddl}|xr|du}|j | |}|j ||||| |||_|jD cic]+\}} t|| dn|j| ||||| |-c} }|_ | F|jj| jDcic]\}}t||c}}tt|jj|_ y#t$r tddwxYwcc} }wcc}}wNrrzuUsing http2=True, but the 'h2' package is not installed. Make sure to install httpx using `pip install httpx[http2]`.)r/r0rr1r2r4r5r/r0rr1r2r4superrqh2 ImportErrorr_init_transport _transportrr7_init_proxy_transport_mountsrrsorted)rnrrrrr/r0rr1r2rr3rrr4rrrr5rr;r proxy_mapr __class__s rKrqzClient.__init__ls. -'#-    &;)t*;''/@A ../ *(oo/ @ U sO}"++#,  @     LL  RXR^R^R` aYC)!; a bF4<<#5#5#789 G !S $ @ !bD -0D9D? D6c,||St||||||SNr8r%rnr/r0rr1r2r4r5s rKr=zClient._init_transports/      rMc &t|||||||SN)r/r0rr1r2r4rrGrnrr/r0rr1r2r4s rKr?zClient._init_proxy_transports&  rMc|jjD]*\}}|j|s||jcS|cS|jSz Returns the transport instance that should be used for a given URL. This will either be the standard connection pool, or a proxy. r@rmatchesr>rnrIpatternr5s rK_transport_for_urlzClient._transport_for_urlS #',,"4"4"6 K GYs#*3*;tJJ KrM rrrrrrrrrrrc | d}tj|td|j||||||||| | |  }|j || | S)a Build and send a request. Equivalent to: ```python request = client.build_request(...) response = client.send(request, ...) ``` See `Client.build_request()`, `Client.send()` and [Merging of configuration][0] for how the various parameters are merged with client-level configuration. [0]: /advanced/clients/#merging-of-configuration Setting per-request cookies=<...> is being deprecated, because the expected behaviour on cookie persistence is ambiguous. Set cookies directly on the client instance instead.r` stacklevel rrIrrrrrrrrrrrwarningswarnDeprecationWarningrsendrnrrIrrrrrrrrrrrmessagers rKrzClient.requestswB  C  MM'#5! D$$!%  yyt>NyOOrMc #K|j||||||||| | |  }|j|| | d} ||jy#|jwxYwwa Alternative to `httpx2.request()` that streams the response body instead of loading it into memory at once. **Parameters**: See `httpx2.request`. See also: [Streaming Responses][0] [0]: /quickstart#streaming-responses rYT)rrrroN)rr_r~rnrrIrrrrrrrrrrrrrs rKroz Client.stream&s}8$$!%  99-    N NN HNN s2AA A AAr rrrrrrrrrrrrmax_event_sizec #K|j|||||||dddt|z| | | | |  5}t||dddy#1swYyxYww) Connect to a server-sent events endpoint and yield an `EventSource`. Iterating the `EventSource` yields `ServerSentEvent` instances. **Parameters**: See `httpx2.request`. text/event-streamno-storeAcceptz Cache-ControlrTrfNrorr"rnrIrrrrrrrrrrrrrfrs rKssez Client.sseZs{4[[  2ZPSZ[bScc-!  Gh~F F G G Gs.AA  A AA max_message_size_bytes queue_sizekeepalive_ping_interval_secondskeepalive_ping_timeout_seconds subprotocolsrrrrrrrc #K ddlm}|t|||||||||| | | | | 5}|dddy#t$r tdwxYw#1swYyxYww)az Open a WebSocket session, using this client's configuration. The session is closed automatically when exiting the context manager. ```python with httpx2.Client() as client: with client.websocket("ws://localhost:8000/ws") as ws: ws.send_text("Hello!") message = ws.receive_text() ``` r ) connect_ws[WebSocket support requires the `wsproto` package. Install it with `pip install httpx2[ws]`.rqN)websockets._apirxr<r)rnrIrrrsrtrurvrrrrrrrrxsessions rK websocketzClient.websockets<  3  H #9!,K+I%-!  M!    m     s/A7AA AA  AAArorrc|jtjk(r tdtj|_t |t r |jn|}|j||j||}|j|||g} |s|j|S#t$r}|j|d}~wwxYw)a Send a request. The request is sent as-is, unmodified. Typically you'll want to build one with `Client.build_request()` so that any client-level configuration is merged into the request, but passing an explicit `httpx2.Request()` is supported as well. See also: [Request instances][0] [0]: /advanced/clients/#request-instances 5Cannot send a request, as the client has been closed.rrhistoryN)rr_rd RuntimeErrorrcrrVrrr_send_handling_authread BaseExceptionr~rnrrorrrrs rKr_z Client.sends* ;;+,, ,VW W!(( 4>?OQa4b400hx '"''6++ - ,    O  NN I sB)) C 2CC c|j|} t|} |j|||} |j|}t ||_|j|}|j|[#t$r|cY|j SwxYw#t$r}|j |d}~wwxYw#|j wxYwN)rr) sync_auth_flownext_send_handling_redirectsr_ StopIterationr~rrrappendr rnrrrr auth_flowr next_requestrs rKrzClient._send_handling_auths''0  9oG88%5#9 ('0~~h'? (,G}H$MMO*GNN8,)(' OO (%NN$I OO sL B>A:3B9B>: BBBB B;$B66B;;B>>Cc t||jkDr td||jdD] }|| |j |} |jdD] }|| t ||_|js|S|j||}||gz}|r|jn ||_ |S #t$r}|j|d}~wwxYwNz#Exceeded maximum allowed redirects.r rr) lenrrr_send_single_requestrrhas_redirect_locationrrrrr~rnrrrhookrrs rKrzClient._send_handling_redirects s 7|d000&'LV]^^)))4 W  009H  --j9#DN##'= 55#O66wI!XJ.#MMO,3H)#O$)2!    s9C3C C%C  C%c|j|j}tj}t |j t s tdt|5|j|}dddt j t sJ||_ t|j ||_|jj||j|_t j#d|j$|j|j&|j(|j*|S#1swYxYw)L Sends a single request, without handling any redirections. z?Attempted to send an async request with a sync Client instance.r NrpHTTP Request: %s %s "%s %d %s")rRrIr|r}rror3rrhandle_requestrrfrextract_cookiesrrloggerinfor http_versionr reason_phrasernrr5rprs rKrzClient._send_single_request0s++GKK8 !!#'...9`a a W - 9 //8H 9(//>:::")(//G $$X.$($:$:! , NN KK  ! !   " "  ' 9 9s !D44D=rrrrrrrc 6|jd|||||||| S)V Send a `GET` request. **Parameters**: See `httpx2.request`. rrr  rnrIrrrrrrrs rKrPz Client.getOs5"||  -!  rMc 6|jd|||||||| S)[ Send an `OPTIONS` request. **Parameters**: See `httpx2.request`. OPTIONSrr rs rKoptionszClient.optionsls5"||  -!  rMc 6|jd|||||||| S)W Send a `HEAD` request. **Parameters**: See `httpx2.request`. rrr rs rKheadz Client.heads5"||  -!  rMc >|jd||||||||| | | |  S)W Send a `POST` request. **Parameters**: See `httpx2.request`. rrTr  rnrIrrrrrrrrrrrs rKpostz Client.postsA*||  -!  rMc >|jd||||||||| | | |  S)V Send a `PUT` request. **Parameters**: See `httpx2.request`. PUTrTr rs rKputz Client.putsA*||  -!  rMc >|jd||||||||| | | |  S)X Send a `PATCH` request. **Parameters**: See `httpx2.request`. PATCHrTr rs rKpatchz Client.patchA*||  -!  rMc 6|jd|||||||| S)Y Send a `DELETE` request. **Parameters**: See `httpx2.request`. DELETErr rs rKdeletez Client.deletes5"||  -!  rMc >|jd||||||||| | | |  S)X Send a `QUERY` request. **Parameters**: See `httpx2.request`. rrTr rs rKqueryz Client.query2rrMc|jtjk7rbtj|_|jj |j j D]}||j yyz. Close transport and proxies. N)rr_rdr>r~r@values)rnr5s rKr~z Client.closeWsd ;;+,, ,%,,DK OO ! ! #!\\002 & (OO% & -rMcv|jtjk7r:tjdtjdi|j}t |tj|_|j j|jjD]}||j|SNz-Cannot open a client instance more than once.z9Cannot reopen a client instance, once it has been closed.) rr_rbrcrdrr> __enter__r@r)rnmsgr5s rKrzClient.__enter__cs ;;+.. .""$S""%`kkCs# #!((  !!#,,. &I$##% & rMctj|_|jj ||||j j D]}||j |||yrh)r_rdrr>__exit__r@r)rnexc_type exc_value tracebackr5s rKrzClient.__exit__ss] "((    9i@,,. CI$""8Y B CrM)(rrrrrrrrr/ssl.SSLContext | str | boolr0CertTypes | Nonerrr1rr2rrr"r3z0None | typing.Mapping[str, BaseTransport | None]rr4rrr4rrrrrrr r5BaseTransport | Nonerr!rr)r/rr0rrrr1rr2rr4rr5rrr')rrr/rr0rrrr1rr2rr4rrr')rIr5rr'rrrIr rr%rr&rr'rr(rrrrrrrr+rbool | UseClientDefaultrr)rr*rr!)rrrIr rr%rr&rr'rr(rrrrrrrr+rrrr)rr*rzGenerator[Response])rIr rrrr%rr&rr'rr(rrrrrrrr+rrrr)rr*rf int | NonerzGenerator[EventSource])rIr rrrrsrrt float | Nonerurrvlist[str] | Nonerrrrrrrr+rrrr)rr*rzGenerator[WebSocketSession] rr rorrr+rrrr! rr rr rrrlist[Response]rr!rr rrrrrr!rr rr!rIr rrrrrrrr+rrrr)rr*rr!rIr rrrrrrrAuthTypes | UseClientDefaultrrrr)rr*rr!rIr rr%rr&rr'rr(rrrrrrrrrrrr)rr*rr!r)rnr>rr>NNNrztype[BaseException] | NonerzBaseException | NonerzTracebackType | Nonerr)&rWrXrYrZrrrrqr=r?rRr;rrrorrprrrrr|r_rrrrPrrrrrrrr~rr __classcell__rCs@rKr=r==s ,b"&)-&*&*.2!%#'EI 6!&'2EI *.GN+K:K:' K: $ K: $ K:,K:K:K:K:K:!K:CK:K:K: !K:"#K:$C%K:&'K:(()K:*E+K:, -K:^/3!%'*. +         (   2/3!%'  ,           (  *.#'%)"&)-&*&*4F4F3E/36P6P6P ' 6P ! 6P#6P 6P'6P$6P$6P26P26P16P-6P !6Pp *.#'%)"&)-&*&*4F4F3E/3111 ' 1 ! 1#1 1'1$1$1212111-1 !11f )-#'%)"&)-&*&*4F4F3E/3%A!(G (G (G ' (G ! (G#(G (G'(G$(G$(G2(G2(G1(G-(G #!(G" #(G(GT 'E,8_7])-)-&*&*4F4F3E/34 4!$ 4  4 *6 4)54'4'4$4$4242414-4 %!44t4F4F -- - 2 - 2 - -^        D!!! !  !FF*.&*&*4F4F3E/3  '  $  $  2 2 1 -   B*.&*&*-?4F3E/3  '  $  $  + 2 1 -   B*.&*&*-?4F3E/3  '  $  $  + 2 1 -   B*.#'%)"&)-&*&*-?4F3E/3# # ' # ! # # #  # '# $# $# +# 2# 1# -#  # R*.#'%)"&)-&*&*-?4F3E/3# # ' # ! # # #  # '# $# $# +# 2# 1# -#  # R*.#'%)"&)-&*&*-?4F3E/3# # ' # ! # # #  # '# $# $# +# 2# 1# -#  # R*.&*&*-?4F3E/3  '  $  $  + 2 1 -   B*.#'%)"&)-&*&*-?4F3E/3# # ' # ! # # #  # '# $# $# +# 2# 1# -#  # J &$04*.*. C, C( C( C  CrMcdeZdZdZddddddddddedeedddddd d%fdZdddddedf d&d Zdddddef d'd Z d(d Z ddddddde e e dd d)d Z e ddddddde e e dd d*dZe dddddddde e e ded d+dZe eeeedddde e e dd d,dZde e d d-dZ d.dZ d/dZd0dZddde e e dd d1dZddde e e dd d2dZddde e e dd d2dZddddddde e e dd d3dZddddddde e e dd d3dZddddddde e e dd d3dZddde e e dd d2d Z ddddddde e e dd d3d!Z!d4d"Z"d5d#Z# d6 d7d$Z$xZ%S)8r<a< An asynchronous HTTP client, with connection pooling, HTTP/2, redirects, cookie persistence, etc. It can be shared between tasks. Usage: ```python >>> async with httpx2.AsyncClient() as client: >>> response = await client.get('https://example.org') ``` **Parameters:** * **auth** - *(optional)* An authentication class to use when sending requests. * **params** - *(optional)* Query parameters to include in request URLs, as a string, dictionary, or sequence of two-tuples. * **headers** - *(optional)* Dictionary of HTTP headers to include when sending requests. * **cookies** - *(optional)* Dictionary of Cookie items to include when sending requests. * **verify** - *(optional)* Either `True` to use an SSL context with the default CA bundle, `False` to disable verification, or an instance of `ssl.SSLContext` to use a custom context. * **http2** - *(optional)* A boolean indicating if HTTP/2 support should be enabled. Defaults to `False`. * **proxy** - *(optional)* A proxy URL where all the traffic should be routed. * **mounts** - *(optional)* A dictionary mapping URL patterns to transports, used to route requests through specific transports based on the URL. * **timeout** - *(optional)* The timeout configuration to use when sending requests. * **limits** - *(optional)* The limits configuration to use. * **max_redirects** - *(optional)* The maximum number of redirect responses that should be followed. * **base_url** - *(optional)* A URL to use as the base when building request URLs. * **transport** - *(optional)* A transport class to use for sending requests over the network. * **trust_env** - *(optional)* Enables or disables usage of environment variables for configuration. * **default_encoding** - *(optional)* The default encoding to use for decoding response text, if no charset information is included in a response Content-Type header. Set to a callable for automatic character set detection. Default: "utf-8". NTFrr)rrrrr/r0r1r2rr3rrr4rrrr5rrct|||||| | ||||| |r ddl}|xr|du}|j | |}|j |||||| ||_|jD cic]+\}} t|| dn|j| |||||| -c} }|_ | F|jj| jDcic]\}}t||c}}tt|jj|_ y#t$r tddwxYwcc} }wcc}}wr7r9)rnrrrrr/r0r1r2rr3rrr4rrrr5rrr;rrBrrCs rKrqzAsyncClient.__init__s. -'#-    &;)t*;''/@A ../ ,(oo/ E U sO}"++#,  E     LL  RXR^R^R` aYC)!; a bF4<<#5#5#789 G !S & E !brDc,||St||||||SrFr$rHs rKr=zAsyncClient._init_transports/   !   rMc &t|||||||SrJrrKs rKr?z!AsyncClient._init_proxy_transports&"  rMc|jjD]*\}}|j|s||jcS|cS|jSrMrNrPs rKrRzAsyncClient._transport_for_url(rSrMrTc K| d}tj|td|j||||||||| | |  }|j || | d{S7w)a Build and send a request. Equivalent to: ```python request = client.build_request(...) response = await client.send(request, ...) ``` See `AsyncClient.build_request()`, `AsyncClient.send()` and [Merging of configuration][0] for how the various parameters are merged with client-level configuration. [0]: /advanced/clients/#merging-of-configuration NrVr`rWrYrZr[r`s rKrzAsyncClient.request3sD  C  MM'#5! D$$!%  YYwTDTYUUUUsAAAAc K|j||||||||| | |  }|j|| | dd{} ||jd{y7#7#|jd{7wxYwwrc)rr_rrds rKrozAsyncClient.streamls8$$!%  - #    $N//# # #  $(//# # #sD5A=AA=AA=AA=A=A:3A64A::A=rrec K|j|||||||dddt|z| | | | |  4d{}t||dddd{y7%7#1d{7swYyxYww)rhrirjrkrTNrmrnros rKrpzAsyncClient.sses4;;  2ZPSZ[bScc-!  G Gh~F F G G G G G G GsD2A3AA3A A3AA3A3A0$A' %A0,A3rqc K ddlm}|t|||||||||| | | | | 4d{}|dddd{y#t$r tdwxYw727#1d{7swYyxYww)a Open a WebSocket session, using this client's configuration. The session is closed automatically when exiting the context manager. ```python async with httpx2.AsyncClient() as client: async with client.websocket("ws://localhost:8000/ws") as ws: await ws.send_text("Hello!") message = await ws.receive_text() ``` r ) aconnect_wsryrqN)rzrr<r)rnrIrrrsrtrurvrrrrrrrrr{s rKr|zAsyncClient.websockets<  4  H #9!,K+I%-!   M!     m        sYA9A#A9A A9A$ A9A"A9AA9"A9$A6*A- +A62A9r}cK|jtjk(r tdtj|_t |t r |jn|}|j||j||}|j|||gd{} |s|jd{|S7!7#t$r }|jd{7|d}~wwxYww)a Send a request. The request is sent as-is, unmodified. Typically you'll want to build one with `AsyncClient.build_request()` so that any client-level configuration is merged into the request, but passing an explicit `httpx2.Request()` is supported as well. See also: [Request instances][0] [0]: /advanced/clients/#request-instances rrN)rr_rdrrcrrVrrrrareadrrrs rKr_zAsyncClient.sends* ;;+,, ,VW W!(( 4>?OQa4b400hx '"''611 - 2    nn&&&O ' //# # #I sTBC+B;C+B?4B=5B?:C+=B?? C(C#CC##C((C+c>K|j|} |jd{} |j|||d{} |j|d{}t ||_|jd{|}|j|s7x7]7D#t$r|cY|j d{7SwxYw7H#t$r }|j d{7|d}~wwxYw#|j d{7wxYwwr) async_auth_flow __anext__rasendStopAsyncIterationrrrrrrrs rKrzAsyncClient._send_handling_auth1s((1  %%//11G!%!>!>%5#"?" (-6__X-F'F (,G}H$"..****GNN8,2(G-('""$ $ $(+%"//+++I""$ $ $sDC?B!C?B#C? B' B%!B'%#CC C C?#C?%B'' C2C3DC D CC C<C7/C20C77C<<C??DDDDc:K t||jkDr td||jdD]}||d{|j |d{} |jdD]}||d{t ||_|js|S|j||}||gz}|r|jd{n ||_ |S 777f7#t$r }|jd{7|d}~wwxYwwr) rrrrrrrrrrrrrrs rKrz$AsyncClient._send_handling_redirectsSs3 7|d000&'LV]^^)))4 $7m## $"66w??H  --j9)Dx.(()$(= 55#O66wI!XJ.#"..***,3H)#O++ $?)+ ! oo'''  sADC'D!C)"D'C/C+#C/(D)-C/C- C/$D)D+C/-C// D8D D DDDcK|j|j}tj}t |j t s tdt|5|j|d{}dddt j t sJ||_ t|j ||_|jj||j|_t j#d|j$|j|j&|j(|j*|S7#1swYxYww)rz>Attempted to send a sync request with an AsyncClient instance.r Nrr)rRrIr|r}rror(rrhandle_async_requestrrrrrrrrrrrrrs rKrz AsyncClient._send_single_requestws ++GKK8 !!#'../:_` ` W - E&;;GDDH E(//?;;;"*8??%H $$X.$($:$:! , NN KK  ! !   " "  #E E Es1A!E #E8D>9E=CE >EE E rc RK|jd|||||||| d{S7w)rrrNr rs rKrPzAsyncClient.getsC"\\  -!"    '%'c RK|jd|||||||| d{S7w)rrrNr rs rKrzAsyncClient.optionssC"\\  -!"    rc RK|jd|||||||| d{S7w)rrrNr rs rKrzAsyncClient.headsC"\\  -!"    rc ZK|jd||||||||| | | |  d{S7w)rrrTNr rs rKrzAsyncClient.postsO*\\  -!"    "+)+c ZK|jd||||||||| | | |  d{S7w)rrrTNr rs rKrzAsyncClient.putsO*\\  -!"    rc ZK|jd||||||||| | | |  d{S7w)rrrTNr rs rKrzAsyncClient.patch6O*\\  -!"    rc RK|jd|||||||| d{S7w)rrrNr rs rKrzAsyncClient.delete[sC"\\  -!"    rc ZK|jd||||||||| | | |  d{S7w)rrrTNr rs rKrzAsyncClient.queryxrrc2K|jtjk7rrtj|_|jj d{|j j D]}||j d{yy7@7 wr)rr_rdr>rr@r)rnrs rKrzAsyncClient.acloses~ ;;+,, ,%,,DK//((* * *,,. )$,,.(( ) - +)s*ABB#B7B B BBcK|jtjk7r:tjdtjdi|j}t |tj|_|j jd{|jjD]}||jd{|S7@7 wr) rr_rbrcrdrr> __aenter__r@r)rnrrs rKrzAsyncClient.__aenter__s ;;+.. .""$S""%`kkCs# #!(( oo((***\\((* )E &&((( ) +)s*B C C  #C1CC CCcKtj|_|jj |||d{|j j D] }||j |||d{"y7B7 wrh)r_rdrr> __aexit__r@r)rnrrrrs rKrzAsyncClient.__aexit__sx "(( oo'')YGGG\\((* FE ooh 9EEE F HFs'6A?A;#A?A?3A=4A?=A?)(rrrrrrrrr/rr0rr1rr2rrr"r3z5None | typing.Mapping[str, AsyncBaseTransport | None]rr4rrr4rrrrrrr r5AsyncBaseTransport | Nonerrrr!rr)r/rr0rrrr1rr2rr4rr5rrr&)rrr/rr0rrrr1rr2rr4rrr&)rIr5rr&r)rrrIr rr%rr&rr'rr(rrrrrrrr+rrrr)rr*rzAsyncGenerator[Response])rIr rrrr%rr&rr'rr(rrrrrrrr+rrrr)rr*rfrrzAsyncGenerator[EventSource])rIr rrrrsrrtrrurrvrrrrrrrrr+rrrr)rr*rz%AsyncGenerator[AsyncWebSocketSession]rrrrrrrr)rnr@rr@rr)&rWrXrYrZrrrrqr=r?rRr;rrrorrprrrrr|r_rrrrPrrrrrrrrrrrrs@rKr<r<s -d"&)-&*&*.2!%#'JN 6!&'2EI /3GN+K:K:' K: $ K: $ K:,K:K:K:K:!K:HK:K:K:K: !K:"C#K:$%K:&-'K:()K:*E+K:, -K:^/3!%'/3 +         -   2/3!%'  ,           (  *.#'%)"&)-&*&*4F4F3E/37V7V7V ' 7V ! 7V#7V 7V'7V$7V$7V27V27V17V-7V !7Vr *.#'%)"&)-&*&*4F4F3E/31$1$1$ ' 1$ ! 1$#1$ 1$'1$$1$$1$21$21$11$-1$ "!1$1$f )-#'%)"&)-&*&*4F4F3E/3%A!(G (G (G ' (G ! (G#(G (G'(G$(G$(G2(G2(G1(G-(G #!(G" %#(G(GT 'E,8_7])-)-&*&*4F4F3E/34 4!$ 4  4 *6 4)54'4'4$4$4242414-4 /!44t4F4F -- - 2 - 2 - -^ % % % %  %  %D""" "  "HD*.&*&*4F4F3E/3  '  $  $  2 2 1 -   B*.&*&*-?4F3E/3  '  $  $  + 2 1 -   B*.&*&*-?4F3E/3  '  $  $  + 2 1 -   B*.#'%)"&)-&*&*-?4F3E/3# # ' # ! # # #  # '# $# $# +# 2# 1# -#  # R*.#'%)"&)-&*&*-?4F3E/3# # ' # ! # # #  # '# $# $# +# 2# 1# -#  # R*.#'%)"&)-&*&*-?4F3E/3# # ' # ! # # #  # '# $# $# +# 2# 1# -#  # R*.&*&*-?4F3E/3  '  $  $  + 2 1 -   B*.#'%)"&)-&*&*-?4F3E/3# # ' # ! # # #  # '# $# $# +# 2# 1# -#  # J )$04*.*. F, F( F( F  FrM)rIr5rJr5rr)rIr5rr)rIr5rSr5rr)i __future__rrzenumloggingr|typingr\collections.abcrr contextlibrrtypesrr rr r r _configrrrrrrrrrrr _decodersr _exceptionsrrrr_modelsrrr r!_sser" _status_codesr# _transportsr$r%_transports.baser&r'_typesr(r)r*r+r,r-r.r/r0r1r2r3r4_urlsr5r6_utilsr7r8 TYPE_CHECKINGsslrzr9r:__all__TypeVarr>r@rLrHrTrVr; getLoggerrrr keysrEnumr_rfrCallableAny EventHookrr=r<)rs0rKr%s"  5:$00    * 98 :?$7 H 9FNN3h'FNN3m, 6 v(&'   8 $k] + )),C,>,C,C,E[SPZIZS[\ $)) n($$* OOCO , @W@WF A CZA CHC F*C FI(\s  G(G