]> git.tdb.fi Git - libs/net.git/blob - source/message.h
Style update: spaces around assignments
[libs/net.git] / source / message.h
1 /* $Id$
2
3 This file is part of libmsphttp
4 Copyright © 2008  Mikkosoft Productions, Mikko Rasa
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_HTTP_MESSAGE_H_
9 #define MSP_HTTP_MESSAGE_H_
10
11 #include <map>
12 #include <string>
13 #include <msp/core/variant.h>
14 #include "version.h"
15
16 namespace Msp {
17 namespace Http {
18
19 class Message
20 {
21 protected:
22         typedef std::map<std::string, std::string> HeaderMap;
23
24         Version http_version;
25         HeaderMap headers;
26         std::string content;
27         unsigned chunk_length;
28         bool complete;
29         Variant user_data;
30
31         Message();
32 public:
33         virtual ~Message() { }
34
35         void set_header(const std::string &, const std::string &);
36         bool has_header(const std::string &) const;
37         const std::string &get_header(const std::string &) const;
38         void add_content(const std::string &);
39         const std::string &get_content() const { return content; }
40         void set_user_data(const Variant &);
41         const Variant &get_user_data() const { return user_data; }
42         bool is_complete() const { return complete; }
43         unsigned parse_content(const std::string &);
44         virtual std::string str() const = 0;
45 protected:
46         unsigned parse_headers(const std::string &);
47         std::string str_common() const;
48         std::string normalize_header_name(const std::string &) const;
49 };
50
51 } // namespace Http
52 } // namespace Msp
53
54 #endif