0x1949 Team - FAZEMRX - MANAGER
Edit File: server.cpython-38.pyc
U k�]e�� � @ s d Z dZdddddgZddlZddlZddlZddlZddlZ ddl Z ddlZddlZddl Z ddlZddlZddlZddlZddlZddlZddlZddlZdd lmZ dd l mZ dZdZG d d� dej�ZG dd� deje�ZG dd� dej �Z!G dd� de!�Z"dd� Z#da$dd� Z%dd� Z&G dd� de"�Z'dd� Z(e!edddfdd�Z)e*dk�r�ddl+Z+e+�,� Z-e-j.dd d!d"� e-j.d#d$d%d&d'� e-j.d(d)e�/� d*d+� e-j.d,d-de0d.d/d0� e-�1� Z2e2j3�r�e'Z4nee"e2j5d1�Z4G d2d3� d3e�Z6e)e4e6e2j7e2j8d4� dS )5a@ HTTP server classes. Note: BaseHTTPRequestHandler doesn't implement any HTTP request; see SimpleHTTPRequestHandler for simple implementations of GET, HEAD and POST, and CGIHTTPRequestHandler for CGI scripts. It does, however, optionally implement HTTP/1.1 persistent connections, as of version 0.3. Notes on CGIHTTPRequestHandler ------------------------------ This class implements GET and POST requests to cgi-bin scripts. If the os.fork() function is not present (e.g. on Windows), subprocess.Popen() is used as a fallback, with slightly altered semantics. 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)�partial)� HTTPStatusa� <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html;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 @ s e Zd ZdZdd� ZdS )r � c C s4 t j�| � | jdd� \}}t�|�| _|| _dS )z.Override server_bind to store the server name.N� )�socketserver� TCPServer�server_bindZserver_address�socketZgetfqdn�server_name�server_port)�self�host�port� r �!/usr/lib/python3.8/http/server.pyr � s zHTTPServer.server_bindN)�__name__� __module__�__qualname__Zallow_reuse_addressr r r r r r � s c @ s e Zd ZdZdS )r TN)r r r Zdaemon_threadsr r r r r � s c @ s e Zd ZdZdej�� d Zde Z e ZeZ dZdd� Zdd � Zd d� Zdd � Zd@dd�ZdAdd�ZdBdd�Zdd� Zdd� Zdd� ZdCdd�Zdd� Zd d!� Zd"d#� ZdDd$d%�Zd&d'� Zd(d)d*d+d,d-d.gZdd/d0d1d2d3d4d5d6d7d8d9d:g Z d;d<� Z!d=Z"e#j$j%Z&d>d?� e'j(�)� D �Z*dS )Er 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/r z BaseHTTP/�HTTP/0.9c C s� d| _ | j | _}d| _t| jd�}|�d�}|| _|�� }t |�dkrLdS t |�dk�r&|d }zT|� d �srt�|�d d�d }|�d�}t |�d kr�t�t|d �t|d �f}W n, tt fk r� | �tjd| � Y dS X |dk�r | jdk�r d| _|dk�r | �tjd| � dS || _d t |� k�rBdk�sZn | �tjd| � dS |dd � \}}t |�d k�r�d| _|dk�r�| �tjd| � dS || | _ | _ztjj| j| jd�| _W n� tjjk �r } z| �tjdt|�� W Y �dS d}~X Y nB tjjk �rH } z| �tjdt|�� W Y �dS d}~X Y nX | j�dd�} | �� dk�rnd| _n | �� dk�r�| jdk�r�d| _| j�dd�} | �� dk�r�| jdk�r�| jdk�r�| �� �s�dS dS )aH 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, any relevant error response has already been sent back. NTz iso-8859-1z r F� ���zHTTP/�/r �.r zBad request version (%r))r r zHTTP/1.1)r r zInvalid HTTP version (%s)zBad request syntax (%r)ZGETzBad HTTP/0.9 request type (%r))Z_classz Line too longzToo many headers� Connection� �close� keep-aliveZExpectz100-continue) �command�default_request_version�request_version�close_connection�str�raw_requestline�rstrip�requestline�split�len� startswith� ValueError�int� IndexError� send_errorr ZBAD_REQUEST�protocol_versionZHTTP_VERSION_NOT_SUPPORTED�path�http�clientZ parse_headers�rfile�MessageClass�headersZLineTooLongZREQUEST_HEADER_FIELDS_TOO_LARGEZ HTTPException�get�lower�handle_expect_100)r �versionr) �wordsZbase_version_numberZversion_numberr"