mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-24 21:22:09 +00:00
FS-2936 stage 2 please test ASAP
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
BASE=../../../..
|
||||
WANT_CURL=yes
|
||||
|
||||
include $(BASE)/build/modmake.rules
|
||||
|
||||
|
||||
@@ -197,24 +197,24 @@ static switch_status_t http_put(switch_core_session_t *session, const char *url,
|
||||
goto done;
|
||||
}
|
||||
|
||||
curl_handle = curl_easy_init();
|
||||
curl_handle = switch_curl_easy_init();
|
||||
if (!curl_handle) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "curl_easy_init() failure\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "switch_curl_easy_init() failure\n");
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
goto done;
|
||||
}
|
||||
curl_easy_setopt(curl_handle, CURLOPT_UPLOAD, 1);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_PUT, 1);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_URL, url);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_READDATA, file_to_put);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 10);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "freeswitch-http-cache/1.0");
|
||||
curl_easy_perform(curl_handle);
|
||||
curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &httpRes);
|
||||
curl_easy_cleanup(curl_handle);
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_UPLOAD, 1);
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_PUT, 1);
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1);
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_URL, url);
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_READDATA, file_to_put);
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size);
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1);
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 10);
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "freeswitch-http-cache/1.0");
|
||||
switch_curl_easy_perform(curl_handle);
|
||||
switch_curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &httpRes);
|
||||
switch_curl_easy_cleanup(curl_handle);
|
||||
|
||||
if (httpRes == 200 || httpRes == 201 || httpRes == 204) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s saved to %s\n", filename, url);
|
||||
@@ -704,7 +704,7 @@ static void cached_url_destroy(cached_url_t *url, switch_memory_pool_t *pool)
|
||||
static switch_status_t http_get(cached_url_t *url, switch_core_session_t *session)
|
||||
{
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
CURL *curl_handle = NULL;
|
||||
switch_CURL *curl_handle = NULL;
|
||||
http_get_data_t get_data = {0};
|
||||
long httpRes = 0;
|
||||
int start_time_ms = switch_time_now() / 1000;
|
||||
@@ -713,20 +713,20 @@ static switch_status_t http_get(cached_url_t *url, switch_core_session_t *sessio
|
||||
get_data.fd = 0;
|
||||
get_data.url = url;
|
||||
|
||||
curl_handle = curl_easy_init();
|
||||
curl_handle = switch_curl_easy_init();
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "opening %s for URL cache\n", get_data.url->filename);
|
||||
if ((get_data.fd = open(get_data.url->filename, O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR)) > -1) {
|
||||
curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 10);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_URL, get_data.url->url);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, get_file_callback);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *) &get_data);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_HEADERFUNCTION, get_header_callback);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_WRITEHEADER, (void *) url);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "freeswitch-http-cache/1.0");
|
||||
curl_easy_perform(curl_handle);
|
||||
curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &httpRes);
|
||||
curl_easy_cleanup(curl_handle);
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1);
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 10);
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_URL, get_data.url->url);
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, get_file_callback);
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *) &get_data);
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_HEADERFUNCTION, get_header_callback);
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_WRITEHEADER, (void *) url);
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "freeswitch-http-cache/1.0");
|
||||
switch_curl_easy_perform(curl_handle);
|
||||
switch_curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &httpRes);
|
||||
switch_curl_easy_cleanup(curl_handle);
|
||||
close(get_data.fd);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "open() error: %s\n", strerror(errno));
|
||||
@@ -1011,9 +1011,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_http_cache_load)
|
||||
|
||||
setup_dir(&gcache);
|
||||
|
||||
/* init CURL */
|
||||
switch_curl_init();
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -1023,7 +1020,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_http_cache_load)
|
||||
*/
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_http_cache_shutdown)
|
||||
{
|
||||
switch_curl_destroy();
|
||||
url_cache_clear(&gcache, NULL);
|
||||
switch_core_hash_destroy(&gcache.map);
|
||||
switch_mutex_destroy(gcache.mutex);
|
||||
|
||||
Reference in New Issue
Block a user