From: Jason Skomorowski Date: Tue, 29 Sep 2009 19:49:56 +0000 (-0400) Subject: XML declaration added to command output. X-Git-Tag: v1.2.1~8 X-Git-Url: http://git.indexdata.com/?a=commitdiff_plain;h=0f2e7a8c7c10f2c3ccb24f4184747f3ebb4284c8;p=pazpar2-moved-to-github.git XML declaration added to command output. Bug #3051 --- diff --git a/src/http_command.c b/src/http_command.c index e9d1ff8..a149e50 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -43,6 +43,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // Update this when the protocol changes #define PAZPAR2_PROTOCOL_VERSION "1" +#define HTTP_COMMAND_RESPONSE_PREFIX "\n" + struct http_session { IOCHAN timeout_iochan; // NOTE: This is NOT associated with a socket struct session *psession; @@ -140,7 +142,7 @@ static void error(struct http_response *rs, rs->msg = nmem_strdup(c->nmem, msg); strcpy(rs->code, http_status); - wrbuf_printf(text, "", (int) code, + wrbuf_printf(text, HTTP_COMMAND_RESPONSE_PREFIX "", (int) code, msg); if (addinfo) wrbuf_xmlputs(text, addinfo); @@ -294,7 +296,7 @@ static void cmd_init(struct http_channel *c) s->session_id = sesid; if (process_settings(s->psession, c->request, c->response) < 0) return; - sprintf(buf, "OK%u" + sprintf(buf, HTTP_COMMAND_RESPONSE_PREFIX "OK%u" "" PAZPAR2_PROTOCOL_VERSION "", sesid); rs->payload = nmem_strdup(c->nmem, buf); http_send_response(c); @@ -338,7 +340,7 @@ static void cmd_settings(struct http_channel *c) } if (process_settings(s->psession, rq, rs) < 0) return; - rs->payload = "OK"; + rs->payload = HTTP_COMMAND_RESPONSE_PREFIX "OK"; http_send_response(c); } @@ -476,7 +478,7 @@ static void cmd_bytarget(struct http_channel *c) return; ht = hitsbytarget(s->psession, &count, c->nmem); wrbuf_rewind(c->wrbuf); - wrbuf_puts(c->wrbuf, "OK"); + wrbuf_puts(c->wrbuf, HTTP_COMMAND_RESPONSE_PREFIX "OK"); for (i = 0; i < count; i++) { @@ -683,7 +685,7 @@ static void cmd_record(struct http_channel *c) } else { - wrbuf_puts(c->wrbuf, "\n"); + wrbuf_puts(c->wrbuf, HTTP_COMMAND_RESPONSE_PREFIX "\n"); wrbuf_puts(c->wrbuf, ""); wrbuf_xmlputs(c->wrbuf, rec->recid); wrbuf_puts(c->wrbuf, "\n"); @@ -755,7 +757,7 @@ static void show_records(struct http_channel *c, int active) rl = show(s->psession, sp, startn, &numn, &total, &total_hits, c->nmem); wrbuf_rewind(c->wrbuf); - wrbuf_puts(c->wrbuf, "\nOK\n"); + wrbuf_puts(c->wrbuf, HTTP_COMMAND_RESPONSE_PREFIX "\nOK\n"); wrbuf_printf(c->wrbuf, "%d\n", active); wrbuf_printf(c->wrbuf, "%d\n", total); wrbuf_printf(c->wrbuf, "%d\n", total_hits); @@ -830,7 +832,7 @@ static void cmd_ping(struct http_channel *c) struct http_session *s = locate_session(rq, rs); if (!s) return; - rs->payload = "OK"; + rs->payload = HTTP_COMMAND_RESPONSE_PREFIX "OK"; http_send_response(c); } @@ -887,7 +889,7 @@ static void cmd_search(struct http_channel *c) error(rs, code, addinfo); return; } - rs->payload = "OK"; + rs->payload = HTTP_COMMAND_RESPONSE_PREFIX "OK"; http_send_response(c); } @@ -913,7 +915,7 @@ static void cmd_stat(struct http_channel *c) } wrbuf_rewind(c->wrbuf); - wrbuf_puts(c->wrbuf, ""); + wrbuf_puts(c->wrbuf, HTTP_COMMAND_RESPONSE_PREFIX ""); wrbuf_printf(c->wrbuf, "%d\n", clients); wrbuf_printf(c->wrbuf, "%d\n", stat.num_hits); wrbuf_printf(c->wrbuf, "%d\n", stat.num_records); @@ -936,7 +938,7 @@ static void cmd_info(struct http_channel *c) struct http_response *rs = c->response; wrbuf_rewind(c->wrbuf); - wrbuf_puts(c->wrbuf, "\n"); + wrbuf_puts(c->wrbuf, HTTP_COMMAND_RESPONSE_PREFIX "\n"); wrbuf_puts(c->wrbuf, " \n"); wrbuf_puts(c->wrbuf, "