Skip to content

Commit 56ae137

Browse files
committed
HttpExtension: header can be '0'
1 parent 5028e3b commit 56ae137

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
@@ -96,7 +96,7 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class)
9696

9797
$initialize = $class->getMethod('initialize');
9898
$config = $this->getConfig();
99-
$headers = $config['headers'];
99+
$headers = array_map('strval', $config['headers']);
100100

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

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

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)