Compare commits
5 Commits
e21818348a
...
65fe83ef87
Author | SHA1 | Date |
---|---|---|
wmasilva | 65fe83ef87 | |
Aron Podrigal | 5cb74797fe | |
wmasilva | d4dc78afdc | |
wmasilva | aa3ef547c4 | |
António Silva | c8f51d6a04 |
|
@ -50,7 +50,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_curl_load);
|
|||
*/
|
||||
SWITCH_MODULE_DEFINITION(mod_curl, mod_curl_load, mod_curl_shutdown, NULL);
|
||||
|
||||
static char *SYNTAX = "curl url [headers|json|content-type <mime-type>|connect-timeout <seconds>|timeout <seconds>|append_headers <header_name:header_value>[|append_headers <header_name:header_value>]|insecure|secure|[proxy <http://proxy:port>]] [get|head|post|delete|put [data]]";
|
||||
static char *SYNTAX = "curl url [headers|json|content-type <mime-type>|connect-timeout <seconds>|timeout <seconds>|append_headers <header_name:header_value>[|append_headers <header_name:header_value>]|insecure|secure|[proxy <http://proxy:port>]|ipv4|ipv6] [get|head|post|delete|put [data]]";
|
||||
|
||||
#define HTTP_SENDFILE_ACK_EVENT "curl_sendfile::ack"
|
||||
#define HTTP_SENDFILE_RESPONSE_SIZE 32768
|
||||
|
@ -138,6 +138,8 @@ struct curl_options_obj {
|
|||
long connect_timeout;
|
||||
long timeout;
|
||||
int insecure;
|
||||
int ipv4;
|
||||
int ipv6;
|
||||
char *proxy;
|
||||
};
|
||||
typedef struct curl_options_obj curl_options_t;
|
||||
|
@ -217,6 +219,14 @@ static http_data_t *do_lookup_url(switch_memory_pool_t *pool, const char *url, c
|
|||
switch_curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, options->timeout);
|
||||
}
|
||||
|
||||
if (options->ipv4) {
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
|
||||
}
|
||||
|
||||
if (options->ipv6) {
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6);
|
||||
}
|
||||
|
||||
if (options->proxy) {
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_PROXY, options->proxy);
|
||||
}
|
||||
|
@ -937,6 +947,10 @@ SWITCH_STANDARD_APP(curl_app_function)
|
|||
if (++i < argc) {
|
||||
options.proxy = argv[i];
|
||||
}
|
||||
} else if (!strcasecmp("ipv4", argv[i])) {
|
||||
options.ipv4 = 1;
|
||||
} else if (!strcasecmp("ipv6", argv[i])) {
|
||||
options.ipv6 = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1080,6 +1094,10 @@ SWITCH_STANDARD_API(curl_function)
|
|||
if (++i < argc) {
|
||||
options.proxy = argv[i];
|
||||
}
|
||||
} else if (!strcasecmp("ipv4", argv[i])) {
|
||||
options.ipv4 = 1;
|
||||
} else if (!strcasecmp("ipv6", argv[i])) {
|
||||
options.ipv6 = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -106,6 +106,22 @@ char * pgsql_handle_get_error(switch_pgsql_handle_t *handle)
|
|||
return err_str;
|
||||
}
|
||||
|
||||
void pgsql_handle_set_error_if_not_set(switch_pgsql_handle_t *handle, char **err)
|
||||
{
|
||||
char *err_str;
|
||||
|
||||
if (err && !(*err)) {
|
||||
err_str = pgsql_handle_get_error(handle);
|
||||
|
||||
if (zstr(err_str)) {
|
||||
switch_safe_free(err_str);
|
||||
err_str = strdup((char *)"SQL ERROR!");
|
||||
}
|
||||
|
||||
*err = err_str;
|
||||
}
|
||||
}
|
||||
|
||||
static int db_is_up(switch_pgsql_handle_t *handle)
|
||||
{
|
||||
int ret = 0;
|
||||
|
@ -553,8 +569,15 @@ switch_status_t pgsql_handle_exec_detailed(const char *file, const char *func, i
|
|||
goto error;
|
||||
}
|
||||
|
||||
return pgsql_finish_results(handle);
|
||||
if (pgsql_finish_results(handle) != SWITCH_STATUS_SUCCESS) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
error:
|
||||
pgsql_handle_set_error_if_not_set(handle, err);
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -630,6 +653,7 @@ done:
|
|||
|
||||
pgsql_free_result(&result);
|
||||
if (pgsql_finish_results(handle) != SWITCH_STATUS_SUCCESS) {
|
||||
pgsql_handle_set_error_if_not_set(handle, err);
|
||||
sstatus = SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -638,6 +662,7 @@ done:
|
|||
error:
|
||||
|
||||
pgsql_free_result(&result);
|
||||
pgsql_handle_set_error_if_not_set(handle, err);
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
@ -1050,6 +1075,8 @@ switch_status_t pgsql_handle_callback_exec_detailed(const char *file, const char
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
error:
|
||||
|
||||
pgsql_handle_set_error_if_not_set(handle, err);
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue