Skip to content

Commit a58dc88

Browse files
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.
1 parent 18f8a2a commit a58dc88

File tree

3 files changed

+0
-19
lines changed

3 files changed

+0
-19
lines changed

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ CHANGELOG
66

77
* Add stale while revalidate and stale if error cache header
88
* Allow dynamic session "ttl" when using a remote storage
9-
* Send `Content-Length` when calling `Response::send()` and the content is a non-empty string
109

1110
6.0
1211
---

Response.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,6 @@ public function sendContent(): static
371371
*/
372372
public function send(): static
373373
{
374-
if (\is_string($this->content) && '' !== $this->content && !$this->headers->has('Transfer-Encoding')) {
375-
$this->headers->set('Content-Length', \strlen($this->content));
376-
}
377-
378374
$this->sendHeaders();
379375
$this->sendContent();
380376

Tests/ResponseTest.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,6 @@ public function testSend()
5757
$this->assertObjectHasAttribute('statusCode', $responseSent);
5858
$this->assertObjectHasAttribute('statusText', $responseSent);
5959
$this->assertObjectHasAttribute('charset', $responseSent);
60-
$this->assertFalse($responseSent->headers->has('Content-Length'));
61-
62-
ob_start();
63-
64-
$response = new Response('foo');
65-
$responseSent = $response->send();
66-
$this->assertSame('3', $responseSent->headers->get('Content-Length'));
67-
68-
$response = new Response('bar');
69-
$response->headers->set('Transfer-Encoding', 'chunked');
70-
$responseSent = $response->send();
71-
$this->assertFalse($responseSent->headers->has('Content-Length'));
72-
73-
$this->assertSame('foobar', ob_get_clean());
7460
}
7561

7662
public function testGetCharset()

0 commit comments

Comments
 (0)