Module: kamailio Branch: master Commit: 35014d465152fbd297fc3c2c951f0a24eabcd84a URL: https://github.com/kamailio/kamailio/commit/35014d465152fbd297fc3c2c951f0a24...
Author: Olle E. Johansson oej@edvina.net Committer: Olle E. Johansson oej@edvina.net Date: 2016-05-12T21:10:07+02:00
http_client Add a function to check if a connection exists to the development API
---
Modified: modules/http_client/curl_api.c Modified: modules/http_client/curl_api.h Modified: modules/http_client/curlcon.c Modified: modules/http_client/curlcon.h Modified: modules/http_client/doc/http_client_devel.xml
---
Diff: https://github.com/kamailio/kamailio/commit/35014d465152fbd297fc3c2c951f0a24... Patch: https://github.com/kamailio/kamailio/commit/35014d465152fbd297fc3c2c951f0a24...
---
diff --git a/modules/http_client/curl_api.c b/modules/http_client/curl_api.c index c0f8fc5..c0e9d71 100644 --- a/modules/http_client/curl_api.c +++ b/modules/http_client/curl_api.c @@ -30,6 +30,7 @@ int bind_httpc_api(httpc_api_t *api) } api->http_connect = curl_con_query_url; api->http_query = http_query; + api->http_connection_exists = http_connection_exists;
return 0; } diff --git a/modules/http_client/curl_api.h b/modules/http_client/curl_api.h index 236aef6..cbca5e3 100644 --- a/modules/http_client/curl_api.h +++ b/modules/http_client/curl_api.h @@ -30,14 +30,17 @@
#include "../../sr_module.h" #include "functions.h" +#include "curlcon.h"
typedef int (*httpcapi_httpconnect_f)(struct sip_msg *msg, const str *connection, const str* _url, str* _result, const char *contenttype, const str* _post); typedef int (*httpcapi_httpquery_f)(struct sip_msg* _m, char* _url, str* _dst, char* _post); +typedef int (*httpcapi_curlcon_exists_f)(str* _name);
typedef struct httpc_api { httpcapi_httpconnect_f http_connect; httpcapi_httpquery_f http_query; + httpcapi_curlcon_exists_f http_connection_exists; } httpc_api_t;
typedef int (*bind_httpc_api_f)(httpc_api_t *api); diff --git a/modules/http_client/curlcon.c b/modules/http_client/curlcon.c index aa03fba..b2caa4a 100644 --- a/modules/http_client/curlcon.c +++ b/modules/http_client/curlcon.c @@ -124,6 +124,20 @@ unsigned int curl_connection_count() }
+/*! Check if CURL connection exists + */ +int http_connection_exists(str *name) +{ + curl_con_t *cc; + + if (curl_get_connection(name) != NULL) { + return 1; + } + + LM_DBG("curl_connection_exists no success in looking for httpcon: [%.*s]\n", name->len, name->s); + return 0; +} + /*! Find CURL connection by name */ curl_con_t* curl_get_connection(str *name) diff --git a/modules/http_client/curlcon.h b/modules/http_client/curlcon.h index 0380648..f878258 100644 --- a/modules/http_client/curlcon.h +++ b/modules/http_client/curlcon.h @@ -39,6 +39,10 @@ extern curl_con_t *_curl_con_root; */ unsigned int curl_connection_count();
+/*! Check if CURL connection exists + */ +int http_connection_exists(str *name); + int http_client_load_config(str *config_file);
int curl_parse_param(char *val); diff --git a/modules/http_client/doc/http_client_devel.xml b/modules/http_client/doc/http_client_devel.xml index 542f50e..ad06026 100644 --- a/modules/http_client/doc/http_client_devel.xml +++ b/modules/http_client/doc/http_client_devel.xml @@ -73,6 +73,19 @@ </section> <section> <title> + <function moreinfo="none">int http_connection_exists(str *connection)</function> + </title> + <para> + Check if a connection definition exists. Connections are defined as modparam's + in the http_client modules. + </para> + <para> + Returns 1 if the connection exists, 0 if a connection with the given name can't + be found. + </para> + </section> + <section> + <title> <function moreinfo="none">http_query(msg, url, dest, post)</function> </title> <para>