close #85\

GET, for collections, will return the same as PROPFIND
pull/144/head
Henrique Dias 2017-04-16 14:01:11 +01:00
parent 00cbdd1833
commit a72ea31b17
No known key found for this signature in database
GPG Key ID: 936F5EB68D786730
1 changed files with 25 additions and 0 deletions

View File

@ -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