Closed
Conversation
The unit (bytes) is mandatory. See https://httpwg.org/specs/rfc9110.html#field.content-range
Content-Type must be "multipart/byteranges" and Content-Range must be unset. See https://httpwg.org/specs/rfc9110.html#partial.multipart
All header lines must be separated by CRLF, not LF. See https://httpwg.org/specs/rfc9110.html#multipart.byteranges and https://www.rfc-editor.org/rfc/rfc2046.html#section-5.1.1
Don't overwrite the default headers when sending a range response.
This was referenced Feb 14, 2026
Owner
|
I've merged every commit in a separate PR, I think it's clear like this. Thanks for this, once again! :) |
Owner
|
I've kept you as author on every commit, FYI. |
Contributor
Author
|
Thank you! They really were separate issues, but they all came up while trying to do one thing, so I filed them as 1 PR originally. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FileResponsedoes not follow the specification for range requests. The problems are:bytesin the value of theContent-Rangeheader when a range request is not satisfiable.Content-Typeheader should bemultipart/byteranges; boundary=<BOUNDARY>andContent-Rangeshould be unset.FileResponseinstead sets theContent-Rangeheader tomultipart/byterangesand sends the originalContent-Type.These 3 issues are addressed by the first 3 commits. The last commit lets
FileResponsemake a copy of the headers before modifying them for a range response. This means that it is possible to use the sameFileResponseinstance multiple times. Not being able to use aFileResponsemultiple times was the original reason I started looking into this, but it is not documented either way and it isn't technically a bug fix because of that, I think.Open questions:
FileResponse's constructor strip out aContent-Rangeheader if it is passed inheaders?Checklist