# HG changeset patch # User Mads Kiilerich # Date 2011-03-07 13:47:30 # Node ID 4e958f2a193fb1ceb3c4aee00da7ab1d1ffbea09 # Parent deb82fdda94e46100e68df680c25083a36967ff9 httprepo: proper handling of invalid responses without content-type (issue2019) This can currently be tested on http://sf.net/ diff --git a/mercurial/httprepo.py b/mercurial/httprepo.py --- a/mercurial/httprepo.py +++ b/mercurial/httprepo.py @@ -107,7 +107,7 @@ class httprepository(wireproto.wirerepos try: proto = resp.getheader('content-type') except AttributeError: - proto = resp.headers['content-type'] + proto = resp.headers.get('content-type', '') safeurl = url.hidepassword(self._url) # accept old "text/plain" and "application/hg-changegroup" for now @@ -118,7 +118,7 @@ class httprepository(wireproto.wirerepos raise error.RepoError( _("'%s' does not appear to be an hg repository:\n" "---%%<--- (%s)\n%s\n---%%<---\n") - % (safeurl, proto, resp.read())) + % (safeurl, proto or 'no content-type', resp.read())) if proto.startswith('application/mercurial-'): try: