about summary refs log tree commit diff stats
path: root/src/loader/cgi.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-01-26 01:11:37 +0100
committerbptato <nincsnevem662@gmail.com>2024-01-26 01:11:37 +0100
commit9b5df91240ea3e38e58d771597cb2a2c3ca95f29 (patch)
tree8d9d4fbe96682b27bc70bf415e050248d69dedae /src/loader/cgi.nim
parentfe9ac5f7824f935d22a1935b1f6f3c51823d3d02 (diff)
downloadchawan-9b5df91240ea3e38e58d771597cb2a2c3ca95f29.tar.gz
cgi: fix broken libexec path env variable
Diffstat (limited to 'src/loader/cgi.nim')
-rw-r--r--src/loader/cgi.nim11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/loader/cgi.nim b/src/loader/cgi.nim
index 76076b1c..2a2451d2 100644
--- a/src/loader/cgi.nim
+++ b/src/loader/cgi.nim
@@ -4,7 +4,6 @@ import std/posix
 import std/streams
 import std/strutils
 
-import config/chapath
 import extern/stdio
 import io/posixstream
 import loader/connecterror
@@ -25,8 +24,8 @@ proc putMappedURL(url: URL) =
   putEnv("MAPPED_URI_PATH", url.path.serialize())
   putEnv("MAPPED_URI_QUERY", url.query.get(""))
 
-proc setupEnv(cmd, scriptName, pathInfo, requestURI: string, request: Request,
-    contentLen: int, prevURL: URL) =
+proc setupEnv(cmd, scriptName, pathInfo, requestURI, libexecPath: string,
+    request: Request, contentLen: int, prevURL: URL) =
   let url = request.url
   putEnv("SERVER_SOFTWARE", "Chawan")
   putEnv("SERVER_PROTOCOL", "HTTP/1.0")
@@ -132,7 +131,7 @@ proc handleLine(handle: LoaderHandle, line: string, headers: Headers) =
   headers.add(k, v)
 
 proc loadCGI*(handle: LoaderHandle, request: Request, cgiDir: seq[string],
-    prevURL: URL) =
+    libexecPath: string, prevURL: URL) =
   template t(body: untyped) =
     if not body:
       return
@@ -210,8 +209,8 @@ proc loadCGI*(handle: LoaderHandle, request: Request, cgiDir: seq[string],
     else:
       closeStdin()
     # we leave stderr open, so it can be seen in the browser console
-    setupEnv(cmd, scriptName, pathInfo, requestURI, request, contentLen,
-      prevURL)
+    setupEnv(cmd, scriptName, pathInfo, requestURI, libexecPath, request,
+      contentLen, prevURL)
     discard execl(cstring(cmd), cstring(basename), nil)
     let code = int(ERROR_FAILED_TO_EXECUTE_CGI_SCRIPT)
     stdout.write("Cha-Control: ConnectionError " & $code)