Compiles but needs lots of flow work.

This commit is contained in:
Brad Arant 2024-08-22 16:13:12 -07:00
parent e6ccda8bca
commit 259de9812f
9 changed files with 19 additions and 30 deletions

View File

@ -1,11 +0,0 @@
cmake_minimum_required(VERSION 3.0.0)
project(JETServer VERSION 0.1.0)
include(CTest)
enable_testing()
add_executable(JETServer main.cpp)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)

View File

@ -1,19 +1,19 @@
#include "FlowAction.h" #include "Flow.h"
namespace http { namespace http {
FlowAction::FlowAction() { Flow::Flow() {
int len = strlen(hex); int len = strlen(hex);
for(int ix = 0; ix < sizeof(actionId); ++ix) { for(int ix = 0; ix < sizeof(actionId); ++ix) {
actionId[ix] = hex[random() % len]; actionId[ix] = hex[random() % len];
} }
} }
bool FlowAction::action(HTTPParameters &p) { bool Flow::action(HTTPParameters &p) {
return true; return true;
} }
coreutils::ZString FlowAction::getId() { coreutils::ZString Flow::getId() {
return coreutils::ZString(actionId, sizeof(actionId)); return coreutils::ZString(actionId, sizeof(actionId));
} }

View File

@ -1,19 +1,19 @@
#include "FlowAction.h" #include "FlowQueue.h"
namespace http { namespace http {
FlowAction::FlowAction() { FlowQueue::FlowQueue() {
int len = strlen(hex); int len = strlen(hex);
for(int ix = 0; ix < sizeof(actionId); ++ix) { for(int ix = 0; ix < sizeof(actionId); ++ix) {
actionId[ix] = hex[random() % len]; actionId[ix] = hex[random() % len];
} }
} }
bool FlowAction::action(HTTPParameters &p) { bool FlowQueue::process() {
return true; return true;
} }
coreutils::ZString FlowAction::getId() { coreutils::ZString FlowQueue::getId() {
return coreutils::ZString(actionId, sizeof(actionId)); return coreutils::ZString(actionId, sizeof(actionId));
} }

View File

@ -10,7 +10,7 @@ namespace http {
public: public:
HTTPConnection(core::EPoll &ePoll, core::TCPServer &server) : TCPSession(ePoll, server, "HTTP Connection") {} HTTPConnection(core::EPoll &ePoll, core::TCPServer *server) : TCPSession(ePoll, server, "HTTP Connection") {}
void onDataReceived(coreutils::ZString &data) override { void onDataReceived(coreutils::ZString &data) override {
protocol(data); protocol(data);

View File

@ -14,11 +14,11 @@ namespace http {
HTTPRequest httpRequest(request); HTTPRequest httpRequest(request);
HTTPSession *httpSession = static_cast<HTTPServer&>(session.server).httpSessions.findSessionByHeader(httpRequest); HTTPSession *httpSession = static_cast<HTTPServer *>(session.server)->httpSessions.findSessionByHeader(httpRequest);
std::stringstream content; std::stringstream content;
HTTPParameters p(httpRequest, session, *httpSession, content, ((HTTPServer &)session.server).actionList); HTTPParameters p(httpRequest, session, *httpSession, content, ((HTTPServer *)session.server)->actionList);
// TODO: What should we do if we receive a request on a GET and there is a session variable? // TODO: What should we do if we receive a request on a GET and there is a session variable?
// If its an entry point then is it an image or link to a downloadable content that was issued // If its an entry point then is it an image or link to a downloadable content that was issued
@ -32,7 +32,7 @@ namespace http {
// TODO: Allow entry points to specify pages in the page cache or do we treat pages as automatic entry points. // TODO: Allow entry points to specify pages in the page cache or do we treat pages as automatic entry points.
try { try {
static_cast<HTTPServer &>(session.server).pageList.processRequest(p); static_cast<HTTPServer *>(session.server)->pageList.processRequest(p);
httpRequest.response.setCode("200"); httpRequest.response.setCode("200");
httpRequest.response.setText("OK"); httpRequest.response.setText("OK");
} }

View File

@ -14,14 +14,14 @@ namespace http {
HTTPRequest httpRequest(request); HTTPRequest httpRequest(request);
HTTPSession *httpSession = ((HTTPServer &)(session.server)).httpSessions.findSessionByHeader(httpRequest); HTTPSession *httpSession = ((HTTPServer *)(session.server))->httpSessions.findSessionByHeader(httpRequest);
std::stringstream content; std::stringstream content;
HTTPParameters p(httpRequest, session, *httpSession, content, ((HTTPServer &)(session.server)).actionList); HTTPParameters p(httpRequest, session, *httpSession, content, ((HTTPServer *)(session.server))->actionList);
try { try {
((HTTPServer &)(session.server)).actionList.processRequest(p); ((HTTPServer *)(session.server))->actionList.processRequest(p);
httpRequest.response.setCode("200"); httpRequest.response.setCode("200");
httpRequest.response.setText("OK"); httpRequest.response.setText("OK");
} }

View File

@ -12,13 +12,13 @@ namespace http {
HTTPRequest httpRequest(request); HTTPRequest httpRequest(request);
HTTPSession *httpSession = static_cast<HTTPServer&>(session.server).httpSessions.findSessionByHeader(httpRequest); HTTPSession *httpSession = static_cast<HTTPServer *>(session.server)->httpSessions.findSessionByHeader(httpRequest);
std::stringstream content; std::stringstream content;
HTTPParameters p(httpRequest, session, *httpSession, content, ((HTTPServer &)session.server).actionList); HTTPParameters p(httpRequest, session, *httpSession, content, ((HTTPServer *)session.server)->actionList);
try { try {
((HTTPServer &)(session.server)).pageList.processRequest(p); ((HTTPServer *)(session.server))->pageList.processRequest(p);
httpRequest.response.setCode("200"); httpRequest.response.setCode("200");
httpRequest.response.setText("OK"); httpRequest.response.setText("OK");
} }

Binary file not shown.

View File

@ -10,7 +10,7 @@ namespace http {
} }
core::TCPSession * HTTPServer::getSocketAccept(core::EPoll &epoll) { core::TCPSession * HTTPServer::getSocketAccept(core::EPoll &epoll) {
return new HTTPConnection(ePoll, *this); return new HTTPConnection(ePoll, this);
} }
} }