[bugfix] Correctly handle range > content-length (#2395)

This commit is contained in:
Jadeiin 2023-11-29 10:25:52 +00:00 committed by GitHub
parent 2eb8b8eeb4
commit 2cc264584e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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