carddav: set content length header for HEAD/GET requests

Now that the backend can supply this value, use it for explicitly
setting the header in GET/HEAD responses if available.
This commit is contained in:
Conrad Hoffmann 2022-05-24 10:57:37 +02:00 committed by Simon Ser
parent a3e56141d9
commit 1e99b70a62

View File

@ -7,6 +7,7 @@ import (
"fmt"
"mime"
"net/http"
"strconv"
"github.com/emersion/go-vcard"
"github.com/emersion/go-webdav"
@ -289,6 +290,9 @@ func (b *backend) HeadGet(w http.ResponseWriter, r *http.Request) error {
}
w.Header().Set("Content-Type", vcard.MIMEType)
if ao.ContentLength > 0 {
w.Header().Set("Content-Length", strconv.FormatInt(ao.ContentLength, 10))
}
if ao.ETag != "" {
w.Header().Set("ETag", internal.ETag(ao.ETag).String())
}