1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 #ifndef HTTPCLIENT_H__
17 #define HTTPCLIENT_H__
22 typedef std::map<std::string,std::string> HeaderMap;
24 const char* HTTP_CLIENT_RESPONSE = "HTTPCLIENT_RESPONSE";
25 const char* HTTP_CLIENT_REQUEST = "HTTPCLIENT_REQUEST";
27 /** This class represents an outgoing HTTP request
29 class HTTPClientRequest : public Request
37 HTTPClientRequest(InspIRCd *Instance, Module *src, Module* target, const std::string &url)
38 : Request(src, target, HTTP_CLIENT_REQUEST), url(url), Instance(Instance), src(src)
40 Headers["User-Agent"] = "InspIRCd (m_http_client.so)";
41 Headers["Connection"] = "Close";
42 Headers["Accept"] = "*/*";
45 HTTPClientRequest() : Request(NULL, NULL, HTTP_CLIENT_REQUEST)
49 const std::string &GetURL()
54 void AddHeader(std::string &header, std::string &data)
56 Headers[header] = data;
59 void DeleteHeader(std::string &header)
61 Headers.erase(header);
64 HeaderMap GetHeaders()
70 class HTTPClientResponse : public Request
73 friend class HTTPSocket;
78 std::string responsestr;
81 HTTPClientResponse(Module* src, Module* target, std::string &url, int response, std::string responsestr)
82 : Request(src, target, HTTP_CLIENT_RESPONSE), url(url), response(response), responsestr(responsestr)
86 HTTPClientResponse() : Request(NULL, NULL, HTTP_CLIENT_RESPONSE)
90 void SetData(const std::string &ndata)
95 void AddHeader(const std::string &header, const std::string &data)
97 Headers[header] = data;
100 const std::string &GetURL()
105 const std::string &GetData()
110 int GetResponse(std::string &str)
116 std::string GetHeader(const std::string &header)
118 HeaderMap::iterator i = Headers.find(header);
120 if (i != Headers.end())