HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberPanel/lib64/python3.10/site-packages/asgiref/__pycache__/wsgi.cpython-310.pyc
o

��ha�@sHddlmZddlmZddlmZmZGdd�d�ZGdd�d�ZdS)	�)�BytesIO)�SpooledTemporaryFile)�AsyncToSync�
sync_to_asyncc@s eZdZdZdd�Zdd�ZdS)�
WsgiToAsgizG
    Wraps a WSGI application to make it into an ASGI application.
    cCs
||_dS�N)�wsgi_application��selfr�r�B/usr/local/CyberPanel/lib/python3.10/site-packages/asgiref/wsgi.py�__init__s
zWsgiToAsgi.__init__c�s�t|j�|||�IdHdS)z�
        ASGI application instantiation point.
        We return a new WsgiToAsgiInstance here with the WSGI app
        and the scope, ready to respond when it is __call__ed.
        N)�WsgiToAsgiInstancer)r
�scope�receive�sendrrr�__call__s�zWsgiToAsgi.__call__N)�__name__�
__module__�__qualname__�__doc__r
rrrrrrsrc@s>eZdZdZdd�Zdd�Zdd�Zd
d	d
�Zedd��Z	dS)rz;
    Per-socket instance of a wrapped WSGI application
    cCs||_d|_d|_dS)NF)r�response_started�response_content_lengthr	rrrr
s
zWsgiToAsgiInstance.__init__c�s��|ddkrtd��||_tdd��<}	|�IdH}|ddkr%td��|�|�d	d
��|�d�s4nq|�d�t|�|_|�|�IdHWd�dS1sRwYdS)
N�type�httpz&WSGI wrapper received a non-HTTP scopei)�max_sizeTzhttp.requestz0WSGI wrapper received a non-HTTP-request message�body��	more_bodyr)	�
ValueErrorrr�write�get�seekr�	sync_send�run_wsgi_app)r
rrrr�messagerrrr"s"�
�

"�zWsgiToAsgiInstance.__call__c	
Cs`|�dd��d��d�}|d�d��d�}|�|�r#|t|�d�}|d|||d�d	�d
|dd|�d
d�|t�dddd�}d|vrY|dd|d<t|dd�|d<nd|d<d|d<|�d�durp|dd|d<|j�dg�D]6\}}|�d�}|dkr�d}n|dkr�d}n
d |���	d!d"�}|�d�}||vr�||d#|}|||<qw|S)$zM
        Builds a scope and request body into a WSGI environ object.
        �	root_path��utf8�latin1�pathN�method�query_string�asciizHTTP/%s�http_version)�r�schemerTF)�REQUEST_METHOD�SCRIPT_NAME�	PATH_INFO�QUERY_STRING�SERVER_PROTOCOLzwsgi.versionzwsgi.url_schemez
wsgi.inputzwsgi.errorszwsgi.multithreadzwsgi.multiprocessz
wsgi.run_once�serverr�SERVER_NAMEr/�SERVER_PORT�	localhost�80�client�REMOTE_ADDR�headers�content-length�CONTENT_LENGTHzcontent-type�CONTENT_TYPEzHTTP_%s�-�_�,)
r!�encode�decode�
startswith�lenr�strr�upper�replace)	r
rr�script_name�	path_info�environ�name�value�corrected_namerrr�
build_environ5sH


�


z WsgiToAsgiInstance.build_environNc	Cs�|jr|d�|d��t|d�r|durtd��|�dd�\}}t|�}dd�|D�}d|_|D]\}}|��d	kr@t|�|_q1d
||d�|_dS)z/
        WSGI start_response callable.
        r/��response_startNz=You cannot call start_response a second time without exc_info� cSs(g|]\}}|���d�|�d�f�qS)r-)�lowerrD)�.0rNrOrrr�
<listcomp>vs��z5WsgiToAsgiInstance.start_response.<locals>.<listcomp>r>zhttp.response.start)r�statusr=)	r�with_traceback�hasattrr�split�intrrUrS)	r
rX�response_headers�exc_info�status_coderBr=rNrOrrr�start_responsefs(��
��z!WsgiToAsgiInstance.start_responsecCs�|�|j|�}d}|�||j�D]:}|jsd|_|�|j�|jdur4|j|}t|�|kr4|d|�}|�d|dd��|t|�7}||jkrJnq|jsWd|_|�|j�|�ddi�dS)z�
        Called in a subthread to run the WSGI app. We encapsulate like
        this so that the start_response callable is called in the same thread.
        rTNzhttp.response.body)rrrr)	rQrrr`rr#rSrrG)r
rrM�
bytes_sent�output�
bytes_allowedrrrr$�s*


�
�zWsgiToAsgiInstance.run_wsgi_appr)
rrrrr
rrQr`rr$rrrrrs
1 rN)	�ior�tempfiler�asgiref.syncrrrrrrrr�<module>s