core: Allow non-tus HEAD requests, Add Length to HEAD responses
See https://github.com/tus/tusd/pull/480 Squashed commit of the following: commit 7439fd84a6103afdedaf94701a65ce4376789380 Author: Marius <marius@transloadit.com> Date: Mon Oct 18 00:27:12 2021 +0200 Docs and test commit 16d9dc67e8c8eefc328b1ce12d7e7ca01a49f9f6 Merge:bae0ffb
bea5183
Author: Marius <marius@transloadit.com> Date: Mon Oct 18 00:23:13 2021 +0200 Merge branch 'head_header_check' of https://github.com/s3rius/tusd into s3rius-head_header_check commitbea5183ec3
Author: Pavel Kirilin <win10@list.ru> Date: Thu May 20 19:53:36 2021 +0400 Fixed "Tus-Resumable" header check for HEAD request. Signed-off-by: Pavel Kirilin <win10@list.ru>
This commit is contained in:
parent
bae0ffb5e5
commit
84faa14987
|
@ -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)
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue