X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fhttpclient.h;h=475ee1540786db0d0490fa6f633086abcd6ad561;hb=f51d9ad5ab7015f78a29039ca7ed169b281ff6bb;hp=181c58b6be8c61689670c00ffc2d3989e656e87f;hpb=34f4ee851c1822696612dadd4a46194f9ed28987;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/httpclient.h b/src/modules/httpclient.h index 181c58b6b..475ee1540 100644 --- a/src/modules/httpclient.h +++ b/src/modules/httpclient.h @@ -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 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) {