Re: [Cppcms-users] query string
Brought to you by:
artyom-beilis
From: mawan s. <ma...@gm...> - 2015-09-30 09:10:02
|
Thankyou , i will read more detial about the source code. Best Regards. Mawan On Wed, Sep 30, 2015 at 4:02 PM, kpeo <sla...@ya...> wrote: > So, is there no load for context if i use GET method? > > GET is tiny bit "harder" to get because of parse from QUERY_STRING. > And GET is less secure than POST, because it exposes the information via > the URL. > > The next, some time I use identifier / name of field using query string > &data[x][name]=value > > Is it convert to array like PHP post method, or we must loop manually > using request().get("data[x][name]")? > > It's clear from the source http_request.cpp/h: > > form_type post_; > > std::string request::post(std::string const &name) > { > std::pair<form_type::iterator,form_type::iterator> pair = > post_.equal_range(name); > form_type::iterator p = pair.first; > if(pair.first == pair.second || ++pair.first != pair.second) > return std::string(); > return p->second; > } > > request::form_type const &request::post() > { > return post_; > } > > Best regards, > kpeo > > 30.09.2015, 11:31, "mawan sugiyanto" <ma...@gm...>: > > Thanks Kpeo > > So, is there no load for context if i use GET method? > > The next, some time I use identifier / name of field using query string > &data[x][name]=value > > Is it convert to array like PHP post method, or we must loop manually > using request().get("data[x][name]")? > > Thank you > > > > On Wed, Sep 30, 2015 at 3:23 PM, kpeo <sla...@ya...> wrote: > > You can use req.get("name") instead req.post("name") and "if > (req.request_method()=="GET") {" > > There is no raw_post_data() member in request class, but you can use > form_type > <http://cppcms.com/cppcms_ref/latest/classcppcms_1_1http_1_1request.html#af80022c2dddaf68330eb7f3f23ec84fc> > const& cppcms::http::request::post_or_get > <http://cppcms.com/cppcms_ref/latest/classcppcms_1_1http_1_1request.html#a0d9ff833540a1a78c5f290aec99cdd90> > () > (form_type represents form-data key-value pairs) > See: > http://cppcms.com/cppcms_ref/latest/classcppcms_1_1http_1_1request.html#a0d9ff833540a1a78c5f290aec99cdd90 > > Best regards, > kpeo > > And also it's good point to read this article: > http://cppcms.com/wikipp/en/page/secure_programming > > 30.09.2015, 10:55, "mawan sugiyanto" <ma...@gm...>: > > How good practice about to get paramters from query string (GET method , > and not from POST method)? > > Thanks > > On Wed, Sep 30, 2015 at 2:42 PM, kpeo <sla...@ya...> wrote: > > Hi! > > You can get raw post data from request (let's assume cppcms::application& > app_;) in your application (below). > (see: > http://cppcms.com/cppcms_ref/latest/classcppcms_1_1http_1_1request.html) > <http://cppcms.com/cppcms_ref/latest/classcppcms_1_1http_1_1request.html> > > But it's not seems like a good practice, because CppCMS have built-in > forms/widgets classes - see: > http://cppcms.com/wikipp/en/page/cppcms_1x_forms > <http://cppcms.com/wikipp/en/page/ref_cppcms_forms> > http://cppcms.com/wikipp/en/page/ref_cppcms_forms > AFAIK values are the same, but by using CppCMS classes you have additional > compile-time type checking, usefull functional, etc. > > virtual void post(content::my_content& c) > > { > cppcms::http::request& req = app_.request(); > if (req.request_method()=="POST") { > std::pair<void *,size_t> post_data = req.raw_post_data(); > std::istringstream ss(std::string(reinterpret_cast<char const > *>(post_data.first),post_data.second)); > //BOOSTER_LOG(debug,__FUNCTION__) << "raw post data: " << ss.str(); > > // Get some submitted values > > if(!req.post("check").empty()) //get some hidden input value for form > with name "check" > { > std::string name = req.post("name"); //get value of input with name > "name" > > // Some handler > > } > } > > Best regards, > kpeo > 30.09.2015, 10:06, "mawan sugiyanto" <ma...@gm...>: > > Dear All > > is there any method from request object to get querystring value? > is it similar with value from form (using load content)? > > Thanks > , > > > ------------------------------------------------------------------------------ > , > > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > > ------------------------------------------------------------------------------ > > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > , > > > ------------------------------------------------------------------------------ > , > > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > > ------------------------------------------------------------------------------ > > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > , > > > ------------------------------------------------------------------------------ > , > > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > > ------------------------------------------------------------------------------ > > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > |