2020-01-14 17:51:17 +00:00
|
|
|
package internal
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/xml"
|
2022-04-29 14:13:38 +01:00
|
|
|
"errors"
|
2020-01-14 20:29:54 +00:00
|
|
|
"fmt"
|
|
|
|
"net/http"
|
2020-01-22 10:07:30 +00:00
|
|
|
"net/url"
|
2020-02-12 16:12:21 +00:00
|
|
|
"path"
|
2020-01-14 20:29:54 +00:00
|
|
|
"strconv"
|
|
|
|
"strings"
|
2020-01-15 18:08:38 +00:00
|
|
|
"time"
|
2020-01-14 17:51:17 +00:00
|
|
|
)
|
|
|
|
|
2020-01-17 16:09:23 +00:00
|
|
|
const Namespace = "DAV:"
|
|
|
|
|
2020-01-20 09:56:25 +00:00
|
|
|
var (
|
|
|
|
ResourceTypeName = xml.Name{"DAV:", "resourcetype"}
|
|
|
|
DisplayNameName = xml.Name{"DAV:", "displayname"}
|
|
|
|
GetContentLengthName = xml.Name{"DAV:", "getcontentlength"}
|
|
|
|
GetContentTypeName = xml.Name{"DAV:", "getcontenttype"}
|
|
|
|
GetLastModifiedName = xml.Name{"DAV:", "getlastmodified"}
|
|
|
|
GetETagName = xml.Name{"DAV:", "getetag"}
|
|
|
|
|
|
|
|
CurrentUserPrincipalName = xml.Name{"DAV:", "current-user-principal"}
|
|
|
|
)
|
|
|
|
|
2020-01-15 18:23:09 +00:00
|
|
|
type Status struct {
|
|
|
|
Code int
|
|
|
|
Text string
|
|
|
|
}
|
2020-01-14 20:29:54 +00:00
|
|
|
|
2020-01-15 18:23:09 +00:00
|
|
|
func (s *Status) MarshalText() ([]byte, error) {
|
|
|
|
text := s.Text
|
|
|
|
if text == "" {
|
|
|
|
text = http.StatusText(s.Code)
|
2020-01-15 17:21:27 +00:00
|
|
|
}
|
2020-02-03 20:54:55 +00:00
|
|
|
return []byte(fmt.Sprintf("HTTP/1.1 %v %v", s.Code, text)), nil
|
2020-01-15 17:21:27 +00:00
|
|
|
}
|
|
|
|
|
2020-01-15 18:23:09 +00:00
|
|
|
func (s *Status) UnmarshalText(b []byte) error {
|
|
|
|
if len(b) == 0 {
|
|
|
|
return nil
|
2020-01-14 20:35:24 +00:00
|
|
|
}
|
|
|
|
|
2020-01-15 18:23:09 +00:00
|
|
|
parts := strings.SplitN(string(b), " ", 3)
|
2020-01-14 20:29:54 +00:00
|
|
|
if len(parts) != 3 {
|
2020-01-15 18:23:09 +00:00
|
|
|
return fmt.Errorf("webdav: invalid HTTP status %q: expected 3 fields", s)
|
2020-01-14 20:29:54 +00:00
|
|
|
}
|
|
|
|
code, err := strconv.Atoi(parts[1])
|
|
|
|
if err != nil {
|
2020-01-15 18:23:09 +00:00
|
|
|
return fmt.Errorf("webdav: invalid HTTP status %q: failed to parse code: %v", s, err)
|
2020-01-14 20:29:54 +00:00
|
|
|
}
|
|
|
|
|
2020-01-15 18:23:09 +00:00
|
|
|
s.Code = code
|
|
|
|
s.Text = parts[2]
|
|
|
|
return nil
|
2020-01-15 17:21:27 +00:00
|
|
|
}
|
|
|
|
|
2020-01-15 18:23:09 +00:00
|
|
|
func (s *Status) Err() error {
|
|
|
|
if s == nil {
|
|
|
|
return nil
|
2020-01-15 17:21:27 +00:00
|
|
|
}
|
|
|
|
|
2020-01-14 20:29:54 +00:00
|
|
|
// TODO: handle 2xx, 3xx
|
2020-01-15 18:23:09 +00:00
|
|
|
if s.Code != http.StatusOK {
|
2020-01-19 14:29:51 +00:00
|
|
|
return &HTTPError{Code: s.Code}
|
2020-01-14 20:29:54 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-01-22 10:07:30 +00:00
|
|
|
type Href url.URL
|
|
|
|
|
|
|
|
func (h *Href) String() string {
|
|
|
|
u := (*url.URL)(h)
|
|
|
|
return u.String()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Href) MarshalText() ([]byte, error) {
|
|
|
|
return []byte(h.String()), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Href) UnmarshalText(b []byte) error {
|
|
|
|
u, err := url.Parse(string(b))
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
*h = Href(*u)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-01-14 17:51:17 +00:00
|
|
|
// https://tools.ietf.org/html/rfc4918#section-14.16
|
2020-01-14 20:29:54 +00:00
|
|
|
type Multistatus struct {
|
2020-01-14 19:27:08 +00:00
|
|
|
XMLName xml.Name `xml:"DAV: multistatus"`
|
2020-01-14 20:32:43 +00:00
|
|
|
Responses []Response `xml:"response"`
|
|
|
|
ResponseDescription string `xml:"responsedescription,omitempty"`
|
2020-03-29 13:08:48 +01:00
|
|
|
SyncToken string `xml:"sync-token,omitempty"`
|
2020-01-14 17:51:17 +00:00
|
|
|
}
|
|
|
|
|
2020-01-15 17:21:27 +00:00
|
|
|
func NewMultistatus(resps ...Response) *Multistatus {
|
|
|
|
return &Multistatus{Responses: resps}
|
|
|
|
}
|
|
|
|
|
2020-02-12 16:12:21 +00:00
|
|
|
func (ms *Multistatus) Get(p string) (*Response, error) {
|
|
|
|
// Clean the path to avoid issues with trailing slashes
|
|
|
|
p = path.Clean(p)
|
2020-01-14 20:29:54 +00:00
|
|
|
for i := range ms.Responses {
|
|
|
|
resp := &ms.Responses[i]
|
2020-01-14 22:13:23 +00:00
|
|
|
for _, h := range resp.Hrefs {
|
2020-02-12 16:12:21 +00:00
|
|
|
if path.Clean(h.Path) == p {
|
2022-04-29 15:06:56 +01:00
|
|
|
return resp, resp.Err()
|
2020-01-14 20:29:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-12 16:12:21 +00:00
|
|
|
return nil, fmt.Errorf("webdav: missing response for path %q", p)
|
2020-01-14 20:29:54 +00:00
|
|
|
}
|
|
|
|
|
2020-01-14 17:51:17 +00:00
|
|
|
// https://tools.ietf.org/html/rfc4918#section-14.24
|
|
|
|
type Response struct {
|
2020-01-17 13:47:10 +00:00
|
|
|
XMLName xml.Name `xml:"DAV: response"`
|
2020-01-22 10:07:30 +00:00
|
|
|
Hrefs []Href `xml:"href"`
|
2020-01-17 13:47:10 +00:00
|
|
|
Propstats []Propstat `xml:"propstat,omitempty"`
|
|
|
|
ResponseDescription string `xml:"responsedescription,omitempty"`
|
|
|
|
Status *Status `xml:"status,omitempty"`
|
|
|
|
Error *Error `xml:"error,omitempty"`
|
|
|
|
Location *Location `xml:"location,omitempty"`
|
2020-01-14 20:29:54 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 10:07:30 +00:00
|
|
|
func NewOKResponse(path string) *Response {
|
|
|
|
href := Href{Path: path}
|
2020-01-15 17:21:27 +00:00
|
|
|
return &Response{
|
2020-01-22 10:07:30 +00:00
|
|
|
Hrefs: []Href{href},
|
2020-01-15 18:23:09 +00:00
|
|
|
Status: &Status{Code: http.StatusOK},
|
2020-01-15 17:21:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-29 14:13:38 +01:00
|
|
|
func NewErrorResponse(path string, err error) *Response {
|
|
|
|
code := http.StatusInternalServerError
|
|
|
|
var httpErr *HTTPError
|
|
|
|
if errors.As(err, &httpErr) {
|
|
|
|
code = httpErr.Code
|
|
|
|
}
|
|
|
|
|
|
|
|
var errElt *Error
|
2022-05-02 19:41:33 +01:00
|
|
|
errors.As(err, &errElt)
|
2022-04-29 14:13:38 +01:00
|
|
|
|
|
|
|
href := Href{Path: path}
|
|
|
|
return &Response{
|
|
|
|
Hrefs: []Href{href},
|
|
|
|
Status: &Status{Code: code},
|
|
|
|
ResponseDescription: err.Error(),
|
|
|
|
Error: errElt,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-29 15:06:56 +01:00
|
|
|
func (resp *Response) Err() error {
|
|
|
|
if resp.Status == nil || resp.Status.Code/100 == 2 {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error = resp.Error
|
|
|
|
if resp.ResponseDescription != "" {
|
|
|
|
if err != nil {
|
|
|
|
err = fmt.Errorf("%v (%w)", resp.ResponseDescription, err)
|
|
|
|
} else {
|
|
|
|
err = fmt.Errorf("%v", resp.ResponseDescription)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return &HTTPError{
|
|
|
|
Code: resp.Status.Code,
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-22 10:07:30 +00:00
|
|
|
func (resp *Response) Path() (string, error) {
|
2022-04-29 15:06:56 +01:00
|
|
|
err := resp.Err()
|
2021-01-12 11:57:28 +00:00
|
|
|
var path string
|
|
|
|
if len(resp.Hrefs) == 1 {
|
|
|
|
path = resp.Hrefs[0].Path
|
|
|
|
} else if err == nil {
|
|
|
|
err = fmt.Errorf("webdav: malformed response: expected exactly one href element, got %v", len(resp.Hrefs))
|
2020-01-14 22:13:23 +00:00
|
|
|
}
|
2021-01-12 11:57:28 +00:00
|
|
|
return path, err
|
2020-01-14 22:13:23 +00:00
|
|
|
}
|
|
|
|
|
2020-01-21 17:41:25 +00:00
|
|
|
func (resp *Response) DecodeProp(values ...interface{}) error {
|
|
|
|
for _, v := range values {
|
|
|
|
// TODO wrap errors with more context (XML name)
|
|
|
|
name, err := valueXMLName(v)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2020-01-19 11:01:55 +00:00
|
|
|
}
|
2022-04-29 15:06:56 +01:00
|
|
|
if err := resp.Err(); err != nil {
|
2020-01-19 11:01:55 +00:00
|
|
|
return err
|
2020-01-14 20:29:54 +00:00
|
|
|
}
|
2020-01-21 17:41:25 +00:00
|
|
|
for _, propstat := range resp.Propstats {
|
|
|
|
raw := propstat.Prop.Get(name)
|
|
|
|
if raw == nil {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if err := propstat.Status.Err(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return raw.Decode(v)
|
|
|
|
}
|
2020-03-28 22:51:45 +00:00
|
|
|
return HTTPErrorf(http.StatusNotFound, "missing property %s", name)
|
2020-01-14 20:29:54 +00:00
|
|
|
}
|
2020-01-21 17:41:25 +00:00
|
|
|
|
|
|
|
return nil
|
2020-01-14 20:29:54 +00:00
|
|
|
}
|
|
|
|
|
2020-01-15 17:21:27 +00:00
|
|
|
func (resp *Response) EncodeProp(code int, v interface{}) error {
|
|
|
|
raw, err := EncodeRawXMLElement(v)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
for i := range resp.Propstats {
|
|
|
|
propstat := &resp.Propstats[i]
|
2020-01-15 18:23:09 +00:00
|
|
|
if propstat.Status.Code == code {
|
2020-01-15 17:21:27 +00:00
|
|
|
propstat.Prop.Raw = append(propstat.Prop.Raw, *raw)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resp.Propstats = append(resp.Propstats, Propstat{
|
2020-01-15 18:23:09 +00:00
|
|
|
Status: Status{Code: code},
|
2020-01-15 17:21:27 +00:00
|
|
|
Prop: Prop{Raw: []RawXMLValue{*raw}},
|
|
|
|
})
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-01-14 20:29:54 +00:00
|
|
|
// https://tools.ietf.org/html/rfc4918#section-14.9
|
|
|
|
type Location struct {
|
|
|
|
XMLName xml.Name `xml:"DAV: location"`
|
2020-01-22 10:07:30 +00:00
|
|
|
Href Href `xml:"href"`
|
2020-01-14 17:51:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// https://tools.ietf.org/html/rfc4918#section-14.22
|
|
|
|
type Propstat struct {
|
2020-01-17 13:47:10 +00:00
|
|
|
XMLName xml.Name `xml:"DAV: propstat"`
|
|
|
|
Prop Prop `xml:"prop"`
|
|
|
|
Status Status `xml:"status"`
|
|
|
|
ResponseDescription string `xml:"responsedescription,omitempty"`
|
|
|
|
Error *Error `xml:"error,omitempty"`
|
2020-01-14 20:29:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// https://tools.ietf.org/html/rfc4918#section-14.18
|
|
|
|
type Prop struct {
|
|
|
|
XMLName xml.Name `xml:"DAV: prop"`
|
|
|
|
Raw []RawXMLValue `xml:",any"`
|
2020-01-14 17:51:17 +00:00
|
|
|
}
|
2020-01-14 19:00:54 +00:00
|
|
|
|
2020-01-15 10:17:38 +00:00
|
|
|
func EncodeProp(values ...interface{}) (*Prop, error) {
|
|
|
|
l := make([]RawXMLValue, len(values))
|
|
|
|
for i, v := range values {
|
|
|
|
raw, err := EncodeRawXMLElement(v)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
l[i] = *raw
|
|
|
|
}
|
|
|
|
return &Prop{Raw: l}, nil
|
|
|
|
}
|
|
|
|
|
2020-01-19 11:01:55 +00:00
|
|
|
func (p *Prop) Get(name xml.Name) *RawXMLValue {
|
|
|
|
for i := range p.Raw {
|
|
|
|
raw := &p.Raw[i]
|
|
|
|
if n, ok := raw.XMLName(); ok && name == n {
|
|
|
|
return raw
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Prop) Decode(v interface{}) error {
|
|
|
|
name, err := valueXMLName(v)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
raw := p.Get(name)
|
|
|
|
if raw == nil {
|
2020-03-28 22:51:45 +00:00
|
|
|
return HTTPErrorf(http.StatusNotFound, "missing property %s", name)
|
2020-01-19 11:01:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return raw.Decode(v)
|
|
|
|
}
|
|
|
|
|
2020-01-14 19:00:54 +00:00
|
|
|
// https://tools.ietf.org/html/rfc4918#section-14.20
|
|
|
|
type Propfind struct {
|
2020-01-15 22:03:09 +00:00
|
|
|
XMLName xml.Name `xml:"DAV: propfind"`
|
|
|
|
Prop *Prop `xml:"prop,omitempty"`
|
|
|
|
AllProp *struct{} `xml:"allprop,omitempty"`
|
|
|
|
Include *Include `xml:"include,omitempty"`
|
|
|
|
PropName *struct{} `xml:"propname,omitempty"`
|
2020-01-14 19:00:54 +00:00
|
|
|
}
|
|
|
|
|
2020-01-15 17:21:27 +00:00
|
|
|
func xmlNamesToRaw(names []xml.Name) []RawXMLValue {
|
|
|
|
l := make([]RawXMLValue, len(names))
|
2020-01-14 19:00:54 +00:00
|
|
|
for i, name := range names {
|
2020-01-15 17:21:27 +00:00
|
|
|
l[i] = *NewRawXMLElement(name, nil, nil)
|
2020-01-14 19:00:54 +00:00
|
|
|
}
|
2020-01-15 17:21:27 +00:00
|
|
|
return l
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewPropNamePropfind(names ...xml.Name) *Propfind {
|
|
|
|
return &Propfind{Prop: &Prop{Raw: xmlNamesToRaw(names)}}
|
2020-01-14 19:00:54 +00:00
|
|
|
}
|
2020-01-14 22:13:23 +00:00
|
|
|
|
2020-01-15 22:03:09 +00:00
|
|
|
// https://tools.ietf.org/html/rfc4918#section-14.8
|
|
|
|
type Include struct {
|
|
|
|
XMLName xml.Name `xml:"DAV: include"`
|
|
|
|
Raw []RawXMLValue `xml:",any"`
|
|
|
|
}
|
|
|
|
|
2020-01-14 22:13:23 +00:00
|
|
|
// https://tools.ietf.org/html/rfc4918#section-15.9
|
|
|
|
type ResourceType struct {
|
|
|
|
XMLName xml.Name `xml:"DAV: resourcetype"`
|
|
|
|
Raw []RawXMLValue `xml:",any"`
|
|
|
|
}
|
|
|
|
|
2020-01-15 17:21:27 +00:00
|
|
|
func NewResourceType(names ...xml.Name) *ResourceType {
|
|
|
|
return &ResourceType{Raw: xmlNamesToRaw(names)}
|
|
|
|
}
|
|
|
|
|
2020-01-14 22:13:23 +00:00
|
|
|
func (t *ResourceType) Is(name xml.Name) bool {
|
|
|
|
for _, raw := range t.Raw {
|
2020-01-17 13:40:29 +00:00
|
|
|
if n, ok := raw.XMLName(); ok && name == n {
|
2020-01-14 22:13:23 +00:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
var CollectionName = xml.Name{"DAV:", "collection"}
|
2020-01-15 18:08:38 +00:00
|
|
|
|
|
|
|
// https://tools.ietf.org/html/rfc4918#section-15.4
|
|
|
|
type GetContentLength struct {
|
|
|
|
XMLName xml.Name `xml:"DAV: getcontentlength"`
|
|
|
|
Length int64 `xml:",chardata"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// https://tools.ietf.org/html/rfc4918#section-15.5
|
|
|
|
type GetContentType struct {
|
|
|
|
XMLName xml.Name `xml:"DAV: getcontenttype"`
|
|
|
|
Type string `xml:",chardata"`
|
|
|
|
}
|
|
|
|
|
2020-01-15 18:32:59 +00:00
|
|
|
type Time time.Time
|
2020-01-15 18:08:38 +00:00
|
|
|
|
2020-01-15 18:32:59 +00:00
|
|
|
func (t *Time) UnmarshalText(b []byte) error {
|
|
|
|
tt, err := http.ParseTime(string(b))
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
*t = Time(tt)
|
|
|
|
return nil
|
2020-01-15 18:08:38 +00:00
|
|
|
}
|
|
|
|
|
2020-01-15 18:32:59 +00:00
|
|
|
func (t *Time) MarshalText() ([]byte, error) {
|
2021-03-16 17:42:55 +00:00
|
|
|
s := time.Time(*t).UTC().Format(http.TimeFormat)
|
2020-01-15 18:32:59 +00:00
|
|
|
return []byte(s), nil
|
2020-01-15 18:08:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// https://tools.ietf.org/html/rfc4918#section-15.7
|
|
|
|
type GetLastModified struct {
|
|
|
|
XMLName xml.Name `xml:"DAV: getlastmodified"`
|
2020-01-15 18:32:59 +00:00
|
|
|
LastModified Time `xml:",chardata"`
|
2020-01-15 18:08:38 +00:00
|
|
|
}
|
2020-01-17 13:47:10 +00:00
|
|
|
|
2020-01-22 10:51:05 +00:00
|
|
|
// https://tools.ietf.org/html/rfc4918#section-15.6
|
|
|
|
type GetETag struct {
|
|
|
|
XMLName xml.Name `xml:"DAV: getetag"`
|
2020-02-03 20:48:31 +00:00
|
|
|
ETag ETag `xml:",chardata"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type ETag string
|
|
|
|
|
|
|
|
func (etag *ETag) UnmarshalText(b []byte) error {
|
|
|
|
s, err := strconv.Unquote(string(b))
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("webdav: failed to unquote ETag: %v", err)
|
|
|
|
}
|
|
|
|
*etag = ETag(s)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-02-03 20:52:15 +00:00
|
|
|
func (etag ETag) MarshalText() ([]byte, error) {
|
|
|
|
return []byte(etag.String()), nil
|
2020-02-03 20:48:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (etag ETag) String() string {
|
2020-02-03 20:52:15 +00:00
|
|
|
return fmt.Sprintf("%q", string(etag))
|
2020-01-22 10:51:05 +00:00
|
|
|
}
|
|
|
|
|
2020-01-17 13:47:10 +00:00
|
|
|
// https://tools.ietf.org/html/rfc4918#section-14.5
|
|
|
|
type Error struct {
|
|
|
|
XMLName xml.Name `xml:"DAV: error"`
|
|
|
|
Raw []RawXMLValue `xml:",any"`
|
|
|
|
}
|
2020-01-19 13:53:58 +00:00
|
|
|
|
2020-05-13 14:02:52 +01:00
|
|
|
func (err *Error) Error() string {
|
|
|
|
b, _ := xml.Marshal(err)
|
|
|
|
return string(b)
|
|
|
|
}
|
|
|
|
|
2020-01-19 13:53:58 +00:00
|
|
|
// https://tools.ietf.org/html/rfc4918#section-15.2
|
|
|
|
type DisplayName struct {
|
|
|
|
XMLName xml.Name `xml:"DAV: displayname"`
|
|
|
|
Name string `xml:",chardata"`
|
|
|
|
}
|
2020-01-20 09:56:25 +00:00
|
|
|
|
|
|
|
// https://tools.ietf.org/html/rfc5397#section-3
|
|
|
|
type CurrentUserPrincipal struct {
|
|
|
|
XMLName xml.Name `xml:"DAV: current-user-principal"`
|
2020-01-22 10:07:30 +00:00
|
|
|
Href Href `xml:"href,omitempty"`
|
2020-01-20 09:56:25 +00:00
|
|
|
Unauthenticated *struct{} `xml:"unauthenticated,omitempty"`
|
|
|
|
}
|
2020-01-21 22:18:27 +00:00
|
|
|
|
|
|
|
// https://tools.ietf.org/html/rfc4918#section-14.19
|
|
|
|
type Propertyupdate struct {
|
|
|
|
XMLName xml.Name `xml:"DAV: propertyupdate"`
|
|
|
|
Remove []Remove `xml:"remove"`
|
|
|
|
Set []Set `xml:"set"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// https://tools.ietf.org/html/rfc4918#section-14.23
|
|
|
|
type Remove struct {
|
|
|
|
XMLName xml.Name `xml:"DAV: remove"`
|
|
|
|
Prop Prop `xml:"prop"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// https://tools.ietf.org/html/rfc4918#section-14.26
|
|
|
|
type Set struct {
|
|
|
|
XMLName xml.Name `xml:"DAV: set"`
|
|
|
|
Prop Prop `xml:"prop"`
|
|
|
|
}
|
2020-03-29 13:08:48 +01:00
|
|
|
|
|
|
|
// https://tools.ietf.org/html/rfc6578#section-6.1
|
|
|
|
type SyncCollectionQuery struct {
|
|
|
|
XMLName xml.Name `xml:"DAV: sync-collection"`
|
|
|
|
SyncToken string `xml:"sync-token"`
|
|
|
|
Limit *Limit `xml:"limit,omitempty"`
|
|
|
|
SyncLevel string `xml:"sync-level"`
|
|
|
|
Prop *Prop `xml:"prop"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// https://tools.ietf.org/html/rfc5323#section-5.17
|
|
|
|
type Limit struct {
|
|
|
|
XMLName xml.Name `xml:"DAV: limit"`
|
|
|
|
NResults uint `xml:"nresults"`
|
|
|
|
}
|