Cleanup, fix so we can run RetroAchievements with https, and start doing that

This commit is contained in:
Henrik Rydgård 2023-07-21 10:49:01 +02:00
parent 9decdd198e
commit 61db21b12d
5 changed files with 15 additions and 26 deletions

View File

@ -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<std::string> responseHeaders_;
Path outfile_;
std::thread thread_;
const char *acceptMime_ = "*/*";
std::string postMime_;
int resultCode_ = 0;
bool completed_ = false;

View File

@ -110,8 +110,7 @@ bool HTTPSDownload::Done() {
completed_ = true;
if (callback_)
callback_(*this);
// The callback will be called later.
return true;
}

View File

@ -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<std::string> responseHeaders_;
Path outfile_;
const char *acceptMime_ = "*/*";
std::string postMime_;
int resultCode_ = 0;
bool completed_ = false;

View File

@ -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<void(Download &)> callback_;
std::string url_;
std::string name_;
const char *acceptMime_ = "*/*";
std::string userAgent_;
net::RequestProgress progress_;
private:

View File

@ -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);