HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/httpx/_transports/__pycache__/wsgi.cpython-310.pyc
o

���g��@s�ddlmZddlZddlZddlZddlZddlmZmZddl	m
Z
ddlmZej
r9ddlmZdd	lmZe�d
�ZdgZddd�ZGdd�de
�ZGdd�de�ZdS)�)�annotationsN�)�Request�Response)�SyncByteStream�)�
BaseTransport)�
OptExcInfo)�WSGIApplication�_T�
WSGITransport�body�typing.Iterable[_T]�returncCs,t|�}|D]
}|rt�|g|�SqgS�N)�iter�	itertools�chain)r
�chunk�r�A/usr/local/lib/python3.10/dist-packages/httpx/_transports/wsgi.py�_skip_leading_empty_chunkss�rc@s*eZdZd
dd�Zddd	�Zdd
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�
�zWSGIByteStream.__iter__cCs|jdur|��dSdSr)r)r rrrr's
�zWSGIByteStream.closeN)rrrr)rr")rr)�__name__�
__module__�__qualname__r!r$rrrrrrs

rc@s.eZdZdZ				dddd�Zddd�ZdS)ra
    A custom transport that handles sending requests directly to an WSGI app.
    The simplest way to use this functionality is to use the `app` argument.

    ```
    client = httpx.Client(app=app)
    ```

    Alternatively, you can setup the transport instance explicitly.
    This allows you to include any additional configuration arguments specific
    to the WSGITransport class:

    ```
    transport = httpx.WSGITransport(
        app=app,
        script_name="/submount",
        remote_addr="1.2.3.4"
    )
    client = httpx.Client(transport=transport)
    ```

    Arguments:

    * `app` - The WSGI 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.
    * `script_name` - The root path on which the WSGI application should be mounted.
    * `remote_addr` - A string indicating the client IP of incoming requests.
    ```
    T��	127.0.0.1N�appr
�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

zWSGITransport.__init__�requestrrc
sT|��t�|j�}|jjpddd�|jj}d|jj||jp!tj	ddd|j
|j|jj|jj
�d�|jjt|�d|jd	�}|jjD]\}}|�d����d
d�}|dvrXd
|}|�d�||<qAd�d�d�	dd���fdd�
}|�||�}	t|	�}
�dus�J��dus�J��r��dr�|jr��d�t���d�}dd��D�}t|||
d�S)N�Pi�)�http�https)rrTF�asciizHTTP/1.1)zwsgi.versionzwsgi.url_schemez
wsgi.inputzwsgi.errorszwsgi.multithreadzwsgi.multiprocessz
wsgi.run_once�REQUEST_METHOD�SCRIPT_NAME�	PATH_INFO�QUERY_STRING�SERVER_NAME�SERVER_PORT�SERVER_PROTOCOL�REMOTE_ADDR�-�_)�CONTENT_TYPE�CONTENT_LENGTH�HTTP_�statusr.�response_headers�list[tuple[str, str]]�exc_info�OptExcInfo | Noner�$typing.Callable[[bytes], typing.Any]cs|�|�|�dd�S)NcSsdSrr)r@rrr�<lambda>�szFWSGITransport.handle_request.<locals>.start_response.<locals>.<lambda>r)rDrErG��
seen_exc_info�seen_response_headers�seen_statusrr�start_response{sz4WSGITransport.handle_request.<locals>.start_responserrcSs$g|]\}}|�d�|�d�f�qS)r6)�encode)�.0�key�valuerrr�
<listcomp>�s��z0WSGITransport.handle_request.<locals>.<listcomp>)�headers�streamr)rDr.rErFrGrHrrI)�read�io�BytesIO�content�url�port�schemer0�sys�stderr�methodr-�path�query�decode�hostr.r/rU�raw�upper�replacer*rr+�int�splitr)
r r2�
wsgi_inputr\�environ�
header_key�header_valuerRrOrrV�status_coderUrrKr�handle_request[sP
���zWSGITransport.handle_request)Tr(r)N)r*r
r+r,r-r.r/r.r0r1rr)r2rrr)r%r&r'�__doc__r!rorrrrr,s#�)r
rrr)�
__future__rrXrr^�typing�_modelsrr�_typesr�baser�
TYPE_CHECKING�	_typeshedr	�_typeshed.wsgir
�TypeVarr�__all__rrrrrrr�<module>s