X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Ftorus.cpp;h=bd0a63bc9d1564e5f256f240f53547c9ffb3d7fe;hb=c1915c1645ff4b7ccaa4ec1f0584fdd4371b253c;hp=d6bcd03711e697f3c1adf8d7c0f6cb3aa272721d;hpb=298c3c20d481cfce45efa87c69dacdd34861cf05;p=metaproxy-moved-to-github.git diff --git a/src/torus.cpp b/src/torus.cpp index d6bcd03..bd0a63b 100644 --- a/src/torus.cpp +++ b/src/torus.cpp @@ -1,5 +1,5 @@ /* This file is part of Metaproxy. - Copyright (C) 2005-2011 Index Data + Copyright (C) 2005-2012 Index Data Metaproxy is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -27,14 +27,22 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA namespace mp = metaproxy_1; -xmlDoc *mp::get_searchable(std::string url_template, const std::string &db, +xmlDoc *mp::get_searchable(mp::Package &package, + std::string url_template, const std::string &db, + const std::string &query, const std::string &realm, const std::string &proxy) { - // http://newmk2.indexdata.com/torus2/searchable.ebsco/records/?query=udb=aberdeenUni + // http://mk2.indexdata.com/torus2/searchable/records/?query=udb%3d%db + // or + // http://mk2.indexdata.com/torus2/searchable/records/?query=%query xmlDoc *doc = 0; size_t found; + found = url_template.find("%query"); + if (found != std::string::npos) + url_template.replace(found, 6, mp::util::uri_encode(query)); + found = url_template.find("%db"); if (found != std::string::npos) url_template.replace(found, 3, mp::util::uri_encode(db)); @@ -61,10 +69,27 @@ xmlDoc *mp::get_searchable(std::string url_template, const std::string &db, ); if (http_response && http_response->code == 200 && http_response->content_buf) + { + package.log("zoom", YLOG_LOG, "Torus: %s OK", url_template.c_str()); doc = xmlParseMemory(http_response->content_buf, http_response->content_len); + + } else - yaz_log(YLOG_WARN, "Could not fetch %s", url_template.c_str()); + { + package.log("zoom", YLOG_WARN, "Torus: %s FAIL", url_template.c_str()); + if (http_response) + { + package.log("zoom", YLOG_LOG, "HTTP code: %d", http_response->code); + } + } + + if (http_response && http_response->content_buf) + { + package.log("zoom", YLOG_LOG, "HTTP content"); + package.log_write(http_response->content_buf, + http_response->content_len); + } yaz_url_destroy(url_p); return doc; }