|  | @@ -5,6 +5,8 @@
 | 
	
		
			
				|  |  |  #include "SATHTTP.h"
 | 
	
		
			
				|  |  |  #include <direct.h>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +CCurlClient g_curl;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  #ifdef _DEBUG
 | 
	
		
			
				|  |  |  #define new DEBUG_NEW
 | 
	
		
			
				|  |  |  #endif
 | 
	
	
		
			
				|  | @@ -124,6 +126,9 @@ bool MKDIR(LPCTSTR dir)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  SATHTTP_API int Login(std::string url, const SATParameters::STLoginReq &stLoginReq, SATParameters::STLoginResp &stLoginResp)
 | 
	
		
			
				|  |  |  {
 | 
	
		
			
				|  |  | +	if ( !g_curl.IsInit() )
 | 
	
		
			
				|  |  | +		g_curl.Initialize();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  	// 转化为Json;
 | 
	
		
			
				|  |  |  	cJSON *pRoot = cJSON_CreateObject();
 | 
	
		
			
				|  |  |  	if ( pRoot == NULL )
 | 
	
	
		
			
				|  | @@ -166,15 +171,14 @@ SATHTTP_API int Login(std::string url, const SATParameters::STLoginReq &stLoginR
 | 
	
		
			
				|  |  |  		cJSON_Delete(pRoot);
 | 
	
		
			
				|  |  |  	pRoot = NULL;		
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	CCurlClient curl;
 | 
	
		
			
				|  |  |  	std::string reponse;	
 | 
	
		
			
				|  |  |  	CURLcode curlCode = CURLE_OK;
 | 
	
		
			
				|  |  | -	if ( CURLE_OK == curl.Initialize() )
 | 
	
		
			
				|  |  | +	if ( g_curl.IsInit() )
 | 
	
		
			
				|  |  |  	{
 | 
	
		
			
				|  |  |  		if (_tcsstr(url.c_str(), "https://") || _tcsstr(url.c_str(), "HTTPS://") )
 | 
	
		
			
				|  |  | -			curlCode = curl.Posts(url, post_data, reponse);
 | 
	
		
			
				|  |  | +			curlCode = g_curl.Posts(url, post_data, reponse);
 | 
	
		
			
				|  |  |  		else
 | 
	
		
			
				|  |  | -			curlCode = curl.Post(url, post_data, reponse);
 | 
	
		
			
				|  |  | +			curlCode = g_curl.Post(url, post_data, reponse);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		if ( curlCode == CURLE_OK )
 | 
	
		
			
				|  |  |  		{
 | 
	
	
		
			
				|  | @@ -289,15 +293,14 @@ SATHTTP_API int UpdateDeviceMessage(std::string url, const SATParameters::STUpda
 | 
	
		
			
				|  |  |  		cJSON_Delete(pRoot);
 | 
	
		
			
				|  |  |  	pRoot = NULL;		
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	CCurlClient curl;
 | 
	
		
			
				|  |  |  	std::string reponse;	
 | 
	
		
			
				|  |  |  	CURLcode curlCode = CURLE_OK;
 | 
	
		
			
				|  |  | -	if ( CURLE_OK == curl.Initialize() )
 | 
	
		
			
				|  |  | +	if ( g_curl.IsInit() )
 | 
	
		
			
				|  |  |  	{
 | 
	
		
			
				|  |  |  		if (_tcsstr(url.c_str(), "https://") || _tcsstr(url.c_str(), "HTTPS://") )
 | 
	
		
			
				|  |  | -			curlCode = curl.Posts(url, post_data, reponse);
 | 
	
		
			
				|  |  | +			curlCode = g_curl.Posts(url, post_data, reponse);
 | 
	
		
			
				|  |  |  		else
 | 
	
		
			
				|  |  | -			curlCode = curl.Post(url, post_data, reponse);
 | 
	
		
			
				|  |  | +			curlCode = g_curl.Post(url, post_data, reponse);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		if ( curlCode == CURLE_OK )
 | 
	
		
			
				|  |  |  		{
 | 
	
	
		
			
				|  | @@ -387,15 +390,14 @@ SATHTTP_API int Heartbeat(std::string url, const SATParameters::STHeartbeatReq &
 | 
	
		
			
				|  |  |  		cJSON_Delete(pRoot);
 | 
	
		
			
				|  |  |  	pRoot = NULL;		
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	CCurlClient curl;
 | 
	
		
			
				|  |  |  	std::string reponse;	
 | 
	
		
			
				|  |  |  	CURLcode curlCode = CURLE_OK;
 | 
	
		
			
				|  |  | -	if ( CURLE_OK == curl.Initialize() )
 | 
	
		
			
				|  |  | +	if ( g_curl.IsInit() )
 | 
	
		
			
				|  |  |  	{
 | 
	
		
			
				|  |  |  		if (_tcsstr(url.c_str(), "https://") || _tcsstr(url.c_str(), "HTTPS://") )
 | 
	
		
			
				|  |  | -			curlCode = curl.Posts(url, post_data, reponse);
 | 
	
		
			
				|  |  | +			curlCode = g_curl.Posts(url, post_data, reponse);
 | 
	
		
			
				|  |  |  		else
 | 
	
		
			
				|  |  | -			curlCode = curl.Post(url, post_data, reponse);
 | 
	
		
			
				|  |  | +			curlCode = g_curl.Post(url, post_data, reponse);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		if ( curlCode == CURLE_OK )
 | 
	
		
			
				|  |  |  		{
 | 
	
	
		
			
				|  | @@ -573,7 +575,8 @@ SATHTTP_API int SetResult(std::string url, const SATParameters::STNotifyJobStart
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	char *pText = cJSON_Print(pRoot);
 | 
	
		
			
				|  |  |  	std::string post_data = "requestMsg=";
 | 
	
		
			
				|  |  | -	post_data.append(CharEncoding::EnCode_UTF8URL(pText));
 | 
	
		
			
				|  |  | +	post_data.append(pText);
 | 
	
		
			
				|  |  | +	//post_data.append(CharEncoding::EnCode_UTF8URL(pText));
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	// 释放堆内存;
 | 
	
		
			
				|  |  |  	if (pText)
 | 
	
	
		
			
				|  | @@ -584,15 +587,14 @@ SATHTTP_API int SetResult(std::string url, const SATParameters::STNotifyJobStart
 | 
	
		
			
				|  |  |  		cJSON_Delete(pRoot);
 | 
	
		
			
				|  |  |  	pRoot = NULL;		
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	CCurlClient curl;
 | 
	
		
			
				|  |  |  	std::string reponse;	
 | 
	
		
			
				|  |  |  	CURLcode curlCode = CURLE_OK;
 | 
	
		
			
				|  |  | -	if ( CURLE_OK == curl.Initialize() )
 | 
	
		
			
				|  |  | +	if ( g_curl.IsInit() )
 | 
	
		
			
				|  |  |  	{
 | 
	
		
			
				|  |  |  		if (_tcsstr(url.c_str(), "https://") || _tcsstr(url.c_str(), "HTTPS://") )
 | 
	
		
			
				|  |  | -			curlCode = curl.Posts(url, post_data, reponse);
 | 
	
		
			
				|  |  | +			curlCode = g_curl.Posts(url, post_data, reponse);
 | 
	
		
			
				|  |  |  		else
 | 
	
		
			
				|  |  | -			curlCode = curl.Post(url, post_data, reponse);
 | 
	
		
			
				|  |  | +			curlCode = g_curl.Post(url, post_data, reponse);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		if ( curlCode == CURLE_OK )
 | 
	
		
			
				|  |  |  		{
 | 
	
	
		
			
				|  | @@ -690,7 +692,8 @@ SATHTTP_API int SetResultList(std::string url, const SATParameters::STJobProcess
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	char *pText = cJSON_Print(pRoot);
 | 
	
		
			
				|  |  |  	std::string post_data = "requestMsg=";
 | 
	
		
			
				|  |  | -	post_data.append(CharEncoding::EnCode_UTF8URL(pText));
 | 
	
		
			
				|  |  | +	post_data.append(CharEncoding::EnCode_GB2312URL(pText));
 | 
	
		
			
				|  |  | +	//post_data.append(pText);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	// 释放堆内存;
 | 
	
		
			
				|  |  |  	if (pText)
 | 
	
	
		
			
				|  | @@ -701,15 +704,14 @@ SATHTTP_API int SetResultList(std::string url, const SATParameters::STJobProcess
 | 
	
		
			
				|  |  |  		cJSON_Delete(pRoot);
 | 
	
		
			
				|  |  |  	pRoot = NULL;		
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	CCurlClient curl;
 | 
	
		
			
				|  |  |  	std::string reponse;	
 | 
	
		
			
				|  |  |  	CURLcode curlCode = CURLE_OK;
 | 
	
		
			
				|  |  | -	if ( CURLE_OK == curl.Initialize() )
 | 
	
		
			
				|  |  | +	if ( g_curl.IsInit() )
 | 
	
		
			
				|  |  |  	{
 | 
	
		
			
				|  |  |  		if (_tcsstr(url.c_str(), "https://") || _tcsstr(url.c_str(), "HTTPS://") )
 | 
	
		
			
				|  |  | -			curlCode = curl.Posts(url, post_data, reponse);
 | 
	
		
			
				|  |  | +			curlCode = g_curl.Posts(url, post_data, reponse);
 | 
	
		
			
				|  |  |  		else
 | 
	
		
			
				|  |  | -			curlCode = curl.Post(url, post_data, reponse);
 | 
	
		
			
				|  |  | +			curlCode = g_curl.Post(url, post_data, reponse);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		if ( curlCode == CURLE_OK )
 | 
	
		
			
				|  |  |  		{
 | 
	
	
		
			
				|  | @@ -782,15 +784,14 @@ SATHTTP_API int GetCaseFileListUrl(std::string url, std::string strCaseId, SATPa
 | 
	
		
			
				|  |  |  		cJSON_Delete(pRoot);
 | 
	
		
			
				|  |  |  	pRoot = NULL;		
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	CCurlClient curl;
 | 
	
		
			
				|  |  |  	std::string reponse;	
 | 
	
		
			
				|  |  |  	CURLcode curlCode = CURLE_OK;
 | 
	
		
			
				|  |  | -	if ( CURLE_OK == curl.Initialize() )
 | 
	
		
			
				|  |  | +	if ( g_curl.IsInit() )
 | 
	
		
			
				|  |  |  	{
 | 
	
		
			
				|  |  |  		if (_tcsstr(url.c_str(), "https://") || _tcsstr(url.c_str(), "HTTPS://") )
 | 
	
		
			
				|  |  | -			curlCode = curl.Posts(url, post_data, reponse);
 | 
	
		
			
				|  |  | +			curlCode = g_curl.Posts(url, post_data, reponse);
 | 
	
		
			
				|  |  |  		else
 | 
	
		
			
				|  |  | -			curlCode = curl.Post(url, post_data, reponse);
 | 
	
		
			
				|  |  | +			curlCode = g_curl.Post(url, post_data, reponse);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		if ( curlCode == CURLE_OK )
 | 
	
		
			
				|  |  |  		{
 | 
	
	
		
			
				|  | @@ -872,15 +873,14 @@ SATHTTP_API int DownloadScript(std::string url, std::string strCaseId, std::stri
 | 
	
		
			
				|  |  |  		cJSON_Delete(pRoot);
 | 
	
		
			
				|  |  |  	pRoot = NULL;		
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	CCurlClient curl;
 | 
	
		
			
				|  |  |  	std::string reponse;	
 | 
	
		
			
				|  |  |  	CURLcode curlCode = CURLE_OK;
 | 
	
		
			
				|  |  | -	if ( CURLE_OK == curl.Initialize() )
 | 
	
		
			
				|  |  | +	if ( g_curl.IsInit() )
 | 
	
		
			
				|  |  |  	{
 | 
	
		
			
				|  |  |  		if (_tcsstr(url.c_str(), "https://") || _tcsstr(url.c_str(), "HTTPS://") )
 | 
	
		
			
				|  |  | -			curlCode = curl.Posts(url, post_data, reponse);
 | 
	
		
			
				|  |  | +			curlCode = g_curl.Posts(url, post_data, reponse);
 | 
	
		
			
				|  |  |  		else
 | 
	
		
			
				|  |  | -			curlCode = curl.Post(url, post_data, reponse);
 | 
	
		
			
				|  |  | +			curlCode = g_curl.Post(url, post_data, reponse);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		if ( curlCode == CURLE_OK )
 | 
	
		
			
				|  |  |  		{
 | 
	
	
		
			
				|  | @@ -930,7 +930,7 @@ SATHTTP_API int DownloadScript(std::string url, std::string strCaseId, std::stri
 | 
	
		
			
				|  |  |  										if ( MKDIR(strSaveDir.c_str()) )
 | 
	
		
			
				|  |  |  										{
 | 
	
		
			
				|  |  |  											// 同时下载脚本目录到指定目录中;
 | 
	
		
			
				|  |  | -											if ( curl.Download(stScriptUrlResp.strURL, strSaveDir, 10000) )
 | 
	
		
			
				|  |  | +											if ( g_curl.Download(stScriptUrlResp.strURL, strSaveDir, 10000) )
 | 
	
		
			
				|  |  |  											{
 | 
	
		
			
				|  |  |  												stScriptUrlResp._strFileName = strFileName.substr(0, strFileName.find_first_of('.'));
 | 
	
		
			
				|  |  |  												stScriptUrlResp._strScripFile = strSaveDir;
 | 
	
	
		
			
				|  | @@ -989,15 +989,14 @@ SATHTTP_API int StopTaskFromRunner(std::string url, std::string strInstnaceId, S
 | 
	
		
			
				|  |  |  		cJSON_Delete(pRoot);
 | 
	
		
			
				|  |  |  	pRoot = NULL;		
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	CCurlClient curl;
 | 
	
		
			
				|  |  |  	std::string reponse;	
 | 
	
		
			
				|  |  |  	CURLcode curlCode = CURLE_OK;
 | 
	
		
			
				|  |  | -	if ( CURLE_OK == curl.Initialize() )
 | 
	
		
			
				|  |  | +	if ( g_curl.IsInit() )
 | 
	
		
			
				|  |  |  	{
 | 
	
		
			
				|  |  |  		if (_tcsstr(url.c_str(), "https://") || _tcsstr(url.c_str(), "HTTPS://") )
 | 
	
		
			
				|  |  | -			curlCode = curl.Posts(url, post_data, reponse);
 | 
	
		
			
				|  |  | +			curlCode = g_curl.Posts(url, post_data, reponse);
 | 
	
		
			
				|  |  |  		else
 | 
	
		
			
				|  |  | -			curlCode = curl.Post(url, post_data, reponse);
 | 
	
		
			
				|  |  | +			curlCode = g_curl.Post(url, post_data, reponse);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		if ( curlCode == CURLE_OK )
 | 
	
		
			
				|  |  |  		{
 | 
	
	
		
			
				|  | @@ -1068,15 +1067,14 @@ SATHTTP_API int SaveCaseOrTaskLog(std::string url, const SATParameters::STSaveLo
 | 
	
		
			
				|  |  |  		cJSON_Delete(pRoot);
 | 
	
		
			
				|  |  |  	pRoot = NULL;		
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	CCurlClient curl;
 | 
	
		
			
				|  |  |  	std::string reponse;	
 | 
	
		
			
				|  |  |  	CURLcode curlCode = CURLE_OK;
 | 
	
		
			
				|  |  | -	if ( CURLE_OK == curl.Initialize() )
 | 
	
		
			
				|  |  | +	if ( g_curl.IsInit() )
 | 
	
		
			
				|  |  |  	{
 | 
	
		
			
				|  |  |  		if (_tcsstr(url.c_str(), "https://") || _tcsstr(url.c_str(), "HTTPS://") )
 | 
	
		
			
				|  |  | -			curlCode = curl.Posts(url, post_data, reponse);
 | 
	
		
			
				|  |  | +			curlCode = g_curl.Posts(url, post_data, reponse);
 | 
	
		
			
				|  |  |  		else
 | 
	
		
			
				|  |  | -			curlCode = curl.PostFile(url, post_data, stSaveLogReq.strUploads, reponse);
 | 
	
		
			
				|  |  | +			curlCode = g_curl.PostFile(url, post_data, stSaveLogReq.strUploads, reponse);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		if ( curlCode == CURLE_OK )
 | 
	
		
			
				|  |  |  		{
 | 
	
	
		
			
				|  | @@ -1166,15 +1164,14 @@ SATHTTP_API int SaveResultFile(std::string url, const SATParameters::STSaveFileR
 | 
	
		
			
				|  |  |  		cJSON_Delete(pRoot);
 | 
	
		
			
				|  |  |  	pRoot = NULL;		
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	CCurlClient curl;
 | 
	
		
			
				|  |  |  	std::string reponse;	
 | 
	
		
			
				|  |  |  	CURLcode curlCode = CURLE_OK;
 | 
	
		
			
				|  |  | -	if ( CURLE_OK == curl.Initialize() )
 | 
	
		
			
				|  |  | +	if ( g_curl.IsInit() )
 | 
	
		
			
				|  |  |  	{
 | 
	
		
			
				|  |  |  		if (_tcsstr(url.c_str(), "https://") || _tcsstr(url.c_str(), "HTTPS://") )
 | 
	
		
			
				|  |  | -			curlCode = curl.Posts(url, post_data, reponse);
 | 
	
		
			
				|  |  | +			curlCode = g_curl.Posts(url, post_data, reponse);
 | 
	
		
			
				|  |  |  		else
 | 
	
		
			
				|  |  | -			curlCode = curl.PostFile(url, post_data, stSaveFileReq.strUploads, reponse);
 | 
	
		
			
				|  |  | +			curlCode = g_curl.PostFile(url, post_data, stSaveFileReq.strUploads, reponse);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		if ( curlCode == CURLE_OK )
 | 
	
		
			
				|  |  |  		{
 | 
	
	
		
			
				|  | @@ -1250,15 +1247,14 @@ SATHTTP_API int SaveResultImg(std::string url, const SATParameters::STSaveImgReq
 | 
	
		
			
				|  |  |  		cJSON_Delete(pRoot);
 | 
	
		
			
				|  |  |  	pRoot = NULL;		
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	CCurlClient curl;
 | 
	
		
			
				|  |  |  	std::string reponse;	
 | 
	
		
			
				|  |  |  	CURLcode curlCode = CURLE_OK;
 | 
	
		
			
				|  |  | -	if ( CURLE_OK == curl.Initialize() )
 | 
	
		
			
				|  |  | +	if ( g_curl.IsInit() )
 | 
	
		
			
				|  |  |  	{
 | 
	
		
			
				|  |  |  		if (_tcsstr(url.c_str(), "https://") || _tcsstr(url.c_str(), "HTTPS://") )
 | 
	
		
			
				|  |  | -			curlCode = curl.Posts(url, post_data, reponse);
 | 
	
		
			
				|  |  | +			curlCode = g_curl.Posts(url, post_data, reponse);
 | 
	
		
			
				|  |  |  		else
 | 
	
		
			
				|  |  | -			curlCode = curl.PostFile(url, post_data, stSaveImgReq.strUploads, reponse);
 | 
	
		
			
				|  |  | +			curlCode = g_curl.PostFile(url, post_data, stSaveImgReq.strUploads, reponse);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		if ( curlCode == CURLE_OK )
 | 
	
		
			
				|  |  |  		{
 |