]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Fixing
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sat, 20 Jan 2007 21:12:47 +0000 (21:12 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sat, 20 Jan 2007 21:12:47 +0000 (21:12 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6407 e03df62e-2008-0410-955e-edbf42e46eb7

src/modules/extra/m_httpclienttest.cpp
src/modules/m_http_client.cpp

index 800cd63f53a17a4691fad864587abdda57c1e786..0a43c4c0afac578097476199e9fe5e36db72e249 100644 (file)
@@ -20,7 +20,7 @@ public:
 
        virtual void Implements(char* List)
        {
-                  List[I_OnUserJoin] = List[I_OnUserPart] = 1;
+               List[I_OnRequest] = List[I_OnUserJoin] = List[I_OnUserPart] = 1;
        }
 
        virtual Version GetVersion()
@@ -36,7 +36,7 @@ public:
                std::string nick = user->nick;
 //               ServerInstance->Log(DEBUG,"User " + nick + " joined " + chan);
 
-                          Module* target = ServerInstance->FindModule("m_http_client");
+                          Module* target = ServerInstance->FindModule("m_http_client.so");
                           if(target) {
                                   HTTPClientRequest req(ServerInstance, this, target, "http://znc.in/~psychon");
                                   req.Send();
index 0034aa246091368925a8042de3b54f0c3da397d5..7e929a8c5440da4536a258bf0b20c4ec04e40dec 100644 (file)
@@ -59,15 +59,18 @@ class HTTPResolver : public Resolver
  public:
        HTTPResolver(HTTPSocket *socket, InspIRCd *Instance, const string &hostname, bool &cached, Module* me) : Resolver(Instance, hostname, DNS_QUERY_FORWARD, cached, me), socket(socket)
        {
+               ServerInstance->Log(DEBUG,"Resolving "+hostname);
        }
        
        void OnLookupComplete(const string &result, unsigned int ttl, bool cached)
        {
+               ServerInstance->Log(DEBUG,"Resolver done");
                socket->Connect(result);
        }
        
        void OnError(ResolverError e, const string &errmsg)
        {
+               ServerInstance->Log(DEBUG,"Resolver error");
                delete socket;
        }
 };
@@ -142,13 +145,18 @@ bool HTTPSocket::DoRequest(HTTPClientRequest *req)
         */
        this->req = *req;
 
+       Instance->Log(DEBUG,"Request in progress");
+
        if (!ParseURL(this->req.GetURL()))
+       {
+               Instance->Log(DEBUG,"Parse failed");
                return false;
+       }
        
        this->port = url.port;
        strlcpy(this->host, url.domain.c_str(), MAXBUF);
 
-       if (!insp_aton(this->host, &this->addy))
+       if (insp_aton(this->host, &this->addy) < 1)
        {
                bool cached;
                HTTPResolver* r = new HTTPResolver(this, Server, url.domain, cached, (Module*)Mod);
@@ -167,17 +175,21 @@ bool HTTPSocket::ParseURL(const std::string &iurl)
 {
        url.url = iurl;
        url.port = 80;
+
+       Instance->Log(DEBUG,"Parse: "+iurl);
        
        // Tokenize by slashes (protocol:, blank, domain, request..)
        int pos = 0, pstart = 0, pend = 0;
        
-       for (; ; pend = url.url.find('/', pstart))
+       for (;;)
        {
+               pend = url.url.find('/', pstart);
                string part = url.url.substr(pstart, pend);
 
                switch (pos)
                {
                        case 0:
+                               Instance->Log(DEBUG,"PART 0: "+part);
                                // Protocol
                                if (part[part.length()-1] != ':')
                                        return false;
@@ -187,6 +199,7 @@ bool HTTPSocket::ParseURL(const std::string &iurl)
                                // Empty, skip
                                break;
                        case 2:
+                               Instance->Log(DEBUG,"PART 2: "+part);
                                // User and password (user:pass@)
                                string::size_type aend = part.find('@', 0);
                                if (aend != string::npos)