
    ,h}                    J   d dl m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gZdd	Zdd
Z G d de      Z G d de	      Zy)    )annotationsN   )RequestResponse)AsyncByteStream   )AsyncBaseTransportASGITransportc                 V    	 dd l } | j                         dk(  ry	 y# t        $ r Y yw xY w)Nr   trioTF)sniffiocurrent_async_libraryImportError)r   s    X/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/httpx/_transports/asgi.pyis_running_trior      sA    	 	((*f4 5
   s    	((c                 j    t               rdd l}  | j                         S dd l} |j                         S )Nr   )r   r   Eventasyncio)r   r   s     r   create_eventr   ,   s*    tzz|7==?    c                      e Zd ZddZddZy)ASGIResponseStreamc                    || _         y N)_body)selfbodys     r   __init__zASGIResponseStream.__init__8   s	    
r   c               H   K   dj                  | j                         y w)Nr   )joinr   )r   s    r   	__aiter__zASGIResponseStream.__aiter__;   s     hhtzz""s    "N)r   zlist[bytes]returnNone)r"   ztyping.AsyncIterator[bytes])__name__
__module____qualname__r   r!    r   r   r   r   7   s    #r   r   c                  B    e Zd ZdZ	 	 	 d	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 ddZy)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.
    ```
    c                <    || _         || _        || _        || _        y r   )appraise_app_exceptions	root_pathclient)r   r*   r+   r,   r-   s        r   r   zASGITransport.__init__W   s!     $8!"r   c                  	
K   t        j                  t              sJ dddidj                  j                  j
                  D cg c]  \  }}|j                         |f c}}j                  j                  j                  j                  j                  j                  j                  d      d   j                  j                  j                  j                  j                  j                  f| j                  | j                   d}j                  j#                         	d
d d g dt%               d	
fd	}dfd
}	 | j'                  |||       d {    j/                         sJ J J t1              }t3        |      S c c}}w 7 =# t(        $ r( | j*                  r j-                          di Y kw xY ww)Nhttpversionz3.0z1.1   ?r   )typeasgihttp_versionmethodheadersschemepathraw_pathquery_stringserverr-   r,   Fc                    K   rj                          d {    ddiS 	 j                          d {   } d| ddS 7 '7 # t        $ r dddddcY S w xY ww)Nr2   zhttp.disconnectTzhttp.requestr   F)r2   r   	more_body)wait	__anext__StopAsyncIteration)r   request_body_chunksrequest_completeresponse_completes    r   receivez3ASGITransport.handle_async_request.<locals>.receive   s~       ',,... 122Q0::<< +DtLL / =% Q#'  .%PPQsA   AAAA AA AA AAAAc                B  K   | d   dk(  rrJ | d   | j                  dg       dy | d   dk(  rlj                         rJ | j                  dd      }| j                  d	d
      }|r j                  dk7  rj                  |       |sj	                          y y y w)Nr2   zhttp.response.startstatusr6   Tzhttp.response.bodyr   r   r=   FHEAD)getis_setr5   appendset)	messager   r=   
body_partsrequestrC   response_headersresponse_startedstatus_codes	      r   sendz0ASGITransport.handle_async_request.<locals>.send   s      v"77++%h/#*;;y"#= #' $88,3355{{63/#KKU;	GNNf4%%d+ %))+ ! 9s   BBi  )r6   stream)r"   zdict[str, typing.Any])rL   z&typing.MutableMapping[str, typing.Any]r"   r#   )
isinstancerS   r   r5   r6   rawlowerurlr7   r8   r9   splitqueryhostportr-   r,   r!   r   r*   	Exceptionr+   rK   rI   r   r   )r   rN   kvscoperD   rR   rS   rM   rA   rB   rC   rO   rP   rQ   s    `      @@@@@@@r   handle_async_requestz"ASGITransport.handle_async_requestc   s     '../:: &!nn5<__5H5HI6AqAIkk((KK$$,,2248;#KK--{{'')9)9:kk
  &nn668  
 (N	M	, 	,*
	&((5'4000 !''))&&++#J/-=fMMY Jv 1 	&((!!#"!'#% 	&sI   AG%F),C.G%F1 1F/2F1 69G%/F1 1.G"G%!G""G%N)T )z	127.0.0.1{   )
r*   _ASGIAppr+   boolr,   strr-   ztuple[str, int]r"   r#   )rN   r   r"   r   )r$   r%   r&   __doc__r   r`   r'   r   r   r
   r
   ?   sd    4 &*"4

 #
 	

  
 

XNXN 
XNr   )r"   rd   )r"   r   )
__future__r   typing_modelsr   r   _typesr   baser	   TYPE_CHECKINGr   r   Unionr   MutableMappingre   Any_MessageCallable	Awaitable_Receive_Sendrc   __all__r   r   r   r
   r'   r   r   <module>rv      s   "  ' $ $	LL

23E   fjj1??2v//99:3

?+,f.>.>t.DD	 ??3

?+Xu=v?O?OPT?UU 
# #|N& |Nr   