1 /* This file is part of Metaproxy.
2 Copyright (C) 2005-2012 Index Data
4 Metaproxy is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #include "filter_bounce.hpp"
20 #include <metaproxy/package.hpp>
21 #include <metaproxy/util.hpp>
22 #include "gduutil.hpp"
28 namespace mp = metaproxy_1;
29 namespace yf = mp::filter;
31 namespace metaproxy_1 {
40 yf::Bounce::Bounce() : m_p(new Rep)
46 { // must have a destructor because of boost::scoped_ptr
49 void yf::Bounce::process(mp::Package &package) const
56 package.session().close();
58 Z_GDU *zgdu = package.request().get();
63 //std::string message("BOUNCE ");
64 std::ostringstream message;
65 message << "BOUNCE " << *zgdu;
69 if (zgdu->which == Z_GDU_Z3950)
72 apdu_res = odr.create_close(zgdu->u.z3950,
73 Z_Close_systemProblem,
74 message.str().c_str());
75 package.response() = apdu_res;
77 else if (zgdu->which == Z_GDU_HTTP_Request)
81 = odr.create_HTTP_Response(package.session(),
82 zgdu->u.HTTP_Request, 400);
84 package.response() = zgdu_res;
86 else if (zgdu->which == Z_GDU_HTTP_Response)
94 void mp::filter::Bounce::configure(const xmlNode * ptr, bool test_only,
97 mp::xml::check_empty(ptr);
100 static mp::filter::Base* filter_creator()
102 return new mp::filter::Bounce;
106 struct metaproxy_1_filter_struct metaproxy_1_filter_bounce = {
117 * c-file-style: "Stroustrup"
118 * indent-tabs-mode: nil
120 * vim: shiftwidth=4 tabstop=8 expandtab