diff --git a/mercurial/help/internals/wireprotocol.txt b/mercurial/help/internals/wireprotocol.txt --- a/mercurial/help/internals/wireprotocol.txt +++ b/mercurial/help/internals/wireprotocol.txt @@ -123,12 +123,6 @@ The content of the HTTP response body typically holds text describing the error. -The ``application/hg-changegroup`` media type indicates a changegroup response -type. - -Clients also accept the ``text/plain`` media type. All other media -types should cause the client to error. - Behavior of media types is further described in the ``Content Negotiation`` section below. diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py --- a/mercurial/httppeer.py +++ b/mercurial/httppeer.py @@ -322,46 +322,40 @@ safeurl = util.hidepassword(baseurl) if proto.startswith('application/hg-error'): 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') - and not resp.headers.get('content-length')) or - proto.startswith('application/hg-changegroup')): + + # Pre 1.0 versions of Mercurial used text/plain and + # application/hg-changegroup. We don't support such old servers. + if not proto.startswith('application/mercurial-'): ui.debug("requested URL: '%s'\n" % util.hidepassword(requrl)) raise error.RepoError( _("'%s' does not appear to be an hg repository:\n" "---%%<--- (%s)\n%s\n---%%<---\n") % (safeurl, proto or 'no content-type', resp.read(1024))) - if proto.startswith('application/mercurial-'): - try: - version = proto.split('-', 1)[1] - version_info = tuple([int(n) for n in version.split('.')]) - except ValueError: - raise error.RepoError(_("'%s' sent a broken Content-Type " - "header (%s)") % (safeurl, proto)) - - # TODO consider switching to a decompression reader that uses - # generators. - if version_info == (0, 1): - if compressible: - resp = util.compengines['zlib'].decompressorreader(resp) + try: + version = proto.split('-', 1)[1] + version_info = tuple([int(n) for n in version.split('.')]) + except ValueError: + raise error.RepoError(_("'%s' sent a broken Content-Type " + "header (%s)") % (safeurl, proto)) - return respurl, resp + # TODO consider switching to a decompression reader that uses + # generators. + if version_info == (0, 1): + if compressible: + resp = util.compengines['zlib'].decompressorreader(resp) - elif version_info == (0, 2): - # application/mercurial-0.2 always identifies the compression - # engine in the payload header. - elen = struct.unpack('B', resp.read(1))[0] - ename = resp.read(elen) - engine = util.compengines.forwiretype(ename) - return respurl, engine.decompressorreader(resp) - else: - raise error.RepoError(_("'%s' uses newer protocol %s") % - (safeurl, version)) + elif version_info == (0, 2): + # application/mercurial-0.2 always identifies the compression + # engine in the payload header. + elen = struct.unpack('B', resp.read(1))[0] + ename = resp.read(elen) + engine = util.compengines.forwiretype(ename) - if compressible: - resp = util.compengines['zlib'].decompressorreader(resp) + resp = engine.decompressorreader(resp) + else: + raise error.RepoError(_("'%s' uses newer protocol %s") % + (safeurl, version)) return respurl, resp