[RFC] [HttpFoundation] Allow partial content to be sent #5057
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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!