httprepo: proper handling of invalid responses without content-type (issue2019) stable
authorMads Kiilerich <mads@kiilerich.com>
Mon, 07 Mar 2011 14:47:30 +0100
branchstable
changeset 14503 4e958f2a193f
parent 14502 deb82fdda94e
child 14504 c59968e8b579
httprepo: proper handling of invalid responses without content-type (issue2019) This can currently be tested on http://sf.net/
mercurial/httprepo.py
--- a/mercurial/httprepo.py	Fri Apr 29 14:56:23 2011 +0200
+++ b/mercurial/httprepo.py	Mon Mar 07 14:47:30 2011 +0100
@@ -107,7 +107,7 @@
         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 @@
             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: