about summary refs log tree commit diff stats
path: root/src/loader/cgi.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-03-19 21:21:18 +0100
committerbptato <nincsnevem662@gmail.com>2024-03-19 21:21:18 +0100
commitb2873fdc765e92aca4267e60c65a5da4897a04a0 (patch)
treef2d2a570a3cb27eafeaa0431604ea4b9d3a1a96a /src/loader/cgi.nim
parent87c918062d4666837b1afafa9094e0e5b7ba57d6 (diff)
downloadchawan-b2873fdc765e92aca4267e60c65a5da4897a04a0.tar.gz
main: set CHA_LIBEXEC_DIR env var at startup
This way, we can use it everywhere (e.g. in mailcap).
Diffstat (limited to 'src/loader/cgi.nim')
-rw-r--r--src/loader/cgi.nim9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/loader/cgi.nim b/src/loader/cgi.nim
index 615f956a..f72009d7 100644
--- a/src/loader/cgi.nim
+++ b/src/loader/cgi.nim
@@ -24,7 +24,7 @@ proc putMappedURL(url: URL) =
   putEnv("MAPPED_URI_PATH", url.path.serialize())
   putEnv("MAPPED_URI_QUERY", url.query.get(""))
 
-proc setupEnv(cmd, scriptName, pathInfo, requestURI, libexecPath, myDir: string;
+proc setupEnv(cmd, scriptName, pathInfo, requestURI, myDir: string;
     request: Request; contentLen: int; prevURL: URL) =
   let url = request.url
   putEnv("SERVER_SOFTWARE", "Chawan")
@@ -38,7 +38,6 @@ proc setupEnv(cmd, scriptName, pathInfo, requestURI, libexecPath, myDir: string;
   putEnv("SCRIPT_FILENAME", cmd)
   putEnv("REQUEST_URI", requestURI)
   putEnv("REQUEST_METHOD", $request.httpMethod)
-  putEnv("CHA_LIBEXEC_DIR", libexecPath)
   var headers = ""
   for k, v in request.headers:
     headers &= k & ": " & v & "\r\n"
@@ -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];
-    libexecPath: string; prevURL: URL) =
+    prevURL: URL) =
   if cgiDir.len == 0:
     handle.sendResult(ERROR_NO_CGI_DIR)
     return
@@ -211,8 +210,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, libexecPath, myDir, request,
-      contentLen, prevURL)
+    setupEnv(cmd, scriptName, pathInfo, requestURI, myDir, 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 & " " &