@@ -25,7 +25,7 @@ Test2::Test2() : http_resource()
2525{
2626}
2727
28- http_response Test::render_GET (const http_request& r)
28+ void Test::render_GET (const http_request& r, http_response** res )
2929{
3030/* cout << r.get_version() << endl;
3131 cout << r.get_requestor() << endl;
@@ -43,10 +43,10 @@ http_response Test::render_GET(const http_request& r)
4343 topics.push_back (" prova" );
4444 // return long_polling_receive_response("", 200, "", topics, 10, "keepalive\n");
4545 cout << r.get_querystring () << endl;
46- return http_file_response (" /home/etr/progs/libhttpserver/test/noimg.png" , 200 , " image/png" );
46+ *res = new http_file_response (" /home/etr/progs/libhttpserver/test/noimg.png" , 200 , " image/png" );
4747}
4848
49- http_response Test::render_POST (const http_request& r)
49+ void Test::render_POST (const http_request& r, http_response** res )
5050{
5151/* fstream filestr;
5252 filestr.open("test.txt", fstream::out | fstream::app);
@@ -59,16 +59,16 @@ http_response Test::render_POST(const http_request& r)
5959 cout << vv[i] << endl;
6060 }
6161 return http_string_response("OK",200);*/
62- http_string_response s (" OK" ,100 );
63- s. set_header (http_utils::http_header_location, " B" );
64- s. set_cookie (" Ciccio" , " Puppo" );
65- s. set_cookie (" Peppe" , " Puppo" );
66- cout << s. get_cookie (" Ciccio" ) << endl;
67- return s;
62+ http_string_response* s = new http_string_response (" OK" ,100 );
63+ s-> set_header (http_utils::http_header_location, " B" );
64+ s-> set_cookie (" Ciccio" , " Puppo" );
65+ s-> set_cookie (" Peppe" , " Puppo" );
66+ cout << s-> get_cookie (" Ciccio" ) << endl;
67+ *res = s;
6868 // return long_polling_send_response("<script type=\"text/javascript\">alert(\"ciao\")</script>\n", "prova");
6969}
7070
71- http_response Test2::render_GET (const http_request& r)
71+ void Test2::render_GET (const http_request& r, http_response** res )
7272{
7373 cout << " D2" << endl;
7474 typedef std::map<std::string, std::string,
@@ -77,18 +77,18 @@ http_response Test2::render_GET(const http_request& r)
7777 r.get_cookies (c);
7878 for (c_type::const_iterator it = c.begin (); it != c.end (); ++it)
7979 cout << (*it).first << " -> " << (*it).second << endl;
80- return http_string_response (" {\" var1 \" : \" " +r.get_arg (" var1" )+" \" , \" var2 \" : \" " +r.get_arg (" var2" )+" \" , \" var3 \" : \" " +r.get_arg (" var3" )+" \" }" , 200 );
80+ *res = new http_string_response (" {\" var1 \" : \" " +r.get_arg (" var1" )+" \" , \" var2 \" : \" " +r.get_arg (" var2" )+" \" , \" var3 \" : \" " +r.get_arg (" var3" )+" \" }" , 200 );
8181}
8282
83- http_response Test::render_PUT (const http_request& r)
83+ void Test::render_PUT (const http_request& r, http_response** res )
8484{
85- return http_string_response (r.get_content (), 200 );
85+ *res = new http_string_response (r.get_content (), 200 );
8686}
8787
8888int main ()
8989{
9090// signal(SIGINT, &signal_callback_handler);
91- webserver ws = create_webserver (8080 ).start_method (http_utils::INTERNAL_REMANAGED). max_threads (5 );
91+ webserver ws = create_webserver (8080 ).max_threads (5 );
9292 ws_ptr = &ws;
9393 Test dt = Test ();
9494 Test2 dt2 = Test2 ();
0 commit comments