From: Adam Dickmeiss Date: Wed, 31 Dec 2003 00:14:00 +0000 (+0000) Subject: Fix problem with print ODR/HTTP/odr_reset X-Git-Tag: YAZ.2.0.9~4 X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;h=da52cf68299952193806f8093c04e46d1bbf8375;p=yaz-moved-to-github.git Fix problem with print ODR/HTTP/odr_reset --- diff --git a/client/client.c b/client/client.c index 9bbeb1d..daee888 100644 --- a/client/client.c +++ b/client/client.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2003, Index Data * See the file LICENSE for details. * - * $Id: client.c,v 1.218 2003-12-30 00:22:11 adam Exp $ + * $Id: client.c,v 1.219 2003-12-31 00:14:00 adam Exp $ */ #include @@ -1197,8 +1197,12 @@ static int send_srw(Z_SRW_PDU *sr) char *buf_out; int len_out; int r; - if (apdu_file && !z_GDU(print, &gdu, 0, 0)) - printf ("Failed to print outgoing APDU\n"); + if (apdu_file) + { + if (!z_GDU(print, &gdu, 0, 0)) + printf ("Failed to print outgoing APDU\n"); + odr_reset(print); + } buf_out = odr_getbuf(out, &len_out, 0); /* we don't odr_reset(out), since we may need the buffer again */ @@ -3446,7 +3450,10 @@ void wait_and_handle_response() odr_dumpBER(f, netbuffer, res); fprintf(f, "---------\n"); if (apdu_file) + { z_GDU(print, &gdu, 0, 0); + odr_reset(print); + } if (conn && cs_more(conn)) continue; break; diff --git a/src/seshigh.c b/src/seshigh.c index 8dd5782..533ab9a 100644 --- a/src/seshigh.c +++ b/src/seshigh.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2003, Index Data * See the file LICENSE for details. * - * $Id: seshigh.c,v 1.11 2003-12-30 00:29:53 adam Exp $ + * $Id: seshigh.c,v 1.12 2003-12-31 00:14:01 adam Exp $ */ /* @@ -353,10 +353,11 @@ void ir_session(IOCHAN h, int event) return; } req->request_mem = odr_extract_mem(assoc->decode); - if (assoc->print && !z_GDU(assoc->print, &req->gdu_request, 0, 0)) - { - yaz_log(LOG_WARN, "ODR print error: %s", - odr_errmsg(odr_geterror(assoc->print))); + if (assoc->print) + { + if (!z_GDU(assoc->print, &req->gdu_request, 0, 0)) + yaz_log(LOG_WARN, "ODR print error: %s", + odr_errmsg(odr_geterror(assoc->print))); odr_reset(assoc->print); } request_enq(&assoc->incoming, req); @@ -1354,10 +1355,11 @@ static int process_gdu_response(association *assoc, request *req, Z_GDU *res) { odr_setbuf(assoc->encode, req->response, req->size_response, 1); - if (assoc->print && !z_GDU(assoc->print, &res, 0, 0)) + if (assoc->print) { - yaz_log(LOG_WARN, "ODR print error: %s", - odr_errmsg(odr_geterror(assoc->print))); + if (!z_GDU(assoc->print, &res, 0, 0)) + yaz_log(LOG_WARN, "ODR print error: %s", + odr_errmsg(odr_geterror(assoc->print))); odr_reset(assoc->print); } if (!z_GDU(assoc->encode, &res, 0, 0)) @@ -1561,7 +1563,7 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb) assoc->init->implementation_name, odr_prepend(assoc->encode, "GFS", resp->implementationName)); - version = odr_strdup(assoc->encode, "$Revision: 1.11 $"); + version = odr_strdup(assoc->encode, "$Revision: 1.12 $"); if (strlen(version) > 10) /* check for unexpanded CVS strings */ version[strlen(version)-2] = '\0'; resp->implementationVersion = odr_prepend(assoc->encode, diff --git a/src/zgdu.c b/src/zgdu.c index 692ccf0..543eda6 100644 --- a/src/zgdu.c +++ b/src/zgdu.c @@ -2,7 +2,7 @@ * Copyright (c) 2002-2003, Index Data. * See the file LICENSE for details. * - * $Id: zgdu.c,v 1.4 2003-12-30 15:18:53 adam Exp $ + * $Id: zgdu.c,v 1.5 2003-12-31 00:14:01 adam Exp $ */ #include @@ -294,11 +294,10 @@ int z_GDU (ODR o, Z_GDU **p, int opt, const char *name) if (!z_HTTP_header_lookup((*p)->u.HTTP_Response->headers, "Content-Length")) { - char lstr[20]; - sprintf(lstr, "%d", (*p)->u.HTTP_Response->content_len); - z_HTTP_header_add(o, - &(*p)->u.HTTP_Response->headers, - "Content-Length", lstr); + char lstr[60]; + sprintf(lstr, "Content-Length: %d\r\n", + (*p)->u.HTTP_Response->content_len); + odr_write(o, (unsigned char *) lstr, strlen(lstr)); } for (h = (*p)->u.HTTP_Response->headers; h; h = h->next) { @@ -333,11 +332,10 @@ int z_GDU (ODR o, Z_GDU **p, int opt, const char *name) !z_HTTP_header_lookup((*p)->u.HTTP_Request->headers, "Content-Length")) { - char lstr[20]; - sprintf(lstr, "%d", (*p)->u.HTTP_Request->content_len); - z_HTTP_header_add(o, - &(*p)->u.HTTP_Request->headers, - "Content-Length", lstr); + char lstr[60]; + sprintf(lstr, "Content-Length: %d\r\n", + (*p)->u.HTTP_Request->content_len); + odr_write(o, (unsigned char *) lstr, strlen(lstr)); } for (h = (*p)->u.HTTP_Request->headers; h; h = h->next) {