Use 200 OK in responses for preflight requests
Some browsers only accept 200 OK and not 204 No Content as respones codes for preflight requests. See tus/tus-js-client#34
This commit is contained in:
parent
3e6ea68d07
commit
d6bc50ff12
|
@ -48,7 +48,7 @@ func TestConcatPartial(t *testing.T) {
|
|||
ResHeader: map[string]string{
|
||||
"Tus-Extension": "creation,concatenation",
|
||||
},
|
||||
Code: http.StatusNoContent,
|
||||
Code: http.StatusOK,
|
||||
}).Run(handler, t)
|
||||
|
||||
(&httpTest{
|
||||
|
|
|
@ -20,7 +20,7 @@ func TestCORS(t *testing.T) {
|
|||
ReqHeader: map[string]string{
|
||||
"Origin": "tus.io",
|
||||
},
|
||||
Code: http.StatusNoContent,
|
||||
Code: http.StatusOK,
|
||||
ResHeader: map[string]string{
|
||||
"Access-Control-Allow-Headers": "",
|
||||
"Access-Control-Allow-Methods": "",
|
||||
|
|
|
@ -18,7 +18,7 @@ func TestOptions(t *testing.T) {
|
|||
(&httpTest{
|
||||
Name: "Successful request",
|
||||
Method: "OPTIONS",
|
||||
Code: http.StatusNoContent,
|
||||
Code: http.StatusOK,
|
||||
ResHeader: map[string]string{
|
||||
"Tus-Extension": "creation",
|
||||
"Tus-Version": "1.0.0",
|
||||
|
|
|
@ -46,7 +46,7 @@ func TestTerminate(t *testing.T) {
|
|||
ResHeader: map[string]string{
|
||||
"Tus-Extension": "creation,termination",
|
||||
},
|
||||
Code: http.StatusNoContent,
|
||||
Code: http.StatusOK,
|
||||
}).Run(handler, t)
|
||||
|
||||
(&httpTest{
|
||||
|
|
|
@ -158,7 +158,14 @@ func (handler *UnroutedHandler) Middleware(h http.Handler) http.Handler {
|
|||
header.Set("Tus-Version", "1.0.0")
|
||||
header.Set("Tus-Extension", handler.extensions)
|
||||
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
// Although the 204 No Content status code is a better fit in this case,
|
||||
// since we do not have a response body included, we cannot use it here
|
||||
// as some browsers only accept 200 OK as successful response to a
|
||||
// preflight request. If we send them the 204 No Content the response
|
||||
// will be ignored or interpreted as a rejection.
|
||||
// For example, the Presto engine, which is used in older versions of
|
||||
// Opera, Opera Mobile and Opera Mini, handles CORS this way.
|
||||
w.WriteHeader(http.StatusOK)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue