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/_transports/__pycache__/asgi.cpython-310.pyc
o

���g}�@sddlmZddlZddlmZmZddlmZddlm	Z	ej
r2ddlZddlZej
ejejfZejeejfZejgejefZejejeejfgejdfZejejeejfeegejdfZdgZddd�Zddd�ZGdd�de�ZGdd�de	�ZdS)�)�annotationsN�)�Request�Response)�AsyncByteStream�)�AsyncBaseTransport�
ASGITransport�return�boolcCs6zddl}|��dkrWdSWdStyYdSw)Nr�trioTF)�sniffio�current_async_library�ImportError)r
�r�A/usr/local/lib/python3.10/dist-packages/httpx/_transports/asgi.py�is_running_trios���r�EventcCs&t�rddl}|��Sddl}|��S)Nr)rrr�asyncio)rrrrr�create_event,s
rc@s eZdZddd�Zddd	�Zd
S)
�ASGIResponseStream�body�list[bytes]r
�NonecCs
||_dS�N)�_body)�selfrrrr�__init__8s
zASGIResponseStream.__init__�typing.AsyncIterator[bytes]cCs�d�|j�VdS)N�)�joinr)rrrr�	__aiter__;s�zASGIResponseStream.__aiter__N)rrr
r)r
r)�__name__�
__module__�__qualname__rr!rrrrr7s
rc@s,eZdZdZ			dddd�Zddd�ZdS)r	a�
    A custom AsyncTransport that handles sending requests directly to an ASGI app.

    ```python
    transport = httpx.ASGITransport(
        app=app,
        root_path="/submount",
        client=("1.2.3.4", 123)
    )
    client = httpx.AsyncClient(transport=transport)
    ```

    Arguments:

    * `app` - The ASGI application.
    * `raise_app_exceptions` - Boolean indicating if exceptions in the application
       should be raised. Default to `True`. Can be set to `False` for use cases
       such as testing the content of a client 500 response.
    * `root_path` - The root path on which the ASGI application should be mounted.
    * `client` - A two-tuple indicating the client IP and port of incoming requests.
    ```
    T��z	127.0.0.1�{�app�_ASGIApp�raise_app_exceptionsr�	root_path�str�client�tuple[str, int]r
rcCs||_||_||_||_dSr)r(r*r+r-)rr(r*r+r-rrrrWs
zASGITransport.__init__�requestrrc
�sJ�t�jt�s	J�dddid�jdd��jjD��jj�jj�jj	�
d�d�jj�jj�jj
f|j|jd	�}�j���d
�d�d�g�d
�t��d���fd
d�}d������fdd�}z|�|||�IdHWnty�|jru�����durd��dur�i�Ynw���s�J��dus�J��dus�J�t��}t��|d�S)N�http�versionz3.0z1.1cSsg|]
\}}|��|f�qSr)�lower)�.0�k�vrrr�
<listcomp>osz6ASGITransport.handle_async_request.<locals>.<listcomp>�?r)�type�asgi�http_version�method�headers�scheme�path�raw_path�query_string�serverr-r+Fr
�dict[str, typing.Any]c�s^��r���IdHddiSz	���IdH}Wnty(d�dddd�YSwd|dd�S)Nr8zhttp.disconnectTzhttp.requestrF)r8r�	more_body)�wait�	__anext__�StopAsyncIteration)r)�request_body_chunks�request_complete�response_completerr�receive�s��z3ASGITransport.handle_async_request.<locals>.receive�message�&typing.MutableMapping[str, typing.Any]rc�s��|ddkr�rJ�|d�|�dg��d�dS|ddkrE���r%J�|�dd�}|�d	d
�}|r=�jdkr=��|�|sG���dSdSdS)Nr8zhttp.response.start�statusr<Tzhttp.response.bodyrrrCF�HEAD)�get�is_setr;�append�set)rKrrC)�
body_partsr/rI�response_headers�response_started�status_coderr�send�s �
�z0ASGITransport.handle_async_request.<locals>.sendi�)r<�stream)r
rB)rKrLr
r)�
isinstancerXrr;r<�raw�urlr=r>r?�split�query�host�portr-r+r!rr(�	Exceptionr*rRrPrr)rr/�scoperJrWrXr)rSr/rGrHrIrTrUrVr�handle_async_requestcsR��
��
z"ASGITransport.handle_async_requestN)Tr%r&)
r(r)r*rr+r,r-r.r
r)r/rr
r)r"r#r$�__doc__rrbrrrrr	?s�)r
r)r
r)�
__future__r�typing�_modelsrr�_typesr�baser�
TYPE_CHECKINGrr�Unionr�MutableMappingr,�Any�_Message�Callable�	Awaitable�_Receive�_Sendr)�__all__rrrr	rrrr�<module>s,��