ok

Mini Shell

Direktori : /proc/self/root/lib64/python2.7/site-packages/M2Crypto/
Upload File :
Current File : //proc/self/root/lib64/python2.7/site-packages/M2Crypto/httpslib.pyo

�
z\Vc@s�dZddlZddlZddlZddlmZmZddlZddlTddlm	Z	ddl
Z
defd��YZde
fd	��YZd
efd��YZdS(seM2Crypto support for Python's httplib. 

Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved.i����N(turlsplitt
urlunsplit(t*(t
HTTPS_PORTtHTTPSConnectioncBsGeZdZeZddd�Zd�Zd�Zd�Z	d�Z
RS(sA
    This class allows communication via SSL using M2Crypto.
    cKs�d|_|j�}y|jd�Wntk
r9nXy|jd�Wntk
r^nXy|jd�Wntk
r�nX|r�td��ny|d|_Wn#tk
r�tjd�|_nXt	j
||||�dS(Ntkey_filet	cert_filetssl_contextsunknown keyword argumenttsslv23(tNonetsessiontkeystremovet
ValueErrortssl_ctxtKeyErrortSSLtContexttHTTPConnectiont__init__(tselfthosttporttstricttsslR((s7/usr/lib64/python2.7/site-packages/M2Crypto/httpslib.pyRs,	




cCsd}x�tj|j|jdtj�D]�\}}}}}d}z�yjtj|jd|�}|j	dk	r�|j
|j	�n|j|j|jf�||_d}dSWntj
k
r�}|}nXWd|dk	r�|j�nXq(W|dkrtd��n|�dS(Nitfamilys"Empty list returned by getaddrinfo(R	tsockettgetaddrinfoRRtSOCK_STREAMRt
ConnectionRR
tset_sessiontconnecttsockterrortclosetAssertionError(RR!Rt_R te((s7/usr/lib64/python2.7/site-packages/M2Crypto/httpslib.pyR.s(4	cCsdS(N((R((s7/usr/lib64/python2.7/site-packages/M2Crypto/httpslib.pyR"KscCs
|jj�S(N(R tget_session(R((s7/usr/lib64/python2.7/site-packages/M2Crypto/httpslib.pyR&\scCs
||_dS(N(R
(RR
((s7/usr/lib64/python2.7/site-packages/M2Crypto/httpslib.pyR_sN(t__name__t
__module__t__doc__Rtdefault_portR	RRR"R&R(((s7/usr/lib64/python2.7/site-packages/M2Crypto/httpslib.pyRs			tHTTPScBs eZeZdddd�ZRS(tcKs`tj||||�y|d|_Wn#tk
rLtjd�|_nX|j|j_dS(NRR(tHTTPRRRRRt_conn(RRRRR((s7/usr/lib64/python2.7/site-packages/M2Crypto/httpslib.pyRgs
N(R'R(Rt_connection_classR	R(((s7/usr/lib64/python2.7/site-packages/M2Crypto/httpslib.pyR+cstProxyHTTPSConnectioncBs�eZdZidd6dd6ZdZdZddddd�Zddd	�Zd
�Z	d�Z
d�Zd
�Zd�Z
d�ZRS(s�
    An HTTPS Connection that uses a proxy and the CONNECT request.

    When the connection is initiated, CONNECT is first sent to the proxy (along
    with authorization headers, if supplied). If successful, an SSL connection
    will be established over the socket through the proxy and to the target
    host.

    Finally, the actual request is sent over the SSL connection tunneling
    through the proxy.
    iPthttpi�thttpssProxy-Authorizations
User-AgentcKsAtj|||||�||_||_d|_d|_dS(s�
        Create the ProxyHTTPSConnection object.

        host and port are the hostname and port number of the proxy server.
        N(RRt	_usernamet	_passwordR	t_proxy_autht	_proxy_UA(RRRRtusernametpasswordR((s7/usr/lib64/python2.7/site-packages/M2Crypto/httpslib.pyR�s
			icCsAt|�\}}}}}	|s1td|�ny|jd�\}
}Wntk
rc|}nXy|jd�\}}
WnItk
r�|}y|j|}
Wq�tk
r�td|�q�XnX||_t|
�|_tdd|||	f�}t
jdkr$tj
||||�ntj
|||||�dS(Nsunknown URL type: %st@t:sunknown protocol for: %sii(ii(RR
tsplitt_portsRt
_real_hosttintt
_real_portRR	tsystversion_infoRt
putrequest(Rtmethodturlt	skip_hosttskip_accept_encodingtprototnetloctpathtquerytfragmenttusername_passwordt	host_portRRtrest((s7/usr/lib64/python2.7/site-packages/M2Crypto/httpslib.pyRB�s*



	cCse|j�|jj�kr'||_n|j�|jj�krN||_ntj|||�dS(N(tlowert
_UA_HEADERR6t_AUTH_HEADERR5Rt	putheader(Rtheadertvalue((s7/usr/lib64/python2.7/site-packages/M2Crypto/httpslib.pyRR�s
cOs2|js|j�|_ntj|||�dS(N(R5t_encode_authRt
endheaders(Rtargstkwargs((s7/usr/lib64/python2.7/site-packages/M2Crypto/httpslib.pyRV�s	cCs|tj|�|jj|j��t|j�}|j�|j}|dkrn|j�t	j
d|�n|j�dS(Ni�sProxy connection failed: %d(RRR tsendallt_get_connect_msgtHTTPResponsetbegintstatusR"RR!t
_start_ssl(Rtresponsetcode((s7/usr/lib64/python2.7/site-packages/M2Crypto/httpslib.pyR�s

	
cCs�d|j|jf}|d|j|jf}|jrV|d|j|jf}n|jr||d|j|jf}n|d}|S(s6 Return an HTTP CONNECT request to send to the proxy. sCONNECT %s:%d HTTP/1.1
s
Host: %s:%d
s%s: %s
s
(R=R?R6RPR5RQ(Rtmsg((s7/usr/lib64/python2.7/site-packages/M2Crypto/httpslib.pyRZ�s		
cCsFtj|j|j�|_|jj�|jj�|jj�dS(s* Make this connection's socket SSL-aware. N(RRRR t	setup_ssltset_connect_statetconnect_ssl(R((s7/usr/lib64/python2.7/site-packages/M2Crypto/httpslib.pyR^�s

cCsO|jo|jsdSd|j|jf}tj|�jdd�}d|S(s> Encode the username and password for use in the auth header. s%s:%ss
R,sBasic %sN(R3R4R	tbase64tencodestringtreplace(Rtuserpasstenc_userpass((s7/usr/lib64/python2.7/site-packages/M2Crypto/httpslib.pyRU�s
N(R'R(R)R<RQRPR	RRBRRRVRRZR^RU(((s7/usr/lib64/python2.7/site-packages/M2Crypto/httpslib.pyR0qs	
							(R)tstringR@RturlparseRRRethttplibRRRRR-R+R0(((s7/usr/lib64/python2.7/site-packages/M2Crypto/httpslib.pyt<module>s
U

Zerion Mini Shell 1.0