From 7016057b01f0ed3ec3ba1f31a580b6661667c2e1 Mon Sep 17 00:00:00 2001 From: Yanick Witschi Date: Tue, 27 Jul 2021 13:26:46 +0200 Subject: [PATCH] [HttpFoundation] Fixed type mismatch --- Response.php | 2 +- Tests/ResponseTest.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Response.php b/Response.php index a9cea09b3..e6b913f41 100644 --- a/Response.php +++ b/Response.php @@ -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); } diff --git a/Tests/ResponseTest.php b/Tests/ResponseTest.php index f26302eef..d4b8812d9 100644 --- a/Tests/ResponseTest.php +++ b/Tests/ResponseTest.php @@ -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);