(w http.ResponseWriter, r *http.Request, entry *imageResponseCacheEntry)
| 102 | } |
| 103 | |
| 104 | func writeCachedImageResponse(w http.ResponseWriter, r *http.Request, entry *imageResponseCacheEntry) { |
| 105 | if r.Header.Get("If-None-Match") == entry.etag { |
| 106 | w.WriteHeader(http.StatusNotModified) |
| 107 | return |
| 108 | } |
| 109 | w.Header().Set("Content-Type", entry.contentType) |
| 110 | w.Header().Set("Content-Length", stringInt(len(entry.body))) |
| 111 | w.Header().Set("Cache-Control", "public, max-age=31536000, immutable") |
| 112 | w.Header().Set("ETag", entry.etag) |
| 113 | w.Header().Set("X-imgdd-si", entry.xImgddSI) |
| 114 | w.WriteHeader(http.StatusOK) |
| 115 | if r.Method == http.MethodHead { |
| 116 | return |
| 117 | } |
| 118 | w.Write(entry.body) |
| 119 | } |
| 120 | |
| 121 | func stringInt(v int) string { |
| 122 | return strconv.Itoa(v) |
no test coverage detected