(w http.ResponseWriter, r *http.Request)
| 711 | } |
| 712 | |
| 713 | func (h *Handler) handlePropfind(w http.ResponseWriter, r *http.Request) (status int, err error) { |
| 714 | reqPath, status, err := h.stripPrefix(r.URL.Path) |
| 715 | if err != nil { |
| 716 | return status, err |
| 717 | } |
| 718 | ctx := r.Context() |
| 719 | userAgent := r.Header.Get("User-Agent") |
| 720 | ctx = context.WithValue(ctx, conf.UserAgentKey, userAgent) |
| 721 | user := ctx.Value(conf.UserKey).(*model.User) |
| 722 | password, _ := ctx.Value(conf.MetaPassKey).(string) |
| 723 | reqPath, err = user.JoinPath(reqPath) |
| 724 | if err != nil { |
| 725 | return http.StatusForbidden, err |
| 726 | } |
| 727 | meta, err := op.GetNearestMeta(reqPath) |
| 728 | if err != nil && !errors.Is(errors.Cause(err), errs.MetaNotFound) { |
| 729 | return http.StatusInternalServerError, err |
| 730 | } |
| 731 | if !common.CanAccess(user, meta, reqPath, password) { |
| 732 | return http.StatusForbidden, errs.PermissionDenied |
| 733 | } |
| 734 | fi, err := fs.Get(ctx, reqPath, &fs.GetArgs{}) |
| 735 | if err != nil { |
| 736 | if errs.IsNotFoundError(err) { |
| 737 | return http.StatusNotFound, err |
| 738 | } |
| 739 | return http.StatusMethodNotAllowed, err |
| 740 | } |
| 741 | depth := infiniteDepth |
| 742 | if hdr := r.Header.Get("Depth"); hdr != "" { |
| 743 | depth = parseDepth(hdr) |
| 744 | if depth == invalidDepth { |
| 745 | return http.StatusBadRequest, errInvalidDepth |
| 746 | } |
| 747 | } |
| 748 | pf, status, err := readPropfind(r.Body) |
| 749 | if err != nil { |
| 750 | return status, err |
| 751 | } |
| 752 | |
| 753 | mw := multistatusWriter{w: w} |
| 754 | |
| 755 | walkFn := func(reqPath string, info model.Obj, err error) error { |
| 756 | if err != nil { |
| 757 | return err |
| 758 | } |
| 759 | var pstats []Propstat |
| 760 | if pf.Propname != nil { |
| 761 | pnames, err := propnames(ctx, h.LockSystem, info) |
| 762 | if err != nil { |
| 763 | return err |
| 764 | } |
| 765 | pstat := Propstat{Status: http.StatusOK} |
| 766 | for _, xmlname := range pnames { |
| 767 | pstat.Props = append(pstat.Props, Property{XMLName: xmlname}) |
| 768 | } |
| 769 | pstats = append(pstats, pstat) |
| 770 | } else if pf.Allprop != nil { |
no test coverage detected