changeset 18697:4921b5c2aeed

httppeer: improve protocol check Pre-0.6c hgweb used text/plain for protocol responses. This meant that a web server could serve a static file and confuse a client into generating a nasty traceback. Now we insist that text/plain protocol responses not include a Content-Length, which older hgweb didn't generate but will typically be produced for static files.
author Matt Mackall <mpm@selenic.com>
date Sun, 17 Feb 2013 14:34:53 -0600
parents d23f61b6617f
children 32292ad53f9f a8204cef4c5a
files mercurial/httppeer.py
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/httppeer.py	Sun Feb 17 14:41:31 2013 -0600
+++ b/mercurial/httppeer.py	Sun Feb 17 14:34:53 2013 -0600
@@ -145,7 +145,8 @@
             raise error.OutOfBandError(resp.read())
         # accept old "text/plain" and "application/hg-changegroup" for now
         if not (proto.startswith('application/mercurial-') or
-                proto.startswith('text/plain') or
+                (proto.startswith('text/plain')
+                 and not resp.headers.get('content-length')) or
                 proto.startswith('application/hg-changegroup')):
             self.ui.debug("requested URL: '%s'\n" % util.hidepassword(cu))
             raise error.RepoError(