From aa8fed542911807dcf5f753288eb724cc1e1cc8a Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 4 Jun 2007 14:27:48 +0000 Subject: [PATCH] Work on bug #1162.. PP2 right now always dump the payload text/xml response for our convenience. It warns if it's non-wellformed . --- src/http.c | 23 ++++++++++++++++++++--- src/http_command.c | 29 +++++++++++++++++++++-------- 2 files changed, 41 insertions(+), 11 deletions(-) diff --git a/src/http.c b/src/http.c index e46d2ae..007eb01 100644 --- a/src/http.c +++ b/src/http.c @@ -1,4 +1,4 @@ -/* $Id: http.c,v 1.31 2007-05-15 08:51:49 adam Exp $ +/* $Id: http.c,v 1.32 2007-06-04 14:27:48 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -350,8 +350,9 @@ struct http_response *http_parse_response_buf(struct http_channel *c, const char return r; } -struct http_request *http_parse_request(struct http_channel *c, struct http_buf **queue, - int len) +struct http_request *http_parse_request(struct http_channel *c, + struct http_buf **queue, + int len) { struct http_request *r = nmem_malloc(c->nmem, sizeof(*r)); char *p, *p2; @@ -482,6 +483,22 @@ static struct http_buf *http_serialize_response(struct http_channel *c, wrbuf_printf(c->wrbuf, "Content-length: %d\r\n", r->payload ? (int) strlen(r->payload) : 0); wrbuf_printf(c->wrbuf, "Content-type: text/xml\r\n"); + if (1) + { + xmlDoc *doc = xmlParseMemory(r->payload, strlen(r->payload)); + if (doc) + { + yaz_log(YLOG_LOG, "payload: %s", r->payload); + + xmlFreeDoc(doc); + } + else + { + yaz_log(YLOG_WARN, "Sending non-wellformed " + "response (bug #1162"); + yaz_log(YLOG_WARN, "payload: %s", r->payload); + } + } } wrbuf_puts(c->wrbuf, "\r\n"); diff --git a/src/http_command.c b/src/http_command.c index dc98b6e..0c660b6 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -1,4 +1,4 @@ -/* $Id: http_command.c,v 1.44 2007-05-23 21:58:28 adam Exp $ +/* $Id: http_command.c,v 1.45 2007-06-04 14:27:48 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.44 2007-05-23 21:58:28 adam Exp $ + * $Id: http_command.c,v 1.45 2007-06-04 14:27:48 adam Exp $ */ #include @@ -260,7 +260,10 @@ static void targets_termlist(WRBUF wrbuf, struct session *se, int num) { wrbuf_puts(wrbuf, "\n\n"); wrbuf_printf(wrbuf, "%s\n", ht[i].id); - wrbuf_printf(wrbuf, "%s\n", ht[i].name); + wrbuf_puts(wrbuf, ""); + wrbuf_xmlputs(wrbuf, ht[i].name); + wrbuf_puts(wrbuf, "\n"); + wrbuf_printf(wrbuf, "%d\n", ht[i].hits); wrbuf_printf(wrbuf, "%s\n", ht[i].state); wrbuf_printf(wrbuf, "%d\n", ht[i].diagnostic); @@ -307,7 +310,9 @@ static void cmd_termlist(struct http_channel *c) strncpy(tname, name, tp - name); tname[tp - name] = '\0'; - wrbuf_printf(c->wrbuf, "\n\n", tname); + wrbuf_puts(c->wrbuf, "\nwrbuf, tname); + wrbuf_puts(c->wrbuf, "\">\n"); if (!strcmp(tname, "xtargets")) targets_termlist(c->wrbuf, s->psession, num); else @@ -317,7 +322,10 @@ static void cmd_termlist(struct http_channel *c) for (i = 0; i < len && i < num; i++) { wrbuf_puts(c->wrbuf, "\n"); - wrbuf_printf(c->wrbuf, "%s", p[i]->term); + wrbuf_puts(c->wrbuf, ""); + wrbuf_xmlputs(c->wrbuf, p[i]->term); + wrbuf_puts(c->wrbuf, ""); + wrbuf_printf(c->wrbuf, "%d", p[i]->frequency); wrbuf_puts(c->wrbuf, ""); } @@ -404,9 +412,14 @@ static void write_subrecord(struct record *r, WRBUF w, { char *name = session_setting_oneval(client_get_database(r->client), PZ_NAME); - wrbuf_printf(w, "", - client_get_database(r->client)->database->url, - *name ? name : "Unknown"); + wrbuf_printf(w, "client)->database->url); + wrbuf_puts(w, "\" "); + + wrbuf_printf(w, "name=\""); + + wrbuf_xmlputs(w, *name ? name : "Unknown"); + wrbuf_printf(w, "\">"); if (show_details) write_metadata(w, service, r->metadata, 1); wrbuf_puts(w, "\n"); -- 1.7.10.4