cppcms-users Mailing List for CppCMS C++ Web Framework (Page 106)
Brought to you by:
artyom-beilis
You can subscribe to this list here.
2009 |
Jan
|
Feb
(22) |
Mar
|
Apr
(3) |
May
|
Jun
(4) |
Jul
|
Aug
|
Sep
|
Oct
(15) |
Nov
(16) |
Dec
(13) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2010 |
Jan
(4) |
Feb
|
Mar
(8) |
Apr
(8) |
May
(8) |
Jun
(36) |
Jul
(63) |
Aug
(126) |
Sep
(47) |
Oct
(66) |
Nov
(46) |
Dec
(42) |
2011 |
Jan
(87) |
Feb
(24) |
Mar
(54) |
Apr
(21) |
May
(22) |
Jun
(18) |
Jul
(22) |
Aug
(101) |
Sep
(57) |
Oct
(33) |
Nov
(34) |
Dec
(66) |
2012 |
Jan
(64) |
Feb
(76) |
Mar
(73) |
Apr
(105) |
May
(93) |
Jun
(83) |
Jul
(84) |
Aug
(88) |
Sep
(57) |
Oct
(59) |
Nov
(35) |
Dec
(49) |
2013 |
Jan
(67) |
Feb
(17) |
Mar
(49) |
Apr
(64) |
May
(87) |
Jun
(64) |
Jul
(93) |
Aug
(23) |
Sep
(15) |
Oct
(16) |
Nov
(62) |
Dec
(73) |
2014 |
Jan
(5) |
Feb
(23) |
Mar
(21) |
Apr
(11) |
May
(1) |
Jun
(19) |
Jul
(27) |
Aug
(16) |
Sep
(5) |
Oct
(37) |
Nov
(12) |
Dec
(9) |
2015 |
Jan
(7) |
Feb
(7) |
Mar
(44) |
Apr
(28) |
May
(5) |
Jun
(12) |
Jul
(8) |
Aug
|
Sep
(39) |
Oct
(34) |
Nov
(30) |
Dec
(34) |
2016 |
Jan
(66) |
Feb
(23) |
Mar
(33) |
Apr
(15) |
May
(11) |
Jun
(15) |
Jul
(26) |
Aug
(4) |
Sep
(1) |
Oct
(30) |
Nov
(10) |
Dec
|
2017 |
Jan
(52) |
Feb
(9) |
Mar
(24) |
Apr
(16) |
May
(9) |
Jun
(12) |
Jul
(33) |
Aug
(8) |
Sep
|
Oct
(1) |
Nov
(2) |
Dec
(6) |
2018 |
Jan
(5) |
Feb
|
Mar
|
Apr
|
May
(14) |
Jun
(1) |
Jul
(9) |
Aug
(1) |
Sep
(13) |
Oct
(8) |
Nov
(2) |
Dec
(2) |
2019 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
(3) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
2020 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
(9) |
Jul
(6) |
Aug
(25) |
Sep
(10) |
Oct
(10) |
Nov
(6) |
Dec
|
2021 |
Jan
|
Feb
|
Mar
(7) |
Apr
(1) |
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
(9) |
Oct
(1) |
Nov
|
Dec
|
2022 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Artyom B. <art...@ya...> - 2011-09-10 08:25:01
|
Hello, Due to the other discussion about json-rpc and same origin policy restriction of XMLHttpRequest I've searched how to apply CORS (Cross Origin Resource Sharing, see [1],[2]) with CppCMS. It was quite simple. I've added this code to the json_rpc/rpc.cpp example (class json_service) virtual void main(std::string url) { // Handle CORS response().set_header("Access-Control-Allow-Origin","*"); response().set_header("Access-Control-Allow-Headers","Content-Type"); if(request().request_method()=="OPTIONS") { return; } cppcms::rpc::json_rpc_server::main(url); } It allows to send appropriate headers and handle JSON-RPC (actually any XMLHttpRequest) in cross domain way. Latest specification of XMLHttpRequest allow to execute cross domain requests if the peer responds on OPTIONS request and sets appropriate headers actually allowing explicitly cross origin request. Few notes: - It requires up to date browsers: Firefox >= 3.5, IE >= 8 and AFAIK any version of Chrome and Safari >= 4 - It currently does not work with internal HTTP web server as it rejects OPTIONS request that was not exist in HTTP/1.0 So you need to run CppCMS behind real web server like Apache, Lighttpd or Nginx. This is fixed in trunk version of CppCMS. Bottom Line: ------------- If you target recent browsers i.e. IE>=8 and FF>=3.5 you don't need to deploy JSONP like techniques. References: [1] http://www.w3.org/TR/cors/ [2] http://en.wikipedia.org/wiki/Cross-Origin_Resource_Sharing Artyom Beilis |
From: 陈抒 <csf...@gm...> - 2011-09-10 08:08:01
|
I figured out the real reason. We have one old cppcms version installed in our computer.After removed them,everything is OK. 陈抒 Best regards http://blog.csdn.net/sheismylife On Sat, Sep 10, 2011 at 2:02 PM, 刘怀宇 <mys...@gm...> wrote: > Hello Artyom , I try JSON_RPC over JSONP by the sample you proposed! > > cppcms::http::request& r = request(); > string name = "method"; > r.get(name); > > But I met a serious error. > > > > > 2011/9/9 <cpp...@li...> > >> Send Cppcms-users mailing list submissions to >> cpp...@li... >> >> To subscribe or unsubscribe via the World Wide Web, visit >> https://lists.sourceforge.net/lists/listinfo/cppcms-users >> or, via email, send a message with subject or body 'help' to >> cpp...@li... >> >> You can reach the person managing the list at >> cpp...@li... >> >> When replying, please edit your Subject line so it is more specific >> than "Re: Contents of Cppcms-users digest..." >> >> >> Today's Topics: >> >> 1. Re: Cppcms-users Digest, Vol 26, Issue 8 (Artyom Beilis) >> >> >> ---------------------------------------------------------------------- >> >> Message: 1 >> Date: Thu, 8 Sep 2011 10:56:20 -0700 (PDT) >> From: Artyom Beilis <art...@ya...> >> Subject: Re: [Cppcms-users] Cppcms-users Digest, Vol 26, Issue 8 >> To: cpp...@li... >> Message-ID: >> <131...@we...> >> Content-Type: text/plain; charset=iso-8859-1 >> >> > Hello,Artyom:? ? My Java developers told me they solved the >> > cross-domain problem using JSONP. Does CppCMS support it? >> > I mean JSON_RPC over JSONP.?Or do you have any better >> > idea for this problem? >> >> CppCMS Supports JSON-RPC over HTTP via POST requests. >> >> So basically that means if you want to implement JSONP >> you will just to need to handle it on your own. >> >> It should be quite trivial to implement with existing >> JSON support. (See sample below) >> >> Now you should remember that: >> >> 1. JSONP may expose the application to many security problems. >> 2. GET requests have limited size this you'll have problems >> passing big parameters. >> >> So it should not be a problem to use but it has no real connection >> to JSON-RPC. >> >> Artyom >> -------------------------- >> >> void main(std::string url) >> { >> wrapper_function = request().get("jsonp"); >> std::string method = request().get("method"); >> cppcms::json::value params; >> { >> std::istringstream params(request().get("params")); >> if(!v.load(params,true)) { >> response().make_error_response(503); >> return; >> } >> } >> >> response.out() << wrapper_function <<'('; >> if(method=="sum") >> sum(v); >> else if >> ... >> response.out() << '); >> >> } >> void sum(json::value const &v) { >> int x = v[0].number(); >> int y = v[0].number(); >> json::value res = x+y; >> response.out() << res; >> } >> >> >> ------------- >> >> >> <script src=" >> http://someurl.com/rpc?method=sum&wrapper=parseRequest&parms=[10,20] >> "></script> >> >> >> >> >> >> >> >> >> ------------------------------ >> >> >> ------------------------------------------------------------------------------ >> Why Cloud-Based Security and Archiving Make Sense >> Osterman Research conducted this study that outlines how and why cloud >> computing security and archiving is rapidly being adopted across the IT >> space for its ease of implementation, lower cost, and increased >> reliability. Learn more. http://www.accelacomm.com/jaw/sfnl/114/51425301/ >> >> ------------------------------ >> >> _______________________________________________ >> Cppcms-users mailing list >> Cpp...@li... >> https://lists.sourceforge.net/lists/listinfo/cppcms-users >> >> >> End of Cppcms-users Digest, Vol 26, Issue 11 >> ******************************************** >> > > > > ------------------------------------------------------------------------------ > Malware Security Report: Protecting Your Business, Customers, and the > Bottom Line. Protect your business and customers by understanding the > threat from malware and how it can impact your online business. > http://www.accelacomm.com/jaw/sfnl/114/51427462/ > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > |
From: 陈抒 <csf...@gm...> - 2011-09-10 07:20:45
|
I modified the example project hello_world,also couldn't use request().get(string const&) method correctly. void my_hello_world::main(std::string /*url*/) { cppcms::http::request & r = request(); std::string str = r.get("ok"); response().out()<< "<html>\n" "<body>\n" " <h1>Hello World</h1>\n" "</body>\n" "</html>\n"; } Got some error messages: /usr/local/src/cppcms-0.99.10/examples/hello_world $ make g++ -O2 -Wall -g hello.cpp -o hello -lcppcms -lbooster hello.cpp: In member function ‘virtual void my_hello_world::main(std::string)’: hello.cpp:19:21: error: invalid use of incomplete type ‘struct cppcms::http::request’ /usr/local/include/cppcms/application.h:52:9: error: forward declaration of ‘struct cppcms::http::request’ hello.cpp:19:14: warning: unused variable ‘str’ [-Wunused-variable] make: *** [hello] Error 1 陈抒 Best regards http://blog.csdn.net/sheismylife On Sat, Sep 10, 2011 at 2:02 PM, 刘怀宇 <mys...@gm...> wrote: > Hello Artyom , I try JSON_RPC over JSONP by the sample you proposed! > > cppcms::http::request& r = request(); > string name = "method"; > r.get(name); > > But I met a serious error. > > > > > 2011/9/9 <cpp...@li...> > >> Send Cppcms-users mailing list submissions to >> cpp...@li... >> >> To subscribe or unsubscribe via the World Wide Web, visit >> https://lists.sourceforge.net/lists/listinfo/cppcms-users >> or, via email, send a message with subject or body 'help' to >> cpp...@li... >> >> You can reach the person managing the list at >> cpp...@li... >> >> When replying, please edit your Subject line so it is more specific >> than "Re: Contents of Cppcms-users digest..." >> >> >> Today's Topics: >> >> 1. Re: Cppcms-users Digest, Vol 26, Issue 8 (Artyom Beilis) >> >> >> ---------------------------------------------------------------------- >> >> Message: 1 >> Date: Thu, 8 Sep 2011 10:56:20 -0700 (PDT) >> From: Artyom Beilis <art...@ya...> >> Subject: Re: [Cppcms-users] Cppcms-users Digest, Vol 26, Issue 8 >> To: cpp...@li... >> Message-ID: >> <131...@we...> >> Content-Type: text/plain; charset=iso-8859-1 >> >> > Hello,Artyom:? ? My Java developers told me they solved the >> > cross-domain problem using JSONP. Does CppCMS support it? >> > I mean JSON_RPC over JSONP.?Or do you have any better >> > idea for this problem? >> >> CppCMS Supports JSON-RPC over HTTP via POST requests. >> >> So basically that means if you want to implement JSONP >> you will just to need to handle it on your own. >> >> It should be quite trivial to implement with existing >> JSON support. (See sample below) >> >> Now you should remember that: >> >> 1. JSONP may expose the application to many security problems. >> 2. GET requests have limited size this you'll have problems >> passing big parameters. >> >> So it should not be a problem to use but it has no real connection >> to JSON-RPC. >> >> Artyom >> -------------------------- >> >> void main(std::string url) >> { >> wrapper_function = request().get("jsonp"); >> std::string method = request().get("method"); >> cppcms::json::value params; >> { >> std::istringstream params(request().get("params")); >> if(!v.load(params,true)) { >> response().make_error_response(503); >> return; >> } >> } >> >> response.out() << wrapper_function <<'('; >> if(method=="sum") >> sum(v); >> else if >> ... >> response.out() << '); >> >> } >> void sum(json::value const &v) { >> int x = v[0].number(); >> int y = v[0].number(); >> json::value res = x+y; >> response.out() << res; >> } >> >> >> ------------- >> >> >> <script src=" >> http://someurl.com/rpc?method=sum&wrapper=parseRequest&parms=[10,20] >> "></script> >> >> >> >> >> >> >> >> >> ------------------------------ >> >> >> ------------------------------------------------------------------------------ >> Why Cloud-Based Security and Archiving Make Sense >> Osterman Research conducted this study that outlines how and why cloud >> computing security and archiving is rapidly being adopted across the IT >> space for its ease of implementation, lower cost, and increased >> reliability. Learn more. http://www.accelacomm.com/jaw/sfnl/114/51425301/ >> >> ------------------------------ >> >> _______________________________________________ >> Cppcms-users mailing list >> Cpp...@li... >> https://lists.sourceforge.net/lists/listinfo/cppcms-users >> >> >> End of Cppcms-users Digest, Vol 26, Issue 11 >> ******************************************** >> > > > > ------------------------------------------------------------------------------ > Malware Security Report: Protecting Your Business, Customers, and the > Bottom Line. Protect your business and customers by understanding the > threat from malware and how it can impact your online business. > http://www.accelacomm.com/jaw/sfnl/114/51427462/ > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > |
From: 刘怀宇 <mys...@gm...> - 2011-09-10 06:59:34
|
I'm so Sorry .I sent two emails to you, just read the second one! |
From: 刘怀宇 <mys...@gm...> - 2011-09-10 06:23:05
|
2011/9/10 刘怀宇 <mys...@gm...> > Hello Artyom , I try JSON_RPC over JSONP by the sample you proposed! > But I met a error when I use get() of the cppcms::http::request > std::string get<http://art-blog.no-ip.info/cppcms_ref_v0_99/classcppcms_1_1http_1_1request.html#9558b7cf069445329bf5c3a7cc8e4044> (std::string > const &name) > Here is the code: cppcms::http::request& r = request(); > string name = "method"; > r.get(name); > > The error is : Undefined reference to `cppcms::http::request::get(std::basic_string<char, > std::char_traits<char>, std::allocator<char> > const&)' > > I have already include the link library libcppcms.so .Do you hava any idea > about this problem? > > > 2011/9/9 <cpp...@li...> > > Send Cppcms-users mailing list submissions to >> cpp...@li... >> >> To subscribe or unsubscribe via the World Wide Web, visit >> https://lists.sourceforge.net/lists/listinfo/cppcms-users >> or, via email, send a message with subject or body 'help' to >> cpp...@li... >> >> You can reach the person managing the list at >> cpp...@li... >> >> When replying, please edit your Subject line so it is more specific >> than "Re: Contents of Cppcms-users digest..." >> >> >> Today's Topics: >> >> 1. Re: Cppcms-users Digest, Vol 26, Issue 8 (Artyom Beilis) >> >> >> ---------------------------------------------------------------------- >> >> Message: 1 >> Date: Thu, 8 Sep 2011 10:56:20 -0700 (PDT) >> From: Artyom Beilis <art...@ya...> >> Subject: Re: [Cppcms-users] Cppcms-users Digest, Vol 26, Issue 8 >> To: cpp...@li... >> Message-ID: >> <131...@we...> >> Content-Type: text/plain; charset=iso-8859-1 >> >> > Hello,Artyom:? ? My Java developers told me they solved the >> > cross-domain problem using JSONP. Does CppCMS support it? >> > I mean JSON_RPC over JSONP.?Or do you have any better >> > idea for this problem? >> >> CppCMS Supports JSON-RPC over HTTP via POST requests. >> >> So basically that means if you want to implement JSONP >> you will just to need to handle it on your own. >> >> It should be quite trivial to implement with existing >> JSON support. (See sample below) >> >> Now you should remember that: >> >> 1. JSONP may expose the application to many security problems. >> 2. GET requests have limited size this you'll have problems >> passing big parameters. >> >> So it should not be a problem to use but it has no real connection >> to JSON-RPC. >> >> Artyom >> -------------------------- >> >> void main(std::string url) >> { >> wrapper_function = request().get("jsonp"); >> std::string method = request().get("method"); >> cppcms::json::value params; >> { >> std::istringstream params(request().get("params")); >> if(!v.load(params,true)) { >> response().make_error_response(503); >> return; >> } >> } >> >> response.out() << wrapper_function <<'('; >> if(method=="sum") >> sum(v); >> else if >> ... >> response.out() << '); >> >> } >> void sum(json::value const &v) { >> int x = v[0].number(); >> int y = v[0].number(); >> json::value res = x+y; >> response.out() << res; >> } >> >> >> ------------- >> >> >> <script src=" >> http://someurl.com/rpc?method=sum&wrapper=parseRequest&parms=[10,20] >> "></script> >> >> >> >> >> >> >> >> >> ------------------------------ >> >> >> ------------------------------------------------------------------------------ >> Why Cloud-Based Security and Archiving Make Sense >> Osterman Research conducted this study that outlines how and why cloud >> computing security and archiving is rapidly being adopted across the IT >> space for its ease of implementation, lower cost, and increased >> reliability. Learn more. http://www.accelacomm.com/jaw/sfnl/114/51425301/ >> >> ------------------------------ >> >> _______________________________________________ >> Cppcms-users mailing list >> Cpp...@li... >> https://lists.sourceforge.net/lists/listinfo/cppcms-users >> >> >> End of Cppcms-users Digest, Vol 26, Issue 11 >> ******************************************** >> > > |
From: 刘怀宇 <mys...@gm...> - 2011-09-10 06:02:15
|
Hello Artyom , I try JSON_RPC over JSONP by the sample you proposed! cppcms::http::request& r = request(); string name = "method"; r.get(name); But I met a serious error. 2011/9/9 <cpp...@li...> > Send Cppcms-users mailing list submissions to > cpp...@li... > > To subscribe or unsubscribe via the World Wide Web, visit > https://lists.sourceforge.net/lists/listinfo/cppcms-users > or, via email, send a message with subject or body 'help' to > cpp...@li... > > You can reach the person managing the list at > cpp...@li... > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Cppcms-users digest..." > > > Today's Topics: > > 1. Re: Cppcms-users Digest, Vol 26, Issue 8 (Artyom Beilis) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Thu, 8 Sep 2011 10:56:20 -0700 (PDT) > From: Artyom Beilis <art...@ya...> > Subject: Re: [Cppcms-users] Cppcms-users Digest, Vol 26, Issue 8 > To: cpp...@li... > Message-ID: > <131...@we...> > Content-Type: text/plain; charset=iso-8859-1 > > > Hello,Artyom:? ? My Java developers told me they solved the > > cross-domain problem using JSONP. Does CppCMS support it? > > I mean JSON_RPC over JSONP.?Or do you have any better > > idea for this problem? > > CppCMS Supports JSON-RPC over HTTP via POST requests. > > So basically that means if you want to implement JSONP > you will just to need to handle it on your own. > > It should be quite trivial to implement with existing > JSON support. (See sample below) > > Now you should remember that: > > 1. JSONP may expose the application to many security problems. > 2. GET requests have limited size this you'll have problems > passing big parameters. > > So it should not be a problem to use but it has no real connection > to JSON-RPC. > > Artyom > -------------------------- > > void main(std::string url) > { > wrapper_function = request().get("jsonp"); > std::string method = request().get("method"); > cppcms::json::value params; > { > std::istringstream params(request().get("params")); > if(!v.load(params,true)) { > response().make_error_response(503); > return; > } > } > > response.out() << wrapper_function <<'('; > if(method=="sum") > sum(v); > else if > ... > response.out() << '); > > } > void sum(json::value const &v) { > int x = v[0].number(); > int y = v[0].number(); > json::value res = x+y; > response.out() << res; > } > > > ------------- > > > <script src=" > http://someurl.com/rpc?method=sum&wrapper=parseRequest&parms=[10,20] > "></script> > > > > > > > > > ------------------------------ > > > ------------------------------------------------------------------------------ > Why Cloud-Based Security and Archiving Make Sense > Osterman Research conducted this study that outlines how and why cloud > computing security and archiving is rapidly being adopted across the IT > space for its ease of implementation, lower cost, and increased > reliability. Learn more. http://www.accelacomm.com/jaw/sfnl/114/51425301/ > > ------------------------------ > > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > End of Cppcms-users Digest, Vol 26, Issue 11 > ******************************************** > |
From: Artyom B. <art...@ya...> - 2011-09-09 14:22:38
|
Hello, It is indeed frequently asked question. However it had no proper answer. So I took the limited tutorial in the wiki, checked it and extended it for 3 popular FOSS web servers Apache, Lighttpd and Nginx and now it seems to be correct and should work properly. http://art-blog.no-ip.info/wikipp/en/page/run_application_web_server_root Enjoy. Feel free to extend it if something does not work Artyom |
From: Artyom B. <art...@ya...> - 2011-09-08 17:56:27
|
> Hello,Artyom: My Java developers told me they solved the > cross-domain problem using JSONP. Does CppCMS support it? > I mean JSON_RPC over JSONP. Or do you have any better > idea for this problem? CppCMS Supports JSON-RPC over HTTP via POST requests. So basically that means if you want to implement JSONP you will just to need to handle it on your own. It should be quite trivial to implement with existing JSON support. (See sample below) Now you should remember that: 1. JSONP may expose the application to many security problems. 2. GET requests have limited size this you'll have problems passing big parameters. So it should not be a problem to use but it has no real connection to JSON-RPC. Artyom -------------------------- void main(std::string url) { wrapper_function = request().get("jsonp"); std::string method = request().get("method"); cppcms::json::value params; { std::istringstream params(request().get("params")); if(!v.load(params,true)) { response().make_error_response(503); return; } } response.out() << wrapper_function <<'('; if(method=="sum") sum(v); else if ... response.out() << '); } void sum(json::value const &v) { int x = v[0].number(); int y = v[0].number(); json::value res = x+y; response.out() << res; } ------------- <script src="http://someurl.com/rpc?method=sum&wrapper=parseRequest&parms=[10,20]"></script> |
From: 陈抒 <csf...@gm...> - 2011-09-08 14:06:33
|
Hello,Artyom: My Java developers told me they solved the cross-domain problem using JSONP. Does CppCMS support it? I mean JSON_RPC over JSONP. Or do you have any better idea for this problem? 陈抒 Best regards http://blog.csdn.net/sheismylife On Thu, Sep 8, 2011 at 5:24 PM, 刘怀宇 <mys...@gm...> wrote: > Thanks for your reply! > I found out that maybe it is just the Same Origin Policy related errors. > I used your HTML example ,and deploy it with json_rpc service in one cppcms > application. > have a see at my config.js > { > "service" : { > "api" : "http", > "port" : 8080 > }, > "http" : { > "script_names" : ["/jsonrpc","/html"] > } > } > We add two applications into cppcms application pool as following: > > 1. cppcms::service srv(argc,argv); > 2. > srv.applications_pool().mount(cppcms::applications_factory<my_hello_world>() , cppcms::mount_point(std::string( > "/html")) ); > 3. > srv.applications_pool().mount(cppcms::applications_factory<json_service>() , cppcms::mount_point(std::string( > "/jsonrpc")) ); > > So there are two applications in the same service but different URI. > I got the response from jsonrpc successfully by this method. > But if I request the jsonrpc service from another computer by javascript > ,it doesn't work. > Is it related to the Same Origin Policy ? > Is there any method to solve this problem? > > > 2011/9/7 <cpp...@li...> > >> Send Cppcms-users mailing list submissions to >> cpp...@li... >> >> To subscribe or unsubscribe via the World Wide Web, visit >> https://lists.sourceforge.net/lists/listinfo/cppcms-users >> or, via email, send a message with subject or body 'help' to >> cpp...@li... >> >> You can reach the person managing the list at >> cpp...@li... >> >> When replying, please edit your Subject line so it is more specific >> than "Re: Contents of Cppcms-users digest..." >> >> >> Today's Topics: >> >> 1. Can't get correct response from json rpc server when using >> javascript (???) >> 2. Re: Can't get correct response from json rpc server when >> using javascript (Artyom Beilis) >> >> >> ---------------------------------------------------------------------- >> >> Message: 1 >> Date: Wed, 7 Sep 2011 16:44:52 +0800 >> From: ??? <mys...@gm...> >> Subject: [Cppcms-users] Can't get correct response from json rpc >> server when using javascript >> To: cpp...@li... >> Message-ID: >> < >> CAM...@ma...> >> Content-Type: text/plain; charset="iso-8859-1" >> >> Hello >> There is a json rpc example in cppcms project. Now I want to send json_rpc >> request using javascript , but it doesn't work. >> I found that the Content-Type field of the HttpRequest message must be >> "application/json" for cppcms application ,otherwise I got error messages >> as follows " invalid content type " >> And I tested successfully by python(in tests dir) and curl command >> >> 1.python: >> >> def test(name,A,B): >> if A != B: >> print "Error :" + name >> print "-----Actual--" >> print A,"---Expected--" >> print B,"-------------" >> sys.exit(1) >> else: >> print "Ok:"+name >> >> def test_status(h,stat): >> if h.status != stat: >> print "Status mistmatch:",h.status,"!=",stat >> sys.exit(1) >> >> def test_valid(name,params,ans,method='POST'): >> h=httplib.HTTPConnection('192.168.30.17:8080'); >> headers = {"Content-type": "application/json"} >> h.request(method,'/rpc',params,headers) >> r=h.getresponse() >> test(name,r.read(),ans) >> >> test_valid('sum','{"method" : "sum" , "params" : [ 1, 2 ], "id" : >> 1}','{"id":1,"error":null,"result":3}') >> >> 2.curl command: >> curl -i -X POST --header "Content-Type:application/json" -d >> '{"method":"sum","params":[1,2],"id":1}' http://192.168.30.17:8080/rpc >> >> They both succeeded. >> >> But I can't get correct response by using javascript.The following code >> has >> been tested in IE8 , Chrome13 and firefox6.It only success in IE8. >> >> var xhr = new XMLHttpRequest(); >> var rpcUrl = 'http://192.168.30.17:8080/rpc'; >> var postData = '{"method":"sum","params":[1,2],"id":1}'; >> >> xhr.open("post", rpcUrl, true); >> >> xhr.setRequestHeader("Content-Type","application/json"); >> >> xhr.onreadystatechange = function() { >> if (xhr.readyState === 4) { >> if (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) { >> alert(xhr.responseText) >> } >> } >> } >> xhr.send(postData); >> >> Maybe the problem is that I can't set the "Content-Type" as >> "application/json" successfully in Chrome and Firefox. >> >> Do you have any experience about ajax? >> Or just give me an idea! >> -------------- next part -------------- >> An HTML attachment was scrubbed... >> >> ------------------------------ >> >> Message: 2 >> Date: Wed, 7 Sep 2011 03:02:34 -0700 (PDT) >> From: Artyom Beilis <art...@ya...> >> Subject: Re: [Cppcms-users] Can't get correct response from json rpc >> server when using javascript >> To: "cpp...@li..." >> <cpp...@li...> >> Message-ID: >> <131...@we...> >> Content-Type: text/plain; charset="utf-8" >> >> Actually I don't see any specific reason why wouldn't it work. >> Are you sure you don't have Same Origin Policy related errors? >> >> I've added an HTML example of JSON RPC service in the json_rpc examples >> directory: >> >> ?? >> http://cppcms.svn.sourceforge.net/viewvc/cppcms/framework/trunk/examples/json_rpc/index.html?view=markup >> >> ? >> Artyom Beilis >> >> >> >> >________________________________ >> >From: ??? <mys...@gm...> >> >To: cpp...@li... >> >Sent: Wednesday, September 7, 2011 11:44 AM >> >Subject: [Cppcms-users] Can't get correct response from json rpc server >> when using javascript >> > >> > >> >Hello?There is a json rpc example in cppcms project. Now I want to send >> json_rpc request ?using javascript , but it doesn't work. >> >?I found that the Content-Type field of the HttpRequest message must be >> "application/json" for ?cppcms application ,otherwise I got error messages >> as follows ?" invalid content type "? >> >And I tested ?successfully by python(in tests dir) and curl command >> > >> > >> >1.python: >> > >> > >> >def test(name,A,B): >> >? ? if A != B: >> >? ? ? ? print "Error :" + name? >> >? ? ? ? print "-----Actual--" >> >? ? ? ? print A,"---Expected--" >> >? ? ? ? print B,"-------------" >> >? ? ? ? sys.exit(1) >> >? ? else: >> >? ? ? ? print "Ok:"+name >> > >> > >> >def test_status(h,stat): >> >? ? if h.status != stat: >> >? ? ? ? print "Status mistmatch:",h.status,"!=",stat >> >? ? ? ? sys.exit(1) >> > >> > >> >def test_valid(name,params,ans,method='POST'): >> >? ? h=httplib.HTTPConnection(' 192.168.30.17:8080'); >> >? ? headers = {"Content-type": "application/json"} >> >? ? h.request(method,'/rpc',params,headers) >> >? ? r=h.getresponse() >> >? ? test(name,r.read(),ans) >> > >> > >> >test_valid('sum','{"method" : "sum" , "params" : [ 1, 2 ], "id" : >> 1}','{"id":1,"error":null,"result":3}') >> > >> > >> >2.curl command: >> >?curl -i -X POST --header "Content-Type:application/json" -d >> '{"method":"sum","params":[1,2],"id":1}' http://192.168.30.17:8080/rpc >> > >> > >> >They both succeeded. >> > >> > >> >But I can't get correct response by using ?javascript.The following code >> has been tested in IE8 , Chrome13 and firefox6.It only success in IE8. >> > >> > >> >var xhr = new XMLHttpRequest(); >> >var rpcUrl = 'http://192.168.30.17:8080/rpc'; >> >var postData = '{"method":"sum","params":[1,2],"id":1}'; >> > >> >xhr.open("post", rpcUrl, true); >> > >> >xhr.setRequestHeader("Content-Type","application/json"); >> > >> >xhr.onreadystatechange = function() { >> >if (xhr.readyState === 4) { >> >if (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) { >> >alert(xhr.responseText) >> >} >> >} >> >} >> >xhr.send(postData);? >> > >> > >> >Maybe the problem is that I can't set the "Content-Type" as >> "application/json" successfully in Chrome and Firefox. >> > >> > >> >Do you have any experience about ajax? >> >Or just give me an idea! >> > >> > >> > >> > >> >> >------------------------------------------------------------------------------ >> >Using storage to extend the benefits of virtualization and iSCSI >> >Virtualization increases hardware utilization and delivers a new level of >> >agility. Learn what those decisions are and how to modernize your storage >> >and backup environments for virtualization. >> >http://www.accelacomm.com/jaw/sfnl/114/51434361/ >> >_______________________________________________ >> >Cppcms-users mailing list >> >Cpp...@li... >> >https://lists.sourceforge.net/lists/listinfo/cppcms-users >> > >> > >> > >> -------------- next part -------------- >> An HTML attachment was scrubbed... >> >> ------------------------------ >> >> >> ------------------------------------------------------------------------------ >> Using storage to extend the benefits of virtualization and iSCSI >> Virtualization increases hardware utilization and delivers a new level of >> agility. Learn what those decisions are and how to modernize your storage >> and backup environments for virtualization. >> http://www.accelacomm.com/jaw/sfnl/114/51434361/ >> >> ------------------------------ >> >> _______________________________________________ >> Cppcms-users mailing list >> Cpp...@li... >> https://lists.sourceforge.net/lists/listinfo/cppcms-users >> >> >> End of Cppcms-users Digest, Vol 26, Issue 8 >> ******************************************* >> > > > > ------------------------------------------------------------------------------ > Doing More with Less: The Next Generation Virtual Desktop > What are the key obstacles that have prevented many mid-market businesses > from deploying virtual desktops? How do next-generation virtual desktops > provide companies an easier-to-deploy, easier-to-manage and more affordable > virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/ > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > |
From: 刘怀宇 <mys...@gm...> - 2011-09-08 09:24:37
|
Thanks for your reply! I found out that maybe it is just the Same Origin Policy related errors. I used your HTML example ,and deploy it with json_rpc service in one cppcms application. have a see at my config.js { "service" : { "api" : "http", "port" : 8080 }, "http" : { "script_names" : ["/jsonrpc","/html"] } } We add two applications into cppcms application pool as following: 1. cppcms::service srv(argc,argv); 2. srv.applications_pool().mount(cppcms::applications_factory<my_hello_world>() , cppcms::mount_point(std::string( "/html")) ); 3. srv.applications_pool().mount(cppcms::applications_factory<json_service>() , cppcms::mount_point(std::string( "/jsonrpc")) ); So there are two applications in the same service but different URI. I got the response from jsonrpc successfully by this method. But if I request the jsonrpc service from another computer by javascript ,it doesn't work. Is it related to the Same Origin Policy ? Is there any method to solve this problem? 2011/9/7 <cpp...@li...> > Send Cppcms-users mailing list submissions to > cpp...@li... > > To subscribe or unsubscribe via the World Wide Web, visit > https://lists.sourceforge.net/lists/listinfo/cppcms-users > or, via email, send a message with subject or body 'help' to > cpp...@li... > > You can reach the person managing the list at > cpp...@li... > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Cppcms-users digest..." > > > Today's Topics: > > 1. Can't get correct response from json rpc server when using > javascript (???) > 2. Re: Can't get correct response from json rpc server when > using javascript (Artyom Beilis) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Wed, 7 Sep 2011 16:44:52 +0800 > From: ??? <mys...@gm...> > Subject: [Cppcms-users] Can't get correct response from json rpc > server when using javascript > To: cpp...@li... > Message-ID: > <CAM...@ma... > > > Content-Type: text/plain; charset="iso-8859-1" > > Hello > There is a json rpc example in cppcms project. Now I want to send json_rpc > request using javascript , but it doesn't work. > I found that the Content-Type field of the HttpRequest message must be > "application/json" for cppcms application ,otherwise I got error messages > as follows " invalid content type " > And I tested successfully by python(in tests dir) and curl command > > 1.python: > > def test(name,A,B): > if A != B: > print "Error :" + name > print "-----Actual--" > print A,"---Expected--" > print B,"-------------" > sys.exit(1) > else: > print "Ok:"+name > > def test_status(h,stat): > if h.status != stat: > print "Status mistmatch:",h.status,"!=",stat > sys.exit(1) > > def test_valid(name,params,ans,method='POST'): > h=httplib.HTTPConnection('192.168.30.17:8080'); > headers = {"Content-type": "application/json"} > h.request(method,'/rpc',params,headers) > r=h.getresponse() > test(name,r.read(),ans) > > test_valid('sum','{"method" : "sum" , "params" : [ 1, 2 ], "id" : > 1}','{"id":1,"error":null,"result":3}') > > 2.curl command: > curl -i -X POST --header "Content-Type:application/json" -d > '{"method":"sum","params":[1,2],"id":1}' http://192.168.30.17:8080/rpc > > They both succeeded. > > But I can't get correct response by using javascript.The following code > has > been tested in IE8 , Chrome13 and firefox6.It only success in IE8. > > var xhr = new XMLHttpRequest(); > var rpcUrl = 'http://192.168.30.17:8080/rpc'; > var postData = '{"method":"sum","params":[1,2],"id":1}'; > > xhr.open("post", rpcUrl, true); > > xhr.setRequestHeader("Content-Type","application/json"); > > xhr.onreadystatechange = function() { > if (xhr.readyState === 4) { > if (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) { > alert(xhr.responseText) > } > } > } > xhr.send(postData); > > Maybe the problem is that I can't set the "Content-Type" as > "application/json" successfully in Chrome and Firefox. > > Do you have any experience about ajax? > Or just give me an idea! > -------------- next part -------------- > An HTML attachment was scrubbed... > > ------------------------------ > > Message: 2 > Date: Wed, 7 Sep 2011 03:02:34 -0700 (PDT) > From: Artyom Beilis <art...@ya...> > Subject: Re: [Cppcms-users] Can't get correct response from json rpc > server when using javascript > To: "cpp...@li..." > <cpp...@li...> > Message-ID: > <131...@we...> > Content-Type: text/plain; charset="utf-8" > > Actually I don't see any specific reason why wouldn't it work. > Are you sure you don't have Same Origin Policy related errors? > > I've added an HTML example of JSON RPC service in the json_rpc examples > directory: > > ?? > http://cppcms.svn.sourceforge.net/viewvc/cppcms/framework/trunk/examples/json_rpc/index.html?view=markup > > ? > Artyom Beilis > > > > >________________________________ > >From: ??? <mys...@gm...> > >To: cpp...@li... > >Sent: Wednesday, September 7, 2011 11:44 AM > >Subject: [Cppcms-users] Can't get correct response from json rpc server > when using javascript > > > > > >Hello?There is a json rpc example in cppcms project. Now I want to send > json_rpc request ?using javascript , but it doesn't work. > >?I found that the Content-Type field of the HttpRequest message must be > "application/json" for ?cppcms application ,otherwise I got error messages > as follows ?" invalid content type "? > >And I tested ?successfully by python(in tests dir) and curl command > > > > > >1.python: > > > > > >def test(name,A,B): > >? ? if A != B: > >? ? ? ? print "Error :" + name? > >? ? ? ? print "-----Actual--" > >? ? ? ? print A,"---Expected--" > >? ? ? ? print B,"-------------" > >? ? ? ? sys.exit(1) > >? ? else: > >? ? ? ? print "Ok:"+name > > > > > >def test_status(h,stat): > >? ? if h.status != stat: > >? ? ? ? print "Status mistmatch:",h.status,"!=",stat > >? ? ? ? sys.exit(1) > > > > > >def test_valid(name,params,ans,method='POST'): > >? ? h=httplib.HTTPConnection(' 192.168.30.17:8080'); > >? ? headers = {"Content-type": "application/json"} > >? ? h.request(method,'/rpc',params,headers) > >? ? r=h.getresponse() > >? ? test(name,r.read(),ans) > > > > > >test_valid('sum','{"method" : "sum" , "params" : [ 1, 2 ], "id" : > 1}','{"id":1,"error":null,"result":3}') > > > > > >2.curl command: > >?curl -i -X POST --header "Content-Type:application/json" -d > '{"method":"sum","params":[1,2],"id":1}' http://192.168.30.17:8080/rpc > > > > > >They both succeeded. > > > > > >But I can't get correct response by using ?javascript.The following code > has been tested in IE8 , Chrome13 and firefox6.It only success in IE8. > > > > > >var xhr = new XMLHttpRequest(); > >var rpcUrl = 'http://192.168.30.17:8080/rpc'; > >var postData = '{"method":"sum","params":[1,2],"id":1}'; > > > >xhr.open("post", rpcUrl, true); > > > >xhr.setRequestHeader("Content-Type","application/json"); > > > >xhr.onreadystatechange = function() { > >if (xhr.readyState === 4) { > >if (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) { > >alert(xhr.responseText) > >} > >} > >} > >xhr.send(postData);? > > > > > >Maybe the problem is that I can't set the "Content-Type" as > "application/json" successfully in Chrome and Firefox. > > > > > >Do you have any experience about ajax? > >Or just give me an idea! > > > > > > > > > > >------------------------------------------------------------------------------ > >Using storage to extend the benefits of virtualization and iSCSI > >Virtualization increases hardware utilization and delivers a new level of > >agility. Learn what those decisions are and how to modernize your storage > >and backup environments for virtualization. > >http://www.accelacomm.com/jaw/sfnl/114/51434361/ > >_______________________________________________ > >Cppcms-users mailing list > >Cpp...@li... > >https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > > > > > -------------- next part -------------- > An HTML attachment was scrubbed... > > ------------------------------ > > > ------------------------------------------------------------------------------ > Using storage to extend the benefits of virtualization and iSCSI > Virtualization increases hardware utilization and delivers a new level of > agility. Learn what those decisions are and how to modernize your storage > and backup environments for virtualization. > http://www.accelacomm.com/jaw/sfnl/114/51434361/ > > ------------------------------ > > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > End of Cppcms-users Digest, Vol 26, Issue 8 > ******************************************* > |
From: Artyom B. <art...@ya...> - 2011-09-07 10:02:42
|
Actually I don't see any specific reason why wouldn't it work. Are you sure you don't have Same Origin Policy related errors? I've added an HTML example of JSON RPC service in the json_rpc examples directory: http://cppcms.svn.sourceforge.net/viewvc/cppcms/framework/trunk/examples/json_rpc/index.html?view=markup Artyom Beilis >________________________________ >From: 刘怀宇 <mys...@gm...> >To: cpp...@li... >Sent: Wednesday, September 7, 2011 11:44 AM >Subject: [Cppcms-users] Can't get correct response from json rpc server when using javascript > > >Hello There is a json rpc example in cppcms project. Now I want to send json_rpc request using javascript , but it doesn't work. > I found that the Content-Type field of the HttpRequest message must be "application/json" for cppcms application ,otherwise I got error messages as follows " invalid content type " >And I tested successfully by python(in tests dir) and curl command > > >1.python: > > >def test(name,A,B): > if A != B: > print "Error :" + name > print "-----Actual--" > print A,"---Expected--" > print B,"-------------" > sys.exit(1) > else: > print "Ok:"+name > > >def test_status(h,stat): > if h.status != stat: > print "Status mistmatch:",h.status,"!=",stat > sys.exit(1) > > >def test_valid(name,params,ans,method='POST'): > h=httplib.HTTPConnection(' 192.168.30.17:8080'); > headers = {"Content-type": "application/json"} > h.request(method,'/rpc',params,headers) > r=h.getresponse() > test(name,r.read(),ans) > > >test_valid('sum','{"method" : "sum" , "params" : [ 1, 2 ], "id" : 1}','{"id":1,"error":null,"result":3}') > > >2.curl command: > curl -i -X POST --header "Content-Type:application/json" -d '{"method":"sum","params":[1,2],"id":1}' http://192.168.30.17:8080/rpc > > >They both succeeded. > > >But I can't get correct response by using javascript.The following code has been tested in IE8 , Chrome13 and firefox6.It only success in IE8. > > >var xhr = new XMLHttpRequest(); >var rpcUrl = 'http://192.168.30.17:8080/rpc'; >var postData = '{"method":"sum","params":[1,2],"id":1}'; > >xhr.open("post", rpcUrl, true); > >xhr.setRequestHeader("Content-Type","application/json"); > >xhr.onreadystatechange = function() { >if (xhr.readyState === 4) { >if (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) { >alert(xhr.responseText) >} >} >} >xhr.send(postData); > > >Maybe the problem is that I can't set the "Content-Type" as "application/json" successfully in Chrome and Firefox. > > >Do you have any experience about ajax? >Or just give me an idea! > > > > >------------------------------------------------------------------------------ >Using storage to extend the benefits of virtualization and iSCSI >Virtualization increases hardware utilization and delivers a new level of >agility. Learn what those decisions are and how to modernize your storage >and backup environments for virtualization. >http://www.accelacomm.com/jaw/sfnl/114/51434361/ >_______________________________________________ >Cppcms-users mailing list >Cpp...@li... >https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > |
From: 刘怀宇 <mys...@gm...> - 2011-09-07 08:45:00
|
Hello There is a json rpc example in cppcms project. Now I want to send json_rpc request using javascript , but it doesn't work. I found that the Content-Type field of the HttpRequest message must be "application/json" for cppcms application ,otherwise I got error messages as follows " invalid content type " And I tested successfully by python(in tests dir) and curl command 1.python: def test(name,A,B): if A != B: print "Error :" + name print "-----Actual--" print A,"---Expected--" print B,"-------------" sys.exit(1) else: print "Ok:"+name def test_status(h,stat): if h.status != stat: print "Status mistmatch:",h.status,"!=",stat sys.exit(1) def test_valid(name,params,ans,method='POST'): h=httplib.HTTPConnection('192.168.30.17:8080'); headers = {"Content-type": "application/json"} h.request(method,'/rpc',params,headers) r=h.getresponse() test(name,r.read(),ans) test_valid('sum','{"method" : "sum" , "params" : [ 1, 2 ], "id" : 1}','{"id":1,"error":null,"result":3}') 2.curl command: curl -i -X POST --header "Content-Type:application/json" -d '{"method":"sum","params":[1,2],"id":1}' http://192.168.30.17:8080/rpc They both succeeded. But I can't get correct response by using javascript.The following code has been tested in IE8 , Chrome13 and firefox6.It only success in IE8. var xhr = new XMLHttpRequest(); var rpcUrl = 'http://192.168.30.17:8080/rpc'; var postData = '{"method":"sum","params":[1,2],"id":1}'; xhr.open("post", rpcUrl, true); xhr.setRequestHeader("Content-Type","application/json"); xhr.onreadystatechange = function() { if (xhr.readyState === 4) { if (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) { alert(xhr.responseText) } } } xhr.send(postData); Maybe the problem is that I can't set the "Content-Type" as "application/json" successfully in Chrome and Firefox. Do you have any experience about ajax? Or just give me an idea! |
From: David E. <dav...@gm...> - 2011-09-06 05:25:12
|
@Augustin no hard feelings :) I assure you that once I have any useful information I will be adding it to the wiki... As for the configuration (I've finally gotten around to it) It's almost working (lol?) I'm getting the following error out of lighttpd (I'm not even trying the mod rewrite webroot thing yet): *Error:* 2011-09-06 01:10:24: (request.c.304) fd: 6 request-len: 454 GET /blog HTTP/1.1 Host: 192.168.1.144 Connection: keep-alive X-Purpose: instant User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.865.1000 Safari/535.2 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Encoding: gzip,deflate,sdch Accept-Language: en-US,en;q=0.8 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 Cookie: player-61646d696e=5; JSESSIONID=10a4mv8znmlna 2011-09-06 01:10:24: (response.c.300) -- splitting Request-URI 2011-09-06 01:10:24: (response.c.301) Request-URI : /blog 2011-09-06 01:10:24: (response.c.302) URI-scheme : http 2011-09-06 01:10:24: (response.c.303) URI-authority: 192.168.1.144 2011-09-06 01:10:24: (response.c.304) URI-path : /blog 2011-09-06 01:10:24: (response.c.305) URI-query : 2011-09-06 01:10:24: (response.c.349) -- sanatising URI 2011-09-06 01:10:24: (response.c.350) URI-path : /blog 2011-09-06 01:10:24: (mod_access.c.135) -- mod_access_uri_handler called 2011-09-06 01:10:24: (mod_fastcgi.c.3636) handling it in mod_fastcgi 2011-09-06 01:10:24: (response.c.470) -- before doc_root 2011-09-06 01:10:24: (response.c.471) Doc-Root : /var/www 2011-09-06 01:10:24: (response.c.472) Rel-Path : /blog 2011-09-06 01:10:24: (response.c.473) Path : 2011-09-06 01:10:24: (response.c.521) -- after doc_root 2011-09-06 01:10:24: (response.c.522) Doc-Root : /var/www 2011-09-06 01:10:24: (response.c.523) Rel-Path : /blog 2011-09-06 01:10:24: (response.c.524) Path : /var/www/blog 2011-09-06 01:10:24: (response.c.541) -- logical -> physical 2011-09-06 01:10:24: (response.c.542) Doc-Root : /var/www 2011-09-06 01:10:24: (response.c.543) Rel-Path : /blog 2011-09-06 01:10:24: (response.c.544) Path : /var/www/blog 2011-09-06 01:10:25: (response.c.128) Response-Header: HTTP/1.1 500 Internal Server Error Content-Encoding: gzip Content-Type: text/html; charset=utf-8 X-Powered-By: CppCMS/0.99.9 Transfer-Encoding: chunked Date: Tue, 06 Sep 2011 05:10:25 GMT Server: lighttpd/1.4.28 my *config.js* looks like this: "blog" : { "media" : "/media", "root" : "/blog", "host" : "192.168.1.144:8080", "connection_string" : "sqlite3:db=cppcms.db;@pool_size=10", //"connection_string" : "mysql:database=newpress;user=root;password=root;@pool_size=10;@use_prepared =on", "tex" : { "enable" : true, //"latex" : "/usr/bin/latex", // "dvigif" : "/usr/bin/dvigif", // "temp_dir" : "/tmp", // "output_dir" : "/var/www/media/tex" } }, "service" : { "api" : "fastcgi", //"ip" : "192.168.1.144", //"port" : 12345 //"port" : 8080 //"api" : "fastcgi", //"api" : "scgi", //"socket" : "/tmp/sock" "socket" : "stdin" }, "http" : { "script" : "/blog" }, "views" : { "default_skin" : "contendend" , //"default_skin" : "orangesky" , "paths" : [ "./" ], "skins" : [ "contendend" , "orangesky" ], }, "file_server" : { "enable" : true, "document_root" : "../" }, "session" : { "expire" : "renew", "timeout" : 604800, // a week "location" : "both", "client" : { "hmac" : "sha1", "hmac_key" : "232074faa0fd37de20858bf8cd0a7d10" }, "server" : { "storage" : "files" } }, "cache" : { "backend" : "thread_shared", "limit" : 100, }, "localization" : { "messages" : { "paths" : [ "./locale" ], "domains" : [ "blog" ] }, "locales" : [ //"he_IL.UTF-8", "en_US.UTF-8", ] } } And the relevant part of *lighttpd.conf* that I have is: fastcgi.server = ( ## The script name of the application "/blog" => (( ## Command line to run "bin-path" => "/opt/blog -c /opt/config.js", "socket" => "/tmp/hello-fcgi-socket", ## Important - only one process should start "max-procs" => 1, "check-local" => "disable" )) ) Any thoughts? -elrom On Sat, Sep 3, 2011 at 5:21 PM, David Elrom <dav...@gm...> wrote: > > On Sat, Sep 3, 2011 at 7:40 AM, Artyom Beilis <art...@ya...> wrote: > >> > >> > So, I went ahead and did a quick copy/paste of the >> > information contributed so >> > far into a new wiki page: >> > >> http://art-blog.no-ip.info/wikipp/en/page/run_application_web_server_root >> > The page can be improved as required over time... >> > >> > linked from: http://art-blog.no-ip.info/wikipp/en/page/cppcms_1x >> > >> > I rearranged the TOC in the 1.x.x menu page, so that there >> > is some logical >> > order: >> > 1) install cppcms. >> > 2) configure the web server. >> > 3) tutorials with more advanced topics. >> > 4) references... >> > >> > >> > The page can be improved as required over time... >> > >> > >> > Augustin. >> > >> > >> > >> >> Thanks, >> >> Artyom >> >> >> >> ------------------------------------------------------------------------------ >> Special Offer -- Download ArcSight Logger for FREE! >> Finally, a world-class log management solution at an even better >> price-free! And you'll get a free "Love Thy Logs" t-shirt when you >> download Logger. Secure your free ArcSight Logger TODAY! >> http://p.sf.net/sfu/arcsisghtdev2dev >> _______________________________________________ >> Cppcms-users mailing list >> Cpp...@li... >> https://lists.sourceforge.net/lists/listinfo/cppcms-users >> > > > Ouch augustin. > > No, I never even got a chance to look at Artyom's response for lighttpd, > let alone configure / test it. > > -elrom > |
From: Daniel V. <chi...@gm...> - 2011-09-05 21:06:10
|
On Mon, 2011-09-05 at 12:38 -0700, Artyom Beilis wrote: > You already can bind any callback of type > > typedef booster::function<void(json::array const &)> method_type > > It allows you to do 0 copy Great. > > > 2) And could response json values without copy operation cost. > > That is cppcms::rpc::json_rpc_server could have the > > following methods: > > void return_result( json::object const & o); > > void return_result( json::array const & a); > > void return_result( std::string const & s); > > Why not to create json::value that can be json object in first > place? Yes, that's what I do: json::value result = json::array(); json::array& result_arr = result.array(); result_arr.push_back("123"); return_result(result); For me it's more clear the following theoretical code: json::array& result; result.push_back("123"); return_result(result); But it's not big deal. > > > > 3) Add the possibility to a json::value > > object to point to an exists json::object, > > json::array or json::string. That is > > required for access the facilities > > that have json::value methods without copy operation. > > This would require entirely different and not always > clear semantics. > > Currently json::* is value type and I'm not sure that > adding non-value semantics would not make it dangerous. > > What happens on copy? Shallow or deep? > Yes, it's not clear. But for me, copy is a copy. > On the other hand you can do > > json::value my_huge_value; > foo["bar"]["bee"].swap(my_huge_value) > Yes, I use swap. But if the values are const, we can't use swap. > Which provides move semantics and reduce the > need of copy. > > > For example, currently, if I want to print a json::array I have to do: > > json::array a; > > > > //... > > > > json::value v = a; > > > > std::cout << v; > > Why not: > > > json::value v = json::array(); > v.array().swap(a); > std::cout << v; > Yes, my example is not good. What about this example? void print(json::array const& a) { json::value v = a; std::cout << v; } My ugly solution is: void print(json::array const& a) { json::value v = json::array(); json::array* array_ptr = const_cast<json::array*>(&a); v.array().swap(*array_ptr); std::cout << v; v.array().swap(*array_ptr); } > > > This leads to an unnecessarily copy operation. I suggest adding the > > following methods to json::value class > > You can use move semantics with swap member functions. > > The semantics change you suggest is too radical. > > Same can be done for example with reimplementing > json using tree of shared_ptr's but it would lead to different > semantics. > > I don't think I want to touch this. Ok. Thank you for you great work. Good bye. |
From: Artyom B. <art...@ya...> - 2011-09-05 19:38:14
|
> 1) The RPC method could receive > parameters that are json values > without copy operation cost. For example: > > using namespace cppcms; > > void my_json_rpc_method( json::object& o, > json::array& a, std::string& s); > You already can bind any callback of type typedef booster::function<void(json::array const &)> method_type It allows you to do 0 copy > 2) And could response json values without copy operation cost. > That is cppcms::rpc::json_rpc_server could have the > following methods: > void return_result( json::object const & o); > void return_result( json::array const & a); > void return_result( std::string const & s); Why not to create json::value that can be json object in first place? > 3) Add the possibility to a json::value > object to point to an exists json::object, > json::array or json::string. That is > required for access the facilities > that have json::value methods without copy operation. This would require entirely different and not always clear semantics. Currently json::* is value type and I'm not sure that adding non-value semantics would not make it dangerous. What happens on copy? Shallow or deep? On the other hand you can do json::value my_huge_value; foo["bar"]["bee"].swap(my_huge_value) Which provides move semantics and reduce the need of copy. > For example, currently, if I want to print a json::array I have to do: > json::array a; > > //... > > json::value v = a; > > std::cout << v; Why not: json::value v = json::array(); v.array().swap(a); std::cout << v; > This leads to an unnecessarily copy operation. I suggest adding the > following methods to json::value class You can use move semantics with swap member functions. The semantics change you suggest is too radical. Same can be done for example with reimplementing json using tree of shared_ptr's but it would lead to different semantics. I don't think I want to touch this. > Cppdb First CppDB is not part of libcppcms and developed independently. so this is not really question about CppDB. > 4 ) Boost fusion integration. > Posibility to fetch fusion sequences > from cppdb::result, for example: Ok... This would I say big... huge, giant NO. Several reasons. 1. Boost has huge drawback not being backward compatible neither in ABI nor in API between its releases and tend to break API every 3-4 month. You probably had already noticed that Boost is never used in CppCMS and CppDB API. And there is good reason for this. 2. Things like Fusion, Proto and some other "friends" lead to enormous compilation times and do not provide too much help. > template <typename T> > void fetch_sequence(cppdb::result& r, T& t ) > boost::fusion::for_each(t, fetch_functor(r) ); > }http:// Why not create a simple project of "Boost CppDB binders" of such type. Also one of the advantages I see in CppDB is clear and simple API with some syntactic sugar. I want things like Fusion, Proto and other Boost crap to stay away from my libraries. They makes code to compile for hours, lead to unreadable error messages. Don't get me wrong, Boost is great project but some parts should be taken with great care. I don't want to scare away my users. > 5) Add the posibility to the library client to extend > fetch and bind to custom types. For example add the > following interface for fetch custom types: Custom value? Object? How do you bind its members? by name? by position? What about partial updates? Biding by name slow (yep) binding by position is not really possible for non-trivial queries.. See CppDB is not ORM and is not meant to be such thing. > Library user code for boost::optional fetch: Actually probably Boost.Optional is the only thing that seems to be useful there as replacement of NULL values. But currently I prefer CppDB not to depend on Boost at all. If I decide to submit it to Boost the sate may change but not at this point (too much headache) Best, Artyom |
From: Daniel V. <chi...@gm...> - 2011-09-05 18:06:54
|
Hello. Apologies for my english. Features required: json RPC 1) The RPC method could receive parameters that are json values without copy operation cost. For example: using namespace cppcms; void my_json_rpc_method( json::object& o, json::array& a, std::string& s); 2) And could response json values without copy operation cost. That is cppcms::rpc::json_rpc_server could have the following methods: void return_result( json::object const & o); void return_result( json::array const & a); void return_result( std::string const & s); Json Values 3) Add the possibility to a json::value object to point to an exists json::object, json::array or json::string. That is required for access the facilities that have json::value methods without copy operation. For example, currently, if I want to print a json::array I have to do: json::array a; //... json::value v = a; std::cout << v; This leads to an unnecessarily copy operation. I suggest adding the following methods to json::value class void wrap(json::object& o); void wrap(json::array& a); void wrap(string& s); void wrap(json::object const& o) const; void wrap(json::array const& a) const; void wrap(string const& s) const; Cppdb 4 ) Boost fusion integration. Posibility to fetch fusion sequences from cppdb::result, for example: typedef boost::fusion::vector< int, string, string> row_t; cppdb::result r = sql << "SELECT id, user, location FROM my_table"; row_t row; fetch_sequence(r, row); My implementation: #include <cppdb/frontend.h> #include <boost/fusion/include/for_each.hpp> #include <boost/fusion/include/is_sequence.hpp> template <typename T> inline bool fetch(cppdb::result& r, T& x) { return r.fetch(x); } class fetch_functor { public: fetch_functor(cppdb::result& r); template <typename T> void operator()(T& x) const { fetch(result_, x); } private: cppdb::result& result_; }; template <typename T> void fetch_sequence(cppdb::result& r, T& t ) { BOOST_MPL_ASSERT(( boost::fusion::traits::is_sequence<T> )); boost::fusion::for_each(t, fetch_functor(r) ); }http:// 5) Add the posibility to the library client to extend fetch and bind to custom types. For example add the following interface for fetch custom types: class CPPDB_API result { public: //... template <typename T> bool fetch(T& t) { return fetch(*this, t); } //... }; Library user code for boost::optional fetch: namespace cppdb { template<typename T> bool fetch( result& r, boost::optional<T>& opt) { opt = T(); // WARNING: only for types with constructor without arguments. if ( ! r.fetch(opt.get()) ) { opt = boost::none; } return true; // Always true } } And finally the same kind of interface for bind. Thanks you. |
From: Artyom B. <art...@ya...> - 2011-09-05 08:04:12
|
Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.sf.net/ CppDB - C++ SQL Connectivity: http://cppcms.sf.net/sql/cppdb/ ----- Original Message ----- > From: kpeo <sla...@ya...> > To: cpp...@li... > Cc: > Sent: Monday, September 5, 2011 9:37 AM > Subject: Re: [Cppcms-users] dynamic shared views > >G reat, thank you! > Believe, url_mapping & dispatcher should also work with loadable modules - > check it soon.. > Currently URL Mapper and URL dispatched do not support detaching URLs same as applications_pool do not support detaching application_factories. So if you load application plug-in you will not be able to unload it. it without stopping the service. > 05.09.2011, 08:44, "Artyom Beilis" <art...@ya...>: >> ----- Original Message ----- >> >>> From: kpeo <sla...@ya...> >>> To: cpp...@li... >>> Cc: >>> Sent: Sunday, September 4, 2011 9:20 PM >>> Subject: [Cppcms-users] dynamic shared views >>> >>> Artyom, >>> >>> Is there way in engine of dynamically loading additional shared libs > with view? >>> I.e. i know how to load shared library and call some class function in > it, but >>> if i want to extend current view with pluggable one at runtime - > whether >>> it's possible with current version? >>> >>> Regards, >>> kpeo >> >> Actually it is possible even with current version. >> >> All view that is linked to executable is automatically >> registered (using global constructor) to the central >> singleton class that holds all views and unregistered >> when unloaded. >> >> So it is just enough to link the view to the plugin's >> shared object or load it as shared object of the view >> and you get it. >> >> Currently the code behind all this stuff is quite ugly >> and is going to be rewritten - code cleanup >> (it is the 1st or the 2nd task in the list) >> but the behavior would remain the same. >> >> And then it will be properly documented. >> >> The only restriction is that each view should >> have a separate name to prevent collide with each >> other. >> >> Artyom >> >> > ------------------------------------------------------------------------------ >> Special Offer -- Download ArcSight Logger for FREE! >> Finally, a world-class log management solution at an even better >> price-free! And you'll get a free "Love Thy Logs" t-shirt > when you >> download Logger. Secure your free ArcSight Logger TODAY! >> http://p.sf.net/sfu/arcsisghtdev2dev >> _______________________________________________ >> Cppcms-users mailing list >> Cpp...@li... >> https://lists.sourceforge.net/lists/listinfo/cppcms-users > > ------------------------------------------------------------------------------ > Special Offer -- Download ArcSight Logger for FREE! > Finally, a world-class log management solution at an even better > price-free! And you'll get a free "Love Thy Logs" t-shirt when you > download Logger. Secure your free ArcSight Logger TODAY! > http://p.sf.net/sfu/arcsisghtdev2dev > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |
From: kpeo <sla...@ya...> - 2011-09-05 06:37:11
|
Great, thank you! Believe, url_mapping & dispatcher should also work with loadable modules - check it soon.. 05.09.2011, 08:44, "Artyom Beilis" <art...@ya...>: > ----- Original Message ----- > >> From: kpeo <sla...@ya...> >> To: cpp...@li... >> Cc: >> Sent: Sunday, September 4, 2011 9:20 PM >> Subject: [Cppcms-users] dynamic shared views >> >> Artyom, >> >> Is there way in engine of dynamically loading additional shared libs with view? >> I.e. i know how to load shared library and call some class function in it, but >> if i want to extend current view with pluggable one at runtime - whether >> it's possible with current version? >> >> Regards, >> kpeo > > Actually it is possible even with current version. > > All view that is linked to executable is automatically > registered (using global constructor) to the central > singleton class that holds all views and unregistered > when unloaded. > > So it is just enough to link the view to the plugin's > shared object or load it as shared object of the view > and you get it. > > Currently the code behind all this stuff is quite ugly > and is going to be rewritten - code cleanup > (it is the 1st or the 2nd task in the list) > but the behavior would remain the same. > > And then it will be properly documented. > > The only restriction is that each view should > have a separate name to prevent collide with each > other. > > Artyom > > ------------------------------------------------------------------------------ > Special Offer -- Download ArcSight Logger for FREE! > Finally, a world-class log management solution at an even better > price-free! And you'll get a free "Love Thy Logs" t-shirt when you > download Logger. Secure your free ArcSight Logger TODAY! > http://p.sf.net/sfu/arcsisghtdev2dev > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users |
From: Artyom B. <art...@ya...> - 2011-09-05 04:55:19
|
> Hello, > > Glad to hear 1.0.0 will soon arrive. > > I would like to have if possible, the possibility to get the accepted > languages sent by a browser as an ordered collection (depending of the > priority given for each languages), that would ease the selection of the > language in which to display the website, and permit easy fallback to a > less prefered language. > You mean this (Accept-Language)? http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4 Actually I think it would be good idea to add parsing of this type of header like foo;q=0.3 bar;q=0.2 to ordered collection in general. It would be useful for many other Accept* headers like Accept-Encoding or Accept-Charset and so on. Ok... I'll take a look on it, but this is something that does not really requires incompatible changes in API, just need a small parser. So I can schedule it for 1.1.x version (unless somebody sends me a patch with such parser) Artyom |
From: Artyom B. <art...@ya...> - 2011-09-05 04:47:30
|
> > > I'd still prefer a somewhat simpler versioning scheme, but what you propose > at > least has a logical explanation and a practical meaning, so that's good. > > Here you are: > http://art-blog.no-ip.info/wikipp/en/page/cppcms_versioning_scheme > > > Blessings, > > Augustin. > Wow... Thanks for updating the wiki. The naming convention is the same convention used by Gnome and by GLib. It is very suitable for libraries as it is clear what kind of dependency required and what library is backward compatible with other and at what level. Artyom |
From: Artyom B. <art...@ya...> - 2011-09-05 04:44:46
|
----- Original Message ----- > From: kpeo <sla...@ya...> > To: cpp...@li... > Cc: > Sent: Sunday, September 4, 2011 9:20 PM > Subject: [Cppcms-users] dynamic shared views > > Artyom, > > Is there way in engine of dynamically loading additional shared libs with view? > I.e. i know how to load shared library and call some class function in it, but > if i want to extend current view with pluggable one at runtime - whether > it's possible with current version? > > Regards, > kpeo > Actually it is possible even with current version. All view that is linked to executable is automatically registered (using global constructor) to the central singleton class that holds all views and unregistered when unloaded. So it is just enough to link the view to the plugin's shared object or load it as shared object of the view and you get it. Currently the code behind all this stuff is quite ugly and is going to be rewritten - code cleanup (it is the 1st or the 2nd task in the list) but the behavior would remain the same. And then it will be properly documented. The only restriction is that each view should have a separate name to prevent collide with each other. Artyom |
From: augustin <aug...@ov...> - 2011-09-05 01:07:08
|
On Sunday, September 04, 2011 05:16:07 PM Artyom Beilis wrote: > Once CppCMS released in version 1.0.0 the major versions would look like > > [Major].[Minor].[Patch] > > Major - defines API and ABI compatibility it expected to be 1 for a > long time. Release of 2.0.0 would mean a major API changes. > > Not planned at this point. > > Minor - Releases that adds new features and functionality such that: > > all that works with 1.0 would work with 1.2 but not other way > around. > > The even numbers would mark stable releases 1.0, 1.2, 1.4 > and odd numbers would mark development releases 1.1, 1.3 that > would become on stable release +1 1.1 -> 1.2 and 1.3->1.4 > upon release. > > Patch - bug fix release that do not change API. > > The 0.99.X and 0.999.X version scheme is a beta-X and RC-X pre-release > scheme - i.e. pre 1.0.0. version I'd still prefer a somewhat simpler versioning scheme, but what you propose at least has a logical explanation and a practical meaning, so that's good. Here you are: http://art-blog.no-ip.info/wikipp/en/page/cppcms_versioning_scheme Blessings, Augustin. -- Friends: http://www.reuniting.info/ My projects: http://astralcity.org/ http://3enjeux.overshoot.tv/ http://linux.overshoot.tv/ http://overshoot.tv/ http://charityware.info/ http://masquilier.org/ http://openteacher.info/ http://minguo.info/ http://www.wechange.org/ http://searching911.info/ . |
From: Allan S. <all...@su...> - 2011-09-04 18:56:56
|
Hello, Glad to hear 1.0.0 will soon arrive. I would like to have if possible, the possibility to get the accepted languages sent by a browser as an ordered collection (depending of the priority given for each languages), that would ease the selection of the language in which to display the website, and permit easy fallback to a less prefered language. Thanks Regards, Allan On 09/04/2011 07:43 AM, Artyom Beilis wrote: > Hello, > > I'm going to start features freeze for CppCMS 1.0.0, that > > means I'm not going to add any new features to the code > besides ones listed there: > > http://art-blog.no-ip.info/wikipp/en/page/cppcms_1x_tasks#CppCMS.0.999.1.-.rc1 > > So the remaining tasks for CppCMS 1.0.0 release are: > > * Review shared objects loading and views_pool class > * Provide CakePHP style helpers to template system > * Improve Unit Tests for Templates System > * Booster.System - provide error_condition in addition to error code > * Do changes required in the code review of the event loop > * Implement Pre-Upload file validation > * Reintegrate distributed session backend > * Booster reference documentation > > > So if anybody wants to have some more features prior to 1.0.0 > that may effect API in backward incompatible way please > rise it now and provide explicit description of what you > want and how the API should look like ASAP. > > > Because after that there will be no backward incompatible > > API and ABI changes in CppCMS 1.x.x branch. > > > > It is the time to get ready to release the stable version of CppCMS 1.x.x. > > > Best, > > > Artyom Beilis > -------------- > CppCMS - C++ Web Framework: http://cppcms.sf.net/ > CppDB - C++ SQL Connectivity: http://cppcms.sf.net/sql/cppdb/ > > ------------------------------------------------------------------------------ > Special Offer -- Download ArcSight Logger for FREE! > Finally, a world-class log management solution at an even better > price-free! And you'll get a free "Love Thy Logs" t-shirt when you > download Logger. Secure your free ArcSight Logger TODAY! > http://p.sf.net/sfu/arcsisghtdev2dev > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users |
From: kpeo <sla...@ya...> - 2011-09-04 18:20:24
|
Artyom, Is there way in engine of dynamically loading additional shared libs with view? I.e. i know how to load shared library and call some class function in it, but if i want to extend current view with pluggable one at runtime - whether it's possible with current version? Regards, kpeo |
From: Artyom B. <art...@ya...> - 2011-09-04 09:16:14
|
Augustin wrote: > Secondly, I would like to suggest the adoption of a much simpler numbering > scheme. You clearly adopted the three digit number like the linux kernel (my > kernel version: 2.6.38). I think a two digit version number would be much > easier to understand in the long run. > > You speak of API and ABI compatibility. The first digit would simply refer to > that. The second digit would simply represent the bug-fix releases. > > According to wikipedia, the linux kernel version 2.6.0 was released on 18 > December 2003: it means the 2.6.x branch is almost 8 years old, and the only > digit that matters is the 3rd one, i.e. supposedly the list significant one! > It makes no sense to me. > > In the roadmap, you refer to 1.1.0 as the next stable release... but how do > you decide when to pass to 2.0.0? When we have reached 1.9.0? > > Once CppCMS released in version 1.0.0 the major versions would look like [Major].[Minor].[Patch] Major - defines API and ABI compatibility it expected to be 1 for a long time. Release of 2.0.0 would mean a major API changes. Not planned at this point. Minor - Releases that adds new features and functionality such that: all that works with 1.0 would work with 1.2 but not other way around. The even numbers would mark stable releases 1.0, 1.2, 1.4 and odd numbers would mark development releases 1.1, 1.3 that would become on stable release +1 1.1 -> 1.2 and 1.3->1.4 upon release. Patch - bug fix release that do not change API. The 0.99.X and 0.999.X version scheme is a beta-X and RC-X pre-release scheme - i.e. pre 1.0.0. version Artyom Beilis |