Skip to content

Return nil from content_range for an unsatisfied range - #353

Open
afurm wants to merge 1 commit into
ruby:masterfrom
afurm:fix-content-range-unsatisfied-range
Open

afurm wants to merge 1 commit into
ruby:masterfrom
afurm:fix-content-range-unsatisfied-range

Conversation

@afurm

@afurm afurm commented Oct 11, 2026

Copy link
Copy Markdown
Member

A 416 response can carry Content-Range: bytes */1000 (RFC 9110, section 14.4). Right now content_range and range_length raise HTTPHeaderSyntaxError for it, so read_body fails on 416 responses that have no Content-Length.

This returns nil for the */length form, the same way non-byte units are handled since #63. Tests added.

A 416 Range Not Satisfiable response may carry
`Content-Range: bytes */1000` (RFC 9110 Section 14.4). `content_range`
only accepted the `first-last/length` form, so it raised
`Net::HTTPHeaderSyntaxError` for this valid value. `range_length` did
too, and `read_body` calls it when there is no Content-Length, so reading
the body of such a response failed.

Accept the unsatisfied-range form and return nil, since it has no byte
range. The body is then read to EOF as before.

This branch has not been deployed

No deployments
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