]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_http_client.cpp
Damn strict typing to hell
[user/henk/code/inspircd.git] / src / modules / m_http_client.cpp
index e3c50ef82022876ae00deb1403e296ca466159ee..a2f80687fa4306ca927f188ef67e3dd6254399bf 100644 (file)
@@ -56,14 +56,16 @@ class HTTPResolver : public Resolver
        {
        }
        
-       void OnLookupComplete(const string &result, unsigned int ttl, bool cached)
+       void OnLookupComplete(const string &result, unsigned int ttl, bool cached, int resultnum = 0)
        {
-               socket->Connect(result);
+               if (!resultnum)
+                       socket->Connect(result);
        }
        
        void OnError(ResolverError e, const string &errmsg)
        {
-               delete socket;
+               if (ServerInstance->SocketCull.find(socket) == ServerInstance->SocketCull.end())
+                       ServerInstance->SocketCull[socket] = socket;
        }
 };
 
@@ -75,7 +77,7 @@ class ModuleHTTPClient : public Module
        HTTPList sockets;
 
        ModuleHTTPClient(InspIRCd *Me)
-               : Module::Module(Me)
+               : Module(Me)
        {
        }
        
@@ -174,10 +176,10 @@ bool HTTPSocket::ParseURL(const std::string &iurl)
        
        for (int p = 0;; p++)
        {
-               std::string part = tokenizer.GetToken();
-               if (part.empty() && tokenizer.StreamEnd())
+               std::string part;
+               if (!tokenizer.GetToken(part))
                        break;
-               
+
                if ((p == 0) && (part[part.length() - 1] == ':'))
                {
                        // Protocol ('http:')
@@ -302,7 +304,7 @@ bool HTTPSocket::OnDataReady()
                        {
                                this->status = HTTP_DATA;
                                this->data += this->buffer;
-                               this->buffer = "";
+                               this->buffer.clear();
                                break;
                        }
 
@@ -343,24 +345,4 @@ void HTTPSocket::OnClose()
        delete response;
 }
 
-class ModuleHTTPClientFactory : public ModuleFactory
-{
- public:
-       ModuleHTTPClientFactory()
-       {
-       }
-       
-       ~ModuleHTTPClientFactory()
-       {
-       }
-       
-       Module *CreateModule(InspIRCd* Me)
-       {
-               return new ModuleHTTPClient(Me);
-       }
-};
-
-extern "C" void *init_module(void)
-{
-       return new ModuleHTTPClientFactory;
-}
+MODULE_INIT(ModuleHTTPClient)