A HTTPPOST question
Date: Fri, 29 Aug 2008 15:48:53 +0400
First, thanks a lot for a very good library.
Second, what I'm trying to achieve.
We use libcurl in a threaded servers to communicate with a bunch of
billing systems. Each billing uses its own protocol over HTTP(S). The
work is divided into separate tasks in a way each task involves
communication with a single billing system. Each working thread has a
dedicated easy handle and setups it for a given task with hommade C++
wrapper classes for setting callbacks, configuring ssl settings,
authentication etc. After the task is completed, the destructors of
wrapper classes clean after themselves so the handle can be safely
reused for the next task i.e. remove read and write callbacks, ssl
Now I need to implement a wrapper class for form/multipart POST. The
class is supposed to hold the data to be sent, build an array of
curl_forms and curl_formadd it as CURLFORM_ARRAY. All the data are
gone at the end of the task and the curl handle must be ready for the
next task that normally uses different HTTP method, different data to
send and different buffer to accommodate the response from billing
The problem is that I cannot figure out how to do it properly.
Unfortunately, the documentation is not quite conclusive. curl_formadd
page says that form data can be cleaned safely with curl_formfree
after curl_easy_perform call while curl_easy_setopt page insists that
as soon as the list of form parts is set with CURLOPT_HTTPPOST, "The
data in this list must remain intact until you close this curl handle
again with curl_easy_cleanup(3)." This is far beyond the task lifetime
and will preclude the use of curl handle shared among all tasks in a
So, my question is: what is the correct way to recover an easy curl
handle after performing a rfc1867-style post in order to reuse it for
different HTTP methods.
-- The fish that is singing in Ucayali river...Received on 2008-08-29