Explorar el Código

Fix content-length crash

Zed hace 5 años
padre
commit
3107ab0ab8
Se han modificado 1 ficheros con 7 adiciones y 1 borrados
  1. 7 1
      src/routes/media.nim

+ 7 - 1
src/routes/media.nim

@@ -44,9 +44,15 @@ proc proxyMedia*(req: jester.Request; url: string): Future[HttpCode] {.async.} =
     if request.headers.getOrDefault("If-None-Match") == hashed:
       return Http304
 
+    let contentLength =
+      if res.headers.hasKey("content-length"):
+        res.headers["content-length", 0]
+      else:
+        ""
+
     let headers = newHttpHeaders({
       "Content-Type": res.headers["content-type", 0],
-      "Content-Length": res.headers["content-length", 0],
+      "Content-Length": contentLength,
       "Cache-Control": maxAge,
       "ETag": hashed
     })