From 80402f3c529dde39120ed0c215d4bc20f218f7c7 Mon Sep 17 00:00:00 2001 From: AviKav Date: Tue, 14 Jul 2020 03:59:07 -0400 Subject: [PATCH] Rename mimetype check --- src/main/kotlin/mdnet/base/server/ImageServer.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/mdnet/base/server/ImageServer.kt b/src/main/kotlin/mdnet/base/server/ImageServer.kt index 8466cb7..dec52dc 100644 --- a/src/main/kotlin/mdnet/base/server/ImageServer.kt +++ b/src/main/kotlin/mdnet/base/server/ImageServer.kt @@ -144,7 +144,7 @@ class ImageServer( // TODO: Cleanup messy conditionals // Ensure that cached file isn't a non-image from the Great Cache Propagation - val flaresFault = imageDatum != null && imageDatum.contentType.isImage().not() + val flaresFault = imageDatum != null && imageDatum.contentType.isImageMimetype().not() if (flaresFault) { snapshot?.close(); snapshot = null @@ -181,7 +181,7 @@ class ImageServer( } } - private fun String.isImage() = this.toLowerCase().startsWith("image/") + private fun String.isImageMimetype() = this.toLowerCase().startsWith("image/") private fun Request.handleCacheHit(sanitizedUri: String, cipher: Cipher, snapshot: DiskLruCache.Snapshot, imageDatum: ImageDatum): Response { // our files never change, so it's safe to use the browser cache @@ -233,8 +233,8 @@ class ImageServer( contentType!! - if (!contentType.isImage()) { - LOGGER.trace { "Upstream query for $sanitizedUri returned bad mime-type $contentType" } + if (!contentType.isImageMimetype()) { + LOGGER.trace { "Upstream query for $sanitizedUri returned bad mimetype $contentType" } mdResponse.close() return Response(mdResponse.status) }