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/mercurial/hgweb/__pycache__/server.cpython-310.pyc
o

�]Lb7�@snddlmZddlZddlZddlZddlZddlZddlZddlZ	ddl
mZddlm
Z
mZddlmZmZmZmZddlmZejZejZejZejZdd	lmZd
d�ZGdd
�d
e�ZGdd�dej�ZGdd�de�Z z
ddl!Z!e!�"�ej#Z$Wne%y�e�&ed�r�ej'Z$nGdd�de�Z$Ynwdd�Z(Gdd�de$eje�Z)Gdd�de)�Z*dd�Z+dS)�)�absolute_importN�)�_)�getattr�open)�encoding�error�pycompat�util)�urlutil�)�commoncCs2d|vr
|�dd�\}}n|d}}t�|�|fS)z�Return path and query that has been split from uri

    Just like CGI environment, the path is unquoted, the query is
    not.
    �?r�)�split�urlreq�unquote)�uri�path�query�r�8/usr/lib/python3/dist-packages/mercurial/hgweb/server.py�	_splitURI+s
rc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�
_error_loggercCs
||_dS�N)�handler)�selfrrrr�__init__9s
z_error_logger.__init__cCsdSrr�rrrr�flush<sz_error_logger.flushcCs|�|�d��dS)N�
)�
writelinesr)r�strrrr�write?sz_error_logger.writecCs"|D]}|j�dt�|��qdS)Nz
HG error:  %s)r�	log_errorr�strfromlocal)r�seq�msgrrrr!Bs�z_error_logger.writelinesN)�__name__�
__module__�__qualname__rrr#r!rrrrr8s
rc@s�eZdZdZedd��Zdd�Zdd�Zdd	�Zd
d�Z	d$d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd%dd�Zdd�Zd d!�Zd"d#�ZdS)&�_httprequesthandlershttpcCsdS)z*Prepare .socket of new HTTPServer instanceNr)�
httpserver�uirrr�preparehttpserverKsz%_httprequesthandler.preparehttpservercOs$d|_tjj|g|�Ri|��dS)N�HTTP/1.1)�protocol_version�
httpservermod�basehttprequesthandlerr)r�args�kargsrrrrOsz_httprequesthandler.__init__c	Gs8|�t�d|jd|��||f�d�|��dS)Nz%s - - [%s] %srr )r#r	�sysbytes�client_address�log_date_time_stringr)r�fp�formatr3rrr�_log_anySs�����z_httprequesthandler._log_anycG�|j|jj|g|�R�dSr)r:�server�errorlog�rr9r3rrrr$a�z_httprequesthandler.log_errorcGr;r)r:r<�	accesslogr>rrr�log_messagedr?z_httprequesthandler.log_message�-cCsXg}t�|d�rdd�|j��D�}|�d|jt|�t|�d�dd�t|�D���dS)NsheaderscSsg|]}|d�d�r|�qS)rzx-)�
startswith��.0�hrrr�
<listcomp>js
��z3_httprequesthandler.log_request.<locals>.<listcomp>z"%s" %s %s%srcSsg|]}d|�qS)z %s:%srrDrrrrGrs)	r
�safehasattr�headers�itemsrA�requestliner"�join�sorted)r�code�size�xheadersrrr�log_requestgs��z_httprequesthandler.log_requestc
CsFz|��WdStjy"}z|jtjkr�WYd}~dSd}~wwr)�do_hgweb�socketr�errno�EPIPE)r�instrrr�do_writeus���z_httprequesthandler.do_writec
Cs�z|��WdStyN}z;t|ttjf�r|jtjks4d�t	j
t����}t
d�}|�d|j||�|�dg�|�d�|��WYd}~dSd}~ww)Nr�
z6Exception happened during processing request '%s':%s%sz500 Internal Server ErrorsInternal Server Error)rW�	Exception�
isinstance�OSErrorrSrrT�
ECONNRESETrL�	traceback�format_exception�sys�exc_info�chrr$r�_start_response�_write�_done)r�e�tb�newlinerrr�do_POST|s&��
��z_httprequesthandler.do_POSTcC�|��dSr�rhrrrr�do_PUT��z_httprequesthandler.do_PUTcCrirrjrrrr�do_GET�rlz_httprequesthandler.do_GETc	Cs�d|_t|j�\}}||jjkr9|�|jjd�s9|�t�t	�
d��g�|jdkr.dg|_|�
d�|��dSi}d|d<|j|d	<|jj|d
<t|jj�|d<|j|d<t�|jj�|d
<t�|t|jj�d��|d<|jd|d<|jd|d<|p�d|d<tjr�|j��dur�|j��|d<n|j��|d<|j�d�}n|jjdur�|jj|d<n|jj|d<|j�d�}|r�||d<dd�|j��D�D] }d|�dd���}|j�|�}|�dd�� �}|r�|||<q�|j!|d<d|d<t�|j"�|d <|�d!d"��#�d#k�rt	�$|j%|j&j'�|_%|j%|d$<t(|�|d%<t)|jt*j+�|d&<t,�-t*d'��r8t)|jt*j.�|d(<nd|d(<d|d)<t/j0�1|�d|_2g|_d|_3d|_4|j�5||j�D]}|�
|��qZ|j�sk|�6�|��dS)*NF�/i��POST)�
Connection�Closes	Not FoundzCGI/1.1�GATEWAY_INTERFACE�REQUEST_METHOD�SERVER_NAME�SERVER_PORT�REQUEST_URI�SCRIPT_NAME�	PATH_INFOr�REMOTE_HOST�REMOTE_ADDRr�QUERY_STRING�CONTENT_TYPE�content-length�CONTENT_LENGTHcSsg|]
}|��dvr|�qS))zcontent-typer}��lowerrDrrrrG�s
�z0_httprequesthandler.do_hgweb.<locals>.<listcomp>�HTTP_rBr�
�SERVER_PROTOCOL)rrzwsgi.versionzwsgi.url_scheme�HTTP_EXPECT�s100-continuez
wsgi.inputzwsgi.errorszwsgi.multithreadsForkingMixInzwsgi.multiprocessz
wsgi.run_once)7�sent_headersrrr<�prefixrCrbr	�strurlr
�
statusmessage�command�
saved_headersrcrd�server_namer"�server_port�sysstr�lenr6�ispy3rI�get_content_type�get_default_type�get�
typeheader�type�	getheader�keys�replace�upper�strip�request_version�
url_schemer��continuereader�rfile�wfiler#rrZ�socketserver�ThreadingMixInr
rH�ForkingMixIn�wsgiref�validate�
check_environ�saved_status�length�_chunked�application�send_headers)	rrr�envr��header�hkey�hval�chunkrrrrR�s�
�




��

�
�z_httprequesthandler.do_hgwebcCs�|jstd��|j�dd�}t|d�|d<|j|�d|_d|_|jD]}|j|�|d�	�dkr:t|d�|_q$|jdura|dt
jkra|joO|j
dk|_|jr[|�dd�n|�d	d
�|��d|_dS)Ns.Sending headers before start_response() calledrrFr}r/zTransfer-Encoding�chunkedrp�closeT)r��AssertionErrorr�int�
send_responser�r�r��send_headerr�r
�HTTP_NOT_MODIFIED�close_connectionr��end_headersr�)rr�rFrrrr��s,�


��
z _httprequesthandler.send_headersNcsJt|t�sJ�|�dd�\}}t|�}||_d��fdd�|D�|_|jS)Nr)�
connectionztransfer-encodingcs g|]}|d���vr|�qS)rrrD��bad_headersrrrGsz7_httprequesthandler._start_response.<locals>.<listcomp>)rZr"rr�r�r�rc)r�http_statusrIr`rNr'rr�rrbs
�z#_httprequesthandler._start_responsecCs�|jstd��|js|��|jdur't|�|jkrtd��|jt|�|_n
|jr4|r4dt|�|f}|j�|�|j�	�dS)Ns+data written before start_response() calledsLContent-length header sent, but more bytes than specified are being written.s%x
%s
)
r�r�r�r�r�r�r�r�r#r)r�datarrrrcs
�
z_httprequesthandler._writecCs$|jr|j�d�|j��dSdS)Ns0

)r�r�r#rrrrrrd*s�z_httprequesthandler._donecCs"|jjrt�|jj�Stj�|�Sr)r<�serverheaderrr%r1r2�version_stringrrrrr�/sz"_httprequesthandler.version_string)rBrBr)r(r)r*r��staticmethodr.rr:r$rArQrWrhrkrmrRr�rbrcrdr�rrrrr+Gs&

X
r+c@s(eZdZdZdZedd��Zdd�ZdS)�_httprequesthandlersslz*HTTPS handler based on Python's ssl moduleshttpscCstzddlm}|jWntyt�td���w|�dd�}|�dd�}|�dd�}|j|j	||||d	�|_	dS)
Nr)�sslutilsSSL support is unavailable�web�certificatesdevelsservercafilesserverrequirecert)�certfile�cafile�requireclientcert)
rr��wrapserversocket�ImportErrorr�Abortr�config�
configboolrS)r,r-r�r�r��reqcertrrrr.:s 
��z(_httprequesthandlerssl.preparehttpservercCs0|j|_|j�d|j�|_|j�d|j�|_dS)N�rb�wb)�requestr��makefile�rbufsizer��wbufsizer�rrrr�setupRsz_httprequesthandlerssl.setupN)r(r)r*�__doc__r�r�r.r�rrrrr�5s
r�sforkc@seZdZdS)�_mixinN)r(r)r*rrrrr�bsr�cCs|r|dkrt|d�S|S)N�-sab)r)�opt�defaultrrr�openlogfs
r�c@seZdZejr	dZdd�ZdS)�MercurialHTTPServerrc	Ks�tjj|||fi|��d|_||_|�||�|�dd�}|r'd|�d�}||_t	|�dd�|j
�}t	|�dd�|j�}||_||_
|j��dd�\|_|_|j|_|�dd	�|_dS)
NTr�sprefixrns	accesslogserrorlogrrs
server-header)r1r,r�daemon_threadsr�r.r�r�r�r��fout�ferrr@r=rS�getsockname�addr�portr��fqaddrr�)	rr-�appr�r�kwargsr��alog�elogrrrrrszMercurialHTTPServer.__init__N)r(r)r*r	�	iswindows�allow_reuse_addressrrrrrr�lsr�cs(eZdZeedd�Z�fdd�Z�ZS)�IPv6HTTPServer�AF_INET6Ncs2|jdurt�td���tt|�j|i|��dS)Ns$IPv6 is not available on this system)�address_familyr�	RepoErrorr�superr�r)rr3r���	__class__rrr�s
zIPv6HTTPServer.__init__)r(r)r*rrSr�r�
__classcell__rrr�rr��sr�c	Cs|�dd�r	t}nt}|�dd�rt}nt}z
ddl}|��Wn3tySt	j
zt�t	�Wn
t
y>tt	�Ynwt	��}t	�d�|��t	�|�Ynw|�dd�}t�|�dd��}z
|||||f|�WStjy�}zt�td�||t�|jd	�f��d}~ww)
Nr�r�sipv6rslatin1saddresssports"cannot start server at '%s:%d': %sr)r�r�r+r�r�r��	mimetypes�init�UnicodeDecodeErrorr_�argv�	importlib�reload�AttributeError�getdefaultencoding�setdefaultencodingr�getportrSrr�rr�
strtolocalr3)	r-r�r�clsr��oldenc�addressr�rVrrr�
create_server�sB�
�����r�),�
__future__rrTr��osrSr_r]�wsgiref.validater��i18nrr	rrrrrr
�utilsrr,r1r��urlerrrr
r�objectrr2r+r��	threading�active_countr�r�r�rHr�r�r�r�r�rrrr�<module>sH
o#
��