1 /* $Id: filter_bounce.cpp,v 1.4 2007-05-09 21:23:09 adam Exp $
2 Copyright (c) 2005-2007, Index Data.
4 This file is part of Metaproxy.
6 Metaproxy is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
11 Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with Metaproxy; see the file LICENSE. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #include "filter_bounce.hpp"
23 #include "package.hpp"
25 #include "gduutil.hpp"
31 //#include "config.hpp"
32 //#include "filter.hpp"
34 //#include <boost/thread/mutex.hpp>
40 namespace mp = metaproxy_1;
41 namespace yf = mp::filter;
43 namespace metaproxy_1 {
52 yf::Bounce::Bounce() : m_p(new Rep)
58 { // must have a destructor because of boost::scoped_ptr
61 void yf::Bounce::process(mp::Package &package) const
68 package.session().close();
70 Z_GDU *zgdu = package.request().get();
75 //std::string message("BOUNCE ");
76 std::ostringstream message;
77 message << "BOUNCE " << *zgdu;
81 if (zgdu->which == Z_GDU_Z3950)
84 apdu_res = odr.create_close(zgdu->u.z3950,
85 Z_Close_systemProblem,
86 message.str().c_str());
87 package.response() = apdu_res;
89 else if (zgdu->which == Z_GDU_HTTP_Request)
93 = odr.create_HTTP_Response(package.session(),
94 zgdu->u.HTTP_Request, 400);
96 package.response() = zgdu_res;
98 else if (zgdu->which == Z_GDU_HTTP_Response)
106 static mp::filter::Base* filter_creator()
108 return new mp::filter::Bounce;
112 struct metaproxy_1_filter_struct metaproxy_1_filter_bounce = {
123 * indent-tabs-mode: nil
124 * c-file-style: "stroustrup"
126 * vim: shiftwidth=4 tabstop=8 expandtab