]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/httpd.h
Stuff for adding extra headers to a response (for Authorization: and Location: etc)
[user/henk/code/inspircd.git] / src / modules / httpd.h
index 9be23f9f00709d99e8fda9cd1ec24aa0479c7087..ba059dca8e01ea2a8d2f25c1247a737df6167923 100644 (file)
@@ -3,21 +3,30 @@
 #ifndef __HTTPD_H__
 #define __HTTPD_H__
 
-HTTPRequest : public classbase
+#include <string>
+#include <sstream>
+
+class HTTPRequest : public classbase
 {
  protected:
 
        std::string type;
        std::string document;
        std::string ipaddr;
+       std::stringstream* headers;
 
  public:
 
-       void* opaque;
+       void* sock;
+
+       HTTPRequest(const std::string &request_type, const std::string &uri, std::stringstream* hdr, void* opaque, const std::string &ip)
+               : type(request_type), document(uri), ipaddr(ip), headers(hdr), sock(opaque)
+       {
+       }
 
-       HTTPRequest(const std::string &request_type, const std::string &uri, void* opaque, const std::string &ip)
-               : type(request_type), document(uri), ipaddr(ip)
+       std::stringstream* GetHeaders()
        {
+               return headers;
        }
 
        std::string& GetType()
@@ -34,7 +43,43 @@ HTTPRequest : public classbase
        {
                return ipaddr;
        }
-}
+};
+
+class HTTPDocument : public classbase
+{
+ protected:
+       std::stringstream* document;
+       int responsecode;
+       std::string extraheaders;
+
+ public:
+
+       void* sock;
+
+       HTTPDocument(void* opaque, std::stringstream* doc, int response, const std::string &extra) : document(doc), responsecode(response), extraheaders(extra), sock(opaque)
+       {
+       }
+
+       std::stringstream* GetDocument()
+       {
+               return this->document;
+       }
+
+       unsigned long GetDocumentSize()
+       {
+               return this->document->str().length();
+       }
+
+       int GetResponseCode()
+       {
+               return this->responsecode;
+       }
+
+       std::string& GetExtraHeaders()
+       {
+               return this->extraheaders;
+       }
+};
 
 #endif