[FX100] HTTP POST

Hello everyone,

I took the “http_get” example and tried to send the values (e.g. value=123 ) with POST instead of GET.

I’ve looked through the manual and different topics in forum, but I couldn’t find a solution where to place the value for a HTTP POST.
I also tried with WIP_COPT_HTTP_HEADER and other possible headers, but with no success.
Does anyone know how to do it?
(With GET it was no problem, I just had to add the values on the url, e.g testxme.com/test.php?value=123 )

const ascii * HTTP_STR_URL = "http://testxme.com/test.php";

        /* HTTP POST command */
        http_ClientTestCtx.DataChannel = wip_getFileOpts ( http_ClientTestCtx.CnxChannel,   /* session channel  */
                                                           (ascii *) HTTP_STR_URL,          /* requested URL    */
                                                           http_ClientTestDataHandler,      /* data handler     */
                                                           &http_ClientTestCtx,             /* context          */
                                                           WIP_COPT_HTTP_METHOD, WIP_HTTP_METHOD_POST,
                                                           /* request headers*/
                                                           WIP_COPT_HTTP_HEADER, "Content-Type", "application/x-www-form-urlencoded",
                                                           WIP_COPT_HTTP_HEADER, "Content-Length", 9, 
                                                           WIP_COPT_HTTP_HEADER, "Accept", "text/html",
                                                           WIP_COPT_HTTP_HEADER, "Accept-Language", "fr, en",
                                                           "value=123"  //?? How to insert these values into HTTP POST
                                                           WIP_COPT_END);

Thank you very much.

Best regard

A.Sevay

Hiya,

It sounds like you’ve misunderstood the way that a POST transaction works.

I recommend that you read “HTTP made really easy” (don’t have the link handy, Google is your friend) to understand the difference between get and post.

Ciao, Dave

Hello Dave,

I know how HTTP Post works.
I’ve also looked at your suggested page jmarshall.com/easy/http/#postmethod.

POST /path/script.cgi HTTP/1.0
From: frog@jmarshall.com
User-Agent: HTTPTool/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 32

home=Cosby&favorite+flavor=flies

I do the settings not differnt than from this site.
However, the questions remains how to commit the values via HTTP Post?

Hiya,

If you know how post works, then you know that you don’t put the data in the url, or add it to a header.

You will have to build the body yourself, and make sure that the data is url encoded correctly.

You will have to do this yourself before sending the data after building the correct headers - including the corrct content - length header.

Ciao, Dave