HTTPServer/HTTPHandler.cpp
2019-05-30 10:22:21 -07:00

29 lines
891 B
C++

#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) << header.getPath() << " " << header.getCGIData();
HTTPSession *httpSession = ((HTTPService &)session->service).httpSessions.findSessionByHeader(header, response);
std::stringstream content;
((HTTPService &)session->service).pageService.processRequest(header.getPath(), content);
response.setProtocol(header.requestProtocol());
response.setCode("200");
response.setText("OK");
response.setMimeType("text/html");
data << response.getResponse(content.str());
return 0;
}
}