mirror of
https://github.com/1f349/go-webdav.git
synced 2024-12-22 08:14:15 +00:00
Make Response.Path return the path on error
This commit is contained in:
parent
373663f9ee
commit
ed52608852
@ -135,13 +135,14 @@ func NewOKResponse(path string) *Response {
|
||||
}
|
||||
|
||||
func (resp *Response) Path() (string, error) {
|
||||
if err := resp.Status.Err(); err != nil {
|
||||
return "", err
|
||||
err := resp.Status.Err()
|
||||
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))
|
||||
}
|
||||
if len(resp.Hrefs) != 1 {
|
||||
return "", fmt.Errorf("webdav: malformed response: expected exactly one href element, got %v", len(resp.Hrefs))
|
||||
}
|
||||
return resp.Hrefs[0].Path, nil
|
||||
return path, err
|
||||
}
|
||||
|
||||
func (resp *Response) DecodeProp(values ...interface{}) error {
|
||||
|
Loading…
Reference in New Issue
Block a user