mercurial/hgweb/common.py
changeset 2514 419c42223bee
parent 2391 d351a3be3371
child 2859 345bac2bc4ec
--- 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 ""