OCT 1. 修复httplib连接异常获取数据导致程序退出问题
This commit is contained in:
parent
c2153fd024
commit
5f3f55fad4
|
@ -378,14 +378,17 @@ template<class T1, class T2> int PlatformProtolPostMessage(const TCHAR *pUrlPath
|
|||
}
|
||||
}
|
||||
|
||||
SPDLOG_DEBUG(TEXT("+++++ Http Request {0}\n---- Http Response {1}"), pJson, res->body.c_str());
|
||||
|
||||
if (res.error() != httplib::Error::Success) {
|
||||
SPDLOG_ERROR(TEXT("[{0}]:Post Data {1} error: {2}"), pUrlPath, pJson, httplib::to_string(res.error()));
|
||||
if(res.error() != httplib::Error::Connection) {
|
||||
SPDLOG_DEBUG(TEXT("+++++ Http Request {0}\n---- Http Response {1}"), pJson, res->body.c_str());
|
||||
}
|
||||
free(pJson);
|
||||
return -ERR_HTTP_POST_DATA;
|
||||
}
|
||||
|
||||
SPDLOG_DEBUG(TEXT("+++++ Http Request {0}\n---- Http Response {1}"), pJson, res->body.c_str());
|
||||
|
||||
if (res->status != 200) {
|
||||
SPDLOG_ERROR(TEXT("[{0}]:Post Data {1} server return HTTP error: {2}"), pUrlPath, pJson, res->status);
|
||||
free(pJson);
|
||||
|
|
|
@ -50,17 +50,22 @@ static spdlog::level::level_enum logLevelToSpdlogLevel(LOG_LEVEL level) {
|
|||
|
||||
static void InitTunnelSDKLog(const TCHAR *pLogFile, LOG_LEVEL level) {
|
||||
TCHAR buf[MAX_PATH] = {0};
|
||||
|
||||
if (pLogFile && strlen(pLogFile) > 0 && !PathIsRelative(pLogFile)) {
|
||||
TCHAR tmpPath[MAX_PATH];
|
||||
StringCbCopy(tmpPath, MAX_PATH, pLogFile);
|
||||
PathRemoveFileSpec(tmpPath);
|
||||
MakeSureDirectoryPathExists(tmpPath);
|
||||
|
||||
if (pLogFile && strlen(pLogFile) > 0) {
|
||||
if (PathIsRelative(buf)) {
|
||||
StringCbPrintf(buf, MAX_PATH, TEXT("%s\\%s"), g_globalConfig.workDirectory, pLogFile);
|
||||
} else {
|
||||
StringCbCopy(buf, MAX_PATH, pLogFile);
|
||||
}
|
||||
} else {
|
||||
StringCbPrintf(buf, MAX_PATH, TEXT("%s\\tunnelsdklog.log"), g_globalConfig.workDirectory);
|
||||
}
|
||||
|
||||
StringCbCopy(tmpPath, MAX_PATH, buf);
|
||||
PathRemoveFileSpec(tmpPath);
|
||||
MakeSureDirectoryPathExists(tmpPath);
|
||||
|
||||
g_globalConfig.enableLog = TRUE;
|
||||
g_globalConfig.logLevel = logLevelToSpdlogLevel(level);
|
||||
|
||||
|
|
|
@ -19,8 +19,7 @@ TEST_MODULE_INITIALIZE(ModuleInitialize) {
|
|||
Assert::AreEqual(0,
|
||||
TunnelSDKInitEnv(path,
|
||||
"http://172.21.40.194:32549",
|
||||
TEXT("C:\\Users\\HuangXin\\Documents\\development\\visual_studio\\tunnel_"
|
||||
"windows\\NetTunnelApp\\bin\\Debug\\utest.log"),
|
||||
TEXT("./test/utest.log"),
|
||||
LOG_TRACE,
|
||||
false));
|
||||
//Assert::AreEqual(0, EnableVerifySignature(TEXT("123"), TEXT("123456")));
|
||||
|
|
Loading…
Reference in New Issue