|
|
|
|
@ -3,6 +3,7 @@
|
|
|
|
|
#include "common/log.h"
|
|
|
|
|
#include "common/string_util.h"
|
|
|
|
|
#include "common/timer.h"
|
|
|
|
|
#include <VersionHelpers.h>
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
Log_SetChannel(HTTPDownloaderWinHttp);
|
|
|
|
|
|
|
|
|
|
@ -32,8 +33,12 @@ std::unique_ptr<HTTPDownloader> HTTPDownloader::Create()
|
|
|
|
|
|
|
|
|
|
bool HTTPDownloaderWinHttp::Initialize()
|
|
|
|
|
{
|
|
|
|
|
m_hSession = WinHttpOpen(StringUtil::UTF8StringToWideString(m_user_agent).c_str(),
|
|
|
|
|
WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY, nullptr, nullptr, WINHTTP_FLAG_ASYNC);
|
|
|
|
|
// WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY is not supported before Win8.1.
|
|
|
|
|
const DWORD dwAccessType =
|
|
|
|
|
IsWindows8Point1OrGreater() ? WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY : WINHTTP_ACCESS_TYPE_DEFAULT_PROXY;
|
|
|
|
|
|
|
|
|
|
m_hSession = WinHttpOpen(StringUtil::UTF8StringToWideString(m_user_agent).c_str(), dwAccessType, nullptr, nullptr,
|
|
|
|
|
WINHTTP_FLAG_ASYNC);
|
|
|
|
|
if (m_hSession == NULL)
|
|
|
|
|
{
|
|
|
|
|
Log_ErrorPrintf("WinHttpOpen() failed: %u", GetLastError());
|
|
|
|
|
|