Skip to content

Commit bdb4516

Browse files
committed
HttpExtension: header can be '0'
1 parent 3660997 commit bdb4516

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Bridges/HttpDI/HttpExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class)
9494

9595
$initialize = $class->getMethod('initialize');
9696
$config = $this->getConfig();
97-
$headers = $config['headers'];
97+
$headers = array_map('strval', $config['headers']);
9898

9999
if (isset($config['frames']) && $config['frames'] !== true && !isset($headers['X-Frame-Options'])) {
100100
$frames = $config['frames'];
@@ -128,7 +128,7 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class)
128128

129129
$code[] = Helpers::formatArgs('$response = $this->getService(?);', [$this->prefix('response')]);
130130
foreach ($headers as $key => $value) {
131-
if ($value != null) { // intentionally ==
131+
if ($value !== '') {
132132
$code[] = Helpers::formatArgs('$response->setHeader(?, ?);', [$key, $value]);
133133
}
134134
}

tests/Http.DI/HttpExtension.headers.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ http:
2626
headers:
2727
A: b
2828
C:
29+
D: 0
2930
EOD
3031
, 'neon'));
3132

@@ -39,6 +40,7 @@ Assert::contains('X-Frame-Options: SAMEORIGIN', $headers);
3940
Assert::contains('Content-Type: text/html; charset=utf-8', $headers);
4041
Assert::contains('X-Powered-By: Nette Framework 3', $headers);
4142
Assert::contains('A: b', $headers);
43+
Assert::contains('D: 0', $headers);
4244
Assert::notContains('C:', $headers);
4345

4446

0 commit comments

Comments
 (0)