Current File : //usr/local/apps/python3/lib/python3.11/site-packages/asgiref/__pycache__/wsgi.cpython-311.pyc |
�
�rRha � �b � d dl mZ d dlmZ d dlmZmZ G d� d� � Z G d� d� � ZdS ) � )�BytesIO)�SpooledTemporaryFile)�AsyncToSync�
sync_to_asyncc � � e Zd ZdZd� Zd� ZdS )�
WsgiToAsgizG
Wraps a WSGI application to make it into an ASGI application.
c � � || _ d S �N)�wsgi_application��selfr s �D/usr/local/apps/python3/lib/python3.11/site-packages/asgiref/wsgi.py�__init__zWsgiToAsgi.__init__ s � � 0����� c � �T K � t | j � � |||� � � d{V �� dS )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�sends r �__call__zWsgiToAsgi.__call__ s@ � � � � 8� ��!6�7�7��w��M�M�M�M�M�M�M�M�M�M�Mr N)�__name__�
__module__�__qualname__�__doc__r r � r r r r sA � � � � � �� �1� 1� 1�N� N� N� N� Nr r c �B � e Zd ZdZd� Zd� Zd� Zdd�Zed� � � Z dS ) r z;
Per-socket instance of a wrapped WSGI application
c �0 � || _ d| _ d | _ d S )NF)r �response_started�response_content_lengthr s r r zWsgiToAsgiInstance.__init__ s � � 0��� %���'+��$�$�$r c � � K � |d dk rt d� � �|| _ t d�� � 5 } |� � � d {V ��}|d dk rt d� � �|� |� d d
� � � � |� d� � sn�k|� d� � t
|� � | _ | � |� � � d {V �� d d d � � d S # 1 swxY w Y d S )
N�type�httpz&WSGI wrapper received a non-HTTP scopei )�max_sizeTzhttp.requestz0WSGI wrapper received a non-HTTP-request message�bodyr � more_bodyr ) �
ValueErrorr r �write�get�seekr � sync_send�run_wsgi_app)r
r r r r$ �messages r r zWsgiToAsgiInstance.__call__"