[PECL-CVS] [pecl-search_engine-solr] master: Merge pull request #90 from bix0r/gh-65/fix-curl-deprecations

[email protected] (Birgir Haraldsson via GitHub)
Newsgroups php.pecl.cvs
Message-ID <[email protected]>
Author: Birgir Haraldsson (bix0r)
Committer: GitHub (web-flow)
Pusher: bix0r
Date: 2025-10-11T20:03:46+02:00

Commit: https://github.com/php/pecl-search_engine-solr/commit/561ca207d12a242e8a893d58addb1e521c47e265
Raw diff: https://github.com/php/pecl-search_engine-solr/commit/561ca207d12a242e8a893d58addb1e521c47e265.diff

Merge pull request #90 from bix0r/gh-65/fix-curl-deprecations

Fix curl deprecations

Changed paths:
  M  src/solr_functions_client.c


Diff:

diff --git a/src/solr_functions_client.c b/src/solr_functions_client.c
index 14e2a2ab..abdcceb0 100644
--- a/src/solr_functions_client.c
+++ b/src/solr_functions_client.c
@@ -384,7 +384,8 @@ PHP_SOLR_API int solr_make_update_stream_request(solr_client_t *client, solr_ust
     solr_client_options_t *options = &(client->options);
     int return_status = SUCCESS;
     CURLcode info_status = CURLE_OK;
-    struct curl_httppost *formpost = NULL, *lastptr = NULL;
+    curl_mime *mime = NULL;
+    curl_mimepart *part = NULL;
     int is_binary = stream_data->content_type == SOLR_EXTRACT_CONTENT_STREAM;
     solr_string_t content_type_header;
 
@@ -405,13 +406,12 @@ PHP_SOLR_API int solr_make_update_stream_request(solr_client_t *client, solr_ust
         curl_easy_setopt(sch->curl_handle, CURLOPT_POSTFIELDS, stream_data->content_info->stream_info.binary_content.str);
         curl_easy_setopt(sch->curl_handle, CURLOPT_POSTFIELDSIZE, stream_data->content_info->stream_info.binary_content.len);
         solr_string_free_ex(&content_type_header);
-    } else{
-        curl_formadd(&formpost, &lastptr,
-                CURLFORM_COPYNAME, "PHPSOLRCLIENT",
-                CURLFORM_FILE, (const char *) stream_data->content_info->filename.str,
-                CURLFORM_END
-        );
-        curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPPOST, formpost);
+    } else {
+        mime = curl_mime_init(sch->curl_handle);
+        part = curl_mime_addpart(mime);
+        curl_mime_name(part, "PHPSOLRCLIENT");
+        curl_mime_filedata(part, (const char *) stream_data->content_info->filename.str);
+        curl_easy_setopt(sch->curl_handle, CURLOPT_MIMEPOST, mime);
     }
 
     curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPHEADER, header_list);
@@ -422,8 +422,8 @@ PHP_SOLR_API int solr_make_update_stream_request(solr_client_t *client, solr_ust
 
     curl_slist_free_all(header_list);
 
-    if (!is_binary) {
-        curl_formfree(formpost);
+    if (!is_binary && mime) {
+        curl_mime_free(mime);
     }
 
     return return_status;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.