modif and added several scipts for testing cgi

+ modif html page for script tests
+ script output not added to response in case of http error
This commit is contained in:
Hugo LAMY
2022-08-16 01:39:46 +02:00
parent c05536ca01
commit 8c2aff6c6b
14 changed files with 482 additions and 186 deletions

View File

@@ -3,46 +3,13 @@
int main (int ac, char **av, char ** env)
{
std::string rq_method = "not found";
std::string rq_body = "";
std::string rq_query = "";
std::string form_infos = "";
std::string http_header = "";
std::string http_body = "";
std::string http_header;
std::string http_body;
(void)ac;
(void)av;
rq_method = parse_env("REQUEST_METHOD");
rq_body = parse_body();
rq_query = parse_env("QUERY_STRING");
if (rq_method == "POST")
form_infos = rq_body;
else if (rq_method == "GET")
form_infos = rq_query;
http_body = HTML_BODY_TOP;
http_body += "<br><h3>method used: </h3>";
http_body += "<p>" + rq_method + "</p>";
http_body += "<br><h3>form body: </h3>";
http_body += "<p>" + rq_body + "</p>";
http_body += "<br><h3>form query: </h3>";
http_body += "<p>" + rq_query + "</p>";
http_body += "<br><br><h3>output:</h3><br>";
http_body += print_form(form_infos, "p", "p");
http_body += "<br><br><h3>cgi_env_variables:</h3><br>";
http_body += print_env(env, "p");
http_body += HTML_BODY_BOTTOM;
http_header = "Content-Type: text/html; charset=UTF-8" CRLF;
http_header += "Content-Length: " + itos(http_body.size() - 10);
fill_response_basic(env, http_body, http_header);
std::cout << http_header << CRLF CRLF << http_body;