summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorTilka <tilkax@gmail.com>2019-02-01 18:27:06 +0000
committerGitHub <noreply@github.com>2019-02-01 18:27:06 +0000
commit363ce67459fd48253d2a38cf2528c7465db49911 (patch)
tree4798830016c1227023f566c0c1e4e06eb9ce3b11 /Source/Core
parenta129d60a570c73b614c02a3145bef42f2d329b64 (diff)
parent4090c19e007b7c8b384168eb4495042611a93cc8 (diff)
Merge pull request #7769 from Tilka/gecko_codes
Fix Gecko Code downloading
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Common/HttpRequest.cpp12
-rw-r--r--Source/Core/Common/HttpRequest.h1
-rw-r--r--Source/Core/Core/GeckoCodeConfig.cpp5
3 files changed, 17 insertions, 1 deletions
diff --git a/Source/Core/Common/HttpRequest.cpp b/Source/Core/Common/HttpRequest.cpp
index 63e4e85878..cee9d7434c 100644
--- a/Source/Core/Common/HttpRequest.cpp
+++ b/Source/Core/Common/HttpRequest.cpp
@@ -30,6 +30,7 @@ public:
bool IsValid() const;
void SetCookies(const std::string& cookies);
void UseIPv4();
+ void FollowRedirects(long max);
Response Fetch(const std::string& url, Method method, const Headers& headers, const u8* payload,
size_t size);
@@ -68,6 +69,11 @@ void HttpRequest::UseIPv4()
m_impl->UseIPv4();
}
+void HttpRequest::FollowRedirects(long max)
+{
+ m_impl->FollowRedirects(max);
+}
+
HttpRequest::Response HttpRequest::Get(const std::string& url, const Headers& headers)
{
return m_impl->Fetch(url, Impl::Method::GET, headers, nullptr, 0);
@@ -147,6 +153,12 @@ void HttpRequest::Impl::UseIPv4()
curl_easy_setopt(m_curl.get(), CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
}
+void HttpRequest::Impl::FollowRedirects(long max)
+{
+ curl_easy_setopt(m_curl.get(), CURLOPT_FOLLOWLOCATION, 1);
+ curl_easy_setopt(m_curl.get(), CURLOPT_MAXREDIRS, max);
+}
+
static size_t CurlWriteCallback(char* data, size_t size, size_t nmemb, void* userdata)
{
auto* buffer = static_cast<std::vector<u8>*>(userdata);
diff --git a/Source/Core/Common/HttpRequest.h b/Source/Core/Common/HttpRequest.h
index 94916f5c3c..17e31ff354 100644
--- a/Source/Core/Common/HttpRequest.h
+++ b/Source/Core/Common/HttpRequest.h
@@ -33,6 +33,7 @@ public:
void SetCookies(const std::string& cookies);
void UseIPv4();
+ void FollowRedirects(long max = 1);
Response Get(const std::string& url, const Headers& headers = {});
Response Post(const std::string& url, const std::vector<u8>& payload,
const Headers& headers = {});
diff --git a/Source/Core/Core/GeckoCodeConfig.cpp b/Source/Core/Core/GeckoCodeConfig.cpp
index 4e5dfd1642..cd7955e7bc 100644
--- a/Source/Core/Core/GeckoCodeConfig.cpp
+++ b/Source/Core/Core/GeckoCodeConfig.cpp
@@ -30,12 +30,15 @@ std::vector<GeckoCode> DownloadCodes(std::string gameid, bool* succeeded)
break;
}
- std::string endpoint{"https://geckocodes.org/txt.php?txt=" + gameid};
+ std::string endpoint{"https://www.geckocodes.org/txt.php?txt=" + gameid};
Common::HttpRequest http;
// Circumvent high-tech DDOS protection
http.SetCookies("challenge=BitMitigate.com;");
+ // The server always redirects once to the same location.
+ http.FollowRedirects(1);
+
const Common::HttpRequest::Response response = http.Get(endpoint);
*succeeded = response.has_value();
if (!response)