Skip to content

Commit

Permalink
[bugfix] Correctly handle range > content-length (#2395)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jadeiin authored Nov 29, 2023
1 parent 2eb8b8e commit 2cc2645
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/api/fileserver/servefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2cc2645

Please sign in to comment.