Plan 9 from Bell Labs’s /usr/web/sources/contrib/bichued/root/sys/lib/python/mercurial/hgweb/server.pyc

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


�
�c@sddkZddkZddkZddkZddkZddkZddkZddkZddkl	Z	l
Z
lZddkl
Z
ddklZddklZd�Zdefd��YZd	eifd
��YZdefd��YZd
�ZdS(i�N(thgtutilterror(thgweb(thgwebdir(t_cCsId|jo|idd�\}}n|d}}ti|�|fS(sx Return path and query splited from uri

    Just like CGI environment, the path is unquoted, the query is
    not.
    t?it(tsplitturllibtunquote(turitpathtquery((s)/sys/lib/python/mercurial/hgweb/server.pyt	_splitURIs

t
_error_loggercBs,eZd�Zd�Zd�Zd�ZRS(cCs
||_dS(N(thandler(tselfR((s)/sys/lib/python/mercurial/hgweb/server.pyt__init__scCsdS(N((R((s)/sys/lib/python/mercurial/hgweb/server.pytflushscCs|i|id��dS(Ns
(t
writelinesR(Rtstr((s)/sys/lib/python/mercurial/hgweb/server.pytwrite scCs(x!|D]}|iid|�qWdS(Ns
HG error:  %s(Rt	log_error(Rtseqtmsg((s)/sys/lib/python/mercurial/hgweb/server.pyR"s(t__name__t
__module__RRRR(((s)/sys/lib/python/mercurial/hgweb/server.pyRs			t
_hgwebhandlercBsteZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zdd
�Z
d�ZRS(
thttpcOs#d|_tii|||�dS(NsHTTP/1.1(tprotocol_versiontBaseHTTPServertBaseHTTPRequestHandlerR(Rtargstkargs((s)/sys/lib/python/mercurial/hgweb/server.pyR*s	cGs9|id|id|i�||f�|i�dS(Ns%s - - [%s] %s
i(Rtclient_addresstlog_date_time_stringR(RtfptformatR!((s)/sys/lib/python/mercurial/hgweb/server.pyt_log_any.s	cGs|i|ii||�dS(N(R'tserverterrorlog(RR&R!((s)/sys/lib/python/mercurial/hgweb/server.pyR4scGs|i|ii||�dS(N(R'R(t	accesslog(RR&R!((s)/sys/lib/python/mercurial/hgweb/server.pytlog_message7scCsHy|i�Wn3tij
o$}|dtijo�qDnXdS(Ni(tdo_hgwebtsocketRterrnotEPIPE(Rtinst((s)/sys/lib/python/mercurial/hgweb/server.pytdo_write:s
cCsyy|i�Wndtj
oX|idg�|id�dititi���}|i	d|i
|�nXdS(Ns500 Internal Server ErrorsInternal Server ErrorRs5Exception happened during processing request '%s':
%s(R1t
StandardErrort_start_responset_writetjoint	tracebacktformat_exceptiontsystexc_infoRR(Rttb((s)/sys/lib/python/mercurial/hgweb/server.pytdo_POSTAs
	cCs|i�dS(N(R;(R((s)/sys/lib/python/mercurial/hgweb/server.pytdo_GETKscCs�t|i�\}}h}d|d<|i|d<|ii|d<t|ii�|d<|i|d<|ii|d<|t|ii�|d<|i	d	|d
<|i	d	|d<|o||d<n|i
idjo|i
i
|d
<n|i
i|d
<|i
id�}|o||d<nx�g}|i
i�D]}|djo||q;q;~D]a}d|idd�i�}|i
i|�}	|	idd�i�}	|	o|	||<q`q`W|i|d<d |d<|i|d<|i|d<t|�|d<t|iti�|d<t|iti�|d<d	|d<t|_d|_g|_t|_ d|_!x-|ii"||i#�D]}
|i$|
�q�WdS(!NsCGI/1.1tGATEWAY_INTERFACEtREQUEST_METHODtSERVER_NAMEtSERVER_PORTtREQUEST_URItSCRIPT_NAMEt	PATH_INFOitREMOTE_HOSTtREMOTE_ADDRtQUERY_STRINGtCONTENT_TYPEscontent-lengthtCONTENT_LENGTHscontent-typetHTTP_t-Rs
RtSERVER_PROTOCOLiswsgi.versionswsgi.url_schemes
wsgi.inputswsgi.errorsswsgi.multithreadswsgi.multiprocesss
wsgi.run_once(scontent-typescontent-length(ii(%RRtcommandR(tserver_nameRtserver_porttprefixtlenR#theaderst
typeheadertNonettypet	getheadertkeystreplacetuppertstriptrequest_versiont
url_schemetrfileRt
isinstancetSocketServertThreadingMixIntForkingMixIntTruetclose_connectiontsaved_statust
saved_headerstFalsetsent_headerstlengthtapplicationR3R4(RRR
tenvRgt_[1]ththeaderthkeythvaltchunk((s)/sys/lib/python/mercurial/hgweb/server.pyR,NsZ






		
					cCs<|iptd��n|iidd�}t|d�|d<|i|�t}xR|iD]G}|i|�|di	�djot
}t|d�|_q`q`Wdg}|ii
dd�id�D]}||i�i	�q�~jo
t}n|o|id	d�n||_|i�t|_dS(
Ns.Sending headers before start_response() callediiscontent-lengthtcloset
connectionRt,t
Connection(RctAssertionErrorRRStintt
send_responseRaRdtsend_headertlowerReRgRQtgetRYRbtend_headersRf(RRctshould_closeRkRjttoken((s)/sys/lib/python/mercurial/hgweb/server.pytsend_headerss(




B
	
c	Csy|idd�\}}t|�}||_d}g}|D](}|di�|jo||q>q>~|_|iS(NiRqstransfer-encodingi(s
connectionstransfer-encoding(RRSRuRcRxRdR4(	Rthttp_statusRQR9tcodeRtbad_headersRjRk((s)/sys/lib/python/mercurial/hgweb/server.pyR3�s	.cCs�|iptd��n|ip|i�n|idj	o@t|�|ijotd��n|it|�|_n|ii|�|ii	�dS(Ns+data written before start_response() calledsLContent-length header sent, but more bytes than specified are being written.(
RcRtRfR}RgRSRPtwfileRR(Rtdata((s)/sys/lib/python/mercurial/hgweb/server.pyR4�s

N(RRR[RR'RR+R1R;R<R,R}RSR3R4(((s)/sys/lib/python/mercurial/hgweb/server.pyR&s						
		1		t_shgwebhandlercBs)eZdZd�Zd�Zd�ZRS(thttpscCsL|i|_ti|id|i�|_ti|id|i�|_dS(Ntrbtwb(trequestRqR-t_fileobjecttrbufsizeR\twbufsizeR�(R((s)/sys/lib/python/mercurial/hgweb/server.pytsetup�scCsaddkl}ytt|�i�Wn3|j
o'}|idtijo�q]nXdS(Ni�(tSysCallErrori(tOpenSSL.SSLR�tsuperR�R1R!R.R/(RR�R0((s)/sys/lib/python/mercurial/hgweb/server.pyR1�scCsVddkl}l}ytt|�i�Wn"||fj
ot|_nXdS(Ni�(R�tZeroReturnError(R�R�R�R�R�thandle_one_requestRaRb(RR�R�((s)/sys/lib/python/mercurial/hgweb/server.pyR��s	(RRR[R�R1R�(((s)/sys/lib/python/mercurial/hgweb/server.pyR��s		c
s�t}d�}�djo
�}n
�i}|iddd��t|iddd��}|iddd���od�id��n|idd	�}|idd
��|idd��||iddd
�ti��||iddd
�ti	��|o4yddk
l}WqEtj
o
t
}qEXn|o
ti}n1ttd�o
ti}nddd��Y}dt|tif��������fd��Y}	d|	f�fd��Y��o
t}
nt}
ddk}|i�y5|o��|f|
�Sn|	�|f|
�SWnAtij
o2}titd��||idf��nXdS(NcSs)|o|djot|d�Sn|S(NRJta(topen(topttdefault((s)/sys/lib/python/mercurial/hgweb/server.pytopenlog�stwebtaddressRtporti@ROt/tipv6twebdir_conftcertificateR*RJR)i�(tactiveCounttforkt_mixincBseZRS((RR(((s)/sys/lib/python/mercurial/hgweb/server.pyR��stMercurialHTTPServercsFeZeidjo
dZn��������fd�ZRS(tntic	sJtii|||��|_�|_t|_���fd�}|�|_�o�y&ddkl	}|i
|i�}Wn(tj
ot
itd���nX|i��|i��ti|i|i�}|i||�|_|i�|i�n|ii�dd!\|_|_�|_ti��|_dS(Ncsb�ot���}nE�dj	o"tti�i�i��}ntit	d���|S(Ns5There is no Mercurial repository here (.hg not found)(
RRSRRt
repositorytuitrootRt	RepoErrorR(thgwebobj(R�trepoR�(s)/sys/lib/python/mercurial/hgweb/server.pytmake_handler�s
"i�(tSSLsSSL support is unavailableii(Rt
HTTPServerRR*R)Ratdaemon_threadsRhtOpenSSLR�tContextt
SSLv23_METHODtImportErrorRtAbortRtuse_privatekey_filetuse_certificate_fileR-taddress_familytsocket_typeRstserver_bindtserver_activatetgetsocknametaddrR�ROtgetfqdntfqaddr(RR!R"R�R�tctxtsock(R*tssl_certR)ROR�R�R�R�(s)/sys/lib/python/mercurial/hgweb/server.pyR�s*				


"	(RRtostnametallow_reuse_addressR((R*R�R�R)R�ROR�R�(s)/sys/lib/python/mercurial/hgweb/server.pyR��s
tIPv6HTTPServercs)eZeedd�Z�fd�ZRS(tAF_INET6csF|idjotitd���nt�|�i||�dS(Ns$IPv6 is not available on this system(R�RSRR�RR�R(RR!tkwargs(R�(s)/sys/lib/python/mercurial/hgweb/server.pyRsN(RRtgetattrR-RSR�R((R�(s)/sys/lib/python/mercurial/hgweb/server.pyR�ss"cannot start server at '%s:%d': %si(( RaRSR�tconfigRuRYt
configboolR8tstdouttstderrt	threadingR�R�ReR^R_thasattrR�R`tobjectRR�R�Rt	mimetypestinitR-RRR�RR!(
R�R�tuse_threadsR�tmyuiR�tuse_ipv6R�R�R�RR�R0((	R�ROR*R�R�R�R�R)R�s)/sys/lib/python/mercurial/hgweb/server.pyt
create_server�sL	

	!!

:'
(R�R8R.R	RR-R^R6t	mercurialRRRt	hgweb_modRthgwebdir_modRtmercurial.i18nRRR�RR RR�R�(((s)/sys/lib/python/mercurial/hgweb/server.pys<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 webmaster@9p.io.