|
@@ -906,57 +906,46 @@ SATHTTP_API int DownloadScript(std::string url, std::string strCaseId, std::stri
|
|
|
|
|
|
std::string reponse;
|
|
|
CURLcode curlCode = CURLE_OK;
|
|
|
- if ( g_curl.IsInit() )
|
|
|
- {
|
|
|
+ if ( g_curl.IsInit() ) {
|
|
|
if (_tcsstr(url.c_str(), "https://") || _tcsstr(url.c_str(), "HTTPS://") )
|
|
|
curlCode = g_curl.Posts(url, post_data, reponse);
|
|
|
else
|
|
|
curlCode = g_curl.Post(url, post_data, reponse);
|
|
|
|
|
|
- if ( curlCode == CURLE_OK )
|
|
|
- {
|
|
|
+ if ( curlCode == CURLE_OK ) {
|
|
|
reponse = CharEncoding::DeCode_URLUTF8(reponse.c_str());
|
|
|
|
|
|
// 解析返回值;
|
|
|
pRoot = cJSON_Parse(reponse.c_str());
|
|
|
- if (pRoot != NULL)
|
|
|
- {
|
|
|
+ if (pRoot != NULL) {
|
|
|
cJSON *pMsg = cJSON_GetObjectItem(pRoot, "responseMsg");
|
|
|
- if ( pMsg )
|
|
|
- {
|
|
|
+ if ( pMsg ) {
|
|
|
stScriptUrlResp.strCode = cJSON_GetObjectItem(pMsg, "code") ? cJSON_GetObjectItem(pMsg, "code")->valuestring : "";
|
|
|
stScriptUrlResp.strMessage = cJSON_GetObjectItem(pMsg, "message") ? cJSON_GetObjectItem(pMsg, "message")->valuestring : "";
|
|
|
stScriptUrlResp.strProjectId = cJSON_GetObjectItem(pMsg, "strProjectId") ? (cJSON_GetObjectItem(pMsg, "strProjectId")->valuestring ? cJSON_GetObjectItem(pMsg, "strProjectId")->valuestring : "") : "";
|
|
|
stScriptUrlResp.strCaseType = cJSON_GetObjectItem(pMsg, "caseType") ? (cJSON_GetObjectItem(pMsg, "caseType")->valuestring ? cJSON_GetObjectItem(pMsg, "caseType")->valuestring : "") : "";
|
|
|
- if ( stScriptUrlResp.strCode == "00" )
|
|
|
- {
|
|
|
+ if ( stScriptUrlResp.strCode == "00" ) {
|
|
|
cJSON *pObj = cJSON_GetObjectItem(pMsg, "data");
|
|
|
- if (pObj != NULL)
|
|
|
- {
|
|
|
- if ( cJSON_GetArraySize(pObj) >= 1 )
|
|
|
- {
|
|
|
+ if (pObj != NULL) {
|
|
|
+ if ( cJSON_GetArraySize(pObj) >= 1 ) {
|
|
|
cJSON *pScripURL = cJSON_GetArrayItem(pObj, 0);
|
|
|
- if ( pScripURL )
|
|
|
- {
|
|
|
+ if ( pScripURL ) {
|
|
|
stScriptUrlResp.strURL = cJSON_GetObjectItem(pScripURL, "url") ? (cJSON_GetObjectItem(pScripURL, "url")->valuestring ? cJSON_GetObjectItem(pScripURL, "url")->valuestring : "") : "";
|
|
|
std::string strFileDir;
|
|
|
std::string strFileName;
|
|
|
int nPos1 = 0, nPos2 = 0;
|
|
|
nPos1 = stScriptUrlResp.strURL.find("fileDir=");
|
|
|
nPos2 = stScriptUrlResp.strURL.find("&fileName=");
|
|
|
- if ( nPos1 != std::string::npos && nPos2 != std::string::npos )
|
|
|
- {
|
|
|
+ if ( nPos1 != std::string::npos && nPos2 != std::string::npos ) {
|
|
|
strFileDir = stScriptUrlResp.strURL.substr(nPos1 + strlen("fileDir="), nPos2 - nPos1 - strlen("fileDir="));
|
|
|
strFileName = stScriptUrlResp.strURL.substr(nPos2 + strlen("&fileName="));
|
|
|
// 保存目录;
|
|
|
stScriptUrlResp._strFileDir = strSaveDir;
|
|
|
strSaveDir.append(strFileName);
|
|
|
// 创建目录;
|
|
|
- if ( MKDIR(strSaveDir.c_str()) )
|
|
|
- {
|
|
|
+ if ( MKDIR(strSaveDir.c_str()) ) {
|
|
|
// 同时下载脚本目录到指定目录中;
|
|
|
- if ( g_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;
|
|
|
// 释放内存;
|