HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/django/core/handlers/__pycache__/asgi.cpython-310.pyc
o

3�a�+�@s�ddlZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZmZddl
mZddlmZmZmZmZmZmZmZddlmZdd	lmZe�d
�ZGdd�de�ZGd
d�dej�ZdS)�N)�
sync_to_async)�settings)�signals)�RequestAborted�RequestDataTooBig)�base)�FileResponse�HttpRequest�HttpResponse�HttpResponseBadRequest�HttpResponseServerError�	QueryDict�parse_cookie)�set_script_prefix)�cached_propertyzdjango.requestcsneZdZdZdZdd�Zedd��Z�fdd�Zd	d
�Z	dd�Z
d
d�Zee	e
�Z
ee�Zedd��Z�ZS)�ASGIRequestzv
    Custom request subclass that decodes from an ASGI-standard request dict
    and wraps request body handling.
    �<cCs||_d|_d|_d|_|j�dd�|_|jr,|d�|j�r,|dt|j�d�|_n|d|_|jrFd|j�	d�|j�
ddd�f|_n|d|_|jd��|_
|j�d	d�}t|t�rc|��}|j
||j|jd
d
d�|_|j�d�r�|jdd
|jd<|jd|jd<|jdd|jd<|j�d�r�|jdd
|jd<t|jdd�|jd<n
d|jd<d|jd<|j�dg�D]9\}}|�d�}|dkr�d}n|dkr�d}n
d|���
dd�}|�d�}||jvr�|j|d|}||j|<q�|�|j�||_d|_dS) NF�	root_path��pathz%s/%s�/��method�query_stringT)�REQUEST_METHOD�QUERY_STRING�SCRIPT_NAME�	PATH_INFOzwsgi.multithreadzwsgi.multiprocess�clientr�REMOTE_ADDR�REMOTE_HOST�REMOTE_PORT�server�SERVER_NAME�SERVER_PORT�unknown�0�headers�latin1zcontent-length�CONTENT_LENGTHzcontent-type�CONTENT_TYPEzHTTP_%s�-�_�,)�scope�_post_parse_error�
_read_started�resolver_match�get�script_name�
startswith�len�	path_info�rstrip�replacer�upperr�
isinstance�bytes�decode�META�str�_set_content_type_params�_stream)�selfr.�	body_filer�name�value�corrected_name�rF�;/usr/lib/python3/dist-packages/django/core/handlers/asgi.py�__init__s`


�

�	





zASGIRequest.__init__cCst|jd�S)Nr)r
r=�rArFrFrG�GETbszASGIRequest.GETcs|j�d�p
t���S)N�scheme)r.r2�super�_get_schemerI��	__class__rFrGrMfszASGIRequest._get_schemecC�t|d�s	|��|jS)N�_post)�hasattr�_load_post_and_filesrQrIrFrFrG�	_get_posti�
zASGIRequest._get_postcCs
||_dS)N)rQ)rA�postrFrFrG�	_set_postns
zASGIRequest._set_postcCrP)N�_files)rRrSrXrIrFrFrG�
_get_filesqrUzASGIRequest._get_filescCst|j�dd��S)N�HTTP_COOKIEr)rr=r2rIrFrFrG�COOKIESyszASGIRequest.COOKIES)�__name__�
__module__�__qualname__�__doc__�body_receive_timeoutrHrrJrMrTrWrY�property�POST�FILESr[�
__classcell__rFrFrNrGrsC

rcsheZdZdZeZdZ�fdd�Zdd�Zdd�Z	d	d
�Z
�fdd�Zd
d�Ze
dd��Zdd�Z�ZS)�ASGIHandlerzHandler for ASGI requests.icst���|jdd�dS)NT)�is_async)rLrH�load_middlewarerIrNrFrGrH�s
zASGIHandler.__init__c�s��|ddkrtd|d��z
|�|�IdH}Wn
ty#YdSwt|�|��ttjjdd�|j	|d�IdH|�
||�\}}|durR|�||�IdHdS|�|�IdH}|j	|_
t|t�rg|j|_|�||�IdHdS)zV
        Async entrypoint - parses the request and hands off to get_response.
        �type�httpz5Django can only handle ASGI/HTTP connections, not %s.NT��thread_sensitive)�senderr.)�
ValueError�	read_bodyrr�get_script_prefixrr�request_started�sendrO�create_request�
send_response�get_response_async�_handler_classr:r�
chunk_size�
block_size)rAr.�receiverqrB�request�error_response�responserFrFrG�__call__�s.���� 
zASGIHandler.__call__c�sf�tjtjdd�}	|�IdH}|ddkrt��d|vr$|�|d�|�dd	�s+nq
|�d
�|S)z*Reads a HTTP body from an ASGI connection.zw+b)�max_size�modeTNrhzhttp.disconnect�body�	more_bodyFr)�tempfile�SpooledTemporaryFiler�FILE_UPLOAD_MAX_MEMORY_SIZEr�writer2�seek)rArxrB�messagerFrFrGrn�s��
zASGIHandler.read_bodycCshz	|�||�dfWSty#tjdt��ddid�dt�fYSty3dtddd�fYSw)	z�
        Create the Request object and returns either (request, None) or
        (None, response) if there is an error response.
        Nz Bad Request (UnicodeDecodeError)�status_codei�)�exc_info�extraz413 Payload too largei�)�status)	�
request_class�UnicodeDecodeError�logger�warning�sysr�rrr
)rAr.rBrFrFrGrr�s��zASGIHandler.create_requestcs@z	t��|||�WStyttjrt��nddd�YSw)z#Last-chance handler for exceptions.zInternal Server Errorz
text/plain)�content_type)rL�handle_uncaught_exception�	Exceptionrr�DEBUG�	traceback�
format_exc)rAry�resolverr�rNrFrGr��s
��z%ASGIHandler.handle_uncaught_exceptionc�s4�g}|��D]#\}}t|t�r|�d�}t|t�r|�d�}|�t|�t|�f�q|j��D]}|�d|jdd��d��	�f�q0|d|j
|d��IdH|jrv|D]}|�|�D]\}}	|d	|d
d��IdHq[qT|dd	i�IdHn|�|j
�D]\}}
|d	||
d��IdHq|t|jd
d
��IdHdS)z)Encode and send a response out over ASGI.�asciir(s
Set-Cookier)�headerzhttp.response.start)rhr�r'Nzhttp.response.bodyT)rhrr�rhrj)�itemsr:r>�encode�appendr;�cookies�values�output�stripr��	streaming�chunk_bytes�contentr�close)rAr{rq�response_headersr�rD�c�part�chunkr,�lastrFrFrGrs�sD�



����	�zASGIHandler.send_responseccsh�d}|s|dfVdS|t|�kr2||||j�||jt|�kfV||j7}|t|�ksdSdS)z
        Chunks some data up so it can be sent in reasonable size messages.
        Yields (chunk, last_chunk) tuples.
        rTN)r5rv)�cls�data�positionrFrFrGr�s�
�
�zASGIHandler.chunk_bytescCstjrtjS|�dd�p
dS)zU
        Return the script prefix to use from either the scope or a setting.
        rr)r�FORCE_SCRIPT_NAMEr2)rAr.rFrFrGroszASGIHandler.get_script_prefix)r\r]r^r_rr�rvrHr|rnrrr�rs�classmethodr�rordrFrFrNrGre~s"/
re) �loggingr�r�r��asgiref.syncr�django.confr�django.corer�django.core.exceptionsrr�django.core.handlersr�django.httprr	r
rrr
r�django.urlsr�django.utils.functionalr�	getLoggerr�r�BaseHandlerrerFrFrFrG�<module>s$
h