fix: improve suffix range and open-ended range handling#64
Open
sendya wants to merge 3 commits into
Open
Conversation
- rangecontrol.Parse now accepts totalSize to resolve suffix ranges and open-ended ranges; skips suffix ranges exceeding total size - fillRange: rename hasSuffixRange to hasUnresolvableRange and also detect open-ended ranges; bypass when object size is unknown - internal.go: add nil check for rng before accessing rng.End - multirange: use rangecontrol.Parse for proper range detection; single suffix ranges pass through to next layer; return 416 for truly unresolvable ranges (unknown objSize without Content-Range) - Add benchmark tests for Parse, ParseRange, and ContentRange Co-Authored-By: Claude <noreply@anthropic.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.
概述
修复 issue #63 — 客户端发送 suffix range(如
Range: bytes=-512)时的两个 bug:rangecontrol.Parse失败都返回 416,但 suffix range 是 RFC 7233 合法的 HTTP Range 格式,multirange 不应拦截单 suffix range。math.MaxInt64推导 suffix range 起始位置,导致生成天文数字的 Range 头发送到上游。修改内容
P0: multirange 透传单 suffix range
rangecontrol.Parse(rawRange, math.MaxInt32)替代自定义hasSuffixRangebytes=abc,bytes=-)返回 416bytes=0-99,-512)在未知对象大小时拒绝P0: fillRange 绕过不可解析 range
hasSuffixRange→hasUnresolvableRange,同时检测 suffix range 和 open-ended rangeP0: rangecontrol.Parse 支持 totalSize
totalSize参数以解析 suffix range其他
internal.go: 新增rngnil 检查防止 panic边界情况
bytes=-512cache MISSbytes=-512cache HITbytes= -512bytes=0-99,-512bytes=100-cache MISSbytes=abcCloses #63
🤖 Generated with Claude Code