From 6ba8ab1db53ad6d1f6924712531bcddc0b3ff2ce Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Fri, 9 Oct 2020 08:10:39 +0000 Subject: [PATCH] Update: Use different xmlns depending on root node --- src/admin.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/admin.c b/src/admin.c index 41a0144b..e55aae0e 100644 --- a/src/admin.c +++ b/src/admin.c @@ -449,7 +449,17 @@ void admin_send_response(xmlDocPtr doc, xmlDocDumpMemory(doc, &buff, &len); content_type = "text/xml"; } else { - char *json = xml2json_render_doc_simple(doc, "http://icecast.org/specs/legacyresponse-0.0.1"); + xmlNodePtr xmlroot = xmlDocGetRootElement(doc); + const char *ns; + char *json; + + if (strcmp((const char *)xmlroot->name, "iceresponse") == 0) { + ns = "http://icecast.org/specs/legacyresponse-0.0.1"; + } else { + ns = "http://icecast.org/specs/legacystats-0.0.1"; + } + + json = xml2json_render_doc_simple(doc, ns); buff = xmlStrdup(XMLSTR(json)); len = strlen(json); free(json);