Re: [Cppcms-users] Mounting both synchronous and asynchronous applications
Brought to you by:
artyom-beilis
From: Artyom <art...@ya...> - 2011-02-02 08:59:30
|
> > Back to my point... I am able to proceed my work now. However, there is > still one thing I don't understand: > > { > dispatcher().assign("^ps$",&async_app::catch_all,this); > } > >s.applications_pool().mount(cppcms::applications_factory<sync_app>(),cppcms::mount_point("/s/(.*)",1)); > > s.applications_pool().mount(e,cppcms::mount_point("/as/(.*)",1)); Lets start: Quoting Documentation: > cppcms::mount_point::mount_point(std::string const & path,int group) > > Create a mount point that checks PATH_INFO only and passes matched group for >dispatching > That means that PATH_INFO is matched so PATH_INFO = /as/ps Matched agains: /as/(.*) And then "ps" is selected and passed to main of application that on "^ps$" gets matched. What does not match the documentation? > cppcms::mount_point::mount_point(std::string const &script) > > Create a mount point that checks SCRIPT_NAME, and passes PATH_INFO for >dispatching > Now this is fo case where we have for exaple foo.cgi bar.cgi And you want to match them So for URL foo.cgi/beep SCRIPT_NAME=foo.cgi PATH_INFO=/beep foo.cgi would be matched by mount_point("foo.cgi") and then "/beep" would passed to main of the application for dispatching ... > cppcms::mount_point::mount_point() > > Create default mount point, it uses PATH_INFO for url-dispatching and gives no >restriction on URL > This case - the default mount point when you use just a one application it passes all PATH_INFO for URL dispatching. > 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)); > No. It is matched against PATH_INFO that is the usual case > 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? No, you just should read documentation more carefully. Different mount points constructors have different semantics allowing to both use script_name and path_info for dispatching, however every mount point should extract something to pass to application's main. Artyom |