summaryrefslogtreecommitdiff
path: root/src/modules/m_http_client.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-01-20 21:12:47 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-01-20 21:12:47 +0000
commitbcdacaac9b1c345acb0b93039c34d3ab29a278a4 (patch)
treea364c052ed8e6c5ebd1f5402d90b0106182c6a72 /src/modules/m_http_client.cpp
parent66cea632d47aa1ef55a299b3ad5b4db47f556be7 (diff)
Fixing
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6407 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_http_client.cpp')
-rw-r--r--src/modules/m_http_client.cpp17
1 files changed, 15 insertions, 2 deletions
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)