Quantcast
Channel: Programmers Heaven Forums RSS Feed
Viewing all articles
Browse latest Browse all 2703

Problem with Https CURL getting very slower response than http curl

$
0
0
i am using the
url = "https://prd.aps.net/cm/json/login.json?username=a ps@aps.com&pass=ca4433$$&apikey=1dd80ss107s3ad9593 c857cc6d14d3a3"

Note:: if iam using the http as a protocol it just grab the values in a few seconds(3 to 4) but using https its a big issue around 40 sec it takes when i am calling curl_easy_perform(curl) why so? please take a part in it.
Thanks.

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,"");


//curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace);
//CA("JL1l");
//curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &config);
//CA("JL1m");
//curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
//CA("JL1n");

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);

/* some servers don't like requests that are made without a user-agent
field, so we provide one */
//curl_easy_setopt(curl, CURLOPT_USERAGENT, "libcurl-agent/1.0");

//curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk);
//curl_easy_setopt(curl, CURLOPT_HTTPGET,1);

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

res = curl_easy_perform(curl);
//
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_GLOB AL_ALL);



Thanks

Viewing all articles
Browse latest Browse all 2703

Trending Articles