]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_httpd.cpp
Support SASL messages other than 'C' and 'D'
[user/henk/code/inspircd.git] / src / modules / m_httpd.cpp
index 0584e97c5eea620a46b587ae7291541b78040fc9..6315809a9f8a6c4d4335b25a8a5551e10abc27f9 100644 (file)
@@ -32,6 +32,7 @@ class ModuleHttpServer;
 
 static ModuleHttpServer* HttpModule;
 static bool claimed;
+static std::set<HttpServerSocket*> sockets;
 
 /** HTTP socket states
  */
@@ -69,6 +70,11 @@ class HttpServerSocket : public BufferedSocket
                        GetIOHook()->OnStreamSocketAccept(this, client, server);
        }
 
+       ~HttpServerSocket()
+       {
+               sockets.erase(this);
+       }
+
        virtual void OnError(BufferedSocketError)
        {
                ServerInstance->GlobalCulls.AddItem(this);
@@ -186,7 +192,7 @@ class HttpServerSocket : public BufferedSocket
                date[strlen(date) - 1] = '\0';
                rheaders.CreateHeader("Date", date);
 
-               rheaders.CreateHeader("Server", "InspIRCd/m_httpd.so/1.2");
+               rheaders.CreateHeader("Server", BRANCH);
                rheaders.SetHeader("Content-Length", ConvToStr(size));
 
                if (size)
@@ -282,7 +288,7 @@ class HttpServerSocket : public BufferedSocket
                        return;
                }
 
-               if (headers.IsSet("Content-Length") && (postsize = atoi(headers.GetHeader("Content-Length").c_str())) != 0)
+               if (headers.IsSet("Content-Length") && (postsize = ConvToInt(headers.GetHeader("Content-Length"))) > 0)
                {
                        InternalState = HTTP_SERVE_RECV_POSTDATA;
 
@@ -333,10 +339,10 @@ class HttpServerSocket : public BufferedSocket
 
 class ModuleHttpServer : public Module
 {
-       std::vector<HttpServerSocket *> httpsocks;
  public:
 
-       ModuleHttpServer()      {
+       void init()
+       {
                HttpModule = this;
                ServerInstance->Modules->Attach(I_OnAcceptConnection, this);
        }
@@ -357,18 +363,21 @@ class ModuleHttpServer : public Module
                int port;
                std::string incomingip;
                irc::sockets::satoap(*client, incomingip, port);
-               new HttpServerSocket(nfd, incomingip, from, client, server);
+               sockets.insert(new HttpServerSocket(nfd, incomingip, from, client, server));
                return MOD_RES_ALLOW;
        }
 
-
-       virtual ~ModuleHttpServer()
+       CullResult cull()
        {
-               for (size_t i = 0; i < httpsocks.size(); i++)
+               std::set<HttpServerSocket*> local;
+               local.swap(sockets);
+               for (std::set<HttpServerSocket*>::const_iterator i = local.begin(); i != local.end(); ++i)
                {
-                       httpsocks[i]->cull();
-                       delete httpsocks[i];
+                       HttpServerSocket* sock = *i;
+                       sock->cull();
+                       delete sock;
                }
+               return Module::cull();
        }
 
        virtual Version GetVersion()