mirror of https://github.com/axmolengine/axmol.git
Downloader: download file with cacert support
This commit is contained in:
parent
6d76dd9f6b
commit
1721141fd7
|
@ -562,9 +562,17 @@ private:
|
|||
|
||||
curl_easy_setopt(handle, CURLOPT_LOW_SPEED_LIMIT, 1L);
|
||||
curl_easy_setopt(handle, CURLOPT_LOW_SPEED_TIME, 10L);
|
||||
|
||||
curl_easy_setopt(handle, CURLOPT_SSL_VERIFYHOST, 0L);
|
||||
curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
|
||||
if(task->cacertPath.empty())
|
||||
{
|
||||
curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
curl_easy_setopt(handle, CURLOPT_SSL_VERIFYHOST, 0L);
|
||||
}
|
||||
else {
|
||||
curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 1L);
|
||||
curl_easy_setopt(handle, CURLOPT_SSL_VERIFYHOST, 2L);
|
||||
curl_easy_setopt(handle, CURLOPT_CAINFO, task->cacertPath.c_str());
|
||||
}
|
||||
|
||||
curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, 1L);
|
||||
curl_easy_setopt(handle, CURLOPT_MAXREDIRS, 5L);
|
||||
|
|
|
@ -50,13 +50,15 @@ DownloadTask::DownloadTask(std::string_view srcUrl,
|
|||
std::string_view storagePath,
|
||||
std::string_view checksum,
|
||||
std::string_view identifier,
|
||||
bool background)
|
||||
bool background,
|
||||
std::string_view cacertPath)
|
||||
{
|
||||
this->requestURL = srcUrl;
|
||||
this->storagePath = storagePath;
|
||||
this->checksum = checksum;
|
||||
this->identifier = identifier;
|
||||
this->background = background;
|
||||
this->cacertPath = cacertPath;
|
||||
}
|
||||
|
||||
DownloadTask::~DownloadTask()
|
||||
|
@ -147,9 +149,10 @@ std::shared_ptr<DownloadTask> Downloader::createDownloadFileTask(std::string_vie
|
|||
std::string_view storagePath,
|
||||
std::string_view identifier,
|
||||
std::string_view md5checksum,
|
||||
bool background)
|
||||
bool background,
|
||||
std::string_view cacertPath)
|
||||
{
|
||||
auto task = std::make_shared<DownloadTask>(srcUrl, storagePath, md5checksum, identifier, background);
|
||||
auto task = std::make_shared<DownloadTask>(srcUrl, storagePath, md5checksum, identifier, background, cacertPath);
|
||||
do
|
||||
{
|
||||
if (srcUrl.empty() || storagePath.empty())
|
||||
|
|
|
@ -60,6 +60,8 @@ public:
|
|||
std::string identifier;
|
||||
std::string requestURL;
|
||||
std::string storagePath;
|
||||
|
||||
std::string cacertPath;
|
||||
|
||||
struct
|
||||
{
|
||||
|
@ -77,7 +79,8 @@ public:
|
|||
std::string_view storagePath,
|
||||
std::string_view checksum, // currently is MD5
|
||||
std::string_view identifier,
|
||||
bool background);
|
||||
bool background,
|
||||
std::string_view cacertPath);
|
||||
|
||||
virtual ~DownloadTask();
|
||||
|
||||
|
@ -140,7 +143,8 @@ public:
|
|||
std::string_view storagePath,
|
||||
std::string_view identifier = "",
|
||||
std::string_view checksum = "",
|
||||
bool background = false);
|
||||
bool background = false,
|
||||
std::string_view cacertPath = "");
|
||||
|
||||
private:
|
||||
std::unique_ptr<IDownloaderImpl> _impl;
|
||||
|
|
Loading…
Reference in New Issue