Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/site-packages/aiohttp/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/site-packages/aiohttp/__pycache__/web_request.cpython-35.pyc



���Z�Q�@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZddl	mZddlmZddlZddlmZmZmZmZddlmZdd	lmZmZdd
lmZmZm Z ddl!m"Z"ddl#m$Z$d
ddfZ%ej&dddd�Gdd�d��Z'ej(ej)dZ*dj+de*�Z,dj+dj-dd�dddfe.e/dd��D���Z0d Z1d!j+d"e0d#e1�Z2d$j+d%e,d&e2�Z3ej4d'�Z5ej4e3�Z6Gd(d
�d
ej7e�Z8Gd)d�de8�Z9dS)*�N)�	parsedate)�SimpleCookie)�MappingProxyType)�	parse_qsl)�CIMultiDict�CIMultiDictProxy�	MultiDict�MultiDictProxy)�URL�)�hdrs�	multipart)�HeadersMixin�reify�sentinel)�EmptyStreamReader)�HTTPRequestEntityTooLarge�BaseRequest�	FileField�Request�frozenT�slotsc@smeZdZejde�Zejde�Zejdej	�Z
ejde�Zejde�Z
dS)r�typeN)�__name__�
__module__�__qualname__�attr�ib�str�name�filename�io�BufferedReader�file�content_typer�headers�r&r&�F/opt/alt/python35/lib64/python3.5/site-packages/aiohttp/web_request.pyrs
z!#$%&'*+.^_`|~-z
[{tchar}]+Ztcharz[{}]�ccs|]}t|�VqdS)N)�chr)�.0�cr&r&r'�	<genexpr>-sr,�	� �!�#�z
\\[\t !-~]z"(?:{quoted_pair}|{qdtext})*"ZqdtextZquoted_pairz#({token})=({token}|{quoted_string})�tokenZ
quoted_stringz\\([\t !-~])c@s�eZdZejejejejejhZ	e
jeddddddddd	d
ddd
ddg�BZddxdddddddddd�Z
dededededededd�Zedd ��Zed!d"��Zed#d$��Zed%d&��Zed'd(��Zed)d*��Zed+d,��Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zed7d8��Zed9d:��Zed;d<��Z ed=d>��Z!ed?d@��Z"edAdB��Z#edCdD��Z$edEdF��Z%edGdH��Z&edIdJ��Z'edKdL��Z(edMdN��Z)edOdP��Z*edQdR��Z+edSdT��Z,eej-dUdV��Z.edWdX��Z/edYdZ��Z0ed[ej1d\d]��Z2ed^d_��Z3ed`da��Z4edbdc��Z5eddde��Z6dfdg�Z7dhdi�Z8djdk�Z9dle:j;dmdn�Z:doe<j=dpdq�Z<drds�Z>dtdu�Z?e@jAdvdw��ZBdS)yr�_message�	_protocol�_payload_writer�_payload�_headers�_method�_version�_rel_url�_post�_read_bytes�_state�_cache�_task�_client_max_size�_loop�client_max_sizei��stateN�scheme�host�remotecCs�|dkri}||_||_||_||_|j|_|j|_|j|_	|j
|_d|_d|_
||_i|_||_||_||_|	dk	r�|	|jd<|
dk	r�|
|jd<|dk	r�||jd<dS)NrErFrG)r3r4r5r6r%r7�methodr8�versionr9�urlr:r;r<r=r>r?r@rA)�self�message�payload�protocolZpayload_writer�task�looprBrDrErFrGr&r&r'�__init__Os.											

zBaseRequest.__init__rH�rel_urlr%c
CsB|jrtd��i}|tk	r1||d<|tk	rct|�}||d<t|�|d<|tk	r�t|�|d<tdd�|j�D��|d<|jj	|�}i}	|tk	r�||	d	<|tk	r�||	d
<|tk	r�||	d<|j
||j|j|j
|j|jd|jd
|jj�|	�S)aClone itself with replacement some attributes.

        Creates and returns a new instance of Request object. If no parameters
        are given, an exact copy is returned. If a parameter is not passed, it
        will reuse the one from the current request object.

        z/Cannot clone request after reading it's contentrHrJ�pathr%css3|])\}}|jd�|jd�fVqdS)zutf-8N)�encode)r*�k�vr&r&r'r,�sz$BaseRequest.clone.<locals>.<genexpr>�raw_headersrErFrGrBrD)r<�RuntimeErrorrr
rr�tuple�itemsr3�_replace�	__class__r6r4r5r?rAr@r=�copy)
rKrHrRr%rErFrG�dctrL�kwargsr&r&r'�cloneos>	




		zBaseRequest.clonecCs|jS)N)r?)rKr&r&r'rO�szBaseRequest.taskcCs|jS)N)r4)rKr&r&r'rN�szBaseRequest.protocolcCs|jdkrdS|jjS)N)r4�	transport)rKr&r&r'ra�szBaseRequest.transportcCs|jS)N)r5)rKr&r&r'�writer�szBaseRequest.writercCs|jS)N)r3)rKr&r&r'rL�szBaseRequest.messagecCs|jS)N)r:)rKr&r&r'rR�szBaseRequest.rel_urlcCs|jS)N)rA)rKr&r&r'rP�szBaseRequest.loopcCs|j|S)N)r=)rK�keyr&r&r'�__getitem__�szBaseRequest.__getitem__cCs||j|<dS)N)r=)rKrc�valuer&r&r'�__setitem__�szBaseRequest.__setitem__cCs|j|=dS)N)r=)rKrcr&r&r'�__delitem__�szBaseRequest.__delitem__cCs
t|j�S)N)�lenr=)rKr&r&r'�__len__�szBaseRequest.__len__cCs
t|j�S)N)�iterr=)rKr&r&r'�__iter__�szBaseRequest.__iter__cCs
|jdkS)z5A bool indicating if the request is handled with SSL.�https)rE)rKr&r&r'�secure�szBaseRequest.securec
Cs�g}x�|jjjtjf�D]�}t|�}d}d}i}|jtj|��xZd|kov|knr�t	j
||�}|dk	r$|r�|jd|�}q�|j�\}}	|	ddkr�t
jd|	dd��}	|	||j�<|t|jd��7}d}q_||dkrcd}i}|jtj|��|d7}q_||d	kr�d}|d7}q_||d
kr�|d7}q_|jd|�}q_Wq"Wt|�S)a�A tuple containing all parsed Forwarded header(s).

        Makes an effort to parse Forwarded headers as specified by RFC 7239:

        - It adds one (immutable) dictionary per Forwarded 'field-value', ie
          per proxy. The element corresponds to the data in the Forwarded
          field-value added by the first proxy encountered by the client. Each
          subsequent item corresponds to those added by later proxies.
        - It checks that every value has valid syntax in general as specified
          in section 4: either a 'token' or a 'quoted-string'.
        - It un-escapes found escape sequences.
        - It does NOT validate 'by' and 'for' contents as specified in section
          6.
        - It does NOT validate 'host' contents (Host ABNF).
        - It does NOT validate 'proto' contents for valid URI scheme names.

        Returns a tuple containing one or more immutable dicts
        rFN�,�"z\1rT�;z 	���)r3r%ZgetallrZ	FORWARDEDrh�append�typesr�_FORWARDED_PAIR_RE�match�find�groups�_QUOTED_PAIR_REPLACE_RE�sub�lower�grouprY)
rKZelemsZfield_value�length�posZneed_separator�elemrurrer&r&r'�	forwarded�s>"		


zBaseRequest.forwardedcCs|jjd�rdSdSdS)aA string representing the scheme of the request.

        Hostname is resolved in this order:

        - overridden value by .clone(scheme=new_scheme) call.
        - type of connection to peer: HTTPS if socket is SSL, HTTP otherwise.

        'http' or 'https'.
        Z
sslcontextrl�httpN)ra�get_extra_info)rKr&r&r'rEszBaseRequest.schemecCs|jS)zyRead only property for getting HTTP method.

        The value is upper-cased str like 'GET', 'POST', 'PUT' etc.
        )r8)rKr&r&r'rH!szBaseRequest.methodcCs|jS)zxRead only property for getting HTTP version of request.

        Returns aiohttp.protocol.HttpVersion instance.
        )r9)rKr&r&r'rI)szBaseRequest.versioncCs6|jjjtj�}|dk	r(|Stj�SdS)z�Hostname of the request.

        Hostname is resolved in this order:

        - overridden value by .clone(host=new_host) call.
        - HOST HTTP header
        - socket.getfqdn() value
        N)r3r%�getrZHOST�socket�getfqdn)rKrFr&r&r'rF1s
zBaseRequest.hostcCsJ|jdkrdS|jjd�}t|ttf�rB|dS|SdS)z�Remote IP of client initiated HTTP request.

        The IP is resolved in this order:

        - overridden value by .clone(remote=new_remote) call.
        - peername of opened socket
        N�peernamer)rar��
isinstance�listrY)rKr�r&r&r'rGAs	zBaseRequest.remotecCs.tjd|jd|j�}|j|j�S)NrErF)r
�buildrErF�joinr:)rKrJr&r&r'rJRszBaseRequest.urlcCs
|jjS)z_The URL including *PATH INFO* without the host or scheme.

        E.g., ``/app/blog``
        )r:rS)rKr&r&r'rSWszBaseRequest.pathcCs
t|j�S)zXThe URL including PATH_INFO and the query string.

        E.g, /app/blog?id=10
        )rr:)rKr&r&r'�path_qs_szBaseRequest.path_qscCs
|jjS)z� The URL including raw *PATH INFO* without the host or scheme.
        Warning, the path is unquoted and may contains non valid URL characters

        E.g., ``/my%2Fpath%7Cwith%21some%25strange%24characters``
        )r3rS)rKr&r&r'�raw_pathgszBaseRequest.raw_pathcCs
|jjS)z7A multidict with all the variables in the query string.)r:�query)rKr&r&r'r�pszBaseRequest.querycCs
|jjS)z:The query string in the URL.

        E.g., id=10
        )r:�query_string)rKr&r&r'r�uszBaseRequest.query_stringcCs|jS)z4A case-insensitive multidict proxy with all headers.)r7)rKr&r&r'r%}szBaseRequest.headerscCs
|jjS)z#A sequence of pars for all headers.)r3rW)rKr&r&r'rW�szBaseRequest.raw_headerscCs]|jj|�}|dk	rYt|�}|dk	rYtj|dd�dtjj�SdS)zyThe value of If-Modified-Since HTTP header, or None.

        This header is represented as a `datetime` object.
        N��tzinfo)r%r�r�datetime�timezone�utc)rKZ_IF_MODIFIED_SINCEZhttpdate�	timetupler&r&r'�if_modified_since�s
zBaseRequest.if_modified_sincecCs|jjS)zIs keepalive enabled by client?)r3Zshould_close)rKr&r&r'�
keep_alive�szBaseRequest.keep_alivecCsA|jjtjd�}t|�}tdd�|j�D��S)zMReturn request cookies.

        A read-only dictionary-like object.
        r(cSs"i|]\}}|j|�qSr&)re)r*rc�valr&r&r'�
<dictcomp>�s	z'BaseRequest.cookies.<locals>.<dictcomp>)r%r�rZCOOKIErrrZ)rK�raw�parsedr&r&r'�cookies�szBaseRequest.cookies�_RANGEcCs2|jj|�}d\}}|dk	r"y&d}tj||�d\}}Wntk
rptd��YnX|r�t|�nd}|r�t|�nd}|dkr�|dk	r�|}|dk	r�|dk	r�|d7}||kr�td��||kodknr"td��t||d�S)	zMThe content of Range HTTP header.

        Return a slice instance.

        Nz^bytes=(\d*)-(\d*)$rzrange not in acceptible formatrzstart cannot be after endz"No start or end of range specified)NN)r7r��re�findall�
IndexError�
ValueError�int�slice)rKr��rng�start�end�patternr&r&r'�
http_range�s& 

zBaseRequest.http_rangecCs|jS)zReturn raw payload stream.)r6)rKr&r&r'�content�szBaseRequest.contentcCs$tjdtdd�|jj�S)z@Return True if request's HTTP BODY can be read, False otherwise.z$Deprecated, use .can_read_body #2005�
stacklevelrC)�warnings�warn�DeprecationWarningr6�at_eof)rKr&r&r'�has_body�s
zBaseRequest.has_bodycCs|jj�S)z@Return True if request's HTTP BODY can be read, False otherwise.)r6r�)rKr&r&r'�
can_read_body�szBaseRequest.can_read_bodycCst|j�tk	S)z6Return True if request has HTTP BODY, False otherwise.)rr6r)rKr&r&r'�body_exists�szBaseRequest.body_existsc�s,x%|jj�s'|jj�IdHqWdS)zKRelease request.

        Eat unread part of HTTP BODY if present.
        N)r6r��readany)rKr&r&r'�release�szBaseRequest.releasec�s�|jdkrzt�}xP|jj�IdH}|j|�|jr`t|�|jkr`t�|sPqWt|�|_|jS)z_Read request body if present.

        Returns bytes object with full request content.
        N)	r<�	bytearrayr6r��extendr@rhr�bytes)rK�body�chunkr&r&r'�read�s	
	zBaseRequest.readc�s-|j�IdH}|jpd}|j|�S)z1Return BODY as text using encoding from .charset.Nzutf-8)r��charset�decode)rKZ
bytes_body�encodingr&r&r'�text�szBaseRequest.text�loadsc�s|j�IdH}||�S)zReturn BODY as JSON.N)r�)rKr�r�r&r&r'�json�szBaseRequest.json�readerc�s||j|j�S)z3Return async iterator to process BODY as multipart.)r7r6)rKr�r&r&r'r
szBaseRequest.multipartc
�s�|jdk	r|jS|j|jkrAtt��|_|jS|j}|dkrott��|_|jSt�}|dkrw|j�IdH}|j�IdH}x"|dk	rsd}|j}|j	j
tj�}|j
r�tj�}|jdd�IdH}xu|r||j|�}|j|�|t|�7}d|koQ|knrbtd	��|jdd�IdH}qW|jd�t|j|j
|||j	�}	|j|j|	�n�|jd
d�IdH}
|dks�|jd�r|jd
d�}|
j|�}
|j|j|
�|t|
�7}d|koN|knr_td	��|j�IdH}q�WnT|j�IdH}|r�|jp�d}|jt|j�j|�ddd|��t|�|_|jS)zReturn POST parameters.Nr(�!application/x-www-form-urlencoded�multipart/form-datar�sizerC�z"Maximum request body size exceededr�Tztext/�defaultzutf-8�keep_blank_valuesr�)r(r�r�ii) r;r8�POST_METHODSr	rr$r
�nextr@r%r�r�CONTENT_TYPEr �tempfile�
TemporaryFileZ
read_chunkr��writerhr��seekrr�addr��
startswith�get_charsetr�r�r�rstrip)
rKr$�outr
�fieldr��max_size�tmpr�Zffrer��datar&r&r'�postsn						
	
	
zBaseRequest.postcCs:|jjdd�jd�}dj|jj|j|�S)N�ascii�backslashreplacez<{} {} {} >)rSrTr��formatr\rr8)rKZascii_encodable_pathr&r&r'�__repr__Ls	zBaseRequest.__repr__ccs	dSdV)Nr&)rK�responser&r&r'�
_prepare_hookRszBaseRequest._prepare_hooki)CrrrrZ
METH_PATCHZ	METH_POSTZMETH_PUTZ
METH_TRACEZMETH_DELETEr�r�ATTRS�	frozensetrQrr`�propertyrOrNrarbrLrRrPrdrfrgrirkrmrrrErHrIrFrGrJrSr�r�r�r�r%rWZIF_MODIFIED_SINCEr�r�r��RANGEr�r�r�r�r�r�r�r�r�r�r
ZMultipartReaderr�r��asyncio�	coroutiner�r&r&r&r'rEst	.<	
!Ecs�eZdZejedg�BZ�fdd�Z�fdd�Zdededed	ed
ede�fdd
�Z	e
dd��Ze
dd��Zdd�Z
�S)r�_match_infocs t�j||�d|_dS)N)�superrQr�)rK�argsr_)r\r&r'rQ\szRequest.__init__csN||jkr7tjdj|jj|�tdd�t�j||�dS)Nz-Setting custom {}.{} attribute is discouragedr�rC)	r�r�r�r�r\rr�r��__setattr__)rKrr�)r\r&r'r�cs	zRequest.__setattr__rHrRr%rErFrGc
sCt�jd|d|d|d|d|d|�}|j|_|S)NrHrRr%rErFrG)r�r`r�)rKrHrRr%rErFrG�ret)r\r&r'r`ls	z
Request.clonecCs|jS)zResult of route resolving.)r�)rKr&r&r'�
match_infoxszRequest.match_infocCs
|jjS)zApplication instance.)r�Zcurrent_app)rKr&r&r'�app}szRequest.appc�sI|j}|dkrdSx)|jD]}|jj||�IdHq#WdS)N)r�ZappsZon_response_prepare�send)rKr�r�r�r&r&r'r��s
	zRequest._prepare_hook)rrrrr�r�rQr�rr`r�r�r�r�r&r&)r\r'rXs	
):r��collectionsr�r!r�r�r��stringr�rsr��email.utilsrZhttp.cookiesrr�urllib.parserrZ	multidictrrrr	Zyarlr
r(rr
�helpersrrrZstreamsrZweb_exceptionsr�__all__�sr�digits�
ascii_lettersZ_TCHARr�Z_TOKENr�rY�rangeZ_QDTEXTZ_QUOTED_PAIRZ_QUOTED_STRINGZ_FORWARDED_PAIR�compilerxrt�MutableMappingrrr&r&r&r'�<module>sN"+	;			��