ZOOM: throw present request out of range again YAZ-739
[yaz-moved-to-github.git] / src / seshigh.c
index 77539a7..cc7959f 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2013 Index Data
+ * Copyright (C) Index Data
  * See the file LICENSE for details.
  */
 /**
@@ -688,6 +688,7 @@ static int retrieve_fetch(association *assoc, bend_fetch_rr *rr)
         if (r)
         {
             rr->errcode = YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS;
+            rr->surrogate_flag = 1;
             if (details)
                 rr->errstring = odr_strdup(rr->stream, details);
         }
@@ -1051,9 +1052,8 @@ static void srw_bend_search(association *assoc,
                     srw_res->resultSetIdleTime =
                         odr_intdup(assoc->encode, *rr.srw_setnameIdleTime );
                }
-                
+
                 srw_res->facetList = yaz_oi_get_facetlist(&rr.search_info);
-                yaz_log(YLOG_LOG, "facetList res = %p",srw_res->facetList);
                 if (start > rr.hits || start < 1)
                 {
                     /* if hits<=0 and start=1 we don't return a diagnostic */
@@ -1261,8 +1261,9 @@ static void srw_bend_explain(association *assoc,
 {
     Z_SRW_explainRequest *srw_req = sr->u.explain_request;
     yaz_log(log_requestdetail, "Got SRW ExplainRequest");
-    *http_code = 404;
     srw_bend_init(assoc, &srw_res->diagnostics, &srw_res->num_diagnostics, sr);
+    if (!assoc->init && srw_res->num_diagnostics == 0)
+        *http_code = 404;
     if (assoc->init)
     {
         bend_explain_rr rr;
@@ -1488,8 +1489,9 @@ static void srw_bend_update(association *assoc,
     Z_SRW_updateRequest *srw_req = sr->u.update_request;
     yaz_log(log_session, "SRWUpdate action=%s", srw_req->operation);
     yaz_log(YLOG_DEBUG, "num_diag = %d", srw_res->num_diagnostics );
-    *http_code = 404;
     srw_bend_init(assoc, &srw_res->diagnostics, &srw_res->num_diagnostics, sr);
+    if (!assoc->init && srw_res->num_diagnostics == 0)
+        *http_code = 404;
     if (assoc->init)
     {
        bend_update_rr rr;
@@ -1932,11 +1934,6 @@ static void process_http_request(association *assoc, request *req)
             hres->code = http_code;
 
             strcpy(ctype, "text/xml");
-            if (charset && strlen(charset) < sizeof(ctype)-30)
-            {
-                strcat(ctype, "; charset=");
-                strcat(ctype, charset);
-            }
             z_HTTP_header_add(o, &hres->headers, "Content-Type", ctype);
         }
         else
@@ -2682,7 +2679,9 @@ static Z_APDU *process_searchRequest(association *assoc, request *reqb)
         bsrr->errcode = 0;
         bsrr->errstring = NULL;
         bsrr->search_info = NULL;
-        bsrr->search_input = req->otherInfo;
+        bsrr->search_input = req->additionalSearchInfo;
+        if (!bsrr->search_input)
+            bsrr->search_input = req->otherInfo;
         bsrr->present_number = *req->mediumSetPresentNumber;
 
         if (assoc->server && assoc->server->cql_transform
@@ -3099,7 +3098,6 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb)
         {
             Z_Entry *e;
             Z_TermInfo *t;
-            Odr_oct *o;
 
             tab[i] = e = (Z_Entry *)odr_malloc(assoc->encode, sizeof(*e));
             if (bsrr->entries[i].occurrences >= 0)
@@ -3126,12 +3124,10 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb)
                 t->term = (Z_Term *)
                     odr_malloc(assoc->encode, sizeof(*t->term));
                 t->term->which = Z_Term_general;
-                t->term->u.general = o =
-                    (Odr_oct *)odr_malloc(assoc->encode, sizeof(Odr_oct));
-                o->buf = (unsigned char *)
-                    odr_malloc(assoc->encode, o->len = o->size =
-                               strlen(bsrr->entries[i].term));
-                memcpy(o->buf, bsrr->entries[i].term, o->len);
+                t->term->u.general =
+                    odr_create_Odr_oct(assoc->encode,
+                                       bsrr->entries[i].term,
+                                       strlen(bsrr->entries[i].term));
                 yaz_log(YLOG_DEBUG, "  term #%d: '%s' (" ODR_INT_PRINTF ")", i,
                          bsrr->entries[i].term, bsrr->entries[i].occurrences);
             }