serve: add test for content-disposition

This commit is contained in:
hiddenmarten 2025-01-22 21:57:10 +01:00
parent a8fe16f381
commit ee607aa373

View File

@ -2,6 +2,8 @@ package serve
import (
"context"
"github.com/rclone/rclone/fs"
"github.com/rclone/rclone/fs/object"
"io"
"net/http"
"net/http/httptest"
@ -82,3 +84,13 @@ func TestObjectBadRange(t *testing.T) {
body, _ := io.ReadAll(resp.Body)
assert.Equal(t, "Bad Request\n", string(body))
}
func TestObjectHEADContentDisposition(t *testing.T) {
w := httptest.NewRecorder()
r := httptest.NewRequest("HEAD", "http://example.com/aFile", nil)
m := fs.Metadata{"content-disposition": "inline"}
o := object.NewMemoryObject("aFile", time.Now(), []byte("")).WithMetadata(m)
Object(w, r, o)
resp := w.Result()
assert.Equal(t, "inline", resp.Header.Get("Content-Disposition"))
}