cURL / Mailing Lists / curl-library / Single Mail

curl-library

how to capture http response number?

From: Kman Devnull <kman.devnull_at_gmail.com>
Date: Thu, 21 Apr 2016 07:02:21 +0100

Hi,
I am new to curl.

The below code works perfectly fine.

After the line,
     result = curl_easy_perform(curl);

the server returns a "response" something like 291236 - I just want to be
able to capture this and print it in my log.

please suggest.

Many thanks!

===========================================================
        CURL *curl;
        CURLcode result;

        curl_global_init(CURL_GLOBAL_ALL);

        curl = curl_easy_init();

        char errbuf[CURL_ERROR_SIZE]; //debug

        if (curl)
        {
                std::string ccc_url("https://url_string");

                curl_easy_setopt(curl, CURLOPT_URL, ccc_url.c_str());
                curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data.c_str());
                curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf);
                curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
                result = curl_easy_perform(curl);

                if (result == CURLE_OK)
                {
                        printf("\n");

                }else
                {

                        printf("\n");

                }
                curl_easy_cleanup(curl);
        }else{

               // printf("Curl request did not work");
        }
        curl_global_cleanup();
}

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-04-21