Ë
    RPfr  ã                  óD  — d dl mZ 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y)é    )ÚannotationsNé   )ÚRequestÚResponse)ÚAsyncByteStreamé   )ÚAsyncBaseTransport)NNNc                 ó„   — t        j                  «       dk(  rdd l}  | j                  «       S dd l} |j                  «       S )NÚtrior   )ÚsniffioÚcurrent_async_libraryr   ÚEventÚasyncio)r   r   s     úP/var/www/fastapitest/venv/lib/python3.12/site-packages/httpx/_transports/asgi.pyÚcreate_eventr      s5   € Ü×$Ñ$Ó&¨&Ò0Ûàˆt�z‰z‹|Ðãàˆw�}‰}‹Ðó    c                  ó   — e Zd Zdd„Zdd„Zy)ÚASGIResponseStreamc                ó   — || _         y ©N)Ú_body)ÚselfÚbodys     r   Ú__init__zASGIResponseStream.__init__)   s	   € Øˆ�
r   c               óH   K  — dj                  | j                  «      ­–— y ­w)Nr   )Újoinr   )r   s    r   Ú	__aiter__zASGIResponseStream.__aiter__,   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   (   s   „ óô#r   r   c                  óB   — e Zd ZdZ	 	 	 d	 	 	 	 	 	 	 	 	 dd„Z	 	 	 	 dd„Zy)Ú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.
    ```
    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)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~   øè ø€ ñ  Ø'×,Ñ,Ó.×.Ð.ØÐ 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)Nr/   zhttp.response.startÚstatusr3   Tzhttp.response.bodyr   r   r:   FÚHEAD)ÚgetÚis_setr2   ÚappendÚset)	Úmessager   r:   Ú
body_partsÚrequestr@   Ú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ô  )r3   Ústream)r   údict[str, typing.Any])rI   rQ   r   r   )Ú
isinstancerP   r   r2   r3   ÚrawÚlowerÚurlr4   r5   r6   ÚsplitÚqueryÚhostÚportr*   r)   r   r   r'   Ú	Exceptionr(   rH   rF   r   r   )r   rK   ÚkÚvÚscoperA   rO   rP   rJ   r>   r?   r@   rL   rM   rN   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   )rK   r   r   r   )r    r!   r"   Ú__doc__r   r^   r#   r   r   r%   r%   0   se   „ ñðF &*ØØ"4ð
àð
ð #ð
ð ð	
ð
  ð
ð 
ó
ðXNàðXNð 
ôXNr   r%   )r   r   )Ú
__future__r   Útypingr   Ú_modelsr   r   Ú_typesr   Úbaser	   ÚTYPE_CHECKINGr   r   ÚUnionr   ÚDictrc   ÚAnyÚ_MessageÚCallableÚ	AwaitableÚ_ReceiveÚ	CoroutineÚ_Sendra   r   r   r%   r#   r   r   ú<module>rt      s  ðÝ "ã ã ç 'Ý $Ý $à	×ÒÛãà�L‰L˜Ÿ™¨¯
©
Ð2Ñ3€Eð �;‰;�s˜FŸJ™J�Ñ'€Ø�?‰?˜2˜v×/Ñ/°Ñ9Ð9Ñ:€Ø�‰Ø‡[�[��f—j‘j�Ñ!Ð" F×$4Ñ$4Ð5EÑ$FÐFñ	€ð �?‰?Ø‡[�[��f—j‘j�Ñ! 8¨UÐ3°V×5EÑ5EÐFVÑ5WÐWñ€ó
ô#˜ô #ôENÐ&õ ENr   