Repository navigation
Conversation
…nses In cli/lib/cache.js, totalOf(res, 0) fell back to Content-Length when Content-Range lacked a numeric '/total'. For segmented downloads (bounded 206 ranges with 'Content-Range: bytes a-b/*' or omitted Content-Range), that treated a single segment's length as the whole file size and aborted the download with a false size mismatch. For 416 responses without Content-Range, it treated the error body's Content-Length as the file size instead of falling back to f.bytes, causing already-complete .part files to be discarded and re-downloaded.
|
@Pybsama is attempting to deploy a commit to the nehanth's projects Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
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.
What
In
cli/lib/cache.js,totalOf(res, from)fell back toContent-LengthwheneverContent-Rangelacked a numeric/totalsuffix, and bothpullSegmented()(boundedRange: bytes=a-b206responses) and the416resume check inpullFile()passedfrom = 0:206segment responses whereContent-Rangeisbytes a-b/*or omitted,totalOf(res, 0)treated the single segment'sContent-Lengthas the full file size and aborted the download with a false size mismatch.416responses without aContent-Rangeheader,totalOf(res, 0)treated the error body'sContent-Lengthas the total file size instead of falling back tof.bytes, discarding an already-complete.partfile and re-downloading it from scratch.Content-Lengthvalues could also coerce toNaN.This change restricts the
Content-Lengthfallback intotalOf()to200responses and open-ended206responses (from != null) with a strict digit check, passesfrom = nullfor bounded206segments and416responses, and adds HTTP server regression tests incli/test/pull_test.mjs.Correctness
Tested on
node --test cli/test/pull_test.mjs— 13 passed, 0 failednpm run test:packages— 213 passed, 6 skipped, 0 failednpm run test:runtime— 6/6 checks passed (172 frames)node --checksyntax sweep across JS/MJS modules — all passed