From: Adam Dickmeiss Date: Wed, 23 May 2007 11:54:46 +0000 (+0000) Subject: For SRU responses allow Content-Type application/xml as well as text/xml. X-Git-Tag: YAZ.3.0.10~85 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=1e49cc7bdcdeb5cb9e7b2e709c5322acccec90df For SRU responses allow Content-Type application/xml as well as text/xml. --- diff --git a/NEWS b/NEWS index 6e30749..3dbc59d 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +For SRU responses allow Content-Type application/xml as well as text/xml. + --- 3.0.4 2007/05/21 Fixed bug in character set conversion of BER strings. Bug introduced diff --git a/client/client.c b/client/client.c index 769c1c5..619f963 100644 --- a/client/client.c +++ b/client/client.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: client.c,v 1.338 2007-05-08 08:22:35 adam Exp $ + * $Id: client.c,v 1.339 2007-05-23 11:54:46 adam Exp $ */ /** \file client.c * \brief yaz-client program @@ -3820,11 +3820,11 @@ static void handle_srw_scan_response(Z_SRW_scanResponse *res) static void http_response(Z_HTTP_Response *hres) { int ret = -1; - const char *content_type = z_HTTP_header_lookup(hres->headers, - "Content-Type"); const char *connection_head = z_HTTP_header_lookup(hres->headers, "Connection"); - if (content_type && !yaz_strcmp_del("text/xml", content_type, "; ")) + if (!yaz_srw_check_content_type(hres)) + printf("Content type does not appear to be XML"); + else { Z_SOAP *soap_package = 0; ODR o = odr_createmem(ODR_DECODE); diff --git a/include/yaz/srw.h b/include/yaz/srw.h index 26e3d3d..4f34a49 100644 --- a/include/yaz/srw.h +++ b/include/yaz/srw.h @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* $Id: srw.h,v 1.33 2007-01-03 08:42:14 adam Exp $ */ +/* $Id: srw.h,v 1.34 2007-05-23 11:54:47 adam Exp $ */ /** * \file srw.h @@ -271,6 +271,9 @@ YAZ_EXPORT int yaz_sru_soap_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu, #define YAZ_XMLNS_DIAG_v1_1 "http://www.loc.gov/zing/srw/diagnostic/" #define YAZ_XMLNS_UPDATE_v0_9 "http://www.loc.gov/zing/srw/update/" +YAZ_EXPORT +int yaz_srw_check_content_type(Z_HTTP_Response *hres); + YAZ_END_CDECL #endif diff --git a/src/srwutil.c b/src/srwutil.c index 2c87b83..af507b1 100644 --- a/src/srwutil.c +++ b/src/srwutil.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: srwutil.c,v 1.56 2007-05-06 20:12:20 adam Exp $ + * $Id: srwutil.c,v 1.57 2007-05-23 11:54:47 adam Exp $ */ /** * \file srwutil.c @@ -235,6 +235,20 @@ static int yaz_base64decode(const char *in, char *out) return olen; } +int yaz_srw_check_content_type(Z_HTTP_Response *hres) +{ + const char *content_type = z_HTTP_header_lookup(hres->headers, + "Content-Type"); + if (content_type) + { + if (!yaz_strcmp_del("text/xml", content_type, "; ")) + return 1; + if (!yaz_strcmp_del("application/xml", content_type, "; ")) + return 1; + } + return 0; +} + /** * Look for authentication tokens in HTTP Basic parameters or in x-username/x-password * parameters. Added by SH. diff --git a/src/zoom-c.c b/src/zoom-c.c index f16b0d1..fa6e729 100644 --- a/src/zoom-c.c +++ b/src/zoom-c.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: zoom-c.c,v 1.130 2007-05-08 08:22:36 adam Exp $ + * $Id: zoom-c.c,v 1.131 2007-05-23 11:54:47 adam Exp $ */ /** * \file zoom-c.c @@ -1341,7 +1341,7 @@ static zoom_ret ZOOM_connection_send_init(ZOOM_connection c) odr_prepend(c->odr_out, "ZOOM-C", ireq->implementationName)); - version = odr_strdup(c->odr_out, "$Revision: 1.130 $"); + version = odr_strdup(c->odr_out, "$Revision: 1.131 $"); if (strlen(version) > 10) /* check for unexpanded CVS strings */ version[strlen(version)-2] = '\0'; ireq->implementationVersion = @@ -3724,14 +3724,15 @@ static void handle_srw_response(ZOOM_connection c, static void handle_http(ZOOM_connection c, Z_HTTP_Response *hres) { int ret = -1; - const char *content_type = z_HTTP_header_lookup(hres->headers, - "Content-Type"); + const char *addinfo = 0; const char *connection_head = z_HTTP_header_lookup(hres->headers, "Connection"); ZOOM_connection_set_mask(c, 0); yaz_log(log_details, "%p handle_http", c); - - if (content_type && !yaz_strcmp_del("text/xml", content_type, "; ")) + + if (!yaz_srw_check_content_type(hres)) + addinfo = "content-type"; + else { Z_SOAP *soap_package = 0; ODR o = c->odr_in; @@ -3766,7 +3767,7 @@ static void handle_http(ZOOM_connection c, Z_HTTP_Response *hres) if (hres->code != 200) set_HTTP_error(c, hres->code, 0, 0); else - set_ZOOM_error(c, ZOOM_ERROR_DECODE, 0); + set_ZOOM_error(c, ZOOM_ERROR_DECODE, addinfo); do_close(c); } ZOOM_connection_remove_task(c);