Only add header to relevant responses

Created on 7 November 2018, about 6 years ago
Updated 19 January 2024, 10 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.71.5 2024