From: SangYoun Kwak Date: Fri, 16 Feb 2024 11:13:02 +0000 (+0900) Subject: plugin: Modify CURLOPT_HTTPPOST to CURLOPT_MIMEPOST X-Git-Tag: accepted/tizen/unified/20240219.160437~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8facde8f39b4c73f25c6af0fff6b9cc1f363a1b5;p=platform%2Fcore%2Fsystem%2Fupdate-control.git plugin: Modify CURLOPT_HTTPPOST to CURLOPT_MIMEPOST Since CURLOPT_HTTPPOST is deprecated option in libcurl, build error occured in Tizen-Unified-X environment. According to the documentation of libcurl, CURLOPT_HTTPPOST is replaced by CURLOPT_MIMEPOST. Change-Id: Id2dfbe5d7712a2fdfbd36d71f8af09f50160897f Signed-off-by: SangYoun Kwak --- diff --git a/src/plugin/http_util.c b/src/plugin/http_util.c index 05b4b3f..5bacc8a 100644 --- a/src/plugin/http_util.c +++ b/src/plugin/http_util.c @@ -394,6 +394,7 @@ int http_util_send_request(fmwup_http_e type, const char *req_url, char **res_he GByteArray *response_body= NULL; CURLcode err; int curl_ret_code = 0; + curl_mime *mime = NULL; curl = curl_easy_init(); retvm_if(!curl, -EIO, "Failed to init curl"); @@ -404,8 +405,15 @@ int http_util_send_request(fmwup_http_e type, const char *req_url, char **res_he curl_ret_code = curl_easy_setopt(curl, CURLOPT_HTTPGET, 1); retvm_if(CURLE_OK != curl_ret_code, -EIO, "Failed to curl_easy_setopt with CURLOPT_HTTPGET : ret_code[%d]", curl_ret_code); } else if (type == FMWUP_HTTP_POST) { - curl_ret_code = curl_easy_setopt(curl, CURLOPT_HTTPPOST, 1); - retvm_if(CURLE_OK != curl_ret_code, -EIO, "Failed to curl_easy_setopt with CURLOPT_HTTPPOST : ret_code[%d]", curl_ret_code); + mime = curl_mime_init(curl); + retvm_if(!mime, -EIO, "curl_mime_init: Failed to init mime"); + + curl_ret_code = curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime); + if (curl_ret_code != CURLE_OK) { + curl_mime_free(mime); + _E("Failed to curl_easy_setopt with CURLOPT_MIMEPOST : ret_code[%d]", curl_ret_code); + return -EIO; + } } else { return -1; } @@ -426,6 +434,8 @@ int http_util_send_request(fmwup_http_e type, const char *req_url, char **res_he __curl_set_response(curl, response_header, response_body, res_header, res_body, NULL); END: + if (mime) + curl_mime_free(mime); if (response_header) g_byte_array_free(response_header, TRUE); if (response_body)