Revert "don't error when asked for 0-based range on empty objects (#17708) (#17713)

Revert "don't error when asked for 0-based range on empty objects (#17708)"

This reverts commit 7e76d66184.

There is no valid way to specify offsets in a 0-byte file. Blame it on the [RFC](https://datatracker.ietf.org/doc/html/rfc7233#section-4.4)

> The 416 (Range Not Satisfiable) status code indicates that none of the ranges in the 
> request's Range header field (Section 3.1) overlap the current extent of the selected resource...

A request for "bytes=0-" is a request for the first byte of a resource. If the resource is 0-length, 
the range [0,0] does not overlap the resource content and the server responds with an error.
This commit is contained in:
Klaus Post 2023-07-24 07:56:28 -07:00 committed by GitHub
parent 7e76d66184
commit 2da4bd5f1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,9 +59,6 @@ func (h *HTTPRangeSpec) GetLength(resourceSize int64) (rangeLength int64, err er
rangeLength = resourceSize
}
case h.Start == 0 && resourceSize == 0:
rangeLength = resourceSize
case h.Start >= resourceSize:
return 0, errInvalidRange