Fix content range for itag-18
Currently we report the chunk size as the size of the entire file. This changes it to clen with a fallback to content length just in case.
Related: https://github.com/TeamPiped/Piped/issues/4244
The code was written with Claude and reviewed by me.
Summary by CodeRabbit
- Bug Fixes
- Improved range response correction with enhanced content-length determination logic and fallback header parsing for more reliable partial content handling.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d43f74a6-f797-4427-acf8-f323f7490e0f
📥 Commits
Reviewing files that changed from the base of the PR and between e8955bb37ec2c267e4601267d90c425ef93f7367 and 17d9f4110bdf3d04e5bec8926d4448855e0f49d6.
📒 Files selected for processing (1)
src/main.rs
📝 Walkthrough
Walkthrough
The handle_range_response_correction function signature is updated to accept an optional clen: Option<u64> parameter. The total_size computation logic now prefers the provided clen value when present and positive, otherwise falls back to parsing content-length from upstream response headers. The call site at line 492 is updated to pass clen as an argument.
Changes
Range Response Correction with Explicit Content Length
| Layer / File(s) | Summary |
|---|---|
Range response correction with explicit content length src/main.rs |
Function signature adds clen: Option<u64> parameter. Logic prioritizes provided clen for total_size computation over header parsing. Call site passes clen argument. |
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~8 minutes
Poem
🐰 A content-length passed straight and true, No parsing headers when I have you! One parameter flows from call to core— Range responses work better than before! 📦
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title 'Fix content range for itag-18' clearly and concisely summarizes the main change: correcting how content-range headers are handled for itag-18 responses. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.