o
    Þ­jÀ	 ã                   @  sX  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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 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l(m)Z)m*Z* ddl+m,Z,m-Z- ddl.m/Z/ ddl0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z? ddl@mAZAmBZB ddlCmDZDmEZEmFZFmGZGmHZH g d¢ZIejJddd�ZKejJddd�ZLG dd„ dƒZMeMƒ ZNe Od¡ZPde› �ZQd Rdd „ e S¡ D ƒ¡ZTG d!d"„ d"ejUƒZVG d#d$„ d$e=ƒZWG d%d&„ d&e1ƒZXejYd'ejZf Z[G d(d)„ d)ƒZ\G d*d„ de\ƒZ]G d+d„ de\ƒZ^dS ),é    )ÚannotationsN)ÚasynccontextmanagerÚcontextmanager)ÚTracebackTypeé   )Ú__version__)ÚAuthÚ	BasicAuthÚFunctionAuth)ÚDEFAULT_LIMITSÚDEFAULT_MAX_REDIRECTSÚDEFAULT_TIMEOUT_CONFIGÚLimitsÚProxyÚTimeout)ÚSUPPORTED_DECODERS)Ú
InvalidURLÚRemoteProtocolErrorÚTooManyRedirectsÚrequest_context)ÚCookiesÚHeadersÚRequestÚResponse)Úcodes)ÚASGITransport)ÚAsyncBaseTransportÚBaseTransport)ÚAsyncHTTPTransportÚHTTPTransport)ÚWSGITransport)ÚAsyncByteStreamÚ	AuthTypesÚ	CertTypesÚCookieTypesÚHeaderTypesÚProxiesTypesÚ
ProxyTypesÚQueryParamTypesÚRequestContentÚRequestDataÚRequestExtensionsÚRequestFilesÚSyncByteStreamÚTimeoutTypesÚVerifyTypes)ÚURLÚQueryParams)ÚTimerÚ
URLPatternÚget_environment_proxiesÚis_https_redirectÚsame_origin)ÚUSE_CLIENT_DEFAULTÚAsyncClientÚClientÚTr9   )ÚboundÚUr8   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__© rB   rB   úJ/var/www/html/CropPilot/venv/lib/python3.10/site-packages/httpx/_client.pyr=   D   s    r=   Úhttpxzpython-httpx/z, c                 C  s   g | ]}|d kr|‘qS )ÚidentityrB   )Ú.0ÚkeyrB   rB   rC   Ú
<listcomp>_   s    rH   c                   @  s   e Zd ZdZdZdZdS )ÚClientStater   é   é   N)r>   r?   r@   ÚUNOPENEDÚOPENEDÚCLOSEDrB   rB   rB   rC   rI   c   s    rI   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 is bound to a given response instance, and that
    ensures the `response.elapsed` is set once the response is closed.
    Ústreamr-   Úresponser   Útimerr2   ÚreturnÚNonec                 C  ó   || _ || _|| _d S ©N©Ú_streamÚ	_responseÚ_timer©ÚselfrQ   rR   rS   rB   rB   rC   Ú__init__w   ó   
zBoundSyncStream.__init__útyping.Iterator[bytes]c                 c  s   � | j D ]}|V  qd S rW   ©rY   ©r]   ÚchunkrB   rB   rC   Ú__iter__~   s   €
ÿzBoundSyncStream.__iter__c                 C  s(   | j  ¡ }tj|d�| j_| j ¡  d S ©N)Úseconds)r[   Úsync_elapsedÚdatetimeÚ	timedeltarZ   ÚelapsedrY   Úclose©r]   rf   rB   rB   rC   rk   ‚   s   
zBoundSyncStream.closeN)rQ   r-   rR   r   rS   r2   rT   rU   )rT   r`   ©rT   rU   )r>   r?   r@   rA   r^   rd   rk   rB   rB   rB   rC   rP   q   ó
    

rP   c                   @  rO   )ÚBoundAsyncStreamzš
    An async byte stream that is bound to a given response instance, and that
    ensures the `response.elapsed` is set once the response is closed.
    rQ   r!   rR   r   rS   r2   rT   rU   c                 C  rV   rW   rX   r\   rB   rB   rC   r^   Ž   r_   zBoundAsyncStream.__init__útyping.AsyncIterator[bytes]c                 C s"   �| j 2 z	3 d H W }|V  q6 d S rW   ra   rb   rB   rB   rC   Ú	__aiter__•   s   €ÿzBoundAsyncStream.__aiter__c                 Ã  s6   �| j  ¡ I d H }tj|d�| j_| j ¡ I d H  d S re   )r[   Úasync_elapsedrh   ri   rZ   rj   rY   Úacloserl   rB   rB   rC   rs   ™   s   €zBoundAsyncStream.acloseN)rQ   r!   rR   r   rS   r2   rT   rU   )rT   rp   rm   )r>   r?   r@   rA   r^   rq   rs   rB   rB   rB   rC   ro   ˆ   rn   ro   .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_encodingrx   úAuthTypes | Nonery   úQueryParamTypes | Nonerz   úHeaderTypes | Noner{   úCookieTypes | Noner|   r.   r}   Úboolr~   Úintr   ú+None | typing.Mapping[str, list[EventHook]]r€   ú	URL | strr�   r‚   ú#str | typing.Callable[[bytes], str]rT   rU   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ÚrequestrR   )r�   rR   )Ú_enforce_trailing_slashr0   Ú	_base_urlÚ_build_authÚ_authr1   Ú_paramsr   rz   r   Ú_cookiesr   Ú_timeoutr}   r~   ÚlistÚgetÚ_event_hooksÚ
_trust_envÚ_default_encodingrI   rL   Ú_state)r]   rx   ry   rz   r{   r|   r}   r~   r   r€   r�   r‚   rB   rB   rC   r^   £   s   



þzBaseClient.__init__c                 C  s   | j tjkS )z2
        Check if the client being closed
        )rš   rI   rN   ©r]   rB   rB   rC   Ú	is_closedÅ   s   zBaseClient.is_closedc                 C  ó   | j S rW   )r˜   r›   rB   rB   rC   r�   Ì   ó   zBaseClient.trust_envÚurlr0   c                 C  s"   |j  d¡r|S |j|j d d�S )Nó   /©Úraw_path)r¢   ÚendswithÚ	copy_with©r]   rŸ   rB   rB   rC   rŽ   Ð   s   z"BaseClient._enforce_trailing_slashÚproxiesúProxiesTypes | NoneÚallow_env_proxiesúdict[str, Proxy | None]c                 C  s”   |d u r|rdd„ t ƒ  ¡ D ƒS i S t|tƒr8i }| ¡ D ]\}}t|ttfƒr-t|d�n|}||t|ƒ< q|S t|ttfƒrDt|d�n|}d|iS )Nc                 S  s(   i | ]\}}||d u rd nt |d�“qS )N©rŸ   )r   )rF   rG   rŸ   rB   rB   rC   Ú
<dictcomp>Ú   s    ÿÿz-BaseClient._get_proxy_map.<locals>.<dictcomp>rª   zall://)r4   ÚitemsÚ
isinstanceÚdictÚstrr0   r   )r]   r¦   r¨   Únew_proxiesrG   ÚvalueÚproxyrB   rB   rC   Ú_get_proxy_mapÕ   s   þ
zBaseClient._get_proxy_mapr   c                 C  r�   rW   )r”   r›   rB   rB   rC   r|   é   rž   zBaseClient.timeoutc                 C  ó   t |ƒ| _d S rW   )r   r”   )r]   r|   rB   rB   rC   r|   í   ó   údict[str, list[EventHook]]c                 C  r�   rW   )r—   r›   rB   rB   rC   r   ñ   rž   zBaseClient.event_hooksc                 C  s(   t | dg ¡ƒt | dg ¡ƒdœ| _d S rŒ   )r•   r–   r—   )r]   r   rB   rB   rC   r   õ   s   þúAuth | Nonec                 C  r�   )z¦
        Authentication class used when none is passed at the request-level.

        See also [Authentication][0].

        [0]: /quickstart/#authentication
        )r‘   r›   rB   rB   rC   rx   ü   s   	zBaseClient.authr"   c                 C  s   |   |¡| _d S rW   )r�   r‘   ©r]   rx   rB   rB   rC   rx     s   c                 C  r�   )zK
        Base URL to use when sending requests with relative URLs.
        )r�   r›   rB   rB   rC   r€     ó   zBaseClient.base_urlc                 C  s   |   t|ƒ¡| _d S rW   )rŽ   r0   r�   r¥   rB   rB   rC   r€     s   r   c                 C  r�   )z@
        HTTP headers to include when sending requests.
        )Ú_headersr›   rB   rB   rC   rz     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º   )r]   rz   Úclient_headersrB   rB   rC   rz     s   üÿ

r   c                 C  r�   )zA
        Cookie values to include when sending requests.
        )r“   r›   rB   rB   rC   r{   *  r¹   zBaseClient.cookiesr$   c                 C  r´   rW   )r   r“   )r]   r{   rB   rB   rC   r{   1  rµ   r1   c                 C  r�   )zO
        Query parameters to include in the URL when sending requests.
        )r’   r›   rB   rB   rC   ry   5  r¹   zBaseClient.paramsr(   c                 C  r´   rW   )r1   r’   )r]   ry   rB   rB   rC   ry   <  rµ   )	ÚcontentÚdataÚfilesÚjsonry   rz   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 )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
        Nr|   )rÁ   rÂ   rÃ   rÄ   ry   rz   r{   rÅ   rB   )Ú
_merge_urlÚ_merge_headersÚ_merge_cookiesÚ_merge_queryparamsr­   r=   r|   r   r®   Úas_dictr   )r]   rÆ   rŸ   rÁ   rÂ   rÃ   rÄ   ry   rz   r{   r|   rÅ   rB   rB   rC   Úbuild_request@  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¡   )r0   Úis_relative_urlr€   r¢   Úlstripr¤   )r]   rŸ   Ú	merge_urlÚmerge_raw_pathrB   rB   rC   rÍ   s  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¿   )r]   r{   Úmerged_cookiesrB   rB   rC   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   rz   r¿   )r]   rz   Úmerged_headersrB   rB   rC   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.
        )ry   r1   Úmerge)r]   ry   Úmerged_queryparamsrB   rB   rC   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¸   rB   rB   rC   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­   r=   r‘   r�   rŸ   rÜ   rÝ   r	   r   )r]   r�   rx   rÜ   rÝ   rB   rB   rC   Ú_build_request_authµ  s   ÿzBaseClient._build_request_authrR   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Ÿ   rz   r{   rQ   rÅ   )Ú_redirect_methodÚ_redirect_urlÚ_redirect_headersÚ_redirect_streamr   r{   r   rÅ   )r]   r�   rR   rÆ   rŸ   rz   rQ   r{   rB   rB   rC   Ú_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k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ÚPOST)rÆ   Ústatus_coder   Ú	SEE_OTHERÚFOUNDÚMOVED_PERMANENTLY)r]   r�   rR   rÆ   rB   rB   rC   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.
        ÚLocationz Invalid URL in location header: Ú.©r�   N)Úhost)Úfragment)rz   r0   r   r   Úschemeró   r¤   rŸ   rÓ   Újoinrô   )r]   r�   rR   ÚlocationrŸ   ÚexcrB   rB   rC   rå   ñ  s$   
ÿþ€ÿzBaseClient._redirect_urlc                 C  sx   t |jƒ}t||jƒst|j|ƒs| dd¡ |j d¡|d< ||jkr4|dkr4| 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   rz   r6   rŸ   r5   ÚpopÚnetlocÚdecoderÆ   )r]   r�   rŸ   rÆ   rz   rB   rB   rC   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Æ   rQ   )r]   r�   rÆ   rB   rB   rC   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|   rB   )rÅ   r­   r|   r=   r   r®   rÑ   )r]   r�   r|   rB   rB   rC   Ú_set_timeout4  s   

ÿý"úzBaseClient._set_timeout)rx   rƒ   ry   r„   rz   r…   r{   r†   r|   r.   r}   r‡   r~   rˆ   r   r‰   r€   rŠ   r�   r‡   r‚   r‹   rT   rU   )rT   r‡   )rŸ   r0   rT   r0   )r¦   r§   r¨   r‡   rT   r©   )rT   r   )r|   r.   rT   rU   )rT   r¶   )r   r¶   rT   rU   )rT   r·   )rx   r"   rT   rU   )rT   r0   )rŸ   rŠ   rT   rU   )rT   r   )rz   r%   rT   rU   )rT   r   )r{   r$   rT   rU   )rT   r1   )ry   r(   rT   rU   )rÆ   r¯   rŸ   rŠ   rÁ   rÇ   rÂ   rÈ   rÃ   rÉ   rÄ   rÊ   ry   r„   rz   r…   r{   r†   r|   rË   rÅ   rÌ   rT   r   )rŸ   rŠ   rT   r0   rW   )r{   r†   rT   r†   )rz   r…   rT   r…   )ry   r„   rT   r„   )rx   rƒ   rT   r·   )r�   r   rx   râ   rT   r   )r�   r   rR   r   rT   r   )r�   r   rR   r   rT   r¯   )r�   r   rR   r   rT   r0   )r�   r   rŸ   r0   rÆ   r¯   rT   r   )r�   r   rÆ   r¯   rT   rÿ   )r�   r   rT   rU   )!r>   r?   r@   r   r   r^   Úpropertyrœ   r�   rŽ   r³   r|   Úsetterr   rx   r€   rz   r{   ry   r7   rÒ   rÍ   rÏ   rÎ   rÐ   r�   rã   rè   rä   rå   ræ   rç   r   rB   rB   rB   rC   rt   ¢   sŽ    ó"


ó
3
ÿ
ý




rt   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dœd€‡ fd1d2„Zddddedddfd�d4d5„Zddddedfd‚d7d8„Z	dƒd;d<„Z
dddddddeeedd=œd„dNdO„Zedddddddeeedd=œd…dQdR„ƒZdeedSœd†dWdX„Zd‡d\d]„Zdˆd^d_„Zd‰d`da„ZdddeeeddbœdŠdcdd„Zdddeeeddbœd‹dfdg„Zdddeeeddbœd‹dhdi„Zdddddddeeedd=œdŒdjdk„Zdddddddeeedd=œdŒdldm„Zdddddddeeedd=œdŒdndo„Zdddeeeddbœd‹dpdq„Zd�drds„ZdŽdvdw„Z			d�d�d~d„Z‡  ZS )‘r9   aŒ	  
    An HTTP client, with connection pooling, HTTP/2, redirects, cookie persistence, etc.

    It can be shared between threads.

    Usage:

    ```python
    >>> client = httpx.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)* SSL certificates (a.k.a CA bundle) used to
    verify the identity of requested hosts. Either `True` (default CA bundle),
    a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
    (which will disable verification).
    * **cert** - *(optional)* An SSL certificate used by the requested host
    to authenticate the client. Either a path to an SSL certificate file, or
    two-tuple of (certificate file, key file), or a three-tuple of (certificate
    file, key file, password).
    * **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.
    * **proxies** - *(optional)* A dictionary mapping proxy keys to proxy
    URLs.
    * **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.
    * **app** - *(optional)* An WSGI application to send requests to,
    rather than sending actual network requests.
    * **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".
    NTFru   rv   ©rx   ry   rz   r{   ÚverifyÚcertÚhttp1Úhttp2r²   r¦   Úmountsr|   r}   Úlimitsr~   r   r€   Ú	transportÚappr�   r‚   rx   rƒ   ry   r„   rz   r…   r{   r†   r  r/   r  úCertTypes | Noner  r‡   r  r²   úProxyTypes | Noner¦   r§   r	  ú0None | typing.Mapping[str, BaseTransport | None]r|   r.   r}   r
  r   r~   rˆ   r   r‰   r€   rŠ   r  úBaseTransport | Noner  ú'typing.Callable[..., typing.Any] | Noner�   r‚   r‹   rT   rU   c                  ó  t ƒ j|||||||||ˆ|d� ˆr&zdd l}W n ty%   tdƒd ‚w |
r6d}t |t¡ |	r6tdƒ‚|r@d}t |t¡ ˆoI|d u oI|d u }ˆ |
pO|	|¡}ˆj	ˆˆ ˆˆˆ||ˆd�ˆ_
‡ ‡‡‡‡‡‡fdd	„| ¡ D ƒˆ_|d urƒˆj d
d	„ | ¡ D ƒ¡ ttˆj ¡ ƒƒˆ_d S )Nrw   r   úuUsing http2=True, but the 'h2' package is not installed. Make sure to install httpx using `pip install httpx[http2]`.úJThe 'proxies' argument is now deprecated. Use 'proxy' or 'mounts' instead.ú*Use either `proxy` or 'proxies', not both.zhThe 'app' shortcut is now deprecated. Use the explicit style 'transport=WSGITransport(app=...)' instead.©r  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�   ©r3   Ú_init_proxy_transport©rF   rG   r²   ©r  r  r  r
  r]   r�   r  rB   rC   r«   Á  ó    õÿùýz#Client.__init__.<locals>.<dictcomp>c                 S  ó   i | ]	\}}t |ƒ|“qS rB   ©r3   ©rF   rG   r  rB   rB   rC   r«   Ñ  ó    ©Úsuperr^   Úh2ÚImportErrorÚwarningsÚwarnÚDeprecationWarningÚRuntimeErrorr³   Ú_init_transportÚ
_transportr¬   Ú_mountsr¿   r®   Úsorted©r]   rx   ry   rz   r{   r  r  r  r  r²   r¦   r	  r|   r}   r
  r~   r   r€   r  r  r�   r‚   r%  Úmessager¨   Ú	proxy_map©Ú	__class__r  rC   r^   t  sj   õÿýÿÿÿø
ôÿzClient.__init__r   c	           	      C  ó2   |d ur|S |d urt |d�S t||||||d�S ©N)r  r  )r    r   ©	r]   r  r  r  r  r
  r  r  r�   rB   rB   rC   r+  Ö  ó   
úzClient._init_transportr   c              	   C  ó   t |||||||d�S ©N)r  r  r  r  r
  r�   r²   )r   ©r]   r²   r  r  r  r  r
  r�   rB   rB   rC   r  ð  ó   
ùzClient._init_proxy_transportrŸ   r0   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,  ©r]   rŸ   Úpatternr  rB   rB   rC   Ú_transport_for_url  ó
   
ÿzClient._transport_for_url©rÁ   rÂ   rÃ   rÄ   ry   rz   r{   rx   r}   r|   rÅ   rÆ   r¯   rÁ   rÇ   rÂ   rÈ   rÃ   rÉ   rÄ   rÊ   râ   úbool | UseClientDefaultrË   rÅ   rÌ   r   c                C  sH   |	durd}t  |t¡ | 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/#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.©rÆ   rŸ   rÁ   rÂ   rÃ   rÄ   ry   rz   r{   r|   rÅ   ©rx   r}   ©r'  r(  r)  rÒ   Úsend©r]   rÆ   rŸ   rÁ   rÂ   rÃ   rÄ   ry   rz   r{   rx   r}   r|   rÅ   r0  r�   rB   rB   rC   r�     s$   !ÿõzClient.requestútyping.Iterator[Response]c                c  sT   � | j |||||||||	||d�}| j||
|dd�}z
|V  W | ¡  dS | ¡  w ©a  
        Alternative to `httpx.request()` that streams the response body
        instead of loading it into memory at once.

        **Parameters**: See `httpx.request`.

        See also: [Streaming Responses][0]

        [0]: /quickstart#streaming-responses
        rG  T)r�   rx   r}   rQ   N)rÒ   rJ  rk   ©r]   rÆ   rŸ   rÁ   rÂ   rÃ   rÄ   ry   rz   r{   rx   r}   r|   rÅ   r�   rR   rB   rB   rC   rQ   G  s.   €õüzClient.stream©rQ   rx   r}   r�   r   rQ   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 `httpx.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.©rx   r}   ÚhistoryN)rš   rI   rN   r*  rM   r­   r=   r}   r   rã   Ú_send_handling_authÚreadÚBaseExceptionrk   ©r]   r�   rQ   rx   r}   rR   rø   rB   rB   rC   rJ  {  s0   ÿý
ü€þzClient.sendr   rR  ú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}   rR  )Úsync_auth_flowÚnextÚ_send_handling_redirectsrJ  ÚStopIterationrk   r•   rR  rT  ÚappendrU  ©	r]   r�   rx   r}   rR  Ú	auth_flowrR   Únext_requestrø   rB   rB   rC   rS  ®  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�   rR   )Úlenr~   r   r—   Ú_send_single_requestr•   rR  Úhas_redirect_locationrè   rT  r`  rU  rk   ©r]   r�   r}   rR  ÚhookrR   rø   rB   rB   rC   r[  Ð  s6   ÿ





ý€þå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ƒs9J ‚||_
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©rR   rS   úHTTP Request: %s %s "%s %d %s")rB  rŸ   r2   Ú
sync_startr­   rQ   r-   r*  r   Úhandle_requestr�   rP   r{   Úextract_cookiesr™   r‚   ÚloggerÚinforÆ   Úhttp_versionrì   Úreason_phrase©r]   r�   r  rS   rR   rB   rB   rC   rc  õ  s4   ÿÿÿú	zClient._send_single_request©ry   rz   r{   rx   r}   r|   rÅ   c          	      C  ó   | j d||||||||d�	S )úU
        Send a `GET` request.

        **Parameters**: See `httpx.request`.
        rê   rr  rò   ©	r]   rŸ   ry   rz   r{   rx   r}   r|   rÅ   rB   rB   rC   r–     ó   ÷z
Client.getúAuthTypes | UseClientDefaultc          	      C  rs  )úZ
        Send an `OPTIONS` request.

        **Parameters**: See `httpx.request`.
        ÚOPTIONSrr  rò   ru  rB   rB   rC   Úoptions6  rv  zClient.optionsc          	      C  rs  )úV
        Send a `HEAD` request.

        **Parameters**: See `httpx.request`.
        ré   rr  rò   ru  rB   rB   rC   ÚheadS  rv  zClient.headc                C  ó$   | j d|||||||||	|
||d�S )úV
        Send a `POST` request.

        **Parameters**: See `httpx.request`.
        rë   rD  rò   ©r]   rŸ   rÁ   rÂ   rÃ   rÄ   ry   rz   r{   rx   r}   r|   rÅ   rB   rB   rC   Úpostp  ó   ózClient.postc                C  r}  )úU
        Send a `PUT` request.

        **Parameters**: See `httpx.request`.
        ÚPUTrD  rò   r  rB   rB   rC   Úput•  r�  z
Client.putc                C  r}  )úW
        Send a `PATCH` request.

        **Parameters**: See `httpx.request`.
        ÚPATCHrD  rò   r  rB   rB   rC   Úpatchº  r�  zClient.patchc          	      C  rs  )úX
        Send a `DELETE` request.

        **Parameters**: See `httpx.request`.
        ÚDELETErr  rò   ru  rB   rB   rC   Údeleteß  rv  zClient.deletec                 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š   rI   rN   r,  rk   r-  Úvalues)r]   r  rB   rB   rC   rk   ü  s   
€úzClient.closer]   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š   rI   rL   rM   rN   r*  r,  Ú	__enter__r-  rŒ  )r]   Úmsgr  rB   rB   rC   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 rW   )rI   rN   rš   r,  Ú__exit__r-  rŒ  )r]   r�  r’  r”  r  rB   rB   rC   r–    s   €þzClient.__exit__),rx   rƒ   ry   r„   rz   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  r�   r‡   r‚   r‹   rT   rU   )r  r/   r  r  r  r‡   r  r‡   r
  r   r  r  r  r  r�   r‡   rT   r   )r²   r   r  r/   r  r  r  r‡   r  r‡   r
  r   r�   r‡   rT   r   )rŸ   r0   rT   r   ©rÆ   r¯   rŸ   rŠ   rÁ   rÇ   rÂ   rÈ   rÃ   rÉ   rÄ   rÊ   ry   r„   rz   r…   r{   r†   rx   râ   r}   rE  r|   rË   rÅ   rÌ   rT   r   )rÆ   r¯   rŸ   rŠ   rÁ   rÇ   rÂ   rÈ   rÃ   rÉ   rÄ   rÊ   ry   r„   rz   r…   r{   r†   rx   râ   r}   rE  r|   rË   rÅ   rÌ   rT   rL  ©
r�   r   rQ   r‡   rx   râ   r}   rE  rT   r   ©
r�   r   rx   r   r}   r‡   rR  rW  rT   r   ©r�   r   r}   r‡   rR  rW  rT   r   ©r�   r   rT   r   ©rŸ   rŠ   ry   r„   rz   r…   r{   r†   rx   râ   r}   rE  r|   rË   rÅ   rÌ   rT   r   ©rŸ   rŠ   ry   r„   rz   r…   r{   r†   rx   rw  r}   rE  r|   rË   rÅ   rÌ   rT   r   ©rŸ   rŠ   rÁ   rÇ   rÂ   rÈ   rÃ   rÉ   rÄ   rÊ   ry   r„   rz   r…   r{   r†   rx   rw  r}   rE  r|   rË   rÅ   rÌ   rT   r   rm   )r]   r:   rT   r:   ©NNN©r�  r‘  r’  r“  r”  r•  rT   rU   )r>   r?   r@   rA   r   r   r   r^   r+  r  rB  r7   r�   r   rQ   rJ  rS  r[  rc  r–   rz  r|  r€  r„  r‡  rŠ  rk   rŽ  r–  Ú__classcell__rB   rB   r2  rC   r9   >  s&   8éd÷ø
ñ8ñ7ú
3
"
%(ö!ö!ö!ò)ò)ò)ö

üc                      r  )‘r8   a»	  
    An asynchronous HTTP client, with connection pooling, HTTP/2, redirects,
    cookie persistence, etc.

    It can be shared between tasks.

    Usage:

    ```python
    >>> async with httpx.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)* SSL certificates (a.k.a CA bundle) used to
    verify the identity of requested hosts. Either `True` (default CA bundle),
    a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
    (which will disable verification).
    * **cert** - *(optional)* An SSL certificate used by the requested host
    to authenticate the client. Either a path to an SSL certificate file, or
    two-tuple of (certificate file, key file), or a three-tuple of (certificate
    file, key file, password).
    * **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.
    * **proxies** - *(optional)* A dictionary mapping HTTP protocols to proxy
    URLs.
    * **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.
    * **app** - *(optional)* An ASGI application to send requests to,
    rather than sending actual network requests.
    * **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".
    NTFru   rv   r  rx   rƒ   ry   r„   rz   r…   r{   r†   r  r/   r  r  r  r‡   r  r²   r  r¦   r§   r	  ú5None | typing.Mapping[str, AsyncBaseTransport | None]r|   r.   r}   r
  r   r~   rˆ   r   r‰   r€   rŠ   r  úAsyncBaseTransport | Noner  r  r�   r‚   r‹   rT   rU   c                  r  )Nrw   r   r  r  r  zhThe 'app' shortcut is now deprecated. Use the explicit style 'transport=ASGITransport(app=...)' instead.r  c                   r  r  r  r  r  rB   rC   r«   ­  r  z(AsyncClient.__init__.<locals>.<dictcomp>c                 S  r  rB   r   r!  rB   rB   rC   r«   ½  r"  r#  r/  r2  r  rC   r^   _  sj   õÿýÿÿÿøôÿzAsyncClient.__init__r   c	           	      C  r4  r5  )r   r   r6  rB   rB   rC   r+  Á  r7  zAsyncClient._init_transportr   c              	   C  r8  r9  )r   r:  rB   rB   rC   r  Û  r;  z!AsyncClient._init_proxy_transportrŸ   r0   c                 C  r<  r=  r>  r@  rB   rB   rC   rB  ï  rC  zAsyncClient._transport_for_urlrD  rÆ   r¯   rÁ   rÇ   rÂ   rÈ   rÃ   rÉ   rÄ   rÊ   râ   rE  rË   rÅ   rÌ   r   c                Ã  sP   �|	durd}t  |t¡ | 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/#merging-of-configuration
        NrF  rG  rH  rI  rK  rB   rB   rC   r�   ú  s&   €"ÿõzAsyncClient.requestútyping.AsyncIterator[Response]c                C sf   �| j |||||||||	||d�}| j||
|dd�I dH }z|V  W | ¡ I dH  dS | ¡ I dH  w rM  )rÒ   rJ  rs   rN  rB   rB   rC   rQ   3  s.   €õü"zAsyncClient.streamrO  r�   r   rQ   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 `httpx.Request()` is supported as well.

        See also: [Request instances][0]

        [0]: /advanced/clients/#request-instances
        rP  rQ  N)rš   rI   rN   r*  rM   r­   r=   r}   r   rã   rS  ÚareadrU  rs   rV  rB   rB   rC   rJ  g  s2   €ÿý
ü€þzAsyncClient.sendr   rR  rW  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 rX  )Úasync_auth_flowÚ	__anext__r[  ÚasendÚStopAsyncIterationrs   r•   rR  r¥  r]  rU  r^  rB   rB   rC   rS  š  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ra  )rb  r~   r   r—   rc  r•   rR  rd  rè   r¥  r`  rU  rs   re  rB   rB   rC   r[  ¼  s8   €ÿ

ý€þäz$AsyncClient._send_handling_redirectsc                 Ã  sÎ   �|   |j¡}tƒ }| ¡ I dH  t|jtƒstdƒ‚t|d�� | 	|¡I dH }W d  ƒ n1 s3w   Y  t|jtƒs@J ‚||_
t|j||d�|_| j |¡ | j|_t d|j|j|j|j|j¡ |S )rg  Nz?Attempted to send an sync request with an AsyncClient instance.rò   rh  ri  )rB  rŸ   r2   Úasync_startr­   rQ   r!   r*  r   Úhandle_async_requestr�   ro   r{   rl  r™   r‚   rm  rn  rÆ   ro  rì   rp  rq  rB   rB   rC   rc  â  s6   €ÿÿÿú	z AsyncClient._send_single_requestrr  c          	      Ã  ó$   �| j d||||||||d�	I dH S )rt  rê   rr  Nrò   ru  rB   rB   rC   r–     ó   €÷zAsyncClient.getrw  c          	      Ã  r¬  )rx  ry  rr  Nrò   ru  rB   rB   rC   rz  "  r­  zAsyncClient.optionsc          	      Ã  r¬  )r{  ré   rr  Nrò   ru  rB   rB   rC   r|  ?  r­  zAsyncClient.headc                Ã  ó,   �| j d|||||||||	|
||d�I dH S )r~  rë   rD  Nrò   r  rB   rB   rC   r€  \  ó    €ózAsyncClient.postc                Ã  r®  )r‚  rƒ  rD  Nrò   r  rB   rB   rC   r„  �  r¯  zAsyncClient.putc                Ã  r®  )r…  r†  rD  Nrò   r  rB   rB   rC   r‡  ¦  r¯  zAsyncClient.patchc          	      Ã  r¬  )rˆ  r‰  rr  Nrò   ru  rB   rB   rC   rŠ  Ë  r­  zAsyncClient.deletec                 Ã  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š   rI   rN   r,  rs   r-  rŒ  )r]   r²   rB   rB   rC   rs   è  s   €€úzAsyncClient.acloser]   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š   rI   rL   rM   rN   r*  r,  Ú
__aenter__r-  rŒ  )r]   r�  r²   rB   rB   rC   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 rW   )rI   rN   rš   r,  Ú	__aexit__r-  rŒ  )r]   r�  r’  r”  r²   rB   rB   rC   r±    s   €€þzAsyncClient.__aexit__),rx   rƒ   ry   r„   rz   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  r�   r‡   r‚   r‹   rT   rU   )r  r/   r  r  r  r‡   r  r‡   r
  r   r  r£  r  r  r�   r‡   rT   r   )r²   r   r  r/   r  r  r  r‡   r  r‡   r
  r   r�   r‡   rT   r   )rŸ   r0   rT   r   r—  )rÆ   r¯   rŸ   rŠ   rÁ   rÇ   rÂ   rÈ   rÃ   rÉ   rÄ   rÊ   ry   r„   rz   r…   r{   r†   rx   râ   r}   rE  r|   rË   rÅ   rÌ   rT   r¤  r˜  r™  rš  r›  rœ  r�  rž  rm   )r]   r<   rT   r<   rŸ  r   )r>   r?   r@   rA   r   r   r   r^   r+  r  rB  r7   r�   r   rQ   rJ  rS  r[  rc  r–   rz  r|  r€  r„  r‡  rŠ  rs   r°  r±  r¡  rB   rB   r2  rC   r8   (  s&   9éd÷ø
ñ9ñ7ú
3
"
&'ö!ö!ö!ò)ò)ò)ö

ü)_Ú
__future__r   rh   ÚenumÚloggingÚtypingr'  Ú
contextlibr   r   Útypesr   r   r‘   r   r	   r
   Ú_configr   r   r   r   r   r   Ú	_decodersr   Ú_exceptionsr   r   r   r   Ú_modelsr   r   r   r   Ú_status_codesr   Ú_transports.asgir   Ú_transports.baser   r   Ú_transports.defaultr   r   Ú_transports.wsgir    Ú_typesr!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   Ú_urlsr0   r1   Ú_utilsr2   r3   r4   r5   r6   Ú__all__ÚTypeVarr:   r<   r=   r7   Ú	getLoggerrm  r¾   rö   Úkeysr¼   ÚEnumrI   rP   ro   ÚCallableÚAnyÚ	EventHookrt   r9   r8   rB   rB   rB   rC   Ú<module>   s^     D

ÿ        o