Multiples minors changes (cgi env, comment, ...)

This commit is contained in:
LuckyLaszlo
2022-08-16 04:00:33 +02:00
parent 2a1aec8f1d
commit 4602844f5a
8 changed files with 207 additions and 194 deletions

View File

@@ -1,5 +1,9 @@
#include "Webserv.hpp"
/*
CGI RFC:
https://www.rfc-editor.org/rfc/rfc3875.html
*/
bool Webserv::_is_cgi(Client *client, std::string path)
{
@@ -99,23 +103,26 @@ std::string Webserv::_dup_env(std::string var, int i)
}
// TODO : verifier que les variables sont corrects
/*
https://www.rfc-editor.org/rfc/rfc3875#section-4.1
*/
void Webserv::_set_env_vector(Client *client, std::vector<std::string> &env_vector)
{
env_vector.push_back(_dup_env("AUTH_TYPE")); // authentification not supporte
env_vector.push_back(_dup_env("CONTENT_LENGTH" , client->get_rq_body().size()));
env_vector.push_back(_dup_env("CONTENT_TYPE" , client->get_rq_headers("Content-Type")));
env_vector.push_back(_dup_env("GATEWAY_INTERFACE" , "CGI/1.1")); // https://www.rfc-editor.org/rfc/rfc387)
env_vector.push_back(_dup_env("PATH_INFO" , client->get_rq_script_info()));
env_vector.push_back(_dup_env("PATH_TRANSLATED")); // not supported
env_vector.push_back(_dup_env("GATEWAY_INTERFACE" , "CGI/1.1")); // https://www.rfc-editor.org/rfc/rfc3875#section-4.1.4
env_vector.push_back(_dup_env("PATH_INFO" , client->get_rq_script_info())); // LUKE: To Check
env_vector.push_back(_dup_env("PATH_TRANSLATED")); // not supported // LUKE: Why not supported ?
env_vector.push_back(_dup_env("QUERY_STRING" , client->get_rq_query()));
env_vector.push_back(_dup_env("REMOTE_ADDR" , client->get_cl_ip()));
env_vector.push_back(_dup_env("REMOTE_HOST" , client->get_rq_headers("Host"))); // just tes
env_vector.push_back(_dup_env("REMOTE_IDENT")); // authentification not supporte
env_vector.push_back(_dup_env("REMOTE_USER")); // authentification not supporte
env_vector.push_back(_dup_env("REMOTE_HOST" , client->get_cl_ip())); // equal to REMOTE_ADDR or empty
env_vector.push_back(_dup_env("REMOTE_IDENT")); // authentification not supported
env_vector.push_back(_dup_env("REMOTE_USER")); // authentification not supported
env_vector.push_back(_dup_env("REQUEST_METHOD" , client->get_rq_method_str()));
env_vector.push_back(_dup_env("SCRIPT_NAME" , client->get_rq_script_path()));
env_vector.push_back(_dup_env("SERVER_NAME" , client->get_rq_hostname()));
env_vector.push_back(_dup_env("SERVER_PORT" , client->get_rq_port()));
env_vector.push_back(_dup_env("SCRIPT_NAME" , client->get_rq_script_path())); // LUKE: To Check
env_vector.push_back(_dup_env("SERVER_NAME" , client->get_cl_lsocket()->host));
env_vector.push_back(_dup_env("SERVER_PORT" , client->get_cl_lsocket()->port));
env_vector.push_back(_dup_env("SERVER_PROTOCOL" , "HTTP/1.1"));
env_vector.push_back(_dup_env("SERVER_SOFTWARE" , "Webserv/0.1"));
env_vector.push_back(_dup_env("REDIRECT_STATUS" , "200"));