Skip to content

Commit

Permalink
fixed CgiResponse not compiling on fedora due to missed cstring include
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Kauker committed Jan 2, 2025
1 parent f3036ca commit 32549bf
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Packets/CgiResponse.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "Response.hpp"
#include <cstring>

void Response::handleCgiResponse(Request &req, Config &config)
{
Expand Down Expand Up @@ -77,7 +78,7 @@ void Response::handleCgiResponse(Request &req, Config &config)
throw std::runtime_error("Failed to create pipe for cgi output");
if (pipe(pipeErr) == -1)
throw std::runtime_error("Failed to create pipe for cgi error");

pid_t pid = fork();
if (pid < 0)
throw std::runtime_error("Failed to fork for cgi execution");
Expand Down Expand Up @@ -105,7 +106,7 @@ void Response::handleCgiResponse(Request &req, Config &config)
execve(argv[0], argv.data(), envp.data());

// If execve returns, an error occurred
std::cerr << "Failed to execute CGI script: " + std::string(strerror(errno)) << std::endl;
std::cerr << "Failed to execute CGI script: " << strerror(errno) << std::endl;
_exit(1);
}

Expand Down Expand Up @@ -150,7 +151,7 @@ void Response::handleCgiResponse(Request &req, Config &config)
setBody("500 Internal Server Error: CGI script execution failed.\n");
return;
}

// 8. Parse output
size_t headerEnd = cgiOutput.find("\r\n\r\n");
if (headerEnd == std::string::npos)
Expand Down

0 comments on commit 32549bf

Please sign in to comment.