8000 bug #20747 [HttpKernel] Fixed RequestDataCollector handling of null h… · symfony/symfony@456e68b · GitHub
[go: up one dir, main page]

Skip to content

Commit 456e68b

Browse files
committed
bug #20747 [HttpKernel] Fixed RequestDataCollector handling of null header values. (Gabriel Moreira)
This PR was submitted for the master branch but it was merged into the 3.2 branch instead (closes #20747). Discussion ---------- [HttpKernel] Fixed RequestDataCollector handling of null header values. | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - This PR references this [discussion](symfony/http-kernel@1fee784#commitcomment-20028839). Commits ------- adc4a26 [HttpKernel] Fixed RequestDataCollector handling of null header values.
2 parents 2d42689 + adc4a26 commit 456e68b

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function collect(Request $request, Response $response, \Exception $except
125125
continue;
126126
}
127127
if ('request_headers' === $key || 'response_headers' === $key) {
128-
$value = array_map(function ($v) { return isset($v[1]) ? $v : $v[0]; }, $value);
128+
$value = array_map(function ($v) { return isset($v[0]) && !isset($v[1]) ? $v[0] : $v; }, $value);
129129
}
130130
if ('request_server' !== $key && 'request_cookies' !== $key) {
131131
$this->data[$key] = array_map(array($this, 'cloneVar'), $value);

src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ protected function createResponse()
234234
$response = new Response();
235235
$response->setStatusCode(200);
236236
$response->headers->set('Content-Type', 'application/json');
237+
$response->headers->set('X-Foo-Bar', null);
237238
$response->headers->setCookie(new Cookie('foo', 'bar', 1, '/foo', 'localhost', true, true));
238239
$response->headers->setCookie(new Cookie('bar', 'foo', new \DateTime('@946684800')));
239240
$response->headers->setCookie(new Cookie('bazz', 'foo', '2000-12-12'));

0 commit comments

Comments
 (0)
0