]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_http_client.cpp
Fixified some more
[user/henk/code/inspircd.git] / src / modules / m_http_client.cpp
index 35b93b5818c480359e55e47133661ab567727b5d..3f424b5955686605783d72eea357aeec6e768ae7 100644 (file)
@@ -24,7 +24,7 @@ class URL
        int port;
 };
 
-class HTTPSocket : public InspSocket
+class HTTPSocket : public BufferedSocket
 {
  private:
        InspIRCd *Server;
@@ -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;
        }
 };
 
@@ -109,7 +111,7 @@ class ModuleHTTPClient : public Module
 };
 
 HTTPSocket::HTTPSocket(InspIRCd *Instance, ModuleHTTPClient *Mod)
-               : InspSocket(Instance), Server(Instance), Mod(Mod), status(HTTP_CLOSED)
+               : BufferedSocket(Instance), Server(Instance), Mod(Mod), status(HTTP_CLOSED)
 {
        this->ClosePending = false;
        this->port = 80;
@@ -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:')