Skip to content

Commit

Permalink
fix(response-handler): Send Accept-Ranges header on stream file
Browse files Browse the repository at this point in the history
  • Loading branch information
oxyno-zeta committed Dec 8, 2022
1 parent d38c7ff commit 4fb000c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/s3-proxy/response-handler/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ func setHeadersFromObjectOutput(w http.ResponseWriter, obj *StreamInput) {
setStrHeader(w, "Content-Range", obj.ContentRange)
setStrHeader(w, "Content-Type", obj.ContentType)
setStrHeader(w, "ETag", obj.ETag)
setStrHeader(w, "Accept-Ranges", "bytes")
setTimeHeader(w, "Last-Modified", obj.LastModified)

httpStatus := determineHTTPStatus(obj)
Expand Down
6 changes: 5 additions & 1 deletion pkg/s3-proxy/response-handler/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ func Test_handler_manageHeaders(t *testing.T) {
func Test_setHeadersFromObjectOutput(t *testing.T) {
// Tests data
now := time.Now()
headerEmpty := http.Header{}
headerEmpty.Add("Accept-Ranges", "bytes")
headerFullInput := http.Header{}
headerFullInput.Add("Cache-Control", "cachecontrol")
headerFullInput.Add("Expires", "expires")
Expand All @@ -164,6 +166,7 @@ func Test_setHeadersFromObjectOutput(t *testing.T) {
headerFullInput.Add("Content-Range", "bytes 200/200")
headerFullInput.Add("Content-Type", "contenttype")
headerFullInput.Add("ETag", "etag")
headerFullInput.Add("Accept-Ranges", "bytes")
headerFullInput.Add("Last-Modified", now.UTC().Format(http.TimeFormat))
headerPartialInput := http.Header{}
headerPartialInput.Add("Cache-Control", "cachecontrol")
Expand All @@ -174,6 +177,7 @@ func Test_setHeadersFromObjectOutput(t *testing.T) {
headerPartialInput.Add("Content-Length", "200")
headerPartialInput.Add("Content-Range", "bytes 200-1000/10000")
headerPartialInput.Add("Content-Type", "contenttype")
headerPartialInput.Add("Accept-Ranges", "bytes")
headerPartialInput.Add("ETag", "etag")
headerPartialInput.Add("Last-Modified", now.UTC().Format(http.TimeFormat))
// Structures
Expand All @@ -191,7 +195,7 @@ func Test_setHeadersFromObjectOutput(t *testing.T) {
args: args{
obj: &StreamInput{},
},
expectedHeaders: http.Header{},
expectedHeaders: headerEmpty,
expectedCode: http.StatusOK,
},
{
Expand Down

0 comments on commit 4fb000c

Please sign in to comment.