
    osjf&                      d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlm	Z	m
Z
 d dlmZmZ d dlmZ ddlmZ ddlmZmZmZ dd	lmZmZmZmZmZmZmZmZmZmZ dd
l m!Z! ddl"m#Z#m$Z$m%Z%m&Z& ddl'm(Z(m)Z)m*Z*m+Z+ ddl,m-Z- ddl.m/Z/ ddl0m1Z1m2Z2 ddl3m4Z4m5Z5 ddl6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZC ddlDmEZEmFZF ddlGmHZHmIZI ej                  rd dlKZKddlLmMZMmNZN g dZO ej                  dd      ZQ ej                  dd      ZRd/dZSd0dZTd1dZU G d d      ZV eV       ZW ej                  d       ZYd!e ZZd"j                   e!j                         D  cg c]
  } | d#k7  s	|  c}       Z] G d$ d%ej                        Z_ G d& d'eB      Z` G d( d)e7      Zaej                  d*ej                  f   Zd G d+ d,      Ze G d- dee      Zf G d. dee      Zgyc c} w )2    )annotationsN)AsyncGenerator	Generator)asynccontextmanagercontextmanager)TracebackType   )__version__)Auth	BasicAuthFunctionAuth)
'DEFAULT_KEEPALIVE_PING_INTERVAL_SECONDS&DEFAULT_KEEPALIVE_PING_TIMEOUT_SECONDSDEFAULT_LIMITSDEFAULT_MAX_MESSAGE_SIZE_BYTESDEFAULT_MAX_REDIRECTSDEFAULT_QUEUE_SIZEDEFAULT_TIMEOUT_CONFIGLimitsProxyTimeout)SUPPORTED_DECODERS)
InvalidURLRemoteProtocolErrorTooManyRedirectsrequest_context)CookiesHeadersRequestResponse)EventSource)codes)AsyncBaseTransportBaseTransport)AsyncHTTPTransportHTTPTransport)AsyncByteStream	AuthTypes	CertTypesCookieTypesHeaderTypes
ProxyTypesQueryParamTypesRequestContentRequestDataRequestExtensionsRequestFilesSyncByteStreamTimeoutTypes)URLQueryParams)
URLPatternget_environment_proxies)AsyncWebSocketSessionWebSocketSession)USE_CLIENT_DEFAULTAsyncClientClientTr<   )boundUr;   c                    | j                   |j                   k7  ry| j                  dk(  xr/ t        |       dk(  xr |j                  dk(  xr t        |      dk(  S )zA
    Return 'True' if 'location' is a HTTPS upgrade of 'url'
    FhttpP   https  )hostscheme_port_or_default)urllocations     A/root/.hermes/venv/lib/python3.12/site-packages/httpx2/_client.py_is_https_redirectrK   F   sa     xx8==  	

f 	.S!R'	.OOw&	. X&#-	    c                n    | j                   | j                   S dddj                  | j                        S )NrB   rD   )rA   rC   )portgetrF   rH   s    rJ   rG   rG   U   s/    
xxxx%))#**55rL   c                    | j                   |j                   k(  xr2 | j                  |j                  k(  xr t        |       t        |      k(  S )z@
    Return 'True' if the given URLs share the same origin.
    )rF   rE   rG   )rH   others     rJ   _same_originrS   [   sA     ::%u#((ejj*@uEUVYEZ^not^uEuurL   c                      e Zd ZdZy)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__ rL   rJ   rU   rU   b   s    rL   rU   httpx2zpython-httpx2/z, identityc                      e Zd ZdZdZdZy)ClientStater	         N)rV   rW   rX   UNOPENEDOPENEDCLOSEDrZ   rL   rJ   r^   r^      s     H F FrL   r^   c                  (    e Zd ZdZddZddZddZy)	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 | _        y N_stream_startelapsedselfstreamstarts      rJ   __init__zBoundSyncStream.__init__       26rL   c              #  8   K   | j                   E d {    y 7 wrg   ri   rm   s    rJ   __iter__zBoundSyncStream.__iter__   s     <<s   c                    t        j                  t        j                         | j                  z
        | _        | j                  j                          y N)seconds)datetime	timedeltatimeperf_counterrj   rk   ri   closert   s    rJ   r}   zBoundSyncStream.close   s6    ))$2C2C2E2STrL   N)rn   r2   ro   floatreturnNone)r   ztyping.Iterator[bytes]r   r   )rV   rW   rX   rY   rp   ru   r}   rZ   rL   rJ   re   re      s    7
 rL   re   c                  (    e Zd ZdZddZddZddZy)	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 | _        y rg   rh   rl   s      rJ   rp   zBoundAsyncStream.__init__   rq   rL   c               H   K   | j                   2 3 d {   }| 7 
6 y wrg   rs   )rm   chunks     rJ   	__aiter__zBoundAsyncStream.__aiter__   s&     << 	 	%K	<s   "  " "c                   K   t        j                  t        j                         | j                  z
        | _        | j                  j                          d {    y 7 wrw   )ry   rz   r{   r|   rj   rk   ri   aclosert   s    rJ   r   zBoundAsyncStream.aclose   s@     ))$2C2C2E2STll!!###s   AA"A A"N)rn   r'   ro   r~   r   r   )r   ztyping.AsyncIterator[bytes]r   )rV   rW   rX   rY   rp   r   r   rZ   rL   rJ   r   r      s    7
$rL   r   .c                     e Zd Zddddededdddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d(dZed)d       Zed)d	       Zd*d
Z	d+dZ
ed,d       Zej                  d-d       Zed.d       Zej                  d/d       Zed0d       Zej                  d1d       Zed2d       Zej                  d3d       Zed4d       Zej                  d5d       Zed6d       Zej                  d7d       Zed8d       Zej                  d9d       Zdddddddedd		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d:dZd;dZd<d=dZd<d>dZd<d?dZd@d Zef	 	 	 	 	 dAd!ZdBd"ZdCd#ZdDd$ZdEd%ZdFd&ZdGd'Z y)H
BaseClientNF Tutf-8authparamsheaderscookiestimeoutfollow_redirectsmax_redirectsevent_hooksbase_url	trust_envdefault_encodingc                  |i n|}| j                  t        |	            | _        | j                  |      | _        t        |      | _        t        |      | _        t        |      | _
        t        |      | _        || _        || _        t        |j!                  dg             t        |j!                  dg             d| _        |
| _        || _        t(        j*                  | _        y Nrequestresponse)r   r   )_enforce_trailing_slashr4   	_base_url_build_auth_authr5   _paramsr   r   r   _cookiesr   _timeoutr   r   listrO   _event_hooks
_trust_env_default_encodingr^   ra   _state)rm   r   r   r   r   r   r   r   r   r   r   r   s               rJ   rp   zBaseClient.__init__   s     (/b[55c(mD%%d+
"6*w'(( 0*KOOIr:;[__Z<=
 $!1!**rL   c                <    | j                   t        j                  k(  S )z2
        Check if the client being closed
        )r   r^   rc   rt   s    rJ   	is_closedzBaseClient.is_closed   s    
 {{k0000rL   c                    | j                   S rg   )r   rt   s    rJ   r   zBaseClient.trust_env   s    rL   c                z    |j                   j                  d      r|S |j                  |j                   dz         S )N   /raw_path)r   endswith	copy_withrm   rH   s     rJ   r   z"BaseClient._enforce_trailing_slash   s3    <<  &J}}cllT&9}::rL   c                    |>|r:t               j                         D ci c]  \  }}||d nt        |       c}}S i S t        |t        t
        f      rt        |      n|}d|iS c c}}w )NrP   zall://)r7   itemsr   
isinstancestrr4   )rm   proxyallow_env_proxieskeyrH   s        rJ   _get_proxy_mapzBaseClient._get_proxy_map   si    = UlUnUtUtUvwcS[TenDwwI(253*(EEe$5Ee$$	 xs   A)c                    | j                   S rg   )r   rt   s    rJ   r   zBaseClient.timeout   s    }}rL   c                $    t        |      | _        y rg   )r   r   )rm   r   s     rJ   r   zBaseClient.timeout       (rL   c                    | j                   S rg   )r   rt   s    rJ   r   zBaseClient.event_hooks   s       rL   c                |    t        |j                  dg             t        |j                  dg             d| _        y r   )r   rO   r   )rm   r   s     rJ   r   zBaseClient.event_hooks  s4     KOOIr:;[__Z<=
rL   c                    | j                   S )z
        Authentication class used when none is passed at the request-level.

        See also [Authentication][0].

        [0]: /quickstart/#authentication
        )r   rt   s    rJ   r   zBaseClient.auth  s     zzrL   c                0    | j                  |      | _        y rg   )r   r   rm   r   s     rJ   r   zBaseClient.auth  s    %%d+
rL   c                    | j                   S )zK
        Base URL to use when sending requests with relative URLs.
        )r   rt   s    rJ   r   zBaseClient.base_url  s    
 ~~rL   c                B    | j                  t        |            | _        y rg   )r   r4   r   r   s     rJ   r   zBaseClient.base_url  s    55c#h?rL   c                    | j                   S )z@
        HTTP headers to include when sending requests.
        )_headersrt   s    rJ   r   zBaseClient.headers"      
 }}rL   c                    t        dt        j                  d      dt        j                  d      d      }|j	                  |       || _        y )Ns   */*asciis
   keep-alive)s   Accepts   Accept-Encodings
   Connections
   User-Agent)r   ACCEPT_ENCODINGencode
USER_AGENTupdater   )rm   r   client_headerss      rJ   r   zBaseClient.headers)  sJ     !$3$:$:7$C,)009	
 	g&&rL   c                    | j                   S )zA
        Cookie values to include when sending requests.
        )r   rt   s    rJ   r   zBaseClient.cookies6  r   rL   c                $    t        |      | _        y rg   )r   r   )rm   r   s     rJ   r   zBaseClient.cookies=  r   rL   c                    | j                   S )zO
        Query parameters to include in the URL when sending requests.
        )r   rt   s    rJ   r   zBaseClient.paramsA  s    
 ||rL   c                $    t        |      | _        y rg   )r5   r   )rm   r   s     rJ   r   zBaseClient.paramsH  s    "6*rL   )	contentdatafilesjsonr   r   r   r   
extensionsc       	        P   | j                  |      }| j                  |      }| j                  |	      }	| j                  |      }|i n|}d|vrDt	        |
t
              r| j                  n
t        |
      }
t        di |d|
j                         i}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   )r   r   r   r   r   r   r   r   rZ   )
_merge_url_merge_headers_merge_cookies_merge_queryparamsr   rU   r   r   dictas_dictr   )rm   methodrH   r   r   r   r   r   r   r   r   r   s               rJ   build_requestzBaseClient.build_requestL  s    4 ooc"%%g.%%g.((0%-R:
J&&0:J&KdllQXY`QaGF
FGOO4EFJ!
 	
rL   c                    t        |      }|j                  rN| j                  j                  |j                  j	                  d      z   }| j                  j                  |      S |S )z
        Merge a URL argument together with any 'base_url' on the client,
        to create the URL used for the outgoing request.
        r   r   )r4   is_relative_urlr   r   lstripr   )rm   rH   	merge_urlmerge_raw_paths       rJ   r   zBaseClient._merge_url{  s\    
 H	$$ "]]33i6H6H6O6OPT6UUN==**N*CCrL   c                r    |s| j                   r(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.
        )r   r   r   )rm   r   merged_cookiess      rJ   r   zBaseClient._merge_cookies  s4    
 dll$T\\2N!!'*!!rL   c                R    t        | j                        }|j                  |       |S )z
        Merge a headers argument together with any headers on the client,
        to create the headers used for the outgoing request.
        )r   r   r   )rm   r   merged_headerss      rJ   r   zBaseClient._merge_headers  s&    
 !.g&rL   c                n    |s| j                   r&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.
        )r   r5   merge)rm   r   merged_queryparamss      rJ   r   zBaseClient._merge_queryparams  s2    
 T[[!,T[[!9%++F33rL   c                    |y t        |t              rt        |d   |d         S t        |t              r|S t	        |      rt        |      S t        d|      )Nr   r	   usernamepassword)funczInvalid "auth" argument: )r   tupler   r   callabler   	TypeErrorr   s     rJ   r   zBaseClient._build_auth  s]    <e$d1gQ@@d#Kd^T**7x@AArL   c                    t        |t              r| j                  n| j                  |      }||S |j                  j
                  |j                  j                  }}|s|rt        ||      S t               S )Nr   )	r   rU   r   r   rH   r   r   r   r   )rm   r   r   r   r   s        rJ   _build_request_authzBaseClient._build_request_auth  sf    
 (.>?tzzTEUEUVZE[K$[[117;;3G3G(xhBBvrL   c                    | j                  ||      }| j                  ||      }| j                  |||      }| j                  ||      }t	        | j
                        }t        ||||||j                        S )z
        Given a request and a redirect response, return a new request that
        should be used to effect the redirect.
        )r   rH   r   r   rn   r   )_redirect_method_redirect_url_redirect_headers_redirect_streamr   r   r   r   )rm   r   r   r   rH   r   rn   r   s           rJ   _build_redirect_requestz"BaseClient._build_redirect_request  s    
 &&w9  (3((#v>&&w7$,,'))
 	
rL   c                    |j                   }|j                  t        j                  k(  r|dk7  rd}|j                  t        j                  k(  r|dvrd}|j                  t        j
                  k(  r|dk(  rd}|S )z
        When being redirected we may want to change the method of the request
        based on certain specs or browser behavior.
        HEADGET)r   QUERYPOST)r   status_coder"   	SEE_OTHERFOUNDMOVED_PERMANENTLY)rm   r   r   r   s       rJ   r   zBaseClient._redirect_method  su    
  5??2v7GF 5;;.6AR3RF 5#:#::v?OFrL   c                   |j                   d   }	 t        |      }|j                  r2|j
                  s&|j                  |j                  j
                        }|j                  r|j                  j                  |      }|j                  j                  r2|j                  s&|j                  |j                  j                        }|S # t        $ r}t        d| d|      dd}~ww xY w)z<
        Return the URL for the redirect to follow.
        Locationz Invalid URL in location header: .r   N)rE   )fragment)r   r4   r   r   rF   rE   r   rH   r   joinr  )rm   r   r   rI   rH   excs         rJ   r   zBaseClient._redirect_url  s     ##J/	lh-C ::chh--W[[%5%5-6C ++""3'C ;;--)=)=->C
#  	l%(HQ&OY`agkk	ls   C 	C+C&&C+c                |   t        |j                        }t        ||j                        sFt	        |j                  |      s|j                  dd       |j                  j                  d      |d<   ||j                  k7  r)|dk(  r$|j                  dd       |j                  dd       |j                  dd       |S )	zR
        Return the headers that should be used for the redirect request.
        AuthorizationNr   Hostr   zContent-LengthzTransfer-EncodingCookie)	r   r   rS   rH   rK   popnetlocdecoder   )rm   r   rH   r   r   s        rJ   r   zBaseClient._redirect_headers  s     '//*C-%gkk37 OT2 "jj//8GFOW^^#% KK($/KK+T2 	Hd#rL   c                D    ||j                   k7  r|dk(  ry|j                  S )zO
        Return the body that should be used for the redirect request.
        r   N)r   rn   )rm   r   r   s      rJ   r   zBaseClient._redirect_stream-  s#     W^^#%~~rL   c                    d|j                   vrht        | j                  t              r| j                  nt	        | j                        }t        di |j                   d|j                         i|_         y y )Nr   rZ   )r   r   r   rU   r   r   r   )rm   r   r   s      rJ   _set_timeoutzBaseClient._set_timeout6  s]    G...&0?O&PdllV]^b^j^jVkG!%!V(:(:!VGOODU!VG /rL   )r   AuthTypes | Noner   QueryParamTypes | Noner   HeaderTypes | Noner   CookieTypes | Noner   r3   r   boolr   intr   +None | typing.Mapping[str, list[EventHook]]r   	URL | strr   r  r   *str | typing.Callable[[bytes], str | None]r   r   )r   r  )rH   r4   r   r4   )r   ProxyTypes | Noner   r  r   zdict[str, Proxy | None])r   r   )r   r3   r   r   )r   dict[str, list[EventHook]])r   r"  r   r   )r   Auth | None)r   r(   r   r   )r   r4   )rH   r  r   r   )r   r   )r   r+   r   r   )r   r   )r   r*   r   r   )r   r5   )r   r-   r   r   )r   r   rH   r  r   RequestContent | Noner   RequestData | Noner   RequestFiles | Noner   typing.Any | Noner   r  r   r  r   r  r   TimeoutTypes | UseClientDefaultr   RequestExtensions | Noner   r   )rH   r  r   r4   rg   )r   r  r   r  )r   r  r   r  )r   r  r   r  )r   r  r   r#  )r   r   r   #AuthTypes | UseClientDefault | Noner   r   )r   r   r   r    r   r   )r   r   r   r    r   r   )r   r   r   r    r   r4   )r   r   rH   r4   r   r   r   r   )r   r   r   r   r   z'SyncByteStream | AsyncByteStream | None)r   r   r   r   )!rV   rW   rX   r   r   rp   propertyr   r   r   r   r   setterr   r   r   r   r   r   r:   r   r   r   r   r   r   r   r   r   r   r   r   r  rZ   rL   rJ   r   r      s    "&)-&*&* 6!&2EI GN +  + '	 +
 $ + $ +  +  +  + C +  +  + E + 
 +D 1 1  ;
%   ^^) ) ! ! 
 
   
[[, ,   __@ @   ^^
' 
'   ^^) )   ]]+ + *.#'%)"&)-&*&*3E/3-
-
 -

 '-
 !-
 #-
  -
 '-
 $-
 $-
 1-
 --
 
-
^,	
B 5G 2 
	 
&266WrL   r   c                  ^    e Zd ZdZdddddddddddedeeddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d% fdZdddddedf	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d&d	Zdddddef	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d'd
Z	d(dZ
dddddddeeedd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d)dZedddddddeeedd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d*d       Zeddddddddeeedd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d+d       Zeeeeeddddeeedd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d,d       Zdeed	 	 	 	 	 	 	 	 	 d-dZ	 	 	 	 	 	 	 	 	 	 d.dZ	 	 	 	 	 	 	 	 d/dZd0dZdddeeedd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d1dZdddeeedd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d2dZdddeeedd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d2dZdddddddeeedd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d3dZdddddddeeedd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d3dZdddddddeeedd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d3dZdddeeedd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d2d Zdddddddeeedd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d3d!Z d4d"Z!d5d#Z"	 	 	 d6	 	 	 	 	 	 	 d7d$Z# xZ$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".
    NTFr   r   )r   r   r   r   verifycertr   http1http2r   mountsr   r   limitsr   r   r   	transportr   c                  t         |   |||||||||||       |	r	 dd l}|xr |d u }| j	                  |
|      }| j                  |||||	||      | _        |j                         D 
ci c]+  \  }}
t        |      |
d n| j                  |
|||||	|      - c}
}| _
        |F| j                  j                  |j                         D ci c]  \  }}t        |      | c}}       t        t        | j                  j                                     | _
        y # t        $ r t        d      d w xY wc c}
}w c c}}w Nr   r   zuUsing http2=True, but the 'h2' package is not installed. Make sure to install httpx using `pip install httpx[http2]`.)r.  r/  r   r0  r1  r3  r4  r.  r/  r   r0  r1  r3  superrp   h2ImportErrorr   _init_transport
_transportr   r6   _init_proxy_transport_mountsr   r   sorted)rm   r   r   r   r   r.  r/  r   r0  r1  r   r2  r   r   r3  r   r   r   r4  r   r:  r   	proxy_mapr   	__class__s                           rJ   rp   zClient.__init__k  s   . 	-'#- 	 	
  &;)t*;''/@A	.. / 
* (oo/@
 U sO} "++# , 
@
 LLRXR^R^R` aYC)!; abF4<<#5#5#789G  !S $@
 !b   D  -0D9D?
 D6c                ,    ||S t        ||||||      S Nr7  r&   rm   r.  r/  r   r0  r1  r3  r4  s           rJ   r<  zClient._init_transport  s/      
 	
rL   c           	     &    t        |||||||      S N)r.  r/  r   r0  r1  r3  r   rF  rm   r   r.  r/  r   r0  r1  r3  s           rJ   r>  zClient._init_proxy_transport  s&     
 	
rL   c                    | j                   j                         D ]*  \  }}|j                  |      s|| j                  c S |c S  | j                  S z
        Returns the transport instance that should be used for a given URL.
        This will either be the standard connection pool, or a proxy.
        r?  r   matchesr=  rm   rH   patternr4  s       rJ   _transport_for_urlzClient._transport_for_url  S    
 #',,"4"4"6 	KGYs#*3*;tJJ	K rL   r   r   r   r   r   r   r   r   r   r   r   c                   |	d}t        j                  |t        d       | 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r   rH   r   r   r   r   r   r   r   r   r   r   r   warningswarnDeprecationWarningr   sendrm   r   rH   r   r   r   r   r   r   r   r   r   r   r   messager   s                   rJ   r   zClient.request  sw    B C 
 MM'#5!D$$! % 
 yyt>NyOOrL   c             #     K   | j                  |||||||||	||      }| j                  ||
|d      }	 | |j                          y# |j                          w xY wwa  
        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
        rX  T)r   r   r   rn   N)r   r^  r}   rm   r   rH   r   r   r   r   r   r   r   r   r   r   r   r   r   s                   rJ   rn   zClient.stream%  s}     8 $$! % 
 99-	  
	NNNHNNs   2AA
 A
AAr   r   r   r   r   r   r   r   r   r   r   r   r   c             #     K   | j                  |||||||dddt        |      z  |	|
|||      5 }t        |       ddd       y# 1 sw Y   yxY wwz
        Connect to a server-sent events endpoint and yield an `EventSource`.

        Iterating the `EventSource` yields `ServerSentEvent` instances.

        **Parameters**: See `httpx2.request`.
        ztext/event-streamzno-store)AcceptzCache-ControlrS  Nrn   r   r!   rm   rH   r   r   r   r   r   r   r   r   r   r   r   r   r   s                  rJ   ssez
Client.sseY  su     2 [[2ZPSZ[bScc-!  
 	( h''	( 	( 	(s   .AA	AAAmax_message_size_bytes
queue_sizekeepalive_ping_interval_secondskeepalive_ping_timeout_secondssubprotocolsr   r   r   r   r   r   r   c             #     K   	 ddl m}  |t        |      | ||||||||	|
|||      5 }| ddd       y# t        $ r t        d      w xY w# 1 sw Y   yxY ww)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]`.rk  N)websockets._apirr  r;  r   )rm   rH   rl  rm  rn  ro  rp  r   r   r   r   r   r   r   rr  sessions                   rJ   	websocketzClient.websocket  s     <	3 H#9!,K+I%-!
 	 M!	 	  	m 	
	 	s/   A7 AA	AAAAArn   r   r   c                  | j                   t        j                  k(  rt        d      t        j                  | _         t        |t              r| j                  n|}| j                  |       | j                  ||      }| j                  |||g       }	 |s|j                          |S # t        $ r}|j                          |d}~ww xY w)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.r   r   historyN)r   r^   rc   RuntimeErrorrb   r   rU   r   r  r   _send_handling_authreadBaseExceptionr}   rm   r   rn   r   r   r   r  s          rJ   r^  zClient.send  s    * ;;+,,,VWW!((4>?OQa4b400hx'"''6++-	 , 
	O 	NNI	s   B) )	C	2CC	c                   |j                  |      }	 t        |      }	 | j                  |||      }	 	 |j                  |      }t        |      |_        |j                          |}|j                  |       [# t        $ r |cY |j                          S w xY w# t        $ r}|j                          |d }~ww xY w# |j                          w xY wN)r   r{  )sync_auth_flownext_send_handling_redirectsr^  StopIterationr}   r   r{  r~  appendr  	rm   r   r   r   r{  	auth_flowr   next_requestr  s	            rJ   r}  zClient._send_handling_auth  s     ''0		9oG88%5# 9 
('0~~h'? (,G}H$MMO*GNN8,  ) (' OO( % NN$I OOsL    B> A: 3B 9B> :BB BB 	B;$B66B;;B> >Cc                   	 t        |      | j                  kD  rt        d|      | j                  d   D ]
  } ||        | j	                  |      }	 | j                  d   D ]
  } ||        t        |      |_        |j                  s|S | j                  ||      }||gz   }|r|j                          n	||_
        |S 	 # t        $ r}|j                          |d }~ww xY wNz#Exceeded maximum allowed redirects.r
  r   r   )lenr   r   r   _send_single_requestr   r{  has_redirect_locationr   r~  r  r  r}   rm   r   r   r{  hookr   r  s          rJ   r  zClient._send_handling_redirects  s     7|d000&'LV]^^)))4 W 009H --j9 #DN##'= 55#O66wI!XJ.#MMO,3H)#O $) 2 !  	s   9C 3C 	C%C  C%c                   | j                  |j                        }t        j                         }t	        |j
                  t              st        d      t        |      5  |j                  |      }ddd       t	        j
                  t              sJ ||_
        t        |j
                  |      |_        | j                  j                  |       | j                  |_        t         j#                  d|j$                  |j                  |j&                  |j(                  |j*                         |S # 1 sw Y   xY w)L
        Sends a single request, without handling any redirections.
        z?Attempted to send an async request with a sync Client instance.r
  Nro   HTTP Request: %s %s "%s %d %s")rQ  rH   r{   r|   r   rn   r2   r|  r   handle_requestr   re   r   extract_cookiesr   r   loggerinfor   http_versionr  reason_phraserm   r   r4  ro   r   s        rJ   r  zClient._send_single_request.  s     ++GKK8	!!#'...9`aaW- 	9 //8H	9 (//>:::")(//G$$X.$($:$:!,NNKK!!  ""	
 '	9 	9s   !D44D=r   r   r   r   r   r   r   c               6    | j                  d||||||||	      S )V
        Send a `GET` request.

        **Parameters**: See `httpx2.request`.
        r   r  r
  	rm   rH   r   r   r   r   r   r   r   s	            rJ   rO   z
Client.getM  s5    " ||-!  

 
	
rL   c               6    | j                  d||||||||	      S )[
        Send an `OPTIONS` request.

        **Parameters**: See `httpx2.request`.
        OPTIONSr  r
  r  s	            rJ   optionszClient.optionsj  s5    " ||-!  

 
	
rL   c               6    | j                  d||||||||	      S )W
        Send a `HEAD` request.

        **Parameters**: See `httpx2.request`.
        r   r  r
  r  s	            rJ   headzClient.head  s5    " ||-!  

 
	
rL   c               >    | j                  d|||||||||	|
||      S )W
        Send a `POST` request.

        **Parameters**: See `httpx2.request`.
        r  rS  r
  rm   rH   r   r   r   r   r   r   r   r   r   r   r   s                rJ   postzClient.post  sA    * ||-!  
 	
rL   c               >    | j                  d|||||||||	|
||      S )V
        Send a `PUT` request.

        **Parameters**: See `httpx2.request`.
        PUTrS  r
  r  s                rJ   putz
Client.put  sA    * ||-!  
 	
rL   c               >    | j                  d|||||||||	|
||      S )X
        Send a `PATCH` request.

        **Parameters**: See `httpx2.request`.
        PATCHrS  r
  r  s                rJ   patchzClient.patch  A    * ||-!  
 	
rL   c               6    | j                  d||||||||	      S )Y
        Send a `DELETE` request.

        **Parameters**: See `httpx2.request`.
        DELETEr  r
  r  s	            rJ   deletezClient.delete  s5    " ||-!  

 
	
rL   c               >    | j                  d|||||||||	|
||      S )X
        Send a `QUERY` request.

        **Parameters**: See `httpx2.request`.
        r  rS  r
  r  s                rJ   queryzClient.query0  r  rL   c                   | j                   t        j                  k7  rbt        j                  | _         | j                  j	                          | j
                  j                         D ]  }||j	                           yyz.
        Close transport and proxies.
        N)r   r^   rc   r=  r}   r?  values)rm   r4  s     rJ   r}   zClient.closeU  sd     ;;+,,,%,,DKOO!!#!\\002 &	(OO%&	 -rL   c                v   | j                   t        j                  k7  r:t        j                  dt        j                  di| j                      }t        |      t        j                  | _         | j                  j                          | j                  j                         D ]  }||j                           | S Nz-Cannot open a client instance more than once.z9Cannot reopen a client instance, once it has been closed.)
r   r^   ra   rb   rc   r|  r=  	__enter__r?  r  )rm   msgr4  s      rJ   r  zClient.__enter__a  s    ;;+...""$S""%` kkC s##!((!!#,,. 	&I$##%	& rL   c                    t         j                  | _        | j                  j	                  |||       | j
                  j                         D ]  }||j	                  |||        y rg   )r^   rc   r   r=  __exit__r?  r  )rm   exc_type	exc_value	tracebackr4  s        rJ   r  zClient.__exit__q  s]     "((  9i@,,. 	CI$""8Y	B	CrL   )(r   r  r   r  r   r  r   r  r.  ssl.SSLContext | str | boolr/  CertTypes | Noner   r  r0  r  r1  r  r   r!  r2  z0None | typing.Mapping[str, BaseTransport | None]r   r3   r   r  r3  r   r   r  r   r  r   r  r4  BaseTransport | Noner   r   r   r   )r.  r  r/  r  r   r  r0  r  r1  r  r3  r   r4  r  r   r$   )r   r   r.  r  r/  r  r   r  r0  r  r1  r  r3  r   r   r$   )rH   r4   r   r$   r   r   rH   r  r   r$  r   r%  r   r&  r   r'  r   r  r   r  r   r  r   r*  r   bool | UseClientDefaultr   r(  r   r)  r   r    )r   r   rH   r  r   r$  r   r%  r   r&  r   r'  r   r  r   r  r   r  r   r*  r   r  r   r(  r   r)  r   zGenerator[Response])rH   r  r   r   r   r$  r   r%  r   r&  r   r'  r   r  r   r  r   r  r   r*  r   r  r   r(  r   r)  r   zGenerator[EventSource])rH   r  rl  r  rm  r  rn  float | Nonero  r  rp  list[str] | Noner   r  r   r  r   r  r   r*  r   r  r   r(  r   r)  r   zGenerator[WebSocketSession]
r   r   rn   r  r   r*  r   r  r   r    
r   r   r   r   r   r  r{  list[Response]r   r    r   r   r   r  r{  r  r   r    r   r   r   r    rH   r  r   r  r   r  r   r  r   r*  r   r  r   r(  r   r)  r   r    rH   r  r   r  r   r  r   r  r   AuthTypes | UseClientDefaultr   r  r   r(  r   r)  r   r    rH   r  r   r$  r   r%  r   r&  r   r'  r   r  r   r  r   r  r   r  r   r  r   r(  r   r)  r   r    r   )rm   r=   r   r=   NNNr  ztype[BaseException] | Noner  zBaseException | Noner  zTracebackType | Noner   r   )%rV   rW   rX   rY   r   r   r   rp   r<  r>  rQ  r:   r   r   rn   rj  r   r   r   r   rv  r^  r}  r  r  rO   r  r  r  r  r  r  r  r}   r  r  __classcell__rB  s   @rJ   r<   r<   <  su
   ,b "&)-&*&*.2!%#'EI 6!&'2EI *.GN+K: K: '	K:
 $K: $K: ,K: K: K: K: K: !K: CK: K: K:  !K:" #K:$ C%K:& 'K:( ()K:* E+K:, 
-K:^ /3!%'*.
+
 
 	

 
 
 
 (
 

2 /3!%'

 ,
 	

 
 
 
 
 

(	  *.#'%)"&)-&*&*4F4F3E/36P6P 6P
 '6P !6P #6P  6P '6P $6P $6P 26P 26P 16P -6P  
!6Pp  *.#'%)"&)-&*&*4F4F3E/311 1
 '1 !1 #1  1 '1 $1 $1 21 21 11 -1  
!1 1f 
 )-#'%)"&)-&*&*4F4F3E/3'('( 	'(
 ''( !'( #'(  '( ''( $'( $'( 2'( 2'( 1'( -'(  
 !'( '(R 
 'E,8_7])-)-&*&*4F4F3E/344 !$	4
 4 *64 )54 '4 '4 $4 $4 24 24 14 -4  
%!4 4t 4F4F-- 	-
 2- 2- 
-^     	 
    
 D!! !  	!
 
!FF *.&*&*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
 
CrL   c                  ^    e Zd ZdZddddddddddedeedddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d% fdZdddddedf	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d&d	Zdddddef	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d'd
Z	d(dZ
dddddddeeedd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d)dZedddddddeeedd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d*d       Zeddddddddeeedd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d+d       Zeeeeeddddeeedd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d,d       Zdeed	 	 	 	 	 	 	 	 	 d-dZ	 	 	 	 	 	 	 	 	 	 d.dZ	 	 	 	 	 	 	 	 d/dZd0dZdddeeedd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d1dZdddeeedd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d2dZdddeeedd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d2dZdddddddeeedd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d3dZdddddddeeedd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d3dZdddddddeeedd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d3dZdddeeedd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d2d Zdddddddeeedd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d3d!Z d4d"Z!d5d#Z"	 	 	 d6	 	 	 	 	 	 	 d7d$Z# xZ$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".
    NTFr   r   )r   r   r   r   r.  r/  r0  r1  r   r2  r   r   r3  r   r   r   r4  r   r   c                  t         |   |||||||||||       |r	 dd l}|xr |d u }| j	                  |	|      }| j                  |||||||      | _        |j                         D 	ci c]+  \  }}	t        |      |	d n| j                  |	||||||      - c}	}| _
        |
F| j                  j                  |
j                         D ci c]  \  }}t        |      | c}}       t        t        | j                  j                                     | _
        y # t        $ r t        d      d w xY wc c}	}w c c}}w r6  r8  )rm   r   r   r   r   r.  r/  r0  r1  r   r2  r   r   r3  r   r   r   r4  r   r   r:  r   rA  r   rB  s                           rJ   rp   zAsyncClient.__init__  s   . 	-'#- 	 	
  &;)t*;''/@A	.. / 
, (oo/E
 U sO} "++# , 
E
 LLRXR^R^R` aYC)!; abF4<<#5#5#789G  !S &E
 !brC  c                ,    ||S t        ||||||      S rE  r%   rG  s           rJ   r<  zAsyncClient._init_transport  s/      !
 	
rL   c           	     &    t        |||||||      S rI  r  rJ  s           rJ   r>  z!AsyncClient._init_proxy_transport  s&     "
 	
rL   c                    | j                   j                         D ]*  \  }}|j                  |      s|| j                  c S |c S  | j                  S rL  rM  rO  s       rJ   rQ  zAsyncClient._transport_for_url&  rR  rL   rS  c                  K   |	d}t        j                  |t        d       | j                  |||||||||	||      }| j	                  ||
|       d{   S 7 w)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
        NrU  r_   rV  rX  rY  rZ  r_  s                   rJ   r   zAsyncClient.request1  s     D C 
 MM'#5!D$$! % 
 YYwTDTYUUUUs   AAAAc                 K   | j                  |||||||||	||      }| j                  ||
|d       d{   }	 | |j                          d{    y7 #7 # |j                          d{  7   w xY wwrb  )r   r^  r   rc  s                   rJ   rn   zAsyncClient.streamj  s     8 $$! % 
 -	 # 
 
	$N//###
 $(//###sD   5A=AA=A A=AA=A=A:3A64A::A=r   rd  c                 K   | j                  |||||||dddt        |      z  |	|
|||      4 d{   }t        |       ddd      d{    y7 #7 # 1 d{  7  sw Y   yxY wwrf  rh  ri  s                  rJ   rj  zAsyncClient.sse  s     2 ;;2ZPSZ[bScc-!  
 	( 	( h''	( 	( 	( 	( 	( 	( 	(sD   2A1AA1AA1AA1A1A."A%#A.*A1rk  c                 K   	 ddl m}  |t        |      | ||||||||	|
|||      4 d{   }| ddd      d{    y# t        $ r t        d      w xY w7 27 # 1 d{  7  sw Y   yxY ww)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_wsrs  rk  N)rt  r  r;  r   )rm   rH   rl  rm  rn  ro  rp  r   r   r   r   r   r   r   r  ru  s                   rJ   rv  zAsyncClient.websocket  s     <	4 H#9!,K+I%-!
 	 	 M!	 	 	  	m 	
	 	 	 	 	sY   A9A #A9A A9A$A9A"A9AA9"A9$A6*A-+A62A9rw  c                 K   | j                   t        j                  k(  rt        d      t        j                  | _         t        |t              r| j                  n|}| j                  |       | j                  ||      }| j                  |||g        d{   }	 |s|j                          d{    |S 7 !7 # t        $ r }|j                          d{  7   |d}~ww xY ww)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
        ry  rz  N)r   r^   rc   r|  rb   r   rU   r   r  r   r}  areadr  r   r  s          rJ   r^  zAsyncClient.send  s     * ;;+,,,VWW!((4>?OQa4b400hx'"''611-	 2 
 
	nn&&&O
 '  	//###I	sT   BC+B;C+B? 4B=5B? :C+=B? ?	C(C#CC##C((C+c                >  K   |j                  |      }	 |j                          d {   }	 | j                  |||       d {   }	 	 |j                  |       d {   }t        |      |_        |j                          d {    |}|j                  |       s7 x7 ]7 D# t        $ r |cY |j                          d {  7   S w xY w7 H# t        $ r }|j                          d {  7   |d }~ww xY w# |j                          d {  7   w xY wwr  )async_auth_flow	__anext__r  asendStopAsyncIterationr   r   r{  r  r  r  r  s	            rJ   r}  zAsyncClient._send_handling_auth.  s     ((1		%%//11G!%!>!>%5# "? " 
(-6__X-F'F (,G}H$"..****GNN8,  2 (G- (' ""$$$( + % "//+++I ""$$$s   DC? B!C? B#C? B'  B%!B' %#C C	C  C? #C? %B' 'C2C 3DC	DCC 	C<C7/C20C77C<<C? ?DDDDc                :  K   	 t        |      | j                  kD  rt        d|      | j                  d   D ]  } ||       d {     | j	                  |       d {   }	 | j                  d   D ]  } ||       d {     t        |      |_        |j                  s|S | j                  ||      }||gz   }|r|j                          d {    n	||_
        |S 	 7 7 7 f7 # t        $ r }|j                          d {  7   |d }~ww xY wwr  )r  r   r   r   r  r   r{  r  r   r  r  r  r   r  s          rJ   r  z$AsyncClient._send_handling_redirectsP  s3     7|d000&'LV]^^)))4 $7m##$ "66w??H --j9 )Dx.(() $(= 55#O66wI!XJ.#"..***,3H)#O ++ 
 $? ) +
 ! oo'''	s   ADC'D!C)"D'C/ C+#C/ (D)-C/ C-C/ $D)D+C/ -C/ /	D8DDDDDc                  K   | j                  |j                        }t        j                         }t	        |j
                  t              st        d      t        |      5  |j                  |       d{   }ddd       t	        j
                  t              sJ ||_
        t        |j
                  |      |_        | j                  j                  |       | j                  |_        t         j#                  d|j$                  |j                  |j&                  |j(                  |j*                         |S 7 # 1 sw Y   xY ww)r  z>Attempted to send a sync request with an AsyncClient instance.r
  Nr  r  )rQ  rH   r{   r|   r   rn   r'   r|  r   handle_async_requestr   r   r   r  r   r   r  r  r   r  r  r  r  s        rJ   r  z AsyncClient._send_single_requestt  s     ++GKK8	!!#'../:_``W- 	E&;;GDDH	E (//?;;;"*8??%H$$X.$($:$:!,NNKK!!  ""	
 # E	E 	Es1   A!E#E 8D>9E =CE>E  E	Er  c               R   K   | j                  d||||||||	       d{   S 7 w)r  r   r  Nr
  r  s	            rJ   rO   zAsyncClient.get  sC     " \\-! " 

 

 
	
 

   '%'c               R   K   | j                  d||||||||	       d{   S 7 w)r  r  r  Nr
  r  s	            rJ   r  zAsyncClient.options  sC     " \\-! " 

 

 
	
 

r  c               R   K   | j                  d||||||||	       d{   S 7 w)r  r   r  Nr
  r  s	            rJ   r  zAsyncClient.head  sC     " \\-! " 

 

 
	
 

r  c               Z   K   | j                  d|||||||||	|
||       d{   S 7 w)r  r  rS  Nr
  r  s                rJ   r  zAsyncClient.post  sO     * \\-! " 
 
 	
 
   "+)+c               Z   K   | j                  d|||||||||	|
||       d{   S 7 w)r  r  rS  Nr
  r  s                rJ   r  zAsyncClient.put  sO     * \\-! " 
 
 	
 
r  c               Z   K   | j                  d|||||||||	|
||       d{   S 7 w)r  r  rS  Nr
  r  s                rJ   r  zAsyncClient.patch3  O     * \\-! " 
 
 	
 
r  c               R   K   | j                  d||||||||	       d{   S 7 w)r  r  r  Nr
  r  s	            rJ   r  zAsyncClient.deleteX  sC     " \\-! " 

 

 
	
 

r  c               Z   K   | j                  d|||||||||	|
||       d{   S 7 w)r  r  rS  Nr
  r  s                rJ   r  zAsyncClient.queryu  r  r  c                2  K   | j                   t        j                  k7  rrt        j                  | _         | j                  j	                          d{    | j
                  j                         D ]  }||j	                          d{     yy7 @7 
wr  )r   r^   rc   r=  r   r?  r  )rm   r   s     rJ   r   zAsyncClient.aclose  s~      ;;+,,,%,,DK//((***,,. )$,,.(()	 - + )s*   ABB#B7B
B	BBc                  K   | j                   t        j                  k7  r:t        j                  dt        j                  di| j                      }t        |      t        j                  | _         | j                  j                          d {    | j                  j                         D ]  }||j                          d {     | S 7 @7 
wr  )
r   r^   ra   rb   rc   r|  r=  
__aenter__r?  r  )rm   r  r   s      rJ   r  zAsyncClient.__aenter__  s     ;;+...""$S""%` kkC s##!((oo((***\\((* 	)E &&(((	) 	 	+ )s*   B
CC#C1CC	CCc                  K   t         j                  | _        | j                  j	                  |||       d {    | j
                  j                         D ]   }||j	                  |||       d {    " y 7 B7 	wrg   )r^   rc   r   r=  	__aexit__r?  r  )rm   r  r  r  r   s        rJ   r   zAsyncClient.__aexit__  sx      "((oo'')YGGG\\((* 	FE ooh	9EEE	F 	H Fs'   6A?A;#A?A?3A=4A?=A?)(r   r  r   r  r   r  r   r  r.  r  r/  r  r0  r  r1  r  r   r!  r2  z5None | typing.Mapping[str, AsyncBaseTransport | None]r   r3   r   r  r3  r   r   r  r   r  r   r  r4  AsyncBaseTransport | Noner   r  r   r   r   r   )r.  r  r/  r  r   r  r0  r  r1  r  r3  r   r4  r  r   r#   )r   r   r.  r  r/  r  r   r  r0  r  r1  r  r3  r   r   r#   )rH   r4   r   r#   r  )r   r   rH   r  r   r$  r   r%  r   r&  r   r'  r   r  r   r  r   r  r   r*  r   r  r   r(  r   r)  r   zAsyncGenerator[Response])rH   r  r   r   r   r$  r   r%  r   r&  r   r'  r   r  r   r  r   r  r   r*  r   r  r   r(  r   r)  r   zAsyncGenerator[EventSource])rH   r  rl  r  rm  r  rn  r  ro  r  rp  r  r   r  r   r  r   r  r   r*  r   r  r   r(  r   r)  r   z%AsyncGenerator[AsyncWebSocketSession]r  r  r  r  r  r  r  r   )rm   r?   r   r?   r  r  )%rV   rW   rX   rY   r   r   r   rp   r<  r>  rQ  r:   r   r   rn   rj  r   r   r   r   rv  r^  r}  r  r  rO   r  r  r  r  r  r  r  r   r  r   r  r  s   @rJ   r;   r;     su
   -d "&)-&*&*.2!%#'JN 6!&'2EI /3GN+K: K: '	K:
 $K: $K: ,K: K: K: K: !K: HK: K: K: K:  !K:" C#K:$ %K:& -'K:( )K:* E+K:, 
-K:^ /3!%'/3
+
 
 	

 
 
 
 -
 

2 /3!%'

 ,
 	

 
 
 
 
 

(	  *.#'%)"&)-&*&*4F4F3E/37V7V 7V
 '7V !7V #7V  7V '7V $7V $7V 27V 27V 17V -7V  
!7Vr  *.#'%)"&)-&*&*4F4F3E/31$1$ 1$
 '1$ !1$ #1$  1$ '1$ $1$ $1$ 21$ 21$ 11$ -1$  
"!1$ 1$f 
 )-#'%)"&)-&*&*4F4F3E/3'('( 	'(
 ''( !'( #'(  '( ''( $'( $'( 2'( 2'( 1'( -'(  
%!'( '(R 
 'E,8_7])-)-&*&*4F4F3E/344 !$	4
 4 *64 )54 '4 '4 $4 $4 24 24 14 -4  
/!4 4t 4F4F-- 	-
 2- 2- 
-^ % %  % 	 %
   % 
 %D"" "  	"
 
"HD *.&*&*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
 
FrL   )rH   r4   rI   r4   r   r  )rH   r4   r   z
int | None)rH   r4   rR   r4   r   r  )h
__future__r   ry   enumloggingr{   typingr[  collections.abcr   r   
contextlibr   r   typesr   r
   r   r   r   r   _configr   r   r   r   r   r   r   r   r   r   	_decodersr   _exceptionsr   r   r   r   _modelsr   r   r   r    _sser!   _status_codesr"   _transports.baser#   r$   _transports.defaultr%   r&   _typesr'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   _urlsr4   r5   _utilsr6   r7   TYPE_CHECKINGsslrt  r8   r9   __all__TypeVarr=   r?   rK   rG   rS   rU   r:   	getLoggerr  r   r  keysr   Enumr^   re   r   CallableAny	EventHookr   r<   r;   )r   s   0rJ   <module>r     s   "       5 :  $ 0 0   *  9 8    ? B    $ 7	H
9 FNN3h'FNN3m,6v ( &'  
		8	$k]+
)),C,>,C,C,E[SPZIZS[\$)) n ($ $* OOCO,	@W @WF@CZ @CFBF* BFG( \s   
G&G