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()