Format: application/x-python-code
⬇ Download File (5.0 KB)
   1  o
   2  
   3  C'h}�@sddlmZddlZddlmZmZddlmZddlm	Z	ej
   4  r2ddlZddlZej
   5  ejejfZejeejfZejgejefZejejeejfgejdfZejejeejfeegejdfZdgZddd�Zddd�ZGdd�de�ZGdd�de	�ZdS)�)�annotationsN�)�Request�Response)�AsyncByteStream�)�AsyncBaseTransport�
   6  ASGITransport�return�boolcCs6zddl}|��dkrWdSWdStyYdSw)Nr�trioTF)�sniffioZcurrent_async_library�ImportError)r
   7  �r�LC:\Users\shubh\Videos\agent\nova\Lib\site-packages\httpx/_transports/asgi.py�is_running_trios���r�EventcCs&t�rddl}|��Sddl}|��S)Nr)rrr�asyncio)rrrrr�create_event,s
   8  rc@s eZdZddd�Zddd	�Zd
   9  S)
  10  �ASGIResponseStream�body�list[bytes]r
  11  �NonecCs
  12  ||_dS�N)�_body)�selfrrrr�__init__8s
  13  zASGIResponseStream.__init__�typing.AsyncIterator[bytes]cCs�d�|j�VdS)N�)�joinr)rrrr�	__aiter__;s�zASGIResponseStream.__aiter__N)rrr
  14  r)r
  15  r)�__name__�
  16  __module__�__qualname__rr rrrrr7s
  17  rc@s,eZdZdZ			dddd�Zddd�ZdS)r	a�
  18      A custom AsyncTransport that handles sending requests directly to an ASGI app.
  19  
  20      ```python
  21      transport = httpx.ASGITransport(
  22          app=app,
  23          root_path="/submount",
  24          client=("1.2.3.4", 123)
  25      )
  26      client = httpx.AsyncClient(transport=transport)
  27      ```
  28  
  29      Arguments:
  30  
  31      * `app` - The ASGI application.
  32      * `raise_app_exceptions` - Boolean indicating if exceptions in the application
  33         should be raised. Default to `True`. Can be set to `False` for use cases
  34         such as testing the content of a client 500 response.
  35      * `root_path` - The root path on which the ASGI application should be mounted.
  36      * `client` - A two-tuple indicating the client IP and port of incoming requests.
  37      ```
  38      T��z	127.0.0.1�{�app�_ASGIApp�raise_app_exceptionsr�	root_path�str�client�tuple[str, int]r
  39  rcCs||_||_||_||_dSr)r'r)r*r,)rr'r)r*r,rrrrWs
  40  zASGITransport.__init__�requestrrc
  41  �sJ�t�jt�s	J�dddid�jdd��jjD��jj�jj�jj	�
  42  d�d�jj�jj�jj
  43  f|j|jd	�}�j���d
  44  �d�d�g�d
  45  �t��d���fd
  46  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|]
  47  \}}|��|f�qSr)�lower)�.0�k�vrrr�
  48  <listcomp>osz6ASGITransport.handle_async_request.<locals>.<listcomp>�?r)�typeZasgi�http_version�method�headers�scheme�path�raw_pathZquery_string�serverr,r*Fr
  49  �dict[str, typing.Any]c�s^��r���IdHddiSz	���IdH}Wnty(d�dddd�YSwd|dd�S)Nr7zhttp.disconnectTzhttp.requestrF)r7r�	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
  50  �}|r=�jdkr=��|�|sG���dSdSdS)Nr7zhttp.response.start�statusr:Tzhttp.response.bodyrrr@F�HEAD)�get�is_setr9�append�set)rHrr@)�
  51  body_partsr.rF�response_headers�response_started�status_coderr�send�s �
  52  �z0ASGITransport.handle_async_request.<locals>.sendi�)r:�stream)r
  53  r?)rHrIr
  54  r)�
  55  isinstancerUrr9r:�raw�urlr;r<r=�split�query�host�portr,r*r rr'�	Exceptionr)rOrMrr)rr.�scoperGrTrUr)rPr.rDrErFrQrRrSr�handle_async_requestcsR��
  56  ��
  57  z"ASGITransport.handle_async_requestN)Tr$r%)
  58  r'r(r)rr*r+r,r-r
  59  r)r.rr
  60  r)r!r"r#�__doc__rr_rrrrr	?s�)r
  61  r)r
  62  r)�
  63  __future__r�typingZ_modelsrr�_typesr�baser�
  64  TYPE_CHECKINGrr�Unionr�MutableMappingr+�AnyZ_Message�Callable�	AwaitableZ_ReceiveZ_Sendr(�__all__rrrr	rrrr�<module>s,��
  65  
  66