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;
}
};
HTTPList sockets;
ModuleHTTPClient(InspIRCd *Me)
- : Module::Module(Me)
+ : Module(Me)
{
}
*/
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);
{
this->status = HTTP_DATA;
this->data += this->buffer;
- this->buffer = "";
+ this->buffer.clear();
break;
}
-// while ((line = buffer.sstrstr(data, "\r\n")) != NULL)
-// {
-// if (strncmp(data, "\r\n", 2) == 0)
-
+
if (this->status == HTTP_REQSENT)
{
// HTTP reply (HTTP/1.1 200 msg)
if ((pos = line.find(':')) != std::string::npos)
{
-
-// char *hdata = strchr(data, ':');
-
-// if (!hdata)
-// continue;
-
-// *hdata = '\0';
-
-// response->AddHeader(data, hdata + 2);
response->AddHeader(line.substr(0, pos), line.substr(pos + 1));
-
-// data = lend + 2;
- } else
+ }
+ else
+ {
continue;
+ }
}
- } else {
+ }
+ else
+ {
this->data += data;
}
return true;
}
};
-extern "C" void *init_module(void)
+extern "C" DllExport void *init_module(void)
{
return new ModuleHTTPClientFactory;
}