From 5a114fb7031f6fe8fdac2d009515f30bb19ef6c0 Mon Sep 17 00:00:00 2001 From: nicolas-arnaud Date: Sat, 12 Nov 2022 00:25:35 +0100 Subject: [PATCH] added PATH_INFO for CGI --- srcs/sock/Client.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/srcs/sock/Client.cpp b/srcs/sock/Client.cpp index d7c60dc..765627b 100644 --- a/srcs/sock/Client.cpp +++ b/srcs/sock/Client.cpp @@ -156,10 +156,14 @@ void Client::send_cgi(string cgi, string path) { args[0] = cgi.c_str(); args[1] = path.c_str(); args[2] = NULL; + string path_info = "PATH_INFO=" + _route->getRoot(); + const char **env = new const char *[path_info.length() + 1]; + env[0] = path_info.c_str(); + env[1] = NULL; dup2(fd[1], STDOUT_FILENO); close(fd[1]); close(fd[0]); - execve(cgi.c_str(), (char **)args, NULL); + execve(cgi.c_str(), (char **)args, (char **)env); } close(fd[1]); waitpid(pid, &status, 0);