o
    ¨Ýj’& ã                   @  sŒ  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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/m0Z0 ddl1m2Z2m3Z3 ddl4m5Z5m6Z6 ddl7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZD ddlEmFZFmGZG ddlHmIZImJZJ ejKrÕd dlLZLddlMmNZNmOZO g d¢ZPejQddd�ZRejQddd�ZSd4d d!„ZTG d"d#„ d#ƒZUeUƒ ZVe Wd$¡ZXd%e› �ZYd& Zd'd(„ e" [¡ D ƒ¡Z\G d)d*„ d*ej]ƒZ^G d+d,„ d,eCƒZ_G d-d.„ d.e8ƒZ`ejad/ejbf ZcG d0d1„ d1ƒZdG d2d„ dedƒZeG d3d„ dedƒZfdS )5é    )ÚannotationsN)ÚAsyncGeneratorÚ	Generator)ÚasynccontextmanagerÚcontextmanager)ÚTracebackTypeé   )Ú__version__)ÚAuthÚ	BasicAuthÚFunctionAuth)Ú'DEFAULT_KEEPALIVE_PING_INTERVAL_SECONDSÚ&DEFAULT_KEEPALIVE_PING_TIMEOUT_SECONDSÚDEFAULT_LIMITSÚDEFAULT_MAX_EVENT_SIZE_BYTESÚ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)ÚAsyncHTTPTransportÚHTTPTransport)ÚAsyncBaseTransportÚBaseTransport)Ú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;   Úurlr4   ÚlocationÚreturnÚboolc                 C  s@   | j }|j }|j|jko|jdko|jdko|jdko|jdkS )zA
    Return 'True' if 'location' is a HTTPS upgrade of 'url'
    ÚhttpéP   Úhttpsi»  )ÚoriginÚhostÚschemeÚport)r@   rA   rG   Zlocation_origin© rK   úI/var/www/html/chatgpt/venv/lib/python3.10/site-packages/httpx2/_client.pyÚ_is_https_redirectG   s   ÿþýûrM   c                   @  s   e Zd ZdZdS )Ú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__rK   rK   rK   rL   rN   W   s    rN   Zhttpx2zpython-httpx2/z, c                 C  s   g | ]}|d kr|‘qS )ÚidentityrK   )Ú.0ÚkeyrK   rK   rL   Ú
<listcomp>q   s    rV   c                   @  s   e Zd ZdZdZdZdS )ÚClientStater   é   é   N)rO   rP   rQ   ÚUNOPENEDÚOPENEDÚCLOSEDrK   rK   rK   rL   rW   t   s    rW   c                   @  ó.   e Zd ZdZddd	„Zddd„Zddd„ZdS )Ú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`.
    Ústreamr2   ÚstartÚfloatrB   ÚNonec                 C  ó   || _ || _d | _d S ©N©Ú_streamÚ_startÚelapsed©Úselfr_   r`   rK   rK   rL   Ú__init__‰   ó   
zBoundSyncStream.__init__útyping.Iterator[bytes]c                 c  s   � | j E d H  d S rd   )rf   ©rj   rK   rK   rL   Ú__iter__Ž   s   €zBoundSyncStream.__iter__c                 C  s&   t jt ¡ | j d�| _| j ¡  d S ©N)Úseconds)ÚdatetimeÚ	timedeltaÚtimeÚperf_counterrg   rh   rf   Úclosern   rK   rK   rL   rv   ‘   s   zBoundSyncStream.closeN)r_   r2   r`   ra   rB   rb   )rB   rm   ©rB   rb   )rO   rP   rQ   rR   rk   ro   rv   rK   rK   rK   rL   r^   ‚   s
    

r^   c                   @  r]   )Ú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`.
    r_   r'   r`   ra   rB   rb   c                 C  rc   rd   re   ri   rK   rK   rL   rk   �   rl   zBoundAsyncStream.__init__útyping.AsyncIterator[bytes]c              	   C sf   �| j  ¡ }z|2 z	3 d H W }|V  q	6 W t|tƒr#| ¡ I d H  d S d S t|tƒr2| ¡ I d H  w w rd   )rf   Ú	__aiter__Ú
isinstancer   Úaclose)rj   r_   ÚchunkrK   rK   rL   rz   ¢   s   €
ÿ
ÿÿzBoundAsyncStream.__aiter__c                 Ã  s.   �t jt ¡ | j d�| _| j ¡ I d H  d S rp   )rr   rs   rt   ru   rg   rh   rf   r|   rn   rK   rK   rL   r|   «   s   €zBoundAsyncStream.acloseN)r_   r'   r`   ra   rB   rb   )rB   ry   rw   )rO   rP   rQ   rR   rk   rz   r|   rK   rK   rK   rL   rx   –   s
    

	rx   .c                   @  sÔ  e Zd Zddddededddddœd|dd„Zed}d d!„ƒZed}d"d#„ƒZd~d&d'„Z	dd,d-„Z
ed€d/d0„ƒZejd�d1d0„ƒZed‚d3d4„ƒZejdƒd5d4„ƒZed„d7d8„ƒZejd…d:d8„ƒZed†d;d<„ƒZejd‡d=d<„ƒZedˆd?d@„ƒZejd‰dBd@„ƒZedŠdDdE„ƒZejd‹dGdE„ƒZedŒdIdJ„ƒZejd�dLdJ„ƒZdddddddeddMœ	dŽd\d]„Zd�d^d_„Zd�d‘d`da„Zd�d’dbdc„Zd�d“ddde„Zd”dfdg„Zefd•dkdl„Zd–dodp„Zd—dqdr„Zd˜dsdt„Zd™dudv„Zdšdxdy„Zd›dzd{„Z dS )œÚ
BaseClientNFÚ Túutf-8©ÚauthÚparamsÚheadersÚcookiesÚtimeoutÚfollow_redirectsÚmax_redirectsÚevent_hooksÚbase_urlÚ	trust_envÚdefault_encodingr‚   úAuthTypes | Nonerƒ   úQueryParamTypes | Noner„   úHeaderTypes | Noner…   úCookieTypes | Noner†   r3   r‡   rC   rˆ   Úintr‰   ú+None | typing.Mapping[str, list[EventHook]]rŠ   ú	URL | strr‹   rŒ   ú*str | typing.Callable[[bytes], str | None]rB   rb   c                C  sœ   |d u ri n|}|   t|	ƒ¡| _|  |¡| _t|ƒ| _t|ƒ| _t	|ƒ| _
t|ƒ| _|| _|| _t| dg ¡ƒt| dg ¡ƒdœ| _|
| _|| _tj| _d S ©NÚrequestÚresponse)r–   r—   )Ú_enforce_trailing_slashr4   Ú	_base_urlÚ_build_authÚ_authr5   Ú_paramsr   r„   r   Ú_cookiesr   Ú_timeoutr‡   rˆ   ÚlistÚgetÚ_event_hooksÚ
_trust_envÚ_default_encodingrW   rZ   Ú_state)rj   r‚   rƒ   r„   r…   r†   r‡   rˆ   r‰   rŠ   r‹   rŒ   rK   rK   rL   rk   ´   s   



þzBaseClient.__init__c                 C  s   | j tjkS )z2
        Check if the client being closed
        )r¤   rW   r\   rn   rK   rK   rL   Ú	is_closedÖ   s   zBaseClient.is_closedc                 C  ó   | j S rd   )r¢   rn   rK   rK   rL   r‹   Ý   ó   zBaseClient.trust_envr@   r4   c                 C  s"   |j  d¡r|S |j|j d d�S )Nó   /©Úraw_path)rª   ÚendswithÚ	copy_with©rj   r@   rK   rK   rL   r˜   á   s   z"BaseClient._enforce_trailing_slashÚproxyúProxyTypes | NoneÚallow_env_proxiesúdict[str, Proxy | None]c                 C  sH   |d u r|rdd„ t ƒ  ¡ D ƒS i S t|ttfƒrt|d�n|}d|iS )Nc                 S  s(   i | ]\}}||d u rd nt |d�“qS )N©r@   )r   )rT   rU   r@   rK   rK   rL   Ú
<dictcomp>é   s   ( z-BaseClient._get_proxy_map.<locals>.<dictcomp>r²   zall://)r7   Úitemsr{   Ústrr4   r   )rj   r®   r°   rK   rK   rL   Ú_get_proxy_mapæ   s   zBaseClient._get_proxy_mapr   c                 C  r¦   rd   )rž   rn   rK   rK   rL   r†   ï   r§   zBaseClient.timeoutc                 C  ó   t |ƒ| _d S rd   )r   rž   )rj   r†   rK   rK   rL   r†   ó   ó   údict[str, list[EventHook]]c                 C  r¦   rd   )r¡   rn   rK   rK   rL   r‰   ÷   r§   zBaseClient.event_hooksc                 C  s(   t | dg ¡ƒt | dg ¡ƒdœ| _d S r•   )rŸ   r    r¡   )rj   r‰   rK   rK   rL   r‰   û   s   þúAuth | Nonec                 C  r¦   )z§
        Authentication class used when none is passed at the request-level.

        See also [Authentication][0].

        [0]: quickstart.md#authentication
        )r›   rn   rK   rK   rL   r‚     s   	zBaseClient.authr(   c                 C  s   |   |¡| _d S rd   )rš   r›   ©rj   r‚   rK   rK   rL   r‚     s   c                 C  r¦   )zK
        Base URL to use when sending requests with relative URLs.
        )r™   rn   rK   rK   rL   rŠ     ó   zBaseClient.base_urlc                 C  s   |   t|ƒ¡| _d S rd   )r˜   r4   r™   r­   rK   rK   rL   rŠ     s   r   c                 C  r¦   )z@
        HTTP headers to include when sending requests.
        )Ú_headersrn   rK   rK   rL   r„     r¼   zBaseClient.headersr+   c                 C  s2   t dt d¡dt d¡dœƒ}| |¡ || _d S )Ns   */*Úasciis
   keep-alive)s   Accepts   Accept-Encodings
   Connections
   User-Agent)r   ÚACCEPT_ENCODINGÚencodeÚ
USER_AGENTÚupdater½   )rj   r„   Zclient_headersrK   rK   rL   r„   #  s   üÿ

r   c                 C  r¦   )zA
        Cookie values to include when sending requests.
        )r�   rn   rK   rK   rL   r…   0  r¼   zBaseClient.cookiesr*   c                 C  r·   rd   )r   r�   )rj   r…   rK   rK   rL   r…   7  r¸   r5   c                 C  r¦   )zO
        Query parameters to include in the URL when sending requests.
        )rœ   rn   rK   rK   rL   rƒ   ;  r¼   zBaseClient.paramsr-   c                 C  r·   rd   )r5   rœ   )rj   rƒ   rK   rK   rL   rƒ   B  r¸   )	ÚcontentÚdataÚfilesÚjsonrƒ   r„   r…   r†   Ú
extensionsÚmethodrµ   rÃ   úRequestContent | NonerÄ   úRequestData | NonerÅ   úRequestFiles | NonerÆ   útyping.Any | NoneúTimeoutTypes | UseClientDefaultrÇ   úRequestExtensions | Noner   c       	         C  sŽ   |   |¡}|  |¡}|  |	¡}	|  |¡}|du ri n|}d|vr9t|
tƒr(| jnt|
ƒ}
tdi |¤d|
 	¡ i¤Ž}t
|||||||||	|d�
S )aS  
        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.md#request-instances
        Nr†   )rÃ   rÄ   rÅ   rÆ   rƒ   r„   r…   rÇ   rK   )Ú
_merge_urlÚ_merge_headersÚ_merge_cookiesÚ_merge_queryparamsr{   rN   r†   r   ÚdictÚas_dictr   )rj   rÈ   r@   rÃ   rÄ   rÅ   rÆ   rƒ   r„   r…   r†   rÇ   rK   rK   rL   Úbuild_requestF  s(   



özBaseClient.build_requestc                 C  s4   t |ƒ}|jr| jj|j d¡ }| jj|d�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¬   )rj   r@   Z	merge_urlZmerge_raw_pathrK   rK   rL   rÏ   u  s
   zBaseClient._merge_urlc                 C  s&   |s| j rt| 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Â   )rj   r…   Úmerged_cookiesrK   rK   rL   rÑ   ‹  s
   


zBaseClient._merge_cookiesc                 C  s   t | 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Â   )rj   r„   Zmerged_headersrK   rK   rL   rÐ   –  s   

zBaseClient._merge_headersc                 C  s"   |s| j rt| 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)rj   rƒ   Zmerged_queryparamsrK   rK   rL   rÒ   Ÿ  s   


zBaseClient._merge_queryparamsc                 C  sX   |d u rd S t |tƒrt|d |d d�S t |tƒr|S t|ƒr%t|d�S td|›�ƒ‚)Nr   r   ©ÚusernameÚpassword)ÚfunczInvalid "auth" argument: )r{   Útupler   r
   Úcallabler   Ú	TypeErrorr»   rK   rK   rL   rš   ©  s   


zBaseClient._build_authr–   ú#AuthTypes | UseClientDefault | Noner
   c                 C  sR   t |tƒr| jn|  |¡}|d ur|S |jj|jj}}|s |r&t||d�S tƒ S )NrÚ   )	r{   rN   r›   rš   r@   rÛ   rÜ   r   r
   )rj   r–   r‚   rÛ   rÜ   rK   rK   rL   Ú_build_request_authµ  s   zBaseClient._build_request_authr—   r    c                 C  sR   |   ||¡}|  ||¡}|  |||¡}|  ||¡}t| jƒ}t||||||jd�S )zƒ
        Given a request and a redirect response, return a new request that
        should be used to effect the redirect.
        )rÈ   r@   r„   r…   r_   rÇ   )Ú_redirect_methodÚ_redirect_urlÚ_redirect_headersÚ_redirect_streamr   r…   r   rÇ   )rj   r–   r—   rÈ   r@   r„   r_   r…   rK   rK   rL   Ú_build_redirect_requestÅ  s   
úz"BaseClient._build_redirect_requestc                 C  sR   |j }|jtjkr|dk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)rj   r–   r—   rÈ   rK   rK   rL   rã   Ø  s   zBaseClient._redirect_methodc              
   C  s–   |j d }zt|ƒ}W n ty" } ztd|› d�|d�d‚d}~ww |jr1|js1|j|jjd�}|jr:|j 	|¡}|jj
rI|j
sI|j|jj
d�}|S )z<
        Return the URL for the redirect to follow.
        ZLocationz Invalid URL in location header: Ú.©r–   N)rH   )Úfragment)r„   r4   r   r   rI   rH   r¬   r@   rÖ   Újoinrò   )rj   r–   r—   rA   r@   ÚexcrK   rK   rL   rä   ñ  s   
€ÿzBaseClient._redirect_urlc                 C  sz   t |jƒ}|j|jjkr t|j|ƒs| dd¡ |j d¡|d< ||jkr5|dkr5| dd¡ | dd¡ | 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„   rG   r@   rM   ÚpopÚnetlocÚdecoderÈ   )rj   r–   r@   rÈ   r„   rK   rK   rL   rå     s   
zBaseClient._redirect_headersú'SyncByteStream | AsyncByteStream | Nonec                 C  s   ||j kr|dkrdS |jS )zO
        Return the body that should be used for the redirect request.
        ré   N)rÈ   r_   )rj   r–   rÈ   rK   rK   rL   ræ   '  s   zBaseClient._redirect_streamc                 C  sL   d|j vr$t| jtƒr| jnt| jƒ}tdi |j ¤d| ¡ i¤Ž|_ d S d S )Nr†   rK   )rÇ   r{   r†   rN   r   rÓ   rÔ   )rj   r–   r†   rK   rK   rL   Ú_set_timeout0  s   
"þzBaseClient._set_timeout)r‚   r�   rƒ   rŽ   r„   r�   r…   r�   r†   r3   r‡   rC   rˆ   r‘   r‰   r’   rŠ   r“   r‹   rC   rŒ   r”   rB   rb   )rB   rC   )r@   r4   rB   r4   )r®   r¯   r°   rC   rB   r±   )rB   r   )r†   r3   rB   rb   )rB   r¹   )r‰   r¹   rB   rb   )rB   rº   )r‚   r(   rB   rb   )rB   r4   )r@   r“   rB   rb   )rB   r   )r„   r+   rB   rb   )rB   r   )r…   r*   rB   rb   )rB   r5   )rƒ   r-   rB   rb   )rÈ   rµ   r@   r“   rÃ   rÉ   rÄ   rÊ   rÅ   rË   rÆ   rÌ   rƒ   rŽ   r„   r�   r…   r�   r†   rÍ   rÇ   rÎ   rB   r   )r@   r“   rB   r4   rd   )r…   r�   rB   r�   )r„   r�   rB   r�   )rƒ   rŽ   rB   rŽ   )r‚   r�   rB   rº   )r–   r   r‚   rá   rB   r
   )r–   r   r—   r    rB   r   )r–   r   r—   r    rB   rµ   )r–   r   r—   r    rB   r4   )r–   r   r@   r4   rÈ   rµ   rB   r   )r–   r   rÈ   rµ   rB   rû   )r–   r   rB   rb   )!rO   rP   rQ   r   r   rk   Ú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ü   rK   rK   rK   rL   r~   ³   sŒ    ó"

	
ó
/	

ý




	r~   c                      s‚  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-d.„Zdddddedfd‘d0d1„Zdddddefd’d3d4„Z	d“d7d8„Z
dddddddeeedd9œd”dJdK„Zedddddddeeedd9œd•dMdN„ƒZedOdddddddeeededPœd–dTdU„ƒZeeeeeddddeeeddVœd—d_d`„ƒZdeedaœd˜dedf„Zd™djdk„Zdšdldm„Zd›dndo„Zdddeeeddpœdœdqdr„Zdddeeeddpœd�dtdu„Zdddeeeddpœd�dvdw„Zdddddddeeedd9œdždxdy„Zdddddddeeedd9œdždzd{„Zdddddddeeedd9œdžd|d}„Zdddeeeddpœd�d~d„Z dddddddeeedd9œdžd€d�„Z!dŸd‚dƒ„Z"d d†d‡„Z#			d¡d¢dŽd�„Z$‡  Z%S )£r<   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Œ   r‚   r�   rƒ   rŽ   r„   r�   r…   r�   rÿ   ússl.SSLContext | str | boolr   úCertTypes | Noner‹   rC   r  r  r®   r¯   r  ú0None | typing.Mapping[str, BaseTransport | None]r†   r3   r‡   r  r   rˆ   r‘   r‰   r’   rŠ   r“   r  úBaseTransport | NonerŒ   r”   rB   rb   c                  sÜ   t ƒ j|||||||||ˆ|d� ˆr&zdd l}W n ty%   tdƒd ‚w ˆo+|d u }ˆ |
|¡}ˆjˆˆ ˆˆˆˆ|d�ˆ_‡ ‡‡‡‡‡‡fdd„| ¡ D ƒˆ_|d urbˆj 	dd„ | ¡ D ƒ¡ t
tˆj ¡ ƒƒˆ_d S )Nr�   r   úuUsing http2=True, but the 'h2' package is not installed. Make sure to install httpx using `pip install httpx[http2]`.©rÿ   r   r‹   r  r  r  r  c                   ó:   i | ]\}}t |ƒ|d u rd nˆj|ˆˆ ˆˆˆˆd�“qS ©N)rÿ   r   r‹   r  r  r  ©r6   Ú_init_proxy_transport©rT   rU   r®   ©r   r  r  r  rj   r‹   rÿ   rK   rL   r³   Ÿ  ó    õÿùýz#Client.__init__.<locals>.<dictcomp>c                 S  ó   i | ]	\}}t |ƒ|“qS rK   ©r6   ©rT   rU   r  rK   rK   rL   r³   ®  ó    ©Úsuperrk   Úh2ÚImportErrorr¶   Ú_init_transportÚ
_transportr´   Ú_mountsrÂ   rÓ   Úsorted)rj   r‚   rƒ   r„   r…   rÿ   r   r‹   r  r  r®   r  r†   r‡   r  rˆ   r‰   rŠ   r  rŒ   r  r°   Ú	proxy_map©Ú	__class__r  rL   rk   e  sP   õÿýÿù	ôzClient.__init__r&   c                 C  ó    |d ur|S t ||||||d�S r  ©r$   ©rj   rÿ   r   r‹   r  r  r  r  rK   rK   rL   r  ²  ó   
úzClient._init_transportr   c              	   C  ó   t |||||||d�S ©N)rÿ   r   r‹   r  r  r  r®   r#  ©rj   r®   rÿ   r   r‹   r  r  r  rK   rK   rL   r  È  ó   
ùzClient._init_proxy_transportr@   r4   c                 C  ó>   | j  ¡ D ]\}}| |¡r|du r| j  S |  S q| 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.
        N©r  r´   Úmatchesr  ©rj   r@   Úpatternr  rK   rK   rL   Ú_transport_for_urlÜ  ó
   
ÿzClient._transport_for_url©rÃ   rÄ   rÅ   rÆ   rƒ   r„   r…   r‚   r‡   r†   rÇ   rÈ   rµ   rÃ   rÉ   rÄ   rÊ   rÅ   rË   rÆ   rÌ   rá   úbool | UseClientDefaultrÍ   rÇ   rÎ   r    c                C  sL   |	durd}t j|tdd� | j|||||||||	||d�}| j||
|d�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.md#merging-of-configuration
        Nú®Setting per-request cookies=<...> is being deprecated, because the expected behaviour on cookie persistence is ambiguous. Set cookies directly on the client instance instead.rX   ©Ú
stacklevel©rÈ   r@   rÃ   rÄ   rÅ   rÆ   rƒ   r„   r…   r†   rÇ   ©r‚   r‡   ©ÚwarningsÚwarnÚDeprecationWarningrÕ   Úsend©rj   rÈ   r@   rÃ   rÄ   rÅ   rÆ   rƒ   r„   r…   r‚   r‡   r†   rÇ   Úmessager–   rK   rK   rL   r–   ç  s$   !ÿõzClient.requestúGenerator[Response]c                c  sT   � | j |||||||||	||d�}| j||
|dd�}z
|V  W | ¡  dS | ¡  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.md#streaming-responses
        r7  T)r–   r‚   r‡   r_   N)rÕ   r=  rv   ©rj   rÈ   r@   rÃ   rÄ   rÅ   rÆ   rƒ   r„   r…   r‚   r‡   r†   rÇ   r–   r—   rK   rK   rL   r_     s.   €õüzClient.streamré   ©rÈ   rÃ   rÄ   rÅ   rÆ   rƒ   r„   r…   r‚   r‡   r†   rÇ   Úmax_event_sizerD  ú
int | NoneúGenerator[EventSource]c                c  sh   � | j |||||||dddœt|ƒB |	|
|||d��}t||d�V  W d  ƒ dS 1 s-w   Y  dS )úÎ
        Connect to a server-sent events endpoint and yield an `EventSource`.

        Iterating the `EventSource` yields `ServerSentEvent` instances.

        **Parameters**: See `httpx2.request`.
        útext/event-streamúno-store©ÚAcceptzCache-Controlr2  ©rD  N©r_   r   r!   ©rj   r@   rÈ   rÃ   rÄ   rÅ   rÆ   rƒ   r„   r…   r‚   r‡   r†   rÇ   rD  r—   rK   rK   rL   ÚsseS  s&   €ó"ñz
Client.sse©Úmax_message_size_bytesÚ
queue_sizeÚkeepalive_ping_interval_secondsÚkeepalive_ping_timeout_secondsÚsubprotocolsrƒ   r„   r…   r‚   r‡   r†   rÇ   rQ  rR  rS  úfloat | NonerT  rU  úlist[str] | NoneúGenerator[WebSocketSession]c                c  s~   � zddl m} W n ty   tdƒ‚w |t|ƒ| ||||||||	|
|||d��}|V  W d  ƒ dS 1 s8w   Y  dS )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]`.rP  N)Úwebsockets._apirY  r  rµ   )rj   r@   rQ  rR  rS  rT  rU  rƒ   r„   r…   r‚   r‡   r†   rÇ   rY  ÚsessionrK   rK   rL   Ú	websocket~  s6   €ÿÿò"ðzClient.websocket©r_   r‚   r‡   r–   r   r_   c             
   C  s�   | j tjkr
tdƒ‚tj| _ t|tƒr| jn|}|  |¡ |  	||¡}| j
|||g d�}z	|s3| ¡  |W S  tyG } z| ¡  |‚d}~w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.md#request-instances
        ú5Cannot send a request, as the client has been closed.©r‚   r‡   ÚhistoryN)r¤   rW   r\   ÚRuntimeErrorr[   r{   rN   r‡   rü   râ   Ú_send_handling_authÚreadÚBaseExceptionrv   ©rj   r–   r_   r‚   r‡   r—   rô   rK   rK   rL   r=  µ  s*   
ü€þzClient.sendr
   ra  úlist[Response]c           	   
   C  s®   |  |¡}zLt|ƒ}	 | j|||d�}z+z| |¡}W n ty,   | Y W W | ¡  S w t|ƒ|_| ¡  |}| 	|¡ W n t
yP } z| ¡  |‚d }~ww q| ¡  w ©NT)r‡   ra  )Zsync_auth_flowÚnextÚ_send_handling_redirectsr=  ÚStopIterationrv   rŸ   ra  rd  Úappendre  ©	rj   r–   r‚   r‡   ra  Z	auth_flowr—   Únext_requestrô   rK   rK   rL   rc  ä  s6   
ý

ô
€þï
zClient._send_handling_authc              
   C  sÈ   	 t |ƒ| jkrtd|d�‚| jd D ]}||ƒ q|  |¡}z1| jd D ]}||ƒ q%t|ƒ|_|js7|W S |  ||¡}||g }|rI| 	¡  n||_
|W S W n tyb } z| ¡  |‚d }~ww q©NTz#Exceeded maximum allowed redirects.rñ   r–   r—   )Úlenrˆ   r   r¡   Ú_send_single_requestrŸ   ra  Úhas_redirect_locationrç   rd  rn  re  rv   ©rj   r–   r‡   ra  Úhookr—   rô   rK   rK   rL   rj    s2   





ý€þçzClient._send_handling_redirectsc                 C  s¸   |   |j¡}t ¡ }t|jtƒstdƒ‚t|d�� | 	|¡}W d  ƒ n1 s)w   Y  t|jtƒs6J ‚||_
t|j|d�|_| j |¡ | j|_t d|j|j|j|j|j¡ |S )úL
        Sends a single request, without handling any redirections.
        z?Attempted to send an async request with a sync Client instance.rñ   N©r`   úHTTP Request: %s %s "%s %d %s")r0  r@   rt   ru   r{   r_   r2   rb  r   Úhandle_requestr–   r^   r…   Úextract_cookiesr£   rŒ   ÚloggerÚinforÈ   Úhttp_versionrì   Úreason_phrase©rj   r–   r  r`   r—   rK   rK   rL   rq  )  s*   ÿú	zClient._send_single_request©rƒ   r„   r…   r‚   r‡   r†   rÇ   c          	      C  ó   | j d||||||||d�	S )úV
        Send a `GET` request.

        **Parameters**: See `httpx2.request`.
        ré   r  rñ   ©	rj   r@   rƒ   r„   r…   r‚   r‡   r†   rÇ   rK   rK   rL   r    H  ó   ÷z
Client.getúAuthTypes | UseClientDefaultc          	      C  r€  )ú[
        Send an `OPTIONS` request.

        **Parameters**: See `httpx2.request`.
        ÚOPTIONSr  rñ   r‚  rK   rK   rL   Úoptionse  rƒ  zClient.optionsc          	      C  r€  )úW
        Send a `HEAD` request.

        **Parameters**: See `httpx2.request`.
        rè   r  rñ   r‚  rK   rK   rL   Úhead‚  rƒ  zClient.headc                C  ó$   | j d|||||||||	|
||d�S )úW
        Send a `POST` request.

        **Parameters**: See `httpx2.request`.
        rë   r2  rñ   ©rj   r@   rÃ   rÄ   rÅ   rÆ   rƒ   r„   r…   r‚   r‡   r†   rÇ   rK   rK   rL   ÚpostŸ  ó   ózClient.postc                C  rŠ  )úV
        Send a `PUT` request.

        **Parameters**: See `httpx2.request`.
        ÚPUTr2  rñ   rŒ  rK   rK   rL   ÚputÄ  rŽ  z
Client.putc                C  rŠ  )úX
        Send a `PATCH` request.

        **Parameters**: See `httpx2.request`.
        ÚPATCHr2  rñ   rŒ  rK   rK   rL   Úpatché  rŽ  zClient.patchc          	      C  r€  )úY
        Send a `DELETE` request.

        **Parameters**: See `httpx2.request`.
        ÚDELETEr  rñ   r‚  rK   rK   rL   Údelete  rƒ  zClient.deletec                C  rŠ  )úX
        Send a `QUERY` request.

        **Parameters**: See `httpx2.request`.
        rê   r2  rñ   rŒ  rK   rK   rL   Úquery+  rŽ  zClient.queryc                 C  sF   | j tjkrtj| _ | j ¡  | j ¡ D ]}|dur| ¡  qdS dS ©z.
        Close transport and proxies.
        N)r¤   rW   r\   r  rv   r  Úvalues)rj   r  rK   rK   rL   rv   P  s   
€úzClient.closerj   r=   c                 C  s`   | j tjkrtjdtjdi| j  }t|ƒ‚tj| _ | j ¡  | j 	¡ D ]
}|d ur-| ¡  q#| S ©Nz-Cannot open a client instance more than once.z9Cannot reopen a client instance, once it has been closed.)
r¤   rW   rZ   r[   r\   rb  r  Ú	__enter__r  r›  )rj   Úmsgr  rK   rK   rL   r�  \  s   þý
€zClient.__enter__Úexc_typeútype[BaseException] | NoneÚ	exc_valueúBaseException | NoneÚ	tracebackúTracebackType | Nonec                 C  sB   t j| _| j |||¡ | j ¡ D ]}|d ur| |||¡ qd S rd   )rW   r\   r¤   r  Ú__exit__r  r›  )rj   rŸ  r¡  r£  r  rK   rK   rL   r¥  l  s   €þzClient.__exit__)(r‚   r�   rƒ   rŽ   r„   r�   r…   r�   rÿ   r  r   r  r‹   rC   r  rC   r  rC   r®   r¯   r  r  r†   r3   r‡   rC   r  r   rˆ   r‘   r‰   r’   rŠ   r“   r  r	  rŒ   r”   rB   rb   )rÿ   r  r   r  r‹   rC   r  rC   r  rC   r  r   r  r	  rB   r&   )r®   r   rÿ   r  r   r  r‹   rC   r  rC   r  rC   r  r   rB   r&   )r@   r4   rB   r&   ©rÈ   rµ   r@   r“   rÃ   rÉ   rÄ   rÊ   rÅ   rË   rÆ   rÌ   rƒ   rŽ   r„   r�   r…   r�   r‚   rá   r‡   r3  r†   rÍ   rÇ   rÎ   rB   r    )rÈ   rµ   r@   r“   rÃ   rÉ   rÄ   rÊ   rÅ   rË   rÆ   rÌ   rƒ   rŽ   r„   r�   r…   r�   r‚   rá   r‡   r3  r†   rÍ   rÇ   rÎ   rB   r@  )r@   r“   rÈ   rµ   rÃ   rÉ   rÄ   rÊ   rÅ   rË   rÆ   rÌ   rƒ   rŽ   r„   r�   r…   r�   r‚   rá   r‡   r3  r†   rÍ   rÇ   rÎ   rD  rE  rB   rF  )r@   r“   rQ  r‘   rR  r‘   rS  rV  rT  rV  rU  rW  rƒ   rŽ   r„   r�   r…   r�   r‚   rá   r‡   r3  r†   rÍ   rÇ   rÎ   rB   rX  ©
r–   r   r_   rC   r‚   rá   r‡   r3  rB   r    ©
r–   r   r‚   r
   r‡   rC   ra  rg  rB   r    ©r–   r   r‡   rC   ra  rg  rB   r    ©r–   r   rB   r    ©r@   r“   rƒ   rŽ   r„   r�   r…   r�   r‚   rá   r‡   r3  r†   rÍ   rÇ   rÎ   rB   r    ©r@   r“   rƒ   rŽ   r„   r�   r…   r�   r‚   r„  r‡   r3  r†   rÍ   rÇ   rÎ   rB   r    ©r@   r“   rÃ   rÉ   rÄ   rÊ   rÅ   rË   rÆ   rÌ   rƒ   rŽ   r„   r�   r…   r�   r‚   r„  r‡   r3  r†   rÍ   rÇ   rÎ   rB   r    rw   )rj   r=   rB   r=   ©NNN©rŸ  r   r¡  r¢  r£  r¤  rB   rb   )&rO   rP   rQ   rR   r   r   r   rk   r  r  r0  r:   r–   r   r_   r   rO  r   r   r   r   r]  r=  rc  rj  rq  r    r‡  r‰  r�  r‘  r”  r—  r™  rv   r�  r¥  Ú__classcell__rK   rK   r   rL   r<   6  sr   1ëOøø
ñ8ñ3ð*ñ:ú
/
"
##ö!ö!ö!ò)ò)ò)ö!ò
%
üc                      s‚  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-d.„Zdddddedfd‘d0d1„Zdddddefd’d3d4„Z	d“d7d8„Z
dddddddeeedd9œd”dJdK„Zedddddddeeedd9œd•dMdN„ƒZedOdddddddeeededPœd–dTdU„ƒZeeeeeddddeeeddVœd—d_d`„ƒZdeedaœd˜dedf„Zd™djdk„Zdšdldm„Zd›dndo„Zdddeeeddpœdœdqdr„Zdddeeeddpœd�dtdu„Zdddeeeddpœd�dvdw„Zdddddddeeedd9œdždxdy„Zdddddddeeedd9œdždzd{„Zdddddddeeedd9œdžd|d}„Zdddeeeddpœd�d~d„Z dddddddeeedd9œdžd€d�„Z!dŸd‚dƒ„Z"d d†d‡„Z#			d¡d¢dŽd�„Z$‡  Z%S )£r;   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   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  rC   r  r®   r¯   r  ú5None | typing.Mapping[str, AsyncBaseTransport | None]r†   r3   r‡   r  r   rˆ   r‘   r‰   r’   rŠ   r“   r  úAsyncBaseTransport | Noner‹   rŒ   r”   rB   rb   c                  sÜ   t ƒ j|||||||||ˆ|d� ˆr&zdd l}W n ty%   tdƒd ‚w ˆo+|d u }ˆ |	|¡}ˆjˆˆ ˆˆˆˆ|d�ˆ_‡ ‡‡‡‡‡‡fdd„| ¡ D ƒˆ_|
d urbˆj 	dd„ |
 ¡ D ƒ¡ t
tˆj ¡ ƒƒˆ_d S )Nr�   r   r
  r  c                   r  r  r  r  r  rK   rL   r³   å  r  z(AsyncClient.__init__.<locals>.<dictcomp>c                 S  r  rK   r  r  rK   rK   rL   r³   ô  r  r  )rj   r‚   rƒ   r„   r…   rÿ   r   r  r  r®   r  r†   r‡   r  rˆ   r‰   rŠ   r  r‹   rŒ   r  r°   r  r   r  rL   rk   ª  sP   õÿýÿù
ôzAsyncClient.__init__r%   c                 C  r"  r  ©r#   r$  rK   rK   rL   r  ÷  r%  zAsyncClient._init_transportr   c              	   C  r&  r'  r³  r(  rK   rK   rL   r    r)  z!AsyncClient._init_proxy_transportr@   r4   c                 C  r*  r+  r,  r.  rK   rK   rL   r0  !  r1  zAsyncClient._transport_for_urlr2  rÈ   rµ   rÃ   rÉ   rÄ   rÊ   rÅ   rË   rÆ   rÌ   rá   r3  rÍ   rÇ   rÎ   r    c                Ã  sT   �|	durd}t j|tdd� | j|||||||||	||d�}| j||
|d�I dH S )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.md#merging-of-configuration
        Nr4  rX   r5  r7  r8  r9  r>  rK   rK   rL   r–   ,  s&   €"ÿõzAsyncClient.requestúAsyncGenerator[Response]c                C sf   �| j |||||||||	||d�}| j||
|dd�I dH }z|V  W | ¡ I dH  dS | ¡ I dH  w rA  )rÕ   r=  r|   rB  rK   rK   rL   r_   e  s.   €õü"zAsyncClient.streamré   rC  rD  rE  úAsyncGenerator[EventSource]c                C s|   �| j |||||||dddœt|ƒB |	|
|||d�4 I dH š}t||d�V  W d  ƒI dH  dS 1 I dH s7w   Y  dS )rG  rH  rI  rJ  r2  NrL  rM  rN  rK   rK   rL   rO  ™  s&   €ó.ñzAsyncClient.sserP  rQ  rR  rS  rV  rT  rU  rW  ú%AsyncGenerator[AsyncWebSocketSession]c                C s’   �zddl m} W n ty   tdƒ‚w |t|ƒ| ||||||||	|
|||d�4 I dH š}|V  W d  ƒI dH  dS 1 I dH sBw   Y  dS )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_wsrZ  rP  N)r[  r·  r  rµ   )rj   r@   rQ  rR  rS  rT  rU  rƒ   r„   r…   r‚   r‡   r†   rÇ   r·  r\  rK   rK   rL   r]  Ä  s6   €ÿÿò.ðzAsyncClient.websocketr^  r–   r   r_   c             
   Ã  s¤   �| j tjkrtdƒ‚tj| _ t|tƒr| jn|}|  |¡ |  	||¡}| j
|||g d�I dH }z|s:| ¡ I dH  |W S  tyQ } z	| ¡ I dH  |‚d}~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.md#request-instances
        r_  r`  N)r¤   rW   r\   rb  r[   r{   rN   r‡   rü   râ   rc  Úareadre  r|   rf  rK   rK   rL   r=  û  s,   €
ü€þzAsyncClient.sendr
   ra  rg  c           	   
   Ã  sÚ   �|  |¡}z^| ¡ I d H }	 | j|||d�I d H }z4z
| |¡I d H }W n ty9   | Y W W | ¡ I d H  S w t|ƒ|_| ¡ I d H  |}| 	|¡ W n t
yc } z	| ¡ I d H  |‚d }~ww q| ¡ I d H  w rh  )Zasync_auth_flowÚ	__anext__rj  ÚasendÚStopAsyncIterationr|   rŸ   ra  r¸  rl  re  rm  rK   rK   rL   rc  *  s8   €
ý
ô
€þïzAsyncClient._send_handling_authc              
   Ã  sè   �	 t |ƒ| jkrtd|d�‚| jd D ]	}||ƒI d H  q|  |¡I d H }z7| jd D ]	}||ƒI d H  q,t|ƒ|_|jsA|W S |  ||¡}||g }|rV| 	¡ I d H  n||_
|W S W n tyr } z	| ¡ I d H  |‚d }~ww qro  )rp  rˆ   r   r¡   rq  rŸ   ra  rr  rç   r¸  rn  re  r|   rs  rK   rK   rL   rj  L  s4   €

ý€þæz$AsyncClient._send_handling_redirectsc                 Ã  sÀ   �|   |j¡}t ¡ }t|jtƒstdƒ‚t|d�� | 	|¡I dH }W d  ƒ n1 s-w   Y  t|jtƒs:J ‚||_
t|j|d�|_| j |¡ | j|_t d|j|j|j|j|j¡ |S )ru  z>Attempted to send a sync request with an AsyncClient instance.rñ   Nrv  rw  )r0  r@   rt   ru   r{   r_   r'   rb  r   Zhandle_async_requestr–   rx   r…   ry  r£   rŒ   rz  r{  rÈ   r|  rì   r}  r~  rK   rK   rL   rq  p  s,   €ÿú	z AsyncClient._send_single_requestr  c          	      Ã  ó$   �| j d||||||||d�	I dH S )r�  ré   r  Nrñ   r‚  rK   rK   rL   r    Ž  ó   €÷zAsyncClient.getr„  c          	      Ã  r¼  )r…  r†  r  Nrñ   r‚  rK   rK   rL   r‡  «  r½  zAsyncClient.optionsc          	      Ã  r¼  )rˆ  rè   r  Nrñ   r‚  rK   rK   rL   r‰  È  r½  zAsyncClient.headc                Ã  ó,   �| j d|||||||||	|
||d�I dH S )r‹  rë   r2  Nrñ   rŒ  rK   rK   rL   r�  å  ó    €ózAsyncClient.postc                Ã  r¾  )r�  r�  r2  Nrñ   rŒ  rK   rK   rL   r‘  
  r¿  zAsyncClient.putc                Ã  r¾  )r’  r“  r2  Nrñ   rŒ  rK   rK   rL   r”  /  r¿  zAsyncClient.patchc          	      Ã  r¼  )r•  r–  r  Nrñ   r‚  rK   rK   rL   r—  T  r½  zAsyncClient.deletec                Ã  r¾  )r˜  rê   r2  Nrñ   rŒ  rK   rK   rL   r™  q  r¿  zAsyncClient.queryc                 Ã  sT   �| j tjkr&tj| _ | j ¡ I dH  | j ¡ D ]}|dur%| ¡ I dH  qdS dS rš  )r¤   rW   r\   r  r|   r  r›  )rj   r®   rK   rK   rL   r|   –  s   €€úzAsyncClient.acloserj   r?   c                 Ã  sn   �| j tjkrtjdtjdi| j  }t|ƒ‚tj| _ | j ¡ I d H  | j 	¡ D ]}|d ur4| ¡ I d H  q'| S rœ  )
r¤   rW   rZ   r[   r\   rb  r  Ú
__aenter__r  r›  )rj   rž  r®   rK   rK   rL   rÀ  ¢  s   €þý€zAsyncClient.__aenter__rŸ  r   r¡  r¢  r£  r¤  c                 Ã  sP   �t j| _| j |||¡I d H  | j ¡ D ]}|d ur%| |||¡I d H  qd S rd   )rW   r\   r¤   r  Ú	__aexit__r  r›  )rj   rŸ  r¡  r£  r®   rK   rK   rL   rÁ  ²  s   €€þzAsyncClient.__aexit__)(r‚   r�   rƒ   rŽ   r„   r�   r…   r�   rÿ   r  r   r  r  rC   r  rC   r®   r¯   r  r±  r†   r3   r‡   rC   r  r   rˆ   r‘   r‰   r’   rŠ   r“   r  r²  r‹   rC   rŒ   r”   rB   rb   )rÿ   r  r   r  r‹   rC   r  rC   r  rC   r  r   r  r²  rB   r%   )r®   r   rÿ   r  r   r  r‹   rC   r  rC   r  rC   r  r   rB   r%   )r@   r4   rB   r%   r¦  )rÈ   rµ   r@   r“   rÃ   rÉ   rÄ   rÊ   rÅ   rË   rÆ   rÌ   rƒ   rŽ   r„   r�   r…   r�   r‚   rá   r‡   r3  r†   rÍ   rÇ   rÎ   rB   r´  )r@   r“   rÈ   rµ   rÃ   rÉ   rÄ   rÊ   rÅ   rË   rÆ   rÌ   rƒ   rŽ   r„   r�   r…   r�   r‚   rá   r‡   r3  r†   rÍ   rÇ   rÎ   rD  rE  rB   rµ  )r@   r“   rQ  r‘   rR  r‘   rS  rV  rT  rV  rU  rW  rƒ   rŽ   r„   r�   r…   r�   r‚   rá   r‡   r3  r†   rÍ   rÇ   rÎ   rB   r¶  r§  r¨  r©  rª  r«  r¬  r­  rw   )rj   r?   rB   r?   r®  r¯  )&rO   rP   rQ   rR   r   r   r   rk   r  r  r0  r:   r–   r   r_   r   rO  r   r   r   r   r]  r=  rc  rj  rq  r    r‡  r‰  r�  r‘  r”  r—  r™  r|   rÀ  rÁ  r°  rK   rK   r   rL   r;   z  sr   2ëOøø
ñ9ñ3ð*ñ:ú
/
"
$"ö!ö!ö!ò)ò)ò)ö!ò
%
ü)r@   r4   rA   r4   rB   rC   )gÚ
__future__r   rr   ÚenumÚloggingrt   Útypingr:  Úcollections.abcr   r   Ú
contextlibr   r   Útypesr   r	   r›   r
   r   r   Ú_configr   r   r   r   r   r   r   r   r   r   r   Ú	_decodersr   Ú_exceptionsr   r   r   r   Z_modelsr   r   r   r    Z_sser!   Z_status_codesr"   Z_transportsr#   r$   Z_transports.baser%   r&   Ú_typesr'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   Z_urlsr4   r5   Z_utilsr6   r7   ÚTYPE_CHECKINGÚsslr[  r8   r9   Ú__all__ÚTypeVarr=   r?   rM   rN   r:   Ú	getLoggerrz  rÁ   ró   Úkeysr¿   ÚEnumrW   r^   rx   ÚCallableÚAnyZ	EventHookr~   r<   r;   rK   rK   rK   rL   Ú<module>   sf    4<


         J