fix(files): bound SeekableHttpStream reads by Content-Range - #64086
Draft
joshtrichards wants to merge 5 commits into
Draft
fix(files): bound SeekableHttpStream reads by Content-Range#64086joshtrichards wants to merge 5 commits into
joshtrichards wants to merge 5 commits into
Conversation
Limit reads to the remaining bytes reported by `Content-Range` and determine EOF from the logical resource offset instead of the underlying HTTP stream. This avoids reading beyond the remote resource boundary when the response connection remains open. The change is safe because this wrapper already requires `Content-Range` and uses its total-size component to establish the remote resource boundary; the read cap is consistent with the existing contract. Signed-off-by: Josh <josh.t.richards@gmail.com>
Replace the ambiguous range-length state with an explicit total size, validate Content-Range responses, and improve stream cleanup during reconnect failures. Signed-off-by: Josh <josh.t.richards@gmail.com>
Assisted-by: Copilot:gpt-5.6-luna Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
8 tasks
Signed-off-by: Josh <josh.t.richards@gmail.com>
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
Harden
SeekableHttpStreamrange handling by making the resource size declared inContent-Rangeauthoritative.The key read-boundary change is:
Reads are now limited to the remaining bytes in the remote resource, so the wrapper no longer requests data beyond the logical end simply because an HTTP connection remains open.
The second commit hardens
Content-Rangevalidation through a dedicated helper and makes stream lifecycle and reconnect failure handling more explicit. It also ensures that the total resource size remains consistent across range requests.Logical EOF is determined from the declared resource size rather than transport connection closure. No additional
feof()check is introduced, since probing a socket for transport-level EOF could add blocking behavior. A response shorter than its declaredContent-Rangeremains governed by the existing PHP stream semantics.This addresses the timeout reported in #58276 while also improving general range-stream correctness and adding focused explicit test coverage.
TODO
Checklist
3. to review, feature component)stable32)AI (if applicable)