From 5c5873f5ca3948394011de1d1e21261168a056e5 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 5 Jan 2015 14:55:40 +0100 Subject: [PATCH] If backend returns other than 200 (OK) produce diagnostic --- src/filter_sparql.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/filter_sparql.cpp b/src/filter_sparql.cpp index e5e3b12..6bc889e 100644 --- a/src/filter_sparql.cpp +++ b/src/filter_sparql.cpp @@ -371,7 +371,24 @@ Z_APDU *yf::SPARQL::Session::run_sparql(mp::Package &package, Z_GDU *gdu_resp = http_package.response().get(); Z_APDU *apdu_res = 0; - if (gdu_resp && gdu_resp->which == Z_GDU_HTTP_Response) + if (!gdu_resp || gdu_resp->which != Z_GDU_HTTP_Response) + { + yaz_log(YLOG_LOG, "sparql: no HTTP response"); + apdu_res = odr.create_searchResponse(apdu_req, + YAZ_BIB1_TEMPORARY_SYSTEM_ERROR, + "no HTTP response from backend"); + } + else if (gdu_resp->u.HTTP_Response->code != 200) + { + mp::wrbuf w; + + wrbuf_printf(w, "sparql: HTTP error %d from backend", + gdu_resp->u.HTTP_Response->code); + apdu_res = odr.create_searchResponse(apdu_req, + YAZ_BIB1_TEMPORARY_SYSTEM_ERROR, + w.c_str()); + } + else { Z_HTTP_Response *resp = gdu_resp->u.HTTP_Response; FrontendSetPtr fset(new FrontendSet); @@ -429,13 +446,6 @@ Z_APDU *yf::SPARQL::Session::run_sparql(mp::Package &package, } } } - else - { - yaz_log(YLOG_LOG, "sparql: no HTTP response"); - apdu_res = odr.create_searchResponse(apdu_req, - YAZ_BIB1_TEMPORARY_SYSTEM_ERROR, - "no HTTP response from backend"); - } return apdu_res; } -- 1.7.10.4