comparison mercurial/httprepo.py @ 4012:d1e31d7f7d44

fix handling of multiple Content-type headers This can happen if an error happens while sending application/mercurial-0.1 content. The error page will be sent resulting (for at least lighttpd) in the following headers: Content-type: application/mercurial-0.1 Content-type: text/html which result in req.proto = 'application/mercurial-0.1, text/html' fix issue344
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Fri, 29 Dec 2006 05:27:48 +0100
parents e674cae8efee
children a195f11ed1a2 d8b3edf88af0
comparison
equal deleted inserted replaced
4011:15955d84bc68 4012:d1e31d7f7d44
255 proto = resp.getheader('content-type') 255 proto = resp.getheader('content-type')
256 except AttributeError: 256 except AttributeError:
257 proto = resp.headers['content-type'] 257 proto = resp.headers['content-type']
258 258
259 # accept old "text/plain" and "application/hg-changegroup" for now 259 # accept old "text/plain" and "application/hg-changegroup" for now
260 if not proto.startswith('application/mercurial') and \ 260 if not proto.startswith('application/mercurial-') and \
261 not proto.startswith('text/plain') and \ 261 not proto.startswith('text/plain') and \
262 not proto.startswith('application/hg-changegroup'): 262 not proto.startswith('application/hg-changegroup'):
263 raise hg.RepoError(_("'%s' does not appear to be an hg repository") % 263 raise hg.RepoError(_("'%s' does not appear to be an hg repository") %
264 self._url) 264 self._url)
265 265
266 if proto.startswith('application/mercurial'): 266 if proto.startswith('application/mercurial-'):
267 version = proto[22:] 267 try:
268 if float(version) > 0.1: 268 version = float(proto[22:])
269 except ValueError:
270 raise hg.RepoError(_("'%s' sent a broken Content-type "
271 "header (%s)") % (self._url, proto))
272 if version > 0.1:
269 raise hg.RepoError(_("'%s' uses newer protocol %s") % 273 raise hg.RepoError(_("'%s' uses newer protocol %s") %
270 (self._url, version)) 274 (self._url, version))
271 275
272 return resp 276 return resp
273 277