From: Adam Dickmeiss Date: Mon, 5 Jan 2015 13:55:40 +0000 (+0100) Subject: If backend returns other than 200 (OK) produce diagnostic X-Git-Tag: v0.1~4 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=5c5873f5ca3948394011de1d1e21261168a056e5;p=mp-sparql-moved-to-github.git If backend returns other than 200 (OK) produce diagnostic --- 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; }