]> git.tdb.fi Git - libs/net.git/blobdiff - source/http/message.h
Prepare for assimilation into mspnet
[libs/net.git] / source / http / message.h
diff --git a/source/http/message.h b/source/http/message.h
new file mode 100644 (file)
index 0000000..4d23102
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef MSP_HTTP_MESSAGE_H_
+#define MSP_HTTP_MESSAGE_H_
+
+#include <map>
+#include <string>
+#include <msp/core/variant.h>
+#include "version.h"
+
+namespace Msp {
+namespace Http {
+
+class Message
+{
+protected:
+       typedef std::map<std::string, std::string> HeaderMap;
+
+       Version http_version;
+       HeaderMap headers;
+       std::string content;
+       unsigned chunk_length;
+       bool complete;
+       Variant user_data;
+
+       Message();
+public:
+       virtual ~Message() { }
+
+       void set_header(const std::string &, const std::string &);
+       bool has_header(const std::string &) const;
+       const std::string &get_header(const std::string &) const;
+       void add_content(const std::string &);
+       const std::string &get_content() const { return content; }
+       void set_user_data(const Variant &);
+       const Variant &get_user_data() const { return user_data; }
+       bool is_complete() const { return complete; }
+       unsigned parse_content(const std::string &);
+       virtual std::string str() const = 0;
+protected:
+       unsigned parse_headers(const std::string &);
+       std::string str_common() const;
+       std::string normalize_header_name(const std::string &) const;
+};
+
+} // namespace Http
+} // namespace Msp
+
+#endif