diff options
Diffstat (limited to 'src/loader')
-rw-r--r-- | src/loader/cgi.nim | 9 | ||||
-rw-r--r-- | src/loader/loader.nim | 7 |
2 files changed, 6 insertions, 10 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 & " " & diff --git a/src/loader/loader.nim b/src/loader/loader.nim index 3b454b4d..17677eb5 100644 --- a/src/loader/loader.nim +++ b/src/loader/loader.nim @@ -24,7 +24,6 @@ import std/streams import std/strutils import std/tables -import config/chapath import io/bufwriter import io/posixstream import io/promise @@ -104,7 +103,6 @@ type ssock: ServerSocket alive: bool config: LoaderConfig - libexecPath: string handleMap: Table[int, LoaderHandle] outputMap: Table[int, OutputHandle] selector: Selector[int] @@ -403,7 +401,7 @@ proc loadResource(ctx: LoaderContext; client: ClientData; request: Request; redo = true continue if request.url.scheme == "cgi-bin": - handle.loadCGI(request, ctx.config.cgiDir, ctx.libexecPath, prevurl) + handle.loadCGI(request, ctx.config.cgiDir, prevurl) if handle.istream != nil: ctx.addFd(handle) else: @@ -660,8 +658,7 @@ proc initLoaderContext(fd: cint; config: LoaderConfig): LoaderContext = var ctx = LoaderContext( alive: true, config: config, - selector: newSelector[int](), - libexecPath: ChaPath("${%CHA_LIBEXEC_DIR}").unquote().get + selector: newSelector[int]() ) gctx = ctx #TODO ideally, buffered would be true. Unfortunately this conflicts with |