]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/httpclient.h
YAY for LDAP oper blocks! :D
[user/henk/code/inspircd.git] / src / modules / httpclient.h
index c5e84261f770b30e54e5ff80cc0e743761113f29..e2067f8b386e3fc53f6dbb8ad68c1e231fbc4fd8 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
  * See: http://www.inspircd.org/wiki/index.php/Credits
  *
  * This program is free but copyrighted software; see
@@ -23,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
  */
@@ -34,8 +35,8 @@ class HTTPClientRequest : public Request
        Module *src;
        HeaderMap Headers;
  public:
-       HTTPClientRequest(InspIRCd *Instance, Module *src, Module* target, const std::string &url)
-               : Request(src, target, HTTP_CLIENT_REQUEST), url(url), Instance(Instance), src(src)
+       HTTPClientRequest(InspIRCd *SI, Module *m, Module* target, const std::string &surl)
+               : Request(m, target, HTTP_CLIENT_REQUEST), url(surl), Instance(SI), src(m)
        {
                Headers["User-Agent"] = "InspIRCd (m_http_client.so)";
                Headers["Connection"] = "Close";
@@ -51,9 +52,9 @@ class HTTPClientRequest : public Request
                return url;
        }
 
-       void AddHeader(std::string &header, std::string &data)
+       void AddHeader(std::string &header, std::string &sdata)
        {
-               Headers[header] = data;
+               Headers[header] = sdata;
        }
        
        void DeleteHeader(std::string &header)
@@ -67,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 &surl, int iresponse)
+               : Request(src, target, HTTP_CLIENT_ERROR), url(surl), response(iresponse)
+       {
+       }
+
+       const std::string &GetURL()
+       {
+               return url;
+       }
+};
+
 class HTTPClientResponse : public Request
 {
  protected:
@@ -78,8 +99,8 @@ class HTTPClientResponse : public Request
        std::string responsestr;
        HeaderMap Headers;
  public:
-       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(Module* src, Module* target, std::string &surl, int iresponse, std::string sresponsestr)
+               : Request(src, target, HTTP_CLIENT_RESPONSE), url(surl), response(iresponse), responsestr(sresponsestr)
        {
        }
 
@@ -92,9 +113,9 @@ class HTTPClientResponse : public Request
                data = ndata;
        }
        
-       void AddHeader(const std::string &header, const std::string &data)
+       void AddHeader(const std::string &header, const std::string &sdata)
        {
-               Headers[header] = data;
+               Headers[header] = sdata;
        }
        
        const std::string &GetURL()
@@ -112,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)
        {