o �J�h��@s`ddlmZddlZddlZddlZddlZddlZddlZddlm Z m Z ddl m Z ddl m Z ddlmZmZmZddlmZmZmZmZmZmZdd lmZdd lmZmZmZmZdd l 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�KC:\pinokio\api\whisper-webui.git\app\env\lib\site-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��Z e j d�d1d0��Z ed�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�Zclient_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�)rhr6Z merge_urlZmerge_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�Zmerged_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�Zmerged_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-Zmerge)rhr�Zmerged_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_coderZ SEE_OTHERZFOUNDZMOVED_PERMANENTLY)rhr�r]r�rArArBr��szBaseClient._redirect_methodc Cs�|jd}zt|�}Wnty"}z td|�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. ZLocationz 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. Z AuthorizationNr�ZHostr�zContent-LengthzTransfer-EncodingZCookie) rr�rIr6rC�pop�netloc�decoder�)rhr�r6r�r�rArArBr�"s       zBaseClient._redirect_headers�'SyncByteStream | AsyncByteStream | NonecCs||jkr |dkr dS|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�r�rArArArBr�s��"                  � 3   �  �      rcseZdZdZdddddddddddedeeddddd�d|�fd-d.�Zdddddedfd}d0d1�Zdddddefd~d3d4�Z dd7d8�Z ddddddde e e dd9� d�dJdK�Z e ddddddde e e dd9� d�dMdN��Zde e dO�d�dSdT�Zd�dXdY�Zd�dZd[�Zd�d\d]�Zddde e e dd^�d�d_d`�Zddde e e dd^�d�dbdc�Zddde e e dd^�d�ddde�Zddddddde e e dd9� d�dfdg�Zddddddde e e dd9� d�dhdi�Zddddddde e e dd9� d�djdk�Zddde e e dd^�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�r9r�r�r�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]`.�r�r�r�r�r�r�r�c �:i|]\}}t|�|durdn �j|������d��qS�N)r�r�r�r�r�r��r.�_init_proxy_transport�rQrRr��r�r�r�r�rhr�r�rArBr��� ����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�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�� proxy_map�� __class__rrBrisT�  ���  �  ��zClient.__init__rcC� |dur|St||||||d�Sr�r�rhr�r�r�r�r�r�r�rArArBr�� �zClient._init_transportrc C�t|||||||d�S�N)r�r�r�r�r�r�r�r�rhr�r�r�r�r�r�r�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�rr��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�r4rw�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�r�r��_send_handling_auth�read� BaseExceptionrw�rhr�r\r�r�r]r�rArArBr4os0 ��  ���z Client.sendrr=�list[Response]c Cs�|�|�}zLt|�} |j|||d�}z+z|�|�}Wnty,|YWW|��Swt|�|_|��|}|� |�Wnt yP}z|��|�d}~wwq |��w�NT)r�r=) Zsync_auth_flow�next�_send_handling_redirectsr4� StopIterationrwr�r=r@�appendrA� rhr�r�r�r=Z auth_flowr]� next_requestr�rArArBr?�s6 �   � ��� zClient._send_handling_authc Cs� t|�|jkrtd|d��|jdD]}||�q|�|�}z1|jdD]}||�q%t|�|_|js7|WS|�||�}||g}|rI|� �n||_ |WSWnt yb}z|� �|�d}~wwq�NTz#Exceeded maximum allowed redirects.r�r�r]) �lenr�rr��_send_single_requestr�r=�has_redirect_locationr�r@rJrArw�rhr�r�r=�hookr]r�rArArBrF�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")r'r6rrrsr�r\r*r>rZhandle_requestr�r[r��extract_cookiesr�r��logger�infor�� http_versionr�� reason_phrase�rhr�r�r^r]rArArBrM�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�rZr�� rhr6r�r�r�r�r�r�r�rArArBrF ��z Client.get�AuthTypes | UseClientDefaultc Cr[)�Z Send an `OPTIONS` request. **Parameters**: See `httpx.request`. �OPTIONSrZr�r]rArArB�options)r^zClient.optionsc Cr[)�V Send a `HEAD` request. **Parameters**: See `httpx.request`. r�rZr�r]rArArB�headFr^z Client.headc C�$|jd||||||||| | | | d� S)�V Send a `POST` request. **Parameters**: See `httpx.request`. r�r)r�� rhr6r�r�r�r�r�r�r�r�r�r�r�rArArB�postc��z Client.postc Cre)�U Send a `PUT` request. **Parameters**: See `httpx.request`. �PUTr)r�rgrArArB�put�riz Client.putc Cre)�W Send a `PATCH` request. **Parameters**: See `httpx.request`. �PATCHr)r�rgrArArB�patch�riz Client.patchc Cr[)�X Send a `DELETE` request. **Parameters**: See `httpx.request`. �DELETErZr�r]rArArB�delete�r^z Client.deletecCsF|jtjkrtj|_|j��|j��D] }|dur|��qdSdS�z. Close transport and proxies. N)r�rTrYrrwr�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�rTrWrXrYr>r� __enter__rrt)rh�msgr�rArArBrv�s �� �zClient.__enter__�exc_type�type[BaseException] | None� exc_value�BaseException | None� traceback�TracebackType | NonecCsBtj|_|j�|||�|j��D] }|dur|�|||�qdSrb)rTrYr�r�__exit__rrt)rhrxrzr|r�rArArBr~ s��zClient.__exit__)(r�r�r�r�r�r�r�r�r�r�r�r�r�r9r�r9r�r9r�r�r�r�r�r+r�r9r�rr�r�r�r�r�r�r�rr�r�r8r`)r�r�r�r�r�r9r�r9r�r9r�rr�rr8r)r�rr�r�r�r�r�r9r�r9r�r9r�rr8r)r6r,r8r�r�r�r6r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r*r�r�r�r�r8r)r�r�r6r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r*r�r�r�r�r8r7� r�rr\r9r�r�r�r*r8r� r�rr�rr�r9r=rCr8r�r�rr�r9r=rCr8r�r�rr8r�r6r�r�r�r�r�r�r�r�r�r�r*r�r�r�r�r8r�r6r�r�r�r�r�r�r�r�r_r�r*r�r�r�r�r8r�r6r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r_r�r*r�r�r�r�r8rry)rhr3r8r3�NNN�rxryrzr{r|r}r8r`)rKrLrMrNr r r rirrr'r0r�rr\r4r?rFrMrFrbrdrhrlrorrrwrvr~� __classcell__rArArrBr2Rs /�Q � � �8�7� 3 " %'�!�!�!�)�)�)�  �cseZdZdZddddddddddedeedddddd�d|�fd-d.�Zdddddedfd}d0d1�Zdddddefd~d3d4�Z dd7d8�Z ddddddde e e dd9� d�dJdK�Z e ddddddde e e dd9� d�dMdN��Zde e dO�d�dSdT�Zd�dXdY�Zd�dZd[�Zd�d\d]�Zddde e e dd^�d�d_d`�Zddde e e dd^�d�dbdc�Zddde e e dd^�d�ddde�Zddddddde e e dd9� d�dfdg�Zddddddde e e dd9� d�dhdi�Zddddddde e e dd9� d�djdk�Zddde e e dd^�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�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�r9r�r�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��r z(AsyncClient.__init__.<locals>.<dictcomp>cSr rAr r rArArBr��r r)rhr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�rrrrBriIsT�  ���  �  ��zAsyncClient.__init__rcCrr�rrrArArBr�rzAsyncClient._init_transportrc Crrr�rrArArBr�r z!AsyncClient._init_proxy_transportr6r,cCr!r"r#r%rArArBr'�r(zAsyncClient._transport_for_urlr)r�r�r�r�r�r�r�r�r�r�r�r*r�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 Nr+rUr,r.r/r0r5rArArBr��s&�"�� zAsyncClient.request�typing.AsyncIterator[Response]c  Csf�|j||||||||| | | d� }|j|| | dd�IdH}z |VW|��IdHdS|��IdHwr8)r�r4r~r9rArArBr\s.��  �"zAsyncClient.streamr:r�rr\c �s��|jtjkr td��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 r;r<N)r�rTrYr>rXr�rJr�r�r�r?�areadrAr~rBrArArBr4:s2� ��   ���zAsyncClient.sendrr=rCc �s��|�|�}z^|��IdH} |j|||d�IdH}z4z |�|�IdH}Wnty9|YWW|��IdHSwt|�|_|��IdH|}|� |�Wnt yc}z |��IdH|�d}~wwq|��IdHwrD) Zasync_auth_flow� __anext__rF�asend�StopAsyncIterationr~r�r=r�rHrArIrArArBr?ms8�  �   � ���zAsyncClient._send_handling_authc �s�� t|�|jkrtd|d��|jdD] }||�IdHq|�|�IdH}z7|jdD] }||�IdHq,t|�|_|jsA|WS|�||�}||g}|rV|� �IdHn||_ |WSWnt yr}z |� �IdH|�d}~wwqrK) rLr�rr�rMr�r=rNr�r�rJrAr~rOrArArBrF�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)rQz?Attempted to send an sync request with an AsyncClient instance.r�NrRrS)r'r6rrrsr�r\rr>rZhandle_async_requestr�r{r�rTr�r�rUrVr�rWr�rXrYrArArBrM�s4�  � �� � z AsyncClient._send_single_requestrZc ��$�|jd||||||||d� IdHS)r\r�rZNr�r]rArArBrF��� �zAsyncClient.getr_c �r�)r`rarZNr�r]rArArBrb�r�zAsyncClient.optionsc �r�)rcr�rZNr�r]rArArBrdr�zAsyncClient.headc ��,�|jd||||||||| | | | d� IdHS)rfr�r)Nr�rgrArArBrh.� � �zAsyncClient.postc �r�)rjrkr)Nr�rgrArArBrlSr�zAsyncClient.putc �r�)rmrnr)Nr�rgrArArBroxr�zAsyncClient.patchc �r�)rprqrZNr�r]rArArBrr�r�zAsyncClient.deletec�sT�|jtjkr&tj|_|j��IdH|j��D]}|dur%|��IdHqdSdSrs)r�rTrYrr~rrt)rhr�rArArBr~�s� ��zAsyncClient.acloserhr5c�sn�|jtjkrtjdtjdi|j}t|��tj|_|j��IdH|j� �D] }|dur4|��IdHq'|Sru) r�rTrWrXrYr>r� __aenter__rrt)rhrwr�rArArBr��s � ���zAsyncClient.__aenter__rxryrzr{r|r}c�sP�tj|_|j�|||�IdH|j��D]}|dur%|�|||�IdHqdSrb)rTrYr�r� __aexit__rrt)rhrxrzr|r�rArArBr��s���zAsyncClient.__aexit__)(r�r�r�r�r�r�r�r�r�r�r�r�r�r9r�r9r�r�r�r�r�r+r�r9r�rr�r�r�r�r�r�r�r�r�r9r�r�r8r`)r�r�r�r�r�r9r�r9r�r9r�rr�r�r8r)r�rr�r�r�r�r�r9r�r9r�r9r�rr8r)r6r,r8rr)r�r�r6r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r*r�r�r�r�r8r�r�r�r�r�r�r�r�ry)rhr5r8r5r�r�)rKrLrMrNr r r rirrr'r0r�rr\r4r?rFrMrFrbrdrhrlrorrr~r�r�r�rArArrBr1s 0�Q � � �9�7� 3 " &&�!�!�!�)�)�)�  �)r6r,r7r,r8r9)r6r,r8rD)r6r,rHr,r8r9)\� __future__rrt�enum�loggingrr�typingr1� contextlibrr�typesrrr�rr r �_configr r r rrrZ _decodersr� _exceptionsrrrr�_modelsrrrr� _status_codesrZ_transports.baserrZ_transports.defaultrr�_typesrr r!r"r#r$r%r&r'r(r)r*r+�_urlsr,r-Z_utilsr.r/� TYPE_CHECKING�ssl�__all__�TypeVarr3r5rCr@rIrJr0� getLoggerrUr�r��keysr��EnumrTr[r{�Callable�AnyZ EventHookrr2r1rArArArB�<module>sf      <      �N
Memory