Add workaround for empty XML tags in RSP replies

The SoundBridge does not support empty XML tags (<foo/>) 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 :)
This commit is contained in:
Julien BLACHE 2009-06-03 12:01:01 +02:00
parent 28350ae9a6
commit 977afbbc5e
1 changed files with 24 additions and 0 deletions

View File

@ -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 <playlists/>
* 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 <items/>
* 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 <items/>
* 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);