More development.
This commit is contained in:
parent
a064615843
commit
ed39ea0b7b
BIN
Debug/main.cpp.o
BIN
Debug/main.cpp.o
Binary file not shown.
@ -1,39 +1,46 @@
|
||||
Debug/main.cpp.o: main.cpp ../ServerCore/includes ../ServerCore/EPoll.h \
|
||||
../ServerCore/Log.h ../ServerCore/includes ../ServerCore/File.h \
|
||||
../ServerCore/Object.h ../ServerCore/Socket.h ../ServerCore/Thread.h \
|
||||
../CoreUtils/Log.h ../CoreUtils/includes ../CoreUtils/File.h \
|
||||
../ServerCore/Object.h ../ServerCore/includes ../CoreUtils/LogListener.h \
|
||||
../ServerCore/Socket.h ../ServerCore/Object.h ../ServerCore/Thread.h \
|
||||
../ServerCore/Session.h ../ServerCore/TCPSocket.h \
|
||||
../ServerCore/IPAddress.h ../ServerCore/SessionFilter.h \
|
||||
../ServerCore/Command.h ../ServerCore/ConsoleServer.h \
|
||||
../ServerCore/TCPServerSocket.h ../ServerCore/Service.h \
|
||||
../ServerCore/CommandList.h ../ServerCore/IPAddressList.h \
|
||||
../ServerCore/EPoll.h ../ServerCore/Exception.h ../ServerCore/File.h \
|
||||
../ServerCore/Log.h ../ServerCore/IPAddress.h HTTPService.h \
|
||||
../ServerCore/Service.h HTTPSessions.h HTTPRequest.h \
|
||||
../CoreUtils/PString.h ../CoreUtils/includes ../CoreUtils/IMFMessage.h \
|
||||
../CoreUtils/PString.h ../CoreUtils/IMFHeader.h \
|
||||
../CoreUtils/IMFRequest.h ../CoreUtils/IMFBody.h \
|
||||
../CoreUtils/IMFRequest.h ../CoreUtils/IMFResponse.h \
|
||||
../CoreUtils/IMFMessage.h HTTPPageList.h ../ServerCore/Session.h \
|
||||
__index.h HTTPPage.h HTTPSession.h ../JET/Variables.h __script.h \
|
||||
__editview.h __style.h __setupadmin.h __favicon_ico.h __welcome.h \
|
||||
../ServerCore/Command.h ../ServerCore/ConsoleService.h \
|
||||
../ServerCore/Service.h ../ServerCore/CommandList.h \
|
||||
../ServerCore/ConsoleSession.h ../ServerCore/TerminalSession.h \
|
||||
../ServerCore/TCPServerSocket.h ../ServerCore/IPAddressList.h \
|
||||
../CoreUtils/Exception.h ../CoreUtils/File.h ../ServerCore/IPAddress.h \
|
||||
HTTPService.h ../ServerCore/Service.h HTTPSessions.h HTTPRequest.h \
|
||||
../CoreUtils/PString.h ../CoreUtils/IMFMessage.h ../CoreUtils/PString.h \
|
||||
../CoreUtils/IMFHeader.h ../CoreUtils/IMFRequest.h \
|
||||
../CoreUtils/IMFBody.h ../CoreUtils/IMFRequest.h \
|
||||
../CoreUtils/IMFResponse.h ../CoreUtils/IMFMessage.h \
|
||||
../ServerCore/Command.h ../ServerCore/Session.h HTTPPageList.h __index.h \
|
||||
HTTPPage.h HTTPSession.h ../JET/Variables.h __script.h __editview.h \
|
||||
__style.h __setupadmin.h __favicon_ico.h __welcome.h \
|
||||
../BMAMySQL/BMAMySQL.h __mainmenu.h __newview.h __configure.h \
|
||||
__viewlist.h ../CoreUtils/Directory.h ../CoreUtils/DirectoryEntry.h \
|
||||
HTTPHandler.h ../ServerCore/Command.h
|
||||
HTTPHandler.h
|
||||
|
||||
../ServerCore/includes:
|
||||
|
||||
../ServerCore/EPoll.h:
|
||||
|
||||
../ServerCore/Log.h:
|
||||
../CoreUtils/Log.h:
|
||||
|
||||
../ServerCore/includes:
|
||||
../CoreUtils/includes:
|
||||
|
||||
../ServerCore/File.h:
|
||||
../CoreUtils/File.h:
|
||||
|
||||
../ServerCore/Object.h:
|
||||
|
||||
../ServerCore/includes:
|
||||
|
||||
../CoreUtils/LogListener.h:
|
||||
|
||||
../ServerCore/Socket.h:
|
||||
|
||||
../ServerCore/Object.h:
|
||||
|
||||
../ServerCore/Thread.h:
|
||||
|
||||
../ServerCore/Session.h:
|
||||
@ -46,23 +53,23 @@ Debug/main.cpp.o: main.cpp ../ServerCore/includes ../ServerCore/EPoll.h \
|
||||
|
||||
../ServerCore/Command.h:
|
||||
|
||||
../ServerCore/ConsoleServer.h:
|
||||
|
||||
../ServerCore/TCPServerSocket.h:
|
||||
../ServerCore/ConsoleService.h:
|
||||
|
||||
../ServerCore/Service.h:
|
||||
|
||||
../ServerCore/CommandList.h:
|
||||
|
||||
../ServerCore/ConsoleSession.h:
|
||||
|
||||
../ServerCore/TerminalSession.h:
|
||||
|
||||
../ServerCore/TCPServerSocket.h:
|
||||
|
||||
../ServerCore/IPAddressList.h:
|
||||
|
||||
../ServerCore/EPoll.h:
|
||||
../CoreUtils/Exception.h:
|
||||
|
||||
../ServerCore/Exception.h:
|
||||
|
||||
../ServerCore/File.h:
|
||||
|
||||
../ServerCore/Log.h:
|
||||
../CoreUtils/File.h:
|
||||
|
||||
../ServerCore/IPAddress.h:
|
||||
|
||||
@ -76,8 +83,6 @@ HTTPRequest.h:
|
||||
|
||||
../CoreUtils/PString.h:
|
||||
|
||||
../CoreUtils/includes:
|
||||
|
||||
../CoreUtils/IMFMessage.h:
|
||||
|
||||
../CoreUtils/PString.h:
|
||||
@ -94,10 +99,12 @@ HTTPRequest.h:
|
||||
|
||||
../CoreUtils/IMFMessage.h:
|
||||
|
||||
HTTPPageList.h:
|
||||
../ServerCore/Command.h:
|
||||
|
||||
../ServerCore/Session.h:
|
||||
|
||||
HTTPPageList.h:
|
||||
|
||||
__index.h:
|
||||
|
||||
HTTPPage.h:
|
||||
@ -133,5 +140,3 @@ __viewlist.h:
|
||||
../CoreUtils/DirectoryEntry.h:
|
||||
|
||||
HTTPHandler.h:
|
||||
|
||||
../ServerCore/Command.h:
|
||||
|
@ -10,19 +10,18 @@ namespace http {
|
||||
|
||||
int HTTPHandler::processCommand(std::string request, core::Session *session, std::stringstream &data) {
|
||||
|
||||
core::Log(core::LOG_DEBUG_1) << request;
|
||||
|
||||
coreutils::PString request1(request);
|
||||
HTTPRequest httpRequest(request1);
|
||||
|
||||
HTTPSession *httpSession = ((HTTPService &)session->service).httpSessions.findSessionByHeader(httpRequest);
|
||||
|
||||
std::stringstream content;
|
||||
|
||||
if(((HTTPService &)session->service).pageList.processRequest(httpRequest, session, httpSession, content)) {
|
||||
std::string contentType = httpRequest.getHeader("Content-Type");
|
||||
if(contentType == "multipart/form-data") {
|
||||
coreutils::IMFFormData *formdata = (coreutils::IMFFormData *)httpRequest.getBody();
|
||||
core::Log(core::LOG_DEBUG_2) << "username is " << formdata->getByName("username") << std::endl;
|
||||
coreutils::Log(coreutils::LOG_DEBUG_2) << "username is '" << formdata->getByName("username") << "'";
|
||||
}
|
||||
|
||||
httpRequest.response.setCode("200");
|
||||
|
17
HTTPPageCache.h
Normal file
17
HTTPPageCache.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef __HTTPPageCache_h__
|
||||
#define __HTTPPageCache_h__
|
||||
|
||||
namespace http {
|
||||
|
||||
class HTTPPageCache {
|
||||
|
||||
public:
|
||||
std::string
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -13,7 +13,7 @@ CurrentFileName :=
|
||||
CurrentFilePath :=
|
||||
CurrentFileFullPath :=
|
||||
User :=Brad Arant
|
||||
Date :=16/08/19
|
||||
Date :=12/09/19
|
||||
CodeLitePath :=/home/bradarant/.codelite
|
||||
LinkerName :=/usr/bin/x86_64-linux-gnu-g++
|
||||
SharedObjectLinkerName :=/usr/bin/x86_64-linux-gnu-g++ -shared -fPIC
|
||||
|
@ -26,6 +26,7 @@
|
||||
<File Name="HTTPRequest.h"/>
|
||||
<File Name="__configure.h"/>
|
||||
<File Name="__viewlist.h"/>
|
||||
<File Name="HTTPPageCache.h"/>
|
||||
</VirtualDirectory>
|
||||
<Dependencies Name="Debug"/>
|
||||
<Dependencies Name="Release"/>
|
||||
|
@ -19,7 +19,7 @@ namespace http {
|
||||
|
||||
HTTPSessions httpSessions;
|
||||
HTTPPageList pageList;
|
||||
|
||||
|
||||
private:
|
||||
HTTPHandler getHandler;
|
||||
HTTPHandler postHandler;
|
||||
|
@ -21,7 +21,7 @@ namespace http {
|
||||
httpSession = createHTTPSession();
|
||||
httpRequest.response.setCookie("sessionId", httpSession->getSessionId());
|
||||
}
|
||||
core::Log(core::LOG_DEBUG_1) << "http session: " << "(" << sessionId << ") " << httpSession;
|
||||
coreutils::Log(coreutils::LOG_DEBUG_1) << "http session: " << "(" << sessionId << ") " << httpSession;
|
||||
|
||||
} else {
|
||||
httpSession = createHTTPSession();
|
||||
@ -44,4 +44,16 @@ namespace http {
|
||||
return uuid_s;
|
||||
}
|
||||
|
||||
int HTTPSessions::processCommand(std::string command, core::Session *session, std::stringstream &data) {
|
||||
if(sessions.size() > 0) {
|
||||
int seq = 0;
|
||||
for(auto httpSession: sessions)
|
||||
data << "|" << ++seq << "|" << httpSession.second->getSessionId() << "|" << std::endl;
|
||||
|
||||
}
|
||||
else
|
||||
data << "There are no sessions active." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,16 +2,20 @@
|
||||
#define __HTTPSessions_h__
|
||||
|
||||
#include "HTTPRequest.h"
|
||||
#include "Command.h"
|
||||
#include "Session.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
class HTTPSession;
|
||||
|
||||
class HTTPSessions {
|
||||
class HTTPSessions : public core::Command {
|
||||
|
||||
public:
|
||||
HTTPSession * findSessionByHeader(HTTPRequest &httpRequest);
|
||||
HTTPSession * findSessionById(std::string sessionId, HTTPRequest &httpRequest);
|
||||
|
||||
int processCommand(std::string request, core::Session *session, std::stringstream &data);
|
||||
|
||||
private:
|
||||
HTTPSession * createHTTPSession();
|
||||
|
@ -9,7 +9,7 @@ namespace http {
|
||||
|
||||
int processCommand(std::string request, core::Session *session, HTTPSession *httpSession, HTTPRequest &httpRequest, std::stringstream &data) override {
|
||||
|
||||
data << " <div style=\"position: relative;\">" << std::endl;
|
||||
data << " <div style=\"position: relative;\">" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << " <div id=\"window1\" style=\"position: absolute; left: 0px; top: 0px; border: 1pt solid black; display: inline-block; padding: 2px; background: #808080; color: #ffffff;\">" << std::endl;
|
||||
data << "" << std::endl;
|
||||
|
22
main.cpp
22
main.cpp
@ -1,6 +1,6 @@
|
||||
#include "includes"
|
||||
#include "EPoll.h"
|
||||
#include "ConsoleServer.h"
|
||||
#include "ConsoleService.h"
|
||||
#include "Exception.h"
|
||||
#include "File.h"
|
||||
#include "Log.h"
|
||||
@ -11,8 +11,8 @@ int main(int argc, char **argv) {
|
||||
|
||||
try {
|
||||
|
||||
core::Log(new core::File("/tmp/http.log", O_WRONLY | O_APPEND | O_CREAT, 0644));
|
||||
core::Log(core::LOG_INFO) << "HTTP Server starting. Build " << __DATE__ << " " << __TIME__;
|
||||
coreutils::Log(new coreutils::File("/tmp/http.log", O_WRONLY | O_APPEND | O_CREAT, 0644));
|
||||
coreutils::Log(coreutils::LOG_INFO) << "HTTP Server starting. Build " << __DATE__ << " " << __TIME__;
|
||||
|
||||
std::string ipAddress = "0.0.0.0";
|
||||
|
||||
@ -21,12 +21,14 @@ int main(int argc, char **argv) {
|
||||
http::HTTPService httpService;
|
||||
core::TCPServerSocket http(ePoll, httpService, core::IPAddress(ipAddress, 8080));
|
||||
|
||||
core::Service consoleService;
|
||||
core::ConsoleServer console(ePoll, consoleService, core::IPAddress(ipAddress, 1027));
|
||||
consoleService.commands.add(ePoll);
|
||||
consoleService.commands.add(http);
|
||||
consoleService.commands.add(console);
|
||||
ePoll.start(4, 1000);
|
||||
core::ConsoleService consoleService;
|
||||
core::TCPServerSocket console(ePoll, consoleService, core::IPAddress(ipAddress, 1027));
|
||||
|
||||
consoleService.commands.add(ePoll, "threads");
|
||||
consoleService.commands.add(httpService.httpSessions, "sessions");
|
||||
consoleService.commands.add(console, "consoles");
|
||||
consoleService.commands.add(consoleService.commands, "help");
|
||||
ePoll.start(16, 1000);
|
||||
|
||||
while(true)
|
||||
sleep(300);
|
||||
@ -35,7 +37,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
}
|
||||
|
||||
catch(core::Exception exception) {
|
||||
catch(coreutils::Exception exception) {
|
||||
std::cout << exception.text << " Error reason is '" << strerror(exception.errorNumber) << "' in file " << exception.file << " at line " << exception.line << std::endl;
|
||||
sleep(10);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user