MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / readLockInfo

Function readLockInfo

server/webdav/xml.go:52–71  ·  view source on GitHub ↗
(r io.Reader)

Source from the content-addressed store, hash-verified

50}
51
52func readLockInfo(r io.Reader) (li lockInfo, status int, err error) {
53 c := &countingReader{r: r}
54 if err = ixml.NewDecoder(c).Decode(&li); err != nil {
55 if err == io.EOF {
56 if c.n == 0 {
57 // An empty body means to refresh the lock.
58 // http://www.webdav.org/specs/rfc4918.html#refreshing-locks
59 return lockInfo{}, 0, nil
60 }
61 err = errInvalidLockInfo
62 }
63 return lockInfo{}, http.StatusBadRequest, err
64 }
65 // We only support exclusive (non-shared) write locks. In practice, these are
66 // the only types of locks that seem to matter.
67 if li.Exclusive == nil || li.Shared != nil || li.Write == nil {
68 return lockInfo{}, http.StatusNotImplemented, errUnsupportedLockInfo
69 }
70 return li, 0, nil
71}
72
73type countingReader struct {
74 n int

Callers 2

handleLockMethod · 0.85
TestReadLockInfoFunction · 0.85

Calls 1

DecodeMethod · 0.80

Tested by 1

TestReadLockInfoFunction · 0.68