Fixed error in nim 0.20.0; now handling uppercase extensions correctly (closes #1)
h3rald h3rald@h3rald.com
Sun, 23 Jun 2019 18:50:37 +0200
1 files changed,
6 insertions(+),
2 deletions(-)
jump to
M
src/nimhttpd.nim
→
src/nimhttpd.nim
@@ -74,7 +74,7 @@ var path2 = path
if cwd == "/": return path else: - path2.delete(0, cwd.len) + path2.delete(0, cwd.len-1) var relpath = path2.replace("\\", "/") if (not relpath.endsWith("/")) and (not path.existsFile): relpath = relpath&"/"@@ -99,7 +99,11 @@ return (code: Http501, content: h_page(settings, content, $Http501), headers: newHttpHeaders())
proc sendStaticFile(settings: NimHttpSettings, path: string): NimHttpResponse = let mimes = settings.mimes - let mimetype = mimes.getMimetype(path.splitFile.ext[1 .. ^1]) + var ext = path.splitFile.ext + if ext == "": + ext = ".txt" + ext = ext[1 .. ^1] + let mimetype = mimes.getMimetype(ext.toLowerAscii) var file = path.readFile return (code: Http200, content: file, headers: {"Content-Type": mimetype}.newHttpHeaders)