Do not reject unexpected content types during upload creation
See tus/tus-java-client#10
This commit is contained in:
parent
d6ccb0fbb8
commit
182a96e3e8
|
@ -201,10 +201,16 @@ func TestPostWithUpload(t *testing.T) {
|
|||
Method: "POST",
|
||||
ReqHeader: map[string]string{
|
||||
"Tus-Resumable": "1.0.0",
|
||||
"Upload-Length": "300",
|
||||
"Upload-Metadata": "foo aGVsbG8=, bar d29ybGQ=",
|
||||
"Content-Type": "application/false",
|
||||
},
|
||||
ReqBody: strings.NewReader("hello"),
|
||||
Code: http.StatusBadRequest,
|
||||
Code: http.StatusCreated,
|
||||
ResHeader: map[string]string{
|
||||
"Location": "http://tus.io/files/foo",
|
||||
"Upload-Offset": "",
|
||||
},
|
||||
}).Run(handler, t)
|
||||
|
||||
(&httpTest{
|
||||
|
|
|
@ -190,15 +190,10 @@ func (handler *UnroutedHandler) Middleware(h http.Handler) http.Handler {
|
|||
// PostFile creates a new file upload using the datastore after validating the
|
||||
// length and parsing the metadata.
|
||||
func (handler *UnroutedHandler) PostFile(w http.ResponseWriter, r *http.Request) {
|
||||
// Check for presence of application/offset+octet-stream
|
||||
containsChunk := false
|
||||
if contentType := r.Header.Get("Content-Type"); contentType != "" {
|
||||
if contentType != "application/offset+octet-stream" {
|
||||
handler.sendError(w, r, ErrInvalidContentType)
|
||||
return
|
||||
}
|
||||
containsChunk = true
|
||||
}
|
||||
// Check for presence of application/offset+octet-stream. If another content
|
||||
// type is defined, it will be ignored and treated as none was set because
|
||||
// some HTTP clients may enforce a default value for this header.
|
||||
containsChunk := r.Header.Get("Content-Type") == "application/offset+octet-stream"
|
||||
|
||||
// Only use the proper Upload-Concat header if the concatenation extension
|
||||
// is even supported by the data store.
|
||||
|
|
Loading…
Reference in New Issue