Skip to content

Commit 99f65ec

Browse files
committed
merged branch igorw/streaming (PR #3017)
Commits ------- 7ae9348 [streaming] Document and test that Transfer-Encoding is absent 83c23ca [streaming] Do not set a Transfer-Encoding header of chunked Discussion ---------- [HttpFoundation] Do not set a Transfer-Encoding header of chunked for streaming responses Bug fix: yes Feature addition: no Backwards compatibility break: no Symfony2 tests pass: yes This is an adjustment to the streaming introduced in #2935. Apache expects the response to already be in chunked format when the Transfer-Encoding header is set to chunked, which causes it to not deliver the streamed body. If no Content-Length is set on the response (regardless of Transfer-Encoding), web servers will automatically switch to chunked Transfer-Encoding, and handle the chunking for you. I have tested this with Apache 2.2.2 and nginx 1.0.5. Testing with other webservers is appreciated.
2 parents 5f959e3 + 7ae9348 commit 99f65ec

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

src/Symfony/Component/HttpFoundation/StreamedResponse.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ public function prepare(Request $request)
7070
{
7171
if ('1.0' != $request->server->get('SERVER_PROTOCOL')) {
7272
$this->setProtocolVersion('1.1');
73-
$this->headers->set('Transfer-Encoding', 'chunked');
7473
}
7574

7675
$this->headers->set('Cache-Control', 'no-cache');

tests/Symfony/Tests/Component/HttpFoundation/StreamedResponseTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function testPrepareWith11Protocol()
3333
$response->prepare($request);
3434

3535
$this->assertEquals('1.1', $response->getProtocolVersion());
36-
$this->assertEquals('chunked', $response->headers->get('Transfer-Encoding'));
36+
$this->assertNotEquals('chunked', $response->headers->get('Transfer-Encoding'), 'Apache assumes responses with a Transfer-Encoding header set to chunked to already be encoded.');
3737
$this->assertEquals('no-cache, private', $response->headers->get('Cache-Control'));
3838
}
3939

0 commit comments

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