]> git.tdb.fi Git - libs/net.git/blob - source/message.h
Use maputils.h
[libs/net.git] / source / message.h
1 #ifndef MSP_HTTP_MESSAGE_H_
2 #define MSP_HTTP_MESSAGE_H_
3
4 #include <map>
5 #include <string>
6 #include <msp/core/variant.h>
7 #include "version.h"
8
9 namespace Msp {
10 namespace Http {
11
12 class Message
13 {
14 protected:
15         typedef std::map<std::string, std::string> HeaderMap;
16
17         Version http_version;
18         HeaderMap headers;
19         std::string content;
20         unsigned chunk_length;
21         bool complete;
22         Variant user_data;
23
24         Message();
25 public:
26         virtual ~Message() { }
27
28         void set_header(const std::string &, const std::string &);
29         bool has_header(const std::string &) const;
30         const std::string &get_header(const std::string &) const;
31         void add_content(const std::string &);
32         const std::string &get_content() const { return content; }
33         void set_user_data(const Variant &);
34         const Variant &get_user_data() const { return user_data; }
35         bool is_complete() const { return complete; }
36         unsigned parse_content(const std::string &);
37         virtual std::string str() const = 0;
38 protected:
39         unsigned parse_headers(const std::string &);
40         std::string str_common() const;
41         std::string normalize_header_name(const std::string &) const;
42 };
43
44 } // namespace Http
45 } // namespace Msp
46
47 #endif