]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_httpd.cpp
Commit patch from danieldg that makes a ton of stuff const-safe for latest warn-happy...
[user/henk/code/inspircd.git] / src / modules / m_httpd.cpp
index dc8a8c8a8958066243a35fef8de6bd26dc6e25e4..56a24119f254b7ebfb3e9a4d35815af88b80d923 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
  * See: http://www.inspircd.org/wiki/index.php/Credits
  *
  * This program is free but copyrighted software; see
@@ -36,7 +36,7 @@ class HttpServerSocket;
 
 /** This class is used to handle HTTP socket timeouts
  */
-class HttpServerTimeout : public InspTimer
+class HttpServerTimeout : public Timer
 {
  private:
        /** HttpServerSocket we are attached to
@@ -56,7 +56,7 @@ class HttpServerTimeout : public InspTimer
 
 /** A socket used for HTTP transport
  */
-class HttpServerSocket : public InspSocket
+class HttpServerSocket : public BufferedSocket
 {
        FileReader* index;
        HttpState InternalState;
@@ -76,13 +76,13 @@ class HttpServerSocket : public InspSocket
        
  public:
 
-       HttpServerSocket(InspIRCd* SI, std::string host, int port, bool listening, unsigned long maxtime, FileReader* index_page) : InspSocket(SI, host, port, listening, maxtime), index(index_page), postsize(0)
+       HttpServerSocket(InspIRCd* SI, std::string shost, int iport, bool listening, unsigned long maxtime, FileReader* index_page) : BufferedSocket(SI, shost, iport, listening, maxtime), index(index_page), postsize(0)
        {
                InternalState = HTTP_LISTEN;
                Timeout = NULL;
        }
 
-       HttpServerSocket(InspIRCd* SI, int newfd, char* ip, FileReader* ind) : InspSocket(SI, newfd, ip), index(ind), postsize(0), keepalive(false), DataSinceLastTick(false)
+       HttpServerSocket(InspIRCd* SI, int newfd, char* ip, FileReader* ind) : BufferedSocket(SI, newfd, ip), index(ind), postsize(0), keepalive(false), DataSinceLastTick(false)
        {
                InternalState = HTTP_SERVE_WAIT_REQUEST;
                Timeout = new HttpServerTimeout(this, Instance->SE);
@@ -270,7 +270,7 @@ class HttpServerSocket : public InspSocket
 
        virtual bool OnDataReady()
        {
-               char* data = this->Read();
+               const char* data = this->Read();
 
                /* Check that the data read is a valid pointer and it has some content */
                if (!data || !*data)
@@ -407,9 +407,9 @@ class HttpServerSocket : public InspSocket
                }
        }
 
-       void Page(std::stringstream* n, int response, HTTPHeaders *headers)
+       void Page(std::stringstream* n, int response, HTTPHeaders *hheaders)
        {
-               SendHeaders(n->str().length(), response, *headers);
+               SendHeaders(n->str().length(), response, *hheaders);
                this->Write(n->str());
                
                if (!keepalive)
@@ -422,7 +422,7 @@ class HttpServerSocket : public InspSocket
        }
 };
 
-HttpServerTimeout::HttpServerTimeout(HttpServerSocket* sock, SocketEngine* engine) : InspTimer(15, time(NULL), true), s(sock), SE(engine)
+HttpServerTimeout::HttpServerTimeout(HttpServerSocket* sock, SocketEngine* engine) : Timer(15, time(NULL), true), s(sock), SE(engine)
 {
 }
 
@@ -474,9 +474,11 @@ class ModuleHttpServer : public Module
        {
                ReadConfig();
                HttpModule = this;
+               Implementation eventlist[] = { I_OnRequest };
+               ServerInstance->Modules->Attach(eventlist, this, 1);
        }
 
-       char* OnRequest(Request* request)
+       virtual const char* OnRequest(Request* request)
        {
                claimed = true;
                HTTPDocument* doc = (HTTPDocument*)request->GetData();
@@ -485,10 +487,6 @@ class ModuleHttpServer : public Module
                return NULL;
        }
 
-       void Implements(char* List)
-       {
-               List[I_OnRequest] = 1;
-       }
 
        virtual ~ModuleHttpServer()
        {
@@ -498,7 +496,7 @@ class ModuleHttpServer : public Module
                        httpsocks[i]->Close();
                        delete httpsocks[i]->GetIndex();
                }
-               ServerInstance->InspSocketCull();
+               ServerInstance->BufferedSocketCull();
        }
 
        virtual Version GetVersion()