From 3c69a3a1f368966e501cd4662733476c3bf0474d Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 6 Sep 2013 15:25:43 +0200 Subject: [PATCH] Always supply operation and version for SRU 2.0 While not required by the standard it does improve compatibility. --- src/srw.c | 17 +++++------------ src/srwutil.c | 21 +++++++++++++-------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/srw.c b/src/srw.c index 97cb05d..4013458 100644 --- a/src/srw.c +++ b/src/srw.c @@ -1070,9 +1070,7 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data, ns_srw = xmlNewNs(ptr, BAD_CAST ns, BAD_CAST "zs"); xmlSetNs(ptr, ns_srw); - if (!version2) - add_xsd_string(ptr, "version", (*p)->srw_version); - + add_xsd_string(ptr, "version", (*p)->srw_version); if (version2) { if (queryType) @@ -1123,8 +1121,7 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data, ns_srw = xmlNewNs(ptr, BAD_CAST ns, BAD_CAST "zs"); xmlSetNs(ptr, ns_srw); - if (!version2) - add_xsd_string(ptr, "version", (*p)->srw_version); + add_xsd_string(ptr, "version", (*p)->srw_version); add_xsd_integer(ptr, "numberOfRecords", res->numberOfRecords); add_xsd_string(ptr, "resultSetId", res->resultSetId); add_xsd_integer(ptr, @@ -1157,8 +1154,7 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data, ns_srw = xmlNewNs(ptr, BAD_CAST ns, BAD_CAST "zs"); xmlSetNs(ptr, ns_srw); - if (!version2) - add_xsd_string(ptr, "version", (*p)->srw_version); + add_xsd_string(ptr, "version", (*p)->srw_version); if (version2) { add_xsd_string(ptr, "recordXMLEscaping", req->recordPacking); @@ -1201,8 +1197,7 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data, ns_srw = xmlNewNs(ptr, BAD_CAST ns, BAD_CAST "zs"); xmlSetNs(ptr, ns_srw); - if (!version2) - add_xsd_string(ptr, "version", (*p)->srw_version); + add_xsd_string(ptr, "version", (*p)->srw_version); if (version2) { @@ -1231,9 +1226,7 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data, ns_srw = xmlNewNs(ptr, BAD_CAST ns, BAD_CAST "zs"); xmlSetNs(ptr, ns_srw); - if (!version2) - add_xsd_string(ptr, "version", (*p)->srw_version); - + add_xsd_string(ptr, "version", (*p)->srw_version); if (res->num_terms) { xmlNodePtr rptr = xmlNewChild(ptr, 0, BAD_CAST "terms", 0); diff --git a/src/srwutil.c b/src/srwutil.c index 4f403a5..c18ca64 100644 --- a/src/srwutil.c +++ b/src/srwutil.c @@ -488,8 +488,13 @@ int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu, } } } - if (!operation && query) - operation = "searchRetrieve"; + if (!operation) + { + if (query) + operation = "searchRetrieve"; + else if (scanClause) + operation = "scan"; + } version = yaz_negotiate_sru_version(version); if (!version) @@ -884,19 +889,19 @@ static int yaz_get_sru_parms(const Z_SRW_PDU *srw_pdu, ODR encode, int version2 = strcmp(srw_pdu->srw_version, "2.") > 0; int i = 0; char *queryType; - if (!version2) - yaz_add_name_value_str(encode, name, value, &i, "version", srw_pdu->srw_version); + yaz_add_name_value_str(encode, name, value, &i, "version", + srw_pdu->srw_version); name[i] = "operation"; switch (srw_pdu->which) { case Z_SRW_searchRetrieve_request: - if (!version2) - value[i++] = "searchRetrieve"; + value[i++] = "searchRetrieve"; queryType = srw_pdu->u.request->queryType; if (version2) { - yaz_add_name_value_str(encode, name, value, &i, "queryType", - queryType); + if (queryType && strcmp(queryType, "cql")) + yaz_add_name_value_str(encode, name, value, &i, "queryType", + queryType); yaz_add_name_value_str(encode, name, value, &i, "query", srw_pdu->u.request->query); } -- 1.7.10.4