From 6dad41e90dba94b5bab014360c97aad82080ef5c Mon Sep 17 00:00:00 2001 From: Nicolas Mora Date: Sun, 9 Jul 2023 20:24:44 -0400 Subject: [PATCH] Set protocols to http and https only in send requests --- src/u_send_request.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/u_send_request.c b/src/u_send_request.c index e0cbda59..ac812111 100644 --- a/src/u_send_request.c +++ b/src/u_send_request.c @@ -220,6 +220,30 @@ int ulfius_send_http_streaming_request(const struct _u_request * request, break; } } + // Set protocols to http and https only +#if CURL_AT_LEAST_VERSION(7,85,0) + if (curl_easy_setopt(curl_handle, CURLOPT_REDIR_PROTOCOLS_STR, "http,https") != CURLE_OK) { + y_log_message(Y_LOG_LEVEL_ERROR, "Ulfius - Error setting curl redirection protocols"); + ret = U_ERROR_LIBCURL; + break; + } + if (curl_easy_setopt(curl_handle, CURLOPT_PROTOCOLS_STR, "http,https") != CURLE_OK) { + y_log_message(Y_LOG_LEVEL_ERROR, "Ulfius - Error setting curl protocols"); + ret = U_ERROR_LIBCURL; + break; + } +#else + if (curl_easy_setopt(curl_handle, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS) != CURLE_OK) { + y_log_message(Y_LOG_LEVEL_ERROR, "Ulfius - Error setting curl redirection protocols"); + ret = U_ERROR_LIBCURL; + break; + } + if (curl_easy_setopt(curl_handle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS) != CURLE_OK) { + y_log_message(Y_LOG_LEVEL_ERROR, "Ulfius - Error setting curl protocols"); + ret = U_ERROR_LIBCURL; + break; + } +#endif // Set basic auth if defined if (copy_request->auth_basic_user != NULL && copy_request->auth_basic_password != NULL) {