Generate PROPFIND request body

Instead of a hardcoded string, generate it with encoding/xml.
This commit is contained in:
Simon Ser
2020-01-14 20:00:54 +01:00
parent 6f9ff62747
commit 87a88d6723
4 changed files with 47 additions and 10 deletions

View File

@@ -27,3 +27,19 @@ type Propstat struct {
Status string `xml:"DAV: status"`
// TODO: error?, responsedescription?
}
// https://tools.ietf.org/html/rfc4918#section-14.20
type Propfind struct {
XMLName xml.Name `xml:"DAV: propfind"`
Prop *RawXMLValue `xml:"DAV: prop,omitempty"`
// TODO: propname | (allprop, include?)
}
func NewPropPropfind(names ...xml.Name) *Propfind {
children := make([]RawXMLValue, len(names))
for i, name := range names {
children[i] = *NewRawXMLElement(name, nil, nil)
}
prop := NewRawXMLElement(xml.Name{"DAV:", "prop"}, nil, children)
return &Propfind{Prop: prop}
}