[RFC] [HttpFoundation] Allow partial content to be sent#5057
[RFC] [HttpFoundation] Allow partial content to be sent#5057Burgov wants to merge 2 commits intosymfony:masterfrom
Conversation
There was a problem hiding this comment.
HttpFoundation should not depend on httpKernel
There was a problem hiding this comment.
you're right, it's not in the composer file, forgot to check. I removed the dependency and set the response code in another way
|
i'm also wondering if this behavior should be enabled by default - if a browser wants partial content, let's just give it to him, unless partial content was explicitly disabled |
|
I doubt it would be the most efficient thing to do. I think #4546 is probably a better idea for when you need to stream large files to the browser. |
|
@fabpot ah, I missed that one, really nice. But that PR wouldn't fix my case, as it supports only sending real files, while my data is a GridFS file I think the other PR should either be changed to support other types of binary content, or somehow use the logic in this PR, e.g. partial support in the base response object, to generate a partial response and besides that i think it should also be possible to send partial normal (ascii) responses |
|
@Burgov wouldn't it be better if you modelled it as a separate Response class? Note that range support is already there in |
|
closed for now |
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!