X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Ffilter_sru_to_z3950.cpp;h=76c5df8702f9f45e42123465436c1e0245eca59e;hb=c93d8c8db5ae24e01775060677f8e8e9c2afff34;hp=68a086b3a286a1841d6b9e37947614f74e85f83b;hpb=ef66a2136e7bc6bd0b9821d880ab949687159aa1;p=metaproxy-moved-to-github.git diff --git a/src/filter_sru_to_z3950.cpp b/src/filter_sru_to_z3950.cpp index 68a086b..76c5df8 100644 --- a/src/filter_sru_to_z3950.cpp +++ b/src/filter_sru_to_z3950.cpp @@ -1,4 +1,4 @@ -/* $Id: filter_sru_to_z3950.cpp,v 1.13 2006-09-26 11:37:08 marc Exp $ +/* $Id: filter_sru_to_z3950.cpp,v 1.15 2006-09-29 08:42:47 marc Exp $ Copyright (c) 2005-2006, Index Data. See the LICENSE file for details @@ -9,6 +9,7 @@ #include "package.hpp" #include "util.hpp" #include "gduutil.hpp" +#include "sru_util.hpp" #include "filter_sru_to_z3950.hpp" #include @@ -24,38 +25,9 @@ namespace mp = metaproxy_1; +namespace mp_util = metaproxy_1::util; namespace yf = mp::filter; -namespace metaproxy_1 -{ - - template - std::string to_string(const T& t) - { - std::ostringstream o; - if(o << t) - return o.str(); - - return std::string(); - } - - std::string http_header_value(const Z_HTTP_Header* header, - const std::string name) - { - while (header && header->name - && std::string(header->name) != name) - header = header->next; - - if (header && header->name && std::string(header->name) == name - && header->value) - return std::string(header->value); - - return std::string(); - } - - -} - namespace metaproxy_1 { namespace filter { @@ -291,18 +263,18 @@ bool yf::SRUtoZ3950::Rep::build_simple_explain(mp::Package &package, // building SRU explain record std::string explain_xml - = mp::to_string( + = mp_util::to_string( "\n" " \n" " ") + package.origin().server_host() - + mp::to_string("\n" + + mp_util::to_string("\n" " ") - + mp::to_string(package.origin().server_port()) - + mp::to_string("\n" + + mp_util::to_string(package.origin().server_port()) + + mp_util::to_string("\n" " ") + database - + mp::to_string("\n" + + mp_util::to_string("\n" " \n" "\n"); @@ -990,7 +962,7 @@ yf::SRUtoZ3950::Rep::sru_protocol(const Z_HTTP_Request &http_req) const const std::string http_method(http_req.method); const std::string http_type - = http_header_value(http_req.headers, "Content-Type"); + = mp_util::http_header_value(http_req.headers, "Content-Type"); if (http_method == "GET") return "SRU GET"; @@ -1021,10 +993,10 @@ yf::SRUtoZ3950::Rep::debug_http(const Z_HTTP_Request &http_req) const message += "Path: " + std::string(http_req.path) + "
\n"; message += "Content-Type:" - + http_header_value(http_req.headers, "Content-Type") + + mp_util::http_header_value(http_req.headers, "Content-Type") + "
\n"; message += "Content-Length:" - + http_header_value(http_req.headers, "Content-Length") + + mp_util::http_header_value(http_req.headers, "Content-Length") + "
\n"; message += "

\n";