Skip to content

Commit

Permalink
set headers before writing them (#800)
Browse files Browse the repository at this point in the history
  • Loading branch information
willscott committed Apr 14, 2021
1 parent 7c58f95 commit ec4f8f9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ func (h *handler) PublicRand(w http.ResponseWriter, r *http.Request) {

if roundExpectedTime.After(time.Now().Add(info.Period)) {
timeToExpected := int(time.Until(roundExpectedTime).Seconds())
w.WriteHeader(http.StatusNotFound)
w.Header().Set("Cache-Control", fmt.Sprintf("public, must-revalidate, max-age=%d", timeToExpected))
w.WriteHeader(http.StatusNotFound)
h.log.Warn("http_server", "request in the future", "client", r.RemoteAddr, "req", url.PathEscape(r.URL.Path))
return
}
Expand All @@ -268,8 +268,8 @@ func (h *handler) PublicRand(w http.ResponseWriter, r *http.Request) {
return
}
if data == nil {
w.WriteHeader(http.StatusNotFound)
w.Header().Set("Cache-Control", "must-revalidate, no-cache, max-age=0")
w.WriteHeader(http.StatusNotFound)
h.log.Warn("http_server", "request in the future", "client", r.RemoteAddr, "req", url.PathEscape(r.URL.Path))
return
}
Expand Down

0 comments on commit ec4f8f9

Please sign in to comment.