Skip to content

Commit

Permalink
refactor webdav publicfile
Browse files Browse the repository at this point in the history
  • Loading branch information
David Christofas committed Jul 13, 2021
1 parent 965ef68 commit d8ac608
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions internal/http/services/owncloud/ocdav/publicfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ func (h *PublicFileHandler) Handler(s *svc) http.Handler {
if relativePath != "" && relativePath != "/" {
// accessing the file
// PROPFIND has an implicit call
if r.Method != "PROPFIND" && !s.adjustResourcePathInURL(w, r) {
if r.Method != MethodPropfind && !s.adjustResourcePathInURL(w, r) {
return
}

r.URL.Path = path.Base(r.URL.Path)
switch r.Method {
case "PROPFIND":
case MethodPropfind:
s.handlePropfindOnToken(w, r, h.namespace, false)
case http.MethodGet:
s.handlePathGet(w, r, h.namespace)
Expand All @@ -73,7 +73,7 @@ func (h *PublicFileHandler) Handler(s *svc) http.Handler {
} else {
// accessing the virtual parent folder
switch r.Method {
case "PROPFIND":
case MethodPropfind:
s.handlePropfindOnToken(w, r, h.namespace, true)
case http.MethodOptions:
s.handleOptions(w, r, h.namespace)
Expand Down Expand Up @@ -138,7 +138,7 @@ func (s *svc) handlePropfindOnToken(w http.ResponseWriter, r *http.Request, ns s
sublog := appctx.GetLogger(ctx).With().Interface("tokenStatInfo", tokenStatInfo).Logger()
sublog.Debug().Msg("handlePropfindOnToken")

depth := r.Header.Get("Depth")
depth := r.Header.Get(HeaderDepth)
if depth == "" {
depth = "1"
}
Expand Down Expand Up @@ -195,8 +195,8 @@ func (s *svc) handlePropfindOnToken(w http.ResponseWriter, r *http.Request, ns s
return
}

w.Header().Set("DAV", "1, 3, extended-mkcol")
w.Header().Set("Content-Type", "application/xml; charset=utf-8")
w.Header().Set(HeaderDav, "1, 3, extended-mkcol")
w.Header().Set(HeaderContentType, "application/xml; charset=utf-8")
w.WriteHeader(http.StatusMultiStatus)
if _, err := w.Write([]byte(propRes)); err != nil {
sublog.Err(err).Msg("error writing response")
Expand Down

0 comments on commit d8ac608

Please sign in to comment.