summaryrefslogtreecommitdiff
path: root/internal/api/fileserver/servefile.go
diff options
context:
space:
mode:
authorLibravatar MaeIsBad <26093674+MaeIsBad@users.noreply.github.com>2023-07-12 09:51:51 +0200
committerLibravatar GitHub <noreply@github.com>2023-07-12 09:51:51 +0200
commit0d267fd598292529d407c3974f71a23df01e806a (patch)
tree01c23357577079869ab936bab80ba0ec6b701011 /internal/api/fileserver/servefile.go
parent[bugfix] Tidy up rss feed serving; don't error on empty feed (#1970) (diff)
downloadgotosocial-0d267fd598292529d407c3974f71a23df01e806a.tar.xz
[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>
Diffstat (limited to 'internal/api/fileserver/servefile.go')
-rw-r--r--internal/api/fileserver/servefile.go7
1 files changed, 3 insertions, 4 deletions
diff --git a/internal/api/fileserver/servefile.go b/internal/api/fileserver/servefile.go
index 275bcc136..25a414319 100644
--- a/internal/api/fileserver/servefile.go
+++ b/internal/api/fileserver/servefile.go
@@ -208,10 +208,9 @@ func serveFileRange(rw http.ResponseWriter, r *http.Request, src io.Reader, rng
}
if end > size {
- // This range exceeds length of the file, therefore unsatisfiable
- rw.Header().Set("Content-Range", "bytes *"+strconv.FormatInt(size, 10))
- http.Error(rw, "Unsatisfiable Range", http.StatusRequestedRangeNotSatisfiable)
- return
+ // 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
}
} else {
// No end supplied, implying file end