Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[HttpFoundation] Do not set a Transfer-Encoding header of chunked for streaming responses #3017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 2, 2012

Conversation

igorw
Copy link
Contributor

@igorw igorw commented Jan 2, 2012

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.

Apache expects the response to already be in chunked format in that case,
which causes it to not deliver the streamed body.

If no Content-Length is set on the response, web servers will automatically
switch to chunked Transfer-Encoding, and handle the chunking for you.

Nginx does not share the issue that apache has, but will add the Content-
Length header too.
@@ -33,7 +33,6 @@ public function testPrepareWith11Protocol()
$response->prepare($request);

$this->assertEquals('1.1', $response->getProtocolVersion());
$this->assertEquals('chunked', $response->headers->get('Transfer-Encoding'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about adding a negative test to avoid regressions and document why it's necessary, i.e. assertNotEquals(...)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

fabpot added a commit that referenced this pull request Jan 2, 2012
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.
@fabpot fabpot merged commit 7ae9348 into symfony:master Jan 2, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants