9 typedef std::map<std::string,std::string> HeaderMap;
11 const char* HTTP_CLIENT_RESPONSE = "HTTPCLIENT_RESPONSE";
12 const char* HTTP_CLIENT_REQUEST = "HTTPCLIENT_REQUEST";
14 /** This class represents an outgoing HTTP request
16 class HTTPClientRequest : public Request
24 HTTPClientRequest(InspIRCd *Instance, Module *src, Module* target, const std::string &url)
25 : Request(src, target, HTTP_CLIENT_REQUEST), url(url), Instance(Instance), src(src)
27 Headers["User-Agent"] = "InspIRCd (m_http_client.so)";
28 Headers["Connection"] = "Close";
29 Headers["Accept"] = "*/*";
32 HTTPClientRequest() : Request(NULL, NULL, HTTP_CLIENT_REQUEST)
36 const std::string &GetURL()
41 void AddHeader(std::string &header, std::string &data)
43 Headers[header] = data;
46 void DeleteHeader(std::string &header)
48 Headers.erase(header);
51 HeaderMap GetHeaders()
57 class HTTPClientResponse : public Request
60 friend class HTTPSocket;
65 std::string responsestr;
68 HTTPClientResponse(Module* src, Module* target, std::string &url, int response, std::string responsestr)
69 : Request(src, target, HTTP_CLIENT_RESPONSE), url(url), response(response), responsestr(responsestr)
73 HTTPClientResponse() : Request(NULL, NULL, HTTP_CLIENT_RESPONSE)
77 void SetData(const std::string &ndata)
82 void AddHeader(const std::string &header, const std::string &data)
84 Headers[header] = data;
87 const std::string &GetURL()
92 const std::string &GetData()
97 int GetResponse(std::string &str)
103 std::string GetHeader(const std::string &header)
105 HeaderMap::iterator i = Headers.find(header);
107 if (i != Headers.end())