cURL / Mailing Lists / curl-library / Single Mail

curl-library

libcurl callback order

From: Erik Earle <erikearle_at_yahoo.com>
Date: Wed, 25 May 2011 11:04:06 -0700 (PDT)

I'm new to this and I'm looking at the samples, docs and list archives... I
cannot find definitive information on whether 'curl_easy_perform' always returns
after all the calls to 'recv_hdr' and 'recv_data' have returned or if the call
backs are multi-threaded.

Is it the same for the share and multi interfaces as the easy?

// the header call back function
size_t recv_hdr( void *ptr, size_t size, size_t nmemb, void *userdata) { //
receive header line }

// the body call back function
static size_t recv_data(void *ptr, size_t size, size_t nmemb, void *data) {
 // receive body data }

// the main CURL call
void callUrl() {

    CURL *curl;
    CURLcode resp;
    CurlContinuationData *pCurlData = new CurlContinuationData(); // a struct
for data

    curl = curl_easy_init();
    if(curl) {
        curl_easy_setopt(curl, CURLOPT_URL,
"http://curl.haxx.se/libcurl/c/curl_easy_setopt.html");

        // set body call back function
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, recv_data);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, pCurlData);
        
        // set header call back function curl_easy_setopt(curl,
CURLOPT_HEADERFUNCTION, recv_hdr);
        curl_easy_setopt(curl, CURLOPT_HEADERDATA, pCurlData);
        
        resp = curl_easy_perform(curl);

        curl_easy_cleanup(curl);
    }

}

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-05-25