X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fsrwutil.c;h=1de920db0e078305bcb5879c7b5fee713f61f45e;hp=ef27e453434aff196ff90d7e26e3a98d1d92b9b2;hb=9a50808021be48e8ff272f762b9f8245330a79e4;hpb=d7f1bc4eb6c5d8e0d2eba2f040eb9c359eca9e45 diff --git a/src/srwutil.c b/src/srwutil.c index ef27e45..1de920d 100644 --- a/src/srwutil.c +++ b/src/srwutil.c @@ -97,6 +97,8 @@ int yaz_srw_check_content_type(Z_HTTP_Response *hres) return 1; if (!yaz_strcmp_del("application/xml", content_type, "; ")) return 1; + if (!yaz_strcmp_del("application/sru+xml", content_type, "; ")) + return 1; } return 0; } @@ -416,7 +418,7 @@ int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu, p1 = p0 + strlen(p0); if (p1 != p0) db = yaz_decode_sru_dbpath_odr(decode, p0, p1 - p0); - if (!strcmp(hreq->method, "POST")) + if (!strcmp(hreq->method, "POST") && hreq->content_buf) p1 = hreq->content_buf; yaz_uri_to_array(p1, decode, &uri_name, &uri_val); #if YAZ_HAVE_XML2 @@ -497,6 +499,8 @@ int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu, operation = "searchRetrieve"; else if (scanClause) operation = "scan"; + else + operation = "explain"; } version = yaz_negotiate_sru_version(version); @@ -754,15 +758,16 @@ Z_SRW_PDU *yaz_srw_get(ODR o, int which) return yaz_srw_get_pdu(o, which, "2.0"); } +/* http://docs.oasis-open.org/search-ws/searchRetrieve/v1.0/os/schemas/sruResponse.xsd */ Z_SRW_PDU *yaz_srw_get_pdu_e(ODR o, int which, Z_SRW_PDU *req) { int version2 = !req->srw_version || strcmp(req->srw_version, "2.") > 0; Z_SRW_PDU *res = yaz_srw_get_pdu(o, which, req->srw_version); + Z_SRW_extra_arg **l = &res->extra_args, *ea; + l = append_extra_arg(o, l, "version", req->srw_version); if (req->which == Z_SRW_searchRetrieve_request && which == Z_SRW_searchRetrieve_response) { - Z_SRW_extra_arg **l = &res->extra_args; - l = append_extra_arg(o, l, "version", req->srw_version); if (req->u.request->queryType && strcmp(req->u.request->queryType, "cql")) l = append_extra_arg(o, l, "queryType", req->u.request->queryType); @@ -786,7 +791,26 @@ Z_SRW_PDU *yaz_srw_get_pdu_e(ODR o, int which, Z_SRW_PDU *req) if (req->u.request->sort_type == Z_SRW_sort_type_sort) l = append_extra_arg(o, l, "sortKeys", req->u.request->sort.sortKeys); + l = append_extra_arg(o, l, "stylesheet", req->u.request->stylesheet); + } + if (req->which == Z_SRW_explain_request && + which == Z_SRW_explain_response) + { + if (version2) + { + l = append_extra_arg(o, l, "recordXMLEscaping", + req->u.explain_request->recordPacking); + l = append_extra_arg(o, l, "recordPacking", + req->u.explain_request->packing); + } + else + l = append_extra_arg(o, l, "recordPacking", + req->u.explain_request->recordPacking); + l = append_extra_arg(o, l, "stylesheet", + req->u.explain_request->stylesheet); } + for (ea = req->extra_args; ea; ea = ea->next) + l = append_extra_arg(o, l, ea->name, ea->value); return res; } @@ -795,7 +819,7 @@ Z_SRW_PDU *yaz_srw_get_pdu(ODR o, int which, const char *version) Z_SRW_PDU *sr = yaz_srw_get_core_ver(o, version); sr->which = which; - switch(which) + switch (which) { case Z_SRW_searchRetrieve_request: sr->u.request = (Z_SRW_searchRetrieveRequest *)