From cdb9d2053fa54a0a2d7da1514164de3bbe52edb3 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 24 Oct 2011 13:18:54 +0200 Subject: [PATCH] Custom session ID may be specified for SRU filter The ID is specified by using x-session-id argument for the SRU URL. It is attached to the origin instance and passed down the chain. --- include/metaproxy/origin.hpp | 3 +++ src/filter_sru_to_z3950.cpp | 4 ++++ src/origin.cpp | 9 ++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/metaproxy/origin.hpp b/include/metaproxy/origin.hpp index d9d625c..955476f 100644 --- a/include/metaproxy/origin.hpp +++ b/include/metaproxy/origin.hpp @@ -59,6 +59,8 @@ namespace metaproxy_1 { /// get tcpip address std::string get_address(); + + void set_custom_session(const std::string &s); private: friend std::ostream& std::operator<<(std::ostream& os, metaproxy_1::Origin& o); @@ -73,6 +75,7 @@ namespace metaproxy_1 { std::string m_listen_host; unsigned int m_listen_port; int m_max_sockets; + std::string m_custom_session; }; } diff --git a/src/filter_sru_to_z3950.cpp b/src/filter_sru_to_z3950.cpp index 140b346..17e5b55 100644 --- a/src/filter_sru_to_z3950.cpp +++ b/src/filter_sru_to_z3950.cpp @@ -223,6 +223,10 @@ void yf::SRUtoZ3950::Impl::sru(mp::Package &package, Z_GDU *zgdu_req) { package.origin().set_max_sockets(atoi(arg->value)); } + else if (!strcmp(arg->name, "x-session-id")) + { + package.origin().set_custom_session(arg->value); + } assert(sru_pdu_req); diff --git a/src/origin.cpp b/src/origin.cpp index 500a446..6901a92 100644 --- a/src/origin.cpp +++ b/src/origin.cpp @@ -67,6 +67,11 @@ void mp::Origin::set_tcpip_address(std::string addr, unsigned long s) m_origin_id = s; } +void mp::Origin::set_custom_session(const std::string &s) +{ + m_custom_session = s; +} + std::string mp::Origin::get_address() { return m_address; @@ -74,11 +79,13 @@ std::string mp::Origin::get_address() std::ostream& std::operator<<(std::ostream& os, mp::Origin& o) { - if (o.m_address != "") + if (o.m_address.length()) os << o.m_address; else os << "0"; os << ":" << o.m_origin_id; + if (o.m_custom_session.length()) + os << ":" << o.m_custom_session; return os; } -- 1.7.10.4