diff options
Diffstat (limited to 'internal/serving/disk')
-rw-r--r-- | internal/serving/disk/reader.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/internal/serving/disk/reader.go b/internal/serving/disk/reader.go index 350d036b..a0c0ed0d 100644 --- a/internal/serving/disk/reader.go +++ b/internal/serving/disk/reader.go @@ -194,10 +194,17 @@ func (reader *Reader) serveFile(ctx context.Context, w http.ResponseWriter, r *h return err } + w.Header().Set("Content-Type", contentType) + reader.fileSizeMetric.Observe(float64(fi.Size())) - w.Header().Set("Content-Type", contentType) - http.ServeContent(w, r, origPath, fi.ModTime(), file) + // Support SeekableFile if available + if rs, ok := file.(vfs.SeekableFile); ok { + http.ServeContent(w, r, origPath, fi.ModTime(), rs) + } else { + w.Header().Set("Content-Length", strconv.FormatInt(fi.Size(), 10)) + io.Copy(w, file) + } return nil } |