If backend returns other than 200 (OK) produce diagnostic
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 5 Jan 2015 13:55:40 +0000 (14:55 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 5 Jan 2015 13:55:40 +0000 (14:55 +0100)
src/filter_sparql.cpp

index e5e3b12..6bc889e 100644 (file)
@@ -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;
 }