一、在使用海康开放库时,发现Win32 V1.1.1库之后版本在Activex中调用时返回一直时10004。但在exe中调用就正常。为了Activex能够获取海康视频流,只能用Win32 V1.1.1版(如果使用新版在Activex中也能返回,欢迎讨论)。
在ie反复调用Activex时,会释放不完全(我明明调用了释放函数)。导致curl_easy_init()函数崩溃。更改如下
HTTPUTILLIB_API string STDCALL HttpPost(string url, map<string, string> headers, string body, string appKey, string appSecret, int timeout, list<string> signHeaderPrefixList)
{
map<string, string> formParam;
if (!body.empty())
{
std::string strKey = "CONTENT-MD5";
if (!FindTheKey(strKey, headers))
{
std::string strMd5Base64 = md5_base64_encode(body);
headers.insert(std::make_pair(HttpHeader::HTTP_HEADER_CONTENT_MD5, strMd5Base64));
}
}
headers = initialBasicHeader(headers, appKey, appSecret, "POST", url, formParam, signHeaderPrefixList);
curl_global_init(CURL_GLOBAL_ALL);
SimpleHttpClient httpClient("POST", url.c_str(), timeout);
for (map<string, string>::iterator it = headers.begin(); it != headers.end(); it++)
{
httpClient.setHttpHeader(it->first, it->second);
}
httpClient.setHttpContent(body);
httpClient.sendHttpRequest();
string retStr = httpClient.getHttpResponseBody();
curl_global_cleanup();
return retStr;
}
当然你想调用哪个HttpPost都可以,只要加上curl_global_init(CURL_GLOBAL_ALL);与curl_global_cleanup();就行。