diff --git a/Debug/main.cpp.o b/Debug/main.cpp.o index 1e8fe44..25f310e 100644 Binary files a/Debug/main.cpp.o and b/Debug/main.cpp.o differ diff --git a/Debug/main.cpp.o.d b/Debug/main.cpp.o.d index be1d57c..1e49cbf 100644 --- a/Debug/main.cpp.o.d +++ b/Debug/main.cpp.o.d @@ -8,8 +8,9 @@ Debug/main.cpp.o: main.cpp ../ServerCore/includes ../ServerCore/EPoll.h \ ../ServerCore/CommandList.h ../ServerCore/EPoll.h \ ../ServerCore/Exception.h ../ServerCore/File.h ../ServerCore/Log.h \ ../ServerCore/IPAddress.h HTTPService.h ../ServerCore/Service.h \ - HTTPSessions.h ../ServerCore/Header.h ../ServerCore/Response.h _GET.h \ - ../ServerCore/Command.h ../ServerCore/Session.h _POST.h + HTTPSessions.h ../ServerCore/Header.h ../ServerCore/Response.h \ + PageService.h HTTPHandler.h ../ServerCore/Command.h \ + ../ServerCore/Session.h ../ServerCore/includes: @@ -65,10 +66,10 @@ HTTPSessions.h: ../ServerCore/Response.h: -_GET.h: +PageService.h: + +HTTPHandler.h: ../ServerCore/Command.h: ../ServerCore/Session.h: - -_POST.h: diff --git a/HTTPHandler.cpp b/HTTPHandler.cpp index 45aed2f..a1c0640 100644 --- a/HTTPHandler.cpp +++ b/HTTPHandler.cpp @@ -10,19 +10,30 @@ namespace http { core::Header header(request); core::Response response; - core::Log(core::LOG_DEBUG_1) << header.getPath() << " " << header.getCGIData(); + core::Log(core::LOG_DEBUG_1) << "Request: " << request; - HTTPSession *httpSession = ((HTTPService &)session->service).httpSessions.findSessionByHeader(header, response); +// 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; + 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; } } diff --git a/HTTPServer.mk b/HTTPServer.mk index 0066006..0af4bc7 100644 --- a/HTTPServer.mk +++ b/HTTPServer.mk @@ -5,16 +5,16 @@ ## Debug ProjectName :=HTTPServer ConfigurationName :=Debug -WorkspacePath :=/home/bradarant/barant -ProjectPath :=/home/bradarant/barant/HTTPServer +WorkspacePath :=/home/barant +ProjectPath :=/home/barant/barant/HTTPServer IntermediateDirectory :=./Debug OutDir := $(IntermediateDirectory) CurrentFileName := CurrentFilePath := CurrentFileFullPath := -User :=Brad Arant -Date :=22/05/19 -CodeLitePath :=/home/bradarant/.codelite +User :=root +Date :=05/30/19 +CodeLitePath :=/home/barant/.codelite LinkerName :=/usr/bin/x86_64-linux-gnu-g++ SharedObjectLinkerName :=/usr/bin/x86_64-linux-gnu-g++ -shared -fPIC ObjectSuffix :=.o @@ -92,7 +92,7 @@ PreBuild: ## Objects ## $(IntermediateDirectory)/main.cpp$(ObjectSuffix): main.cpp $(IntermediateDirectory)/main.cpp$(DependSuffix) - $(CXX) $(IncludePCH) $(SourceSwitch) "/home/bradarant/barant/HTTPServer/main.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/main.cpp$(ObjectSuffix) $(IncludePath) + $(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/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/bradarant/barant/HTTPServer/HTTPSession.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/HTTPSession.cpp$(ObjectSuffix) $(IncludePath) + $(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/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,7 +108,7 @@ $(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/bradarant/barant/HTTPServer/HTTPSessions.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/HTTPSessions.cpp$(ObjectSuffix) $(IncludePath) + $(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/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 @@ -116,7 +116,7 @@ $(IntermediateDirectory)/HTTPSessions.cpp$(PreprocessSuffix): HTTPSessions.cpp $(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/HTTPSessions.cpp$(PreprocessSuffix) HTTPSessions.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) + $(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/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 diff --git a/HTTPServer.project b/HTTPServer.project index 526c584..2192b14 100644 --- a/HTTPServer.project +++ b/HTTPServer.project @@ -9,11 +9,12 @@ - - - + + + + diff --git a/HTTPServer.txt b/HTTPServer.txt index 013258e..bbfbe1f 100644 --- a/HTTPServer.txt +++ b/HTTPServer.txt @@ -1 +1 @@ -./Debug/main.cpp.o ./Debug/HTTPSession.cpp.o ./Debug/HTTPSessions.cpp.o ./Debug/_GET.cpp.o ./Debug/src__POST.cpp.o +./Debug/main.cpp.o ./Debug/HTTPSession.cpp.o ./Debug/HTTPSessions.cpp.o ./Debug/HTTPHandler.cpp.o diff --git a/HTTPService.h b/HTTPService.h index 1f0208c..3ef48de 100644 --- a/HTTPService.h +++ b/HTTPService.h @@ -3,7 +3,7 @@ #include "Service.h" #include "HTTPSessions.h" -#include "PageService.h" +#include "PageList.h" #include "Exception.h" #include "HTTPHandler.h" @@ -13,15 +13,16 @@ namespace http { public: HTTPService() { - commands.add(httpHandler, "GET "); - commands.add(httpHandler, "POST "); + commands.add(getHandler, "GET"); + commands.add(postHandler, "POST"); } HTTPSessions httpSessions; - PageService pageService; + PageList pageList; private: - HTTPHandler httpHandler; + HTTPHandler getHandler; + HTTPHandler postHandler; }; diff --git a/PageList.h b/PageList.h new file mode 100644 index 0000000..319d2a5 --- /dev/null +++ b/PageList.h @@ -0,0 +1,26 @@ +#ifndef __PageList_h__ +#define __PageList_h__ + +#include "CommandList.h" +#include "__index.h" +#include "__setupadmin.h" + +namespace http { + + class PageList : public core::CommandList { + + public: + PageList() { + add(index, "/ "); + add(setupadmin, "/setupadmin "); + } + + private: + __index index; + __setupadmin setupadmin; + + }; + +} + +#endif diff --git a/__favicon_ico.h b/__favicon_ico.h new file mode 100644 index 0000000..60cc7dd --- /dev/null +++ b/__favicon_ico.h @@ -0,0 +1,85 @@ +#ifndef ____favicon_ico_h__ +#define ____favicon_ico_h__ + +namespace http { + + class __favicon_ico : public core::Command { + + int processCommand(std::string request, core::Session *session, std::stringstream &data) override { + + data << header_data; + + return true; + } + + char *header_data = + "````````````````````````````````````````^PH_U/([J-@W@<4T3[4R+*TQ" + "+ZTQ6+(X@,4T-JXQ)*HQ" + ")JHQ/*\\RBLHUP.8Y]P@_`````````0X`KMPW):HQ)*HQ;[XS^@H_````````````" + "````````_PT_=+`T)*HQ+*PQTO$[````````^0D_I-\\,T_`X`````W_H\\)*HQ)*HQP>4Y)*HQ)*HQO^8Y````````A<@U)*HQ:KPS`P\\`" + "UO,[)*HQ)*HQYOX]````[`0^+*LQ)*HQI=0Y````_@T_-*TQ)*HQ)*HQ)*HQ)*HQ)*HQ" + ")*HQ)*HQ)*HQ)*HQ)*HQ;;XS`P```P\\`I-8W)*HQ=L$T````````F=$V)*HQA\\DU" + "+:TQ)*HQP>8Y````]@@_)*HQ)*HQ6+8Y````]@@_)*HQ)*HQ>L,TG-,VE,\\V)*HQ)*HQ)*HQ)*HQ)*HQ)*HQ" + ")*HQ)*HQ)*HQ)*HQ)*HQ):HQL=\\XM-`X@,4T)*HQ0K,R````````JMDW)*HQ7KLS" + "4[8S)*HQMM`X`````0X`+JTQ)*HQO.0Y````_@T_-*TQ)*HQ)*HQ)*HQ)*HQ)*HQ" + ")*HQ)*HQ)*HQ)*HQ)*HQ;;XS````````I-`[````^0D_+:LQ)*HQQ.DY" + "UO0[)*HQ)*HQYOX]````[`0^+*LQ)*HQI=\\,T_`X`````W_D\\)*HQ)*HQP>XZ````````" + "````````_PT_=;`T)*HQ+*LQTO$[````````^0D_I=\ -

You have successfully set up a JETServer.\ -
Session Id: " + httpSession->getSessionId() + "\ +

You have successfully set up a JETServer.\ +
Session Id: \
The configuration has not yet been established for this web site.

\ \
"; - } -} \ No newline at end of file + + return true; + } + }; +} + +#endif diff --git a/__setupadmin.h b/__setupadmin.h new file mode 100644 index 0000000..17e0146 --- /dev/null +++ b/__setupadmin.h @@ -0,0 +1,23 @@ +#ifndef ____setupadmin_h__ +#define ____setupadmin_h__ + +namespace http { + + class __setupadmin : public core::Command { + + int processCommand(std::string request, core::Session *session, std::stringstream &data) override { + + data << "\ +

Please enter credential information\ + for the security officer.
\ +
Session Id: \ +
The configuration has not yet been established for this web site.

\ + \ +
"; + + return true; + } + }; +} + +#endif diff --git a/src/PageService.h b/src/PageService.h deleted file mode 100644 index d310896..0000000 --- a/src/PageService.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef __PageService_h__ -#define __PageService_h__ - -#include "Service.h" -#include "__index.h" -#include "__setupadmin.h" - -namespace http { - - class PageService : public core::Service { - - public: - PageService() { - commands.add(index, "/"); - commands.add(setupadmin, "/setupadmin"); - } - - private: - __index index; - __setupadmin setupadmin; - - }; - -} - -#endif diff --git a/src/__setupadmin.h b/src/__setupadmin.h deleted file mode 100644 index a7886a1..0000000 --- a/src/__setupadmin.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef ____setupadmin_h__ -#define ____setupadmin_h__ - -namespace http { - - class __setupadmin : core::Command { - - 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.

\ - \ -
"; - } -} \ No newline at end of file