Revert "[Core, mod_curl, mod_httapi, mod_http_cache] Compatible with libcurl>=7.87.0" (#2070)

This reverts commit 0398238489.
This commit is contained in:
Andrey Volk authored and GitHub committed 2023-05-01 20:38:51 +03:00
1 parent 0398238489
commit f377a0ff57
6 files changed
+2 -87

No files matched your search

-36
View File
@@ -104,13 +104,8 @@ struct http_sendfile_data_obj {
char *extrapost_elements;
switch_CURL *curl_handle;
char *cacert;
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
curl_mime *mime;
curl_mimepart *part;
#else
struct curl_httppost *formpost;
struct curl_httppost *lastptr;
#endif
uint8_t flags; /* This is for where to send output of the curl_sendfile commands */
switch_stream_handle_t *stream;
char *sendfile_response;
@@ -461,19 +456,8 @@ static void http_sendfile_initialize_curl(http_sendfile_data_t *http_data)
curl_easy_setopt(http_data->curl_handle, CURLOPT_WRITEFUNCTION, http_sendfile_response_callback);
curl_easy_setopt(http_data->curl_handle, CURLOPT_WRITEDATA, (void *) http_data);
/* Initial http_data->mime */
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
http_data->mime = curl_mime_init(http_data->curl_handle);
#endif
/* Add the file to upload as a POST form field */
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
http_data->part = curl_mime_addpart(http_data->mime);
curl_mime_name(http_data->part, http_data->filename_element_name);
curl_mime_filedata(http_data->part, http_data->filename_element);
#else
curl_formadd(&http_data->formpost, &http_data->lastptr, CURLFORM_COPYNAME, http_data->filename_element_name, CURLFORM_FILE, http_data->filename_element, CURLFORM_END);
#endif
if(!zstr(http_data->extrapost_elements))
{
@@ -492,32 +476,16 @@ static void http_sendfile_initialize_curl(http_sendfile_data_t *http_data)
if(argc2 == 2) {
switch_url_decode(argv2[0]);
switch_url_decode(argv2[1]);
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
http_data->part = curl_mime_addpart(http_data->mime);
curl_mime_name(http_data->part, argv2[0]);
curl_mime_data(http_data->part, argv2[1], CURL_ZERO_TERMINATED);
#else
curl_formadd(&http_data->formpost, &http_data->lastptr, CURLFORM_COPYNAME, argv2[0], CURLFORM_COPYCONTENTS, argv2[1], CURLFORM_END);
#endif
}
}
}
/* Fill in the submit field too, even if this isn't really needed */
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
http_data->part = curl_mime_addpart(http_data->mime);
curl_mime_name(http_data->part, "submit");
curl_mime_data(http_data->part, "or_die", CURL_ZERO_TERMINATED);
#else
curl_formadd(&http_data->formpost, &http_data->lastptr, CURLFORM_COPYNAME, "submit", CURLFORM_COPYCONTENTS, "or_die", CURLFORM_END);
#endif
/* what URL that receives this POST */
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
curl_easy_setopt(http_data->curl_handle, CURLOPT_MIMEPOST, http_data->mime);
#else
curl_easy_setopt(http_data->curl_handle, CURLOPT_HTTPPOST, http_data->formpost);
#endif
// This part actually fires off the curl, captures the HTTP response code, and then frees up the handle.
curl_easy_perform(http_data->curl_handle);
@@ -526,11 +494,7 @@ static void http_sendfile_initialize_curl(http_sendfile_data_t *http_data)
curl_easy_cleanup(http_data->curl_handle);
// Clean up the form data from POST
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
curl_mime_free(http_data->mime);
#else
curl_formfree(http_data->formpost);
#endif
}
static switch_status_t http_sendfile_test_file_open(http_sendfile_data_t *http_data, switch_event_t *event)
@@ -1419,11 +1419,7 @@ static switch_status_t httapi_sync(client_t *client)
switch_status_t status = SWITCH_STATUS_FALSE;
int get_style_method = 0;
char *method = NULL;
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
curl_mime *formpost = NULL;
#else
struct curl_httppost *formpost=NULL;
#endif
switch_event_t *save_params = NULL;
const char *put_file;
FILE *fd = NULL;
@@ -1592,11 +1588,7 @@ static switch_status_t httapi_sync(client_t *client)
curl_easy_setopt(curl_handle, CURLOPT_READFUNCTION, put_file_read);
} else if (formpost) {
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
curl_easy_setopt(curl_handle, CURLOPT_MIMEPOST, formpost);
#else
curl_easy_setopt(curl_handle, CURLOPT_HTTPPOST, formpost);
#endif
} else {
switch_curl_easy_setopt(curl_handle, CURLOPT_POST, !get_style_method);
}
@@ -1679,11 +1671,7 @@ static switch_status_t httapi_sync(client_t *client)
switch_curl_slist_free_all(headers);
if (formpost) {
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
curl_mime_free(formpost);
#else
curl_formfree(formpost);
#endif
}
if (client->err) {
@@ -279,11 +279,7 @@ switch_status_t azure_blob_finalise_put(http_profile_t *profile, const char *url
goto done;
}
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x070c01)
switch_curl_easy_setopt(curl_handle, CURLOPT_UPLOAD, 1);
#else
switch_curl_easy_setopt(curl_handle, CURLOPT_PUT, 1);
#endif
switch_curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1);
switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, headers);
switch_curl_easy_setopt(curl_handle, CURLOPT_URL, full_url);
@@ -393,9 +393,7 @@ static switch_status_t http_put(url_cache_t *cache, http_profile_t *profile, swi
goto done;
}
switch_curl_easy_setopt(curl_handle, CURLOPT_UPLOAD, 1);
#if !defined(LIBCURL_VERSION_NUM) || (LIBCURL_VERSION_NUM < 0x070c01)
switch_curl_easy_setopt(curl_handle, CURLOPT_PUT, 1);
#endif
switch_curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1);
switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, headers);
switch_curl_easy_setopt(curl_handle, CURLOPT_URL, full_url);