Mercurial > public > mercurial-scm > hg-stable
diff mercurial/hgweb/hgwebdir_mod.py @ 5928:3340aa5a64f7
hgweb: move HTTP content types out of header templates
This removes the ability for templates to add custom HTTP headers, which can
easily be re-added if someone needs it. Thanks to asak for repeatedly reviewing
this patch and helping to iron out the quirks.
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Tue, 22 Jan 2008 10:45:55 +0100 |
parents | d0576d065993 |
children | abe373e16fe6 |
line wrap: on
line diff
--- a/mercurial/hgweb/hgwebdir_mod.py Tue Jan 22 10:45:52 2008 +0100 +++ b/mercurial/hgweb/hgwebdir_mod.py Tue Jan 22 10:45:55 2008 +0100 @@ -6,7 +6,7 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -import os, mimetools, cStringIO +import os from mercurial.i18n import gettext as _ from mercurial import ui, hg, util, templater from common import ErrorResponse, get_mtime, staticfile, style_map, paritygen, \ @@ -226,6 +226,7 @@ "%s%s" % ((not descending and column == sortcolumn) and "-" or "", column)) for column in sortable] + req.write(tmpl("index", entries=entries, subdir=subdir, sortcolumn=sortcolumn, descending=descending, **dict(sort))) @@ -233,11 +234,9 @@ def templater(self, req): def header(**map): - header_file = cStringIO.StringIO( - ''.join(tmpl("header", encoding=util._encoding, **map))) - msg = mimetools.Message(header_file, 0) - req.header(msg.items()) - yield header_file.read() + ctype = tmpl('mimetype', encoding=util._encoding) + req.httphdr(templater.stringify(ctype)) + yield tmpl('header', encoding=util._encoding, **map) def footer(**map): yield tmpl("footer", **map)