Your IP : 3.145.96.41


Current Path : /opt/alt/python313/lib64/python3.13/http/__pycache__/
Upload File :
Current File : //opt/alt/python313/lib64/python3.13/http/__pycache__/server.cpython-313.opt-1.pyc

�

*}g����R�SrSr/SQrSSKrSSKrSSKrSSKrSSKr	SSK
r
SSKrSSKrSSK
r
SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	Jr SrSr"SS	\R45r"S
S\R8\5r"SS
\R<5r"SS\5r Sr!Sq"Sr#Sr$"SS\ 5r%Sr&\\SSS4Sjr'\(S:Xa�SSK)r)SSK*r*\)RV"5r,\,R[SSSS9 \,R[SSS S!S"9 \,R[S#S$\
R\"5S%S&9 \,R[S'S(S)SS*S+9 \,R[S,S\/S-S.S/9 \,Ra5r1\1Rd(a\%r3O\ r3"S0S1\5r4\'"\3\4\1Rj\1Rl\1RnS29 gg)3a�HTTP server classes.

Note: BaseHTTPRequestHandler doesn't implement any HTTP request; see
SimpleHTTPRequestHandler for simple implementations of GET, HEAD and POST,
and (deprecated) CGIHTTPRequestHandler for CGI scripts.

It does, however, optionally implement HTTP/1.1 persistent connections.

Notes on CGIHTTPRequestHandler
------------------------------

This class is deprecated. It implements GET and POST requests to cgi-bin scripts.

If the os.fork() function is not present (Windows), subprocess.Popen() is used,
with slightly altered but never documented semantics.  Use from a threaded
process is likely to trigger a warning at os.fork() time.

In all cases, the implementation is intentionally naive -- all
requests are executed synchronously.

SECURITY WARNING: DON'T USE THIS CODE UNLESS YOU ARE INSIDE A FIREWALL
-- it may execute arbitrary Python code or external programs.

Note that status code 200 is sent prior to execution of a CGI script, so
scripts cannot send other status codes such as 302 (redirect).

XXX To do:

- log requests even later (to capture byte count)
- log user-agent header and other interesting goodies
- send error log to separate file
z0.6)�
HTTPServer�ThreadingHTTPServer�BaseHTTPRequestHandler�SimpleHTTPRequestHandler�CGIHTTPRequestHandler�N)�
HTTPStatusaD<!DOCTYPE HTML>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Error response</title>
    </head>
    <body>
        <h1>Error response</h1>
        <p>Error code: %(code)d</p>
        <p>Message: %(message)s.</p>
        <p>Error code explanation: %(code)s - %(explain)s.</p>
    </body>
</html>
ztext/html;charset=utf-8c��\rSrSrSrSrSrg)r��c��[RRU5 URSSup[R
"U5UlX lg)z.Override server_bind to store the server name.N�)�socketserver�	TCPServer�server_bind�server_address�socket�getfqdn�server_name�server_port)�self�host�ports   �2/opt/alt/python313/lib64/python3.13/http/server.pyr�HTTPServer.server_bind�sA�����*�*�4�0��(�(��!�,�
��!�>�>�$�/�����)rrN)�__name__�
__module__�__qualname__�__firstlineno__�allow_reuse_addressr�__static_attributes__�rrrr�s
���� rrc��\rSrSrSrSrg)r�Tr"N)rrrr�daemon_threadsr!r"rrrr�s���Nrrc
�h�\rSrSrSrS\RR5S-rS\	-r
\r\
rSrSrSrS	rS
rS$SjrS%S
jrS%SjrSrSrSrS&SjrSr\R;\R>"\ "S5\ "SS55VVs0sH	oSUS3_M snn5r!S\!\""S5'Sr#Sr$S%Sjr%Sr&/SQr'/S Qr(S!r)S"r*\+RXRZr.\/R`Rc5VVs0sHnX"RdURf4_M snnr4S#r5gs snnfs snnf)'r�a�
HTTP request handler base class.

The following explanation of HTTP serves to guide you through the
code as well as to expose any misunderstandings I may have about
HTTP (so you don't need to read the code to figure out I'm wrong
:-).

HTTP (HyperText Transfer Protocol) is an extensible protocol on
top of a reliable stream transport (e.g. TCP/IP).  The protocol
recognizes three parts to a request:

1. One line identifying the request type and path
2. An optional set of RFC-822-style headers
3. An optional data part

The headers and data are separated by a blank line.

The first line of the request has the form

<command> <path> <version>

where <command> is a (case-sensitive) keyword such as GET or POST,
<path> is a string containing path information for the request,
and <version> should be the string "HTTP/1.0" or "HTTP/1.1".
<path> is encoded using the URL encoding scheme (using %xx to signify
the ASCII character with hex code xx).

The specification specifies that lines are separated by CRLF but
for compatibility with the widest range of clients recommends
servers also handle LF.  Similarly, whitespace in the request line
is treated sensibly (allowing multiple spaces between components
and allowing trailing whitespace).

Similarly, for output, lines ought to be separated by CRLF pairs
but most clients grok LF characters just fine.

If the first line of the request has the form

<command> <path>

(i.e. <version> is left out) then this is assumed to be an HTTP
0.9 request; this form has no optional headers and data part and
the reply consists of just the data.

The reply form of the HTTP 1.x protocol again has three parts:

1. One line giving the response code
2. An optional set of RFC-822-style headers
3. The data

Again, the headers and data are separated by a blank line.

The response code line has the form

<version> <responsecode> <responsestring>

where <version> is the protocol version ("HTTP/1.0" or "HTTP/1.1"),
<responsecode> is a 3-digit response code indicating success or
failure of the request, and <responsestring> is an optional
human-readable string explaining what the response code means.

This server parses the request and the headers, and then calls a
function specific to the request type (<command>).  Specifically,
a request SPAM will be handled by a method do_SPAM().  If no
such method exists the server sends an error response to the
client.  If it exists, it is called with no arguments:

do_SPAM()

Note that the request name is case sensitive (i.e. SPAM and spam
are different requests).

The various request details are stored in instance variables:

- client_address is the client IP address in the form (host,
port);

- command, path and version are the broken-down request line;

- headers is an instance of email.message.Message (or a derived
class) containing the header information;

- rfile is a file object open for reading positioned at the
start of the optional input data part;

- wfile is a file object open for writing.

IT IS IMPORTANT TO ADHERE TO THE PROTOCOL FOR WRITING!

The first thing to be written must be the response line.  Then
follow 0 or more header lines, then a blank line, and then the
actual data (if any).  The meaning of the header lines depends on
the command executed by the server; in most cases, when data is
returned, there should be at least one header line of the form

Content-type: <type>/<subtype>

where <type> and <subtype> should be registered MIME types,
e.g. "text/html" or "text/plain".

zPython/rz	BaseHTTP/�HTTP/0.9c�z�SUlUR=UlnSUl[	UR
S5nUR
S5nX lUR5n[U5S:Xag[U5S:�Ga
USnURS	5(d[eURS
S5SnURS5n[U5S
:wa[e[SU55(a[S5e[SU55(a[S5e[US5[US54nUS:�aUR$S:�aSUlUS:�a$UR[ R&SU-5 gXlS
[U5s=::aS::d&O UR[ R"SU-5 gUSS
upg[U5S
:Xa1SUlUS:wa$UR[ R"SU-5 gXgsUlUlUR(RS5(a#S
UR(R+S
5-Ul[,R.R1UR2UR4S9UlUR6R?SS5n	U	RA5S :XaSUlO+U	RA5S!:XaUR$S:�aSUlUR6R?S"S5n
U
RA5S#:Xa6UR$S:�a&URS:�aURC5(dgg![[4a& UR[ R"SU-5 gf=f![,R.R8a4nUR[ R:S[	U55 SnAgSnAf[,R.R<a4nUR[ R:S[	U55 SnAgSnAff=f)$aParse a request (internal).

The request should be stored in self.raw_requestline; the results
are in self.command, self.path, self.request_version and
self.headers.

Return True for success, False for failure; on failure, any relevant
error response has already been sent back.

NTz
iso-8859-1�
rF����zHTTP/�/r�.r
c3�J# �UHoR5(+v� M g7f�N)�isdigit��.0�	components  r�	<genexpr>�7BaseHTTPRequestHandler.parse_request.<locals>.<genexpr>/s���O��9�,�,�.�.�.��s�!#znon digit in http versionc3�># �UHn[U5S:�v� M g7f)�
N)�lenr2s  rr5r61s���K�N�y�s�9�~��*�N�s�z unreasonable length http versionzBad request version (%r))rrzHTTP/1.1)r
rzInvalid HTTP version (%s)zBad request syntax (%r)�GETzBad HTTP/0.9 request type (%r)z//)�_classz
Line too longzToo many headers�
Connection��close�
keep-alive�Expectz100-continue)"�command�default_request_version�request_version�close_connection�str�raw_requestline�rstrip�requestline�splitr9�
startswith�
ValueError�any�int�
IndexError�
send_errorr�BAD_REQUEST�protocol_version�HTTP_VERSION_NOT_SUPPORTED�path�lstrip�http�client�
parse_headers�rfile�MessageClass�headers�LineTooLong�REQUEST_HEADER_FIELDS_TOO_LARGE�
HTTPException�get�lower�handle_expect_100)r�versionrH�words�base_version_number�version_numberrArS�err�conntype�expects           r�
parse_request�$BaseHTTPRequestHandler.parse_requests������)-�)E�)E�E���w� $����$�.�.��=��!�(�(��0��&���!�!�#���u�:��?���u�:��?��B�i�G�
��)�)�'�2�2�$�$�&-�m�m�C��&;�A�&>�#�!4�!:�!:�3�!?���~�&�!�+�$�$��O��O�O�O�$�%@�A�A��K�N�K�K�K�$�%G�H�H�!$�^�A�%6�!7��^�A�=N�9O�!O����'�D�,A�,A�Z�,O�(-��%���'�����9�9�/�2E�E�G��#*� ��C��J�#�!�#��O�O��&�&�)�K�7�
9���b�q�	�
���u�:��?�$(�D�!��%������*�*�4�w�>�@��")����d�i��9�9����%�%��d�i�i�.�.�s�3�3�D�I�	��;�;�4�4�T�Z�Z�<@�<M�<M�5�O�D�L� �<�<�#�#�L�"�5���>�>��w�&�$(�D�!��n�n��,�.��#�#�z�1�$)�D�!����!�!�(�B�/���L�L�N�n�,��%�%��3��$�$�
�2��)�)�+�+����G�
�+�
�����*�*�.��8�:��	
��P�{�{�&�&�	��O�O��:�:���C��
����{�{�(�(�	��O�O��:�:�"��C��
�
��
	�s7�B7M�7N�3N�N�P:�6*O%�%!P:�*P5�5P:c�b�UR[R5 UR5 g)a�Decide what to do with an "Expect: 100-continue" header.

If the client is expecting a 100 Continue response, we must
respond with either a 100 Continue or a final response before
waiting for the request body. The default is to always respond
with a 100 Continue. You can behave differently (for example,
reject unauthorized requests) by overriding this method.

This method should either return True (possibly after sending
a 100 Continue response) or send an error response and return
False.

T)�send_response_onlyr�CONTINUE�end_headers�rs rr`�(BaseHTTPRequestHandler.handle_expect_100ys'��	
���
� 3� 3�4�����rc��URRS5Ul[UR5S:�a5SUlSUlSUlUR[R5 gUR(dSUl
gUR5(dgSUR-n[X5(d.UR[RSUR-5 g[X5nU"5 URR!5 g!["a#nUR%SU5 SUl
SnAgSnAff=f)	z�Handle a single HTTP request.

You normally don't need to override this method; see the class
__doc__ string for information on how to handle specific HTTP
commands such as GET and POST.

iir=NT�do_zUnsupported method (%r)zRequest timed out: %r)rX�readlinerFr9rHrCrArOr�REQUEST_URI_TOO_LONGrDrh�hasattr�NOT_IMPLEMENTED�getattr�wfile�flush�TimeoutError�	log_error)r�mname�method�es    r�handle_one_request�)BaseHTTPRequestHandler.handle_one_request�s��	�#'�:�:�#6�#6�u�#=�D� ��4�'�'�(�5�0�#%�� �')��$�!������
� ?� ?�@���'�'�(,��%���%�%�'�'���D�L�L�(�E��4�'�'�����.�.�-����<�>���T�)�F��H��J�J������	��N�N�2�A�6�$(�D�!���		�s1�A-D�0D�	D�AD�,,D�
E�#E�Ec��SUlUR5 UR(d$UR5 UR(dM#gg)z&Handle multiple requests if necessary.TN)rDr~rns r�handle�BaseHTTPRequestHandler.handle�s9�� $������!��'�'��#�#�%��'�'�'rNc���URUupEUcUnUcUnURSX5 URX5 UR	SS5 SnUS:�a�U[
R[
R[
R4;a�URU[R"USS9[R"USS9S	.-nURS
S5nUR	SUR5 UR	S
[[U555 UR!5 UR"S:wa$U(aUR$R'U5 ggg![a SupEGN[f=f)aSend and log an error reply.

Arguments are
* code:    an HTTP error code
           3 digits
* message: a simple optional 1 line reason phrase.
           *( HTAB / SP / VCHAR / %x80-FF )
           defaults to short entry matching the response code
* explain: a detailed message defaults to the long entry
           matching the response code.

This sends an error response (so it must be called before any
output has been generated), logs the error, and finally sends
a piece of HTML explaining the error to the user.

)�???r�Nzcode %d, message %sr<r>��F��quote)�code�message�explainzUTF-8�replacezContent-Type�Content-Length�HEAD)�	responses�KeyErrorrz�
send_response�send_headerr�
NO_CONTENT�
RESET_CONTENT�NOT_MODIFIED�error_message_format�html�escape�encode�error_content_typerEr9rmrArw�write)rr�r�r��shortmsg�longmsg�body�contents        rrO�!BaseHTTPRequestHandler.send_error�sV��$	-� $���t� 4��H��?��G��?��G����,�d�<����4�)�����w�/�
���C�K���.�.�#�1�1�#�0�0�2�
2�
�0�0���;�;�w�e�<��;�;�w�e�<�4��G�
�>�>�'�9�5�D����^�T�-D�-D�E����-�s�3�t�9�~�>������<�<�6�!�d��J�J���T�"�'+�!��=�	-� ,��H�g�	-�s�E�E/�.E/c���URU5 URX5 URSUR55 URSUR	55 g)z�Add the response header to the headers buffer and log the
response code.

Also send two standard headers with the server software
version and the current date.

�Server�DateN)�log_requestrkr��version_string�date_time_string�rr�r�s   rr��$BaseHTTPRequestHandler.send_response�sR��	
���������.�����4�#6�#6�#8�9������!6�!6�!8�9rc��URS:wazUc$XR;aURUSnOSn[US5(d/UlURR	SUR
X4-R
SS55 gg)	zSend the response header only.r(Nrr=�_headers_bufferz
%s %d %s
�latin-1�strict)rCr�rtr��appendrQr�r�s   rrk�)BaseHTTPRequestHandler.send_response_only�s������:�-����>�>�)�"�n�n�T�2�1�5�G� �G��4�!2�3�3�')��$�� � �'�'���*�*�D�:�*;�<B�F�!�8�=-�
.�.rc�T�URS:waK[US5(d/UlURRU<SU<S3R	SS55 UR5S:Xa9UR5S:XaS	UlgUR5S
:XaSUlggg)
z)Send a MIME header to the headers buffer.r(r�z: r*r�r��
connectionr>Tr?FN)rCrtr�r�r�r_rD)r�keyword�values   rr��"BaseHTTPRequestHandler.send_headers������:�-��4�!2�3�3�')��$�� � �'�'�!(�%�0�8�8��H�M�
O��=�=�?�l�*��{�{�}��'�(,��%�����,�.�(-��%�/�+rc�|�URS:wa,URRS5 UR5 gg)z,Send the blank line ending the MIME headers.r(s
N)rCr�r��
flush_headersrns rrm�"BaseHTTPRequestHandler.end_headerss5�����:�-�� � �'�'��0���� �.rc��[US5(a<URRSRUR55 /Ulgg)Nr�r)rtrwr��joinr�rns rr��$BaseHTTPRequestHandler.flush_headerss>���4�*�+�+��J�J���S�X�X�d�&:�&:�;�<�#%�D� �,rc��[U[5(aURnURSUR[U5[U55 g)z>Log an accepted request.

This is called by send_response().

z
"%s" %s %sN)�
isinstancerr��log_messagerHrE)rr��sizes   rr��"BaseHTTPRequestHandler.log_request!s@���d�J�'�'��:�:�D������)�)�3�t�9�c�$�i�	Arc�*�UR"U/UQ76 g)z�Log an error.

This is called when a request cannot be fulfilled.  By
default it passes the message on to log_message().

Arguments are the same as for log_message().

XXX This should go to the separate error log.

N)r�)r�format�argss   rrz� BaseHTTPRequestHandler.log_error,s��	
����'�$�'r� ��z\x�02xz\\�\c	���X-n[RRUR5<SUR	5<SURUR5<S35 g)a�Log an arbitrary message.

This is used by all other logging functions.  Override
it if you have specific logging wishes.

The first argument, FORMAT, is a format string for the
message to be logged.  If the format string contains
any % escapes requiring parameters, they should be
specified as subsequent arguments (it's just like
printf!).

The client ip and current date/time are prefixed to
every message.

Unicode control characters are replaced with escaped hex
before writing the output to stderr.

z - - [z] �
N)�sys�stderrr��address_string�log_date_time_string�	translate�_control_char_table)rr�r�r�s    rr��"BaseHTTPRequestHandler.log_message?sP��(�-���
�
����-�-�/��3�3�5�!�+�+�D�,D�,D�E�G�	Hrc�:�URS-UR-$)z*Return the server software version string.� )�server_version�sys_versionrns rr��%BaseHTTPRequestHandler.version_stringYs���"�"�S�(�4�+;�+;�;�;rc�n�Uc[R"5n[RRUSS9$)z@Return the current date and time formatted for a message header.T)�usegmt)�time�email�utils�
formatdate)r�	timestamps  rr��'BaseHTTPRequestHandler.date_time_string]s-�����	�	��I��{�{�%�%�i��%�=�=rc	��[R"5n[R"U5u	p#pEpgp�n
SX@RUX%Xg4-nU$)z.Return the current time formatted for logging.z%02d/%3s/%04d %02d:%02d:%02d)r��	localtime�	monthname)r�now�year�month�day�hh�mm�ss�x�y�z�ss            rr��+BaseHTTPRequestHandler.log_date_time_stringcsJ���i�i�k��04���s�0C�-��S�b�a�A�*��^�^�E�*�D�b�.>�
>���r)�Mon�Tue�Wed�Thu�Fri�Sat�Sun)
N�Jan�Feb�Mar�Apr�May�Jun�Jul�Aug�Sep�Oct�Nov�Decc� �URS$)zReturn the client address.r)�client_addressrns rr��%BaseHTTPRequestHandler.address_stringqs���"�"�1�%�%r�HTTP/1.0)r�rDrArZrSrFrCrH)NNr0)�-r)6rrrr�__doc__r�rarIr��__version__r��DEFAULT_ERROR_MESSAGEr��DEFAULT_ERROR_CONTENT_TYPEr�rBrhr`r~r�rOr�rkr�rmr�r�rzrE�	maketrans�	itertools�chain�ranger��ordr�r�r�r��weekdaynamer�r�rQrUrV�HTTPMessagerYr�__members__�values�phrase�descriptionr�r!)r3�c�vs000rrr�sk��d�N�c�k�k�/�/�1�!�4�4�K�
!�;�.�N�0��3��)��l�\�$#�J&�3#�j:�.�.�!�&�
	A�(��-�-�'0���u�T�{�E�$�t�DT�'U�V�'U�!�2�a��W�
�
�'U�V�X��%*���D�	�"�H�4<�>��D�K�;�I�&�"���;�;�*�*�L�
�'�'�.�.�0��0�A�	
�H�H�a�m�m�$�$�0��I��I
W��Hs�D(
�?"D.rc�~^�\rSrSrSrS\-rSrSSSSS	.=rr	S
S.U4Sjjr
S
rSrSr
SrSrSrSrSrU=r$)ri�a?Simple HTTP request handler with GET and HEAD commands.

This serves files from the current directory and any of its
subdirectories.  The MIME type for files is determined by
calling the .guess_type() method.

The GET and HEAD requests are identical except that the HEAD
request omits the actual contents of the file.

zSimpleHTTP/)z
index.htmlz	index.htmzapplication/gzip�application/octet-streamzapplication/x-bzip2zapplication/x-xz)z.gzz.Zz.bz2z.xzN��	directoryc�>�Uc[R"5n[R"U5Ul[TU]"U0UD6 gr0)�os�getcwd�fspathr�super�__init__)rrr��kwargs�	__class__s    �rr�!SimpleHTTPRequestHandler.__init__�s6������	�	��I����9�-���
���$�)�&�)rc��UR5nU(a-URXR5 UR5 gg!UR5 f=f)zServe a GET request.N)�	send_head�copyfilerwr>�r�fs  r�do_GET�SimpleHTTPRequestHandler.do_GET�sA���N�N����
��
�
�a���,����	�	
�����	�s�A�Ac�T�UR5nU(aUR5 gg)zServe a HEAD request.N)r#r>r%s  r�do_HEAD� SimpleHTTPRequestHandler.do_HEAD�s���N�N����
�G�G�I�
rc�^�URUR5nSn[RRU5(Ga@[R
R
UR5nURRS5(d�UR[R5 USUSUSS-USUS4n[R
RU5nURSU5 URS	S
5 UR5 gURHJn[RRX5n[RR!U5(dMHUn O UR#U5$UR%U5nURS5(a!UR'[R(S5 g[+US5n[R."UR155nS
UR2;Ga/SUR2;Ga[4R6R9UR2S
5n	U	R:c'U	R=[>R@RBS9n	U	R:[>R@RBLa�[>R>REURF[>R@RB5n
U
R=SS9n
X�::a@UR[RH5 UR5 URK5 gUR[RT5 URSU5 URS	[WUS55 URSURYURF55 UR5 U$![,a# UR'[R(S5 gf=f![L[N[P[R4a N�f=f! URK5 e=f)aKCommon code for GET and HEAD commands.

This sends the response code and MIME headers.

Return value is either a file object (which has to be copied
to the outputfile by the caller unless the command was HEAD,
and must be closed by the caller under all circumstances), or
None, in which case the caller has nothing further to do.

Nr-rrr
r+��Locationr��0zFile not found�rbzIf-Modified-Sincez
If-None-Match)�tzinfo)�microsecond�Content-type�z
Last-Modified)-�translate_pathrSr�isdir�urllib�parse�urlsplit�endswithr�r�MOVED_PERMANENTLY�
urlunsplitr�rm�index_pagesr��isfile�list_directory�
guess_typerO�	NOT_FOUND�open�OSError�fstat�filenorZr�r��parsedate_to_datetimer1r��datetime�timezone�utc�
fromtimestamp�st_mtimer�r>�	TypeErrorrN�
OverflowErrorrK�OKrEr�)rrSr&�parts�	new_parts�new_url�index�ctype�fs�ims�
last_modifs           rr#�"SimpleHTTPRequestHandler.send_head�sJ���"�"�4�9�9�-����
�7�7�=�=�����L�L�)�)�$�)�)�4�E��:�:�&�&�s�+�+��"�"�:�#?�#?�@�"�1�X�u�Q�x��q��C��"�1�X�u�Q�x�1�	� �,�,�1�1�)�<��� � ��W�5�� � �!1�3�7�� � �"���)�)�������T�1���7�7�>�>�%�(�(� �D��	*��*�*�4�0�0�����%���=�=�����O�O�J�0�0�2B�C��	��T�4� �A�
'	����!�(�(�*�%�B�#�t�|�|�3�'�t�|�|�;�(��+�+�;�;����%8�9�;�C��z�z�)�"�k�k��1B�1B�1F�1F�k�G���z�z�X�%6�%6�%:�%:�:�%-�%6�%6�%D�%D��K�K��):�):�)>�)>�&@�
�&0�%7�%7�A�%7�%F�
�%�,� �.�.�z�/F�/F�G� �,�,�.��G�G�I�#'����z�}�}�-����^�U�3����-�s�2�a�5�z�:����_��%�%�b�k�k�2�
4������H��Q�	��O�O�J�0�0�2B�C��	��"�:�}�j�I�����8	�
�G�G�I��sK�O	�AP� ,O9�C0P�=BP�	*O6�5O6�9P�P�P�P�P,c��[R"U5nUR
SS9 /n[RRURSS9n[R"USS9n[R"5nS	U3nUR!S
5 UR!S5 UR!S5 UR!S
US35 UR!SUS35 UR!SUS35 UR!S5 UH�n[RR#X5nU=p�[RR%U5(a
US-n	US-n
[RR'U5(aUS-n	UR!S[RR)U
SS9<S[R"U	SS9<S35 M� UR!S5 SR#U5R+US5n[,R."5nUR1U5 UR3S5 UR5[R65 UR9SSU-5 UR9S[;[=U555 UR?5 U$![a# UR[R
S5 gf=f![a- [RRUR5nGN�f=f)z�Helper to produce a directory listing (absent index.html).

Return value is either a file object, or None (indicating an
error).  In either case, the headers are sent, making the
interface the same as for send_head().

zNo permission to list directoryNc�"�UR5$r0)r_)�as r�<lambda>�9SimpleHTTPRequestHandler.list_directory.<locals>.<lambda>s
�����	r)�key�
surrogatepass��errorsFr�zDirectory listing for z<!DOCTYPE HTML>z<html lang="en">z<head>z<meta charset="z">z<title>z</title>
</head>z<body>
<h1>z</h1>z	<hr>
<ul>r-�@z
<li><a href="z	</a></li>z</ul>
<hr>
</body>
</html>
r��surrogateescaperr3ztext/html; charset=%sr�) r�listdirrCrOrrA�sortr7r8�unquoterS�UnicodeDecodeErrorr�r�r��getfilesystemencodingr�r�r6�islinkr�r��io�BytesIOr��seekr�rNr�rEr9rm)
rrS�list�r�displaypath�enc�title�name�fullname�displayname�linkname�encodedr&s
             rr?�'SimpleHTTPRequestHandler.list_directory	s���	��:�:�d�#�D�	
�	�	�)�	�*���	:� �,�,�.�.�t�y�y�6E�/�G�K��k�k�+�U�;���'�'�)��(��
�6��	���"�#�	���#�$�	�����	���?�3�%�r�*�+�	���7�5�'�!2�3�4�	���<��w�e�,�-�	������D��w�w�|�|�D�/�H�%)�)�K��w�w�}�}�X�&�&�"�S�j���#�:���w�w�~�~�h�'�'�"�S�j��
�H�H��|�|�)�)�(�1@�*�B��{�{�;�e�<�>�
?��	
���2�3��)�)�A�,�%�%�c�+<�=���J�J�L��	�����	���q�	����:�=�=�)�����)@�3�)F�G����)�3�s�7�|�+<�=��������[�	��O�O��$�$�1�
3��		��"�	:� �,�,�.�.�t�y�y�9�K�	:�s"�J#�(K�#*K�K�3L
�	L
c��URSS5SnURSS5SnUR5RS5n[RRUSS9n[R"U5nURS5n[SU5nURnUHln[RRU5(d$U[R[R4;aMM[RR!X5nMn U(aUS-
nU$![a" [RRU5nN�f=f)	z�Translate a /-separated PATH to the local filename syntax.

Components that mean special things to the local file system
(e.g. drive or directory names) are ignored.  (XXX They should
probably be diagnosed.)

�?rr�#r-r^r_N)rIrGr:r7r8rerf�	posixpath�normpath�filterrrrS�dirname�curdir�pardirr�)rrS�trailing_slashrb�words     rr5�'SimpleHTTPRequestHandler.translate_pathBs���z�z�#�a� ��#���z�z�#�a� ��#������/�/��4��	.��<�<�'�'��_�'�E�D��!�!�$�'���
�
�3����t�U�#���~�~���D��w�w���t�$�$�����B�I�I�0F�(F���7�7�<�<��+�D�	�
��C�K�D����"�	.��<�<�'�'��-�D�	.�s�D(�()E�Ec�0�[R"X5 g)a�Copy all data between two file objects.

The SOURCE argument is a file object open for reading
(or anything with a read() method) and the DESTINATION
argument is a file object open for writing (or
anything with a write() method).

The only reason for overriding this would be to change
the block size or perhaps to replace newlines by CRLF
-- note however that this the default server uses this
to copy binary data as well.

N)�shutil�copyfileobj)r�source�
outputfiles   rr$�!SimpleHTTPRequestHandler.copyfile`s��	���6�.rc��[R"U5up#X0R;aURU$UR5nX0R;aURU$[R
"U5upEU(aU$g)a{Guess the type of a file.

Argument is a PATH (a filename).

Return value is a string of the form type/subtype,
usable for a MIME Content-type header.

The default implementation looks the file's extension
up in the table self.extensions_map, using application/octet-stream
as a default; however it would be permissible (if
slow) to look inside the data to make a better guess.

r)rz�splitext�extensions_mapr_�	mimetypes�guess_file_type)rrS�base�ext�guess�_s      rr@�#SimpleHTTPRequestHandler.guess_typepsx���&�&�t�,�	���%�%�%��&�&�s�+�+��i�i�k���%�%�%��&�&�s�+�+��,�,�T�2�����L�)r)rrrrrrr�r=r��_encodings_map_defaultrr'r*r#r?r5r$r@r!�
__classcell__�r s@rrr�sn���	�#�[�0�N�-�K�!�(�%�!�	/��N�+�)-�*�*���V�p7�r�</� *�*rrc�"�URS5upn[RRU5nUR	S5n/nUSSH=nUS:XaUR5 MU(dM$US:wdM,UR
U5 M? U(a9UR5nU(a!US:XaUR5 SnOUS:XaSnOSnU(aSRXb45nSSRU5-U4nSRU5nU$)a�
Given a URL path, remove extra '/'s and '.' path elements and collapse
any '..' references and returns a collapsed path.

Implements something akin to RFC-2396 5.2 step 6 to parse relative paths.
The utility of this function is limited to is_cgi method and helps
preventing some security attacks.

Returns: The reconstituted URL, which will always start with a '/'.

Raises: IndexError if too many '..' occur within the path.

rxr-Nr,z..r.r=)�	partitionr7r8rerI�popr�r�)	rSr��query�
path_parts�
head_parts�part�	tail_part�	splitpath�collapsed_paths	         r�_url_collapse_pathr��s����^�^�C�(�N�D�U��<�<����%�D����C��J��J��3�B����4�<��N�N��
�T�d�c�k����t�%�	 �
��N�N�$�	���D� ���� ��	��c�!��	���	���H�H�i�/�0�	��s�x�x�
�+�+�Y�7�I��X�X�i�(�N��rc���[(a[$SSKnURS5Sq[$![a gf=f![a+ S[SUR
555-q[$f=f)z$Internal routine to get nobody's uidrNr,�nobodyr
rc3�*# �UH	oSv� M g7f)r
Nr")r3r�s  rr5�nobody_uid.<locals>.<genexpr>�s���6�~�!�1��~�s�)r��pwd�ImportError�getpwnamr��max�getpwall)r�s r�
nobody_uidr��sy���v��
���7����h�'��*���M��
������7��S�6�s�|�|�~�6�6�6���M�7�s�2�A�
?�?�-A7�6A7c�L�[R"U[R5$)zTest for executable file.)r�access�X_OK)rSs r�
executabler��s��
�9�9�T�2�7�7�#�#rc�n^�\rSrSrSrU4Sjr\"\S5rSr	Sr
SrSrS	S
/r
SrSrS
rSrU=r$)ri�z�Complete HTTP server with GET, HEAD and POST commands.

GET and HEAD also support running CGI scripts.

The POST command is *only* implemented for CGI scripts.

c�N>�SSKnURSSS9 [TU]"U0UD6 g)Nrz!http.server.CGIHTTPRequestHandler)r+�)�remove)�warnings�_deprecatedrr)rr�rr�r s    �rr�CGIHTTPRequestHandler.__init__�s1�������@�$+�	�	-�
���$�)�&�)r�forkrc��UR5(aUR5 gUR[RS5 g)zBServe a POST request.

This is only implemented for CGI scripts.

zCan only POST to CGI scriptsN)�is_cgi�run_cgirOrrurns r�do_POST�CGIHTTPRequestHandler.do_POST�s0���;�;�=�=��L�L�N��O�O��*�*�.�
0rc�v�UR5(aUR5$[RU5$)z-Version of send_head that support CGI scripts)r�r�rr#rns rr#�CGIHTTPRequestHandler.send_head�s*���;�;�=�=��<�<�>�!�+�5�5�d�;�;rc��[UR5nURSS5nUS:�aCUSUUR;a0URSUS-5nUS:�aUSUUR;aM0US:�aUSUXS-SpCX44Ulgg)a�Test whether self.path corresponds to a CGI script.

Returns True and updates the cgi_info attribute to the tuple
(dir, rest) if self.path requires running a CGI script.
Returns False otherwise.

If any exception is raised, the caller should assume that
self.path was rejected as invalid and act accordingly.

The default implementation tests whether the normalized url
path begins with one of the strings in self.cgi_directories
(and the next character is a '/' or the end of the string).

r-rrNTF)r�rS�find�cgi_directories�cgi_info)rr��dir_sep�head�tails     rr��CGIHTTPRequestHandler.is_cgi�s���,�D�I�I�6�� �%�%�c�1�-����k�.��'�":�d�>R�>R�"R�$�)�)�#�w�q�y�9�G���k�.��'�":�d�>R�>R�"R��Q�;�'���1�>�!�)�*�3M�$� �J�D�M��rz/cgi-binz/htbinc��[U5$)z1Test whether argument path is an executable file.)r�)rrSs  r�
is_executable�#CGIHTTPRequestHandler.is_executables
���$��rc�j�[RRU5up#UR5S;$)z.Test whether argument path is a Python script.)z.pyz.pyw)rrSr�r_)rrSr�r�s    r�	is_python�CGIHTTPRequestHandler.is_pythons)���W�W�%�%�d�+�
���z�z�|��.�.rc���URupUS-U-nURS[U5S-5nUS:�akUSUnX4S-SnURU5n[R
R
U5(a!XVp!URS[U5S-5nOOUS:�aMkURS5up(n	URS5nUS:�a	USUX$Sp*OUSp*US-U
-nURU5n[R
RU5(d$UR[RSU-5 g[R
RU5(d$UR[RSU-5 gURU5n
UR(dU
(d:UR!U5(d$UR[RS	U-5 g["R$"[R&5nUR)5US
'UR*R,US'SUS
'UR.US'[1UR*R25US'UR4US'[6R8R;U5nX�S'URU5US'X�S'X�S'UR<SUS'UR>RAS5nU(a�URC5n[U5S:Xa�SSK"nSSK#nUSUS'USRI5S:Xa]USRKS5nURMU5ROS5nURCS5n[U5S:XaUSUS'UR>RAS5cUR>RU5US'OUR>SUS'UR>RAS5nU(aUUS 'UR>RAS!5nU(aUUS"'UR>RWS#S$5nS%RYU5US&'UR>RAS'5nU(aUUS('[[SUR>RWS)/55nS*RYU5nU(aUUS+'S,HnUR]US5 M UR_[R`S-5 URc5 U	ReS.S/5nUR(Ga�U
/nS0U;aURgU5 [i5nURjRm5 [Rn"5nUS:wa�[Rp"US5unn[rRr"URt///S5S(aOURtRwS5(dO.[rRr"URt///S5S(aMO[Rx"U5nU(aUR{S1U35 g[R|"U5 [R�"URtR�5S5 [R�"URjR�5S5 [R�"UUU5 gSSKFn U/n!URU5(aF[�R�n"U"RI5R�S35(aU"SS4U"S5S-n"U"S6/U!-n!S0U	;aU!RgU	5 UR�S7U R�U!55 [�U5n#U R�U!U R�U R�U R�US89n$UR4RI5S9:Xa"U#S:�aURtRwU#5n%OSn%[rRr"URtR�///S5S(acURtR�R�S5(dO8[rRr"URtR�///S5S(aMcU$R�U%5un&n'URjR�U&5 U'(aUR{S:U'5 U$R�R�5 U$R�R�5 U$R�n(U((aUR{S;U(5 gUR�S<5 g!URP[R4a GN�f=f![~a GNf=f! UR*R�UR�UR<5 [R�"S25 g=f![�[�4a Sn#GNPf=f)=zExecute a CGI script.r-rrNrxr=zNo such CGI script (%r)z#CGI script is not a plain file (%r)z!CGI script is not executable (%r)�SERVER_SOFTWARE�SERVER_NAMEzCGI/1.1�GATEWAY_INTERFACE�SERVER_PROTOCOL�SERVER_PORT�REQUEST_METHOD�	PATH_INFO�PATH_TRANSLATED�SCRIPT_NAME�QUERY_STRING�REMOTE_ADDR�
authorizationr
�	AUTH_TYPE�basic�ascii�:�REMOTE_USERzcontent-type�CONTENT_TYPEzcontent-length�CONTENT_LENGTH�referer�HTTP_REFERER�acceptr"�,�HTTP_ACCEPTz
user-agent�HTTP_USER_AGENT�cookiez, �HTTP_COOKIE)r��REMOTE_HOSTr�r�r�r�zScript output follows�+r��=zCGI script exit code r�zw.exe������z-uzcommand: %s)�stdin�stdoutr��env�postz%szCGI script exit status %#xzCGI script exited OK)Yr�r�r9r5rrSr6r��existsrOrrAr>�	FORBIDDENr��	have_forkr��copy�deepcopy�environr��serverrrQrErrAr7r8rerrZr^rI�base64�binasciir_r��decodebytes�decode�Error�UnicodeError�get_content_type�get_allr�r|�
setdefaultr�rNr�r�r�r�rwrxr��waitpid�selectrX�read�waitstatus_to_exitcoderz�setuidrC�dup2rE�execve�handle_error�request�_exit�
subprocessr�r�r:r��list2cmdlinerMrLrK�Popen�PIPE�_sock�recv�communicater�r�r>r��
returncode))r�dir�restrS�i�nextdir�nextrest�	scriptdirr�r��script�
scriptname�
scriptfile�ispyr��uqrestr�r�r��lengthr�r��ua�co�
cookie_str�k�
decoded_queryr�r��pid�sts�exitcoder�cmdline�interp�nbytes�p�datar�r��statuss)                                         rr��CGIHTTPRequestHandler.run_cgi$sB���M�M�	���S�y�4����I�I�c�3�s�8�A�:�&���1�f��2�A�h�G��a�C�D�z�H��+�+�G�4�I��w�w�}�}�Y�'�'�#�T��I�I�c�3�s�8�A�:�.����1�f�����,����
�I�I�c�N����6����8�T�"�X�D���D��3�Y��'�
��(�(��4�
��w�w�~�~�j�)�)��O�O��$�$�)�J�6�
8�
��w�w�~�~�j�)�)��O�O��$�$�5�
�B�
D�
��~�~�j�)���>�>���%�%�j�1�1�����(�(�7�*�D�F���m�m�B�J�J�'��!%�!4�!4�!6����!�[�[�4�4��M��#,��� �!%�!6�!6���� ����!8�!8�9��M�� $���������%�%�d�+��!�K��!%�!4�!4�V�!<����'�M��#�N��!�0�0��3��M�����(�(��9�
��)�/�/�1�M��=�!�Q�&�'�#0��#3��K� � ��#�)�)�+�w�6�	B�(5�a�(8�(?�(?��(H�
�(.�(:�(:�=�(I�(.��w��&�
)6�(;�(;�C�(@�
��}�-��2�1>�q�1A�C�
�.��<�<���N�+�3�"&�,�,�"?�"?�"A�C���"&�,�,�~�">�C������!�!�"2�3���$*�C� �!��,�,�"�"�9�-���")�C������%�%�h��3�� �X�X�f�-��M��
�\�\�
�
�l�
+��
�%'�C�!�"�
�D�$�,�,�.�.�x��<�
=���Y�Y�r�]�
��!+�C�
��D�A��N�N�1�b�!�D�	
���:�=�=�*A�B������
�
�c�3�/�
��>�>�>��8�D��-�'����M�*��\�F��J�J�����'�'�)�C��a�x��:�:�c�1�-���S��m�m�T�Z�Z�L�"�b�!�<�Q�?��:�:�?�?�1�-�-���m�m�T�Z�Z�L�"�b�!�<�Q�?�?��4�4�S�9����N�N�%:�8�*�#E�F��

���I�I�f�%�����
�
�)�)�+�Q�/�����
�
�)�)�+�Q�/��	�	�*�d�C�0�
�!�l�G��~�~�j�)�)������<�<�>�*�*�7�3�3�#�C�R�[�6�"�#�;�6�F�!�4�.�7�2���%�����u�%����]�J�,C�,C�G�,L�M�
��V���� � ��'1���(2���(2���'*�	!�#�A��|�|�!�!�#�v�-�&�1�*��z�z���v�.�����-�-����!1�!1� 2�B��A�>�q�A��z�z�'�'�,�,�Q�/�/���-�-����!1�!1� 2�B��A�>�q�A�A��]�]�4�0�N�F�F��J�J���V�$�����t�V�,�
�H�H�N�N��
�H�H�N�N���\�\�F�����;�V�D�� � �!7�8��_%�N�N�L�9�����z�����

����(�(����t�7J�7J�K�����
��"�z�*�
���
�sP�84e
�e*�/A6e;�g�
e'�&e'�*
e8�4e;�7e8�8e;�;Ag�g�g)r�)rrrrrrrtrr��rbufsizer�r#r�r�r�r�r�r!r�r�s@rrr�sS����*���F�#�I��H�0�<��4"�8�,�O� �/�
x9�x9rrc��[R"U[R[RS.6n[	[U55up#pEnX&4$)N)�type�flags)r�getaddrinfo�SOCK_STREAM�
AI_PASSIVE�next�iter)�address�infos�familyr0�proto�	canonname�sockaddrs       r�_get_best_familyr=�sG�����	�
�
�
����
�E�
04�D��K�/@�,�F�%�H���rri@c��[XC5uUlnX lU"XP5nURR	5SSupsSU;aSUS3OUn[SUSUSUSUS	3	5 UR
5 SSS5 g![a$ [S
5 [R"S5 N6f=f!,(df   g=f)zeTest the HTTP request handler class.

This runs an HTTP server on port 8000 (or the port argument).

Nr
r��[�]zServing HTTP on z port z	 (http://z/) ...z&
Keyboard interrupt received, exiting.r)
r=�address_familyrQr�getsockname�print�
serve_forever�KeyboardInterruptr��exit)	�HandlerClass�ServerClass�protocolr�bind�addr�httpdr�url_hosts	         r�testrN�s���(8��'C�$�K���$,�!�	�T�	(�E��\�\�-�-�/���3�
��"%��+�Q�t�f�A�;�4��
��t�f�F�4�&�1��j��$��v�
/�	
�	����!�
)�	(��!�	��;�<��H�H�Q�K�	��
)�	(�s*�AB3�)B�+B0�-B3�/B0�0B3�3
C�__main__z--cgi�
store_truezrun as CGI server)�action�helpz-bz--bind�ADDRESSz.bind to this address (default: all interfaces))�metavarrRz-dz--directoryz1serve this directory (default: current directory))�defaultrRz-pz
--protocol�VERSIONz3conform to this HTTP version (default: %(default)s))rTrUrRrrxz(bind to this port (default: %(default)s))rUr0�nargsrRc�.^�\rSrSrU4SjrSrSrU=r$)�DualStackServeric�>�[R"[5 URR	[R
[RS5 SSS5 [TU]!5$!,(df   N=f)Nr)	�
contextlib�suppress�	Exceptionr�
setsockopt�IPPROTO_IPV6�IPV6_V6ONLYrr)rr s �rr�DualStackServer.server_bindsU����$�$�Y�/����&�&��'�'��);�);�Q�@�0��7�&�(�(�0�/�s�:A,�,
A:c�B�URXU[RS9 g)Nr)�RequestHandlerClassr�r)rr	rs   r�finish_request�DualStackServer.finish_request$s ���$�$�W�d�/3�~�~�
%�
?rr")rrrrrrdr!r�r�s@rrYrYs���	)�	?�	?rrY)rGrHrrJrI)8rr�__all__r�rG�email.utilsr�r��http.clientrUrir	r�rrzrr�rrr�r��urllib.parser7rrrrr�ThreadingMixInr�StreamRequestHandlerrrr�r�r�r�rr=rNr�argparser[�ArgumentParser�parser�add_argumentrrM�
parse_argsr��cgi�
handler_classrYrrJrIr"rr�<module>rss���d����
�����	���	��
�
�
��
������ 7��	 ��'�'�	 ��,�5�5�z��q�\�>�>�q�hA*�5�A*�L,�`
��
� $�
I9�4�I9�X�-�(��4�d��.�z����
�
$�
$�
&�F�
�����0��2�
����h�	�9��:�����m�R�Y�Y�[�<��=�����l�I� *�6��7������3�c�6��7�����D��x�x�-�
�0�
�?�-�?�	�"�#�
�Y�Y�
�Y�Y�����Qr

?>