8000 [RFC] [HttpFoundation] Allow partial content to be sent by Burgov · Pull Request #5057 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@Burgov
Copy link
Contributor
@Burgov Burgov commented Jul 26, 2012

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!

Copy link
Member

Choose a reason for hiding this comment

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

HttpFoundation should not depend on httpKernel

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

@Burgov
Copy link
Contributor Author
Burgov commented Jul 26, 2012

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

@fabpot
Copy link
Member
fabpot commented Jul 26, 2012

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.

@Burgov
Copy link
Contributor Author
Burgov commented Jul 26, 2012

@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

@jakzal
Copy link
Contributor
jakzal commented Dec 23, 2013

@Burgov wouldn't it be better if you modelled it as a separate Response class? PartialContentResponse for example.

Note that range support is already there in BinaryFileResponse (might be you could reuse these bits).

@Burgov
Copy link
Contributor Author
Burgov commented May 2, 2014

closed for now

@Burgov Burgov closed this May 2, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

0