mirror of
https://github.com/rclone/rclone.git
synced 2025-08-09 13:55:15 +02:00
http: fix webdav OPTIONS response (#6433)
This commit is contained in:
@ -62,6 +62,11 @@ func basicAuth(authenticator *LoggedBasicAuth) func(next http.Handler) http.Hand
|
||||
next.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
// skip auth for CORS preflight
|
||||
if r.Method == "OPTIONS" {
|
||||
next.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
username := authenticator.CheckAuth(r)
|
||||
if username == "" {
|
||||
@ -123,6 +128,11 @@ func MiddlewareAuthCustom(fn CustomAuthFn, realm string, userFromContext bool) M
|
||||
next.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
// skip auth for CORS preflight
|
||||
if r.Method == "OPTIONS" {
|
||||
next.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
user, pass, ok := parseAuthorization(r)
|
||||
if !ok && userFromContext {
|
||||
@ -177,13 +187,6 @@ func MiddlewareCORS(allowOrigin string) Middleware {
|
||||
w.Header().Add("Access-Control-Allow-Headers", "authorization, Content-Type")
|
||||
}
|
||||
|
||||
if r.Method == "OPTIONS" {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
return
|
||||
// Because CORS preflight OPTIONS requests are not authenticated,
|
||||
// and require a 200 OK response, we will return early here.
|
||||
}
|
||||
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user