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].


[1]: http://curl.haxx.se/libcurl/c/CURLOPT_CONNECT_ONLY.html
[2]: http://curl.haxx.se/libcurl/c/curl_easy_send.html
[3]: http://curl.haxx.se/libcurl/c/curl_easy_recv.html
[4]: http://curl.haxx.se/libcurl/c/CURLOPT_POST.html
[5]: http://curl.haxx.se/libcurl/c/CURLOPT_POSTFIELDS.html
[6]: http://curl.haxx.se/libcurl/c/http-post.html
[7]: http://curl.haxx.se/libcurl/c/CURLOPT_WRITEFUNCTION.html
[8]: http://curl.haxx.se/libcurl/c/getinmemory.html
[9]: https://gist.github.com/jay/a43724c98220de85d020#file-showgmailfolders-c-L70-L94
[10]: http://curl.haxx.se/docs/caextract.html
[11]: http://curl.haxx.se/libcurl/c/CURLOPT_CAINFO.html

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to