symfony/symfony — pull request #5057 by Burgov (2012-07-26 07:02:46+00:00)
Title: [HttpFoundation] Allow partial content to be sent

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
License of the code: MIT

I have an application which sends ogv video files from a MongoDB to the browser. This worked perfectly fine for Firefox browsers, but for some reason Chrome refused to show me the duration or the progress of the clip. After some googling, I found out it is because Chrome requires for Partial responses to be send. After some experimenting with manually creating partial content, I found this indeed to be the case. When I send partial content, satisfiable to Chromes Range request, it would show me duration and progress.

This PR will automatically parse a partial request for you, but only if you set the required flag on the response before the prepare() method is called.

There's some questions though.

First of all, it seems impossible or at least really unreliable to implement this for streamed response. If it should be made possible, it can only be done if the user actually specifies the content length for the full response, and then using buffered output, the response object can selectively echo the requested bytes.

Second of all, I'm not sure if all the code is in right place, so I'd like to hear all suggestions!