Documentation ¶
Overview ¶
Package gowebdav is a WebDAV client library with a command line tool included.
Index ¶
- func FixSlash(s string) string
- func FixSlashes(s string) string
- func IsErrCode(err error, code int) bool
- func IsErrNotFound(err error) bool
- func Join(path0 string, path1 string) string
- func PathEscape(path string) string
- func ReadConfig(uri, netrc string) (string, string)
- func String(r io.Reader) string
- type Authenticator
- type BasicAuth
- type Client
- func (c *Client) Connect() error
- func (c *Client) Copy(oldpath, newpath string, overwrite bool) error
- func (c *Client) Link(path string) (string, http.Header, error)
- func (c *Client) Mkdir(path string, _ os.FileMode) (err error)
- func (c *Client) MkdirAll(path string, _ os.FileMode) (err error)
- func (c *Client) Read(path string) ([]byte, error)
- func (c *Client) ReadDir(path string) ([]os.FileInfo, error)
- func (c *Client) ReadStream(path string, callback func(rq *http.Request)) (io.ReadCloser, http.Header, error)
- func (c *Client) ReadStreamRange(path string, offset, length int64) (io.ReadCloser, error)
- func (c *Client) Remove(path string) error
- func (c *Client) RemoveAll(path string) error
- func (c *Client) Rename(oldpath, newpath string, overwrite bool) error
- func (c *Client) SetHeader(key, value string)
- func (c *Client) SetInterceptor(interceptor func(method string, rq *http.Request))
- func (c *Client) SetJar(jar http.CookieJar)
- func (c *Client) SetTimeout(timeout time.Duration)
- func (c *Client) SetTransport(transport http.RoundTripper)
- func (c *Client) Stat(path string) (os.FileInfo, error)
- func (c *Client) Write(path string, data []byte, _ os.FileMode) (err error)
- func (c *Client) WriteStream(path string, stream io.Reader, _ os.FileMode, callback func(r *http.Request)) (err error)
- type DigestAuth
- type File
- func (f File) ContentType() string
- func (f File) ETag() string
- func (f File) IsDir() bool
- func (f File) ModTime() time.Time
- func (f File) Mode() os.FileMode
- func (f File) Name() string
- func (f File) Path() string
- func (f File) Size() int64
- func (f File) String() string
- func (f File) Sys() interface{}
- type NoAuth
- type StatusError
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FixSlashes ¶
FixSlashes appends and prepends a / if they are missing
func IsErrCode ¶
IsErrCode returns true if the given error is an os.PathError wrapping a StatusError with the given status code.
func IsErrNotFound ¶
IsErrNotFound is shorthand for IsErrCode for status 404.
func PathEscape ¶
PathEscape escapes all segments of a given path
Example ¶
fmt.Println(PathEscape("")) fmt.Println(PathEscape("/")) fmt.Println(PathEscape("/web")) fmt.Println(PathEscape("/web/")) fmt.Println(PathEscape("/w e b/d a v/s%u&c#k:s/"))
Output: / /web /web/ /w%20e%20b/d%20a%20v/s%25u&c%23k:s/
func ReadConfig ¶
ReadConfig reads login and password configuration from ~/.netrc machine foo.com login username password 123456
Types ¶
type Authenticator ¶
type Authenticator interface { Type() string User() string Pass() string Authorize(*http.Request, string, string) }
Authenticator stub
type BasicAuth ¶
type BasicAuth struct {
// contains filtered or unexported fields
}
BasicAuth structure holds our credentials
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client defines our structure
func (*Client) ReadStream ¶
func (c *Client) ReadStream(path string, callback func(rq *http.Request)) (io.ReadCloser, http.Header, error)
ReadStream reads the stream for a given path
func (*Client) ReadStreamRange ¶
ReadStreamRange reads the stream representing a subset of bytes for a given path, utilizing HTTP Range Requests if the server supports it. The range is expressed as offset from the start of the file and length, for example offset=10, length=10 will return bytes 10 through 19.
If the server does not support partial content requests and returns full content instead, this function will emulate the behavior by skipping `offset` bytes and limiting the result to `length`.
func (*Client) SetInterceptor ¶
SetInterceptor lets us set an arbitrary interceptor for a given client
func (*Client) SetTimeout ¶
SetTimeout exposes the ability to set a time limit for requests
func (*Client) SetTransport ¶
func (c *Client) SetTransport(transport http.RoundTripper)
SetTransport exposes the ability to define custom transports
type DigestAuth ¶
type DigestAuth struct {
// contains filtered or unexported fields
}
DigestAuth structure holds our credentials
func (*DigestAuth) Authorize ¶
func (d *DigestAuth) Authorize(req *http.Request, method string, path string)
Authorize the current request
func (*DigestAuth) Type ¶
func (d *DigestAuth) Type() string
Type identifies the DigestAuthenticator
type File ¶
type File struct {
// contains filtered or unexported fields
}
File is our structure for a given file
func (File) ContentType ¶
ContentType returns the content type of a file
type NoAuth ¶
type NoAuth struct {
// contains filtered or unexported fields
}
NoAuth structure holds our credentials
type StatusError ¶
type StatusError struct {
Status int
}
StatusError implements error and wraps an erroneous status code.
func (StatusError) Error ¶
func (se StatusError) Error() string