From: Adam Dickmeiss Date: Sun, 28 Oct 2007 18:55:26 +0000 (+0000) Subject: Fixed bug #1794: Pazpar2 does not return valid XML. X-Git-Tag: PAZPAR2.1.0.5~8 X-Git-Url: http://git.indexdata.com/?a=commitdiff_plain;h=d8313ec350f1eb3a8fc8815a35c5f97aaddfc724;hp=a028d413803b82dd3d9ed025e88b06fbf82d40de;p=pazpar2-moved-to-github.git Fixed bug #1794: Pazpar2 does not return valid XML. The routine, error, was modified so that 'addinfo' in error message is generated using xmlputs. --- diff --git a/src/http_command.c b/src/http_command.c index 158bfaa..1e9d4f6 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -1,4 +1,4 @@ -/* $Id: http_command.c,v 1.65 2007-10-08 13:19:23 adam Exp $ +/* $Id: http_command.c,v 1.66 2007-10-28 18:55:26 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -20,7 +20,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA */ /* - * $Id: http_command.c,v 1.65 2007-10-08 13:19:23 adam Exp $ + * $Id: http_command.c,v 1.66 2007-10-28 18:55:26 adam Exp $ */ #include @@ -139,20 +139,23 @@ static void error(struct http_response *rs, const char *addinfo) { struct http_channel *c = rs->channel; - char text[1024]; + WRBUF text = wrbuf_alloc(); const char *http_status = "417"; const char *msg = get_msg(code); - + rs->msg = nmem_strdup(c->nmem, msg); strcpy(rs->code, http_status); - yaz_snprintf(text, sizeof(text), - "%s", (int) code, - msg, addinfo ? addinfo : ""); + wrbuf_printf(text, "", (int) code, + msg); + if (addinfo) + wrbuf_xmlputs(text, addinfo); + wrbuf_puts(text, ""); yaz_log(YLOG_WARN, "HTTP %s %s%s%s", http_status, msg, addinfo ? ": " : "" , addinfo ? addinfo : ""); - rs->payload = nmem_strdup(c->nmem, text); + rs->payload = nmem_strdup(c->nmem, wrbuf_cstr(text)); + wrbuf_destroy(text); http_send_response(c); }