X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Ftorus.cpp;h=d6bcd03711e697f3c1adf8d7c0f6cb3aa272721d;hb=c45ae107e9836f63beb51f5792f9963f221781ef;hp=e715614be4d829930396e0eebf707d6171e7cd59;hpb=cf16212cc3ea5a38f40b49779814eaeba57e69c0;p=metaproxy-moved-to-github.git diff --git a/src/torus.cpp b/src/torus.cpp index e715614..d6bcd03 100644 --- a/src/torus.cpp +++ b/src/torus.cpp @@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include +#include #include #include #include "torus.hpp" @@ -27,6 +28,7 @@ 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, + const std::string &realm, const std::string &proxy) { // http://newmk2.indexdata.com/torus2/searchable.ebsco/records/?query=udb=aberdeenUni @@ -35,7 +37,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; @@ -53,9 +59,12 @@ xmlDoc *mp::get_searchable(std::string url_template, const std::string &db, 0, /* content buf */ 0 /* content_len */ ); - if (http_response->code == 200 && http_response->content_buf) + if (http_response && http_response->code == 200 && + http_response->content_buf) doc = xmlParseMemory(http_response->content_buf, http_response->content_len); + else + yaz_log(YLOG_WARN, "Could not fetch %s", url_template.c_str()); yaz_url_destroy(url_p); return doc; }