mirror of
https://github.com/KeyZox71/webserv.git
synced 2025-06-25 09:33:36 +02:00
「🔨」 fix: fixed cgi config handling to match subjet
also changed cgi behavior to match the new config
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/19 14:59:41 by adjoly #+# #+# */
|
||||
/* Updated: 2025/05/16 12:08:03 by adjoly ### ########.fr */
|
||||
/* Updated: 2025/05/26 17:02:12 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -30,48 +30,26 @@ class Route {
|
||||
Route(toml::ANode *);
|
||||
~Route(void);
|
||||
|
||||
bool getDirList(void) { return _dirlist; }
|
||||
/* bool getCookies(void) { return _cookies; } */
|
||||
bool getRedirect(void) { return _redirect; }
|
||||
|
||||
int32_t getMaxBody(void) { return _max_body; }
|
||||
|
||||
std::string getRootDir(void) { return _root; }
|
||||
std::string getUpRoot(void) { return _up_root; }
|
||||
std::string getIndex(void) { return _index; }
|
||||
std::map<std::string, std::string> *getCgi(void) { return _cgi; }
|
||||
std::string getCgiPath(const std::string file) {
|
||||
if (_cgi == not_nullptr)
|
||||
return "";
|
||||
size_t pos = file.find_last_of(".");
|
||||
|
||||
if (pos == file.length())
|
||||
return "";
|
||||
std::string ext = file.substr(pos + 1);
|
||||
|
||||
for (auto it = prange(_cgi)) {
|
||||
if (ext == it->first) {
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
bool *getMethods(void) { return _methods; }
|
||||
bool getDirList(void) { return _dirlist; }
|
||||
bool getRedirect(void) { return _redirect; }
|
||||
int32_t getMaxBody(void) { return _max_body; }
|
||||
std::string getRootDir(void) { return _root; }
|
||||
std::string getUpRoot(void) { return _up_root; }
|
||||
std::string getIndex(void) { return _index; }
|
||||
std::vector<std::string> *getCgi(void) { return _cgi; }
|
||||
bool * getMethods(void) { return _methods; }
|
||||
|
||||
protected:
|
||||
private:
|
||||
bool _dirlist;
|
||||
/* bool _cookies; */
|
||||
bool _redirect;
|
||||
|
||||
int32_t _max_body;
|
||||
|
||||
std::string _root;
|
||||
std::string _up_root;
|
||||
std::string _index;
|
||||
std::map<std::string, std::string> *_cgi;
|
||||
std::string _root;
|
||||
std::string _up_root;
|
||||
std::string _index;
|
||||
std::vector<std::string> *_cgi;
|
||||
|
||||
bool _methods[3]; ///> A methods boolean array which correspond to - 0: GET,
|
||||
/// 1: POST, 2: DELETE
|
||||
@ -84,7 +62,7 @@ class Route {
|
||||
*
|
||||
* @return A pointer to a map of cgi
|
||||
*/
|
||||
std::map<std::string, std::string> *_parseCGI(toml::ANode *);
|
||||
std::vector<std::string> *_parseCGI(toml::ANode *);
|
||||
|
||||
/**
|
||||
* @brief Can be used to parse a table of error pages
|
||||
|
Reference in New Issue
Block a user