-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
bugSomething isn't workingSomething isn't workinggood-first-issueGood for newcomersGood for newcomers
Description
Description
In app/services/media_server.py (~line 23), the build_range_response function parses range requests using a simple string split:
range_spec = range_header.replace("bytes=", "").strip()
parts = range_spec.split("-")
start = int(parts[0]) if parts[0] else 0
end = int(parts[1]) if len(parts) > 1 and parts[1] else file_size - 1If a client requests the last 500 bytes using the standard suffix-byte-range format bytes=-500, parts evaluates to ["", "500"].
Because parts[0] is empty, start is erroneously set to 0, and end becomes 500.
This results in the server returning the first 501 bytes instead of the last 500 bytes, which breaks clients that attempt to seek to the end of a file or read trailing metadata.
Suggested Fix
Check if parts[0] is empty and parts[1] is present. If so, calculate the start offset from the end of the file:
if not parts[0] and len(parts) > 1 and parts[1]:
start = max(0, file_size - int(parts[1]))
end = file_size - 1File Path
app/services/media_server.py
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood-first-issueGood for newcomersGood for newcomers