mirror of
https://github.com/rclone/rclone.git
synced 2026-01-05 18:13:17 +00:00
serve webdav: fix webdav with --baseurl under Windows
Windows webdav does an OPTIONS request on the root even when given a path and if we return 404 here then Windows refuses to use the path. This patch allows OPTIONS requests only on the root to fix this. This affects all the HTTP servers.
This commit is contained in:
@@ -195,6 +195,14 @@ func MiddlewareCORS(allowOrigin string) Middleware {
|
||||
// MiddlewareStripPrefix instantiates middleware that removes the BaseURL from the path
|
||||
func MiddlewareStripPrefix(prefix string) Middleware {
|
||||
return func(next http.Handler) http.Handler {
|
||||
return http.StripPrefix(prefix, next)
|
||||
stripPrefixHandler := http.StripPrefix(prefix, next)
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
// Allow OPTIONS on the root only
|
||||
if r.URL.Path == "/" && r.Method == "OPTIONS" {
|
||||
next.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
stripPrefixHandler.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user