Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Range Requests are not correctly handled for streaming large files #59159

Copy link
Copy link
Open
@bogdan-dinu-me

Description

@bogdan-dinu-me
Issue body actions

Symfony version(s) affected

6.4.x

Description

BinaryFileResponse returns Status 200 and no Content-Length or Content-Range headers when sending a request with "Range: bytes=0-".
I have a controller that sends large mp3 files for an html audio player. The audio file is loaded and starts playing in all browsers, but only Firefox allows seeking. Chrome and Edge just restart the audio when trying to seek.
I narroewed the issue to line 263 in BinaryFileResponse.php
} elseif ($end - $start < $fileSize - 1) {
Because $end is set to $fileSize -1 if not present in the Range header, the above condition will never be met.
Changing the above line to:
} elseif ($end - $start <= $fileSize - 1) {
Corrects the behaviour and the response from BinaryFileResponse is the same as from requesting a static file.

How to reproduce

Make a request from a web player for a large media file served by BinaryFileResponse. The server wil respond with Status 200 instead of Status 206 and proper headers.

Possible Solution

BinaryFileResponse.php (line 263):
} elseif ($end - $start <= $fileSize - 1) {

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.