diff --git a/pkg/handler/head_test.go b/pkg/handler/head_test.go index 59da085..b5c83bb 100644 --- a/pkg/handler/head_test.go +++ b/pkg/handler/head_test.go @@ -48,9 +48,10 @@ func TestHead(t *testing.T) { }, Code: http.StatusOK, ResHeader: map[string]string{ - "Upload-Offset": "11", - "Upload-Length": "44", - "Cache-Control": "no-store", + "Upload-Offset": "11", + "Upload-Length": "44", + "Content-Length": "44", + "Cache-Control": "no-store", }, }).Run(handler, t) diff --git a/pkg/handler/unrouted_handler.go b/pkg/handler/unrouted_handler.go index ba2fb42..6c5f52b 100644 --- a/pkg/handler/unrouted_handler.go +++ b/pkg/handler/unrouted_handler.go @@ -260,9 +260,9 @@ func (handler *UnroutedHandler) Middleware(h http.Handler) http.Handler { } // Test if the version sent by the client is supported - // GET methods are not checked since a browser may visit this URL and does - // not include this header. This request is not part of the specification. - if r.Method != "GET" && r.Header.Get("Tus-Resumable") != "1.0.0" { + // GET and HEAD methods are not checked since a browser may visit this URL and does + // not include this header. GET requests are not part of the specification. + if r.Method != "GET" && r.Method != "HEAD" && r.Header.Get("Tus-Resumable") != "1.0.0" { handler.sendError(w, r, ErrUnsupportedVersion) return } @@ -472,6 +472,7 @@ func (handler *UnroutedHandler) HeadFile(w http.ResponseWriter, r *http.Request) w.Header().Set("Upload-Defer-Length", UploadLengthDeferred) } else { w.Header().Set("Upload-Length", strconv.FormatInt(info.Size, 10)) + w.Header().Set("Content-Length", strconv.FormatInt(info.Size, 10)) } w.Header().Set("Cache-Control", "no-store")