From 169348bd70306cd03de12122c6c7e898be1ac945 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 14 Dec 2006 15:08:23 +0000 Subject: [PATCH] add auth to xml_curl git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3649 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/xml_int/mod_xml_curl/mod_xml_curl.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c b/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c index 7e03b85db7..bc29fe5c53 100644 --- a/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c +++ b/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c @@ -36,10 +36,12 @@ static const char modname[] = "mod_xml_curl"; static struct { char *url; char *bindings; + char *cred; } globals; SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_url, globals.url); SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_bindings, globals.bindings); +SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_cred, globals.cred); struct config_data { char *name; @@ -93,6 +95,10 @@ static switch_xml_t xml_url_fetch(char *section, config_data.name = filename; if ((config_data.fd = open(filename, O_CREAT | O_RDWR | O_TRUNC)) > -1) { + if (!switch_strlen_zero(globals.cred)) { + curl_easy_setopt(curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_ANY); + curl_easy_setopt(curl_handle, CURLOPT_USERPWD, globals.cred); + } curl_easy_setopt(curl_handle, CURLOPT_POST, 1); curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, data); curl_easy_setopt(curl_handle, CURLOPT_URL, globals.url); @@ -150,7 +156,9 @@ static switch_status_t do_config(void) char *bindings = (char *) switch_xml_attr_soft(param, "bindings"); set_global_bindings(bindings); set_global_url(val); - } + } else if (!strcasecmp(var, "gateway-credentials")) { + set_global_cred(val); + } } }