summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/modules/httpd.h19
-rw-r--r--src/modules/m_httpd.cpp13
2 files changed, 21 insertions, 11 deletions
diff --git a/src/modules/httpd.h b/src/modules/httpd.h
index 9be23f9f0..8819202eb 100644
--- a/src/modules/httpd.h
+++ b/src/modules/httpd.h
@@ -3,21 +3,30 @@
#ifndef __HTTPD_H__
#define __HTTPD_H__
-HTTPRequest : public classbase
+#include <string>
+#include <sstream>
+
+class HTTPRequest : public classbase
{
protected:
std::string type;
std::string document;
std::string ipaddr;
+ std::stringstream* headers;
public:
- void* opaque;
+ void* sock;
+
+ HTTPRequest(const std::string &request_type, const std::string &uri, std::stringstream* hdr, void* opaque, const std::string &ip)
+ : type(request_type), document(uri), ipaddr(ip), headers(hdr), sock(opaque)
+ {
+ }
- HTTPRequest(const std::string &request_type, const std::string &uri, void* opaque, const std::string &ip)
- : type(request_type), document(uri), ipaddr(ip)
+ std::stringstream* GetHeaders()
{
+ return headers;
}
std::string& GetType()
@@ -34,7 +43,7 @@ HTTPRequest : public classbase
{
return ipaddr;
}
-}
+};
#endif
diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp
index b618e01f9..d0c63d818 100644
--- a/src/modules/m_httpd.cpp
+++ b/src/modules/m_httpd.cpp
@@ -29,7 +29,7 @@ using namespace std;
class ModuleHttp;
static Server *Srv;
-static ModuleHttp* HttpModule;
+ModuleHttp* HttpModule;
extern time_t TIME;
enum HttpState
@@ -85,6 +85,7 @@ class HttpSocket : public InspSocket
{
char* data = this->Read();
std::string request_type;
+ std::string uri;
/* Check that the data read is a valid pointer and it has some content */
if (data && *data)
@@ -99,15 +100,15 @@ class HttpSocket : public InspSocket
headers >> request_type;
headers >> uri;
- if ((request_type == "GET") && (uri = "/"))
+ if ((request_type == "GET") && (uri == "/"))
{
SendHeaders(index->ContentSize());
this->Write(index->Contents());
}
else
{
- HttpRequest httpr(request_type,uri,headers,this,this->GetIP());
- Event e(uri, HttpModule, "httpd_url");
+ HTTPRequest httpr(request_type,uri,&headers,this,this->GetIP());
+ Event e((char*)&httpr, (Module*)HttpModule, "httpd_url");
}
return false;
@@ -203,8 +204,8 @@ class ModuleHttpFactory : public ModuleFactory
virtual Module * CreateModule(Server* Me)
{
- ModuleHttp = new ModuleHttp(Me);
- return new HttpModule;
+ HttpModule = new ModuleHttp(Me);
+ return HttpModule;
}
};