Re: [Cppcms-users] Mounting both synchronous and asynchronous applications
Brought to you by:
artyom-beilis
From: CN <cn...@gr...> - 2011-02-02 04:01:02
|
This morning this program all a sudden begins to match requested URI. The possible reason for being not working last night most likely is because the browser did not fully reload java script and/or the web page from web server (because of its caching mechanism?) even I clicked its refresh button. I had this experience before and wasted hours looking for the cause of unexpected behavior. If people start to get the similar weird result, please try closing the tab from your browsers and then locate the URI again, or even restart it. Back to my point... I am able to proceed my work now. However, there is still one thing I don't understand: class async_app : public cppcms::application { public: async_app(cppcms::service &srv) : cppcms::application(srv) { dispatcher().assign("^ps$",&async_app::catch_all,this); } void catch_all() { BOOSTER_LOG(debug,"async app is fired"); std::map<std::string,std::string> env=request().getenv(); std::map<std::string,std::string>::const_iterator i; for(i=env.begin();i != env.end();++i) BOOSTER_LOG(debug,"ENV") << (*i).first << ":" << (*i).second; } } int main(int argc,char **argv) { cppcms::service s(argc,argv); s.applications_pool().mount(cppcms::applications_factory<sync_app>(),cppcms::mount_point("/s/(.*)",1)); booster::intrusive_ptr<async_app> e=new async_app(s); s.applications_pool().mount(e,cppcms::mount_point("/as/(.*)",1)); s.run(); return 0; } The excerpted log follows: 2011-02-02 02:30:07 GMT; ENV, debug: DOCUMENT_ROOT:/var/www/example (cgi.cpp:114) 2011-02-02 02:30:07 GMT; ENV, debug: GATEWAY_INTERFACE:CGI/1.1 (cgi.cpp:114) 2011-02-02 02:30:07 GMT; ENV, debug: HTTP_ACCEPT:text/html, */* (cgi.cpp:114) 2011-02-02 02:30:07 GMT; ENV, debug: HTTP_ACCEPT_CHARSET:iso-8859-1, utf-8, utf-16, *;q=0.1 (cgi.cpp:114) 2011-02-02 02:30:07 GMT; ENV, debug: HTTP_ACCEPT_ENCODING:deflate, gzip, x-gzip, identity, *;q=0 (cgi.cpp:114) 2011-02-02 02:30:07 GMT; ENV, debug: HTTP_CONNECTION:Keep-Alive, TE (cgi.cpp:114) 2011-02-02 02:30:07 GMT; ENV, debug: HTTP_HOST:www.example.com (cgi.cpp:114) 2011-02-02 02:30:07 GMT; ENV, debug: HTTP_REFERER:http://www.example.com/test.html (cgi.cpp:114) 2011-02-02 02:30:07 GMT; ENV, debug: HTTP_TE:deflate, gzip, chunked, identity, trailers (cgi.cpp:114) 2011-02-02 02:30:07 GMT; ENV, debug: HTTP_USER_AGENT:Opera/9.80 (X11; Linux i686; U; en) Presto/2.7.62 Version/11.00 (cgi.cpp:114) 2011-02-02 02:30:07 GMT; ENV, debug: HTTP_X_REQUESTED_WITH:XMLHttpRequest (cgi.cpp:114) 2011-02-02 02:30:07 GMT; ENV, debug: PATH_INFO:/as/ps (cgi.cpp:114) 2011-02-02 02:30:07 GMT; ENV, debug: PATH_TRANSLATED:/var/www/example/as/ps (cgi.cpp:114) 2011-02-02 02:30:07 GMT; ENV, debug: QUERY_STRING: (cgi.cpp:114) 2011-02-02 02:30:07 GMT; ENV, debug: REDIRECT_STATUS:200 (cgi.cpp:114) 2011-02-02 02:30:07 GMT; ENV, debug: REMOTE_ADDR:127.0.0.1 (cgi.cpp:114) 2011-02-02 02:30:07 GMT; ENV, debug: REMOTE_PORT:41362 (cgi.cpp:114) 2011-02-02 02:30:07 GMT; ENV, debug: REQUEST_METHOD:GET (cgi.cpp:114) 2011-02-02 02:30:07 GMT; ENV, debug: REQUEST_URI:/cgi/as/ps (cgi.cpp:114) 2011-02-02 02:30:07 GMT; ENV, debug: SCRIPT_FILENAME:/var/www/example/cgi (cgi.cpp:114) 2011-02-02 02:30:07 GMT; ENV, debug: SCRIPT_NAME:/cgi (cgi.cpp:114) 2011-02-02 02:30:07 GMT; ENV, debug: SERVER_ADDR:127.0.0.1 (cgi.cpp:114) 2011-02-02 02:30:07 GMT; ENV, debug: SERVER_NAME:www.example.com (cgi.cpp:114) 2011-02-02 02:30:07 GMT; ENV, debug: SERVER_PORT:80 (cgi.cpp:114) 2011-02-02 02:30:07 GMT; ENV, debug: SERVER_PROTOCOL:HTTP/1.1 (cgi.cpp:114) 2011-02-02 02:30:07 GMT; ENV, debug: SERVER_SOFTWARE:lighttpd/1.4.28-devel-485M (cgi.cpp:114) Please take special note of these two lines in the log: 2011-02-02 02:30:07 GMT; ENV, debug: PATH_INFO:/as/ps (cgi.cpp:114) 2011-02-02 02:30:07 GMT; ENV, debug: SCRIPT_NAME:/cgi (cgi.cpp:114) The description for the overloaded function cppcms::mount_point::mount_point(std::string const &script) is "Create a mount point that checks SCRIPT_NAME, and passes PATH_INFO for dispatching the version of mount_point() among the overloads" Refer to: http://cppcms.sourceforge.net/cppcms_ref_v0_99/classcppcms_1_1mount__point.html My understanding is that the following code should match nothing: s.applications_pool().mount(e,cppcms::mount_point("/as/(.*)",1)); because according to the log, the incoming SCRIPT_NAME is "/cgi". However, the reality is that it matches! On the contrary, this version fails to match: s.applications_pool().mount(e,cppcms::mount_point("/cgi/(.*)",1)); Is this a descrepancy between CppCMS documentation and the library itself? Best Regards, CN |