Mercurial > hg-stable
changeset 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 | 15955d84bc68 |
children | 54fa628b8c78 |
files | mercurial/httprepo.py |
diffstat | 1 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/httprepo.py Fri Dec 29 04:22:31 2006 +0100 +++ b/mercurial/httprepo.py Fri Dec 29 05:27:48 2006 +0100 @@ -257,15 +257,19 @@ proto = resp.headers['content-type'] # accept old "text/plain" and "application/hg-changegroup" for now - if not proto.startswith('application/mercurial') and \ + if not proto.startswith('application/mercurial-') and \ not proto.startswith('text/plain') and \ not proto.startswith('application/hg-changegroup'): raise hg.RepoError(_("'%s' does not appear to be an hg repository") % self._url) - if proto.startswith('application/mercurial'): - version = proto[22:] - if float(version) > 0.1: + if proto.startswith('application/mercurial-'): + try: + version = float(proto[22:]) + except ValueError: + raise hg.RepoError(_("'%s' sent a broken Content-type " + "header (%s)") % (self._url, proto)) + if version > 0.1: raise hg.RepoError(_("'%s' uses newer protocol %s") % (self._url, version))