# HG changeset patch # User marcink # Date 2010-03-18 13:37:05 # Node ID 707dfdb1c7a8568d8aabedb1a8dc8c2b7a65562b # Parent 846e2d8672c48ac66bcc3b8eaab571e2f0df78ec Bugfix when client is using old mercurial version and not setting http accept diff --git a/pylons_app/controllers/hg.py b/pylons_app/controllers/hg.py --- a/pylons_app/controllers/hg.py +++ b/pylons_app/controllers/hg.py @@ -11,6 +11,7 @@ from mercurial import ui, hg from mercurial.error import RepoError from ConfigParser import ConfigParser import encodings +from pylons.controllers.util import abort log = logging.getLogger(__name__) class HgController(BaseController): @@ -20,8 +21,13 @@ class HgController(BaseController): def view(self, *args, **kwargs): response = g.hgapp(request.environ, self.start_response) + + http_accept = request.environ.get('HTTP_ACCEPT', False) + if not http_accept: + return abort(status_code=400, detail='no http accept in header') + #for mercurial protocols and raw files we can't wrap into mako - if request.environ['HTTP_ACCEPT'].find("mercurial") != -1 or \ + if http_accept.find("mercurial") != -1 or \ request.environ['PATH_INFO'].find('raw-file') != -1: return response try: