Re: [Cppcms-users] query string
Brought to you by:
artyom-beilis
|
From: mawan s. <ma...@gm...> - 2015-09-30 08:30:20
|
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
>
>
|