Skip to content

rgw: send Content-Range with 416 InvalidRange responses - #73200

Open
RaminNietzsche wants to merge 1 commit into
ceph:mainfrom
RaminNietzsche:wip-rgw-416-content-range
Open

RaminNietzsche wants to merge 1 commit into
ceph:mainfrom
RaminNietzsche:wip-rgw-416-content-range

Conversation

@RaminNietzsche

Copy link
Copy Markdown
Member

A GetObject whose Range cannot be satisfied is answered 416 with no Content-Range. RFC 9110 14.4 and 15.5.17 say a server answering 416 to a byte-range request should send the complete length as Content-Range: bytes */<length>, and AWS S3 does; clients that resume downloads read the object size from it.

The S3 and Swift send_response_data() return on error before they dump the range. When the range parsed and the object turned out too short or empty, this sends the unsatisfied-range form with the object size. A range that did not parse also ends in -ERANGE (with rgw_ignore_get_invalid_range=false), but the object has not been read at that point, so no size is sent for it.

Fixes: https://tracker.ceph.com/issues/82229

Testing

On a single-host vstart cluster built from this branch (on main, the 416 answers carry no Content-Range; see the tracker):

Request Answer
S3, 10-byte object, Range: bytes=100-200 416, Content-Range: bytes */10
S3, empty object, Range: bytes=0-1 416, Content-Range: bytes */0
S3, Range: bytes=5-9 206, Content-Range: bytes 5-9/10
S3, Range: bytes=9-3 (does not parse) 416, no Content-Range
Swift, 10-byte object, Range: bytes=100-200 416, Content-Range: bytes */10
Swift, Range: bytes=2-3 206, Content-Range: bytes 2-3/10

s3-tests: test_ranged_request_invalid_range and test_ranged_request_empty_object now assert the header; -k test_ranged_request passes (5 tests).

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

A GetObject whose range cannot be satisfied is answered 416 with no
Content-Range. RFC 9110 sections 14.4 and 15.5.17 say a server that
answers 416 to a byte-range request should send the complete length as
"Content-Range: bytes */<length>", and AWS S3 does; clients that resume
downloads read the object size from it.

The S3 and Swift send_response_data() return on error before they dump
the range. When the range parsed and the object turned out too short
or empty, send the unsatisfied-range form with the object size. A
range that did not parse also ends in -ERANGE, but the object has not
been read then, so no size is sent.

Fixes: https://tracker.ceph.com/issues/82229
Signed-off-by: ramin.najarbashi <[email protected]>
@RaminNietzsche
RaminNietzsche requested a review from a team as a code owner October 28, 2026 12:51
@RaminNietzsche

Copy link
Copy Markdown
Member Author

The probe script used for the before/after checks is here: https://gist.github.com/RaminNietzsche/818ad8dd6b8d8093560183cd09d2b169

It runs against a vstart RGW (python3 rgw-rfc9110-repro.py, defaults to localhost:8000 with the vstart credentials). The case for this PR is T1 416 unsatisfiable range; on main it prints no Content-Range, with this branch it prints Content-Range: bytes */10. The other cases in the script cover separate RFC 9110 items and are not affected by this change.

@RaminNietzsche

Copy link
Copy Markdown
Member Author

RFC 9110 RGW audit — series context

This PR is one focused change from an RFC 9110 conformance review of RGW (S3, Swift, Admin, STS). Each PR is meant to review and merge on its own; there is no batch dependency unless called out below.

Item PR Tracker
T1 — 416 + Content-Range #73200 #82229
T4b — CopyObject source preconditions → 412 #73201 #82230
T4a — If-Match before If-Modified-Since #73205 #82233 (Fixes #19965)
T5 — 405 + Allow, 501 for unknown methods #73206 #82235
T6 — Swift 401 + WWW-Authenticate #73209 #82242

Same audit, already tracked on other PRs (not part of this series authorship):

Item PR Tracker
T2 — Range header parsing #71300 #13412
T3 — whole-tag If-Match / If-None-Match #72117 #80924

Follow-ups from the audit not opened yet: T4d If-Range (best after #71300 and #72117 land), T8b header field section too large → 431, T9 admin GET ?sync=true side effects.

Shared repro script and sample output: https://gist.github.com/RaminNietzsche/818ad8dd6b8d8093560183cd09d2b169 (rgw-rfc9110-repro.py; cases T1–T8).

This PR (T1): RFC 9110 §14.4 — unsatisfiable range responses should include Content-Range: bytes */<length>. Kept separate from Range parser work in #71300.

@RaminNietzsche

Copy link
Copy Markdown
Member Author

jenkins test make check arm64

@anrao19 anrao19 added the wip-anrao6-testing wip-anrao6-testing label Nov 13, 2026
@anrao19

anrao19 commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to wip-anrao6-testing-2026-11-13-0833-main.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants