comparison mercurial/hgweb/hgweb_mod.py @ 2514:419c42223bee

Really fix http headers for web UI and issue 254. This also arranges for static content to allow a keepalive connection.
author Eric Hopper <hopper@omnifarious.org>
date Tue, 27 Jun 2006 09:33:12 -0700
parents 6350b01d173f
children d5a3cc6520d5
comparison
equal deleted inserted replaced
2513:f22e3e8fd457 2514:419c42223bee
8 8
9 import os 9 import os
10 import os.path 10 import os.path
11 import mimetypes 11 import mimetypes
12 from mercurial.demandload import demandload 12 from mercurial.demandload import demandload
13 demandload(globals(), "re zlib ConfigParser cStringIO sys tempfile") 13 demandload(globals(), "re zlib ConfigParser mimetools cStringIO sys tempfile")
14 demandload(globals(), "mercurial:mdiff,ui,hg,util,archival,templater") 14 demandload(globals(), "mercurial:mdiff,ui,hg,util,archival,templater")
15 demandload(globals(), "mercurial.hgweb.common:get_mtime,staticfile") 15 demandload(globals(), "mercurial.hgweb.common:get_mtime,staticfile")
16 from mercurial.node import * 16 from mercurial.node import *
17 from mercurial.i18n import gettext as _ 17 from mercurial.i18n import gettext as _
18 18
650 raise Exception("suspicious path") 650 raise Exception("suspicious path")
651 return p 651 return p
652 652
653 def run(self, req): 653 def run(self, req):
654 def header(**map): 654 def header(**map):
655 yield self.t("header", **map) 655 header_file = cStringIO.StringIO(''.join(self.t("header", **map)))
656 msg = mimetools.Message(header_file, 0)
657 req.header(msg.items())
658 yield header_file.read()
656 659
657 def footer(**map): 660 def footer(**map):
658 yield self.t("footer", 661 yield self.t("footer",
659 motd=self.repo.ui.config("web", "motd", ""), 662 motd=self.repo.ui.config("web", "motd", ""),
660 **map) 663 **map)
826 def do_static(self, req): 829 def do_static(self, req):
827 fname = req.form['file'][0] 830 fname = req.form['file'][0]
828 static = self.repo.ui.config("web", "static", 831 static = self.repo.ui.config("web", "static",
829 os.path.join(self.templatepath, 832 os.path.join(self.templatepath,
830 "static")) 833 "static"))
831 req.write(staticfile(static, fname) 834 req.write(staticfile(static, fname, req)
832 or self.t("error", error="%r not found" % fname)) 835 or self.t("error", error="%r not found" % fname))
833 836
834 def do_capabilities(self, req): 837 def do_capabilities(self, req):
835 resp = 'unbundle' 838 resp = 'unbundle'
836 req.httphdr("application/mercurial-0.1", length=len(resp)) 839 req.httphdr("application/mercurial-0.1", length=len(resp))