X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fzoom-sru.c;h=f9baf44d6e00722a0cea7366c146867f09fdf981;hb=29846d8b70756fceab1c76a524e172f68ad23cbe;hp=0dc27453731f34d506c6adbde55bf3818a158bdd;hpb=540b8919836aede9f2fe7f7a20978fc290e8972c;p=yaz-moved-to-github.git diff --git a/src/zoom-sru.c b/src/zoom-sru.c index 0dc2745..f9baf44 100644 --- a/src/zoom-sru.c +++ b/src/zoom-sru.c @@ -1,11 +1,14 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2010 Index Data + * Copyright (C) 1995-2011 Index Data * See the file LICENSE for details. */ /** * \file zoom-sru.c * \brief Implements ZOOM SRU */ +#if HAVE_CONFIG_H +#include +#endif #include #include @@ -33,12 +36,10 @@ static zoom_ret send_srw(ZOOM_connection c, Z_SRW_PDU *sr) Z_GDU *gdu; ZOOM_Event event; const char *database = ZOOM_options_get(c->options, "databaseName"); - char *fdatabase = 0; - - if (database) - fdatabase = yaz_encode_sru_dbpath_odr(c->odr_out, database); - gdu = z_get_HTTP_Request_host_path(c->odr_out, c->host_port, - fdatabase ? fdatabase : c->path); + + gdu = z_get_HTTP_Request_uri(c->odr_out, c->host_port, + database, + c->proxy ? 1 : 0); if (c->sru_mode == zoom_sru_get) { @@ -156,9 +157,8 @@ zoom_ret ZOOM_connection_srw_send_search(ZOOM_connection c) start = &c->tasks->u.search.start; count = &c->tasks->u.search.count; facets = ZOOM_options_get(resultset->options, "facets"); - if (facets) { + if (facets) facet_list = yaz_pqf_parse_facet_list(c->odr_out, facets); - } break; case ZOOM_TASK_RETRIEVE: resultset = c->tasks->u.retrieve.resultset; @@ -261,8 +261,9 @@ static zoom_ret handle_srw_response(ZOOM_connection c, syntax = c->tasks->u.search.syntax; elementSetName = c->tasks->u.search.elementSetName; - if (!c->tasks->u.search.recv_search_fired) - { + /* Required not for reporting client hit count multiple times into session */ + if (!c->tasks->u.search.recv_search_fired) { + yaz_log(YLOG_DEBUG, "posting ZOOM_EVENT_RECV_SEARCH"); event = ZOOM_Event_create(ZOOM_EVENT_RECV_SEARCH); ZOOM_connection_put_event(c, event); c->tasks->u.search.recv_search_fired = 1; @@ -325,6 +326,7 @@ static zoom_ret handle_srw_response(ZOOM_connection c, npr->u.databaseRecord->descriptor = 0; npr->u.databaseRecord->direct_reference = odr_oiddup(c->odr_in, yaz_oid_recsyn_xml); + npr->u.databaseRecord->indirect_reference = 0; npr->u.databaseRecord->which = Z_External_octet; npr->u.databaseRecord->u.octet_aligned = (Odr_oct *) @@ -389,15 +391,15 @@ static void handle_srw_scan_response(ZOOM_connection c, #endif int ZOOM_handle_sru(ZOOM_connection c, Z_HTTP_Response *hres, - zoom_ret *cret) + zoom_ret *cret, char **addinfo) { +#if YAZ_HAVE_XML2 int ret = 0; - const char *addinfo = 0; /* not redirect (normal response) */ if (!yaz_srw_check_content_type(hres)) { - addinfo = "content-type"; + *addinfo = "content-type"; ret = -1; } else if (c->sru_mode == zoom_sru_solr) @@ -442,9 +444,24 @@ int ZOOM_handle_sru(ZOOM_connection c, Z_HTTP_Response *hres, soap_package->u.fault->fault_string); } else + { + size_t max_chars = 1000; + size_t sz = hres->content_len; + if (sz > max_chars - 1) + sz = max_chars; + *addinfo = odr_malloc(c->odr_in, sz + 4); + memcpy(*addinfo, hres->content_buf, sz); + if (sz == max_chars) + strcpy(*addinfo + sz, "..."); + else + strcpy(*addinfo + sz, ""); ret = -1; + } } return ret; +#else + return -1; +#endif } /*