From bcdacaac9b1c345acb0b93039c34d3ab29a278a4 Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 20 Jan 2007 21:12:47 +0000 Subject: Fixing git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6407 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/extra/m_httpclienttest.cpp | 4 ++-- src/modules/m_http_client.cpp | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/modules/extra/m_httpclienttest.cpp b/src/modules/extra/m_httpclienttest.cpp index 800cd63f5..0a43c4c0a 100644 --- a/src/modules/extra/m_httpclienttest.cpp +++ b/src/modules/extra/m_httpclienttest.cpp @@ -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(); diff --git a/src/modules/m_http_client.cpp b/src/modules/m_http_client.cpp index 0034aa246..7e929a8c5 100644 --- a/src/modules/m_http_client.cpp +++ b/src/modules/m_http_client.cpp @@ -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) -- cgit v1.2.3