X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Ftorus.cpp;h=6ee010f7d659ca17f09b9ef639bf8e02ffc488bc;hb=51bd69f6e778ab83e4017172625c0decc8465e1b;hp=f3661f91154efbcc606136453c62a65eef00025e;hpb=2e5efc21c03caec53122f872cbb95657dd3c823f;p=metaproxy-moved-to-github.git diff --git a/src/torus.cpp b/src/torus.cpp index f3661f9..6ee010f 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 @@ -20,13 +20,16 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include +#include #include #include #include "torus.hpp" 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 &realm, const std::string &proxy) { // http://newmk2.indexdata.com/torus2/searchable.ebsco/records/?query=udb=aberdeenUni @@ -35,7 +38,11 @@ xmlDoc *mp::get_searchable(std::string url_template, const std::string &db, found = url_template.find("%db"); if (found != std::string::npos) - url_template.replace(found, found+3, mp::util::uri_encode(db)); + url_template.replace(found, 3, mp::util::uri_encode(db)); + + found = url_template.find("%realm"); + if (found != std::string::npos) + url_template.replace(found, 6, mp::util::uri_encode(realm)); Z_HTTP_Header *http_headers = 0; mp::odr odr; @@ -55,8 +62,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 + { + 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; }