-/* $Id: filter_sru_to_z3950.cpp,v 1.16 2006-09-29 09:48:36 marc Exp $
+/* $Id: filter_sru_to_z3950.cpp,v 1.17 2006-10-02 12:01:06 marc Exp $
Copyright (c) 2005-2006, Index Data.
See the LICENSE file for details
const *er_req) const
{
+
+
// z3950'fy recordPacking
int record_packing = Z_SRW_recordPacking_XML;
if (er_req->recordPacking && 's' == *(er_req->recordPacking))
if (er_req->database)
database = er_req->database;
+ // getting host and port info
+ std::string host = package.origin().listen_host();
+ std::string port = mp_util::to_string(package.origin().listen_port());
+
+ // overwriting host and port info if set from HTTP Host header
+ Z_GDU *zgdu_req = package.request().get();
+ if (zgdu_req && zgdu_req->which == Z_GDU_HTTP_Request)
+ {
+ Z_HTTP_Request* http_req = zgdu_req->u.HTTP_Request;
+ if (http_req)
+ {
+ std::string http_host_address
+ = mp_util::http_header_value(http_req->headers, "Host");
+
+ std::string::size_type i = http_host_address.rfind(":");
+ if (i != std::string::npos)
+ {
+ host.assign(http_host_address, 0, i);
+ port.assign(http_host_address, i + 1, std::string::npos);
+ }
+ }
+ }
+
// building SRU explain record
std::string explain_xml
= mp_util::to_string(
"<explain>\n"
" <serverInfo protocol='SRU'>\n"
" <host>")
- + package.origin().server_host()
+ + host
+ mp_util::to_string("</host>\n"
" <port>")
- + mp_util::to_string(package.origin().server_port())
+ + port
+ mp_util::to_string("</port>\n"
" <database>")
+ database
-/* $Id: origin.cpp,v 1.3 2006-09-26 13:02:50 marc Exp $
+/* $Id: origin.cpp,v 1.4 2006-10-02 12:01:06 marc Exp $
Copyright (c) 2005-2006, Index Data.
See the LICENSE file for details
namespace mp = metaproxy_1;
-mp::Origin::Origin(std::string server_host,
- unsigned int server_port)
+mp::Origin::Origin(std::string listen_host,
+ unsigned int listen_port)
: m_type(API), m_address(""), m_origin_id(0),
- m_server_host(server_host), m_server_port(server_port)
+ m_listen_host(listen_host), m_listen_port(listen_port)
{
}
-std::string mp::Origin::server_host() const
+std::string mp::Origin::listen_host() const
{
- return m_server_host;
+ return m_listen_host;
};
-unsigned int mp::Origin::server_port() const
+std::string & mp::Origin::listen_host()
{
- return m_server_port;
+ return m_listen_host;
};
+unsigned int mp::Origin::listen_port() const
+{
+ return m_listen_port;
+};
+
+unsigned int & mp::Origin::listen_port()
+{
+ return m_listen_port;
+};
+
+
void mp::Origin::set_tcpip_address(std::string addr, unsigned long s)
{
-/* $Id: origin.hpp,v 1.1 2006-09-26 13:04:07 marc Exp $
+/* $Id: origin.hpp,v 1.2 2006-10-02 12:01:06 marc Exp $
Copyright (c) 2005-2006, Index Data.
See the LICENSE file for details
class Origin {
public:
- Origin(std::string server_host = "", unsigned int server_port = 0);
+ Origin(std::string listen_host = "", unsigned int listen_port = 0);
/// get function - right val in assignment
- std::string server_host() const;
-
+ std::string listen_host() const;
+
+ /// set function - left val in assignment
+ std::string & listen_host();
+
/// get function - right val in assignment
- unsigned int server_port() const;
+ unsigned int listen_port() const;
+ /// set function - left val in assignment
+ unsigned int & listen_port();
+
/// set client IP info - left val in assignment
void set_tcpip_address(std::string addr, unsigned long id);
TCPIP
} m_type;
std::string m_address; // UNIX+TCPIP
- unsigned long m_origin_id;
- std::string m_server_host;
- unsigned int m_server_port;
+ unsigned int m_origin_id;
+ std::string m_listen_host;
+ unsigned int m_listen_port;
};
}