caldav: 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-23 21:34:02 +02:00 committed by Simon Ser
parent 491af8e42c
commit 757a615e9f

View File

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