Your IP : 3.133.123.248


Current Path : /lib64/python3.6/wsgiref/__pycache__/
Upload File :
Current File : //lib64/python3.6/wsgiref/__pycache__/validate.cpython-36.opt-2.pyc

3


 \;;�@s�dgZddlZddlZddlZejd�Zejd�ZGdd�de�Zdd�Z	d	d
�Z
dd�ZGdd
�d
�ZGdd�d�Z
Gdd�d�ZGdd�d�ZGdd�d�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�ZdS)&�	validator�Nz^[a-zA-Z][a-zA-Z0-9\-_]*$z[\000-\037]c@seZdZdS)�WSGIWarningN)�__name__�
__module__�__qualname__�rr�(/usr/lib64/python3.6/wsgiref/validate.pyrysrcGs|st|��dS)N)�AssertionError)Zcond�argsrrr�assert_~srcCs(t|�tkr|Stdj|t|����dS)Nz!{0} must be of type str (got {1}))�type�strr	�format�repr)�value�titlerrr�check_string_type�srcs�fdd�}|S)Ncs�tt|�dkd�t|d�|\}�t|�g���fdd�}t|d�|d<t|d�|d<�||�}t|dk	oz|dkd	�t|�t|��S)
N�zTwo arguments requiredzNo keyword arguments allowedcs�tt|�dkpt|�dkd|f�t|d�|d}|d}t|�dkrV|d}nd}t|�t|�t||�t|��jd�t�|��S)Nr�zInvalid number of arguments: %szNo keyword arguments allowedr�)r�len�check_status�
check_headers�check_content_type�check_exc_info�append�WriteWrapper)r
�kw�status�headers�exc_info)�start_response�start_response_startedrr�start_response_wrapper�s


z;validator.<locals>.lint_app.<locals>.start_response_wrapperz
wsgi.inputzwsgi.errorsFz>The application must return an iterator, if only an empty list)rr�
check_environ�InputWrapper�ErrorWrapper�check_iterator�IteratorWrapper)r
r�environr#�iterator)�application)r!r"r�lint_app�s
zvalidator.<locals>.lint_appr)r+r,r)r+rr�s)c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)r%cCs
||_dS)N)�input)�self�
wsgi_inputrrr�__init__�szInputWrapper.__init__cGs0tt|�dk�|jj|�}tt|�tk�|S)Nr)rrr-�readr�bytes)r.r
�vrrrr1�szInputWrapper.readcGs0tt|�dk�|jj|�}tt|�tk�|S)Nr)rrr-�readlinerr2)r.r
r3rrrr4�szInputWrapper.readlinecGsNtt|�dk�|jj|�}tt|�tk�x|D]}tt|�tk�q2W|S)Nr)rrr-�	readlinesr�listr2)r.r
�lines�linerrrr5�s
zInputWrapper.readlinesccs x|j�}|sdS|VqWdS)N)r4)r.r8rrr�__iter__�s
zInputWrapper.__iter__cCstdd�dS)Nrz input.close() must not be called)r)r.rrr�close�szInputWrapper.closeN)	rrrr0r1r4r5r9r:rrrrr%�sr%c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)r&cCs
||_dS)N)�errors)r.�wsgi_errorsrrrr0�szErrorWrapper.__init__cCs tt|�tk�|jj|�dS)N)rrr
r;�write)r.�srrrr=�szErrorWrapper.writecCs|jj�dS)N)r;�flush)r.rrrr?�szErrorWrapper.flushcCsx|D]}|j|�qWdS)N)r=)r.�seqr8rrr�
writelines�s
zErrorWrapper.writelinescCstdd�dS)Nrz!errors.close() must not be called)r)r.rrrr:�szErrorWrapper.closeN)rrrr0r=r?rAr:rrrrr&�s
r&c@seZdZdd�Zdd�ZdS)rcCs
||_dS)N)�writer)r.Zwsgi_writerrrrr0�szWriteWrapper.__init__cCstt|�tk�|j|�dS)N)rrr2rB)r.r>rrr�__call__�szWriteWrapper.__call__N)rrrr0rCrrrrr�src@seZdZdd�Zdd�ZdS)�PartialIteratorWrappercCs
||_dS)N)r*)r.�
wsgi_iteratorrrrr0szPartialIteratorWrapper.__init__cCst|jd�S)N)r(r*)r.rrrr9szPartialIteratorWrapper.__iter__N)rrrr0r9rrrrrD�srDc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)r(cCs ||_t|�|_d|_||_dS)NF)�original_iterator�iterr*�closed�check_start_response)r.rErIrrrr0	s
zIteratorWrapper.__init__cCs|S)Nr)r.rrrr9szIteratorWrapper.__iter__cCsTt|jd�t|j�}t|�tk	r4tdd|f�|jdk	rPt|jd�d|_|S)NzIterator read after closedFz$Iterator yielded non-bytestring (%r)zjThe application returns and we started iterating over its body, but start_response has not yet been called)rrH�nextr*rr2rI)r.r3rrr�__next__s

zIteratorWrapper.__next__cCs d|_t|jd�r|jj�dS)NTr:)rH�hasattrrFr:)r.rrrr:szIteratorWrapper.closecCs"|jstjjd�t|jd�dS)Nz/Iterator garbage collected without being closed)rH�sys�stderrr=r)r.rrr�__del__#s
zIteratorWrapper.__del__N)rrrr0r9rKr:rOrrrrr(s
r(c	Cs�tt|�tkdt|�|f�x d,D]}t||kd|f�q$Wx*d-D]"}t||kd||dd�f�qFWd|kr�tjdt�xF|j�D]:}d|kr�q�tt||�tkd|t||�||f�q�Wtt|d�tkd|df�t|dd.kd|d�t	|d�t
|d�|dd/k�r<tjd!|dt�t|jd"��pX|d"jd#�d$|d"�t|jd%��p�|d%jd#�d&|d%�|jd'��r�tt
|d'�d(kd)|d'�|jd"��s�td%|kd*�t|jd"�d#kd+�dS)0Nz:Environment is not of the right type: %r (environment: %r)�REQUEST_METHOD�SERVER_NAME�SERVER_PORT�wsgi.version�
wsgi.input�wsgi.errors�wsgi.multithread�wsgi.multiprocess�
wsgi.run_oncez$Environment missing required key: %r�HTTP_CONTENT_TYPE�HTTP_CONTENT_LENGTHz8Environment should not have the key: %s (use %s instead)�ZQUERY_STRINGz�QUERY_STRING is not in the WSGI environment; the cgi module will use sys.argv when this variable is missing, so application errors are more likely�.z9Environmental variable %s is not a string: %r (value: %r)z#wsgi.version should be a tuple (%r)zwsgi.url_scheme�http�httpszwsgi.url_scheme unknown: %r�GET�HEAD�POST�OPTIONS�PATCH�PUT�DELETE�TRACEzUnknown REQUEST_METHOD: %rZSCRIPT_NAME�/z$SCRIPT_NAME doesn't start with /: %rZ	PATH_INFOz"PATH_INFO doesn't start with /: %rZCONTENT_LENGTHrzInvalid CONTENT_LENGTH: %rzgOne of SCRIPT_NAME or PATH_INFO are required (PATH_INFO should at least be '/' if SCRIPT_NAME is empty)zOSCRIPT_NAME cannot be '/'; it should instead be '', and PATH_INFO should be '/')	rPrQrRrSrTrUrVrWrX)rYrZ)r]r^)r_r`rarbrcrdrerf)rr�dict�warnings�warnr�keysr
�tuple�check_input�check_errors�get�
startswith�int)r)�keyrrrr$*s`

r$cCs*x$dD]}tt||�d||f�qWdS)Nr1r4r5r9z-wsgi.input (%r) doesn't have the attribute %s)r1r4r5r9)rrL)r/�attrrrrrmks

rmcCs*x$dD]}tt||�d||f�qWdS)Nr?r=rAz.wsgi.errors (%r) doesn't have the attribute %s)r?r=rA)rrL)r<rsrrrrnqs

rncCsvt|d�}|jdd�d}tt|�dkd|�t|�}t|dkd|�t|�dksb|dd	krrtjd
|t�dS)N�Statusrrrz)Status codes must be three characters: %r�dzStatus code is invalid: %r�� zjThe status string (%r) should be a three-digit integer followed by a single space and a status explanation)r�splitrrrqrirjr)rZstatus_codeZ
status_intrrrrws

rcCstt|�tkd|t|�f�i}x�|D]�}tt|�tkd|t|�f�tt|�dk�|\}}t|d�}t|d�}t|j�dkd|�d||j�<td|ko�d	|kd
|�ttj|�d|�t|j	d�o�|j	d
�d|�t
j|�r(tdd|t
j|�jd�f�q(WdS)Nz%Headers (%r) must be of type list: %rz1Individual headers (%r) must be of type tuple: %rrzHeader namezHeader valuerzyThe Status header cannot be used; it conflicts with CGI script, and HTTP status is not given through headers (value: %r).�
�:z,Header names may not contain ':' or '\n': %rzBad header name: %r�-�_z#Names may not end in '-' or '_': %rrz#Bad header value: %r (bad char: %r))rrr6rlrr�lower�	header_re�search�endswith�bad_header_value_re�group)rZheader_names�item�namerrrrr�s0





rcCs~t|d�}t|jdd�d�}d
}x@|D]8\}}t|d�}|j�dkr(||krRdStdd|�q(W||krztdd	|�dS)Nrtrr���0zHeader namezcontent-typezJContent-Type header found in a %s response, which must not return content.z,No Content-Type header found in headers (%s))r�r�)rrqrxr}r)rr�codeZNO_MESSAGE_BODYr�rrrrr�s

rcCs*t|dkpt|�tkd|t|�f�dS)Nz exc_info (%r) is not a tuple: %r)rrrl)r rrrr�srcCstt|ttf�d�dS)NzwYou should not return a string as your application iterator, instead return a single-item list containing a bytestring.)r�
isinstancer
r2)r*rrrr'�sr')�__all__�rerMri�compiler~r��Warningrrrrr%r&rrDr(r$rmrnrrrrr'rrrr�<module>os,

7#		#A