mercurial/hgweb/hgweb_mod.py
changeset 36861 a88d68dc3ee8
parent 36856 1f7d9024674c
child 36863 1a1972b1a1ff
equal deleted inserted replaced
36860:2859c6fa4fc2 36861:a88d68dc3ee8
   303                 for r in self._runwsgi(wsgireq, repo):
   303                 for r in self._runwsgi(wsgireq, repo):
   304                     yield r
   304                     yield r
   305 
   305 
   306     def _runwsgi(self, wsgireq, repo):
   306     def _runwsgi(self, wsgireq, repo):
   307         req = wsgireq.req
   307         req = wsgireq.req
       
   308         res = wsgireq.res
   308         rctx = requestcontext(self, repo)
   309         rctx = requestcontext(self, repo)
   309 
   310 
   310         # This state is global across all threads.
   311         # This state is global across all threads.
   311         encoding.encoding = rctx.config('web', 'encoding')
   312         encoding.encoding = rctx.config('web', 'encoding')
   312         rctx.repo.ui.environ = wsgireq.env
   313         rctx.repo.ui.environ = wsgireq.env
   315             # hgwebdir may have added CSP header. Since we generate our own,
   316             # hgwebdir may have added CSP header. Since we generate our own,
   316             # replace it.
   317             # replace it.
   317             wsgireq.headers = [h for h in wsgireq.headers
   318             wsgireq.headers = [h for h in wsgireq.headers
   318                                if h[0] != 'Content-Security-Policy']
   319                                if h[0] != 'Content-Security-Policy']
   319             wsgireq.headers.append(('Content-Security-Policy', rctx.csp))
   320             wsgireq.headers.append(('Content-Security-Policy', rctx.csp))
   320 
   321             res.headers['Content-Security-Policy'] = rctx.csp
   321         handled, res = wireprotoserver.handlewsgirequest(
   322 
   322             rctx, wsgireq, req, self.check_perm)
   323         handled = wireprotoserver.handlewsgirequest(
       
   324             rctx, wsgireq, req, res, self.check_perm)
   323         if handled:
   325         if handled:
   324             return res
   326             return res.sendresponse()
   325 
   327 
   326         if req.havepathinfo:
   328         if req.havepathinfo:
   327             query = req.dispatchpath
   329             query = req.dispatchpath
   328         else:
   330         else:
   329             query = req.querystring.partition('&')[0].partition(';')[0]
   331             query = req.querystring.partition('&')[0].partition(';')[0]