Open Jake1152 opened 1 year ago
bool ConfigInfo::isCgiRequest(const std::string &file_path, const unsigned short& port)
/ 하드코딩된 extension을 getExtension을 이용해서 처리하게 변경할 수 있다. 그렇게되면 config에 cgi-pass에 있는 extension 타입에 따라 우리의 cgi 적용범위를 더욱 넓게 처리할 수 있다. / bool ConfigInfo::isCgiRequest(const std::string &file_path, const unsigned short& port) { // config에 있는 cgi정보 이용 필요 ServerConfig server_config;
if (getServerConfig(port, server_config))
{
const std::map<std::string, std::string>& cgi_pass_map = server_config.getCgiPass();
std::map<std::string, std::string>::const_iterator cgi_pass_map_iter;
cgi_pass_map_iter = cgi_pass_map.begin();
for (;cgi_pass_map_iter != cgi_pass_map.end(); cgi_pass_map_iter++)
{
std::string cgi_type_str;
cgi_type_str = cgi_pass_map_iter->first;
// printContent(cgi_type_str, "in isCgiRequest", BRW);
// printContent(file_path, "in isCgiRequest if statement. file_path", BRW);
if (this->isLastPartOfStr(file_path, ".php") &&
this->isLastPartOfStr(cgi_type_str, ".php"))
return (true);
else if (this->isLastPartOfStr(file_path, ".py") &&
this->isLastPartOfStr(cgi_type_str, ".py"))
return (true);
}
}
else
{
std::cerr << RED << "!!!! Could not found server config to match using arument port In isCgiRequest()" << WHI << std::endl;
return (false);
}
// printContent(file_path, "after if statement in isCgiRequest. file_path", BRW);
return (false);
}