diff --git a/src/client/http/Request.cpp b/src/client/http/Request.cpp index 09ef595cc..4ab9427ae 100644 --- a/src/client/http/Request.cpp +++ b/src/client/http/Request.cpp @@ -230,12 +230,22 @@ namespace http } curl_easy_setopt(easy, CURLOPT_FOLLOWLOCATION, 1L); -#ifdef ENFORCE_HTTPS +#if defined(CURL_AT_LEAST_VERSION) && CURL_AT_LEAST_VERSION(7, 85, 0) +# ifdef ENFORCE_HTTPS + curl_easy_setopt(easy, CURLOPT_PROTOCOLS_STR, "https"); + curl_easy_setopt(easy, CURLOPT_REDIR_PROTOCOLS_STR, "https"); +# else + curl_easy_setopt(easy, CURLOPT_PROTOCOLS_STR, "https,http"); + curl_easy_setopt(easy, CURLOPT_REDIR_PROTOCOLS_STR, "https,http"); +# endif +#else +# ifdef ENFORCE_HTTPS curl_easy_setopt(easy, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS); curl_easy_setopt(easy, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS); -#else +# else curl_easy_setopt(easy, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS | CURLPROTO_HTTP); curl_easy_setopt(easy, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS | CURLPROTO_HTTP); +# endif #endif SetupCurlEasyCiphers(easy); diff --git a/src/lua/LuaTCPSocket.cpp b/src/lua/LuaTCPSocket.cpp index 670bd3ff0..b18541182 100644 --- a/src/lua/LuaTCPSocket.cpp +++ b/src/lua/LuaTCPSocket.cpp @@ -468,15 +468,25 @@ namespace LuaTCPSocket curl_easy_setopt(tcps->easy, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); if (lua_toboolean(l, 4)) { +#if defined(CURL_AT_LEAST_VERSION) && CURL_AT_LEAST_VERSION(7, 85, 0) + curl_easy_setopt(tcps->easy, CURLOPT_PROTOCOLS_STR, "https"); + curl_easy_setopt(tcps->easy, CURLOPT_REDIR_PROTOCOLS_STR, "https"); +#else curl_easy_setopt(tcps->easy, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS); curl_easy_setopt(tcps->easy, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS); +#endif SetupCurlEasyCiphers(tcps->easy); address = "https://" + address; } else { +#if defined(CURL_AT_LEAST_VERSION) && CURL_AT_LEAST_VERSION(7, 85, 0) + curl_easy_setopt(tcps->easy, CURLOPT_PROTOCOLS_STR, "http"); + curl_easy_setopt(tcps->easy, CURLOPT_REDIR_PROTOCOLS_STR, "http"); +#else curl_easy_setopt(tcps->easy, CURLOPT_PROTOCOLS, CURLPROTO_HTTP); curl_easy_setopt(tcps->easy, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP); +#endif address = "http://" + address; } curl_easy_setopt(tcps->easy, CURLOPT_URL, address.c_str());