From 61db21b12d39699674aaa71ea8a33f45058d2360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 21 Jul 2023 10:49:01 +0200 Subject: [PATCH] Cleanup, fix so we can run RetroAchievements with https, and start doing that --- Common/Net/HTTPClient.h | 10 ---------- Common/Net/HTTPNaettRequest.cpp | 3 +-- Common/Net/HTTPNaettRequest.h | 10 ---------- Common/Net/HTTPRequest.h | 12 ++++++++++-- Core/RetroAchievements.cpp | 6 ++++-- 5 files changed, 15 insertions(+), 26 deletions(-) diff --git a/Common/Net/HTTPClient.h b/Common/Net/HTTPClient.h index 85543bb53c..d3e91d027a 100644 --- a/Common/Net/HTTPClient.h +++ b/Common/Net/HTTPClient.h @@ -96,14 +96,6 @@ public: HTTPDownload(RequestMethod method, const std::string &url, const std::string &postData, const std::string &postMime, const Path &outfile, ProgressBarMode progressBarMode = ProgressBarMode::DELAYED, const std::string &name = ""); ~HTTPDownload(); - void SetAccept(const char *mime) override { - acceptMime_ = mime; - } - - void SetUserAgent(const std::string &userAgent) override { - userAgent_ = userAgent; - } - void Start() override; void Join() override; @@ -135,12 +127,10 @@ private: RequestMethod method_; std::string postData_; - std::string userAgent_; Buffer buffer_; std::vector responseHeaders_; Path outfile_; std::thread thread_; - const char *acceptMime_ = "*/*"; std::string postMime_; int resultCode_ = 0; bool completed_ = false; diff --git a/Common/Net/HTTPNaettRequest.cpp b/Common/Net/HTTPNaettRequest.cpp index bb6888cc4a..f706de794d 100644 --- a/Common/Net/HTTPNaettRequest.cpp +++ b/Common/Net/HTTPNaettRequest.cpp @@ -110,8 +110,7 @@ bool HTTPSDownload::Done() { completed_ = true; - if (callback_) - callback_(*this); + // The callback will be called later. return true; } diff --git a/Common/Net/HTTPNaettRequest.h b/Common/Net/HTTPNaettRequest.h index 6a9f62eba9..064c9c70ed 100644 --- a/Common/Net/HTTPNaettRequest.h +++ b/Common/Net/HTTPNaettRequest.h @@ -16,14 +16,6 @@ public: HTTPSDownload(RequestMethod method, const std::string &url, const std::string &postData, const std::string &postMime, const Path &outfile, ProgressBarMode progressBarMode = ProgressBarMode::DELAYED, const std::string &name = ""); ~HTTPSDownload(); - void SetAccept(const char *mime) override { - acceptMime_ = mime; - } - - void SetUserAgent(const std::string &userAgent) override { - userAgent_ = userAgent; - } - void Start() override; void Join() override; @@ -51,11 +43,9 @@ public: private: RequestMethod method_; std::string postData_; - std::string userAgent_; Buffer buffer_; std::vector responseHeaders_; Path outfile_; - const char *acceptMime_ = "*/*"; std::string postMime_; int resultCode_ = 0; bool completed_ = false; diff --git a/Common/Net/HTTPRequest.h b/Common/Net/HTTPRequest.h index 7c55c5bd85..fc83c3f09b 100644 --- a/Common/Net/HTTPRequest.h +++ b/Common/Net/HTTPRequest.h @@ -26,8 +26,13 @@ public: Download(const std::string &url, const std::string &name, bool *cancelled) : url_(url), name_(name), progress_(cancelled) {} virtual ~Download() {} - virtual void SetAccept(const char *mime) = 0; - virtual void SetUserAgent(const std::string &userAgent) = 0; + void SetAccept(const char *mime) { + acceptMime_ = mime; + } + + void SetUserAgent(const std::string &userAgent) { + userAgent_ = userAgent; + } // NOTE: Completion callbacks (which these are) are deferred until RunCallback is called. This is so that // the call will end up on the thread that calls g_DownloadManager.Update(). @@ -65,6 +70,9 @@ protected: std::function callback_; std::string url_; std::string name_; + const char *acceptMime_ = "*/*"; + std::string userAgent_; + net::RequestProgress progress_; private: diff --git a/Core/RetroAchievements.cpp b/Core/RetroAchievements.cpp index 84302c8123..3821470ada 100644 --- a/Core/RetroAchievements.cpp +++ b/Core/RetroAchievements.cpp @@ -349,8 +349,10 @@ void Initialize() { // Provide a logging function to simplify debugging rc_client_enable_logging(g_rcClient, RC_CLIENT_LOG_LEVEL_VERBOSE, log_message_callback); - // Disable SSL for now. - rc_client_set_host(g_rcClient, "http://retroachievements.org"); + if (!System_GetPropertyBool(SYSPROP_SUPPORTS_HTTPS)) { + // Disable SSL if not supported by our platform implementation. + rc_client_set_host(g_rcClient, "http://retroachievements.org"); + } rc_client_set_event_handler(g_rcClient, event_handler_callback);