Documentation
¶
Overview ¶
Package internal provides low-level helpers for WebDAV clients and servers.
Index ¶
- Constants
- Variables
- func DecodeXMLRequest(r *http.Request, v interface{}) error
- func FormatLockToken(token string) string
- func FormatOverwrite(overwrite bool) string
- func IsNotFound(err error) bool
- func IsRequestBodyEmpty(r *http.Request) bool
- func ParseConditions(s string) ([][]Condition, error)
- func ParseLockToken(s string) (string, error)
- func ParseOverwrite(s string) (bool, error)
- func ServeError(w http.ResponseWriter, err error)
- func ServeMultiStatus(w http.ResponseWriter, ms *MultiStatus) error
- func ServeXML(w http.ResponseWriter) *xml.Encoder
- type ActiveLock
- type Backend
- type Client
- func (c *Client) Do(req *http.Request) (*http.Response, error)
- func (c *Client) DoMultiStatus(req *http.Request) (*MultiStatus, error)
- func (c *Client) NewRequest(method string, path string, body io.Reader) (*http.Request, error)
- func (c *Client) NewXMLRequest(method string, path string, v interface{}) (*http.Request, error)
- func (c *Client) Options(ctx context.Context, path string) (classes map[string]bool, methods map[string]bool, err error)
- func (c *Client) PropFind(ctx context.Context, path string, depth Depth, propfind *PropFind) (*MultiStatus, error)
- func (c *Client) PropFindFlat(ctx context.Context, path string, propfind *PropFind) (*Response, error)
- func (c *Client) ResolveHref(p string) *url.URL
- func (c *Client) SyncCollection(ctx context.Context, path, syncToken string, level Depth, limit *Limit, ...) (*MultiStatus, error)
- type Condition
- type CurrentUserPrincipal
- type Depth
- type DisplayName
- type ETag
- type Error
- type GetContentLength
- type GetContentType
- type GetETag
- type GetLastModified
- type HTTPClient
- type HTTPError
- type Handler
- type Href
- type Include
- type Limit
- type Location
- type Lock
- type LockDiscovery
- type LockEntry
- type LockInfo
- type LockRoot
- type LockScope
- type LockToken
- type LockType
- type MultiStatus
- type Owner
- type Prop
- type PropFind
- type PropFindFunc
- type PropStat
- type PropertyUpdate
- type RawXMLValue
- func (val *RawXMLValue) Decode(v interface{}) error
- func (val *RawXMLValue) GetTextContent() string
- func (val *RawXMLValue) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (val *RawXMLValue) TokenReader() xml.TokenReader
- func (val *RawXMLValue) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- func (val *RawXMLValue) XMLName() (name xml.Name, ok bool)
- type Remove
- type ResourceType
- type Response
- type Set
- type Status
- type SupportedLock
- type SyncCollectionQuery
- type Time
- type Timeout
Constants ¶
const Namespace = "DAV:"
Variables ¶
var ( ResourceTypeName = xml.Name{Namespace, "resourcetype"} DisplayNameName = xml.Name{Namespace, "displayname"} GetContentLengthName = xml.Name{Namespace, "getcontentlength"} GetContentTypeName = xml.Name{Namespace, "getcontenttype"} GetLastModifiedName = xml.Name{Namespace, "getlastmodified"} GetETagName = xml.Name{Namespace, "getetag"} SupportedLockName = xml.Name{Namespace, "supportedlock"} LockDiscoveryName = xml.Name{Namespace, "lockdiscovery"} CurrentUserPrincipalName = xml.Name{Namespace, "current-user-principal"} )
var CollectionName = xml.Name{Namespace, "collection"}
Functions ¶
func DecodeXMLRequest ¶
func FormatLockToken ¶
func FormatOverwrite ¶
FormatOverwrite formats an Overwrite header.
func IsNotFound ¶
func IsRequestBodyEmpty ¶
func ParseConditions ¶
func ParseLockToken ¶
func ParseOverwrite ¶
ParseOverwrite parses an Overwrite header.
func ServeError ¶
func ServeError(w http.ResponseWriter, err error)
func ServeMultiStatus ¶
func ServeMultiStatus(w http.ResponseWriter, ms *MultiStatus) error
Types ¶
type ActiveLock ¶
type ActiveLock struct {
XMLName xml.Name `xml:"DAV: activelock"`
LockScope LockScope `xml:"lockscope"`
LockType LockType `xml:"locktype"`
Depth Depth `xml:"depth"`
Owner *Owner `xml:"owner,omitempty"`
Timeout *Timeout `xml:"timeout,omitempty"`
LockToken *LockToken `xml:"locktoken,omitempty"`
LockRoot LockRoot `xml:"lockroot"`
}
type Backend ¶
type Backend interface {
Options(r *http.Request) (caps []string, allow []string, err error)
HeadGet(w http.ResponseWriter, r *http.Request) error
PropFind(r *http.Request, pf *PropFind, depth Depth) (*MultiStatus, error)
PropPatch(r *http.Request, pu *PropertyUpdate) (*Response, error)
Put(w http.ResponseWriter, r *http.Request) error
Delete(r *http.Request) error
Mkcol(r *http.Request) error
Copy(r *http.Request, dest *Href, recursive, overwrite bool) (created bool, err error)
Move(r *http.Request, dest *Href, overwrite bool) (created bool, err error)
Lock(r *http.Request, depth Depth, timeout time.Duration, refreshToken string) (lock *Lock, created bool, err error)
Unlock(r *http.Request, tokenHref string) error
}
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) DoMultiStatus ¶
func (c *Client) DoMultiStatus(req *http.Request) (*MultiStatus, error)
func (*Client) NewRequest ¶
func (*Client) NewXMLRequest ¶
type Condition ¶
Condition is a condition to match lock tokens and entity tags.
Only one of Token or ETag is set.
type CurrentUserPrincipal ¶
type Depth ¶
type Depth int
Depth indicates whether a request applies to the resource's members. It's defined in RFC 4918 section 10.2.
const ( // DepthZero indicates that the request applies only to the resource. DepthZero Depth = 0 // DepthOne indicates that the request applies to the resource and its // internal members only. DepthOne Depth = 1 // DepthInfinity indicates that the request applies to the resource and all // of its members. DepthInfinity Depth = -1 )
type DisplayName ¶
type Error ¶
type Error struct {
XMLName xml.Name `xml:"DAV: error"`
Raw []RawXMLValue `xml:",any"`
}
type GetContentLength ¶
type GetContentType ¶
type GetLastModified ¶
type HTTPClient ¶
HTTPClient performs HTTP requests. It's implemented by *http.Client.
type Include ¶
type Include struct {
XMLName xml.Name `xml:"DAV: include"`
Raw []RawXMLValue `xml:",any"`
}
type LockDiscovery ¶
type LockDiscovery struct {
XMLName xml.Name `xml:"DAV: lockdiscovery"`
ActiveLock []ActiveLock `xml:"activelock,omitempty"`
}
type LockEntry ¶
type LockInfo ¶
type LockScope ¶
type MultiStatus ¶
type MultiStatus struct {
XMLName xml.Name `xml:"DAV: multistatus"`
Responses []Response `xml:"response"`
ResponseDescription string `xml:"responsedescription,omitempty"`
SyncToken string `xml:"sync-token,omitempty"`
}
https://tools.ietf.org/html/rfc4918#section-14.16
func NewMultiStatus ¶
func NewMultiStatus(resps ...Response) *MultiStatus
type Prop ¶
type Prop struct {
XMLName xml.Name `xml:"DAV: prop"`
Raw []RawXMLValue `xml:",any"`
}
https://tools.ietf.org/html/rfc4918#section-14.18
func EncodeProp ¶
type PropFind ¶
type PropFind struct {
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"`
}
https://tools.ietf.org/html/rfc4918#section-14.20
func NewPropNamePropFind ¶
type PropFindFunc ¶
type PropFindFunc func(raw *RawXMLValue) (interface{}, error)
func PropFindValue ¶
func PropFindValue(value interface{}) PropFindFunc
type PropStat ¶
type PropertyUpdate ¶
type RawXMLValue ¶
type RawXMLValue struct {
// contains filtered or unexported fields
}
RawXMLValue is a raw XML value. It implements xml.Unmarshaler and xml.Marshaler and can be used to delay XML decoding or precompute an XML encoding.
func EncodeRawXMLElement ¶
func EncodeRawXMLElement(v interface{}) (*RawXMLValue, error)
EncodeRawXMLElement encodes a value into a new RawXMLValue. The XML value can only be used for marshalling.
func NewRawXMLElement ¶
func NewRawXMLElement(name xml.Name, attr []xml.Attr, children []RawXMLValue) *RawXMLValue
NewRawXMLElement creates a new RawXMLValue for an element.
func (*RawXMLValue) Decode ¶
func (val *RawXMLValue) Decode(v interface{}) error
func (*RawXMLValue) GetTextContent ¶ added in v1.0.1
func (val *RawXMLValue) GetTextContent() string
GetTextContent extracts the text content from the RawXMLValue's children.
func (*RawXMLValue) MarshalXML ¶
func (val *RawXMLValue) MarshalXML(e *xml.Encoder, start xml.StartElement) error
MarshalXML implements xml.Marshaler.
func (*RawXMLValue) TokenReader ¶
func (val *RawXMLValue) TokenReader() xml.TokenReader
TokenReader returns a stream of tokens for the XML value.
func (*RawXMLValue) UnmarshalXML ¶
func (val *RawXMLValue) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
UnmarshalXML implements xml.Unmarshaler.
type ResourceType ¶
type ResourceType struct {
XMLName xml.Name `xml:"DAV: resourcetype"`
Raw []RawXMLValue `xml:",any"`
}
https://tools.ietf.org/html/rfc4918#section-15.9
func NewResourceType ¶
func NewResourceType(names ...xml.Name) *ResourceType
type Response ¶
type Response struct {
XMLName xml.Name `xml:"DAV: response"`
Hrefs []Href `xml:"href"`
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"`
}
https://tools.ietf.org/html/rfc4918#section-14.24