@@ -10,12 +10,13 @@ using namespace std;
1010
1111webserver* ws_ptr;
1212
13+ /*
1314void signal_callback_handler(int signum)
1415{
1516 cout << "bye!" << endl;
1617 ws_ptr->stop();
1718}
18-
19+ */
1920Test::Test () : http_resource()
2021{
2122}
@@ -26,7 +27,7 @@ Test2::Test2() : http_resource()
2627
2728http_response Test::render_GET (const http_request& r)
2829{
29- cout << r.get_version () << endl;
30+ /* cout << r.get_version() << endl;
3031 cout << r.get_requestor() << endl;
3132 cout << r.get_requestor_port() << endl;
3233 cout << "PROVA: " << r.get_arg("prova") << endl;
@@ -37,13 +38,17 @@ http_response Test::render_GET(const http_request& r)
3738 r.get_headers(head);
3839 for(std::map<std::string, std::string, header_comparator>::const_iterator it = head.begin(); it != head.end(); ++it)
3940 cout << (*it).first << "-> " << (*it).second << endl;
40- string pp = r.get_arg (" prova" );
41- return http_file_response (" /home/etr/progs/libhttpserver/test/noimg.png" , 200 , " image/png" );
41+ string pp = r.get_arg("prova"); */
42+ std::vector<std::string> topics;
43+ topics.push_back (" prova" );
44+ // return long_polling_receive_response("", 200, "", topics, 10, "keepalive\n");
45+ cout << r.get_querystring () << endl;
46+ return http_file_response (" /home/etr/progs/libhttpserver/test/noimg.png" , 200 , " image/png" );
4247}
4348
4449http_response Test::render_POST (const http_request& r)
4550{
46- fstream filestr;
51+ /* fstream filestr;
4752 filestr.open("test.txt", fstream::out | fstream::app);
4853 filestr << r.get_content() << endl;
4954 filestr.close();
@@ -53,7 +58,11 @@ http_response Test::render_POST(const http_request& r)
5358 {
5459 cout << vv[i] << endl;
5560 }
56- return http_string_response (" OK" ,200 );
61+ return http_string_response("OK",200);*/
62+ http_string_response s (" OK" ,200 );
63+ s.set_header (http_utils::http_header_location, " B" );
64+ return s;
65+ // return long_polling_send_response("<script type=\"text/javascript\">alert(\"ciao\")</script>\n", "prova");
5766}
5867
5968http_response Test2::render_GET (const http_request& r)
@@ -69,7 +78,7 @@ http_response Test::render_PUT(const http_request& r)
6978
7079int main ()
7180{
72- signal (SIGINT, &signal_callback_handler);
81+ // signal(SIGINT, &signal_callback_handler);
7382 webserver ws = create_webserver (8080 );
7483 ws_ptr = &ws;
7584 Test dt = Test ();
0 commit comments