Current File : //opt/imh-python/lib/python2.7/test/ssl_servers.pyc
�
��Wc@s0ddlZddlZddlZddlZddlZddlZddlmZm	Z	ddl
mZddlm
Zejd�Zejje�ZejZejjed�Zdefd��YZd	efd
��YZde	fd��YZd
ejfd��YZdeedd�Zedkr,ddl Z e j!dd�Z"e"j#ddde$dddd�e"j#ddddde%dddd �e"j#d!d"dd#de&dd$dd%�e"j#d&dd'de'dd(dd)�e"j#d*dd+de'dd,�e"j#d-dd.de'dd(dd/�e"j(�Z)e)j*e_*e)j+r\eZ,neZ,ej-�e,_.ej/ej0j1�Z2e2j3e�e)j4r�e2j5e)j4�ne)j6r�e2j7e)j6�ne)j8r�e2j9e)j8�ned0e)j:fe,e2�Z;e)j*rd1j<e)�GHne;j=d2�ndS(3i����N(t
HTTPServertBaseHTTPRequestHandler(tSimpleHTTPRequestHandler(ttest_supportt	threadingskeycert.pemtHTTPSServercBs#eZd�Zd�Zd�ZRS(cCs tj|||�||_dS(N(t_HTTPServert__init__tcontext(tselftserver_addresst
handler_classR((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/ssl_servers.pyRscCsd|jj|j|jfS(Ns
<%s %s:%s>(t	__class__t__name__tserver_nametserver_port(R	((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/ssl_servers.pyt__str__s	cCsty1|jj�\}}|jj|dt�}Wn6tk
ri}tjrctj	j
d|�n�nX||fS(Ntserver_sidesGot an error:
%s
(tsockettacceptRtwrap_sockettTruetOSErrortsupporttverbosetsyststderrtwrite(R	tsocktaddrtsslconnte((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/ssl_servers.pytget_request!s	(R
t
__module__RRR (((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/ssl_servers.pyRs		tRootedHTTPRequestHandlercBs,eZdZeZdZd�Zd�ZRS(s
TestHTTPS/1.0icCs�tj|�d}tjjtj|��}|jd�}td|�}|j	}xS|D]K}tjj
|�\}}tjj|�\}}tjj||�}q\W|S(s�Translate a /-separated PATH to the local filename syntax.

        Components that mean special things to the local file system
        (e.g. drive or directory names) are ignored.  (XXX They should
        probably be diagnosed.)

        it/N(turlparsetostpathtnormpathturllibtunquotetsplittfiltertNonetroott
splitdrivetjoin(R	R&twordstwordtdrivethead((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/ssl_servers.pyttranslate_path7s		
cGsRtjrNtjjd|jj|jj|jj	�|j
�||f�ndS(Ns server (%s:%d %s):
   [%s] %s
(RRRtstdoutRtserverR
Rtrequesttciphertlog_date_time_string(R	tformattargs((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/ssl_servers.pytlog_messageKs				(R
R!tserver_versionthereR-ttimeoutR4R<(((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/ssl_servers.pyR"-s
	tStatsRequestHandlercBs2eZdZdZed�Zd�Zd�ZRS(sSExample HTTP request handler which returns SSL statistics on GET
    requests.
    sStatsHTTPS/1.0cCs�|jjj}|j}i|j�d6|j�d6|j�d6}tj|�}|j	d�}|j
d�|jdd�|jdtt
|���|j�|r�|jj|�nd	S(
sServe a GET request.t
session_cacheR8tcompressionsutf-8i�sContent-typestext/plain; charset=utf-8sContent-LengthN(trfiletrawt_sockRt
session_statsR8RBtpprinttpformattencodet
send_responsetsend_headertstrtlentend_headerstwfileR(R	t	send_bodyRRtstatstbody((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/ssl_servers.pytdo_GET]s	



cCs|jdt�dS(sServe a HEAD request.RPN(RStFalse(R	((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/ssl_servers.pytdo_HEADoscGs#tjrtj|||�ndS(N(RRRtlog_request(R	R:R;((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/ssl_servers.pyRVss	(R
R!t__doc__R=RRSRURV(((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/ssl_servers.pyR@Vs
	tHTTPSServerThreadcBs>eZedd�Zd�Zdd�Zd�Zd�ZRS(cCsVd|_t|df|pt|�|_|jj|_tjj	|�t
|_dS(Ni(R,tflagRR"R6RtportRtThreadRRtdaemon(R	RthostR((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/ssl_servers.pyRzs		cCsd|jj|jfS(Ns<%s %s>(RR
R6(R	((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/ssl_servers.pyR�scCs||_tjj|�dS(N(RYRR[tstart(R	RY((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/ssl_servers.pyR^�s	cCsB|jr|jj�nz|jjd�Wd|jj�XdS(Ng�������?(RYtsetR6t
serve_forevertserver_close(R	((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/ssl_servers.pytrun�s
	cCs|jj�dS(N(R6tshutdown(R	((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/ssl_servers.pytstop�sN(	R
R!tHOSTR,RRR^RbRd(((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/ssl_servers.pyRXxs
			cs�|dkr$tjtjj�}n|j|�t|||��tj�}�j	|�|j
��fd�}|j|��S(NcsPtjrtjjd�n�j�tjrBtjjd�n�j�dS(Nsstopping HTTPS server
sjoining HTTPS thread
(RRRR5RRdR/((R6(si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/ssl_servers.pytcleanup�s	
	(R,tssltcreate_default_contexttPurposetCLIENT_AUTHtload_cert_chainRXRtEventR^twaitt
addCleanup(tcaseRtcertfileR]RRYRf((R6si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/ssl_servers.pytmake_https_server�s



t__main__tdescriptionsERun a test HTTPS server. By default, the current directory is served.s-ps--portttypetdefaultiQthelps(port to listen on (default: %(default)s)s-qs--quiettdestRtactiontstore_falsesbe less verboses-ss--statstuse_stats_handlert
store_truesalways return stats pages--curve-namet
curve_nametstores&curve name for EC-based Diffie-Hellmans	--cipherstcipherssallowed cipher lists--dhtdh_files!PEM file containing DH parametersts'Listening on https://localhost:{0.port}g�������?(>R%RRgRGR(R$tBaseHTTPServerRRRtSimpleHTTPServerRttestRRt
import_moduleRR&tdirnamet__file__R>ReR/tCERTFILERR"R@R[RXR,RqR
targparsetArgumentParsertparsertadd_argumenttintRRTRLt
parse_argsR;RRzRtgetcwdR-RhRiRjRRkR|tset_ecdh_curveRtload_dh_paramsR~tset_ciphersRZR6R:R`(((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/ssl_servers.pyt<module>sj	)"