8000 Return correct content range and length from audio endpoint by mbsantiago · Pull Request #56 · mbsantiago/whombat · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Return correct content range and length from audio endpoint #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 29, 2025

Conversation

mbsantiago
Copy link
Owner
@mbsantiago mbsantiago commented Mar 29, 2025

This PR resolves an issue #51 where audio playback would abruptly stop before the end of the audio file in Chrome and Safari, while working as expected in Firefox.

Root Cause: The issue stemmed from how different browsers handle HTTP range requests. Chrome and Safari enforce stricter validation of Content-Range and Content-Length headers than Firefox.

Previously, the backend was returning headers in the form:

Content-Range: bytes a-b/total
Content-Length: (b - a)

However, per the HTTP Range Requests specification, the byte range is inclusive (a-b includes both a and b). Therefore, the correct Content-Length should be:

Content-Length: (b - a + 1)

Firefox tolerated the off-by-one discrepancy, but Chrome and Safari did not, leading to incomplete audio playback when streaming.

Fix: Updated the backend to:

  • Correctly calculate Content-Length as (b - a + 1)
  • Ensure that Content-Range accurately reflects the byte range being served

Audio playback now functions correctly across Chrome and Firefox. Testing in Safari is pending.

A big thanks to @federico-ferlito for pointing out this issue!

Copy link
codecov bot commented Mar 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.62%. Comparing base (50c2e62) to head (67080b1).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #56   +/-   ##
=======================================
  Coverage   66.62%   66.62%           
=======================================
  Files         179      179           
  Lines        8375     8375           
=======================================
  Hits         5580     5580           
  Misses       2795     2795           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mbsantiago mbsantiago merged commit 06583ed into main Mar 29, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0