size_t Callback_SaveHeader(void* pszbuffer, size_t nSize, size_t nMemb, void* pUsrFp)
{
return (size_t)(nSize * nMemb);
}
bool CheckUrlAccess(string strUrl)
{
CURL* pCurlHandle = curl_easy_init();
if (pCurlHandle == NULL)
{
return false;
}
(void)curl_easy_setopt(pCurlHandle, CURLOPT_SSL_VERIFYPEER, false);
(void)curl_easy_setopt(pCurlHandle, CURLOPT_SSL_VERIFYHOST, false);
(void)curl_easy_setopt(pCurlHandle, CURLOPT_URL, strUrl.c_str());
(void)curl_easy_setopt(pCurlHandle, CURLOPT_NOBODY, 1L);
(void)curl_easy_setopt(pCurlHandle, CURLOPT_HEADERFUNCTION, Callback_SaveHeader);
(void)curl_easy_setopt(pCurlHandle, CURLOPT_HEADER, 1L);
(void)curl_easy_setopt(pCurlHandle, CURLOPT_CUSTOMREQUEST, "HEAD");
CURLcode eRet = curl_easy_perform(pCurlHandle);
curl_easy_cleanup(pCurlHandle);
if (eRet == CURLE_OK)
{
return true;
}
return false;
}