[PATCH 2 of 2] httprepo: proper handling of invalid responses without content-type (issue2019)
Mads Kiilerich
mads at kiilerich.com
Mon Mar 7 18:33:41 CST 2011
# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1299505650 -3600
# Node ID 0d08957b10210b3ab7632a9854ae5caf27ab17b0
# Parent d4168b2f9181b8413c52effa03c76a6d8dad19c9
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
@@ -106,7 +106,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 @@
_("'%s' does not appear to be an hg repository:\n"
"---%%<--- (%s)\n%s\n---%%<---\n"
"(for static http use static-http://...)\n")
- % (safeurl, proto, resp.read()))
+ % (safeurl, proto or 'no content-type', resp.read()))
if proto.startswith('application/mercurial-'):
try:
More information about the Mercurial-devel
mailing list