Module: kamailio Branch: master Commit: 778e4a1e7ea2143089749bab317d87fcfdcd6629 URL: https://github.com/kamailio/kamailio/commit/778e4a1e7ea2143089749bab317d87fc...
Author: Federico Cabiddu federico.cabiddu@gmail.com Committer: Federico Cabiddu federico.cabiddu@gmail.com Date: 2016-02-26T15:21:41+01:00
http_async_client: add "suspend" to $http_req keys
---
Modified: modules/http_async_client/doc/http_async_client_admin.xml Modified: modules/http_async_client/http_async_client_mod.c
---
Diff: https://github.com/kamailio/kamailio/commit/778e4a1e7ea2143089749bab317d87fc... Patch: https://github.com/kamailio/kamailio/commit/778e4a1e7ea2143089749bab317d87fc...
---
diff --git a/modules/http_async_client/doc/http_async_client_admin.xml b/modules/http_async_client/doc/http_async_client_admin.xml index 3c3f46b..e2c30d9 100644 --- a/modules/http_async_client/doc/http_async_client_admin.xml +++ b/modules/http_async_client/doc/http_async_client_admin.xml @@ -573,6 +573,7 @@ http_async_query("https://example.com/test.php", "HTTP_REPLY"); <listitem><para><emphasis>tls_client_cert</emphasis>: sets the client certificate to use (see <emphasis>http_set_tls_client_cert()</emphasis>)</para></listitem> <listitem><para><emphasis>tls_client_key</emphasis>: sets the client certificate key to use (see <emphasis>http_set_tls_client_key()</emphasis>)</para></listitem> <listitem><para><emphasis>tls_ca_path</emphasis>: sets the CA certificate files to use (see <emphasis>http_set_tls_ca_path()</emphasis>)</para></listitem> + <listitem><para><emphasis>suspend</emphasis>: if set to 0 doesn't suspend the current transaction before performing the query (see <emphasis>http_async_suspend()</emphasis>)</para></listitem> </itemizedlist> <example> <title><literal>$http_req(key)</literal> variable usage</title> @@ -583,6 +584,7 @@ $http_req(timeout) = 100; # 100 ms $http_req(method) = "DELETE"; $http_req(hdr) = "X-Sip-Call-Id: " + $ci; $http_req(hdr) = "X-Foo: bar"; # add a 2nd header +$http_req(suspend) = 0; # don't suspend the transaction, continue routing script's execution # the following request will use the above parameters http_async_query("https://example.com/test.php", "HTTP_REPLY"); ... diff --git a/modules/http_async_client/http_async_client_mod.c b/modules/http_async_client/http_async_client_mod.c index 20d953a..e945136 100644 --- a/modules/http_async_client/http_async_client_mod.c +++ b/modules/http_async_client/http_async_client_mod.c @@ -124,7 +124,7 @@ enum http_req_name_t { E_HRN_ALL = 0, E_HRN_HDR, E_HRN_METHOD, E_HRN_TIMEOUT, E_HRN_TLS_CA_PATH, E_HRN_TLS_CLIENT_KEY, - E_HRN_TLS_CLIENT_CERT + E_HRN_TLS_CLIENT_CERT, E_HRN_SUSPEND };
static cmd_export_t cmds[]={ @@ -737,6 +737,8 @@ static int ah_parse_req_name(pv_spec_p sp, str *in) { case 7: if(strncmp(in->s, "timeout", 7)==0) sp->pvp.pvn.u.isname.name.n = E_HRN_TIMEOUT; + else if(strncmp(in->s, "suspend", 7)==0) + sp->pvp.pvn.u.isname.name.n = E_HRN_SUSPEND; else goto error; break; case 11: @@ -849,6 +851,17 @@ static int ah_set_req(struct sip_msg* msg, pv_param_t *param, set_query_param(&ah_params.tls_client_cert, tls_client_cert); } break; + case E_HRN_SUSPEND: + if (tval) { + if (!(tval->flags & PV_VAL_INT)) { + LM_ERR("invalid value type for $http_req(suspend)\n"); + return -1; + } + ah_params.suspend_transaction = tval->ri?1:0; + } else { + ah_params.suspend_transaction = 1; + } + break; }
return 1;