Re: [Cppcms-users] Cppcms-users Digest, Vol 26, Issue 11
Brought to you by:
artyom-beilis
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 > ******************************************** > |