You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@serf.apache.org by andrew klassen <ap...@yahoo.com.INVALID> on 2021/03/15 15:12:31 UTC
example code POST with json body
Sorry to bother you but I am not able to find example code for client side POSTrequest. Specifically, I need to send POST messages with a json body. I see severaluses of GET in the tests directory.
Thank you for any help,Andrew
Re: example code POST with json body
Posted by Justin Erenkrantz <ju...@erenkrantz.com>.
Hi Andrew,
You can pass in the -f and -m options to serf_get to send a POST request -
eg:
% ./serf_get -m POST -f your.json
Take a look around setup_request (lines 347) and the options parsing around
lines 617:
https://github.com/apache/serf/blob/trunk/test/serf_get.c#L347
https://github.com/apache/serf/blob/trunk/test/serf_get.c#L617
If you have the JSON blob in memory rather than on disk, you can replace
the file bucket with a memory bucket, etc, etc.
Depending upon what is on the other end, you may also need to set request
headers as well indicating the content-type of the body.
Cheers. -- justin
On Tue, Mar 16, 2021 at 6:20 AM andrew klassen <ap...@yahoo.com.invalid>
wrote:
> Sorry to bother you but I am not able to find example code for client side
> POSTrequest. Specifically, I need to send POST messages with a json body. I
> see severaluses of GET in the tests directory.
> Thank you for any help,Andrew
>