From 31591c36970e1ba9e064a3382f258b49c700f1c9 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 --- src/Symfony/Component/HttpFoundation/Response.php | 2 +- src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index a9cea09b39f05..e6b913f416508 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/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/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php index f26302eef1120..d4b8812d99c21 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/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); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy