@@ -384,7 +384,8 @@ PHP_SOLR_API int solr_make_update_stream_request(solr_client_t *client, solr_ust
384384 solr_client_options_t * options = & (client -> options );
385385 int return_status = SUCCESS ;
386386 CURLcode info_status = CURLE_OK ;
387- struct curl_httppost * formpost = NULL , * lastptr = NULL ;
387+ curl_mime * mime = NULL ;
388+ curl_mimepart * part = NULL ;
388389 int is_binary = stream_data -> content_type == SOLR_EXTRACT_CONTENT_STREAM ;
389390 solr_string_t content_type_header ;
390391
@@ -405,13 +406,12 @@ PHP_SOLR_API int solr_make_update_stream_request(solr_client_t *client, solr_ust
405406 curl_easy_setopt (sch -> curl_handle , CURLOPT_POSTFIELDS , stream_data -> content_info -> stream_info .binary_content .str );
406407 curl_easy_setopt (sch -> curl_handle , CURLOPT_POSTFIELDSIZE , stream_data -> content_info -> stream_info .binary_content .len );
407408 solr_string_free_ex (& content_type_header );
408- } else {
409- curl_formadd (& formpost , & lastptr ,
410- CURLFORM_COPYNAME , "PHPSOLRCLIENT" ,
411- CURLFORM_FILE , (const char * ) stream_data -> content_info -> filename .str ,
412- CURLFORM_END
413- );
414- curl_easy_setopt (sch -> curl_handle , CURLOPT_HTTPPOST , formpost );
409+ } else {
410+ mime = curl_mime_init (sch -> curl_handle );
411+ part = curl_mime_addpart (mime );
412+ curl_mime_name (part , "PHPSOLRCLIENT" );
413+ curl_mime_filedata (part , (const char * ) stream_data -> content_info -> filename .str );
414+ curl_easy_setopt (sch -> curl_handle , CURLOPT_MIMEPOST , mime );
415415 }
416416
417417 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
422422
423423 curl_slist_free_all (header_list );
424424
425- if (!is_binary ) {
426- curl_formfree ( formpost );
425+ if (!is_binary && mime ) {
426+ curl_mime_free ( mime );
427427 }
428428
429429 return return_status ;
0 commit comments