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/servers/__pycache__/basehttp.cpython-310.pyc
o

3�a"�@s�dZddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddlmZddl
mZdZe�d	�Zd
d�Zdd
�ZGdd�dej�ZGdd�deje�ZGdd�dej�ZGdd�dej�Zddefdd�ZdS)a0
HTTP server that implements the Python WSGI protocol (PEP 333, rev 1.21).

Based on wsgiref.simple_server which is part of the standard library since 2.5.

This is a simple server for use in testing or debugging Django apps. It hasn't
been reviewed for security issues. DON'T USE IT FOR PRODUCTION USE!
�N)�
simple_server)�ImproperlyConfigured)�
LimitedStream)�get_wsgi_application)�
import_string)�
WSGIServer�WSGIRequestHandlerz
django.serverc
CsVddlm}t|d�}|durt�Szt|�WSty*}ztd|�|�d}~ww)aK
    Load and return the WSGI application as configured by the user in
    ``settings.WSGI_APPLICATION``. With the default ``startproject`` layout,
    this will be the ``application`` object in ``projectname/wsgi.py``.

    This function, and the ``WSGI_APPLICATION`` setting itself, are only useful
    for Django's internal server (runserver); external WSGI servers should just
    be configured to point to the correct application object directly.

    If settings.WSGI_APPLICATION is not set (is ``None``), return
    whatever ``django.core.wsgi.get_wsgi_application`` returns.
    r)�settings�WSGI_APPLICATIONNzBWSGI application '%s' could not be loaded; Error importing module.)�django.confr	�getattrrr�ImportErrorr)r	�app_path�err�r�>/usr/lib/python3/dist-packages/django/core/servers/basehttp.py�get_internal_wsgi_applications 

�����rcCst��\}}}t|tttf�S�N)�sys�exc_info�
issubclass�BrokenPipeError�ConnectionAbortedError�ConnectionResetError)�exc_type�_rrr�is_broken_pipe_error5s�rcs8eZdZdZdZddd��fdd�
Z�fdd	�Z�ZS)
rz7BaseHTTPServer that implements the Python WSGI protocol�
FT)�ipv6�allow_reuse_addresscs(|rtj|_||_t�j|i|��dSr)�socket�AF_INET6�address_familyr�super�__init__)�selfrr�args�kwargs��	__class__rrr$CszWSGIServer.__init__cs(t�rt�d|�dSt��||�dS)Nz- Broken pipe from %s
)r�logger�infor#�handle_error)r%�request�client_addressr(rrr,IszWSGIServer.handle_error)�__name__�
__module__�__qualname__�__doc__�request_queue_sizer$r,�
__classcell__rrr(rr>s
rc@seZdZdZdZdS)�ThreadedWSGIServerz$A threaded version of the WSGIServerTN)r/r0r1r2�daemon_threadsrrrrr5Psr5csDeZdZdZ�fdd�Z�fdd�Z�fdd�Z�fdd	�Z�ZS)
�
ServerHandlerz1.1c	sRz	t|�d��}Wn
ttfyd}Ynwt�jt||�|||fi|��dS)a#
        Use a LimitedStream so that unread request data will be ignored at
        the end of the request. WSGIRequest uses a LimitedStream but it
        shouldn't discard the data since the upstream servers usually do this.
        This fix applies only for testserver/runserver.
        �CONTENT_LENGTHrN)�int�get�
ValueError�	TypeErrorr#r$r)r%�stdin�stdout�stderr�environr'�content_lengthr(rrr$Xs�$zServerHandler.__init__csZt���d|jvrd|jd<n
t|jjtj�sd|jd<|j�d�dkr+d|j_	dSdS)NzContent-Length�close�
ConnectionT)
r#�cleanup_headers�headers�
isinstance�request_handler�server�socketserver�ThreadingMixInr:�close_connection�r%r(rrrDes


�zServerHandler.cleanup_headerscs|����t���dSr)�	get_stdin�
_read_limitedr#rBrLr(rrrBtszServerHandler.closecst�s
t���dSdSr)rr#r,rLr(rrr,xs�zServerHandler.handle_error)	r/r0r1�http_versionr$rDrBr,r4rrr(rr7Us
r7cs@eZdZdZdd�Zdd�Z�fdd�Zdd	�Zd
d�Z�Z	S)rzHTTP/1.1cCs
|jdS)Nr)r.rLrrr�address_string�s
z!WSGIRequestHandler.address_stringcGs�|j|��d�}|dddkr$|d�d�r$d|d<tjd|d	�dS|d��rPt|d�d
krPt|d�}||d<|dkrDtj}n|dkrLtj}ntj	}ntj	}||g|�Rd|i�dS)
N)r-�server_time�r�4zi��status_codezOYou're accessing the development server over HTTPS, but it only supports HTTP.
)�extra�i�rU)
r-�log_date_time_string�
startswithr*�error�isdigit�lenr9�warningr+)r%�formatr&rUrT�levelrrr�log_message�s*��zWSGIRequestHandler.log_messagecs&|jD]
}d|vr
|j|=qt���S)Nr)rEr#�get_environ)r%�kr(rrr`�s

�
zWSGIRequestHandler.get_environc	CsPd|_|��|js|��|jr
z
|j�tj�WdSttfy'YdSw)NT)rK�handle_one_request�
connection�shutdownr �SHUT_WR�AttributeError�OSErrorrLrrr�handle�s��zWSGIRequestHandler.handlecCs||j�d�|_t|j�dkrd|_d|_d|_|�d�dS|��s$dSt	|j|j
|��|���}||_
|�|j���dS)zDCopy of WSGIRequestHandler.handle() but with different ServerHandlerii�i�N)�rfile�readline�raw_requestliner[�requestline�request_version�command�
send_error�
parse_requestr7�wfile�
get_stderrr`rG�runrH�get_app)r%�handlerrrrrb�s
�z%WSGIRequestHandler.handle_one_request)
r/r0r1�protocol_versionrPr_r`rhrbr4rrr(rr~s
rFc	CsR||f}|rtdtj|fi�}n|}||t|d�}|rd|_|�|�|��dS)Nr)rT)�typerIrJrr6�set_app�
serve_forever)	�addr�port�wsgi_handlerr�	threading�
server_cls�server_address�	httpd_cls�httpdrrrrt�s
rt)r2�loggingr rIr�wsgirefr�django.core.exceptionsr�django.core.handlers.wsgir�django.core.wsgir�django.utils.module_loadingr�__all__�	getLoggerr*rrrrJr5r7rrtrrrr�<module>s&	
	)N