Ë
    Eü´j5  ã                  ó2  — 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                  z  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    úU/root/workspace/ytshorts/venv/lib/python3.12/site-packages/httpx2/_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*   € ÜÔÛàˆt�z‰z‹|Ðãàˆ7�=‰=‹?Ðó    c                  ó   — e Zd Zdd„Zdd„Zy)ÚASGIResponseStreamc                ó   — || _         y ©N)Ú_body)ÚselfÚbodys     r   Ú__init__zASGIResponseStream.__init__4   s	   € Øˆ�
r   c               óH   K  — dj                  | j                  «      ­–— y ­w)Nr   )Újoinr   )r   s    r   Ú	__aiter__zASGIResponseStream.__aiter__7   s   è ø€ Ø�h‰h�t—z‘zÓ"Ô"ùs   ‚ "N)r   zlist[bytes]ÚreturnÚNone)r"   ztyping.AsyncIterator[bytes])Ú__name__Ú
__module__Ú__qualname__r   r!   © r   r   r   r   3   s   „ óô#r   r   c                  ó:   — 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 = httpx2.ASGITransport(
        app=app,
        root_path="/submount",
        client=("1.2.3.4", 123)
    )
    client = httpx2.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__Q   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×:Ñ:Ó<×<�ð +°DÀtÑ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Ð5Ø—{‘{ 6¨3Ó/�Ø#ŸK™K¨°UÓ;�	á˜GŸN™N¨fÒ4Ø×%Ñ% dÔ+á Ø%×)Ñ)Õ+ð !ð 9ùs   ƒ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_request]   sÄ  ÿè ø€ Ü˜'Ÿ.™.¬/Ô:Ð:Ð:ð Ø Ð&Ø!Ø—n‘nØ5<·_±_×5HÑ5H×I©6¨A¨q˜Ÿ™› AšÓIØ—k‘k×(Ñ(Ø—K‘K×$Ñ$ØŸ™×,Ñ,×2Ñ2°4Ó8¸Ñ;Ø#ŸK™K×-Ñ-Ø—{‘{×'Ñ'¨¯©×)9Ñ)9Ð:Ø—k‘kØŸ™ñ
ˆð  &Ÿn™n×6Ñ6Ó8ÐØ Ðð ˆØÐØ"$ˆ
Ø ÐÜ(›NÐ÷	M÷	,ò 	,ð*
	&Ø—(‘(˜5 '¨4Ó0×0Ð0ð !×'Ñ'Ô)Ð)Ð)ØÐ&Ð&Ð&ØÐ+Ð+Ð+ä# JÓ/ˆä˜Ð-=ÀfÔMÐMùóY 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
   ;   sN   „ ñð0 &*ØØ"4ð
àð
ð #ð
ð ð	
ð
  ð
ð 
ó
ôUNr   )r"   rd   )r"   r   )Ú
__future__r   ÚtypingÚ_modelsr   r   Ú_typesr   Úbaser	   ÚTYPE_CHECKINGr   r   r   ÚMutableMappingre   ÚAnyÚ_MessageÚCallableÚ	AwaitableÚ_ReceiveÚ_Sendrc   Ú__all__r   r   r   r
   r'   r   r   ú<module>ru      s  ðÝ "ã ç 'Ý $Ý $à	×ÒÛãà�M‰M˜DŸJ™JÑ&€Eð × Ñ   f§j¡j Ñ1€Ø�?‰?˜2˜v×/Ñ/°Ñ9Ð9Ñ:€Ø�‰˜×.Ñ.¨s°F·J±J¨Ñ?Ð@À&×BRÑBRÐSWÑBXÐXÑY€Ø�?‰?˜F×1Ñ1°#°v·z±z°/ÑBÀHÈeÐTÐV\×VfÑVfÐgkÑVlÐlÑm€àÐ
€óóô#˜ô #ôwNÐ&õ wNr   