cURL / Mailing Lists / curl-library / Single Mail


Re: New to CURL - HTTP POST to web service and response

From: Ray Satiro via curl-library <>
Date: Thu, 18 Jun 2015 14:55:11 -0400

On 6/18/2015 11:20 AM, Fitzgerald, Kevin wrote:
> Hi, sorry I was not detailed enough. Yes, I am using the POST example
> from the CURL repository. I originally was trying the sendrecv
> example. I replaced the send portion with the POST portion and was
> still using the receive part.

It looks like you mixed two disparate examples together.
CURLOPT_CONNECT_ONLY [1] will stop the library from initiating a
transfer. So if you use that option then after the connection is
established nothing will happen and you'll have to use curl_easy_send
[2] and curl_easy_recv [3]. That is what you would do if you needed to
implement a custom protocol.

Instead you should be able to use CURLOPT_POST [4] and the simplest way
is CURLOPT_POSTFIELDS [5] as shown in the http-post.c example [6]. As
Tim suggested a write callback [7] may be helpful if you need to parse
the response because you can use it to direct the response body
somewhere (eg to memory [8][9]) instead of having it output to stdout.
However in Tim's code he's also using CURLOPT_CONNECT_ONLY, which you
wouldn't use in this case.

I caution you for security reasons it is not a good idea to disable peer
verification (CURLOPT_SSL_VERIFYPEER) as is shown in your code. If you
can't verify the server successfully find out why. I can here. You may
just need a later certificate bundle [10]. You can change the bundle
location using CURLOPT_CAINFO [11].


List admin:
Received on 2015-06-18