%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib64/python2.7/site-packages/tornado/
Upload File :
Create Path :
Current File : //lib64/python2.7/site-packages/tornado/http1connection.pyc

�
��L]c@�sNdZddlmZmZmZmZddlZddlmZddl	m
Z
mZddlm
Z
ddlmZddlmZdd	lmZmZdd
lmZddlmZdefd
��YZdefd��YZdefd��YZdejfd��YZdejfd��YZdefd��YZdS(sFClient and server implementations of HTTP/1.x.

.. versionadded:: 4.0
i(tabsolute_importtdivisiontprint_functiontwith_statementN(tFuture(t
native_strtutf8(tgen(thttputil(tiostream(tgen_logtapp_log(t
stack_context(tGzipDecompressort_QuietExceptioncB�seZd�ZRS(cC�sdS(N((tself((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyt__init__$s(t__name__t
__module__R(((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyR#st_ExceptionLoggingContextcB�s)eZdZd�Zd�Zd�ZRS(s�Used with the ``with`` statement when calling delegate methods to
    log any exceptions with the given logger.  Any exceptions caught are
    converted to _QuietException
    cC�s
||_dS(N(tlogger(RR((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyR-scC�sdS(N((R((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyt	__enter__0scC�s8|dk	r4|jjdd|||f�t�ndS(NsUncaught exceptiontexc_info(tNoneRterrorR(Rttyptvaluettb((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyt__exit__3s(RRt__doc__RRR(((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyR(s		tHTTP1ConnectionParameterscB�s,eZdZeddddded�ZRS(sDParameters for `.HTTP1Connection` and `.HTTP1ServerConnection`.
    cC�sO||_|pd|_|p!d|_||_||_||_||_dS(s;
        :arg bool no_keep_alive: If true, always close the connection after
            one request.
        :arg int chunk_size: how much data to read into memory at once
        :arg int max_header_size:  maximum amount of data for HTTP headers
        :arg float header_timeout: how long to wait for all headers (seconds)
        :arg int max_body_size: maximum amount of data for body
        :arg float body_timeout: how long to wait while reading body (seconds)
        :arg bool decompress: if true, decode incoming
            ``Content-Encoding: gzip``
        iN(t
no_keep_alivet
chunk_sizetmax_header_sizetheader_timeoutt
max_body_sizetbody_timeoutt
decompress(RRR R!R"R#R$R%((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyR<s				N(RRRtFalseRR(((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyR9s	tHTTP1ConnectioncB�seZdZddd�Zd�Zejd��Zd�Z	d�Z
d�Zd�Zd�Z
d	�Zd
�Zddd�Zd�Zdd
�Zd�Zd�Zd�Zd�Zd�Zd�Zejd��Zejd��Zejd��ZRS(s�Implements the HTTP/1.x protocol.

    This class can be on its own for clients, or via `HTTP1ServerConnection`
    for servers.
    cC�s�||_||_|dkr*t�}n||_||_|j|_|jjp]|jj|_	|jj
|_t|_
t|_t�|_t|_|j�d|_d|_d|_d|_d|_d|_dS(s
        :arg stream: an `.IOStream`
        :arg bool is_client: client or server
        :arg params: a `.HTTP1ConnectionParameters` instance or ``None``
        :arg context: an opaque application-defined object that can be accessed
            as ``connection.context``.
        N(t	is_clienttstreamRRtparamstcontextRR#tmax_buffer_sizet_max_body_sizeR$t
_body_timeoutR&t_write_finishedt_read_finishedRt_finish_futuret_disconnect_on_finisht_clear_callbackst_request_start_linet_response_start_linet_request_headerst_chunking_outputt_expected_content_remainingt_pending_write(RR)R(R*R+((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyRYs*							
					cC�s1|jjr$t||jj�}n|j|�S(sHRead a single HTTP response.

        Typical client-mode usage is to write a request using `write_headers`,
        `write`, and `finish`, and then call ``read_response``.

        :arg delegate: a `.HTTPMessageDelegate`

        Returns a `.Future` that resolves to None after the full response has
        been read.
        (R*R%t_GzipMessageDelegateR t
_read_message(Rtdelegate((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyt
read_response�scc�s�t}zZy|jjdd|jj�}|jjdkrF|V}nryBtj|jj	j
�|jj|d|jj	dtj�V}Wn-tj
k
r�|j�tjt��nX|j|�\}}|jr�tj|�}||_n!tj|�}||_||_|j||�|_t}tt��+|j||�}|dk	ra|VnWdQX|jdkr�t}tjt��nt}|jr?|jdk	r�|jjdkr�t}n|j}|dkr�t}n|dkrq|dkrqd	|ksd
|kr+tj d|��n|j!|�Vqqn2|j"d�d
krq|j#rq|jj$d�n|sG|j%|jr�|jnd||�}	|	dk	rG|j&dkr�|	VqDy:tj|jj	j
�|j&|	|jj	dtj�VWqDtj
k
r@t'j(d|j)�|jj�tjt��qDXqGnt|_*|j#sc|jr�t}tt��|j+�WdQXn|j,j-�r�|jdk	r�|jj.�r�|jj/|j0�|j,Vn|jr�|jr�|j�n|jdkrtjt��nWnEtj k
r^}
t'j(d|j)|
�|j�tjt��nXWd|r�tt��|j1�WdQXn|j2�Xtjt��dS(Ns
?

?
t	max_bytestio_looptquiet_exceptionstHEADi0idi�sContent-LengthsTransfer-Encodings!Response code %d cannot have bodytExpects100-continuesHTTP/1.1 100 (Continue)

isTimeout reading body from %ss"Malformed HTTP message from %s: %s(3R&R)tread_until_regexR*R!R"RRtwith_timeoutR?ttimeR	tStreamClosedErrortTimeoutErrortclosetReturnt_parse_headersR(Rtparse_response_start_lineR5tparse_request_start_lineR4R6t_can_keep_aliveR2tTrueRRtheaders_receivedtmethodtcodetHTTPInputErrorR;tgetR/twritet
_read_bodyR.R
tinfoR+R0tfinishR1tdonetclosedtset_close_callbackt_on_connection_closeton_connection_closeR3(RR<tneed_delegate_closet
header_futuretheader_datat
start_linetheaderst	skip_bodyRQtbody_futurete((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyR;�s�	

			
				
!	

	

	


cC�sAd|_d|_d|_|jdk	r=|jjd�ndS(s�Clears the callback attributes.

        This allows the request handler to be garbage collected more
        quickly in CPython by breaking up reference cycles.
        N(Rt_write_callbackt
_write_futuret_close_callbackR)RZ(R((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyR3s
			cC�stj|�|_dS(s�Sets a callback that will be run when the connection is closed.

        .. deprecated:: 4.0
            Use `.HTTPMessageDelegate.on_connection_close` instead.
        N(RtwrapRg(Rtcallback((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyRZscC�s[|jdk	r+|j}d|_|�n|jj�sM|jjd�n|j�dS(N(RgRR1RXt
set_resultR3(RRi((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyR[s		
cC�sO|jdk	r|jj�n|j�|jj�sK|jjd�ndS(N(R)RRHR3R1RXRj(R((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyRH&s

cC�sB|j�|j}d|_|jj�s>|jjd�n|S(s>Take control of the underlying stream.

        Returns the underlying `.IOStream` object and stops all further
        HTTP processing.  May only be called during
        `.HTTPMessageDelegate.headers_received`.  Intended for implementing
        protocols like websockets that tunnel over an HTTP handshake.
        N(R3R)RR1RXRj(RR)((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pytdetach-s
		cC�s
||_dS(stSets the body timeout for a single request.

        Overrides the value from `.HTTP1ConnectionParameters`.
        N(R.(Rttimeout((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pytset_body_timeout<scC�s
||_dS(swSets the body size limit for a single request.

        Overrides the value from `.HTTP1ConnectionParameters`.
        N(R-(RR#((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pytset_max_body_sizeCscC�s�g}|jrj||_|jtd|d|df��|jdkoad|koad|k|_n�||_|jtd	|d|d
f��|jjdko�|jdko�d|ko�d|k|_|jjd
kr|j	j
dd�j�dkrd|d<n|jr*d|d<n|jra|jjdksU|jdkrad|_n+d|kr�t
|d�|_n	d|_|jg|j�D]&\}}t|�dt|�^q��x3|D]+}d|kr�tdt|���q�q�Wd}	|jj�rGt�}	|_|	jtj��|	j�n�|dk	rhtj|�|_nt�}	|_dj|�d}
|r�|
|j|�7}
n|jj |
�|_!|j!j"|j#�|	S(s+Implements `.HTTPConnection.write_headers`.s%s %s HTTP/1.1iitPOSTtPUTtPATCHsContent-LengthsTransfer-EncodingsHTTP/1.1 %s %sisHTTP/1.1i0sHTTP/1.0t
Connectionts
keep-alives
Keep-AlivetchunkedRAs: s
sNewline in header: s
s

(RoRpRqN($R(R4tappendRRPR7R5tversionRQR6RStlowerR8tintRtextendtget_allt
ValueErrortreprR)RYRRft
set_exceptionR	RFt	exceptionRRhRetjoint
_format_chunkRTR9tadd_done_callbackt_on_write_complete(RR`RatchunkRitlinestntvtlinetfuturetdata((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyt
write_headersJsX		%	%	
	

	@

cC�s�|jdk	rU|jt|�8_|jdkrU|jj�tjd��qUn|jr�|r�tdt|��d|dS|SdS(Nis,Tried to write more data than Content-Lengths%xs
(	R8RtlenR)RHRtHTTPOutputErrorR7R(RR�((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyR��s
 cC�s�d}|jj�rKt�}|_|jjtj��|jj�nb|dk	rlt	j
|�|_nt�}|_|jj|j
|��|_|jj|j�|S(s�Implements `.HTTPConnection.write`.

        For backwards compatibility is is allowed but deprecated to
        skip `write_headers` and instead call `write()` with a
        pre-encoded header block.
        N(RR)RYRRfR}R	RFR~RRhReRTR�R9R�R�(RR�RiR�((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyRT�scC�s�|jdk	rT|jdkrT|jj�rT|jj�tjd|j��n|jr�|jj�s�|jjd�|_	|j	j
|j�q�nt|_
|js�t|_n|jjt�|j	dkr�|jd�n|j	j
|j�dS(s$Implements `.HTTPConnection.finish`.is0Tried to write %d bytes less than Content-Lengths0

N(R8RR)RYRHRR�R7RTR9R�R�RNR/R0R2tset_nodelayt_finish_request(R((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyRW�s$
			cC�s�|j�}|dk	r8t|tj�r8|j�n|jdk	ro|j}d|_|jjj	|�n|j
dk	r�|j
}d|_
|jd�ndS(N(R~Rt
isinstanceR	RFtresultReR)R?tadd_callbackRfRj(RR�texcRi((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyR��s
				cC�s�|jjrtS|jd�}|dk	r:|j�}n|jdkrS|dkSd|ks�|jdd�j�dks�|jdkr�|d
kStS(NRrsHTTP/1.1RHsContent-LengthsTransfer-EncodingRsRtRAtGETs
keep-alive(sHEADR�(R*RR&RSRRwRvRP(RR`Ratconnection_header((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyRM�s

cC�sa|j�|jr+|jr+|j�dS|jjt�|jj�s]|jj	d�ndS(N(R3R(R2RHR)R�R&R1RXRjR(RR�((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyR��s

cC�s�t|jd��jd�}|jd�}|| jd�}ytjj||�}Wn+tk
r�tj	d||d!��nX||fS(Ntlatin1s
s
s
sMalformed HTTP headers: %rid(
RtdecodetlstriptfindtrstripRtHTTPHeaderstparseR{RR(RR�teolR`Ra((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyRJ�s
	c�sNd|kr�d|dkrytjd|d��t�fd��D��rhtjd|d��n�d|d<nt|d�}||jkr�tjd��q�nd}|dkr�d	|ks�|dkr�tjd
|��nd}n|dk	r|j||�S|j	d	�dkr4|j
|�S|jrJ|j|�SdS(
NsContent-Lengtht,s,\s*c3�s|]}|�dkVqdS(iN((t.0ti(tpieces(s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pys	<genexpr>
ss$Multiple unequal Content-Lengths: %risContent-Length too longi�sTransfer-Encodings*Response with code %d should not have bodyRt(Ni(
tretsplittanyRRRRxR-Rt_read_fixed_bodyRSt_read_chunked_bodyR(t_read_body_until_close(RRQRaR<tcontent_length((R�s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyRUs2	
	
cc�s�x�|dkr�|jjt|jj|�dt�V}|t|�8}|jsZ|jrt	t
��tj|j
|��VWdQXqqWdS(Nitpartial(R)t
read_bytestminR*R RNR�R/R(RRRtmaybe_futuret
data_received(RR�R<tbody((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyR�(s	
cc�s0d}x#tr+|jjddd�V}t|j�d�}|dkrMdS||7}||jkrxtjd��n|}x�|r|jjt	||j
j�dt�V}|t|�8}|j
s�|jr�tt��tj|j|��VWdQXq�q�W|jjd�V}|dks	t�q	WdS(	Nis
R>i@ischunked body too largeR�i(RNR)t
read_untilRxtstripR-RRRR�R�R*R R�R/R(RRRR�R�tAssertionError(RR<t
total_sizet	chunk_lent
bytes_to_readR�tcrlf((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyR�2s&	
		
$cc�sJ|jj�V}|js#|jrFtt��|j|�WdQXndS(N(R)tread_until_closeR/R(RRR�(RR<R�((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyR�Js
N(RRRRRR=Rt	coroutineR;R3RZR[RHRkRmRnR�R�RTRWR�RMR�RJRUR�R�R�(((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyR'Ss.0	n							A			
				%
R:cB�sDeZdZd�Zd�Zejd��Zd�Zd�Z	RS(sIWraps an `HTTPMessageDelegate` to decode ``Content-Encoding: gzip``.
    cC�s||_||_d|_dS(N(t	_delegatet_chunk_sizeRt
_decompressor(RR<R ((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyRUs		cC�sR|jd�dkr?t�|_|jd|d�|d=n|jj||�S(NsContent-EncodingtgzipsX-Consumed-Content-Encoding(RSR
R�taddR�RO(RR`Ra((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyROZs	
cc�s�|jrf|}xn|rb|jj||j�}|rStj|jj|��Vn|jj}qWntj|jj|��VdS(N(R�R%R�RR�R�R�tunconsumed_tail(RR�tcompressed_datatdecompressed((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyR�es			cC�sG|jdk	r:|jj�}|r:|jj|�q:n|jj�S(N(R�RtflushR�R�RW(Rttail((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyRWss
cC�s
|jj�S(N(R�R\(R((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyR\s(
RRRRRORR�R�RWR\(((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyR:Rs			tHTTP1ServerConnectioncB�sJeZdZddd�Zejd��Zd�Zejd��Z	RS(sAn HTTP/1.x server.cC�s@||_|dkr!t�}n||_||_d|_dS(s�
        :arg stream: an `.IOStream`
        :arg params: a `.HTTP1ConnectionParameters` or None
        :arg context: an opaque application-defined object that is accessible
            as ``connection.context``
        N(R)RRR*R+t_serving_future(RR)R*R+((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyR�s			cc�s1|jj�y|jVWntk
r,nXdS(smCloses the connection.

        Returns a `.Future` that resolves after the serving loop has exited.
        N(R)RHR�t	Exception(R((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyRH�s


cC�sJt|tj�st�|j|�|_|jjj|jd��dS(snStarts serving requests on this connection.

        :arg delegate: a `.HTTPServerConnectionDelegate`
        cS�s
|j�S(N(R�(tf((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyt<lambda>�sN(	R�RtHTTPServerConnectionDelegateR�t_server_request_loopR�R)R?t
add_future(RR<((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyt
start_serving�scc�s�z�x�tr�t|jt|j|j�}|j||�}y|j|�V}Wngtj	tj
fk
rpdStk
r�|j�dSt
k
r�tjddt�|j�dSX|s�dStjVqWWd|j|�XdS(NsUncaught exceptionR(RNR'R)R&R*R+t
start_requestR=R	RFtUnsatisfiableReadErrorRRHR�R
RRtmomentton_close(RR<tconntrequest_delegatetret((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyR��s*	



N(
RRRRRRR�RHR�R�(((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyR��s
	( Rt
__future__RRRRR�ttornado.concurrentRttornado.escapeRRttornadoRRR	ttornado.logR
RRttornado.utilR
R�RtobjectRRtHTTPConnectionR'tHTTPMessageDelegateR:R�(((s=/usr/lib64/python2.7/site-packages/tornado/http1connection.pyt<module>s$"��1

Zerion Mini Shell 1.0