##// END OF EJS Templates
pyro4: Add the custom header `X-RhodeCode-Backend` to the pyro4 backend responses....
Martin Bornhold -
r848:2956cade default
parent child Browse files
Show More
@@ -76,7 +76,8 b' class SimpleGit(simplevcs.SimpleVCS):'
76 76 return 'pull'
77 77
78 78 def _create_wsgi_app(self, repo_path, repo_name, config):
79 return self.scm_app.create_git_wsgi_app(repo_path, repo_name, config)
79 return self.scm_app.create_git_wsgi_app(
80 repo_path, repo_name, config, self.SCM)
80 81
81 82 def _create_config(self, extras, repo_name):
82 83 extras['git_update_server_info'] = utils2.str2bool(
@@ -71,7 +71,8 b' class SimpleHg(simplevcs.SimpleVCS):'
71 71 return 'pull'
72 72
73 73 def _create_wsgi_app(self, repo_path, repo_name, config):
74 return self.scm_app.create_hg_wsgi_app(repo_path, repo_name, config)
74 return self.scm_app.create_hg_wsgi_app(
75 repo_path, repo_name, config, self.SCM)
75 76
76 77 def _create_config(self, extras, repo_name):
77 78 config = utils.make_db_config(repo=repo_name)
@@ -34,7 +34,7 b' HG_REMOTE_WSGI = None'
34 34 GIT_REMOTE_WSGI = None
35 35
36 36
37 def create_git_wsgi_app(repo_path, repo_name, config):
37 def create_git_wsgi_app(repo_path, repo_name, config, backend):
38 38 """
39 39 Return a WSGI app backed by a remote app to handle Git.
40 40
@@ -45,10 +45,10 b' def create_git_wsgi_app(repo_path, repo_'
45 45 log.error('Pyro server has not been initialized yet')
46 46
47 47 return wsgi_app_caller_client.RemoteAppCaller(
48 factory, repo_path, repo_name, config)
48 factory, backend, repo_path, repo_name, config)
49 49
50 50
51 def create_hg_wsgi_app(repo_path, repo_name, config):
51 def create_hg_wsgi_app(repo_path, repo_name, config, backend):
52 52 """
53 53 Return a WSGI app backed by a remote app to handle Mercurial.
54 54
@@ -60,4 +60,4 b' def create_hg_wsgi_app(repo_path, repo_n'
60 60 log.error('Pyro server has not been initialized yet')
61 61
62 62 return wsgi_app_caller_client.RemoteAppCaller(
63 factory, repo_path, repo_name, config)
63 factory, backend, repo_path, repo_name, config)
@@ -37,14 +37,14 b' import rhodecode'
37 37 log = logging.getLogger(__name__)
38 38
39 39
40 def create_git_wsgi_app(repo_path, repo_name, config):
40 def create_git_wsgi_app(repo_path, repo_name, config, backend):
41 41 url = _vcs_streaming_url() + 'git/'
42 return VcsHttpProxy(url, repo_path, repo_name, config, 'git')
42 return VcsHttpProxy(url, repo_path, repo_name, config, backend)
43 43
44 44
45 def create_hg_wsgi_app(repo_path, repo_name, config):
45 def create_hg_wsgi_app(repo_path, repo_name, config, backend):
46 46 url = _vcs_streaming_url() + 'hg/'
47 return VcsHttpProxy(url, repo_path, repo_name, config, 'hg')
47 return VcsHttpProxy(url, repo_path, repo_name, config, backend)
48 48
49 49
50 50 def _vcs_streaming_url():
@@ -56,16 +56,18 b' class RemoteAppCaller(object):'
56 56 It first cleans the environment, so as to reduce the data transferred.
57 57 """
58 58
59 def __init__(self, remote_wsgi, *args, **kwargs):
59 def __init__(self, remote_wsgi, backend, *args, **kwargs):
60 60 """
61 61 :param remote_wsgi: The remote wsgi object that creates a
62 62 WSGIAppCaller. This object
63 63 has to have a handle method, with the signature:
64 64 handle(environ, start_response, *args, **kwargs)
65 :param backend: Key (str) of the SCM backend that is in use.
65 66 :param args: args to be passed to the app creation
66 67 :param kwargs: kwargs to be passed to the app creation
67 68 """
68 69 self._remote_wsgi = remote_wsgi
70 self._backend = backend
69 71 self._args = args
70 72 self._kwargs = kwargs
71 73
@@ -92,6 +94,10 b' class RemoteAppCaller(object):'
92 94 data, status, headers = self._remote_wsgi.handle(
93 95 clean_environ, input_data, *self._args, **self._kwargs)
94 96
97 # Add custom response header to indicate that this is a VCS response
98 # and which backend is used.
99 headers.append(('X-RhodeCode-Backend', self._backend))
100
95 101 log.debug("Got result from proxy, returning to WSGI container")
96 102 start_response(status, headers)
97 103
@@ -27,11 +27,11 b' for testing purposes.'
27 27 import mock
28 28
29 29
30 def create_git_wsgi_app(repo_path, repo_name, config):
30 def create_git_wsgi_app(repo_path, repo_name, config, backend):
31 31 return mock_git_wsgi
32 32
33 33
34 def create_hg_wsgi_app(repo_path, repo_name, config):
34 def create_hg_wsgi_app(repo_path, repo_name, config, backend):
35 35 return mock_hg_wsgi
36 36
37 37
General Comments 0
You need to be logged in to leave comments. Login now