-/* $Id: filter_frontend_net.cpp,v 1.26 2008-02-20 15:07:51 adam Exp $
- Copyright (c) 2005-2008, Index Data.
-
-This file is part of Metaproxy.
+/* This file is part of Metaproxy.
+ Copyright (C) 2005-2009 Index Data
Metaproxy is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
for more details.
You should have received a copy of the GNU General Public License
-along with Metaproxy; see the file LICENSE. If not, write to the
-Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.
- */
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
#include "config.hpp"
class ThreadPoolPackage : public mp::IThreadPoolMsg {
public:
ThreadPoolPackage(mp::Package *package, mp::ZAssocChild *ses) :
- m_session(ses), m_package(package) { };
+ m_assoc_child(ses), m_package(package) { };
~ThreadPoolPackage();
IThreadPoolMsg *handle();
void result();
private:
- mp::ZAssocChild *m_session;
+ mp::ZAssocChild *m_assoc_child;
mp::Package *m_package;
};
void mp::ThreadPoolPackage::result()
{
- m_session->m_no_requests--;
+ m_assoc_child->m_no_requests--;
yazpp_1::GDU *gdu = &m_package->response();
if (gdu->get())
{
int len;
- m_session->send_GDU(gdu->get(), &len);
+ m_assoc_child->send_GDU(gdu->get(), &len);
}
else if (!m_package->session().is_closed())
{
z_gdu->u.z3950, Z_Close_systemProblem,
"unhandled Z39.50 request");
- m_session->send_Z_PDU(apdu_response, &len);
- m_package->session().close();
+ m_assoc_child->send_Z_PDU(apdu_response, &len);
}
+ else if (z_gdu && z_gdu->which == Z_GDU_HTTP_Request)
+ {
+ // For HTTP, respond with Server Error
+ int len;
+ mp::odr odr;
+ Z_GDU *zgdu_res
+ = odr.create_HTTP_Response(m_package->session(),
+ z_gdu->u.HTTP_Request, 500);
+ m_assoc_child->send_GDU(zgdu_res, &len);
+ }
+ m_package->session().close();
}
- if (m_session->m_no_requests == 0 && m_package->session().is_closed())
+ if (m_assoc_child->m_no_requests == 0 && m_package->session().is_closed())
{
- m_session->close();
+ m_assoc_child->close();
}
delete this;
}
// TODO: send Package to signal "close"
if (m_session.is_closed())
{
- delete this;
+ if (m_no_requests == 0)
+ delete this;
return;
}
m_no_requests++;
/*
* Local variables:
* c-basic-offset: 4
+ * c-file-style: "Stroustrup"
* indent-tabs-mode: nil
- * c-file-style: "stroustrup"
* End:
* vim: shiftwidth=4 tabstop=8 expandtab
*/
+