Silence a few libcurl warnings

About CURLOPT_PROTOCOLS and CURLOPT_REDIR_PROTOCOLS being deprecated in 7.85.0.
This commit is contained in:
Tamás Bálint Misius 2022-12-25 11:16:54 +01:00
parent d3ab2e231e
commit a3fe59a2c8
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2
2 changed files with 22 additions and 2 deletions

View File

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

View File

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