#include "HTTPHandler.h" #include "HTTPSession.h" #include "HTTPService.h" #include "Log.h" namespace http { int HTTPHandler::processCommand(std::string request, core::Session *session, std::stringstream &data) { core::Header header(request); core::Response response; core::Log(core::LOG_DEBUG_1) << "Request: " << request; // HTTPSession *httpSession = ((HTTPService &)session->service).httpSessions.findSessionByHeader(header, response); std::stringstream content; if(((HTTPService &)session->service).pageList.processRequest(header.getPath() + " ", session, content)) { response.setProtocol(header.requestProtocol()); response.setCode("200"); response.setText("OK"); response.setMimeType("text/html"); data << response.getResponse(content.str()); } else { response.setProtocol(header.requestProtocol()); response.setCode("404"); response.setText("Not Found"); response.setMimeType("text/html"); data << response.getResponse(content.str()); } core::Log(core::LOG_DEBUG_1) << "==========Request completed."; return true; } }