mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Allow empty headers to be read.
Allow headers with '' and '0' as their values to be read. Fixes #6299
This commit is contained in:
parent
b2958dad79
commit
f55111bdc1
2 changed files with 3 additions and 1 deletions
|
@ -648,7 +648,7 @@ class CakeRequest implements ArrayAccess {
|
|||
*/
|
||||
public static function header($name) {
|
||||
$name = 'HTTP_' . strtoupper(str_replace('-', '_', $name));
|
||||
if (!empty($_SERVER[$name])) {
|
||||
if (isset($_SERVER[$name])) {
|
||||
return $_SERVER[$name];
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -1069,12 +1069,14 @@ class CakeRequestTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testHeader() {
|
||||
$_SERVER['HTTP_X_THING'] = '';
|
||||
$_SERVER['HTTP_HOST'] = 'localhost';
|
||||
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-ca) AppleWebKit/534.8+ (KHTML, like Gecko) Version/5.0 Safari/533.16';
|
||||
$request = new CakeRequest('/', false);
|
||||
|
||||
$this->assertEquals($_SERVER['HTTP_HOST'], $request->header('host'));
|
||||
$this->assertEquals($_SERVER['HTTP_USER_AGENT'], $request->header('User-Agent'));
|
||||
$this->assertSame('', $request->header('X-thing'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue