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 2022-02-24 12:41:56 +01:00 committed by GitHub
parent 0f6744ede8
commit dc57b81662
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -262,7 +262,12 @@ func (b *backend) HeadGet(w http.ResponseWriter, r *http.Request) error {
} }
w.Header().Set("Content-Type", vcard.MIMEType) 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 { if r.Method != http.MethodHead {
return vcard.NewEncoder(w).Encode(ao.Card) return vcard.NewEncoder(w).Encode(ao.Card)