summaryrefslogtreecommitdiffhomepage
path: root/NetEx/HttpServlet.cpp
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-03-29 23:28:05 +0200
committerAki <please@ignore.pl>2022-03-29 23:29:18 +0200
commit27ffda3b67d172afca2cb85387fad27e78719480 (patch)
tree6ca5f6992b54ff34d42125b03522c7227cbaa108 /NetEx/HttpServlet.cpp
parent20eb9409e1d4d5d26222e62df4a81b0be9cae6f2 (diff)
downloadstarshatter-27ffda3b67d172afca2cb85387fad27e78719480.zip
starshatter-27ffda3b67d172afca2cb85387fad27e78719480.tar.gz
starshatter-27ffda3b67d172afca2cb85387fad27e78719480.tar.bz2
Split Session from HttpServlet
Diffstat (limited to 'NetEx/HttpServlet.cpp')
-rw-r--r--NetEx/HttpServlet.cpp165
1 files changed, 16 insertions, 149 deletions
diff --git a/NetEx/HttpServlet.cpp b/NetEx/HttpServlet.cpp
index eb9f19e..150719c 100644
--- a/NetEx/HttpServlet.cpp
+++ b/NetEx/HttpServlet.cpp
@@ -3,31 +3,31 @@
Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors
Copyright (c) 1997-2006, Destroyer Studios LLC.
- AUTHOR: John DiCamillo
+ AUTHOR: John DiCamillo
-
- OVERVIEW
- ========
- Network Server Pump for HTTP Server
+ OVERVIEW
+ ========
+ Network Server Pump for HTTP Server
*/
#include "HttpServlet.h"
-#include "NetLayer.h"
-#include <stdlib.h>
#include <stdio.h>
-#include <ctype.h>
-// +-------------------------------------------------------------------+
+#include "HttpRequest.h"
+#include "HttpResponse.h"
+
+
+HttpServlet::HttpServlet() :
+ session(nullptr)
+{
+}
-HttpServlet::HttpServlet()
- : session(0)
-{ }
HttpServlet::~HttpServlet()
-{ }
+{
+}
-// +--------------------------------------------------------------------+
bool
HttpServlet::Service(HttpRequest& request, HttpResponse& response)
@@ -54,7 +54,6 @@ HttpServlet::Service(HttpRequest& request, HttpResponse& response)
return result;
}
-// +--------------------------------------------------------------------+
bool
HttpServlet::DoGet(HttpRequest& request, HttpResponse& response)
@@ -62,12 +61,14 @@ HttpServlet::DoGet(HttpRequest& request, HttpResponse& response)
return false;
}
+
bool
HttpServlet::DoPost(HttpRequest& request, HttpResponse& response)
{
return DoGet(request, response);
}
+
bool
HttpServlet::DoHead(HttpRequest& request, HttpResponse& response)
{
@@ -84,137 +85,3 @@ HttpServlet::DoHead(HttpRequest& request, HttpResponse& response)
return false;
}
-
-// +--------------------------------------------------------------------+
-// +--------------------------------------------------------------------+
-// +--------------------------------------------------------------------+
-
-HttpSession::HttpSession()
-{
- id = GenerateUniqueID();
- access_time = NetLayer::GetUTC();
-}
-
-HttpSession::~HttpSession()
-{
- attributes.destroy();
-}
-
-// +--------------------------------------------------------------------+
-
-Text
-HttpSession::GetAttribute(const char* name)
-{
- ListIter<HttpParam> iter = attributes;
- while (++iter) {
- HttpParam* p = iter.value();
-
- if (p->name == name)
- return p->value;
- }
-
- return Text();
-}
-
-void
-HttpSession::SetAttribute(const char* name, const char* value)
-{
- ListIter<HttpParam> iter = attributes;
- while (++iter) {
- HttpParam* p = iter.value();
-
- if (p->name == name) {
- p->value = value;
- return;
- }
- }
-
- HttpParam* param = new HttpParam(name, value);
- if (param)
- attributes.append(param);
-}
-
-void
-HttpSession::DelAttribute(const char* name)
-{
- ListIter<HttpParam> iter = attributes;
- while (++iter) {
- HttpParam* p = iter.value();
-
- if (p->name == name) {
- delete iter.removeItem();
- return;
- }
- }
-}
-
-// +--------------------------------------------------------------------+
-
-int
-HttpSession::GetIntAttribute(const char* name)
-{
- ListIter<HttpParam> iter = attributes;
- while (++iter) {
- HttpParam* p = iter.value();
-
- if (p->name == name) {
- int result = ::atoi(p->value.data());
- return result;
- }
- }
-
- return 0;
-}
-
-void
-HttpSession::SetIntAttribute(const char* name, int value)
-{
- char buf[32];
- sprintf(buf, "%d", value);
-
- ListIter<HttpParam> iter = attributes;
- while (++iter) {
- HttpParam* p = iter.value();
-
- if (p->name == name) {
- p->value = buf;
- return;
- }
- }
-
- HttpParam* param = new HttpParam(name, buf);
- if (param)
- attributes.append(param);
-}
-
-void
-HttpSession::DelIntAttribute(const char* name)
-{
- DelAttribute(name);
-}
-
-// +--------------------------------------------------------------------+
-
-Text
-HttpSession::GenerateUniqueID()
-{
- char unique[17];
-
- for (int i = 0; i < 16; i++) {
- char c = rand() % 25 + 'a';
- unique[i] = c;
- }
-
- unique[16] = 0;
- return unique;
-}
-
-// +--------------------------------------------------------------------+
-
-void
-HttpSession::Access()
-{
- access_time = NetLayer::GetUTC();
-}
-
-