Plan 9 from Bell Labs’s /usr/web/sources/contrib/jas/root/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


��Qc@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	m
Z
ddlmZddl
mZd�Zdefd��YZdejfd	��YZd
efd��YZdefd
��YZy$ddlmZe�ejZWnEek
ree	jed�rLejZqfdefd��YZnXd�Zdeeejfd��YZdefd��YZ d�Z!dS(i�N(tutilterror(tcommon(t_cCsGd|kr'|jdd�\}}n
|d}}tj|�|fS(s�Return path and query that has been split from uri

    Just like CGI environment, the path is unquoted, the query is
    not.
    t?it(tsplitturllibtunquote(turitpathtquery((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pyt	_splitURIs
t
_error_loggercBs,eZd�Zd�Zd�Zd�ZRS(cCs
||_dS(N(thandler(tselfR((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pyt__init__scCsdS(N((R((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pytflushscCs|j|jd��dS(Ns
(t
writelinesR(Rtstr((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pytwritescCs(x!|D]}|jjd|�qWdS(Ns
HG error:  %s(Rt	log_error(Rtseqtmsg((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pyR!s
(t__name__t
__module__RRRR(((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pyR
s			t_httprequesthandlercBs�eZdZed��Zd�Zd�Zd�Zd�Zddd�Z	d�Z
d	�Zd
�Zd�Z
d�Zdd
�Zd�Zd�ZRS(thttpcCsdS(s*Prepare .socket of new HTTPServer instanceN((t
httpservertssl_cert((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pytpreparehttpserver)scOs#d|_tjj|||�dS(NsHTTP/1.1(tprotocol_versiontBaseHTTPServertBaseHTTPRequestHandlerR(Rtargstkargs((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pyR.s	cGs9|jd|jd|j�||f�|j�dS(Ns%s - - [%s] %s
i(Rtclient_addresstlog_date_time_stringR(RtfptformatR"((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pyt_log_any2s	cGs|j|jj||�dS(N(R(tserverterrorlog(RR'R"((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pyR8scGs|j|jj||�dS(N(R(R)t	accesslog(RR'R"((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pytlog_message;st-c
Cs�g|jj�D]}|djd�r|^q}|jd|jt|�t|�djgt|�D]}d|^qi��dS(Nisx-s"%s" %s %s%sRs %s:%s(theaderstitemst
startswithR,trequestlineRtjointsorted(Rtcodetsizethtxheaders((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pytlog_request>s5	cCsDy|j�Wn/tjk
r?}|dtjkr@�q@nXdS(Ni(tdo_hgwebtsocketRterrnotEPIPE(Rtinst((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pytdo_writeDs
cCswy|j�Wnbtk
rr|jdg�|jd�djtjtj���}|j	d|j
|�nXdS(Ns500 Internal Server ErrorsInternal Server ErrorRs5Exception happened during processing request '%s':
%s(R>t	Exceptiont_start_responset_writeR2t	tracebacktformat_exceptiontsystexc_infoRR
(Rttb((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pytdo_POSTKs

	cCs|j�dS(N(RG(R((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pytdo_GETUsc
Cs�t|j�\}}i}d|d<|j|d<|jj|d<t|jj�|d<|j|d<|jj|d<|t|jj�|d<|j	d	|d
<|j	d	|d<|r�||d<n|j
jdkr�j
j
|d
<n|j
j|d
<|j
jd�}|r||d<nx�g|j
j�D]}|d!kr1|^q1D]_}d|jdd�j�}|j
j|�}|jdd�j�}|rM|||<qMqMW|j|d<d"|d<|j|d<|jdd�j�dkrtj|j|jj�|_n|j|d<t|�|d<t|jtj�|d<t|jtj �|d<d	|d <d|_!g|_"t#|_$d|_%d|_&x-|jj'||j(�D]}	|j)|	�q�W|j$s�|j*�n|j+�dS(#NsCGI/1.1tGATEWAY_INTERFACEtREQUEST_METHODtSERVER_NAMEtSERVER_PORTtREQUEST_URItSCRIPT_NAMEt	PATH_INFOitREMOTE_HOSTtREMOTE_ADDRtQUERY_STRINGtCONTENT_TYPEscontent-lengthtCONTENT_LENGTHscontent-typetHTTP_R-Rs
RtSERVER_PROTOCOLiswsgi.versionswsgi.url_schemetHTTP_EXPECTs100-continues
wsgi.inputswsgi.errorsswsgi.multithreadswsgi.multiprocesss
wsgi.run_once(scontent-typescontent-length(ii(,RR
tcommandR)tserver_nameRtserver_porttprefixtlenR$R.t
typeheadertNonettypet	getheadertkeystreplacetuppertstriptrequest_versiont
url_schemetgettlowerRtcontinuereadertrfiletwfileRR
t
isinstancetSocketServertThreadingMixIntForkingMixIntsaved_statust
saved_headerstFalsetsent_headerstlengtht_chunkedtapplicationR@RAtsend_headerst_done(
RR
RtenvRtR6theaderthkeythvaltchunk((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pyR9Xs`







!
		
						
cCs1|jstd��n|jjdd�}t|d�|d<|j|�d|_t|_xJ|j	D]?}|j
|�|dj�dkrjt|d�|_qjqjW|jdkr|dtj
kr|jo�jdk|_|jr|j
dd�q|j
dd	�n|j�t|_dS(
Ns.Sending headers before start_response() callediiscontent-lengthsHTTP/1.1sTransfer-Encodingtchunkedt
Connectiontclose(RptAssertionErrorRR^tintt
send_responseRtRrRuRqtsend_headerRhRtHTTP_NOT_MODIFIEDtclose_connectionRetend_headerstTrueRs(RRpR6((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pyRw�s(	
		

	
cCsl|jdd�\}}t|�}||_d}g|D]"}|dj�|kr:|^q:|_|jS(Nit
connectionstransfer-encodingi(s
connectionstransfer-encoding(RR^R�RpRhRqRA(Rthttp_statusR.RER4Rtbad_headersR6((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pyR@�s	
%cCs�|jstd��n|js.|j�n|jdk	rzt|�|jkratd��n|jt|�|_n(|jr�|r�dt|�|f}n|jj	|�|jj
�dS(Ns+data written before start_response() calledsLContent-length header sent, but more bytes than specified are being written.s%x
%s
(RpR�RsRwRtR^R\RuRkRR(Rtdata((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pyRA�s		
cCs-|jr)|jjd�|jj�ndS(Ns0

(RuRkRR(R((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pyRx�s	N(RRRftstaticmethodRRR(RR,R8R>RGRHR9RwR^R@RARx(((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pyR%s						
		7			t_httprequesthandleropensslcBs>eZdZdZed��Zd�Zd�Zd�ZRS(s HTTPS handler based on pyOpenSSLthttpscCs�yddl}|jjWn&tk
rBtjtd���nX|jj|jj�}|j|�|j	|�t
j
|j|j�}|jj
||�|_
|j�|j�dS(Ni�sSSL support is unavailable(tOpenSSLtSSLtContexttImportErrorRtAbortRt
SSLv23_METHODtuse_privatekey_filetuse_certificate_fileR:taddress_familytsocket_typeRtserver_bindtserver_activate(RRR�tctxtsock((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pyR�s



cCsL|j|_tj|jd|j�|_tj|jd|j�|_dS(Ntrbtwb(trequestR�R:t_fileobjecttrbufsizeRjtwbufsizeRk(R((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pytsetup�scCsYddl}ytj|�Wn5|jjk
rT}|jdtjkrU�qUnXdS(Ni�i(R�RR>R�tSysCallErrorR"R;R<(RR�R=((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pyR>�scCsPddl}ytj|�Wn,|jj|jjfk
rKt|_nXdS(Ni�(R�Rthandle_one_requestR�R�tZeroReturnErrorR�R�(RR�((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pyR��s	(	RRt__doc__RfR�RR�R>R�(((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pyR��s		t_httprequesthandlersslcBs,eZdZdZed��Zd�ZRS(s=HTTPS handler based on Pythons ssl module (introduced in 2.6)R�cCsnyddl}|jWn&tk
r?tjtd���nX|j|jdtd|d|j�|_dS(Ni�sSSL support is unavailabletserver_sidetcertfiletssl_version(	tssltwrap_socketR�RR�RR:R�tPROTOCOL_SSLv23(RRR�((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pyR�s
cCsL|j|_tj|jd|j�|_tj|jd|j�|_dS(NR�R�(R�R�R:R�R�RjR�Rk(R((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pyR��s(RRR�RfR�RR�(((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pyR��s
(tactiveCounttforkt_mixincBseZRS((RR(((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pyR�	scCs#|r|dkrt|d�S|S(NR-ta(topen(topttdefault((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pytopenlogs
tMercurialHTTPServercBs)eZejdkrdZnd�ZRS(tntic	Kstjj||||�t|_||_|j||jdd��|jddd�}|rxd|jd�}n||_	t
|jddd�tj�}t
|jddd�tj
�}||_||_|jj�d	d
!\|_|_tj|d	�|_dS(NtwebtcertificateR[Rt/R+R-R*ii(R t
HTTPServerRR�tdaemon_threadsRvRtconfigRdR[R�RDtstdouttstderrR+R*R:tgetsocknametaddrtporttgetfqdntfqaddr(	RtuitappR�RtkwargsR[talogtelog((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pyRs			!!		"(RRtostnametallow_reuse_addressR(((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pyR�s	tIPv6HTTPServercBs#eZeedd�Zd�ZRS(tAF_INET6cOsD|jdkr'tjtd���ntt|�j||�dS(Ns$IPv6 is not available on this system(R�R^Rt	RepoErrorRtsuperR�R(RR"R�((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pyR-sN(RRtgetattrR:R^R�R(((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pyR�+scCs|jdd�r3tjd
kr*t}q9t}nt}|jdd�rTt}nt}ddl	}|j
�|jddd�}tj|jdd	d
��}y|||||f|�SWn?t
jk
r}tjtd�|||jdf��nXdS(NR�R�iitipv6i�taddressRR�i@s"cannot start server at '%s:%d': %si(ii(R�RDtversion_infoR�R�Rt
configboolR�R�t	mimetypestinitRtgetportR:RR�RR"(R�R�RtclsR�R�R�R=((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pyt
create_server2s"			
("R�RDR;RR R:RmRBt	mercurialRRtmercurial.hgwebRtmercurial.i18nRRtobjectR
R!RR�R�t	threadingR�RnR�R�tsafehasattrRoR�R�R�R�R�(((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/server.pyt<module>	s(`	�)

	

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].