aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/m_http_client.cpp
diff options
context:
space:
mode:
authorGravatar brain2007-11-11 20:52:21 +0000
committerGravatar brain2007-11-11 20:52:21 +0000
commit9b3f2821960aa5203d84cf7994090d069b0d1e51 (patch)
tree9ee60b515a2d47c517254416f2ae8f590eb54aee /src/modules/m_http_client.cpp
parentThis fixed. Initialise dns at the end of pass 1 before loading first set of m... (diff)
downloadinspircd++-9b3f2821960aa5203d84cf7994090d069b0d1e51.tar.gz
inspircd++-9b3f2821960aa5203d84cf7994090d069b0d1e51.tar.bz2
inspircd++-9b3f2821960aa5203d84cf7994090d069b0d1e51.zip
Fixed all that, back to the crash we had before (yay?)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8583 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_http_client.cpp')
-rw-r--r--src/modules/m_http_client.cpp29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/modules/m_http_client.cpp b/src/modules/m_http_client.cpp
index 6a72d4eee..0c7ec509a 100644
--- a/src/modules/m_http_client.cpp
+++ b/src/modules/m_http_client.cpp
@@ -70,8 +70,7 @@ class HTTPResolver : public Resolver
void OnError(ResolverError e, const string &errmsg)
{
ServerInstance->Log(DEBUG,"HTTPResolver::OnError");
- /*if (ServerInstance->SocketCull.find(socket) == ServerInstance->SocketCull.end())
- ServerInstance->SocketCull[socket] = socket;*/
+ socket->OnClose();
}
};
@@ -150,13 +149,17 @@ bool HTTPSocket::DoRequest(HTTPClientRequest *req)
this->port = url.port;
strlcpy(this->host, url.domain.c_str(), MAXBUF);
- /*
- bool cached;
- HTTPResolver* r = new HTTPResolver(this, Server, url.domain, cached, (Module*)Mod);
- Instance->AddResolver(r, cached);
- return true;
- */
- Connect(url.domain);
+ in6_addr s6;
+ in_addr s4;
+ /* Doesnt look like an ipv4 or an ipv6 address */
+ if ((inet_pton(AF_INET6, url.domain.c_str(), &s6) < 1) && (inet_pton(AF_INET, url.domain.c_str(), &s4) < 1))
+ {
+ bool cached;
+ HTTPResolver* r = new HTTPResolver(this, Server, url.domain, cached, (Module*)Mod);
+ Instance->AddResolver(r, cached);
+ }
+ else
+ Connect(url.domain);
return true;
}
@@ -334,8 +337,14 @@ void HTTPSocket::OnClose()
{
Instance->Log(DEBUG,"HTTPSocket::OnClose");
if (data.empty())
- return; // notification that request failed?
+ {
+ HTTPClientError* err = new HTTPClientError((Module*)Mod, req.GetSource(), req.GetURL(), 0);
+ err->Send();
+ delete err;
+ return;
+ }
+ Instance->Log(DEBUG,"Set data and send");
response->data = data;
response->Send();
delete response;