equal
deleted
inserted
replaced
314 with profiling.profile(repo.ui, enabled=profile): |
314 with profiling.profile(repo.ui, enabled=profile): |
315 for r in self._runwsgi(wsgireq, repo): |
315 for r in self._runwsgi(wsgireq, repo): |
316 yield r |
316 yield r |
317 |
317 |
318 def _runwsgi(self, wsgireq, repo): |
318 def _runwsgi(self, wsgireq, repo): |
|
319 req = requestmod.parserequestfromenv(wsgireq.env) |
319 rctx = requestcontext(self, repo) |
320 rctx = requestcontext(self, repo) |
320 |
321 |
321 # This state is global across all threads. |
322 # This state is global across all threads. |
322 encoding.encoding = rctx.config('web', 'encoding') |
323 encoding.encoding = rctx.config('web', 'encoding') |
323 rctx.repo.ui.environ = wsgireq.env |
324 rctx.repo.ui.environ = wsgireq.env |
327 # replace it. |
328 # replace it. |
328 wsgireq.headers = [h for h in wsgireq.headers |
329 wsgireq.headers = [h for h in wsgireq.headers |
329 if h[0] != 'Content-Security-Policy'] |
330 if h[0] != 'Content-Security-Policy'] |
330 wsgireq.headers.append(('Content-Security-Policy', rctx.csp)) |
331 wsgireq.headers.append(('Content-Security-Policy', rctx.csp)) |
331 |
332 |
332 # work with CGI variables to create coherent structure |
333 wsgireq.url = pycompat.sysstr(req.apppath) |
333 # use SCRIPT_NAME, PATH_INFO and QUERY_STRING as well as our REPO_NAME |
|
334 |
|
335 wsgireq.url = wsgireq.env[r'SCRIPT_NAME'] |
|
336 if not wsgireq.url.endswith(r'/'): |
|
337 wsgireq.url += r'/' |
|
338 if wsgireq.env.get('REPO_NAME'): |
|
339 wsgireq.url += wsgireq.env[r'REPO_NAME'] + r'/' |
|
340 |
334 |
341 if r'PATH_INFO' in wsgireq.env: |
335 if r'PATH_INFO' in wsgireq.env: |
342 parts = wsgireq.env[r'PATH_INFO'].strip(r'/').split(r'/') |
336 parts = wsgireq.env[r'PATH_INFO'].strip(r'/').split(r'/') |
343 repo_parts = wsgireq.env.get(r'REPO_NAME', r'').split(r'/') |
337 repo_parts = wsgireq.env.get(r'REPO_NAME', r'').split(r'/') |
344 if parts[:len(repo_parts)] == repo_parts: |
338 if parts[:len(repo_parts)] == repo_parts: |