curl-library
Seeing error message: "Please call cul_multi_perfom() soon"
Date: Mon, 25 Jun 2012 13:01:57 -0700
Hi
I am trying to send POST request to a web server using curl_multi_perform.
However, I see the error "Please call curl_multi_perfom() soon" when I call
curl_multi_perform().
The code works fine when I call curl_easy_perform() (commented out below.)
I am not able to understand why my requests are successful on
curl_easy_perform but not on curl_multi_perform.
Appreciate your help. Below is the same code
Thanks
Sam
struct curl_slist *headers=NULL;
CURL *curl;
CURLM *multi_handle;
curl = curl_easy_init();
multi_handle = curl_multi_init();
if (multi_handle == NULL) {
printf("DE: Could not get a MULTI curl handle again\n");
return -1;
}
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Content-Type: application/json;
charset=utf-8");
headers = curl_slist_append(headers, "Expect: ");
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, ""); /* just to start the
cookie engine */
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); // needed to set
Content-Type to "application/json" rather than the default
"application/x-www-form-urlencoded"
curl_easy_setopt(curl, CURLOPT_URL, url); //has to URL information to
send POST request to
curl_easy_setopt(curl, CURLOPT_POST, 1); /* specify that this request
is a HTTP POST */
curl_easy_setopt(curl, CURLOPT_POSTFIELDS,
(*ctx)->post_req.body.memory); /* Specify the content of the request
(XML) */
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, memwrite_callback);
curl_easy_setopt(curl, CURLOPT_HEADERDATA, &(*ctx)->post_resp.hdr);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, memwrite_callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &(*ctx)->post_resp.body);
curl_multi_add_handle(multi_handle, curl);
#if 0
CURLcode res = curl_easy_perform(curl); *//This works fine when
commented out.*
if (res != CURLE_OK) {
printf("DE: Curl perform failed: %s\n", curl_easy_strerror(res));
return -1;
}
#endif
CURLcode res = curl_multi_perform(multi_handle, &still_running);
if (res != CURLM_OK) {
printf("DE: Curl multi perform failed: %s\n",
curl_multi_strerror(res)); *//My code enters here for some reason and
shows "Please call cul_multi_perfom() soon"*
return -1;
}
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-06-25