From 7e76d66184ac219f30314d5cffc4d2ef62529fa7 Mon Sep 17 00:00:00 2001 From: flisk <73703417+flisk@users.noreply.github.com> Date: Sun, 23 Jul 2023 09:10:03 +0200 Subject: [PATCH] don't error when asked for 0-based range on empty objects (#17708) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In a reverse proxying setup, a proxy in front of MinIO may attempt to request objects in slices for enhanced cache efficiency. Since such a a proxy cannot have prior knowledge of how large a requested resource is, it usually sends a header of the form: Range: 0-$slice_size ... and, depending on the size of the resource, expects either: - an empty response, if $resource_size == 0 - a full response, if $resource_size <= $slice_size - a partial response, if $resource_size > $slice_size Prior to this change, MinIO would respond 416 Range Not Satisfiable if a client tried to request a range on an empty resource. This behavior is technically consistent with RFC9110[1] – However, it renders sliced reverse proxying, such as implemented in Nginx, broken in the case of empty files. Nginx itself seems to break this convention to enable "useful" responses in these cases, and MinIO should probably do that too. [1]: https://www.rfc-editor.org/rfc/rfc9110#byte.ranges --- cmd/httprange.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/httprange.go b/cmd/httprange.go index db2229905..ce91abb72 100644 --- a/cmd/httprange.go +++ b/cmd/httprange.go @@ -59,6 +59,9 @@ 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