1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
9 #include <anna/core/tracing/Logger.hpp>
10 #include <anna/core/tracing/TraceMethod.hpp>
12 #include <anna/app/functions.hpp>
14 #include <anna/comm/ClientSocket.hpp>
15 #include <anna/comm/Communicator.hpp>
17 #include "Application.hpp"
18 #include "Reactor.hpp"
19 #include "Context.hpp"
20 #include "Transaction.hpp"
27 * Recupera la respuesta del servidor que usa ANNA.comm y lo transfiere al
28 * cliente original que usaba el protocolo HTTP.
30 void http4comm::Reactor::apply (comm::ClientSocket&, const comm::Message& message)
31 throw (RuntimeException)
33 LOGMETHOD (TraceMethod tm ("http4comm::Reactor", "apply", ANNA_FILE_LOCATION));
35 comm::Communicator* communicator = app::functions::component <comm::Communicator> (ANNA_FILE_LOCATION);
37 http4comm::Application& app = static_cast <http4comm::Application&> (app::functions::getApp ());
38 Context* context = app.getContext ();
40 a_response.decode (message.getBody ());
42 // Como cookie entre extremos del gateway usa el inittime de la peticiĆ³n
43 Transaction* transaction = static_cast <http4comm::Transaction*> (context->find (a_response.initTime));
45 comm::ClientSocket* clientSocket = transaction->getClientSocket ();
47 if (communicator->isUsable (clientSocket) == false) {
49 string msg (transaction->asString ());
50 msg += " | Response ignoreb because of ClientSocket";
51 Logger::warning (msg, ANNA_FILE_LOCATION);
56 a_httpResponse.setStatusCode (200);
57 a_httpResponse.setBody (message.getBody ());
60 clientSocket->send (a_httpResponse);
62 catch (RuntimeException& ex) {
66 context->close (transaction);