| 176 | } |
| 177 | |
| 178 | func readPropfind(r io.Reader) (pf propfind, status int, err error) { |
| 179 | c := countingReader{r: r} |
| 180 | if err = ixml.NewDecoder(&c).Decode(&pf); err != nil { |
| 181 | if err == io.EOF { |
| 182 | if c.n == 0 { |
| 183 | // An empty body means to propfind allprop. |
| 184 | // http://www.webdav.org/specs/rfc4918.html#METHOD_PROPFIND |
| 185 | return propfind{Allprop: new(struct{})}, 0, nil |
| 186 | } |
| 187 | err = errInvalidPropfind |
| 188 | } |
| 189 | return propfind{}, http.StatusBadRequest, err |
| 190 | } |
| 191 | |
| 192 | if pf.Allprop == nil && pf.Include != nil { |
| 193 | return propfind{}, http.StatusBadRequest, errInvalidPropfind |
| 194 | } |
| 195 | if pf.Allprop != nil && (pf.Prop != nil || pf.Propname != nil) { |
| 196 | return propfind{}, http.StatusBadRequest, errInvalidPropfind |
| 197 | } |
| 198 | if pf.Prop != nil && pf.Propname != nil { |
| 199 | return propfind{}, http.StatusBadRequest, errInvalidPropfind |
| 200 | } |
| 201 | if pf.Propname == nil && pf.Allprop == nil && pf.Prop == nil { |
| 202 | return propfind{}, http.StatusBadRequest, errInvalidPropfind |
| 203 | } |
| 204 | return pf, 0, nil |
| 205 | } |
| 206 | |
| 207 | // Property represents a single DAV resource property as defined in RFC 4918. |
| 208 | // See http://www.webdav.org/specs/rfc4918.html#data.model.for.resource.properties |