From 7e24e5dbf9b5eb5af8ca466be8c482a61d790c0b Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 31 May 2022 16:27:13 +0200 Subject: [PATCH] Revert "feature #45092 [HttpFoundation] Send `Content-Length` when calling `Response::send()` and the content is a non-empty string (nicolas-grekas)" This reverts commit aff969d9353616bdbefbe64f5964f1f38d9e9260, reversing changes made to 8b680f053208219e479ed7a8e82314b91f24f270. --- src/Symfony/Component/HttpFoundation/CHANGELOG.md | 1 - src/Symfony/Component/HttpFoundation/Response.php | 4 ---- .../HttpFoundation/Tests/ResponseTest.php | 14 -------------- 3 files changed, 19 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/CHANGELOG.md b/src/Symfony/Component/HttpFoundation/CHANGELOG.md index 29bc7507e58b6..fdbd39cead318 100644 --- a/src/Symfony/Component/HttpFoundation/CHANGELOG.md +++ b/src/Symfony/Component/HttpFoundation/CHANGELOG.md @@ -6,7 +6,6 @@ CHANGELOG * Add stale while revalidate and stale if error cache header * Allow dynamic session "ttl" when using a remote storage - * Send `Content-Length` when calling `Response::send()` and the content is a non-empty string 6.0 --- diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index da5cec5405226..e452e1a017f37 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -371,10 +371,6 @@ public function sendContent(): static */ public function send(): static { - if (\is_string($this->content) && '' !== $this->content && !$this->headers->has('Transfer-Encoding')) { - $this->headers->set('Content-Length', \strlen($this->content)); - } - $this->sendHeaders(); $this->sendContent(); diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php index 9d4a32a54269d..d3905c8f9d3aa 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php @@ -57,20 +57,6 @@ public function testSend() $this->assertObjectHasAttribute('statusCode', $responseSent); $this->assertObjectHasAttribute('statusText', $responseSent); $this->assertObjectHasAttribute('charset', $responseSent); - $this->assertFalse($responseSent->headers->has('Content-Length')); - - ob_start(); - - $response = new Response('foo'); - $responseSent = $response->send(); - $this->assertSame('3', $responseSent->headers->get('Content-Length')); - - $response = new Response('bar'); - $response->headers->set('Transfer-Encoding', 'chunked'); - $responseSent = $response->send(); - $this->assertFalse($responseSent->headers->has('Content-Length')); - - $this->assertSame('foobar', ob_get_clean()); } public function testGetCharset() 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