HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/httpx/__pycache__/_client.cpython-310.pyc
o

���g��@s`ddlmZddlZddlZddlZddlZddlZddlZddlm	Z	m
Z
ddlmZddl
m
Z
ddlmZmZmZddlmZmZmZmZmZmZdd	lmZdd
lmZmZmZmZddl m!Z!m"Z"m#Z#m$Z$ddl%m&Z&dd
l'm(Z(m)Z)ddl*m+Z+m,Z,ddl-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:ddl;m<Z<m=Z=ddl>m?Z?m@Z@ejAr�ddlBZBgd�ZCejDddd�ZEejDddd�ZFd7dd�ZGd8d d!�ZHd9d#d$�ZIGd%d&�d&�ZJeJ�ZKe�Ld'�ZMd(e
��ZNd)�Od*d+�e�P�D��ZQGd,d-�d-ejR�ZSGd.d/�d/e9�ZTGd0d1�d1e.�ZUejVd2ejWfZXGd3d4�d4�ZYGd5d�deY�ZZGd6d�deY�Z[dS):�)�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)�AsyncBaseTransport�
BaseTransport)�AsyncHTTPTransport�
HTTPTransport)
�AsyncByteStream�	AuthTypes�	CertTypes�CookieTypes�HeaderTypes�
ProxyTypes�QueryParamTypes�RequestContent�RequestData�RequestExtensions�RequestFiles�SyncByteStream�TimeoutTypes)�URL�QueryParams)�
URLPattern�get_environment_proxies)�USE_CLIENT_DEFAULT�AsyncClient�Client�Tr2)�bound�Ur1�urlr,�location�return�boolcCs<|j|jkrdS|jdkot|�dko|jdkot|�dkS)zA
    Return 'True' if 'location' is a HTTPS upgrade of 'url'
    F�http�P�https�)�host�scheme�_port_or_default)r6r7�rA�8/usr/local/lib/python3.10/dist-packages/httpx/_client.py�_is_https_redirect>s

��
�rC�
int | NonecCs"|jdur|jSddd��|j�S)Nr;r=)r:r<)�port�getr?�r6rArArBr@Ms
r@�othercCs(|j|jko|j|jkot|�t|�kS)z@
    Return 'True' if the given URLs share the same origin.
    )r?r>r@)r6rHrArArB�_same_originSs

��rIc@seZdZdZdS)�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__rArArArBrJ^srJ�httpxz
python-httpx/z, cCsg|]}|dkr|�qS)�identityrA)�.0�keyrArArB�
<listcomp>ysrSc@seZdZdZdZdZdS)�ClientStater��N)rKrLrM�UNOPENED�OPENED�CLOSEDrArArArBrT}srTc@�.eZdZdZdd
d�Zdd
d�Zddd�ZdS)�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�start�floatr8�NonecC�||_||_||_dS�N��_stream�	_response�_start��selfr\r]r^rArArB�__init__��
zBoundSyncStream.__init__�typing.Iterator[bytes]ccs�|jD]}|VqdSrb�rd�rh�chunkrArArB�__iter__�s�
�zBoundSyncStream.__iter__cCs,t��|j}tj|d�|j_|j��dS�N)�seconds)	�time�perf_counterrf�datetime�	timedeltare�elapsedrd�close�rhrvrArArBrw�szBoundSyncStream.closeN)r\r*r]rr^r_r8r`)r8rk�r8r`)rKrLrMrNrirorwrArArArBr[��


r[c@rZ)�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.
    r\rr]rr^r_r8r`cCrarbrcrgrArArBri�rjzBoundAsyncStream.__init__�typing.AsyncIterator[bytes]cCs"�|j2z	3dHW}|Vq6dSrbrlrmrArArB�	__aiter__�s��zBoundAsyncStream.__aiter__c�s4�t��|j}tj|d�|j_|j��IdHdSrp)	rrrsrfrtrurervrd�acloserxrArArBr~�s�zBoundAsyncStream.acloseN)r\rr]rr^r_r8r`)r8r|ry)rKrLrMrNrir}r~rArArArBr{�rzr{.c@s�eZdZddddededdddd�d|dd�Zed}d d!��Zed}d"d#��Zd~d&d'�Z	dd,d-�Z
ed�d/d0��Zejd�d1d0��Zed�d3d4��Z
e
jd�d5d4��Z
ed�d7d8��Zejd�d:d8��Zed�d;d<��Zejd�d=d<��Zed�d?d@��Zejd�dBd@��Zed�dDdE��Zejd�dGdE��Zed�dIdJ��Zejd�dLdJ��ZdddddddeddM�	d�d\d]�Zd�d^d_�Zd�d�d`da�Zd�d�dbdc�Z	d�d�ddde�Zd�dfdg�Zefd�dkdl�Zd�dodp�Zd�dqdr�Zd�dsdt�Zd�dudv�Zd�dxdy�Zd�dzd{�Z dS)��
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�r+r�r9r��intr��+None | typing.Mapping[str, list[EventHook]]r��	URL | strr�r��#str | typing.Callable[[bytes], str]r8r`cCs�|durin|}|�t|	��|_|�|�|_t|�|_t|�|_t	|�|_
t|�|_||_
||_t|�dg��t|�dg��d�|_|
|_||_tj|_dS�N�requestr])r�r])�_enforce_trailing_slashr,�	_base_url�_build_auth�_authr-�_paramsrr�r�_cookiesr�_timeoutr�r��listrF�_event_hooks�
_trust_env�_default_encodingrTrW�_state)rhr�r�r�r�r�r�r�r�r�r�r�rArArBri�s



�zBaseClient.__init__cCs|jtjkS)z2
        Check if the client being closed
        )r�rTrY�rhrArArB�	is_closed�szBaseClient.is_closedcC�|jSrb)r�r�rArArBr���zBaseClient.trust_envr6r,cCs"|j�d�r|S|j|jdd�S)N�/��raw_path)r��endswith�	copy_with�rhr6rArArBr��sz"BaseClient._enforce_trailing_slash�proxy�ProxyTypes | None�allow_env_proxies�dict[str, Proxy | None]cCsH|dur|rdd�t���D�SiSt|ttf�rt|d�n|}d|iS)NcSs(i|]\}}||dur
dnt|d��qS)NrG)r)rQrRr6rArArB�
<dictcomp>�s��z-BaseClient._get_proxy_map.<locals>.<dictcomp>rGzall://)r/�items�
isinstance�strr,r)rhr�r�rArArB�_get_proxy_map�s�zBaseClient._get_proxy_maprcCr�rb)r�r�rArArBr��r�zBaseClient.timeoutcC�t|�|_dSrb)rr�)rhr�rArArBr���dict[str, list[EventHook]]cCr�rb)r�r�rArArBr�r�zBaseClient.event_hookscCs(t|�dg��t|�dg��d�|_dSr�)r�rFr�)rhr�rArArBr�	s��Auth | NonecCr�)z�
        Authentication class used when none is passed at the request-level.

        See also [Authentication][0].

        [0]: /quickstart/#authentication
        )r�r�rArArBr�s	zBaseClient.authr cCs|�|�|_dSrb)r�r��rhr�rArArBr�scCr�)zK
        Base URL to use when sending requests with relative URLs.
        )r�r�rArArBr��zBaseClient.base_urlcCs|�t|��|_dSrb)r�r,r�r�rArArBr�&srcCr�)z@
        HTTP headers to include when sending requests.
        )�_headersr�rArArBr�*r�zBaseClient.headersr#cCs2tdt�d�dt�d�d��}|�|�||_dS)Ns*/*�asciis
keep-alive)sAcceptsAccept-Encodings
Connections
User-Agent)r�ACCEPT_ENCODING�encode�
USER_AGENT�updater�)rhr��client_headersrArArBr�1s��

rcCr�)zA
        Cookie values to include when sending requests.
        )r�r�rArArBr�>r�zBaseClient.cookiesr"cCr�rb)rr�)rhr�rArArBr�Er�r-cCr�)zO
        Query parameters to include in the URL when sending requests.
        )r�r�rArArBr�Ir�zBaseClient.paramsr%cCr�rb)r-r�)rhr�rArArBr�Pr�)	�content�data�files�jsonr�r�r�r��
extensions�methodr�r��RequestContent | Noner��RequestData | Noner��RequestFiles | Noner��typing.Any | None�TimeoutTypes | UseClientDefaultr��RequestExtensions | Nonerc	Cs�|�|�}|�|�}|�|	�}	|�|�}|durin|}d|vr9t|
t�r(|jnt|
�}
tdi|�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�r�r�r�r�rA)�
_merge_url�_merge_headers�_merge_cookies�_merge_queryparamsr�rJr�r�dict�as_dictr)rhr�r6r�r�r�r�r�r�r�r�r�rArArB�
build_requestTs.



���zBaseClient.build_requestcCs4t|�}|jr|jj|j�d�}|jj|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�)r,�is_relative_urlr�r��lstripr�)rhr6�	merge_url�merge_raw_pathrArArBr��s
zBaseClient._merge_urlcCs&|s|jrt|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�rr�)rhr��merged_cookiesrArArBr��s



zBaseClient._merge_cookiescCst|j�}|�|�|S)z�
        Merge a headers argument together with any headers on the client,
        to create the headers used for the outgoing request.
        )rr�r�)rhr��merged_headersrArArBr��s

zBaseClient._merge_headerscCs"|s|jrt|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�r-�merge)rhr��merged_queryparamsrArArBr��s


zBaseClient._merge_queryparamscCsX|durdSt|t�rt|d|dd�St|t�r|St|�r%t|d�Std|����)Nrr��username�password)�funczInvalid "auth" argument: )r��tupler	r�callabler
�	TypeErrorr�rArArBr��s


zBaseClient._build_authr��#AuthTypes | UseClientDefault | NonercCsRt|t�r|jn|�|�}|dur|S|jj|jj}}|s |r&t||d�St�S)Nr�)	r�rJr�r�r6r�r�r	r)rhr�r�r�r�rArArB�_build_request_auth�s�zBaseClient._build_request_authr]rcCsR|�||�}|�||�}|�|||�}|�||�}t|j�}t||||||jd�S)z�
        Given a request and a redirect response, return a new request that
        should be used to effect the redirect.
        )r�r6r�r�r\r�)�_redirect_method�
_redirect_url�_redirect_headers�_redirect_streamrr�rr�)rhr�r]r�r6r�r\r�rArArB�_build_redirect_request�s
�z"BaseClient._build_redirect_requestcCsR|j}|jtjkr|dkrd}|jtjkr|dkrd}|jtjkr'|dkr'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)rhr�r]r�rArArBr��szBaseClient._redirect_methodc
Cs�|jd}zt|�}Wnty"}ztd|�d�|d�d�d}~ww|jr1|js1|j|jjd�}|jr:|j�	|�}|jj
rI|j
sI|j|jj
d�}|S)z<
        Return the URL for the redirect to follow.
        �Locationz Invalid URL in location header: �.�r�N)r>)�fragment)r�r,rrr?r>r�r6r��joinr�)rhr�r]r7r6�excrArArBr�s$
����zBaseClient._redirect_urlcCsxt|j�}t||j�st|j|�s|�dd�|j�d�|d<||jkr4|dkr4|�dd�|�dd�|�dd�|S)	zR
        Return the headers that should be used for the redirect request.
        �
AuthorizationNr��Hostr�zContent-LengthzTransfer-Encoding�Cookie)	rr�rIr6rC�pop�netloc�decoder�)rhr�r6r�r�rArArBr�"s
zBaseClient._redirect_headers�'SyncByteStream | AsyncByteStream | NonecCs||jkr|dkrdS|jS)zO
        Return the body that should be used for the redirect request.
        r�N)r�r\)rhr�r�rArArBr�=szBaseClient._redirect_streamcCsLd|jvr$t|jt�r|jnt|j�}tdi|j�d|��i��|_dSdS)Nr�rA)r�r�r�rJrr�r�)rhr�r�rArArB�_set_timeoutHs

��"�zBaseClient._set_timeout)r�r�r�r�r�r�r�r�r�r+r�r9r�r�r�r�r�r�r�r9r�r�r8r`)r8r9)r6r,r8r,)r�r�r�r9r8r�)r8r)r�r+r8r`)r8r�)r�r�r8r`)r8r�)r�r r8r`)r8r,)r6r�r8r`)r8r)r�r#r8r`)r8r)r�r"r8r`)r8r-)r�r%r8r`)r�r�r6r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r8r)r6r�r8r,rb)r�r�r8r�)r�r�r8r�)r�r�r8r�)r�r�r8r�)r�rr�r�r8r)r�rr]rr8r)r�rr]rr8r�)r�rr]rr8r,)r�rr6r,r�r�r8r)r�rr�r�r8r)r�rr8r`)!rKrLrMr
rri�propertyr�r�r�r�r��setterr�r�r�r�r�r�r0r�r�r�r�r�r�r�r�r�r�r�r�rrArArArBr�s��"


�
3
�
�




rcseZdZdZdddddddddddedeeddddd�d|�fd-d.�Zdddddedfd}d0d1�Zdddddefd~d3d4�Z	dd7d8�Z
dddddddeeedd9�d�dJdK�Ze
dddddddeeedd9�d�dMdN��ZdeedO�d�dSdT�Zd�dXdY�Zd�dZd[�Zd�d\d]�Zdddeeedd^�d�d_d`�Zdddeeedd^�d�dbdc�Zdddeeedd^�d�ddde�Zdddddddeeedd9�d�dfdg�Zdddddddeeedd9�d�dhdi�Zdddddddeeedd9�d�djdk�Zdddeeedd^�d�dldm�Zd�dndo�Zd�drds�Z			d�d�dzd{�Z�ZS)�r2av
    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)* 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.
    * **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�r9rrr�r�r�0None | typing.Mapping[str, BaseTransport | None]r�r+r�r	rr�r�r�r�r�r�r
�BaseTransport | Noner�r�r8r`c
s�t�j||||||
|||�|d��r&zddl}Wnty%td�d�w�o+|du}��|
|�}�j������|d��_�������fdd�|��D��_|durb�j�	dd�|��D��t
t�j�����_dS)Nr�r�uUsing http2=True, but the 'h2' package is not installed. Make sure to install httpx using `pip install httpx[http2]`.�rrr�rrr	r
c�:i|]\}}t|�|durdn�j|������d��qS�N)rrr�rrr	�r.�_init_proxy_transport�rQrRr��rrrr	rhr�rrArBr�������z#Client.__init__.<locals>.<dictcomp>cS�i|]	\}}t|�|�qSrA�r.�rQrRr
rArArBr�����superri�h2�ImportErrorr��_init_transport�
_transportr��_mountsr�r��sorted)rhr�r�r�r�rrr�rrr�rr�r�r	r�r�r�r
r�rr��	proxy_map��	__class__rrBrisT�����	��zClient.__init__rcC� |dur|St||||||d�Sr�r�rhrrr�rrr	r
rArArBr ��
�zClient._init_transportrc	C�t|||||||d�S�N)rrr�rrr	r�r(�rhr�rrr�rrr	rArArBr��
�zClient._init_proxy_transportr6r,cC�>|j��D]\}}|�|�r|dur|jS|Sq|jS�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!�rhr6�patternr
rArArB�_transport_for_url��

�zClient._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�rc
CsL|	durd}tj|tdd�|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.rU��
stacklevel�r�r6r�r�r�r�r�r�r�r�r��r�r���warnings�warn�DeprecationWarningr��send�rhr�r6r�r�r�r�r�r�r�r�r�r�r��messager�rArArBr�s$!��
zClient.request�typing.Iterator[Response]c
csT�|j|||||||||	||
d�}|j||
|dd�}z
|VW|��dS|��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
        r<T)r�r�r�r\N)r�rBrw�rhr�r6r�r�r�r�r�r�r�r�r�r�r�r�r]rArArBr\;s.��
�z
Client.stream�r\r�r�r�rr\c
Cs�|jtjkr
td��tj|_t|t�r|jn|}|�|�|�	||�}|j
|||gd�}z	|s3|��|WStyG}z|�
�|�d}~ww)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.�r�r��historyN)r�rTrY�RuntimeErrorrXr�rJr�rr��_send_handling_auth�read�
BaseExceptionrw�rhr�r\r�r�r]r�rArArBrBos0��
���zClient.sendrrK�list[Response]c	
Cs�|�|�}zLt|�}	|j|||d�}z+z|�|�}Wnty,|YWW|��Swt|�|_|��|}|�	|�Wnt
yP}z|��|�d}~wwq|��w�NT)r�rK)�sync_auth_flow�next�_send_handling_redirectsrB�
StopIterationrwr�rKrN�appendrO�	rhr�r�r�rK�	auth_flowr]�next_requestr�rArArBrM�s6
�

�
���
zClient._send_handling_authc
Cs�	t|�|jkrtd|d��|jdD]}||�q|�|�}z1|jdD]}||�q%t|�|_|js7|WS|�||�}||g}|rI|�	�n||_
|WSWntyb}z|��|�d}~wwq�NTz#Exceeded maximum allowed redirects.r�r�r])
�lenr�rr��_send_single_requestr�rK�has_redirect_locationr�rNrZrOrw�rhr�r�rK�hookr]r�rArArBrU�s6�





����zClient._send_handling_redirectscCs�|�|j�}t��}t|jt�std��t|d��
|�	|�}Wd�n1s)wYt|jt�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]r^�HTTP Request: %s %s "%s %d %s")r5r6rrrsr�r\r*rLr�handle_requestr�r[r��extract_cookiesr�r��logger�infor��http_versionr��
reason_phrase�rhr�r
r^r]rArArBr]�s2����	zClient._send_single_request�r�r�r�r�r�r�r�c	C�|jd||||||||d�	S)�U
        Send a `GET` request.

        **Parameters**: See `httpx.request`.
        r�rkr��	rhr6r�r�r�r�r�r�r�rArArBrF��z
Client.get�AuthTypes | UseClientDefaultc	Crl)�Z
        Send an `OPTIONS` request.

        **Parameters**: See `httpx.request`.
        �OPTIONSrkr�rnrArArB�options)rozClient.optionsc	Crl)�V
        Send a `HEAD` request.

        **Parameters**: See `httpx.request`.
        r�rkr�rnrArArB�headFrozClient.headc
C�$|jd|||||||||	|
||d�
S)�V
        Send a `POST` request.

        **Parameters**: See `httpx.request`.
        r�r7r��
rhr6r�r�r�r�r�r�r�r�r�r�r�rArArB�postc��zClient.postc
Crv)�U
        Send a `PUT` request.

        **Parameters**: See `httpx.request`.
        �PUTr7r�rxrArArB�put�rzz
Client.putc
Crv)�W
        Send a `PATCH` request.

        **Parameters**: See `httpx.request`.
        �PATCHr7r�rxrArArB�patch�rzzClient.patchc	Crl)�X
        Send a `DELETE` request.

        **Parameters**: See `httpx.request`.
        �DELETErkr�rnrArArB�delete�roz
Client.deletecCsF|jtjkrtj|_|j��|j��D]}|dur|��qdSdS�z.
        Close transport and proxies.
        N)r�rTrYr!rwr"�values)rhr
rArArBrw�s
��zClient.closerhr3cCs`|jtjkrtjdtjdi|j}t|��tj|_|j��|j�	�D]
}|dur-|��q#|S�Nz-Cannot open a client instance more than once.z9Cannot reopen a client instance, once it has been closed.)
r�rTrWrXrYrLr!�	__enter__r"r�)rh�msgr
rArArBr��s��
�zClient.__enter__�exc_type�type[BaseException] | None�	exc_value�BaseException | None�	traceback�TracebackType | NonecCsBtj|_|j�|||�|j��D]
}|dur|�|||�qdSrb)rTrYr�r!�__exit__r"r�)rhr�r�r�r
rArArBr�
s��zClient.__exit__)(r�r�r�r�r�r�r�r�rrrrr�r9rr9rr9r�r�rr
r�r+r�r9r	rr�r�r�r�r�r�r
rr�r�r8r`)rrrrr�r9rr9rr9r	rr
rr8r)r�rrrrrr�r9rr9rr9r	rr8r)r6r,r8r�r�r�r6r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r8r�r�r�r�r8r)r�r�r6r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r8r�r�r�r�r8rE�
r�rr\r9r�r�r�r8r8r�
r�rr�rr�r9rKrQr8r�r�rr�r9rKrQr8r�r�rr8r�r6r�r�r�r�r�r�r�r�r�r�r8r�r�r�r�r8r�r6r�r�r�r�r�r�r�r�rpr�r8r�r�r�r�r8r�r6r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rpr�r8r�r�r�r�r8rry)rhr3r8r3�NNN�r�r�r�r�r�r�r8r`)rKrLrMrNr
rrrir rr5r0r�rr\rBrMrUr]rFrsruryr}r�r�rwr�r��
__classcell__rArAr%rBr2Rs /�Q��
�8�7�
3
"
%'�!�!�!�)�)�)�

�cseZdZdZddddddddddedeedddddd�d|�fd-d.�Zdddddedfd}d0d1�Zdddddefd~d3d4�Z	dd7d8�Z
dddddddeeedd9�d�dJdK�Ze
dddddddeeedd9�d�dMdN��ZdeedO�d�dSdT�Zd�dXdY�Zd�dZd[�Zd�d\d]�Zdddeeedd^�d�d_d`�Zdddeeedd^�d�dbdc�Zdddeeedd^�d�ddde�Zdddddddeeedd9�d�dfdg�Zdddddddeeedd9�d�dhdi�Zdddddddeeedd9�d�djdk�Zdddeeedd^�d�dldm�Zd�dndo�Zd�drds�Z			d�d�dzd{�Z�ZS)�r1a�
    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)* 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.
    * **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�rrrrr�rr�r�r	r�r�r�r
r�r�r�r�r�r�r�r�r�r�rrrrrr9rr�r�r�5None | typing.Mapping[str, AsyncBaseTransport | None]r�r+r�r	rr�r�r�r�r�r�r
�AsyncBaseTransport | Noner�r�r�r8r`c
s�t�j|||||||||�|d��r&zddl}Wnty%td�d�w�o+|du}��|	|�}�j������|d��_�������fdd�|��D��_|
durb�j�	dd�|
��D��t
t�j�����_dS)Nr�rrrcrrrrrrArBr��rz(AsyncClient.__init__.<locals>.<dictcomp>cSrrArrrArArBr��rr)rhr�r�r�r�rrrrr�rr�r�r	r�r�r�r
r�r�rr�r$r%rrBriIsT�����
��zAsyncClient.__init__rcCr'r�rr)rArArBr �r*zAsyncClient._init_transportrc	Cr+r,r�r-rArArBr�r.z!AsyncClient._init_proxy_transportr6r,cCr/r0r1r3rArArBr5�r6zAsyncClient._transport_for_urlr7r�r�r�r�r�r�r�r�r�r�r�r8r�r�r�rc
�sT�|	durd}tj|tdd�|j|||||||||	||
d�}|j||
|d�IdHS)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
        Nr9rUr:r<r=r>rCrArArBr��s&�"��
zAsyncClient.request�typing.AsyncIterator[Response]c
Csf�|j|||||||||	||
d�}|j||
|dd�IdH}z
|VW|��IdHdS|��IdHwrF)r�rBr~rGrArArBr\s.��
�"zAsyncClient.streamrHr�rr\c
�s��|jtjkrtd��tj|_t|t�r|jn|}|�|�|�	||�}|j
|||gd�IdH}z|s:|��IdH|WStyQ}z	|�
�IdH|�d}~ww)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
        rIrJN)r�rTrYrLrXr�rJr�rr�rM�areadrOr~rPrArArBrB:s2���
���zAsyncClient.sendrrKrQc	
�s��|�|�}z^|��IdH}	|j|||d�IdH}z4z
|�|�IdH}Wnty9|YWW|��IdHSwt|�|_|��IdH|}|�	|�Wnt
yc}z	|��IdH|�d}~wwq|��IdHwrR)�async_auth_flow�	__anext__rU�asend�StopAsyncIterationr~r�rKr�rWrOrXrArArBrMms8�
�
�
���zAsyncClient._send_handling_authc
�s��	t|�|jkrtd|d��|jdD]	}||�IdHq|�|�IdH}z7|jdD]	}||�IdHq,t|�|_|jsA|WS|�||�}||g}|rV|�	�IdHn||_
|WSWntyr}z	|��IdH|�d}~wwqr[)
r\r�rr�r]r�rKr^r�r�rZrOr~r_rArArBrU�s8��

����z$AsyncClient._send_handling_redirectsc�s��|�|j�}t��}t|jt�std��t|d��|�	|�IdH}Wd�n1s-wYt|jt�s:J�||_
t|j||d�|_|j�
|�|j|_t�d|j|j|j|j|j�|S)raz?Attempted to send an sync request with an AsyncClient instance.r�Nrbrc)r5r6rrrsr�r\rrLr�handle_async_requestr�r{r�rer�r�rfrgr�rhr�rirjrArArBr]�s4�����	z AsyncClient._send_single_requestrkc	��$�|jd||||||||d�	IdHS)rmr�rkNr�rnrArArBrF����zAsyncClient.getrpc	�r�)rqrrrkNr�rnrArArBrs�r�zAsyncClient.optionsc	�r�)rtr�rkNr�rnrArArBrur�zAsyncClient.headc
��,�|jd|||||||||	|
||d�
IdHS)rwr�r7Nr�rxrArArBry.� ��zAsyncClient.postc
�r�)r{r|r7Nr�rxrArArBr}Sr�zAsyncClient.putc
�r�)r~rr7Nr�rxrArArBr�xr�zAsyncClient.patchc	�r�)r�r�rkNr�rnrArArBr��r�zAsyncClient.deletec�sT�|jtjkr&tj|_|j��IdH|j��D]}|dur%|��IdHqdSdSr�)r�rTrYr!r~r"r�)rhr�rArArBr~�s���zAsyncClient.acloserhr5c�sn�|jtjkrtjdtjdi|j}t|��tj|_|j��IdH|j�	�D]
}|dur4|��IdHq'|Sr�)
r�rTrWrXrYrLr!�
__aenter__r"r�)rhr�r�rArArBr��s ����zAsyncClient.__aenter__r�r�r�r�r�r�c�sP�tj|_|j�|||�IdH|j��D]}|dur%|�|||�IdHqdSrb)rTrYr�r!�	__aexit__r"r�)rhr�r�r�r�rArArBr��s���zAsyncClient.__aexit__)(r�r�r�r�r�r�r�r�rrrrrr9rr9r�r�rr�r�r+r�r9r	rr�r�r�r�r�r�r
r�r�r9r�r�r8r`)rrrrr�r9rr9rr9r	rr
r�r8r)r�rrrrrr�r9rr9rr9r	rr8r)r6r,r8rr�)r�r�r6r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r8r�r�r�r�r8r�r�r�r�r�r�r�r�ry)rhr5r8r5r�r�)rKrLrMrNr
rrrir rr5r0r�rr\rBrMrUr]rFrsruryr}r�r�r~r�r�r�rArAr%rBr1s 0�Q��
�9�7�
3
"
&&�!�!�!�)�)�)�

�)r6r,r7r,r8r9)r6r,r8rD)r6r,rHr,r8r9)\�
__future__rrt�enum�loggingrr�typingr?�
contextlibrr�typesrrr�rr	r
�_configrrr
rrr�	_decodersr�_exceptionsrrrr�_modelsrrrr�
_status_codesr�_transports.baserr�_transports.defaultrr�_typesrr r!r"r#r$r%r&r'r(r)r*r+�_urlsr,r-�_utilsr.r/�
TYPE_CHECKING�ssl�__all__�TypeVarr3r5rCr@rIrJr0�	getLoggerrfr�r��keysr��EnumrTr[r{�Callable�Any�	EventHookrr2r1rArArArB�<module>sf <




�N