316 # replace it. |
316 # replace it. |
317 wsgireq.headers = [h for h in wsgireq.headers |
317 wsgireq.headers = [h for h in wsgireq.headers |
318 if h[0] != 'Content-Security-Policy'] |
318 if h[0] != 'Content-Security-Policy'] |
319 wsgireq.headers.append(('Content-Security-Policy', rctx.csp)) |
319 wsgireq.headers.append(('Content-Security-Policy', rctx.csp)) |
320 |
320 |
|
321 handled, res = wireprotoserver.handlewsgirequest( |
|
322 rctx, wsgireq, req, self.check_perm) |
|
323 if handled: |
|
324 return res |
|
325 |
321 if req.havepathinfo: |
326 if req.havepathinfo: |
322 query = req.dispatchpath |
327 query = req.dispatchpath |
323 else: |
328 else: |
324 query = req.querystring.partition('&')[0].partition(';')[0] |
329 query = req.querystring.partition('&')[0].partition(';')[0] |
325 |
|
326 # Route it to a wire protocol handler if it looks like a wire protocol |
|
327 # request. |
|
328 protohandler = wireprotoserver.parsehttprequest(rctx, wsgireq, req, |
|
329 self.check_perm) |
|
330 |
|
331 if protohandler: |
|
332 try: |
|
333 if query: |
|
334 raise ErrorResponse(HTTP_NOT_FOUND) |
|
335 |
|
336 return protohandler['dispatch']() |
|
337 except ErrorResponse as inst: |
|
338 return protohandler['handleerror'](inst) |
|
339 |
330 |
340 # translate user-visible url structure to internal structure |
331 # translate user-visible url structure to internal structure |
341 |
332 |
342 args = query.split('/', 2) |
333 args = query.split('/', 2) |
343 if 'cmd' not in wsgireq.form and args and args[0]: |
334 if 'cmd' not in wsgireq.form and args and args[0]: |