Only add header to relevant responses

Created on 7 November 2018, over 5 years ago
Updated 19 January 2024, 5 months ago

CSP adds headers to any response that triggers the KernelEvents::RESPONSE event, but Drupal may serve other content types that CSP is not relevant to.

Proposed Changes

Check the class / content-type of the response, and only add headers when appropriate

Response Classes to skip:
- \Symfony\Component\HttpFoundation\JsonResponse (\Drupal\Core\Ajax\AjaxResponse is a subclass)
- \Drupal\Core\Routing\LocalRedirectResponse
- \Drupal\rest\ResourceResponse, \Drupal\rest\ModifiedResourceResponse

Content Types to add header to:
- HTML
- XML
- SVG

πŸ“Œ Task
Status

Needs work

Version

2.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada gapple

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024