Skip to content

Handle open-ended byte ranges and empty list members correctly - #328

Open
OskarEichler wants to merge 1 commit into
ruby:masterfrom
OskarEichler:codex/ranges-http
Open

Handle open-ended byte ranges and empty list members correctly#328
OskarEichler wants to merge 1 commit into
ruby:masterfrom
OskarEichler:codex/ranges-http

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Accept valid open-ended byte ranges starting at zero, ignore empty list members, and serialize 0..-1 as bytes=0-. Keep rejecting a sole zero-length suffix and reject empty exclusive Ruby ranges before decrementing their end.

Reproduction

With r = Net::HTTP::Get.new('/'), r['Range'] = 'bytes=0-'; r.range raises before the patch but returns [0..-1] afterward. r.range = 0..-1 previously produced bytes=-0. Parsing bytes=,0-1 or bytes=0-1,,2-3 also raised. Assigning 0...0 previously produced an invalid range.

Verification

  • Ruby 4.0.6 through rbenv; existing bundle exec rake test: 201 tests, 914 assertions, zero failures/errors, both baseline and this isolated patch.
  • 26 focused checks cover open-ended/suffix/multiple ranges, empty list members, invalid descending ranges and empty exclusive assignments. HTTP list recipients ignore empty members: RFC 9110 section 5.6.1.2.
  • Ruby syntax and git diff --check pass. Supplemental Lint scan retains the same 25 pre-existing findings; no new findings by file/cop.
  • No test/spec files were added or modified, per this contribution's explicit no-new-tests constraint. Focused reproductions were run externally.

Compatibility and limitations

No API or dependency change. Intentional corrections: these valid inputs now succeed; assigning an empty exclusive range raises Net::HTTPHeaderSyntaxError. Sole bytes=-0 remains rejected.

Based on master 23e859e92e10e43cad520fcacac3fd43640dba7b. Optional external OpenSSL tests and other Ruby/OS combinations were not run. Existing related issues/PRs were checked; this is a focused correctness change, not a claim of exhaustive coverage.

Reference: https://www.rfc-editor.org/rfc/rfc9110.html#section-5.6.1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant