[HttpFoundation] Fixed case-sensitive handling of cache-control header in RedirectResponse constructor.
This commit is contained in:
parent
1583b4f46a
commit
b5e6c99a3b
@ -42,7 +42,7 @@ class RedirectResponse extends Response
|
||||
throw new \InvalidArgumentException(sprintf('The HTTP status code is not a redirect ("%s" given).', $status));
|
||||
}
|
||||
|
||||
if (301 == $status && !\array_key_exists('cache-control', $headers)) {
|
||||
if (301 == $status && !\array_key_exists('cache-control', array_change_key_case($headers, \CASE_LOWER))) {
|
||||
$this->headers->remove('cache-control');
|
||||
}
|
||||
}
|
||||
|
@ -91,6 +91,10 @@ class RedirectResponseTest extends TestCase
|
||||
$this->assertFalse($response->headers->hasCacheControlDirective('no-cache'));
|
||||
$this->assertTrue($response->headers->hasCacheControlDirective('max-age'));
|
||||
|
||||
$response = new RedirectResponse('foo.bar', 301, ['Cache-Control' => 'max-age=86400']);
|
||||
$this->assertFalse($response->headers->hasCacheControlDirective('no-cache'));
|
||||
$this->assertTrue($response->headers->hasCacheControlDirective('max-age'));
|
||||
|
||||
$response = new RedirectResponse('foo.bar', 302);
|
||||
$this->assertTrue($response->headers->hasCacheControlDirective('no-cache'));
|
||||
}
|
||||
|
Reference in New Issue
Block a user