Module: kamailio Branch: master Commit: 0183de317d0d2578e83061fc7541afde37ec4853 URL: https://github.com/kamailio/kamailio/commit/0183de317d0d2578e83061fc7541afde...
Author: Federico Cabiddu federico.cabiddu@gmail.com Committer: GitHub noreply@github.com Date: 2021-03-30T14:04:06+02:00
Merge pull request #2694 from gled-rs/http_async_follow_redirect
http_async_client: add curl_follow_redirect parameter
---
Modified: src/modules/http_async_client/doc/http_async_client_admin.xml Modified: src/modules/http_async_client/http_async_client_mod.c Modified: src/modules/http_async_client/http_multi.c Modified: src/modules/http_async_client/http_multi.h
---
Diff: https://github.com/kamailio/kamailio/commit/0183de317d0d2578e83061fc7541afde... Patch: https://github.com/kamailio/kamailio/commit/0183de317d0d2578e83061fc7541afde...
---
diff --git a/src/modules/http_async_client/doc/http_async_client_admin.xml b/src/modules/http_async_client/doc/http_async_client_admin.xml index 1efe0a1f33..4e4701fcb3 100644 --- a/src/modules/http_async_client/doc/http_async_client_admin.xml +++ b/src/modules/http_async_client/doc/http_async_client_admin.xml @@ -200,6 +200,26 @@ modparam("http_async_client", "curl_verbose", 1) </programlisting> </example> </section> + <section> + <title><varname>curl_follow_redirect</varname> (integer)</title> + <para> + If defined to a non-zero value, will tell curl to follow HTTP 3xx redirects. + </para> + <para> + <emphasis> + Default value is 0 (disabled). + </emphasis> + </para> + <example> + <title>Set <varname>curl_follow_redirect</varname> parameter</title> + <programlisting format="linespecific"> +... +modparam("http_async_client", "curl_follow_redirect", 1) +... +</programlisting> + </example> + </section> + <section> <title><varname>memory_manager</varname> (string)</title> <para> diff --git a/src/modules/http_async_client/http_async_client_mod.c b/src/modules/http_async_client/http_async_client_mod.c index 7f56f98a56..f369cf083d 100644 --- a/src/modules/http_async_client/http_async_client_mod.c +++ b/src/modules/http_async_client/http_async_client_mod.c @@ -74,6 +74,7 @@ int tls_version = 0; // Use default SSL version in HTTPS requests (see curl/curl int tls_verify_host = 1; // By default verify host in HTTPS requests int tls_verify_peer = 1; // By default verify peer in HTTPS requests int curl_verbose = 0; +int curl_follow_redirect = 0; char* tls_client_cert = NULL; // client SSL certificate path, defaults to NULL char* tls_client_key = NULL; // client SSL certificate key path, defaults to NULL char* tls_ca_path = NULL; // certificate authority dir path, defaults to NULL @@ -150,6 +151,7 @@ static param_export_t params[]={ {"tls_verify_host", INT_PARAM, &tls_verify_host}, {"tls_verify_peer", INT_PARAM, &tls_verify_peer}, {"curl_verbose", INT_PARAM, &curl_verbose}, + {"curl_follow_redirect", INT_PARAM, &curl_follow_redirect}, {"tls_client_cert", PARAM_STRING, &tls_client_cert}, {"tls_client_key", PARAM_STRING, &tls_client_key}, {"tls_ca_path", PARAM_STRING, &tls_ca_path}, diff --git a/src/modules/http_async_client/http_multi.c b/src/modules/http_async_client/http_multi.c index c4351b1b94..7baf153140 100644 --- a/src/modules/http_async_client/http_multi.c +++ b/src/modules/http_async_client/http_multi.c @@ -462,6 +462,9 @@ int new_request(str *query, http_m_params_t *query_params, http_multi_cbe_t cb, curl_easy_setopt(cell->easy, CURLOPT_VERBOSE, 1L); curl_easy_setopt(cell->easy, CURLOPT_DEBUGFUNCTION, debug_cb); } + if (curl_follow_redirect) { + curl_easy_setopt(cell->easy, CURLOPT_FOLLOWLOCATION, 1L); + } curl_easy_setopt(cell->easy, CURLOPT_ERRORBUFFER, cell->error); curl_easy_setopt(cell->easy, CURLOPT_PRIVATE, cell); curl_easy_setopt(cell->easy, CURLOPT_SSL_VERIFYPEER, cell->params.tls_verify_peer); diff --git a/src/modules/http_async_client/http_multi.h b/src/modules/http_async_client/http_multi.h index 0e63811df7..2a99b8cb36 100644 --- a/src/modules/http_async_client/http_multi.h +++ b/src/modules/http_async_client/http_multi.h @@ -58,6 +58,7 @@ extern stat_var *errors; extern stat_var *timeouts; extern int tls_version; extern int curl_verbose; +extern int curl_follow_redirect;
void set_curl_mem_callbacks(void); int init_http_multi();