about summary refs log tree commit diff stats
path: root/src/loader/response.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-08-11 13:59:24 +0200
committerbptato <nincsnevem662@gmail.com>2024-08-11 13:59:24 +0200
commitd0910f85adfec4a2cddfe2297be821841f4dd671 (patch)
tree7fac3e6c83bcb96ab8156eb22a833649ac56659c /src/loader/response.nim
parent4393412d971269055401f2e8a6be766f4402e193 (diff)
downloadchawan-d0910f85adfec4a2cddfe2297be821841f4dd671.tar.gz
dom: fix crash on wrong image content type
+ slightly optimize getContentType
Diffstat (limited to 'src/loader/response.nim')
-rw-r--r--src/loader/response.nim5
1 files changed, 2 insertions, 3 deletions
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)