fix(storage): fall back to range GET when proxy strips Content-Length - #511
fix(storage): fall back to range GET when proxy strips Content-Length#511tylere wants to merge 5 commits into
Conversation
…y strips Content-Length The data proxy omits Content-Length from HEAD responses, causing getObjectInfo() to always resolve ContentLength as undefined → 0, and ObjectSummary to display "0 B" for every object. When ContentLength is absent (or 0) from the HEAD response, issue a GET with Range: bytes=0-0 and read the actual total from the Content-Range response header. Swallow failures in the fallback so objects on proxies that don't support ranges still return gracefully. Fixes #509 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Claude finished @alukach's task in 1m 52s —— View job Review complete
❌ Changes requested — see findings below.
Everything else looks solid: the regex/parseInt extraction of the total from Simplify (ponytail): nothing to report — the fallback is a minimal try/catch + regex, no unneeded abstractions or dependencies. 💰 Estimated review cost: $0.31 · 1m52s · 15 turns |
|
@claude address the PR review (#511 (comment)) and also consider if we could avoid interacting with the request body in entirety and instead only review the response headers |
|
Claude finished @alukach's task in 1m 42s —— View job Addressed the review
Change ( - // Content-Range format: "bytes 0-0/TOTAL_SIZE"
+ // Content-Range format: "bytes 0-0/TOTAL_SIZE". That header is all
+ // we need, so destroy the body instead of reading it — a proxy that
+ // ignores Range and returns the full object shouldn't be downloaded
+ // just to size it.
const match = rangeResponse.ContentRange?.match(/\/(\d+)$/);
if (match) {
size = parseInt(match[1], 10);
}
- for await (const _ of rangeResponse.Body as Readable) {
- // drain the 1-byte body to avoid connection leaks
- }
+ (rangeResponse.Body as Readable | undefined)?.destroy();This covers both asks:
The review's second point ( Note: I couldn't run |
Avoids downloading the full object when a proxy ignores the Range header and returns 200 with the whole body, and avoids reading any body bytes at all in the normal case — the fallback only needs the Content-Range header. Co-authored-by: Anthony Lukach <897290+alukach@users.noreply.github.com>
Summary
Content-Lengthfrom HEAD responses, sogetObjectInfo()always seesContentLengthasundefined→0, andObjectSummarydisplays 0 B for every objectContentLengthis absent (or0) from the HEAD, issue aGETwithRange: bytes=0-0and read the actual total from theContent-Rangeresponse header (bytes 0-0/TOTAL)size: 0Fixes #509
Test plan
getObjectInfotests still passContent-LengthContentLengthis0sizeas0when the range GET also fails🤖 Generated with Claude Code