Skip to content

Commit 25639a4

Browse files
Merge branch '5.4' into 6.3
* 5.4: [Translation] Fix `TranslationNodeVisitor` with constant domain [Messenger] [AMQP] Throw exception on `nack` callback [Validator] revise Latvian translations [ErrorHandler] Fix `RecursiveDirectoryIterator` exception with wrong composer autoload [HttpFoundation] Request without content-type or content-length header should result in null values, not empty strings [Cache] Fix possible infinite loop in `CachePoolPass` [Mime] Fix undefined array key 0 when empty sender [Console] Allow '0' as a $shortcut in InputOption.php fix multi-byte code area to convert [Validator] Make it explicit when English translation differs from its resource name
2 parents 63a2041 + 528f59f commit 25639a4

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

ServerBag.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function getHeaders(): array
2929
foreach ($this->parameters as $key => $value) {
3030
if (str_starts_with($key, 'HTTP_')) {
3131
$headers[substr($key, 5)] = $value;
32-
} elseif (\in_array($key, ['CONTENT_TYPE', 'CONTENT_LENGTH', 'CONTENT_MD5'], true)) {
32+
} elseif (\in_array($key, ['CONTENT_TYPE', 'CONTENT_LENGTH', 'CONTENT_MD5'], true) && '' !== $value) {
3333
$headers[$key] = $value;
3434
}
3535
}

Tests/ServerBagTest.php

+16
Original file line numberDiff line numberDiff line change
@@ -177,4 +177,20 @@ public function testItDoesNotOverwriteTheAuthorizationHeaderIfItIsAlreadySet()
177177
'PHP_AUTH_PW' => '',
178178
], $bag->getHeaders());
179179
}
180+
181+
/**
182+
* An HTTP request without content-type and content-length will result in
183+
* the variables $_SERVER['CONTENT_TYPE'] and $_SERVER['CONTENT_LENGTH']
184+
* containing an empty string in PHP.
185+
*/
186+
public function testRequestWithoutContentTypeAndContentLength()
187+
{
188+
$bag = new ServerBag([
189+
'CONTENT_TYPE' => '',
190+
'CONTENT_LENGTH' => '',
191+
'HTTP_USER_AGENT' => 'foo',
192+
]);
193+
194+
$this->assertSame(['USER_AGENT' => 'foo'], $bag->getHeaders());
195+
}
180196
}

0 commit comments

Comments
 (0)