mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2024-11-23 12:53:23 +00:00
[bugfix] Properly handle range > content-length (#1979)
This makes the serveFileRange function return the entire file if suffix-range is larger than content-length in compliance with RFC9110 Co-authored-by: mae <git@badat.dev>
This commit is contained in:
parent
ca5492b65f
commit
0d267fd598
1 changed files with 3 additions and 4 deletions
|
@ -208,10 +208,9 @@ func serveFileRange(rw http.ResponseWriter, r *http.Request, src io.Reader, rng
|
||||||
}
|
}
|
||||||
|
|
||||||
if end > size {
|
if end > size {
|
||||||
// This range exceeds length of the file, therefore unsatisfiable
|
// According to the http spec if end >= size the server should return the rest of the file
|
||||||
rw.Header().Set("Content-Range", "bytes *"+strconv.FormatInt(size, 10))
|
// https://www.rfc-editor.org/rfc/rfc9110#section-14.1.2-6
|
||||||
http.Error(rw, "Unsatisfiable Range", http.StatusRequestedRangeNotSatisfiable)
|
end = size - 1
|
||||||
return
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// No end supplied, implying file end
|
// No end supplied, implying file end
|
||||||
|
|
Loading…
Reference in a new issue