提交 b13611b1 authored 作者: Anthony Minessale's avatar Anthony Minessale

add better debug line to xml_curl

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6860 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 13c02c87
...@@ -128,16 +128,14 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con ...@@ -128,16 +128,14 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con
return xml; return xml;
} }
if (!(data = switch_mprintf("hostname=%s&section=%s&tag_name=%s&key_name=%s&key_value=%s%s%s", data = switch_mprintf("hostname=%s&section=%s&tag_name=%s&key_name=%s&key_value=%s%s%s",
hostname, hostname,
section, section,
tag_name ? tag_name : "", switch_str_nil(tag_name),
key_name ? key_name : "", switch_str_nil(key_name),
key_value ? key_value : "", params ? strchr(params, '=') ? "&" : "&params=" : "", params ? params : ""))) { switch_str_nil(key_value),
params ? strchr(params, '=') ? "&" : "&params=" : "", params ? params : "");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n"); switch_assert(data);
return NULL;
}
switch_uuid_get(&uuid); switch_uuid_get(&uuid);
switch_uuid_format(uuid_str, &uuid); switch_uuid_format(uuid_str, &uuid);
...@@ -166,7 +164,7 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con ...@@ -166,7 +164,7 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con
curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "freeswitch-xml/1.0"); curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "freeswitch-xml/1.0");
if (binding->disable100continue) { if (binding->disable100continue) {
slist = curl_slist_append(slist,"Expect:"); slist = curl_slist_append(slist, "Expect:");
curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, slist); curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, slist);
} }
...@@ -175,7 +173,7 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con ...@@ -175,7 +173,7 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con
} }
curl_easy_perform(curl_handle); curl_easy_perform(curl_handle);
curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE,&httpRes); curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &httpRes);
curl_easy_cleanup(curl_handle); curl_easy_cleanup(curl_handle);
curl_slist_free_all(headers); curl_slist_free_all(headers);
close(config_data.fd); close(config_data.fd);
...@@ -183,19 +181,17 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con ...@@ -183,19 +181,17 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening temp file!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening temp file!\n");
} }
switch_safe_free(data); if (httpRes == 200) {
if(httpRes==200) {
if (!(xml = switch_xml_parse_file(filename))) { if (!(xml = switch_xml_parse_file(filename))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Parsing Result!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Parsing Result!\n");
} }
} else { } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received HTTP error %ld trying to fetch %s\n",httpRes,key_value); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received HTTP error %ld trying to fetch %s\ndata: [%s]\n", httpRes, binding->url, data);
xml=NULL; xml = NULL;
} }
/* Debug by leaving the file behind for review */ /* Debug by leaving the file behind for review */
if(keep_files_around) { if (keep_files_around) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "XML response is in %s\n", filename); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "XML response is in %s\n", filename);
} else { } else {
if (unlink(filename) != 0) { if (unlink(filename) != 0) {
...@@ -203,6 +199,8 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con ...@@ -203,6 +199,8 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con
} }
} }
switch_safe_free(data);
return xml; return xml;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论