Format: application/x-python-code
⬇ Download File (5.1 KB)
   1  o
   2  
   3  C'h��@s�ddlmZddlZddlZddlZddlZddlmZmZddl	m
   4  Z
   5  ddlmZej
   6  r9ddlmZdd	lmZe�d
   7  �ZdgZddd�ZGdd�de
   8  �ZGdd�de�ZdS)�)�annotationsN�)�Request�Response)�SyncByteStream�)�
   9  BaseTransport)�
  10  OptExcInfo)�WSGIApplication�_T�
  11  WSGITransport�body�typing.Iterable[_T]�returncCs,t|�}|D]
  12  }|rt�|g|�SqgS�N)�iter�	itertools�chain)r
  13  �chunk�r�LC:\Users\shubh\Videos\agent\nova\Lib\site-packages\httpx/_transports/wsgi.py�_skip_leading_empty_chunkss�rc@s*eZdZd
  14  dd�Zddd	�Zdd
  15  d�ZdS)�WSGIByteStream�result�typing.Iterable[bytes]r�NonecCst|dd�|_t|�|_dS)N�close)�getattr�_closer�_result)�selfrrrr�__init__szWSGIByteStream.__init__�typing.Iterator[bytes]ccs�|jD]}|VqdSr)r)r �partrrr�__iter__#s�
  16  �zWSGIByteStream.__iter__cCs|jdur|��dSdSr)r)r rrrr's
  17  �zWSGIByteStream.closeN)rrrr)rr")rr)�__name__�
  18  __module__�__qualname__r!r$rrrrrrs
  19  
  20  rc@s.eZdZdZ				dddd�Zddd�ZdS)ra
  21      A custom transport that handles sending requests directly to an WSGI app.
  22      The simplest way to use this functionality is to use the `app` argument.
  23  
  24      ```
  25      client = httpx.Client(app=app)
  26      ```
  27  
  28      Alternatively, you can setup the transport instance explicitly.
  29      This allows you to include any additional configuration arguments specific
  30      to the WSGITransport class:
  31  
  32      ```
  33      transport = httpx.WSGITransport(
  34          app=app,
  35          script_name="/submount",
  36          remote_addr="1.2.3.4"
  37      )
  38      client = httpx.Client(transport=transport)
  39      ```
  40  
  41      Arguments:
  42  
  43      * `app` - The WSGI application.
  44      * `raise_app_exceptions` - Boolean indicating if exceptions in the application
  45         should be raised. Default to `True`. Can be set to `False` for use cases
  46         such as testing the content of a client 500 response.
  47      * `script_name` - The root path on which the WSGI application should be mounted.
  48      * `remote_addr` - A string indicating the client IP of incoming requests.
  49      ```
  50      T��	127.0.0.1N�appr
  51  �raise_app_exceptions�bool�script_name�str�remote_addr�wsgi_errors�typing.TextIO | NonerrcCs"||_||_||_||_||_dSr)r*r+r-r/r0)r r*r+r-r/r0rrrr!Ms
  52  
  53  zWSGITransport.__init__�requestrrc
  54  sT|��t�|j�}|jjpddd�|jj}d|jj||jp!tj	ddd|j
  55  |j|jj|jj
  56  �d�|jjt|�d|jd	�}|jjD]\}}|�d����d
  57  d�}|dvrXd
  58  |}|�d�||<qAd�d�d�	dd���fdd�
  59  }|�||�}	t|	�}
  60  �dus�J��dus�J��r��dr�|jr��d�t���d�}dd��D�}t|||
  61  d�S)N�Pi�)�http�https)rrTF�asciizHTTP/1.1)zwsgi.versionzwsgi.url_schemez
  62  wsgi.inputzwsgi.errorszwsgi.multithreadzwsgi.multiprocessz
  63  wsgi.run_once�REQUEST_METHODZSCRIPT_NAMEZ	PATH_INFOZQUERY_STRINGZSERVER_NAMEZSERVER_PORTZSERVER_PROTOCOLZREMOTE_ADDR�-�_)ZCONTENT_TYPEZCONTENT_LENGTHZHTTP_�statusr.�response_headers�list[tuple[str, str]]�exc_info�OptExcInfo | Noner�$typing.Callable[[bytes], typing.Any]cs|�|�|�dd�S)NcSsdSrr)r9rrr�<lambda>�szFWSGITransport.handle_request.<locals>.start_response.<locals>.<lambda>r)r:r;r=�Z
  64  seen_exc_infoZseen_response_headersZseen_statusrr�start_response{sz4WSGITransport.handle_request.<locals>.start_responserrcSs$g|]\}}|�d�|�d�f�qS)r6)�encode)�.0�key�valuerrr�
  65  <listcomp>�s��z0WSGITransport.handle_request.<locals>.<listcomp>)�headers�streamr)r:r.r;r<r=r>rr?)�read�io�BytesIO�content�url�port�schemer0�sys�stderr�methodr-�path�query�decode�hostr.r/rH�raw�upper�replacer*rr+�int�splitr)
  66  r r2Z
  67  wsgi_inputrO�environZ
  68  header_key�header_valuerErBrrI�status_coderHrrAr�handle_request[sP
  69  ���zWSGITransport.handle_request)Tr(r)N)r*r
  70  r+r,r-r.r/r.r0r1rr)r2rrr)r%r&r'�__doc__r!r`rrrrr,s#�)r
  71  rrr)�
  72  __future__rrKrrQ�typingZ_modelsrr�_typesr�baser�
  73  TYPE_CHECKINGZ	_typeshedr	Z_typeshed.wsgir
  74  �TypeVarr�__all__rrrrrrr�<module>s 
  75  
  76