Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 1e8b6c4

Browse files
author
Jefersson Nathan
committed
Bugfix: Header with value "0" is being discarded
1 parent 3a7562d commit 1e8b6c4

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/functions/marshal_headers_from_sapi.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ function marshalHeadersFromSapi(array $server) : array
4646
$headers[$name] = $value;
4747
continue;
4848
}
49+
50+
$headers[$key] = $value;
4951
}
5052

5153
return $headers;

test/ServerRequestFactoryTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,18 @@ public function testFromGlobalsUsesCookieHeaderInsteadOfCookieSuperGlobal()
421421
$this->assertSame(['foo_bar' => 'baz'], $request->getCookieParams());
422422
}
423423

424+
/**
425+
* @runInSeparateProcess
426+
* @preserveGlobalState
427+
*/
428+
public function testCreateFromGlobalsShouldPreserveKeysWhenCreatedWithAZeroValue()
429+
{
430+
$_SERVER['Accept'] = '0';
431+
432+
$request = ServerRequestFactory::fromGlobals();
433+
$this->assertSame('0', $request->getHeaderLine('Accept'));
434+
}
435+
424436
/**
425437
* @runInSeparateProcess
426438
* @preserveGlobalState disabled

0 commit comments

Comments
 (0)