³ò ø$•Jc@sddkZddkZddkZddkZddkZddkZddkZddkZddkl Z l Z l Z ddk l Z ddklZddklZd„Zdefd„ƒYZd eifd „ƒYZd efd „ƒ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 „Z d 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.pyt log_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_GETKsc Cs£t|iƒ\}}h}d|d<|i|d<|ii|dq>~|_|iS(NiRqstransfer-encodingi(s connectionstransfer-encoding(RRSRuRcRxRdR4( Rt http_statusRQR9tcodeRt bad_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(t OpenSSL.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(RRŒRRŽ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/tipv6t webdir_conft certificateR*RJR)iÿÿÿÿ(t activeCounttforkt_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_METHODt ImportErrorRtAbortRtuse_privatekey_filetuse_certificate_fileR-taddress_familyt socket_typeRst server_bindtserver_activatet getsocknametaddrR˜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 threadingRR¯ReR^R_thasattrR¾R`tobjectRRªRƒRt mimetypestinitR-RRR°RR!( R£R§t use_threadsR•tmyuiR˜tuse_ipv6RRŸ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 s`  ‡