internal: add ETag

This commit is contained in:
Simon Ser
2020-02-03 21:48:31 +01:00
parent ca51e9427a
commit 25678476db
6 changed files with 26 additions and 23 deletions

View File

@@ -6,7 +6,6 @@ import (
"net"
"net/http"
"net/url"
"strconv"
"strings"
"time"
@@ -222,10 +221,6 @@ func decodeAddressList(ms *internal.Multistatus) ([]AddressObject, error) {
if err := resp.DecodeProp(&getETag); err != nil && !internal.IsNotFound(err) {
return nil, err
}
etag, err := strconv.Unquote(getETag.ETag)
if err != nil {
return nil, fmt.Errorf("carddav: failed to unquote ETag: %v", err)
}
r := bytes.NewReader(addrData.Data)
card, err := vcard.NewDecoder(r).Decode()
@@ -236,7 +231,7 @@ func decodeAddressList(ms *internal.Multistatus) ([]AddressObject, error) {
addrs = append(addrs, AddressObject{
Path: path,
ModTime: time.Time(getLastMod.LastModified),
ETag: etag,
ETag: string(getETag.ETag),
Card: card,
})
}

View File

@@ -372,7 +372,7 @@ func (b *backend) propfindAddressObject(propfind *internal.Propfind, ao *Address
if ao.ETag != "" {
props[internal.GetETagName] = func(*internal.RawXMLValue) (interface{}, error) {
return &internal.GetETag{ETag: fmt.Sprintf("%q", ao.ETag)}, nil
return &internal.GetETag{ETag: internal.ETag(ao.ETag)}, nil
}
}