about summary refs log tree commit diff stats
path: root/src/loader/loader.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-12-12 20:28:54 +0100
committerbptato <nincsnevem662@gmail.com>2023-12-12 20:49:30 +0100
commita6166c4dfc7b028761a884127cc78aeb0056ed8d (patch)
treee19cda9ba3e46fa4cf42aa383c3530d472282c10 /src/loader/loader.nim
parent1dcb9cf6567145a0d3705b95717ccbf37eac6140 (diff)
downloadchawan-a6166c4dfc7b028761a884127cc78aeb0056ed8d.tar.gz
Move out file: protocol handling to adapter/
Diffstat (limited to 'src/loader/loader.nim')
-rw-r--r--src/loader/loader.nim9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/loader/loader.nim b/src/loader/loader.nim
index b6250098..28029160 100644
--- a/src/loader/loader.nim
+++ b/src/loader/loader.nim
@@ -31,7 +31,6 @@ import js/javascript
 import loader/cgi
 import loader/connecterror
 import loader/curlhandle
-import loader/file
 import loader/ftp
 import loader/gopher
 import loader/headers
@@ -115,8 +114,6 @@ proc addFd(ctx: LoaderContext, fd: int, flags: int) =
 const MaxRewrites = 4
 
 func canRewriteForCGICompat(ctx: LoaderContext, path: string): bool =
-  if not ctx.config.w3mCGICompat:
-    return false
   if path.startsWith("/cgi-bin/") or path.startsWith("/$LIB/"):
     return true
   for dir in ctx.config.cgiDir:
@@ -130,8 +127,7 @@ proc loadResource(ctx: LoaderContext, request: Request, handle: LoaderHandle) =
   var prevurl: URL = nil
   while redo and tries < MaxRewrites:
     redo = false
-    case request.url.scheme
-    of "file":
+    if ctx.config.w3mCGICompat and request.url.scheme == "file":
       let path = request.url.path.serialize_unicode()
       if ctx.canRewriteForCGICompat(path):
         let newURL = newURL("cgi-bin:" & path & request.url.search)
@@ -140,8 +136,7 @@ proc loadResource(ctx: LoaderContext, request: Request, handle: LoaderHandle) =
           inc tries
           redo = true
           continue
-      handle.loadFilePath(request.url, path)
-      handle.close()
+    case request.url.scheme
     of "http", "https":
       let handleData = handle.loadHttp(ctx.curlm, request)
       if handleData != nil: