Skip to content

Commit

Permalink
set Content-Length header before writing body
Browse files Browse the repository at this point in the history
  • Loading branch information
ajatprabha committed Nov 4, 2020
1 parent 43246b9 commit 7664d78
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/handler/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ func ImageHandler(deps *service.Dependencies) http.HandlerFunc {
w.Header().Set(CacheControlHeader, fmt.Sprintf("public,max-age=%d", config.CacheTime()))
// Ref to Google CDN we support: https://cloud.google.com/cdn/docs/caching#cacheability
w.Header().Set(VaryHeader, "Accept")
w.Header().Set(ContentLengthHeader, fmt.Sprintf("%d", len(data)))

cl, _ := w.Write(data)
w.Header().Set(ContentLengthHeader, fmt.Sprintf("%d", cl))
_, _ = w.Write(data)
}
}

0 comments on commit 7664d78

Please sign in to comment.