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 //
13 #include <anna/http/Request.hpp>
16 #include <MyHandler.hpp>
17 #include <Launcher.hpp>
20 void MyHandler::evRequest(anna::comm::ClientSocket& clientSocket, const anna::http::Request& request)
21 throw(anna::RuntimeException) {
22 const anna::DataBlock& body = request.getBody();
24 if(body.getSize() == 0)
25 throw anna::RuntimeException("Missing operation parameters on HTTP request", ANNA_FILE_LOCATION);
28 std::string msg("Received body: ");
29 msg += anna::functions::asString(body);
30 anna::Logger::information(msg, ANNA_FILE_LOCATION);
32 std::string body_content;
33 body_content.assign(body.getData(), body.getSize());
35 std::string response_content;
38 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
39 my_app.eventOperation(body_content, response_content);
40 } catch(RuntimeException &ex) {
44 anna::http::Response* response = allocateResponse();
45 response->setStatusCode(200); // http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
46 anna::DataBlock db_content(true);
47 db_content = response_content;
48 response->setBody(db_content);
49 // response->find(anna::http::Header::Type::Date)->setValue("Mon, 30 Jan 2006 14:36:18 GMT");
50 // anna::http::Header* keepAlive = response->find("Keep-Alive");
52 // if (keepAlive == NULL)
53 // keepAlive = response->createHeader("Keep-Alive");
55 // keepAlive->setValue("Verificacion del cambio 1.0.7");
58 clientSocket.send(*response);
59 } catch(Exception& ex) {