carddav/server: set ETag and Last-Modified if available

Some clients (e.g. Evolution) will not work properly without this. It is
up to the underlying backend to actually provide this data, the headers
will only be set if it is available.
This commit is contained in:
Conrad Hoffmann authored and GitHub committed 2022-02-24 12:41:56 +01:00
1 parent 0f6744ede8
commit dc57b81662
1 file changed
+6 -1
+6 -1
View File
@@ -262,7 +262,12 @@ func (b *backend) HeadGet(w http.ResponseWriter, r *http.Request) error {
}
w.Header().Set("Content-Type", vcard.MIMEType)
// TODO: set ETag, Last-Modified
if ao.ETag != "" {
w.Header().Set("ETag", internal.ETag(ao.ETag).String())
}
if !ao.ModTime.IsZero() {
w.Header().Set("Last-Modified", ao.ModTime.UTC().Format(http.TimeFormat))
}
if r.Method != http.MethodHead {
return vcard.NewEncoder(w).Encode(ao.Card)