%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib64/python2.7/site-packages/tornado/
Upload File :
Create Path :
Current File : //usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyo

�
��L]c@�sddlmZmZmZmZddlmZddlmZm	Z	ddl
mZmZm
Z
mZmZddlmZddlmZmZddlmZddlmZmZmZdd	lmZdd
lmZddlmZddl Z ddl!Z!ddl"Z"ddl#Z#ddl$Z$ddl%Z%ddl&Z&dd
l'm(Z(yddl)Z)Wn e*k
r�ddl+j,Z)nXyddl-Z-Wne*k
r�e.Z-nXd�Z/de
fd��YZ0dej1fd��YZ2e3dkre
j4e0�e�ndS(i(tabsolute_importtdivisiontprint_functiontwith_statement(t	is_future(tutf8t_unicode(tHTTPResponset	HTTPErrortAsyncHTTPClienttmaint
_RequestProxy(thttputil(tHTTP1ConnectiontHTTP1ConnectionParameters(tStreamClosedError(tResolvertOverrideResolvert_client_ssl_defaults(tgen_log(t
stack_context(t	TCPClientN(tBytesIOcC�sdS(Ns/etc/pki/tls/cert.pem((((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyt_default_ca_certs#stSimpleAsyncHTTPClientcB�steZdZdddddddd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�ZRS(
siNon-blocking HTTP client with no external dependencies.

    This class implements an HTTP 1.1 client on top of Tornado's IOStreams.
    Some features found in the curl-based AsyncHTTPClient are not yet
    supported.  In particular, proxies are not supported, connections
    are not reused, and callers cannot select the network interface to be
    used.
    i
i@c		C�s�tt|�j|d|�||_tj�|_i|_i|_||_	||_
||_|r|||_t
|_ntd|�|_t|_|dk	r�td|jd|�|_ntd|jd|�|_dS(sCreates a AsyncHTTPClient.

        Only a single AsyncHTTPClient instance exists per IOLoop
        in order to provide limitations on the number of pending connections.
        ``force_instance=True`` may be used to suppress this behavior.

        Note that because of this implicit reuse, unless ``force_instance``
        is used, only the first call to the constructor actually uses
        its arguments. It is recommended to use the ``configure`` method
        instead of the constructor to ensure that arguments take effect.

        ``max_clients`` is the number of concurrent requests that can be
        in progress; when this limit is reached additional requests will be
        queued. Note that time spent waiting in this queue still counts
        against the ``request_timeout``.

        ``hostname_mapping`` is a dictionary mapping hostnames to IP addresses.
        It can be used to make local DNS changes when modifying system-wide
        settings like ``/etc/hosts`` is not possible or desirable (e.g. in
        unittests).

        ``max_buffer_size`` (default 100MB) is the number of bytes
        that can be read into memory at once. ``max_body_size``
        (defaults to ``max_buffer_size``) is the largest response body
        that the client will accept.  Without a
        ``streaming_callback``, the smaller of these two limits
        applies; with a ``streaming_callback`` only ``max_body_size``
        does.

        .. versionchanged:: 4.2
           Added the ``max_body_size`` argument.
        tdefaultstio_looptresolvertmappingN(tsuperRt
initializetmax_clientstcollectionstdequetqueuetactivetwaitingtmax_buffer_sizetmax_header_sizet
max_body_sizeRtFalsetown_resolverRtTruetNoneRRt
tcp_client(	tselfRRthostname_mappingR%RRR&R'((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyR0s$$								cC�s=tt|�j�|jr,|jj�n|jj�dS(N(RRtcloseR)RR,(R-((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyR/js	cC�s�t�}|jj|||f�t|j�|jks}|jj|jj�t	|j
|j�tj
|j|��}nd}|||f|j|<|j�|jr�tjdt|j�t|j�f�ndS(NsImax_clients limit reached, request queued. %d active, %d queued requests.(tobjectR"tappendtlenR#RRtadd_timeoutttimetmintconnect_timeouttrequest_timeoutt	functoolstpartialt_on_timeoutR+R$t_process_queueRtdebug(R-trequesttcallbacktkeyttimeout_handle((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyt
fetch_implps		

		c	C�s�tj���x�|jr�t|j�|jkr�|jj�\}}}||jkr^qn|j|�||f|j|<t	j
|j|�}|j|||�qWWdQXdS(N(
RtNullContextR"R2R#RtpopleftR$t_remove_timeoutR8R9t_release_fetcht_handle_request(R-R?R=R>trelease_callback((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyR;�s
$
cC�stS(N(t_HTTPConnection(R-((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyt_connection_class�sc
C�s;|j�|j|||||j|j|j|j�	dS(N(RIRR%R,R&R'(R-R=RGtfinal_callback((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyRF�s	cC�s|j|=|j�dS(N(R#R;(R-R?((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyRE�s
cC�sU||jkrQ|j|\}}}|dk	rD|jj|�n|j|=ndS(N(R$R+Rtremove_timeout(R-R?R=R>R@((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyRD�s
cC�s�|j|\}}}|jj|||f�t|ddtdd�d|jj�|j�}|jj||�|j|=dS(NiWterrortTimeouttrequest_time(	R$R"tremoveRRRR4t
start_timetadd_callback(R-R?R=R>R@ttimeout_response((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyR:�sN(
t__name__t
__module__t__doc__R+RR/RAR;RIRFRERDR:(((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyR's	7							RHcB�s�eZedddddddg�Zd�Zd�Zd	�Zd
�Zd�Zd�Z	d
�Z
d�Zd�Zd�Z
d�Zd�Zd�Zd�Zd�Zd�ZRS(tGETtHEADtPOSTtPUTtDELETEtPATCHtOPTIONSc
C�sU|j�|_||_||_||_||_||_||_||_||_	|	|_
d|_d|_
g|_d|_d|_d|_tj|j���tjt|jj��|_|jjdkr�td|jj��n|jj}
d|
kr%|
jd�\}}}
ntj|
�\}
}|dkrg|jjdkr^dnd}nt j!d|
�r�|
dd	!}
n|
|_"|j#t$kr�t%j&}n	t%j'}|j(|jj�}t)|jj*|jj+�}|r|jj,|j|tj-|j.��|_n|jj/|
|d
|d|d|jd
|j0�WdQXdS(NthttpthttpssUnsupported url scheme: %st@i�iPs^\[.*\]$ii����taftssl_optionsR%R>(R]R^(1R4RPRtclientR=RGRJR%R,R&R'R+tcodetheaderstchunkst
_decompressort_timeoutt	_sockaddrRtExceptionStackContextt_handle_exceptionturlparseturlsplitRturltparsedtschemet
ValueErrortnetloct
rpartitionRtsplit_host_and_porttretmatchtparsed_hostnamet
allow_ipv6R(tsockettAF_INETt	AF_UNSPECt_get_ssl_optionsR5R6R7R3twrapR:tconnectt_on_connect(R-RRbR=RGRJR%R,R&R'Rqtuserpasst_thosttportR`Rattimeout((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyt__init__�sV															!			
	cC�sO|dkrK|jjdk	r(|jjS|jjrn|jjdkrn|jjdkrn|jjdkrntSi}|jjr�tj	|d<n|jjdk	r�|jj|d<nt
td�s�t�|d<n|jjdk	r�|jj|d<n|jjdk	r|jj|d<ntj
dkr:d	|d
<n
tj|d<|SdS(
NR^t	cert_reqstca_certstcreate_default_contexttkeyfiletcertfileiisDEFAULT:!SSLv2:!EXPORT:!DEStcipherstssl_version(ii(R=RaR+t
validate_certR�tclient_certt
client_keyRtsslt
CERT_REQUIREDthasattrRtsystversion_infotPROTOCOL_TLSv1(R-RoRa((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyR{�s0



cC�s.d|_|jdk	r*tdd��ndS(NiWRM(R+RgRJR(R-((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyR:s	cC�s2|jdk	r.|jj|j�d|_ndS(N(RgR+RRK(R-((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyRDsc
C�sl|jdkr|j�dS||_|jj|j�|j�|jdkrVdS|jjr�|j	j
|j|jjtj
|j��|_n|jj|jkr�|jjr�td|jj��nx6d"D].}t|j|d�r�td|��q�q�Wd|jjkr/d	|jjd<nd
|jjkr�d|jjkry|jjjd�d|jjd
<q�|jj|jjd
<nd#\}}|jjdk	r�|jj|jj}}n3|jjdk	r�|jj}|jjp�d
}n|dk	ro|jjd$kr5td|jj��nt |�dt |�}dt!j"|�|jjd<n|jj#r�|jj#|jjd<n|jjs|jjd%k}|jj$dk	p�|jj%dk	}|r�|s�|r|rtd|rdnd
|jjf��qn|jj&r=d|jjd<n|jj$dk	rtt't(|jj$��|jjd<n|jjdkr�d|jjkr�d|jjd<n|jj)r�d|jjd<n|jj*p�d |jj+r�d!|jj+nd
}|j,|�|_-t.j/|jj|d
�}	|j-j0|	|jj�|jj&r[|j1�n
|j2t3�dS(&Nsunknown method %stnetwork_interfacet
proxy_hostt
proxy_porttproxy_usernametproxy_passwords%s not supportedt
ConnectionR/tHostR_i����ttbasicsunsupported auth_mode %st:sBasic t
Authorizations
User-AgentRXR[RYsLBody must %sbe None for method %s (unless allow_nonstandard_methods is true)snot s100-continuetExpectsContent-LengthsContent-Types!application/x-www-form-urlencodedtgzipsAccept-Encodingt/t?(R�R�R�R�R�(NN(NR�(RXR[RY(4RJR+R/tstreamtset_close_callbackton_connection_closeRDR=R7RR3RPRR|R:Rgtmethodt_SUPPORTED_METHODStallow_nonstandard_methodstKeyErrortgetattrtNotImplementedErrorRdRnRqRrtusernametpasswordt
auth_usernamet
auth_passwordt	auth_modeRpRtbase64t	b64encodet
user_agenttbodyt
body_producertexpect_100_continuetstrR2tdecompress_responsetpathtqueryt_create_connectiont
connectionRtRequestStartLinet
write_headerst_read_responset_write_bodyR*(
R-R�R?R�R�tautht
body_expectedtbody_presenttreq_patht
start_line((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyR~s�
	
	

&

(#
cC�sP|jt�t|ttdtd|jd|jd|jj�|j�}|S(Nt
no_keep_aliveR&R't
decompress(	tset_nodelayR*R
RR&R'R=R�Rh(R-R�R�((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyR�os
		c�s��jjdk	r+�jj�jj�nb�jjdk	r��jj�jj�}t|�r���fd�}�jj||�dSn�jj	��r��j
�ndS(Nc�s.|j��jj��r*�j�ndS(N(tresultR�tfinishR�(tfut(R-t
start_read(s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyton_body_written�s

(R=R�R+R�twriteR�RRt
add_futureR�R�(R-R�R�R�((R-R�s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyR�{s
cC�s&|jj|jj|�d��dS(NcS�s
|j�S(N(R�(tf((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyt<lambda>�s(RR�R�t
read_response(R-((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyR��s	cC�s/|jdk	r+|j}d|_|�ndS(N(RGR+(R-RG((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyt_release�s		cC�sE|j�|jdk	rA|j}d|_|jj||�ndS(N(R�RJR+RRQ(R-tresponseRJ((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyt
_run_callback�s

		c	C�s�|jr�|j�t|t�r4tdd�}n|jt|jdd|d|jj	�|j
��t|d�r�|jj
�ntSt|t�SdS(NiWs
Stream closedRLRNR�(RJRDt
isinstanceRRR�RR=RR4RPR�R�R/R*(R-ttyptvaluettb((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyRj�s	
cC�sq|jdk	rmd}|jjr0|jj�nytd|��Wqmtk
ri|jtj��qmXndS(NsConnection closediW(RJR+R�RLRRjR�texc_info(R-tmessage((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyR��s
cC�s�|jjr,|jdkr,|jt�dS||_|j|_|j|_|jjdk	r�|jjd|�x7|jj	�D]&\}}|jjd||f�q�W|jjd�ndS(Nids
%s %s %s
s%s: %s
s
(
R=R�RcR�R(Rdtreasontheader_callbackR+tget_all(R-t
first_lineRdtktv((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pytheaders_received�s
	cC�s�dj|j�}|j�t|jd|j�}|jjra|jjdkra|jdkratj|jj�}t	j
|jj|jd�|_|jjd	|_|jd
=|jdkrd|_
d|_xBdd
ddgD]+}y|jj|=Wq�tk
rq�Xq�Wn||_|j}d|_|j�|jj||�|j�dS|jjryt�}nt|�}t||jdt|dd�d|jd|jj�|jd|d|jj�}|j|�|j�dS(NR�toriginal_requestii-i.i/i3tLocationiR�RVsContent-LengthsContent-TypesContent-EncodingsTransfer-EncodingR�RdRNtbuffert
effective_url(i-i.i/i3(i.i/(tjoinReRDR�R=tfollow_redirectst
max_redirectsRctcopyRkturljoinRmRdR�R+R�R�R�RJR�Rbtfetcht_on_end_requesttstreaming_callbackRRRR4RPR�(R-tdataR�tnew_requestthRJR�R�((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyR��sN

			
			

	
cC�s|jj�dS(N(R�R/(R-((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyR�scC�s9|jjdk	r%|jj|�n|jj|�dS(N(R=R�R+ReR1(R-tchunk((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyt
data_receiveds(RSRTtsetR�R�R{R:RDR~R�R�R�R�R�RjR�R�R�R�R�(((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyRH�s"!	7	1			P							
		2	t__main__(5t
__future__RRRRttornado.concurrentRttornado.escapeRRttornado.httpclientRRR	R
RttornadoRttornado.http1connectionR
Rttornado.iostreamRttornado.netutilRRRttornado.logRRttornado.tcpclientRR�R R�R8RtRxR�tioRRktImportErrorturllib.parsetparseR�R+RRtHTTPMessageDelegateRHRSt	configure(((s?/usr/lib64/python2.7/site-packages/tornado/simple_httpclient.pyt<module>sB"(


	��b


Zerion Mini Shell 1.0