From dc57b81662609b4ef4e86c257522c62d5793dff9 Mon Sep 17 00:00:00 2001 From: Conrad Hoffmann <1226676+bitfehler@users.noreply.github.com> Date: Thu, 24 Feb 2022 12:41:56 +0100 Subject: [PATCH] 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. --- carddav/server.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/carddav/server.go b/carddav/server.go index 5838d7c..d4cf876 100644 --- a/carddav/server.go +++ b/carddav/server.go @@ -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)