From 2cc264584e807297e26f6447eeaf2ad5c30dc10a Mon Sep 17 00:00:00 2001 From: Jadeiin <92222981+Jadeiin@users.noreply.github.com> Date: Wed, 29 Nov 2023 10:25:52 +0000 Subject: [PATCH] [bugfix] Correctly handle range > content-length (#2395) --- internal/api/fileserver/servefile.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/api/fileserver/servefile.go b/internal/api/fileserver/servefile.go index 5fe79f1d7..8fb5a838e 100644 --- a/internal/api/fileserver/servefile.go +++ b/internal/api/fileserver/servefile.go @@ -206,10 +206,11 @@ func serveFileRange(rw http.ResponseWriter, r *http.Request, src io.Reader, rng return } - if end > size { + if end >= size { // According to the http spec if end >= size the server should return the rest of the file // https://www.rfc-editor.org/rfc/rfc9110#section-14.1.2-6 end = size - 1 + endRng = strconv.FormatInt(end, 10) } } else { // No end supplied, implying file end