Conditions | 7 |
Paths | 6 |
Total Lines | 21 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 7.0222 |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | 2 | public function onAfterInit() |
|
11 | { |
||
12 | 2 | $response = $this->owner->getResponse(); |
|
13 | |||
14 | 2 | $headersToSend = (array) Config::inst()->get('Guttmann\SilverStripe\SecurityHeaderControllerExtension', 'headers'); |
|
15 | 2 | $xHeaderMap = (array) Config::inst()->get('Guttmann\SilverStripe\SecurityHeaderControllerExtension', 'x_headers_map'); |
|
16 | |||
17 | 2 | foreach ($headersToSend as $header => $value) { |
|
18 | 2 | if (empty($value)) { |
|
19 | continue; |
||
20 | } |
||
21 | |||
22 | 2 | if ($header === 'Content-Security-Policy' && !$this->browserHasWorkingCSPImplementation()) { |
|
23 | 1 | continue; |
|
24 | } |
||
25 | |||
26 | 2 | $response->addHeader($header, $value); |
|
27 | |||
28 | 2 | if (isset($xHeaderMap[$header])) { |
|
29 | 2 | foreach ($xHeaderMap[$header] as $xHeader) { |
|
30 | 2 | $response->addHeader($xHeader, $value); |
|
31 | 2 | } |
|
62 |