[Libwebsockets] How to get query parameters using the GET method?

Andy Green andy at warmcat.com
Mon Jun 13 11:16:39 CEST 2016



On 06/13/2016 04:37 PM, Thomas Spitz wrote:
> Hello Andy,
>
> I compiled last libwebsockets-test-server and it seems that POST
> examples don't work anymore (default compilation without plugins and lwsws)
>
> The redirect to postresults work but I always get the following results:
>
>     Form results. "
>
> I had a quick glance at test-server-http.c but I don't see where the
> problem come from yet.

The problem is I only updated the nice clean plugin version and not the 
oldstyle test server.

Here's a patch on master now that updates the old version to do the same 
as the new.

https://github.com/warmcat/libwebsockets/commit/31900d6ae70418b2d933dc68b11f936cec541dba

Notice if you're copying things out of the tree, test.html was also 
updated with the plugin changes, he now presents two forms, so both 
kinds can be tested.

-Andy

> Best regards,
> Thomas
>
>
> 2016-06-11 3:42 GMT+02:00 Andy Green <andy at warmcat.com
> <mailto:andy at warmcat.com>>:
>
>
>
>     On 06/10/2016 10:54 AM, Andy Green wrote:
>
>
>
>         On 06/08/2016 03:53 AM, Edwin van den Oetelaar wrote:
>
>             Maybe you want to send the value of the form fields in the
>             CONTENTS of
>             the post instead of the URL ?
>             See https://tools.ietf.org/html/rfc1867
>
>             ENCTYPE="multipart/form-data"
>
>
>             <form action="formtest" method="post"
>             ENCTYPE="multipart/form-data" >
>
>
>         I rather belatedly see what you meant here... support for this
>         is also
>         required in this new api if it can handle file transfer.
>
>
>     On master, this is supported now, and the POST demo has two forms,
>     one uses the urlencoded x=y POST BODY style, and the other uses
>     multipart/form-data - both forms work using the same api and the
>     second one supports a file upload demo.
>
>     -Andy
>
>
>         -Andy
>
>
>             Best regards,
>             Edwin van den Oetelaar
>
>             On Tue, Jun 7, 2016 at 9:40 PM, Thomas Spitz
>             <thomas.spitz at hestia-france.com
>             <mailto:thomas.spitz at hestia-france.com>
>             <mailto:thomas.spitz at hestia-france.com
>             <mailto:thomas.spitz at hestia-france.com>>>
>             wrote:
>
>                 Hello everyone,
>
>                 It might not make sense as POST request are possibly
>             much larger,
>                 but is there also an official way to retrieve the query
>             parameters,
>                 which were
>                 appended in the URI using POST?
>
>                 I have seen that the parameters are in *in egg:
>
>                     <form action="formtest" method="post">
>                       Some text:<br>
>                       <input type="text" name="Text" value="Give me some
>             text"><br>
>                       <input type="text" name="Text2"
>             value="secondValue"><br>
>                       <input type="submit" value="Send the form">
>                     </form>
>
>                 gives
>
>                     Form results: 'Text=Give+me+some+text&Text2=secondValue'
>
>                 But then we need to parse it manually
>                 Best regards,
>                 Thomas
>
>
>                 2016-05-20 15:13 GMT+02:00 Roger Schreiter
>             <roger at planinternet.de <mailto:roger at planinternet.de>
>                 <mailto:roger at planinternet.de
>             <mailto:roger at planinternet.de>>>:
>
>                     Am 20.05.2016 15:09, schrieb Andy Green:
>                     > ...
>                     > /* dump the individual URI Arg parameters */
>                     >                       n = 0;
>                     >                       while
>             (lws_hdr_copy_fragment(wsi, buf,
>             sizeof(buf),
>                     >
>             WSI_TOKEN_HTTP_URI_ARGS, n) > 0) {
>                     >                               lwsl_notice("URI Arg %d:
>             %s\n", ++n, buf);
>
>
>                     Great!
>
>                     Regards,
>                     Roger.
>                     _______________________________________________
>                     Libwebsockets mailing list
>                     Libwebsockets at ml.libwebsockets.org
>             <mailto:Libwebsockets at ml.libwebsockets.org>
>                     <mailto:Libwebsockets at ml.libwebsockets.org
>             <mailto:Libwebsockets at ml.libwebsockets.org>>
>                     http://libwebsockets.org/mailman/listinfo/libwebsockets
>
>
>
>                 _______________________________________________
>                 Libwebsockets mailing list
>                 Libwebsockets at ml.libwebsockets.org
>             <mailto:Libwebsockets at ml.libwebsockets.org>
>                 <mailto:Libwebsockets at ml.libwebsockets.org
>             <mailto:Libwebsockets at ml.libwebsockets.org>>
>                 http://libwebsockets.org/mailman/listinfo/libwebsockets
>
>
>
>
>             _______________________________________________
>             Libwebsockets mailing list
>             Libwebsockets at ml.libwebsockets.org
>             <mailto:Libwebsockets at ml.libwebsockets.org>
>             http://libwebsockets.org/mailman/listinfo/libwebsockets
>
>         _______________________________________________
>         Libwebsockets mailing list
>         Libwebsockets at ml.libwebsockets.org
>         <mailto:Libwebsockets at ml.libwebsockets.org>
>         http://libwebsockets.org/mailman/listinfo/libwebsockets
>
>     _______________________________________________
>     Libwebsockets mailing list
>     Libwebsockets at ml.libwebsockets.org
>     <mailto:Libwebsockets at ml.libwebsockets.org>
>     http://libwebsockets.org/mailman/listinfo/libwebsockets
>
>



More information about the Libwebsockets mailing list