From 4e2b1218691e6e9e8d3e51de18efcefd8ac806ec Mon Sep 17 00:00:00 2001 From: chrislu Date: Sun, 16 Nov 2025 17:01:32 -0800 Subject: [PATCH] set content range --- weed/s3api/s3api_object_handlers.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/weed/s3api/s3api_object_handlers.go b/weed/s3api/s3api_object_handlers.go index 94f9d3afd..cd7159e33 100644 --- a/weed/s3api/s3api_object_handlers.go +++ b/weed/s3api/s3api_object_handlers.go @@ -817,8 +817,9 @@ func (s3a *S3ApiServer) streamFromVolumeServersWithSSE(w http.ResponseWriter, r startOffset = totalSize - suffixLen endOffset = totalSize - 1 } else { - w.WriteHeader(http.StatusRequestedRangeNotSatisfiable) + // Set header BEFORE WriteHeader w.Header().Set("Content-Range", fmt.Sprintf("bytes */%d", totalSize)) + w.WriteHeader(http.StatusRequestedRangeNotSatisfiable) return fmt.Errorf("invalid suffix range") } } else { @@ -839,8 +840,9 @@ func (s3a *S3ApiServer) streamFromVolumeServersWithSSE(w http.ResponseWriter, r // Validate range if startOffset < 0 || startOffset >= totalSize { - w.WriteHeader(http.StatusRequestedRangeNotSatisfiable) + // Set header BEFORE WriteHeader w.Header().Set("Content-Range", fmt.Sprintf("bytes */%d", totalSize)) + w.WriteHeader(http.StatusRequestedRangeNotSatisfiable) return fmt.Errorf("invalid range start") } @@ -849,8 +851,9 @@ func (s3a *S3ApiServer) streamFromVolumeServersWithSSE(w http.ResponseWriter, r } if endOffset < startOffset { - w.WriteHeader(http.StatusRequestedRangeNotSatisfiable) + // Set header BEFORE WriteHeader w.Header().Set("Content-Range", fmt.Sprintf("bytes */%d", totalSize)) + w.WriteHeader(http.StatusRequestedRangeNotSatisfiable) return fmt.Errorf("invalid range: end before start") } }