| 50 | } |
| 51 | |
| 52 | func 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 | |
| 73 | type countingReader struct { |
| 74 | n int |