Mercurial > public > mercurial-scm > hg
comparison mercurial/httppeer.py @ 18737:56f8522c3591
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 | 988974c2a4bf |
children | b376e8f91c16 |
comparison
equal
deleted
inserted
replaced
18667:f12804d3ff80 | 18737:56f8522c3591 |
---|---|
143 safeurl = util.hidepassword(self._url) | 143 safeurl = util.hidepassword(self._url) |
144 if proto.startswith('application/hg-error'): | 144 if proto.startswith('application/hg-error'): |
145 raise error.OutOfBandError(resp.read()) | 145 raise error.OutOfBandError(resp.read()) |
146 # accept old "text/plain" and "application/hg-changegroup" for now | 146 # accept old "text/plain" and "application/hg-changegroup" for now |
147 if not (proto.startswith('application/mercurial-') or | 147 if not (proto.startswith('application/mercurial-') or |
148 proto.startswith('text/plain') or | 148 (proto.startswith('text/plain') |
149 and not resp.headers.get('content-length')) or | |
149 proto.startswith('application/hg-changegroup')): | 150 proto.startswith('application/hg-changegroup')): |
150 self.ui.debug("requested URL: '%s'\n" % util.hidepassword(cu)) | 151 self.ui.debug("requested URL: '%s'\n" % util.hidepassword(cu)) |
151 raise error.RepoError( | 152 raise error.RepoError( |
152 _("'%s' does not appear to be an hg repository:\n" | 153 _("'%s' does not appear to be an hg repository:\n" |
153 "---%%<--- (%s)\n%s\n---%%<---\n") | 154 "---%%<--- (%s)\n%s\n---%%<---\n") |