From d0910f85adfec4a2cddfe2297be821841f4dd671 Mon Sep 17 00:00:00 2001 From: bptato Date: Sun, 11 Aug 2024 13:59:24 +0200 Subject: dom: fix crash on wrong image content type + slightly optimize getContentType --- src/loader/response.nim | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/loader/response.nim') diff --git a/src/loader/response.nim b/src/loader/response.nim index e97e931b..a3b7e3e4 100644 --- a/src/loader/response.nim +++ b/src/loader/response.nim @@ -97,9 +97,8 @@ func getCharset*(this: Response; fallback: Charset): Charset = func getContentType*(this: Response; fallback = "application/octet-stream"): string = - if "Content-Type" in this.headers.table: - let header = this.headers.table["Content-Type"][0].toLowerAscii() - return header.until(';').strip() + this.headers.table.withValue("Content-Type", p): + return p[][0].untilLower(';').strip() # also use DefaultGuess for container, so that local mime.types cannot # override buffer mime.types return DefaultGuess.guessContentType(this.url.pathname, fallback) -- cgit 1.4.1-2-gfad0