- curl_easy_setopt(curl, CURLOPT_URL, url);
- curl_easy_setopt(curl, CURLOPT_VERBOSE, 0);
- curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cbk_curl);
- curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk);
+ pthread_mutex_lock(&sess->lock);
+
+ curl_easy_setopt(sess->curl, CURLOPT_URL, url);
+ curl_easy_setopt(sess->curl, CURLOPT_VERBOSE, 0);
+ if (content) {
+ curl_easy_setopt(sess->curl, CURLOPT_POSTFIELDS, content);
+ curl_easy_setopt(sess->curl,
+ CURLOPT_POSTFIELDSIZE,
+ (long)strlen(content));
+ }
+ curl_easy_setopt(sess->curl, CURLOPT_WRITEFUNCTION, cbk_curl);
+ curl_easy_setopt(sess->curl, CURLOPT_WRITEDATA, (void *)&chunk);
+
+ result = curl_easy_perform(sess->curl);