]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/httpclient.h
Fix m_chanlog crashing.
[user/henk/code/inspircd.git] / src / modules / httpclient.h
index 181c58b6be8c61689670c00ffc2d3989e656e87f..475ee1540786db0d0490fa6f633086abcd6ad561 100644 (file)
@@ -1,3 +1,16 @@
+/*       +------------------------------------+
+ *       | Inspire Internet Relay Chat Daemon |
+ *       +------------------------------------+
+ *
+ *  InspIRCd: (C) 2002-2008 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__
@@ -10,6 +23,7 @@ typedef std::map<std::string,std::string> HeaderMap;
 
 const char* HTTP_CLIENT_RESPONSE = "HTTPCLIENT_RESPONSE";
 const char* HTTP_CLIENT_REQUEST = "HTTPCLIENT_REQUEST";
+const char* HTTP_CLIENT_ERROR = "HTTPCLIENT_ERROR";
 
 /** This class represents an outgoing HTTP request
  */
@@ -29,6 +43,10 @@ class HTTPClientRequest : public Request
                Headers["Accept"] = "*/*";
        }
 
+       HTTPClientRequest() : Request(NULL, NULL, HTTP_CLIENT_REQUEST)
+       {
+       }
+
        const std::string &GetURL()
        {
                return url;
@@ -50,6 +68,26 @@ class HTTPClientRequest : public Request
        }
 };
 
+class HTTPClientError : public Request
+{
+ protected:
+       friend class HTTPSocket;
+       std::string url;
+       int response;
+       std::string responsestr;
+       HeaderMap Headers;
+ public:
+       HTTPClientError(Module* src, Module* target, const std::string &url, int response)
+               : Request(src, target, HTTP_CLIENT_ERROR), url(url), response(response)
+       {
+       }
+
+       const std::string &GetURL()
+       {
+               return url;
+       }
+};
+
 class HTTPClientResponse : public Request
 {
  protected:
@@ -65,7 +103,11 @@ class HTTPClientResponse : public Request
                : 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;
@@ -91,6 +133,12 @@ class HTTPClientResponse : public Request
                str = responsestr;
                return response;
        }
+
+       void SetResponse(const std::string &str)
+       {
+               responsestr = str;
+               response = atoi(responsestr.c_str());
+       }
        
        std::string GetHeader(const std::string &header)
        {