]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/httpclient.h
Convert more modules
[user/henk/code/inspircd.git] / src / modules / httpclient.h
index 8e1a314dd0af4342e9ab38326c4215f778ac25dc..c5e84261f770b30e54e5ff80cc0e743761113f29 100644 (file)
@@ -1,3 +1,16 @@
+/*       +------------------------------------+
+ *       | Inspire Internet Relay Chat Daemon |
+ *       +------------------------------------+
+ *
+ *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
+ *
+ * This program is free but copyrighted software; see
+ *            the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
 #include "base.h"
 
 #ifndef HTTPCLIENT_H__
@@ -8,9 +21,12 @@
 
 typedef std::map<std::string,std::string> HeaderMap;
 
+const char* HTTP_CLIENT_RESPONSE = "HTTPCLIENT_RESPONSE";
+const char* HTTP_CLIENT_REQUEST = "HTTPCLIENT_REQUEST";
+
 /** This class represents an outgoing HTTP request
  */
-class HTTPClientRequest : public classbase
+class HTTPClientRequest : public Request
 {
  protected:
        std::string url;
@@ -18,22 +34,21 @@ class HTTPClientRequest : public classbase
        Module *src;
        HeaderMap Headers;
  public:
-       HTTPClientRequest(InspIRCd *Instance, Module *src, const std::string &url)
-               : url(url), Instance(Instance), src(src)
+       HTTPClientRequest(InspIRCd *Instance, Module *src, Module* target, const std::string &url)
+               : Request(src, target, HTTP_CLIENT_REQUEST), url(url), Instance(Instance), src(src)
        {
                Headers["User-Agent"] = "InspIRCd (m_http_client.so)";
                Headers["Connection"] = "Close";
                Headers["Accept"] = "*/*";
        }
 
-       const std::string &GetURL()
+       HTTPClientRequest() : Request(NULL, NULL, HTTP_CLIENT_REQUEST)
        {
-               return url;
        }
-       
-       Module *GetSrc()
+
+       const std::string &GetURL()
        {
-               return src;
+               return url;
        }
 
        void AddHeader(std::string &header, std::string &data)
@@ -50,22 +65,9 @@ class HTTPClientRequest : public classbase
        {
                return Headers;
        }
-       
-       void SendRequest()
-       {
-               Module *HTTPModule = Instance->FindModule("m_http_client.so");
-               if (!HTTPModule)
-               {
-                       Instance->Log(DEFAULT, "HTTP module not loaded!");
-                       return;
-               }
-               
-               Request req((char *)this, src, HTTPModule);
-               req.Send();
-       }
 };
 
-class HTTPClientResponse : public classbase
+class HTTPClientResponse : public Request
 {
  protected:
        friend class HTTPSocket;
@@ -76,11 +78,15 @@ class HTTPClientResponse : public classbase
        std::string responsestr;
        HeaderMap Headers;
  public:
-       HTTPClientResponse(std::string &url, int response, std::string responsestr)
-               : url(url), response(response), responsestr(responsestr)
+       HTTPClientResponse(Module* src, Module* target, std::string &url, int response, std::string responsestr)
+               : Request(src, target, HTTP_CLIENT_RESPONSE), url(url), response(response), responsestr(responsestr)
        {
        }
-       
+
+       HTTPClientResponse() : Request(NULL, NULL, HTTP_CLIENT_RESPONSE)
+       {
+       }
+
        void SetData(const std::string &ndata)
        {
                data = ndata;