From 977afbbc5ea020f9e58637f2abd45e02aa707a20 Mon Sep 17 00:00:00 2001 From: Julien BLACHE Date: Wed, 3 Jun 2009 12:01:01 +0200 Subject: [PATCH] Add workaround for empty XML tags in RSP replies The SoundBridge does not support empty XML tags () and treats anything containing such tags as invalid. Adding an empty string to the element works around that, in that mxml won't produce empty tags in this case. Hackish, but dealing with a hackish implementation on the other side :) --- src/httpd_rsp.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/httpd_rsp.c b/src/httpd_rsp.c index ee1b6d2e..bd9d1790 100644 --- a/src/httpd_rsp.c +++ b/src/httpd_rsp.c @@ -391,6 +391,14 @@ rsp_reply_db(struct evhttp_request *req, char **uri, struct evkeyvalq *query) free(db_errmsg); } + /* HACK + * Add a dummy empty string to the playlists element if there is no data + * to return - this prevents mxml from sending out an empty + * tag that the SoundBridge does not handle. It's hackish, but it works. + */ + if (qi.specifiedtotalcount == 0) + mxmlNewText(pls, 0, ""); + evbuf = mxml_to_evbuf(reply); mxmlDelete(reply); @@ -643,6 +651,14 @@ rsp_reply_playlist(struct evhttp_request *req, char **uri, struct evkeyvalq *que free(db_errmsg); } + /* HACK + * Add a dummy empty string to the items element if there is no data + * to return - this prevents mxml from sending out an empty + * tag that the SoundBridge does not handle. It's hackish, but it works. + */ + if (qi.specifiedtotalcount == 0) + mxmlNewText(items, 0, ""); + evbuf = mxml_to_evbuf(reply); mxmlDelete(reply); @@ -833,6 +849,14 @@ rsp_reply_browse(struct evhttp_request *req, char **uri, struct evkeyvalq *query free(db_errmsg); } + /* HACK + * Add a dummy empty string to the items element if there is no data + * to return - this prevents mxml from sending out an empty + * tag that the SoundBridge does not handle. It's hackish, but it works. + */ + if (qi.specifiedtotalcount == 0) + mxmlNewText(items, 0, ""); + evbuf = mxml_to_evbuf(reply); mxmlDelete(reply);