que je fais avec succès un http appel POST en utilisant le code suivant:libcURL WriteCallback (Async?) - C++
std::string curlString;
CURL* pCurl = curl_easy_init();
if(!pCurl)
return NULL;
string outgoingUrl = Url;
string postFields = fields;
curl_easy_setopt(pCurl, CURLOPT_TIMEOUT, 0);
curl_easy_setopt(pCurl, CURLOPT_URL, outgoingUrl.c_str());
curl_easy_setopt(pCurl, CURLOPT_POST, 1);
curl_easy_setopt(pCurl, CURLOPT_POSTFIELDS, postFields.c_str());
curl_easy_setopt(pCurl, CURLOPT_POSTFIELDSIZE, (long)postFields.size());
curl_easy_setopt(pCurl, CURLOPT_WRITEFUNCTION, CurlWriteCallback);
curl_easy_setopt(pCurl, CURLOPT_WRITEDATA, &curlString);
curl_easy_perform(pCurl);
curl_easy_cleanup(pCurl);
Le rappel d'écriture a le prototype suivant:
size_t CurlWriteCallback(char* a_ptr, size_t a_size, size_t a_nmemb, void* a_userp);
est-il un moyen faire cela de manière asynchrone? Actuellement, il attend que le rappel se termine avant que curl_easy_perform ne renvoie. Cette méthode de blocage ne fonctionnera pas pour un serveur avec plusieurs utilisateurs.
Êtes-vous venu pour résoudre ce problème? Pouvez-vous ajouter votre solution à la question? –