close #85\
GET, for collections, will return the same as PROPFIND
Former-commit-id: 41c186e17e16de45496d801ae93ec1ebb354278a [formerly ed98a85eedbb5ade8a15baafc6431eec423096a3] [formerly dd7355277eb837d12ae626b80b6b692426f824ca [formerly a72ea31b17
]]
Former-commit-id: 3d98abf4da701a5919a63d38c2331e96089baae7 [formerly 8dbca8f8ed8f3a87d244fb8aa0cc8bf523e51a67]
Former-commit-id: 07c11f93beb2fc10fb0253424c1d55a4178d7010
pull/726/head
parent
79ad87f4d8
commit
4a0c6ccd0b
|
@ -6,6 +6,8 @@ package filemanager
|
|||
import (
|
||||
e "errors"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/hacdias/caddy-filemanager/assets"
|
||||
|
@ -67,6 +69,29 @@ func (f FileManager) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, err
|
|||
}
|
||||
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
// Excerpt from RFC4918, section 9.4:
|
||||
//
|
||||
// GET, when applied to a collection, may return the contents of an
|
||||
// "index.html" resource, a human-readable view of the contents of
|
||||
// the collection, or something else altogether.
|
||||
//
|
||||
// It was decided on https://github.com/hacdias/caddy-filemanager/issues/85
|
||||
// that GET, for collection, will return the same as PROPFIND method.
|
||||
path := strings.Replace(r.URL.Path, c.WebDavURL, "", 1)
|
||||
path = user.Scope + "/" + path
|
||||
path = filepath.Clean(path)
|
||||
|
||||
var i os.FileInfo
|
||||
i, err = os.Stat(path)
|
||||
if err != nil {
|
||||
// Is there any error? WebDav will handle it... no worries.
|
||||
break
|
||||
}
|
||||
|
||||
if i.IsDir() {
|
||||
r.Method = "PROPFIND"
|
||||
}
|
||||
case "PROPPATCH", "MOVE", "PATCH", "PUT", "DELETE":
|
||||
if !user.AllowEdit {
|
||||
return http.StatusForbidden, nil
|
||||
|
|
Loading…
Reference in New Issue