cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: HTTPS CURL get slow when calling at first time

From: sagar hagawne <sh2012.aps_at_gmail.com>
Date: Tue, 27 Nov 2012 19:50:40 +0530

Thanks Gokhan Sengun,

my code snippet is as follows please try to find if anyone knows better.

         curl_global_init(CURL_GLOBAL_ALL);
         curl = curl_easy_init();

        struct data config;
      config.trace_ascii = 1; /* enable ascii tracing */
    struct curl_slist *chunk = NULL;
        curl_slist_append( chunk, "Content-Type: application/json");

curl = curl_easy_init();

struct AppMemoryStruct chunk1;
        chunk1.memory = (char *)malloc(1); /* will be grown as needed by
the realloc above */
        chunk1.size = 0; /* no data at this point */

        if(curl) {

                  curl_easy_setopt(curl, CURLOPT_URL,
url.GetPlatformString().c_str());
                  curl_easy_setopt(curl,CURLOPT_SSLCERTTYPE,"PEM");
                  curl_easy_setopt(curl, CURLOPT_SSLCERT,
"C:\\test\\omg.aps.net.pem");

                  curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE);
                  curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2);
                  curl_easy_setopt(curl,CURLOPT_KEYPASSWD,"");

                  char error[1024];
                  curl_easy_setopt ( curl, CURLOPT_ERRORBUFFER, error );

                  /* send all data to this function */
                  curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
&AppWriteMemoryCallback);

                  /* we pass our 'chunk' struct to the callback function */
                  curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void
*)&chunk1);

    //heres the performance get down its around 40 seconds to call the
server

                 res = curl_easy_perform(curl);
    //till here

                 if(CURLE_OK != res)
                 {

                    errorCode = kFalse;
                    if(chunk1.memory)
                    {

                      free(chunk1.memory);
                    }
                   curl_easy_cleanup(curl);
                  return errorCode;
                 }
                 errorCode = kTrue;

                if(chunk1.memory)
                {

                    returndata.SetCString(chunk1.memory);
                    free(chunk1.memory);

                }

                /* always cleanup */
               curl_easy_cleanup(curl);curl_global_init(CURL_GLOBAL_ALL);

}
please try to find a key issue why the performance is very bad using https
curl.

Thanks,
Sagar

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-11-27