Working test server
This commit is contained in:
parent
a0aa6fb0d8
commit
c89c36c49a
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
Debug
|
||||||
|
Release
|
||||||
|
*~
|
||||||
|
*.o
|
||||||
|
*.o.d
|
BIN
Debug/HTTPServer
BIN
Debug/HTTPServer
Binary file not shown.
BIN
Debug/main.cpp.o
BIN
Debug/main.cpp.o
Binary file not shown.
@ -5,12 +5,11 @@ Debug/main.cpp.o: main.cpp ../ServerCore/includes ../ServerCore/EPoll.h \
|
|||||||
../ServerCore/IPAddress.h ../ServerCore/SessionFilter.h \
|
../ServerCore/IPAddress.h ../ServerCore/SessionFilter.h \
|
||||||
../ServerCore/Command.h ../ServerCore/ConsoleServer.h \
|
../ServerCore/Command.h ../ServerCore/ConsoleServer.h \
|
||||||
../ServerCore/TCPServerSocket.h ../ServerCore/Service.h \
|
../ServerCore/TCPServerSocket.h ../ServerCore/Service.h \
|
||||||
../ServerCore/CommandList.h ../ServerCore/EPoll.h HTTPServer.h \
|
../ServerCore/CommandList.h ../ServerCore/EPoll.h \
|
||||||
../ServerCore/TCPServerSocket.h ../ServerCore/Session.h \
|
../ServerCore/Exception.h ../ServerCore/File.h ../ServerCore/Log.h \
|
||||||
../ServerCore/IPAddress.h HTTPService.h ../ServerCore/Service.h _GET.h \
|
../ServerCore/IPAddress.h HTTPService.h ../ServerCore/Service.h _GET.h \
|
||||||
../ServerCore/Command.h ../ServerCore/Header.h ../ServerCore/Response.h \
|
../ServerCore/Command.h ../ServerCore/Session.h ../ServerCore/Header.h \
|
||||||
_POST.h ../ServerCore/Exception.h ../ServerCore/File.h \
|
../ServerCore/Response.h _POST.h
|
||||||
../ServerCore/Log.h
|
|
||||||
|
|
||||||
../ServerCore/includes:
|
../ServerCore/includes:
|
||||||
|
|
||||||
@ -48,11 +47,11 @@ Debug/main.cpp.o: main.cpp ../ServerCore/includes ../ServerCore/EPoll.h \
|
|||||||
|
|
||||||
../ServerCore/EPoll.h:
|
../ServerCore/EPoll.h:
|
||||||
|
|
||||||
HTTPServer.h:
|
../ServerCore/Exception.h:
|
||||||
|
|
||||||
../ServerCore/TCPServerSocket.h:
|
../ServerCore/File.h:
|
||||||
|
|
||||||
../ServerCore/Session.h:
|
../ServerCore/Log.h:
|
||||||
|
|
||||||
../ServerCore/IPAddress.h:
|
../ServerCore/IPAddress.h:
|
||||||
|
|
||||||
@ -64,14 +63,10 @@ _GET.h:
|
|||||||
|
|
||||||
../ServerCore/Command.h:
|
../ServerCore/Command.h:
|
||||||
|
|
||||||
|
../ServerCore/Session.h:
|
||||||
|
|
||||||
../ServerCore/Header.h:
|
../ServerCore/Header.h:
|
||||||
|
|
||||||
../ServerCore/Response.h:
|
../ServerCore/Response.h:
|
||||||
|
|
||||||
_POST.h:
|
_POST.h:
|
||||||
|
|
||||||
../ServerCore/Exception.h:
|
|
||||||
|
|
||||||
../ServerCore/File.h:
|
|
||||||
|
|
||||||
../ServerCore/Log.h:
|
|
||||||
|
27
HTTPServer.h
27
HTTPServer.h
@ -1,27 +0,0 @@
|
|||||||
#ifndef __HTTPServer_h__
|
|
||||||
#define __HTTPServer_h__
|
|
||||||
|
|
||||||
#include "includes"
|
|
||||||
#include "EPoll.h"
|
|
||||||
#include "TCPServerSocket.h"
|
|
||||||
#include "Session.h"
|
|
||||||
#include "IPAddress.h"
|
|
||||||
#include "HTTPService.h"
|
|
||||||
|
|
||||||
namespace http {
|
|
||||||
|
|
||||||
class HTTPServer : public core::TCPServerSocket {
|
|
||||||
|
|
||||||
public:
|
|
||||||
HTTPServer(core::EPoll &ePoll, core::IPAddress address) : core::TCPServerSocket(ePoll, address) {}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
core::Service * getService() override {
|
|
||||||
return new HTTPService(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -2,25 +2,25 @@
|
|||||||
## Auto Generated makefile by CodeLite IDE
|
## Auto Generated makefile by CodeLite IDE
|
||||||
## any manual changes will be erased
|
## any manual changes will be erased
|
||||||
##
|
##
|
||||||
## Release
|
## Debug
|
||||||
ProjectName :=HTTPServer
|
ProjectName :=HTTPServer
|
||||||
ConfigurationName :=Release
|
ConfigurationName :=Debug
|
||||||
WorkspacePath :=/home/barant/barant
|
WorkspacePath :=/home/barant/Development/BMA/server_core
|
||||||
ProjectPath :=/home/barant/barant/HTTPServer
|
ProjectPath :=/home/barant/Development/BMA/server_core/HTTPServer
|
||||||
IntermediateDirectory :=./Release
|
IntermediateDirectory :=./Debug
|
||||||
OutDir := $(IntermediateDirectory)
|
OutDir := $(IntermediateDirectory)
|
||||||
CurrentFileName :=
|
CurrentFileName :=
|
||||||
CurrentFilePath :=
|
CurrentFilePath :=
|
||||||
CurrentFileFullPath :=
|
CurrentFileFullPath :=
|
||||||
User :=
|
User :=Brad Arant
|
||||||
Date :=03/03/19
|
Date :=12/03/19
|
||||||
CodeLitePath :=/home/barant/.codelite
|
CodeLitePath :=/home/barant/.codelite
|
||||||
LinkerName :=/usr/bin/x86_64-linux-gnu-g++
|
LinkerName :=g++
|
||||||
SharedObjectLinkerName :=/usr/bin/x86_64-linux-gnu-g++ -shared -fPIC
|
SharedObjectLinkerName :=g++ -shared -fPIC
|
||||||
ObjectSuffix :=.o
|
ObjectSuffix :=.o
|
||||||
DependSuffix :=.o.d
|
DependSuffix :=.o.d
|
||||||
PreprocessSuffix :=.i
|
PreprocessSuffix :=.o.i
|
||||||
DebugSwitch :=-g
|
DebugSwitch :=-gstab
|
||||||
IncludeSwitch :=-I
|
IncludeSwitch :=-I
|
||||||
LibrarySwitch :=-l
|
LibrarySwitch :=-l
|
||||||
OutputSwitch :=-o
|
OutputSwitch :=-o
|
||||||
@ -28,7 +28,7 @@ LibraryPathSwitch :=-L
|
|||||||
PreprocessorSwitch :=-D
|
PreprocessorSwitch :=-D
|
||||||
SourceSwitch :=-c
|
SourceSwitch :=-c
|
||||||
OutputFile :=$(IntermediateDirectory)/$(ProjectName)
|
OutputFile :=$(IntermediateDirectory)/$(ProjectName)
|
||||||
Preprocessors :=$(PreprocessorSwitch)NDEBUG
|
Preprocessors :=
|
||||||
ObjectSwitch :=-o
|
ObjectSwitch :=-o
|
||||||
ArchiveOutputSwitch :=
|
ArchiveOutputSwitch :=
|
||||||
PreprocessOnlySwitch :=-E
|
PreprocessOnlySwitch :=-E
|
||||||
@ -36,24 +36,24 @@ ObjectsFileList :="HTTPServer.txt"
|
|||||||
PCHCompileFlags :=
|
PCHCompileFlags :=
|
||||||
MakeDirCommand :=mkdir -p
|
MakeDirCommand :=mkdir -p
|
||||||
LinkOptions :=
|
LinkOptions :=
|
||||||
IncludePath := $(IncludeSwitch). $(IncludeSwitch). $(IncludeSwitch)../ServerCore
|
IncludePath := $(IncludeSwitch). $(IncludeSwitch). $(IncludeSwitch)../ServerCore/
|
||||||
IncludePCH :=
|
IncludePCH :=
|
||||||
RcIncludePath :=
|
RcIncludePath :=
|
||||||
Libs := $(LibrarySwitch)ServerCore $(LibrarySwitch)pthread
|
Libs := $(LibrarySwitch)ServerCore $(LibrarySwitch)pthread
|
||||||
ArLibs := "ServerCore" "pthread"
|
ArLibs := "ServerCore" "pthread"
|
||||||
LibPath := $(LibraryPathSwitch). $(LibraryPathSwitch)../ServerCore/Debug
|
LibPath := $(LibraryPathSwitch). $(LibraryPathSwitch)../ServerCore/Debug/
|
||||||
|
|
||||||
##
|
##
|
||||||
## Common variables
|
## Common variables
|
||||||
## AR, CXX, CC, AS, CXXFLAGS and CFLAGS can be overriden using an environment variables
|
## AR, CXX, CC, AS, CXXFLAGS and CFLAGS can be overriden using an environment variables
|
||||||
##
|
##
|
||||||
AR := /usr/bin/x86_64-linux-gnu-ar rcu
|
AR := ar rcus
|
||||||
CXX := /usr/bin/x86_64-linux-gnu-g++
|
CXX := g++
|
||||||
CC := /usr/bin/x86_64-linux-gnu-gcc
|
CC := gcc
|
||||||
CXXFLAGS := -O2 -Wall $(Preprocessors)
|
CXXFLAGS := -g -O0 -Wall $(Preprocessors)
|
||||||
CFLAGS := -O2 -Wall $(Preprocessors)
|
CFLAGS := -g -O0 -Wall $(Preprocessors)
|
||||||
ASFLAGS :=
|
ASFLAGS :=
|
||||||
AS := /usr/bin/x86_64-linux-gnu-as
|
AS := as
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
@ -79,11 +79,11 @@ $(OutputFile): $(IntermediateDirectory)/.d $(Objects)
|
|||||||
$(LinkerName) $(OutputSwitch)$(OutputFile) @$(ObjectsFileList) $(LibPath) $(Libs) $(LinkOptions)
|
$(LinkerName) $(OutputSwitch)$(OutputFile) @$(ObjectsFileList) $(LibPath) $(Libs) $(LinkOptions)
|
||||||
|
|
||||||
MakeIntermediateDirs:
|
MakeIntermediateDirs:
|
||||||
@test -d ./Release || $(MakeDirCommand) ./Release
|
@test -d ./Debug || $(MakeDirCommand) ./Debug
|
||||||
|
|
||||||
|
|
||||||
$(IntermediateDirectory)/.d:
|
$(IntermediateDirectory)/.d:
|
||||||
@test -d ./Release || $(MakeDirCommand) ./Release
|
@test -d ./Debug || $(MakeDirCommand) ./Debug
|
||||||
|
|
||||||
PreBuild:
|
PreBuild:
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ PreBuild:
|
|||||||
## Objects
|
## Objects
|
||||||
##
|
##
|
||||||
$(IntermediateDirectory)/main.cpp$(ObjectSuffix): main.cpp $(IntermediateDirectory)/main.cpp$(DependSuffix)
|
$(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/barant/Development/BMA/server_core/HTTPServer/main.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/main.cpp$(ObjectSuffix) $(IncludePath)
|
||||||
$(IntermediateDirectory)/main.cpp$(DependSuffix): main.cpp
|
$(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
|
@$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/main.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/main.cpp$(DependSuffix) -MM main.cpp
|
||||||
|
|
||||||
@ -105,6 +105,6 @@ $(IntermediateDirectory)/main.cpp$(PreprocessSuffix): main.cpp
|
|||||||
## Clean
|
## Clean
|
||||||
##
|
##
|
||||||
clean:
|
clean:
|
||||||
$(RM) -r ./Release/
|
$(RM) -r ./Debug/
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
<Description/>
|
<Description/>
|
||||||
<Dependencies/>
|
<Dependencies/>
|
||||||
<VirtualDirectory Name="src">
|
<VirtualDirectory Name="src">
|
||||||
<File Name="HTTPServer.h"/>
|
|
||||||
<File Name="HTTPService.h"/>
|
<File Name="HTTPService.h"/>
|
||||||
<File Name="_GET.h"/>
|
<File Name="_GET.h"/>
|
||||||
<File Name="_POST.h"/>
|
<File Name="_POST.h"/>
|
||||||
@ -109,4 +108,6 @@
|
|||||||
</Completion>
|
</Completion>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
</Settings>
|
</Settings>
|
||||||
|
<Dependencies Name="Debug"/>
|
||||||
|
<Dependencies Name="Release"/>
|
||||||
</CodeLite_Project>
|
</CodeLite_Project>
|
||||||
|
@ -1 +1 @@
|
|||||||
./Release/main.cpp.o
|
./Debug/main.cpp.o
|
||||||
|
@ -2,18 +2,15 @@
|
|||||||
#define __HTTPService_h__
|
#define __HTTPService_h__
|
||||||
|
|
||||||
#include "Service.h"
|
#include "Service.h"
|
||||||
//#include "HTTPServer.h"
|
|
||||||
#include "_GET.h"
|
#include "_GET.h"
|
||||||
#include "_POST.h"
|
#include "_POST.h"
|
||||||
|
|
||||||
namespace http {
|
namespace http {
|
||||||
|
|
||||||
class HTTPServer;
|
|
||||||
|
|
||||||
class HTTPService : public core::Service {
|
class HTTPService : public core::Service {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HTTPService(HTTPServer &server) : core::Service((core::TCPServerSocket &)server) {
|
HTTPService() {
|
||||||
commands.add(get, "GET ");
|
commands.add(get, "GET ");
|
||||||
commands.add(post, "POST ");
|
commands.add(post, "POST ");
|
||||||
}
|
}
|
||||||
|
14
main.cpp
14
main.cpp
@ -1,11 +1,11 @@
|
|||||||
#include "includes"
|
#include "includes"
|
||||||
#include "EPoll.h"
|
#include "EPoll.h"
|
||||||
#include "ConsoleServer.h"
|
#include "ConsoleServer.h"
|
||||||
#include "HTTPServer.h"
|
|
||||||
#include "Exception.h"
|
#include "Exception.h"
|
||||||
#include "File.h"
|
#include "File.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "IPAddress.h"
|
#include "IPAddress.h"
|
||||||
|
#include "HTTPService.h"
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
@ -18,12 +18,14 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
core::EPoll ePoll;
|
core::EPoll ePoll;
|
||||||
|
|
||||||
http::HTTPServer http(ePoll, core::IPAddress(ipAddress, 8090));
|
http::HTTPService httpService;
|
||||||
|
core::TCPServerSocket http(ePoll, httpService, core::IPAddress(ipAddress, 8090));
|
||||||
|
|
||||||
core::ConsoleServer console(ePoll, core::IPAddress(ipAddress, 1027));
|
core::Service consoleService;
|
||||||
console.service->commands.add(ePoll);
|
core::ConsoleServer console(ePoll, consoleService, core::IPAddress(ipAddress, 1027));
|
||||||
console.service->commands.add(http);
|
consoleService.commands.add(ePoll);
|
||||||
console.service->commands.add(console);
|
consoleService.commands.add(http);
|
||||||
|
consoleService.commands.add(console);
|
||||||
ePoll.start(4, 1000);
|
ePoll.start(4, 1000);
|
||||||
|
|
||||||
while(true)
|
while(true)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user