webdav: add basic Client.Open

This commit is contained in:
Simon Ser
2020-01-21 18:47:29 +01:00
parent e84362bc0a
commit 8e50764757

View File

@@ -2,6 +2,7 @@ package webdav
import ( import (
"fmt" "fmt"
"io"
"net/http" "net/http"
"os" "os"
"path" "path"
@@ -114,3 +115,17 @@ func (c *Client) Stat(name string) (os.FileInfo, error) {
return fi, nil 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
}