( w http.ResponseWriter, reader io.Reader, imageResponseCache *imageResponseCache, cacheKey string, contentType string, etag string, xImgddSI string, )
| 207 | } |
| 208 | |
| 209 | func copyImageResponse( |
| 210 | w http.ResponseWriter, |
| 211 | reader io.Reader, |
| 212 | imageResponseCache *imageResponseCache, |
| 213 | cacheKey string, |
| 214 | contentType string, |
| 215 | etag string, |
| 216 | xImgddSI string, |
| 217 | ) { |
| 218 | if imageResponseCache == nil { |
| 219 | io.Copy(w, reader) |
| 220 | return |
| 221 | } |
| 222 | body, err := io.ReadAll(io.LimitReader(reader, imageResponseCache.maxFileBytes+1)) |
| 223 | if err != nil { |
| 224 | httpLogger.Info().Err(err).Msg("Unable to read image") |
| 225 | return |
| 226 | } |
| 227 | if int64(len(body)) > imageResponseCache.maxFileBytes { |
| 228 | w.Write(body) |
| 229 | io.Copy(w, reader) |
| 230 | return |
| 231 | } |
| 232 | imageResponseCache.put(cacheKey, contentType, etag, xImgddSI, body) |
| 233 | w.Write(body) |
| 234 | } |
| 235 | |
| 236 | func sortStoredImages(storedImages []*domainmodels.StoredImage, storageDefRepo storage.StorageDefRepo) ([]storedImageWithStorageDef, error) { |
| 237 | var storedImageWithStorageDefs []storedImageWithStorageDef |
no test coverage detected