OwlCyberSecurity - MANAGER
Edit File: BaseHTTPServer.pyo
� zfc�����������@���s ��d��Z��d�Z�d�d�g�Z�d�d�l�Z�d�d�l�Z�d�d�l�Z�d�d�l�m�Z�m�Z�e�����-�e�j �rx�e�d�d�e ���n��d�d�l�Z�Wd�QXd�d�l�Z�d �Z �d �Z�d����Z�d�e�j�f�d�������YZ�d�e�j�f�d �������YZ�e�e�d�d���Z�e�d�k�re����n��d�S(���s ��HTTP server base class. Note: the class in this module doesn't implement any HTTP request; see SimpleHTTPServer for simple implementations of GET, HEAD and POST (including CGI scripts). It does, however, optionally implement HTTP/1.1 persistent connections, as of version 0.3. Contents: - BaseHTTPRequestHandler: HTTP request handler base class - test: test function 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 s���0.3t ���HTTPServert���BaseHTTPRequestHandleri����N(���t���filterwarningst���catch_warningst���ignores���.*mimetools has been removeds����<head> <title>Error response</title> </head> <body> <h1>Error response</h1> <p>Error code %(code)d. <p>Message: %(message)s. <p>Error code explanation: %(code)s = %(explain)s. </body> s ���text/htmlc���������C���s(���|��j��d�d���j��d�d���j��d�d���S(���Nt���&s���&t���<s���<t���>s���>(���t���replace(���t���html(����(����s&���/usr/lib64/python2.7/BaseHTTPServer.pyt���_quote_htmlc���s����c�����������B���s���e��Z�d��Z�d����Z�RS(���i���c���������C���sH���t��j�j�|����|��j�j����d� \�}�}�t�j�|���|��_�|�|��_�d�S(���s.���Override server_bind to store the server name.i���N(���t���SocketServert ���TCPServert���server_bindt���sockett���getsocknamet���getfqdnt���server_namet���server_port(���t���selft���hostt���port(����(����s&���/usr/lib64/python2.7/BaseHTTPServer.pyR ���j���s����(���t���__name__t ���__module__t���allow_reuse_addressR ���(����(����(����s&���/usr/lib64/python2.7/BaseHTTPServer.pyR����f���s���c�������� ���B���sC��e��Z�d��Z�d�e�j�j����d�Z�d�e�Z�d�Z �d����Z �d����Z�d����Z�d��d���Z�e�Z�e�Z�d��d ���Z�d ����Z�d����Z�d�d�d ���Z�d����Z�d����Z�d����Z�d��d���Z�d����Z�d�d�d�d�d�d�d�g�Z�d��d�d�d�d�d�d�d �d!�d"�d#�d$�d%�g �Z�d&����Z�d'�Z�e �j!�Z"�i(�d��d*�6d��d-�6d��d0�6d��d3�6d��d6�6d��d9�6d��d<�6d��d?�6d��dB�6d��dE�6d��dH�6d��dK�6d��dN�6d��dQ�6d��dT�6d��dV�6d��dY�6d��d\�6d��d_�6d��db�6d��de�6d��dh�6d��dk�6d��dn�6d��dq�6d��dt�6d��dw�6d��dz�6d��d}�6d��d��6d��d��6d��d��6d��d��6d��d��6d��d��6d��d��6d��d��6d��d��6d��d��6d��d��6Z#�RS(����s���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 mimetools.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". s���Python/i����s ���BaseHTTP/s���HTTP/0.9c��� ������C���s���d�|��_�|��j�|��_�}�d�|��_�|��j�}�|�j�d���}�|�|��_�|�j����}�t �|���d�k�ry|�\�}�}�}�|�d� d�k�r��|��j �d�d�|���t�Syd�|�j�d�d���d�}�|�j�d ���}�t �|���d �k�r��t���n��t �|�d���t �|�d���f�}�Wn,�t�t�f�k �r*|��j �d�d�|���t�SX|�d�k�rR|��j�d�k�rRd�|��_�n��|�d�k�r�|��j �d �d�|���t�Snp�t �|���d �k�r�|�\�}�}�d�|��_�|�d�k�r�|��j �d�d�|���t�Sn"�|�s�t�S|��j �d�d�|���t�S|�|�|�|��_�|��_�|��_�|��j�|��j�d���|��_�|��j�j�d�d���}�|�j����d�k�rQd�|��_�n-�|�j����d�k�r~|��j�d�k�r~d�|��_�n��t�S(���s'��Parse 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, an error is sent back. i���s��� i���i���s���HTTP/i���s���Bad request version (%r)t���/t���.i���i����s���HTTP/1.1i���s���Invalid HTTP Version (%s)t���GETs���Bad HTTP/0.9 request type (%r)s���Bad request syntax (%r)t ���Connectiont����t���closes ���keep-aliveN(���i���i���(���i���i����(���t���Nonet���commandt���default_request_versiont���request_versiont���close_connectiont���raw_requestlinet���rstript���requestlinet���splitt���lent ���send_errort���Falset ���ValueErrort���intt ���IndexErrort���protocol_versiont���patht���MessageClasst���rfilet���headerst���gett���lowert���True( ���R���t���versionR&���t���wordsR ���R/���t���base_version_numbert���version_numbert���conntype(����(����s&���/usr/lib64/python2.7/BaseHTTPServer.pyt ���parse_request����s^���� $ c���������C���s��y��|��j��j�d���|��_�t�|��j���d�k�rY�d�|��_�d�|��_�d�|��_�|��j�d���d�S|��j�so�d�|��_�d�S|��j ����s�d�Sd�|��j�}�t �|��|���s��|��j�d�d �|��j���d�St�|��|���}�|����|��j�j ����Wn0�t�j�k �r}�|��j�d �|���d�|��_�d�SXd�S(���s����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. i��i���R���i���Ni���t���do_i���s���Unsupported method (%r)s���Request timed out: %r(���R1���t���readlineR$���R(���R&���R"���R ���R)���R#���R;���t���hasattrt���getattrt���wfilet���flushR���t���timeoutt ���log_error(���R���t���mnamet���methodt���e(����(����s&���/usr/lib64/python2.7/BaseHTTPServer.pyt���handle_one_request-��s0���� c���������C���s1���d�|��_��|��j����x�|��j��s,�|��j����q�Wd�S(���s&���Handle multiple requests if necessary.i���N(���R#���RG���(���R���(����(����s&���/usr/lib64/python2.7/BaseHTTPServer.pyt���handleP��s���� c���������C���s��y�|��j��|�\�}�}�Wn�t�k �r6�d�\�}�}�n�X|�d�k�rL�|�}�n��|�}�|��j�d�|�|���|��j�|�|���|��j�d�d���d�}�|�d�k�r��|�d�k�r��|��j�i�|�d �6t�|���d �6|�d�6}�|��j�d�|��j���n��|��j ����|��j �d �k�r|�r|��j�j�|���n��d�S(���s���Send and log an error reply. Arguments are the error code, and a detailed message. The detailed message defaults to the short 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. s���???s���code %d, message %sR���R���i����i����i����i0��t���codet���messaget���explains���Content-Typet���HEADN(���s���???s���???(���i����i����i0��( ���t ���responsest���KeyErrorR���RC���t ���send_responset���send_headert���error_message_formatR ���t���error_content_typet���end_headersR ���R@���t���write(���R���RI���RJ���t���shortt���longRK���t���content(����(����s&���/usr/lib64/python2.7/BaseHTTPServer.pyR)���X��s(���� c���������C���s����|��j��|���|�d�k�rE�|�|��j�k�r<�|��j�|�d�}�qE�d�}�n��|��j�d�k�rw�|��j�j�d�|��j�|�|�f���n��|��j�d�|��j������|��j�d�|��j ������d�S(���s����Send the response header and log the response code. Also send two standard headers with the server software version and the current date. i����R���s���HTTP/0.9s ���%s %d %s t���Servert���DateN( ���t���log_requestR���RM���R"���R@���RT���R.���RP���t���version_stringt���date_time_string(���R���RI���RJ���(����(����s&���/usr/lib64/python2.7/BaseHTTPServer.pyRO������s���� c���������C���s����|��j��d�k�r,�|��j�j�d�|�|�f���n��|�j����d�k�r}�|�j����d�k�r\�d�|��_�q}�|�j����d�k�r}�d�|��_�q}�n��d�S( ���s���Send a MIME header.s���HTTP/0.9s���%s: %s t ���connectionR���i���s ���keep-alivei����N(���R"���R@���RT���R4���R#���(���R���t���keywordt���value(����(����s&���/usr/lib64/python2.7/BaseHTTPServer.pyRP������s����c���������C���s&���|��j��d�k�r"�|��j�j�d���n��d�S(���s,���Send the blank line ending the MIME headers.s���HTTP/0.9s��� N(���R"���R@���RT���(���R���(����(����s&���/usr/lib64/python2.7/BaseHTTPServer.pyRS������s����t���-c���������C���s)���|��j��d�|��j�t�|���t�|�����d�S(���sN���Log an accepted request. This is called by send_response(). s ���"%s" %s %sN(���t���log_messageR&���t���str(���R���RI���t���size(����(����s&���/usr/lib64/python2.7/BaseHTTPServer.pyRZ������s���� c���������G���s���|��j��|�|���d�S(���s����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(���Ra���(���R���t���formatt���args(����(����s&���/usr/lib64/python2.7/BaseHTTPServer.pyRC������s����c���������G���s2���t��j�j�d�|��j�d�|��j����|�|�f���d�S(���s���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 address and current date/time are prefixed to every message. s���%s - - [%s] %s i����N(���t���syst���stderrRT���t���client_addresst���log_date_time_string(���R���Rd���Re���(����(����s&���/usr/lib64/python2.7/BaseHTTPServer.pyRa������s���� c���������C���s���|��j��d�|��j�S(���s*���Return the server software version string.t��� (���t���server_versiont���sys_version(���R���(����(����s&���/usr/lib64/python2.7/BaseHTTPServer.pyR[������s����c������ ���C���sv���|�d�k�r�t�j����}�n��t�j�|���\ �}�}�}�}�}�}�}�} �} �d�|��j�|�|�|��j�|�|�|�|�|�f�}�|�S(���s@���Return the current date and time formatted for a message header.s#���%s, %02d %3s %4d %02d:%02d:%02d GMTN(���R���t���timet���gmtimet���weekdaynamet ���monthname(���R���t ���timestampt���yeart���montht���dayt���hht���mmt���sst���wdt���yt���zt���s(����(����s&���/usr/lib64/python2.7/BaseHTTPServer.pyR\������s����* c������ ���C���s]���t��j�����}�t��j�|���\ �}�}�}�}�}�}�}�} �} �d�|�|��j�|�|�|�|�|�f�}�|�S(���s.���Return the current time formatted for logging.s���%02d/%3s/%04d %02d:%02d:%02d(���Rm���t ���localtimeRp���(���R���t���nowRr���Rs���Rt���Ru���Rv���Rw���t���xRy���Rz���R{���(����(����s&���/usr/lib64/python2.7/BaseHTTPServer.pyRi������s ����* t���Mont���Tuet���Wedt���Thut���Frit���Satt���Sunt���Jant���Febt���Mart���Aprt���Mayt���Junt���Jult���Augt���Sept���Octt���Novt���Decc���������C���s ���|��j��d� \�}�}�t�j�|���S(���s����Return the client address formatted for logging. This version looks up the full hostname using gethostbyaddr(), and tries to find a name that contains at least one dot. i���(���Rh���R���R���(���R���R���R���(����(����s&���/usr/lib64/python2.7/BaseHTTPServer.pyt���address_string���s����s���HTTP/1.0t���Continues!���Request received, please continueid���s���Switching Protocolss.���Switching to new protocol; obey Upgrade headerie���t���OKs#���Request fulfilled, document followsi����t���Createds���Document created, URL followsi����t���Accepteds/���Request accepted, processing continues off-linei����s���Non-Authoritative Informations���Request fulfilled from cachei����s ���No Contents"���Request fulfilled, nothing followsi����s ���Reset Contents#���Clear input form for further input.i����s���Partial Contents���Partial content follows.i����s���Multiple Choicess,���Object has several resources -- see URI listi,��s���Moved Permanentlys(���Object moved permanently -- see URI listi-��t���Founds(���Object moved temporarily -- see URI listi.��s ���See Others'���Object moved -- see Method and URL listi/��s���Not Modifieds)���Document has not changed since given timei0��s ���Use ProxysA���You must use proxy specified in Location to access this resource.i1��s���Temporary Redirecti3��s���Bad Requests(���Bad request syntax or unsupported methodi���t���Unauthorizeds*���No permission -- see authorization schemesi���s���Payment Requireds"���No payment -- see charging schemesi���t ���Forbiddens0���Request forbidden -- authorization will not helpi���s ���Not Founds���Nothing matches the given URIi���s���Method Not Alloweds.���Specified method is invalid for this resource.i���s���Not Acceptables&���URI not available in preferred format.i���s���Proxy Authentication Requireds8���You must authenticate with this proxy before proceeding.i���s���Request Timeouts#���Request timed out; try again later.i���t���Conflicts���Request conflict.i���t���Gones6���URI no longer exists and has been permanently removed.i���s���Length Requireds#���Client must specify Content-Length.i���s���Precondition Faileds!���Precondition in headers is false.i���s���Request Entity Too Larges���Entity is too large.i���s���Request-URI Too Longs���URI is too long.i���s���Unsupported Media Types"���Entity body in unsupported format.i���s���Requested Range Not Satisfiables���Cannot satisfy request range.i���s���Expectation Faileds(���Expect condition could not be satisfied.i���s���Internal Server Errors���Server got itself in troublei���s���Not Implementeds&���Server does not support this operationi���s���Bad Gateways,���Invalid responses from another server/proxy.i���s���Service Unavailables8���The server cannot process the request due to a high loadi���s���Gateway Timeouts4���The gateway server did not receive a timely responsei���s���HTTP Version Not Supporteds���Cannot fulfill request.i���N(���R����s!���Request received, please continue(���s���Switching Protocolss.���Switching to new protocol; obey Upgrade header(���R����s#���Request fulfilled, document follows(���R����s���Document created, URL follows(���R����s/���Request accepted, processing continues off-line(���s���Non-Authoritative Informations���Request fulfilled from cache(���s ���No Contents"���Request fulfilled, nothing follows(���s ���Reset Contents#���Clear input form for further input.(���s���Partial Contents���Partial content follows.(���s���Multiple Choicess,���Object has several resources -- see URI list(���s���Moved Permanentlys(���Object moved permanently -- see URI list(���R����s(���Object moved temporarily -- see URI list(���s ���See Others'���Object moved -- see Method and URL list(���s���Not Modifieds)���Document has not changed since given time(���s ���Use ProxysA���You must use proxy specified in Location to access this resource.(���s���Temporary Redirects(���Object moved temporarily -- see URI list(���s���Bad Requests(���Bad request syntax or unsupported method(���R����s*���No permission -- see authorization schemes(���s���Payment Requireds"���No payment -- see charging schemes(���R����s0���Request forbidden -- authorization will not help(���s ���Not Founds���Nothing matches the given URI(���s���Method Not Alloweds.���Specified method is invalid for this resource.(���s���Not Acceptables&���URI not available in preferred format.(���s���Proxy Authentication Requireds8���You must authenticate with this proxy before proceeding.(���s���Request Timeouts#���Request timed out; try again later.(���R����s���Request conflict.(���R����s6���URI no longer exists and has been permanently removed.(���s���Length Requireds#���Client must specify Content-Length.(���s���Precondition Faileds!���Precondition in headers is false.(���s���Request Entity Too Larges���Entity is too large.(���s���Request-URI Too Longs���URI is too long.(���s���Unsupported Media Types"���Entity body in unsupported format.(���s���Requested Range Not Satisfiables���Cannot satisfy request range.(���s���Expectation Faileds(���Expect condition could not be satisfied.(���s���Internal Server Errors���Server got itself in trouble(���s���Not Implementeds&���Server does not support this operation(���s���Bad Gateways,���Invalid responses from another server/proxy.(���s���Service Unavailables8���The server cannot process the request due to a high load(���s���Gateway Timeouts4���The gateway server did not receive a timely response(���s���HTTP Version Not Supporteds���Cannot fulfill request.($���R���R���t���__doc__Rf���R6���R'���Rl���t���__version__Rk���R!���R;���RG���RH���R���R)���t���DEFAULT_ERROR_MESSAGERQ���t���DEFAULT_ERROR_CONTENT_TYPERR���RO���RP���RS���RZ���RC���Ra���R[���R\���Ri���Ro���Rp���R����R.���t ���mimetoolst���MessageR0���RM���(����(����(����s&���/usr/lib64/python2.7/BaseHTTPServer.pyR���r���s����f E # * �����������������s���HTTP/1.0c���������C���s����t��j�d�r#�t�t��j�d���}�n�d�}�d�|�f�}�|�|��_�|�|�|����}�|�j�j����}�d�G|�d�Gd�G|�d�Gd�GH|�j����d�S( ���s���Test the HTTP request handler class. This runs an HTTP server on port 8000 (or the first command line argument). i���i@��R���s���Serving HTTP oni����R���s���...N(���Rf���t���argvR,���R.���R���R���t ���serve_forever(���t���HandlerClasst���ServerClasst���protocolR���t���server_addresst���httpdt���sa(����(����s&���/usr/lib64/python2.7/BaseHTTPServer.pyt���testN��s���� t���__main__(���R����R����t���__all__Rf���Rm���R���t���warningsR���R���t���py3kwarningt���DeprecationWarningR����R���R����R����R ���R���R����t���StreamRequestHandlerR���R����R���(����(����(����s&���/usr/lib64/python2.7/BaseHTTPServer.pyt���<module>���s,���3 ���