Mercurial > public > mercurial-scm > hg-stable
diff mercurial/hgweb/common.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 | d351a3be3371 |
children | 345bac2bc4ec |
line wrap: on
line diff
--- a/mercurial/hgweb/common.py Tue Jun 27 09:30:50 2006 -0700 +++ b/mercurial/hgweb/common.py Tue Jun 27 09:33:12 2006 -0700 @@ -17,7 +17,7 @@ else: return os.stat(hg_path).st_mtime -def staticfile(directory, fname): +def staticfile(directory, fname, req): """return a file inside directory with guessed content-type header fname always uses '/' as directory separator and isn't allowed to @@ -36,7 +36,9 @@ try: os.stat(path) ct = mimetypes.guess_type(path)[0] or "text/plain" - return "Content-type: %s\n\n%s" % (ct, file(path).read()) + req.header([('Content-type', ct), + ('Content-length', os.path.getsize(path))]) + return file(path).read() except (TypeError, OSError): # illegal fname or unreadable file return ""