(w http.ResponseWriter, r *http.Request)
| 670 | } |
| 671 | |
| 672 | func (h *Handler) handleUnlock(w http.ResponseWriter, r *http.Request) (status int, err error) { |
| 673 | // http://www.webdav.org/specs/rfc4918.html#HEADER_Lock-Token says that the |
| 674 | // Lock-Token value is a Coded-URL. We strip its angle brackets. |
| 675 | t := r.Header.Get("Lock-Token") |
| 676 | if len(t) < 2 || t[0] != '<' || t[len(t)-1] != '>' { |
| 677 | return http.StatusBadRequest, errInvalidLockToken |
| 678 | } |
| 679 | t = t[1 : len(t)-1] |
| 680 | |
| 681 | reqPath, status, err := h.stripPrefix(r.URL.Path) |
| 682 | if err != nil { |
| 683 | return status, err |
| 684 | } |
| 685 | ctx := r.Context() |
| 686 | user := ctx.Value(conf.UserKey).(*model.User) |
| 687 | reqPath, err = user.JoinPath(reqPath) |
| 688 | if err != nil { |
| 689 | return http.StatusForbidden, err |
| 690 | } |
| 691 | meta, err := op.GetNearestMeta(reqPath) |
| 692 | if err != nil && !errors.Is(errors.Cause(err), errs.MetaNotFound) { |
| 693 | return http.StatusInternalServerError, err |
| 694 | } |
| 695 | if !common.CanWrite(user, meta, reqPath) { |
| 696 | return http.StatusForbidden, errs.PermissionDenied |
| 697 | } |
| 698 | |
| 699 | switch err = h.LockSystem.Unlock(time.Now(), t); err { |
| 700 | case nil: |
| 701 | return http.StatusNoContent, err |
| 702 | case ErrForbidden: |
| 703 | return http.StatusForbidden, err |
| 704 | case ErrLocked: |
| 705 | return StatusLocked, err |
| 706 | case ErrNoSuchLock: |
| 707 | return http.StatusConflict, err |
| 708 | default: |
| 709 | return http.StatusInternalServerError, err |
| 710 | } |
| 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) |
no test coverage detected