+// ANNA - Anna is Not Nothingness Anymore //
+// //
+// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
+// //
+// See project site at http://redmine.teslayout.com/projects/anna-suite //
+// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
+
+
+// Standard
+#include <string>
+
+// Project
+#include <anna/http/Request.hpp>
+
+// Process
+#include "MyHandler.hpp"
+#include "Launcher.hpp"
+
+
+void MyHandler::evRequest(anna::comm::ClientSocket& clientSocket, const anna::http::Request& request)
+throw(anna::RuntimeException) {
+ const anna::DataBlock& body = request.getBody();
+
+ if(body.getSize() == 0)
+ throw anna::RuntimeException("Missing operation parameters on HTTP request", ANNA_FILE_LOCATION);
+
+ LOGINFORMATION(
+ std::string msg("Received body: ");
+ msg += anna::functions::asString(body);
+ anna::Logger::information(msg, ANNA_FILE_LOCATION);
+ );
+ std::string body_content;
+ body_content.assign(body.getData(), body.getSize());
+ // Operation:
+ std::string response_content;
+
+ try {
+ Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
+ my_app.eventOperation(body_content, response_content);
+ } catch(RuntimeException &ex) {
+ ex.trace();
+ }
+
+ anna::http::Response* response = allocateResponse();
+ response->setStatusCode(200); // http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
+ anna::DataBlock db_content(true);
+ db_content = response_content;
+ response->setBody(db_content);
+// response->find(anna::http::Header::Type::Date)->setValue("Mon, 30 Jan 2006 14:36:18 GMT");
+// anna::http::Header* keepAlive = response->find("Keep-Alive");
+//
+// if (keepAlive == NULL)
+// keepAlive = response->createHeader("Keep-Alive");
+//
+// keepAlive->setValue("Verificacion del cambio 1.0.7");
+
+ try {
+ clientSocket.send(*response);
+ } catch(Exception& ex) {
+ ex.trace();
+ }
+}