##// END OF EJS Templates
vcs: Add custom response header 'X-RhodeCode-Backend' to indicate VCS responses and which backend is in use.
Martin Bornhold -
r608:74424d4b default
parent child Browse files
Show More
@@ -79,12 +79,18 b' class SimpleSvnApp(object):'
79 return headers
79 return headers
80
80
81 def _get_response_headers(self, headers):
81 def _get_response_headers(self, headers):
82 return [
82 headers = [
83 (h, headers[h])
83 (h, headers[h])
84 for h in headers
84 for h in headers
85 if h.lower() not in self.IGNORED_HEADERS
85 if h.lower() not in self.IGNORED_HEADERS
86 ]
86 ]
87
87
88 # Add custom response header to indicate that this is a VCS response
89 # and which backend is used.
90 headers.append(('X-RhodeCode-Backend', 'svn'))
91
92 return headers
93
88
94
89 class SimpleSvn(simplevcs.SimpleVCS):
95 class SimpleSvn(simplevcs.SimpleVCS):
90
96
@@ -39,12 +39,12 b' log = logging.getLogger(__name__)'
39
39
40 def create_git_wsgi_app(repo_path, repo_name, config):
40 def create_git_wsgi_app(repo_path, repo_name, config):
41 url = _vcs_streaming_url() + 'git/'
41 url = _vcs_streaming_url() + 'git/'
42 return VcsHttpProxy(url, repo_path, repo_name, config)
42 return VcsHttpProxy(url, repo_path, repo_name, config, 'git')
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):
46 url = _vcs_streaming_url() + 'hg/'
46 url = _vcs_streaming_url() + 'hg/'
47 return VcsHttpProxy(url, repo_path, repo_name, config)
47 return VcsHttpProxy(url, repo_path, repo_name, config, 'hg')
48
48
49
49
50 def _vcs_streaming_url():
50 def _vcs_streaming_url():
@@ -67,7 +67,7 b' class VcsHttpProxy(object):'
67 server as well.
67 server as well.
68 """
68 """
69
69
70 def __init__(self, url, repo_path, repo_name, config):
70 def __init__(self, url, repo_path, repo_name, config, backend):
71 """
71 """
72 :param str url: The URL of the VCSServer to call.
72 :param str url: The URL of the VCSServer to call.
73 """
73 """
@@ -75,6 +75,7 b' class VcsHttpProxy(object):'
75 self._repo_name = repo_name
75 self._repo_name = repo_name
76 self._repo_path = repo_path
76 self._repo_path = repo_path
77 self._config = config
77 self._config = config
78 self._backend = backend
78 log.debug(
79 log.debug(
79 "Creating VcsHttpProxy for repo %s, url %s",
80 "Creating VcsHttpProxy for repo %s, url %s",
80 repo_name, url)
81 repo_name, url)
@@ -115,6 +116,10 b' class VcsHttpProxy(object):'
115 if not wsgiref.util.is_hop_by_hop(h)
116 if not wsgiref.util.is_hop_by_hop(h)
116 ]
117 ]
117
118
119 # Add custom response header to indicate that this is a VCS response
120 # and which backend is used.
121 response_headers.append(('X-RhodeCode-Backend', self._backend))
122
118 # TODO: johbo: Better way to get the status including text?
123 # TODO: johbo: Better way to get the status including text?
119 status = str(response.status_code)
124 status = str(response.status_code)
120 start_response(status, response_headers)
125 start_response(status, response_headers)
General Comments 0
You need to be logged in to leave comments. Login now