diff --git a/src/Http.c b/src/Http.c index b6c9535cc..a2d5b61c3 100644 --- a/src/Http.c +++ b/src/Http.c @@ -6,8 +6,9 @@ #include "Stream.h" #include "Game.h" #include "Utils.h" +#include "Options.h" -static cc_bool httpsOnly; +static cc_bool httpsOnly, httpOnly; /* Frees data from a HTTP request. */ static void HttpRequest_Free(struct HttpRequest* request) { Mem_Free(request->data); @@ -119,7 +120,8 @@ static void Http_WorkerStop(void); /* Adds a req to the list of pending requests, waking up worker thread if needed. */ static int Http_Add(const cc_string* url, cc_bool priority, cc_uint8 type, const cc_string* lastModified, const cc_string* etag, const void* data, cc_uint32 size, struct StringsBuffer* cookies) { - static const cc_string http = String_FromConst("http://"); + static const cc_string https = String_FromConst("https://"); + static const cc_string http = String_FromConst("http://"); struct HttpRequest req = { 0 }; String_CopyToRawArray(req.url, url); @@ -133,6 +135,11 @@ static int Http_Add(const cc_string* url, cc_bool priority, cc_uint8 type, const cc_string url_ = String_FromRawArray(req.url); if (String_CaselessStarts(&url_, &http)) String_InsertAt(&url_, 4, 's'); } + /* Change https:// to http:// if required */ + if (httpOnly) { + cc_string url_ = String_FromRawArray(req.url); + if (String_CaselessStarts(&url_, &https)) String_DeleteAt(&url_, 4); + } if (lastModified) { String_CopyToRawArray(req.lastModified, lastModified); @@ -1141,6 +1148,8 @@ void Http_UrlEncodeUtf8(cc_string* dst, const cc_string* src) { *#########################################################################################################################*/ static void OnInit(void) { http_terminate = false; + httpOnly = Options_GetBool(OPT_HTTP_ONLY, false); + Http_WorkerInit(); ScheduledTask_Add(30, Http_CleanCacheTask); RequestList_Init(&pendingReqs); diff --git a/src/Options.h b/src/Options.h index fca948e45..f93cb80bc 100644 --- a/src/Options.h +++ b/src/Options.h @@ -70,6 +70,7 @@ #define OPT_GRAB_CURSOR "win-grab-cursor" #define OPT_TOUCH_BUTTONS "gui-touchbuttons" #define OPT_TOUCH_SCALE "gui-touchscale" +#define OPT_HTTP_ONLY "http-no-https" struct StringsBuffer; extern struct StringsBuffer Options;