�
Ϫ�f� � �� � d Z ddlmZ g d�ZddlZddlZddlZddlZddlZddl Z ddl
Z
ddlZddlZddl
mZ ddlmZ ddlmZ ddlmZmZmZmZmZmZ dd lmZmZmZ dd
l m!Z!m"Z"m#Z#m$Z$ ddl%m&Z& ddl'm(Z(m)Z)m*Z* dd
l+m,Z, ddl-m.Z. ddl/m0Z0 ddl1m2Z2 ddl3m4Z4m5Z5 ddl6m7Z7 ddl8m9Z9m:Z: ddl;m<Z< ddl=m>Z> ddl?m@Z@ ddlAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZWmXZXmYZYmZZZm[Z[m\Z\m]Z]m^Z^m_Z_m`Z`maZambZbmcZcmdZdmeZemfZfmgZgmhZhmiZimjZjmkZkmlZlmmZm ddlnmoZompZp ddlqmrZrmsZsmtZt ddlumvZv dZwdZydZzdZ{efZ|g d �Z}g d!�Z~e}D � cg c] } | j� � �� c} Z�e~D � cg c] } | xr | j� � �� c} Z�dZd"�Z� G d#� d$e�� Z�d[d%�Z�d&� Zd\d'�Z�d]d(�Z�d]d)�Z�d*� Z�d+� Z�d,� Z�d^d-�Z�d_d.�Z�d`d/�Z�d0� Z� G d1� d2e"� Z� G d3� d4� Z� G d5� d6e4�j$ � Z�d7Z� e�� Z�d8� Z� e �j0 d9� Z� e#e)�j4 e�� G d:� d;� � Z� G d<� d=e�� Z� G d>� d?e�� Z� G d@� dAe�� Z� G dB� dC� Z�dDZ�dEZ� G dF� dG� Z� e#e)�jF � G dH� dI� � Z� e#e)�jJ e)�jF e)�j4 � G dJ� dKe4�j$ e5�jL � � Z�dL� Z� e$er� dM� � Z� e#e)�jT � G dN� dO� � Z� G dP� dQ e<etdR� � Z� e$er� dS� � Z� G dT� dU e<e0dV� � Z�dW� Z� G dX� dYe*�j` � Z�y# ex$ r dZwY ��&w xY wc c} w c c} w )aa�
HyperText Transfer Protocol implementation.
This is the basic server-side protocol implementation used by the Twisted
Web server. It can parse HTTP 1.0 requests and supports many HTTP 1.1
features as well. Additionally, some functionality implemented here is
also useful for HTTP clients (such as the chunked encoding parser).
@var CACHED: A marker value to be returned from cache-related request methods
to indicate to the caller that a cached response will be usable and no
response body should be generated.
@var FOUND: An HTTP response code indicating a temporary redirect.
@var NOT_MODIFIED: An HTTP response code indicating that a requested
pre-condition (for example, the condition represented by an
I{If-Modified-Since} header is present in the request) has succeeded. This
indicates a response body cached by the client can be used.
@var PRECONDITION_FAILED: An HTTP response code indicating that a requested
pre-condition (for example, the condition represented by an I{If-None-Match}
header is present in the request) has failed. This should typically
indicate that the server has not taken the requested action.
@var maxChunkSizeLineLength: Maximum allowable length of the CRLF-terminated
line that indicates the size of a chunk and the extensions associated with
it, as in the HTTP 1.1 chunked I{Transfer-Encoding} (RFC 7230 section 4.1).
This limits how much data may be buffered when decoding the line.
� )�annotations)=� SWITCHING�OK�CREATED�ACCEPTED�NON_AUTHORITATIVE_INFORMATION�
NO_CONTENT�
RESET_CONTENT�PARTIAL_CONTENT�MULTI_STATUS�MULTIPLE_CHOICE�MOVED_PERMANENTLY�FOUND� SEE_OTHER�NOT_MODIFIED� USE_PROXY�TEMPORARY_REDIRECT�PERMANENT_REDIRECT�BAD_REQUEST�UNAUTHORIZED�PAYMENT_REQUIRED� FORBIDDEN� NOT_FOUND�NOT_ALLOWED�NOT_ACCEPTABLE�PROXY_AUTH_REQUIRED�REQUEST_TIMEOUT�CONFLICT�GONE�LENGTH_REQUIRED�PRECONDITION_FAILED�REQUEST_ENTITY_TOO_LARGE�REQUEST_URI_TOO_LONG�UNSUPPORTED_MEDIA_TYPE�REQUESTED_RANGE_NOT_SATISFIABLE�EXPECTATION_FAILED�INTERNAL_SERVER_ERROR�NOT_IMPLEMENTED�BAD_GATEWAY�SERVICE_UNAVAILABLE�GATEWAY_TIMEOUT�HTTP_VERSION_NOT_SUPPORTED�INSUFFICIENT_STORAGE_SPACE�NOT_EXTENDED� RESPONSES�CACHED�urlparse�parse_qs�datetimeToString�datetimeToLogString�timegm�stringToDatetime�toChunk� fromChunk�parseContentRange�StringTransport�
HTTPClient�
NO_BODY_CODES�Request�PotentialDataLoss�HTTPChannel�HTTPFactoryN)�message_from_bytes)�EmailMessage)�BytesIO)�AnyStr�Callable�Dict�List�Optional�Tuple)�ParseResultBytes�unquote_to_bytesr1 )� Attribute� Interface�implementer�provider)�Version)�address�
interfaces�protocol)�_PullToPush)�Deferred)� IProtocol)�Logger)�basic�policies)�log)�nativeString�
networkString)�proxyForInterface)�
deprecated)�Failure),r r) r r r r& |