Skip to content

Commit

Permalink
Cleanup, fix so we can run RetroAchievements with https, and start do…
Browse files Browse the repository at this point in the history
…ing that
  • Loading branch information
hrydgard committed Jul 21, 2023
1 parent 9decdd1 commit 61db21b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 26 deletions.
10 changes: 0 additions & 10 deletions Common/Net/HTTPClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,6 @@ class HTTPDownload : public Download {
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;

Expand Down Expand Up @@ -135,12 +127,10 @@ class HTTPDownload : public Download {

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;
Expand Down
3 changes: 1 addition & 2 deletions Common/Net/HTTPNaettRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ bool HTTPSDownload::Done() {

completed_ = true;

if (callback_)
callback_(*this);
// The callback will be called later.
return true;
}

Expand Down
10 changes: 0 additions & 10 deletions Common/Net/HTTPNaettRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ class HTTPSDownload : public Download {
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;

Expand Down Expand Up @@ -51,11 +43,9 @@ class HTTPSDownload : public Download {
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;
Expand Down
12 changes: 10 additions & 2 deletions Common/Net/HTTPRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@ class Download {
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().
Expand Down Expand Up @@ -65,6 +70,9 @@ class Download {
std::function<void(Download &)> callback_;
std::string url_;
std::string name_;
const char *acceptMime_ = "*/*";
std::string userAgent_;

net::RequestProgress progress_;

private:
Expand Down
6 changes: 4 additions & 2 deletions Core/RetroAchievements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 61db21b

Please sign in to comment.