Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions carddav/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func (b *backend) HeadGet(w http.ResponseWriter, r *http.Request) error {
w.Header().Set("Content-Length", strconv.FormatInt(ao.ContentLength, 10))
}
if ao.ETag != "" {
w.Header().Set("ETag", internal.ETag(ao.ETag).String())
w.Header().Set("ETag", ao.ETag)
}
if !ao.ModTime.IsZero() {
w.Header().Set("Last-Modified", ao.ModTime.UTC().Format(http.TimeFormat))
Expand Down Expand Up @@ -458,7 +458,7 @@ func (b *backend) propFindAddressObject(ctx context.Context, propfind *internal.

if ao.ETag != "" {
props[internal.GetETagName] = func(*internal.RawXMLValue) (interface{}, error) {
return &internal.GetETag{ETag: internal.ETag(ao.ETag)}, nil
return &internal.GetETag{ETag: ao.ETag}, nil
}
}

Expand Down
21 changes: 1 addition & 20 deletions internal/elements.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,26 +368,7 @@ type GetLastModified struct {
// https://tools.ietf.org/html/rfc4918#section-15.6
type GetETag struct {
XMLName xml.Name `xml:"DAV: getetag"`
ETag ETag `xml:",chardata"`
}

type ETag string

func (etag *ETag) UnmarshalText(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return fmt.Errorf("webdav: failed to unquote ETag: %v", err)
}
*etag = ETag(s)
return nil
}

func (etag ETag) MarshalText() ([]byte, error) {
return []byte(etag.String()), nil
}

func (etag ETag) String() string {
return fmt.Sprintf("%q", string(etag))
ETag string `xml:",chardata"`
}

// https://tools.ietf.org/html/rfc4918#section-14.5
Expand Down
4 changes: 2 additions & 2 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (b *backend) HeadGet(w http.ResponseWriter, r *http.Request) error {
w.Header().Set("Last-Modified", fi.ModTime.UTC().Format(http.TimeFormat))
}
if fi.ETag != "" {
w.Header().Set("ETag", internal.ETag(fi.ETag).String())
w.Header().Set("ETag", fi.ETag)
}

if rs, ok := f.(io.ReadSeeker); ok {
Expand Down Expand Up @@ -184,7 +184,7 @@ func (b *backend) propFindFile(propfind *internal.PropFind, fi *FileInfo) (*inte

if fi.ETag != "" {
props[internal.GetETagName] = func(*internal.RawXMLValue) (interface{}, error) {
return &internal.GetETag{ETag: internal.ETag(fi.ETag)}, nil
return &internal.GetETag{ETag: fi.ETag}, nil
}
}
}
Expand Down