[server][storage] make sure to not send range response with minio storage driver

This commit is contained in:
Abhishek Shroff
2024-10-25 16:54:20 +05:30
parent 5102b11e3c
commit 44860df4a0
2 changed files with 14 additions and 3 deletions
+8 -2
View File
@@ -23,6 +23,8 @@ var htmlReplacer = strings.NewReplacer(
"'", "'",
)
var ErrRangeNotSupported = errors.New("byte range not suppoered")
type Resource interface {
FSName() string
FSPath() string
@@ -122,9 +124,13 @@ func serveResource(w http.ResponseWriter, r *http.Request, file Resource) {
// multipart responses."
ra := ranges[0]
sendSize = ra.length
code = http.StatusPartialContent
w.Header().Set("Content-Range", ra.contentRange(file.FSContentSize()))
reader, err = file.OpenRead(ra.start, ra.length)
if err == nil {
code = http.StatusPartialContent
w.Header().Set("Content-Range", ra.contentRange(file.FSContentSize()))
} else if errors.Is(err, ErrRangeNotSupported) {
err = nil
}
} else {
reader, err = file.OpenRead(0, -1)
}