2014-12-07 19:09:38 -05:00
|
|
|
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
#include "HttpPrivatePCH.h"
|
|
|
|
|
#include "WindowsPlatformHttp.h"
|
|
|
|
|
#include "HttpWinInet.h"
|
2014-04-02 18:09:23 -04:00
|
|
|
#include "Curl/CurlHttp.h"
|
|
|
|
|
#include "Curl/CurlHttpManager.h"
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2015-01-29 17:12:48 -05:00
|
|
|
bool bUseCurl = true;
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
void FWindowsPlatformHttp::Init()
|
|
|
|
|
{
|
2014-09-11 15:10:20 -04:00
|
|
|
if (GConfig)
|
|
|
|
|
{
|
|
|
|
|
bool bUseCurlConfigValue = false;
|
|
|
|
|
if (GConfig->GetBool(TEXT("Networking"), TEXT("UseLibCurl"), bUseCurlConfigValue, GEngineIni))
|
|
|
|
|
{
|
|
|
|
|
bUseCurl = bUseCurlConfigValue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// allow override on command line
|
2014-04-02 18:09:23 -04:00
|
|
|
FString HttpMode;
|
|
|
|
|
if (FParse::Value(FCommandLine::Get(), TEXT("HTTP="), HttpMode) &&
|
2015-01-29 17:12:48 -05:00
|
|
|
(HttpMode.Equals(TEXT("WinInet"), ESearchCase::IgnoreCase)))
|
2014-04-02 18:09:23 -04:00
|
|
|
{
|
2015-01-29 17:12:48 -05:00
|
|
|
bUseCurl = false;
|
2014-04-02 18:09:23 -04:00
|
|
|
}
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2014-04-02 18:09:23 -04:00
|
|
|
#if WITH_LIBCURL
|
2014-09-11 15:10:20 -04:00
|
|
|
if (bUseCurl)
|
|
|
|
|
{
|
|
|
|
|
FCurlHttpManager::InitCurl();
|
|
|
|
|
}
|
2014-04-02 18:09:23 -04:00
|
|
|
#endif
|
|
|
|
|
}
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
void FWindowsPlatformHttp::Shutdown()
|
|
|
|
|
{
|
2014-04-02 18:09:23 -04:00
|
|
|
#if WITH_LIBCURL
|
2014-09-11 15:10:20 -04:00
|
|
|
if (bUseCurl)
|
|
|
|
|
{
|
|
|
|
|
FCurlHttpManager::ShutdownCurl();
|
|
|
|
|
}
|
|
|
|
|
else
|
2014-04-02 18:09:23 -04:00
|
|
|
#endif
|
2014-09-11 15:10:20 -04:00
|
|
|
{
|
|
|
|
|
FWinInetConnection::Get().ShutdownConnection();
|
|
|
|
|
}
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
2014-04-02 18:09:23 -04:00
|
|
|
FHttpManager * FWindowsPlatformHttp::CreatePlatformHttpManager()
|
|
|
|
|
{
|
|
|
|
|
#if WITH_LIBCURL
|
|
|
|
|
if (bUseCurl)
|
|
|
|
|
{
|
|
|
|
|
return new FCurlHttpManager();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
// allow default to be used
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
IHttpRequest* FWindowsPlatformHttp::ConstructRequest()
|
|
|
|
|
{
|
2014-04-02 18:09:23 -04:00
|
|
|
#if WITH_LIBCURL
|
|
|
|
|
if (bUseCurl)
|
|
|
|
|
{
|
|
|
|
|
return new FCurlHttpRequest(FCurlHttpManager::GMultiHandle);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
return new FHttpRequestWinInet();
|
|
|
|
|
}
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|