core: set cache-control max-age as integer, not float (#6764)

As specified in rfc2616, the max-age is an integer.
Setting a float might make the header get ignored in some cases.
This commit is contained in:
Johnny Bergström 2024-10-24 21:20:19 +02:00 committed by GitHub
parent 2d1ce165a5
commit 909ce9386d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -188,7 +188,7 @@ func (s *ServerHTTPS) ServeHTTP(w http.ResponseWriter, r *http.Request) {
age := dnsutil.MinimalTTL(dw.Msg, mt)
w.Header().Set("Content-Type", doh.MimeType)
w.Header().Set("Cache-Control", fmt.Sprintf("max-age=%f", age.Seconds()))
w.Header().Set("Cache-Control", fmt.Sprintf("max-age=%d", uint32(age.Seconds())))
w.Header().Set("Content-Length", strconv.Itoa(len(buf)))
w.WriteHeader(http.StatusOK)
s.countResponse(http.StatusOK)