webdav: add basic Client.Open

This commit is contained in:
Simon Ser 2020-01-21 18:47:29 +01:00
parent e84362bc0a
commit 8e50764757
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

View File

@ -2,6 +2,7 @@ package webdav
import (
"fmt"
"io"
"net/http"
"os"
"path"
@ -114,3 +115,17 @@ func (c *Client) Stat(name string) (os.FileInfo, error) {
return fi, nil
}
func (c *Client) Open(name string) (io.ReadCloser, error) {
req, err := c.ic.NewRequest(http.MethodGet, name, nil)
if err != nil {
return nil, err
}
resp, err := c.ic.Do(req)
if err != nil {
return nil, err
}
return resp.Body, nil
}