From 517f5dfc8adc771bf675acc7e23144270eeda5ff Mon Sep 17 00:00:00 2001 From: Hugo LAMY Date: Tue, 16 Aug 2022 20:28:40 +0200 Subject: [PATCH] script test sleep input by user --- srcs/cgi-bin/cgi_cpp_sleep.cpp | 12 ++++++++---- www/form_cgi.html | 4 ++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/srcs/cgi-bin/cgi_cpp_sleep.cpp b/srcs/cgi-bin/cgi_cpp_sleep.cpp index 303c074..0910855 100644 --- a/srcs/cgi-bin/cgi_cpp_sleep.cpp +++ b/srcs/cgi-bin/cgi_cpp_sleep.cpp @@ -3,9 +3,11 @@ int main (int ac, char **av, char ** env) { - std::string http_header; - std::string http_body; - std::string rq_body; + std::string http_header; + std::string http_body; + std::string rq_body; + size_t time; + std::stringstream ss; std::cin >> rq_body; @@ -14,7 +16,9 @@ int main (int ac, char **av, char ** env) fill_response_basic(env, http_body, http_header, rq_body); - sleep(60); + ss << get_value("sleep", rq_body); + ss >> time; + sleep(time); std::cout << http_header << CRLF CRLF << http_body; diff --git a/www/form_cgi.html b/www/form_cgi.html index 500961a..c77148e 100644 --- a/www/form_cgi.html +++ b/www/form_cgi.html @@ -204,6 +204,8 @@



+
+

expectation:

the request will sleep for one minute

@@ -427,6 +429,8 @@



+
+

expectation:

the request will sleep for one minute