comparison mercurial/hgweb/hgweb_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 f39110afc039
children c301f15c965a
comparison
equal deleted inserted replaced
5927:b06c56f8fab7 5928:3340aa5a64f7
4 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> 4 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
5 # 5 #
6 # This software may be used and distributed according to the terms 6 # This software may be used and distributed according to the terms
7 # of the GNU General Public License, incorporated herein by reference. 7 # of the GNU General Public License, incorporated herein by reference.
8 8
9 import os, mimetypes, re, mimetools, cStringIO 9 import os, mimetypes, re
10 from mercurial.node import * 10 from mercurial.node import *
11 from mercurial import mdiff, ui, hg, util, archival, patch, hook 11 from mercurial import mdiff, ui, hg, util, archival, patch, hook
12 from mercurial import revlog, templater 12 from mercurial import revlog, templater
13 from common import ErrorResponse, get_mtime, style_map, paritygen, get_contact 13 from common import ErrorResponse, get_mtime, style_map, paritygen, get_contact
14 from request import wsgirequest 14 from request import wsgirequest
251 staticurl += '/' 251 staticurl += '/'
252 252
253 # some functions for the templater 253 # some functions for the templater
254 254
255 def header(**map): 255 def header(**map):
256 header_file = cStringIO.StringIO( 256 ctype = tmpl('mimetype', encoding=self.encoding)
257 ''.join(tmpl("header", encoding=self.encoding, **map))) 257 req.httphdr(templater.stringify(ctype))
258 msg = mimetools.Message(header_file, 0) 258 yield tmpl('header', encoding=self.encoding, **map)
259 req.header(msg.items())
260 yield header_file.read()
261 259
262 def footer(**map): 260 def footer(**map):
263 yield tmpl("footer", **map) 261 yield tmpl("footer", **map)
264 262
265 def motd(**map): 263 def motd(**map):