
    zi]                        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 e j	        r!d dl
Z
d dlZe j        e
j        ej        f         Ze j        ee j        f         Ze j        g e j        e         f         Ze j        e j        ee j        f         ge j        d         f         Ze j        e j        ee j        f         eege j        d         f         Zdd
Z G d de          Z G d de          ZdS )    N   )RequestResponse)AsyncByteStream   )AsyncBaseTransport)NNNreturnEventc                  |    t          j                    dk    rdd l}  | j                    S dd l} |j                    S )Ntrior   )sniffiocurrent_async_libraryr   r
   asyncio)r   r   s     a/var/www/tmov.alphamb/tmov_inventario/venv/lib/python3.11/site-packages/httpx/_transports/asgi.pycreate_eventr      sD    $&&&00tz||w}    c                   V    e Zd Zdej        e         ddfdZdej        e         fdZdS )ASGIResponseStreambodyr	   Nc                     || _         d S N)_body)selfr   s     r   __init__zASGIResponseStream.__init__'   s    


r   c                D   K   d                     | j                  W V  d S )Nr   )joinr   )r   s    r   	__aiter__zASGIResponseStream.__aiter__*   s)      hhtz""""""""r   )	__name__
__module____qualname__typingListbytesr   AsyncIteratorr    r   r   r   r   &   s`        V[/ D    #!5e!< # # # # # #r   r   c                   `    e Zd ZdZ	 	 	 ddedededej        ee	f         d	d
f
dZ
ded	efdZd
S )ASGITransporta  
    A custom AsyncTransport that handles sending requests directly to an ASGI app.
    The simplest way to use this functionality is to use the `app` argument.

    ```
    client = httpx.AsyncClient(app=app)
    ```

    Alternatively, you can setup the transport instance explicitly.
    This allows you to include any additional configuration arguments specific
    to the ASGITransport class:

    ```
    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raise_app_exceptions	root_pathclientr	   Nc                 >    || _         || _        || _        || _        d S r   )r+   r,   r-   r.   )r   r+   r,   r-   r.   s        r   r   zASGITransport.__init__O   s%     $8!"r   requestc                 n  	
K   t          j        t                    sJ dddidj        d j        j        D             j        j        j        j        j        j	        j        j
        j        j        j        j        f| j        | j        d}j                                        dd d 
g dt!                      	dt"          j        t&          t"          j        f         f	fd	}d
t"          j        t&          t"          j        f         dd f	
fd}	 |                     |||           d {V  n4# t,          $ r' | j        r 	                                 d
i 
Y nw xY w	                                sJ J 
J t5                    }t7          
|          S )Nhttpversionz3.0z1.1c                 @    g | ]\  }}|                                 |fS r%   )lower).0kvs      r   
<listcomp>z6ASGITransport.handle_async_request.<locals>.<listcomp>g   s(    III6AqAIIIr   )typeasgihttp_versionmethodheadersschemepathraw_pathquery_stringserverr.   r-   Fr	   c                     K   r                                  d {V  ddiS 	                                  d {V } n# t          $ r dddddcY S w xY wd| ddS )Nr:   zhttp.disconnectTzhttp.requestr   F)r:   r   	more_body)wait	__anext__StopAsyncIteration)r   request_body_chunksrequest_completeresponse_completes    r   receivez3ASGITransport.handle_async_request.<locals>.receive~   s         3',,......... 122Q0::<<<<<<<<% Q Q Q#'  .%PPPPPQ +DtLLLs   A   AAmessagec                   K   | d         dk    r&rJ | d         |                      dg           dd S | d         dk    r|                                rJ |                      dd          }|                      d	d
          }|r j        dk    r                    |           |s                                 d S d S d S )Nr:   zhttp.response.startstatusr>   Tzhttp.response.bodyr   r   rE   FHEAD)getis_setr=   appendset)	rM   r   rE   
body_partsr0   rK   response_headersresponse_startedstatus_codes	      r   sendz0ASGITransport.handle_async_request.<locals>.send   s       v"777++++%h/#*;;y"#=#= #'   $888,3355555{{63//#KKU;;	 ,GNf44%%d+++  ,%))+++++ 98, ,r   i  )r>   stream)
isinstancerZ   r   r=   r>   rawurlr?   r@   rA   queryhostportr.   r-   r   r   r!   DictstrAnyr+   	Exceptionr,   rT   rR   r   r   )r   r0   scoperL   rY   rZ   rU   rI   rJ   rK   rV   rW   rX   s    `    @@@@@@@r   handle_async_requestz"ASGITransport.handle_async_request[   sI      './::::: &!nIIW_5HIIIk(K$,#K-{')9:k
 
  &n6688  
 (NN	Mv{3
?; 	M 	M 	M 	M 	M 	M 	M 	M	,CO < 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,*
	&((5'40000000000 	& 	& 	&( !!###"!'#% 	& !'')))))&&&+++#J//-=fMMMMs   &E .E54E5)Tr(   r)   )r   r   r    __doc___ASGIAppboolrb   r!   Tupleintr   r   r   rf   r%   r   r   r'   r'   .   s         F &*);
 

 #
 	

 S#X&
 

 
 
 
XNXN 
XN XN XN XN XN XNr   r'   )r	   r
   )r!   r   _modelsr   r   _typesr   baser   TYPE_CHECKINGr   r   Unionr
   ra   rb   rc   _MessageCallable	Awaitable_Receive	Coroutine_Sendrh   r   r   r'   r%   r   r   <module>rw      s     ' ' ' ' ' ' ' ' $ $ $ $ $ $ $ $ $ $ $ $	 4NNNKKKL
23E ;sFJ'?2v/99:[fj!"F$45E$FF	 ?[fj!8U3V5EFV5WW
   # # # # # # # #EN EN EN EN EN& EN EN EN EN ENr   