Skip to content

Commit

Permalink
[HttpFoundation] Fixed type mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
Toflar authored and derrabus committed Jul 27, 2021
1 parent 31d4a64 commit 7016057
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ public function prepare(Request $request)
}

// Check if we need to send extra expire info headers
if ('1.0' == $this->getProtocolVersion() && str_contains($headers->get('Cache-Control'), 'no-cache')) {
if ('1.0' == $this->getProtocolVersion() && str_contains($headers->get('Cache-Control', ''), 'no-cache')) {
$headers->set('pragma', 'no-cache');
$headers->set('expires', -1);
}
Expand Down
6 changes: 6 additions & 0 deletions Tests/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,12 @@ public function testPrepareSetsPragmaOnHttp10Only()
$this->assertEquals('no-cache', $response->headers->get('pragma'));
$this->assertEquals('-1', $response->headers->get('expires'));

$response = new Response('foo');
$response->headers->remove('cache-control');
$response->prepare($request);
$this->assertFalse($response->headers->has('pragma'));
$this->assertFalse($response->headers->has('expires'));

$request->server->set('SERVER_PROTOCOL', 'HTTP/1.1');
$response = new Response('foo');
$response->prepare($request);
Expand Down

0 comments on commit 7016057

Please sign in to comment.