请教一个curl的问题
展开全部
下面是线程函数体。
去掉了一些无关的东西,大体结构是这样的。trace文件里有curlErrFlag = 0, 但是没有resultCode = 的信息,说明是curl_easy_perform( )出的错。而且负责通信的另一端的人说,命令是传送过去并执行了的。
大牛们看看?
void slccorCurl_c::PerformCurl(const char* url,string userpwd, string xmlbuffer , string protocol )
{
try
{
CPFDEF::TraceBuffer_c trace;
trace.SetPacketLevel( 5 );
struct memoryStruct response;
response.memory=NULL;
response.size = 0;
curl_global_init(CURL_GLOBAL_ALL);
CURL *c = curl_easy_init();
if( ! c ) {
CPFDEF::Error_c err(SLCCOR_CURL_INIT_EXCEPTION,
"Error during curl initialisation");
err.SetLocation(__FILE__, __LINE__);
CPFCEC::ErrorLog_c::Send( err );
}
int curlErrFlag = 0;
if (( curl_easy_setopt(c, CURLOPT_URL, url)) != CURLE_OK ) curlErrFlag = 1;
//...a lot of curl_easy_setopt calling
if (( curl_easy_setopt(c, CURLOPT_SSL_VERIFYHOST, 0))!= CURLE_OK ) curlErrFlag = 1;
trace << " curlErrFlag = " << curlErrFlag << endl << flush ;
if ( curlErrFlag == 1 )
{
result = SLCCOR_CURL_ERROR;
}
else
{
CURLcode resultCode = curl_easy_perform( c );
trace << " resultCode = " << resultCode << endl << flush ;
if ( resultCode == CURLE_COULDNT_CONNECT || resultCode == CURLE_COULDNT_RESOLVE_HOST )
{
result = SLCCOR_NO_NE_CONNECT ;
}
if(response.memory)
{
xmlResponse = response.memory;
}
free (response.memory);
curl_easy_cleanup( c );
}
}
catch (...) {
//...
}
}
去掉了一些无关的东西,大体结构是这样的。trace文件里有curlErrFlag = 0, 但是没有resultCode = 的信息,说明是curl_easy_perform( )出的错。而且负责通信的另一端的人说,命令是传送过去并执行了的。
大牛们看看?
void slccorCurl_c::PerformCurl(const char* url,string userpwd, string xmlbuffer , string protocol )
{
try
{
CPFDEF::TraceBuffer_c trace;
trace.SetPacketLevel( 5 );
struct memoryStruct response;
response.memory=NULL;
response.size = 0;
curl_global_init(CURL_GLOBAL_ALL);
CURL *c = curl_easy_init();
if( ! c ) {
CPFDEF::Error_c err(SLCCOR_CURL_INIT_EXCEPTION,
"Error during curl initialisation");
err.SetLocation(__FILE__, __LINE__);
CPFCEC::ErrorLog_c::Send( err );
}
int curlErrFlag = 0;
if (( curl_easy_setopt(c, CURLOPT_URL, url)) != CURLE_OK ) curlErrFlag = 1;
//...a lot of curl_easy_setopt calling
if (( curl_easy_setopt(c, CURLOPT_SSL_VERIFYHOST, 0))!= CURLE_OK ) curlErrFlag = 1;
trace << " curlErrFlag = " << curlErrFlag << endl << flush ;
if ( curlErrFlag == 1 )
{
result = SLCCOR_CURL_ERROR;
}
else
{
CURLcode resultCode = curl_easy_perform( c );
trace << " resultCode = " << resultCode << endl << flush ;
if ( resultCode == CURLE_COULDNT_CONNECT || resultCode == CURLE_COULDNT_RESOLVE_HOST )
{
result = SLCCOR_NO_NE_CONNECT ;
}
if(response.memory)
{
xmlResponse = response.memory;
}
free (response.memory);
curl_easy_cleanup( c );
}
}
catch (...) {
//...
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询