diff --git a/.gitignore b/.gitignore index 37fecde..b078b75 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ Release *~ *.o *.o.d +*.mk + diff --git a/Debug/main.cpp.o b/Debug/main.cpp.o index 8203f02..1e8fe44 100644 Binary files a/Debug/main.cpp.o and b/Debug/main.cpp.o differ diff --git a/_GET.cpp b/HTTPHandler.cpp similarity index 85% rename from _GET.cpp rename to HTTPHandler.cpp index 707148a..45aed2f 100644 --- a/_GET.cpp +++ b/HTTPHandler.cpp @@ -1,11 +1,11 @@ -#include "_GET.h" +#include "HTTPHandler.h" #include "HTTPSession.h" #include "HTTPService.h" #include "Log.h" namespace http { - int _GET::processCommand(std::string request, core::Session *session, std::stringstream &data) { + int HTTPHandler::processCommand(std::string request, core::Session *session, std::stringstream &data) { core::Header header(request); core::Response response; diff --git a/_GET.h b/HTTPHandler.h similarity index 73% rename from _GET.h rename to HTTPHandler.h index 970d14b..4788925 100644 --- a/_GET.h +++ b/HTTPHandler.h @@ -1,5 +1,5 @@ -#ifndef ___GET_h__ -#define ___GET_h__ +#ifndef __HTTPHandler_h__ +#define __HTTPHandler_h__ #include "Command.h" #include "Session.h" @@ -9,7 +9,7 @@ namespace http { - class _GET : public core::Command { + class HTTPHandler : public core::Command { public: int processCommand(std::string request, core::Session *session, std::stringstream &data) override; diff --git a/HTTPServer.mk b/HTTPServer.mk index 510fc7e..0066006 100644 --- a/HTTPServer.mk +++ b/HTTPServer.mk @@ -5,16 +5,16 @@ ## Debug ProjectName :=HTTPServer ConfigurationName :=Debug -WorkspacePath :=/home/barant/barant -ProjectPath :=/home/barant/barant/HTTPServer +WorkspacePath :=/home/bradarant/barant +ProjectPath :=/home/bradarant/barant/HTTPServer IntermediateDirectory :=./Debug OutDir := $(IntermediateDirectory) CurrentFileName := CurrentFilePath := CurrentFileFullPath := -User := -Date :=05/18/19 -CodeLitePath :=/home/barant/.codelite +User :=Brad Arant +Date :=22/05/19 +CodeLitePath :=/home/bradarant/.codelite LinkerName :=/usr/bin/x86_64-linux-gnu-g++ SharedObjectLinkerName :=/usr/bin/x86_64-linux-gnu-g++ -shared -fPIC ObjectSuffix :=.o @@ -60,7 +60,7 @@ AS := /usr/bin/x86_64-linux-gnu-as ## User defined environment variables ## CodeLiteDir:=/usr/share/codelite -Objects0=$(IntermediateDirectory)/main.cpp$(ObjectSuffix) $(IntermediateDirectory)/HTTPSession.cpp$(ObjectSuffix) $(IntermediateDirectory)/HTTPSessions.cpp$(ObjectSuffix) $(IntermediateDirectory)/_GET.cpp$(ObjectSuffix) $(IntermediateDirectory)/src__POST.cpp$(ObjectSuffix) +Objects0=$(IntermediateDirectory)/main.cpp$(ObjectSuffix) $(IntermediateDirectory)/HTTPSession.cpp$(ObjectSuffix) $(IntermediateDirectory)/HTTPSessions.cpp$(ObjectSuffix) $(IntermediateDirectory)/HTTPHandler.cpp$(ObjectSuffix) @@ -92,7 +92,7 @@ PreBuild: ## Objects ## $(IntermediateDirectory)/main.cpp$(ObjectSuffix): main.cpp $(IntermediateDirectory)/main.cpp$(DependSuffix) - $(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/barant/HTTPServer/main.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/main.cpp$(ObjectSuffix) $(IncludePath) + $(CXX) $(IncludePCH) $(SourceSwitch) "/home/bradarant/barant/HTTPServer/main.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/main.cpp$(ObjectSuffix) $(IncludePath) $(IntermediateDirectory)/main.cpp$(DependSuffix): main.cpp @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/main.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/main.cpp$(DependSuffix) -MM main.cpp @@ -100,7 +100,7 @@ $(IntermediateDirectory)/main.cpp$(PreprocessSuffix): main.cpp $(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/main.cpp$(PreprocessSuffix) main.cpp $(IntermediateDirectory)/HTTPSession.cpp$(ObjectSuffix): HTTPSession.cpp $(IntermediateDirectory)/HTTPSession.cpp$(DependSuffix) - $(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/barant/HTTPServer/HTTPSession.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/HTTPSession.cpp$(ObjectSuffix) $(IncludePath) + $(CXX) $(IncludePCH) $(SourceSwitch) "/home/bradarant/barant/HTTPServer/HTTPSession.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/HTTPSession.cpp$(ObjectSuffix) $(IncludePath) $(IntermediateDirectory)/HTTPSession.cpp$(DependSuffix): HTTPSession.cpp @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/HTTPSession.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/HTTPSession.cpp$(DependSuffix) -MM HTTPSession.cpp @@ -108,28 +108,20 @@ $(IntermediateDirectory)/HTTPSession.cpp$(PreprocessSuffix): HTTPSession.cpp $(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/HTTPSession.cpp$(PreprocessSuffix) HTTPSession.cpp $(IntermediateDirectory)/HTTPSessions.cpp$(ObjectSuffix): HTTPSessions.cpp $(IntermediateDirectory)/HTTPSessions.cpp$(DependSuffix) - $(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/barant/HTTPServer/HTTPSessions.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/HTTPSessions.cpp$(ObjectSuffix) $(IncludePath) + $(CXX) $(IncludePCH) $(SourceSwitch) "/home/bradarant/barant/HTTPServer/HTTPSessions.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/HTTPSessions.cpp$(ObjectSuffix) $(IncludePath) $(IntermediateDirectory)/HTTPSessions.cpp$(DependSuffix): HTTPSessions.cpp @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/HTTPSessions.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/HTTPSessions.cpp$(DependSuffix) -MM HTTPSessions.cpp $(IntermediateDirectory)/HTTPSessions.cpp$(PreprocessSuffix): HTTPSessions.cpp $(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/HTTPSessions.cpp$(PreprocessSuffix) HTTPSessions.cpp -$(IntermediateDirectory)/_GET.cpp$(ObjectSuffix): _GET.cpp $(IntermediateDirectory)/_GET.cpp$(DependSuffix) - $(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/barant/HTTPServer/_GET.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/_GET.cpp$(ObjectSuffix) $(IncludePath) -$(IntermediateDirectory)/_GET.cpp$(DependSuffix): _GET.cpp - @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/_GET.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/_GET.cpp$(DependSuffix) -MM _GET.cpp +$(IntermediateDirectory)/HTTPHandler.cpp$(ObjectSuffix): HTTPHandler.cpp $(IntermediateDirectory)/HTTPHandler.cpp$(DependSuffix) + $(CXX) $(IncludePCH) $(SourceSwitch) "/home/bradarant/barant/HTTPServer/HTTPHandler.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/HTTPHandler.cpp$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/HTTPHandler.cpp$(DependSuffix): HTTPHandler.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/HTTPHandler.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/HTTPHandler.cpp$(DependSuffix) -MM HTTPHandler.cpp -$(IntermediateDirectory)/_GET.cpp$(PreprocessSuffix): _GET.cpp - $(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/_GET.cpp$(PreprocessSuffix) _GET.cpp - -$(IntermediateDirectory)/src__POST.cpp$(ObjectSuffix): src/_POST.cpp $(IntermediateDirectory)/src__POST.cpp$(DependSuffix) - $(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/barant/HTTPServer/src/_POST.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/src__POST.cpp$(ObjectSuffix) $(IncludePath) -$(IntermediateDirectory)/src__POST.cpp$(DependSuffix): src/_POST.cpp - @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/src__POST.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/src__POST.cpp$(DependSuffix) -MM src/_POST.cpp - -$(IntermediateDirectory)/src__POST.cpp$(PreprocessSuffix): src/_POST.cpp - $(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src__POST.cpp$(PreprocessSuffix) src/_POST.cpp +$(IntermediateDirectory)/HTTPHandler.cpp$(PreprocessSuffix): HTTPHandler.cpp + $(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/HTTPHandler.cpp$(PreprocessSuffix) HTTPHandler.cpp -include $(IntermediateDirectory)/*$(DependSuffix) diff --git a/HTTPServer.project b/HTTPServer.project index 340c058..526c584 100644 --- a/HTTPServer.project +++ b/HTTPServer.project @@ -4,18 +4,16 @@ - - - - + + diff --git a/HTTPService.h b/HTTPService.h index 942350e..1f0208c 100644 --- a/HTTPService.h +++ b/HTTPService.h @@ -3,9 +3,9 @@ #include "Service.h" #include "HTTPSessions.h" +#include "PageService.h" #include "Exception.h" -#include "_GET.h" -#include "_POST.h" +#include "HTTPHandler.h" namespace http { @@ -13,16 +13,15 @@ namespace http { public: HTTPService() { - commands.add(get, "GET "); - commands.add(post, "POST "); + commands.add(httpHandler, "GET "); + commands.add(httpHandler, "POST "); } HTTPSessions httpSessions; -// PageService pageService; + PageService pageService; private: - _GET get; - _POST post; + HTTPHandler httpHandler; }; diff --git a/_POST.h b/_POST.h deleted file mode 100644 index 2630f5c..0000000 --- a/_POST.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef ___POST_h__ -#define ___POST_h__ - -#include "Command.h" -#include "Session.h" -#include "Header.h" -#include "Response.h" - -namespace http { - - class _POST : public core::Command { - - public: - int processCommand(std::string request, core::Session *session, std::stringstream &data) override; - - }; - -} - -#endif diff --git a/main.cpp b/main.cpp index 41faa5e..7887e26 100644 --- a/main.cpp +++ b/main.cpp @@ -18,10 +18,10 @@ int main(int argc, char **argv) { core::EPoll ePoll; - http::HTTPService httpService; + http::HTTPService httpService; core::TCPServerSocket http(ePoll, httpService, core::IPAddress(ipAddress, 8080)); - core::Service consoleService; + core::Service consoleService; core::ConsoleServer console(ePoll, consoleService, core::IPAddress(ipAddress, 1027)); consoleService.commands.add(ePoll); consoleService.commands.add(http); diff --git a/src/PageService.h b/src/PageService.h index cc877cc..d310896 100644 --- a/src/PageService.h +++ b/src/PageService.h @@ -2,7 +2,6 @@ #define __PageService_h__ #include "Service.h" -#include "Exception.h" #include "__index.h" #include "__setupadmin.h" @@ -13,7 +12,7 @@ namespace http { public: PageService() { commands.add(index, "/"); - commands.add(setupadmin, "/setupadmin "); + commands.add(setupadmin, "/setupadmin"); } private: diff --git a/src/_POST.cpp b/src/_POST.cpp deleted file mode 100644 index efc1d53..0000000 --- a/src/_POST.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "_POST.h" -#include "HTTPSession.h" -#include "HTTPService.h" -#include "Log.h" - -namespace http { - - int _POST::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; - } - -} diff --git a/src/__index.h b/src/__index.h index 43ce187..e970278 100644 --- a/src/__index.h +++ b/src/__index.h @@ -5,13 +5,13 @@ namespace http { class __index : core::Command { - int processCommand(std::string request, core::Session *session) override { - session.out << "\ + int processCommand(std::string request, core::Session *session, std::stringstream &data) override { + + data << "\

You have successfully set up a JETServer.\
Session Id: " + httpSession->getSessionId() + "\
The configuration has not yet been established for this web site.

\ \
"; - session.send(); } } \ No newline at end of file diff --git a/src/__setupadmin.h b/src/__setupadmin.h index d899315..a7886a1 100644 --- a/src/__setupadmin.h +++ b/src/__setupadmin.h @@ -5,14 +5,14 @@ namespace http { class __setupadmin : core::Command { - int processCommand(std::string request, core::Session *session) override { - session.out << "\ + int processCommand(std::string request, core::Session *session, std::stringstream &data) override { + + data << "\

Please enter credential information\ for the security officer.
\
Session Id: " + httpSession->getSessionId() + "\
The configuration has not yet been established for this web site.

\ \
"; - session.send(); } } \ No newline at end of file