internal: drop Multistatus.Get

This is now unused.
This commit is contained in:
Simon Ser 2022-05-31 16:11:08 +02:00
parent 03633121d9
commit 9bc7a8f15b
2 changed files with 8 additions and 18 deletions

View File

@ -6,7 +6,6 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"net/url" "net/url"
"path"
"strconv" "strconv"
"strings" "strings"
"time" "time"
@ -101,21 +100,6 @@ func NewMultistatus(resps ...Response) *Multistatus {
return &Multistatus{Responses: resps} return &Multistatus{Responses: resps}
} }
func (ms *Multistatus) Get(p string) (*Response, error) {
// Clean the path to avoid issues with trailing slashes
p = path.Clean(p)
for i := range ms.Responses {
resp := &ms.Responses[i]
for _, h := range resp.Hrefs {
if path.Clean(h.Path) == p {
return resp, resp.Err()
}
}
}
return nil, fmt.Errorf("webdav: missing response for path %q", p)
}
// https://tools.ietf.org/html/rfc4918#section-14.24 // https://tools.ietf.org/html/rfc4918#section-14.24
type Response struct { type Response struct {
XMLName xml.Name `xml:"DAV: response"` XMLName xml.Name `xml:"DAV: response"`

View File

@ -18,14 +18,20 @@ const exampleDeleteMultistatusStr = `<?xml version="1.0" encoding="utf-8" ?>
</d:response> </d:response>
</d:multistatus>` </d:multistatus>`
func TestMultistatus_Get_error(t *testing.T) { func TestResponse_Err_error(t *testing.T) {
r := strings.NewReader(exampleDeleteMultistatusStr) r := strings.NewReader(exampleDeleteMultistatusStr)
var ms Multistatus var ms Multistatus
if err := xml.NewDecoder(r).Decode(&ms); err != nil { if err := xml.NewDecoder(r).Decode(&ms); err != nil {
t.Fatalf("Decode() = %v", err) t.Fatalf("Decode() = %v", err)
} }
_, err := ms.Get("/container/resource3") if len(ms.Responses) != 1 {
t.Fatalf("expected 1 <response>, got %v", len(ms.Responses))
}
resp := ms.Responses[0]
err := resp.Err()
if err == nil { if err == nil {
t.Errorf("Multistatus.Get() returned a nil error, expected non-nil") t.Errorf("Multistatus.Get() returned a nil error, expected non-nil")
} else if httpErr, ok := err.(*HTTPError); !ok { } else if httpErr, ok := err.(*HTTPError); !ok {