From f1b2b04119c726432acb0ccea12805831567bd42 Mon Sep 17 00:00:00 2001 From: Talyx Date: Wed, 9 Feb 2022 17:15:46 +0300 Subject: [PATCH] add: cgi_pass in config file --- src/Client/Client.cpp | 2 +- src/Server/ServerConfig.cpp | 7 +++++++ src/Server/ServerConfig.hpp | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Client/Client.cpp b/src/Client/Client.cpp index 5e72978..58fe3eb 100644 --- a/src/Client/Client.cpp +++ b/src/Client/Client.cpp @@ -176,7 +176,7 @@ std::string Client::generateRespons(std::vector &configs) _config = Config::getConfig(configs, _request, connected_to); tmp = Config::getLocation(_config->getLocations(), _request.getURI()); _response.setData(_request, _config, tmp); - _response.generate2(); + _response.generate2(connected_to); _headerToSend = _response.getHeader(); _bodyToSend = _response.getBody(); _toSend = _headerToSend + _bodyToSend; diff --git a/src/Server/ServerConfig.cpp b/src/Server/ServerConfig.cpp index 88286d9..5b1d4dd 100644 --- a/src/Server/ServerConfig.cpp +++ b/src/Server/ServerConfig.cpp @@ -184,6 +184,12 @@ int ServerConfig::putLocation(toml_node *node) return (1); tmp->uploadDir = *it1->second->getString(); } + else if (it1->first == "cgi_pass") + { + if (it1->second->get_type() != toml_node::STRING) + return (1); + tmp->cgi_pass = *it1->second->getString(); + } else if (it1->first == "directory_file") { if (it1->second->get_type() != toml_node::STRING) @@ -281,6 +287,7 @@ void ServerConfig::printFields(void) std::cout << YELLOW << "uploadDir " << BLUE << (*it)->uploadDir <autoindex <uploadAccept <cgi_pass <methods.begin(); while (it2 != (*it)->methods.end()) diff --git a/src/Server/ServerConfig.hpp b/src/Server/ServerConfig.hpp index d63c77f..96365d2 100644 --- a/src/Server/ServerConfig.hpp +++ b/src/Server/ServerConfig.hpp @@ -14,6 +14,7 @@ struct location bool uploadAccept; std::vector methods; std::map redirect; + std::string cgi_pass; }; struct serverListen