summaryrefslogtreecommitdiff
path: root/src/modules/httpclient.h
diff options
context:
space:
mode:
authorpeavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7>2007-07-16 17:14:45 +0000
committerpeavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7>2007-07-16 17:14:45 +0000
commitbab14f0dd2345c9d7dcbc47c918563709e1ac094 (patch)
tree753a23cfc9fc08c6697e80b3e686f074aa911d85 /src/modules/httpclient.h
parent3abff3a37550cc1d88dd4d1fd7ed526e89309a53 (diff)
'svn propset -R svn:eol-style CR *' Set to UNIX-style always. Binaries are auto skipped by svn.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7454 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/httpclient.h')
-rw-r--r--src/modules/httpclient.h128
1 files changed, 1 insertions, 127 deletions
diff --git a/src/modules/httpclient.h b/src/modules/httpclient.h
index c5e84261f..109bfa666 100644
--- a/src/modules/httpclient.h
+++ b/src/modules/httpclient.h
@@ -1,127 +1 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2007 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__
-#define HTTPCLIENT_H__
-
-#include <string>
-#include <map>
-
-typedef std::map<std::string,std::string> HeaderMap;
-
-const char* HTTP_CLIENT_RESPONSE = "HTTPCLIENT_RESPONSE";
-const char* HTTP_CLIENT_REQUEST = "HTTPCLIENT_REQUEST";
-
-/** This class represents an outgoing HTTP request
- */
-class HTTPClientRequest : public Request
-{
- protected:
- std::string url;
- InspIRCd *Instance;
- 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)
- {
- Headers["User-Agent"] = "InspIRCd (m_http_client.so)";
- Headers["Connection"] = "Close";
- Headers["Accept"] = "*/*";
- }
-
- HTTPClientRequest() : Request(NULL, NULL, HTTP_CLIENT_REQUEST)
- {
- }
-
- const std::string &GetURL()
- {
- return url;
- }
-
- void AddHeader(std::string &header, std::string &data)
- {
- Headers[header] = data;
- }
-
- void DeleteHeader(std::string &header)
- {
- Headers.erase(header);
- }
-
- HeaderMap GetHeaders()
- {
- return Headers;
- }
-};
-
-class HTTPClientResponse : public Request
-{
- protected:
- friend class HTTPSocket;
-
- std::string url;
- std::string data;
- int response;
- 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() : Request(NULL, NULL, HTTP_CLIENT_RESPONSE)
- {
- }
-
- void SetData(const std::string &ndata)
- {
- data = ndata;
- }
-
- void AddHeader(const std::string &header, const std::string &data)
- {
- Headers[header] = data;
- }
-
- const std::string &GetURL()
- {
- return url;
- }
-
- const std::string &GetData()
- {
- return data;
- }
-
- int GetResponse(std::string &str)
- {
- str = responsestr;
- return response;
- }
-
- std::string GetHeader(const std::string &header)
- {
- HeaderMap::iterator i = Headers.find(header);
-
- if (i != Headers.end())
- return i->second;
- else
- return "";
- }
-};
-
-#endif
+/* +------------------------------------+ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * * InspIRCd: (C) 2002-2007 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__ #define HTTPCLIENT_H__ #include <string> #include <map> typedef std::map<std::string,std::string> HeaderMap; const char* HTTP_CLIENT_RESPONSE = "HTTPCLIENT_RESPONSE"; const char* HTTP_CLIENT_REQUEST = "HTTPCLIENT_REQUEST"; /** This class represents an outgoing HTTP request */ class HTTPClientRequest : public Request { protected: std::string url; InspIRCd *Instance; 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) { Headers["User-Agent"] = "InspIRCd (m_http_client.so)"; Headers["Connection"] = "Close"; Headers["Accept"] = "*/*"; } HTTPClientRequest() : Request(NULL, NULL, HTTP_CLIENT_REQUEST) { } const std::string &GetURL() { return url; } void AddHeader(std::string &header, std::string &data) { Headers[header] = data; } void DeleteHeader(std::string &header) { Headers.erase(header); } HeaderMap GetHeaders() { return Headers; } }; class HTTPClientResponse : public Request { protected: friend class HTTPSocket; std::string url; std::string data; int response; 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() : Request(NULL, NULL, HTTP_CLIENT_RESPONSE) { } void SetData(const std::string &ndata) { data = ndata; } void AddHeader(const std::string &header, const std::string &data) { Headers[header] = data; } const std::string &GetURL() { return url; } const std::string &GetData() { return data; } int GetResponse(std::string &str) { str = responsestr; return response; } std::string GetHeader(const std::string &header) { HeaderMap::iterator i = Headers.find(header); if (i != Headers.end()) return i->second; else return ""; } }; #endif \ No newline at end of file