]> git.tdb.fi Git - libs/net.git/blob - source/http/header.h
Add a dynamic receiver class for more flexible packet handling
[libs/net.git] / source / http / header.h
1 #ifndef MSP_HTTP_HEADER_H_
2 #define MSP_HTTP_HEADER_H_
3
4 #include <map>
5 #include <string>
6 #include <vector>
7 #include <msp/net/mspnet_api.h>
8
9 namespace Msp {
10 namespace Http {
11
12 class Message;
13
14 struct MSPNET_API Header
15 {
16         enum Style
17         {
18                 DEFAULT,
19                 SINGLE_VALUE,
20                 LIST,
21                 KEY_VALUE_LIST,
22                 VALUE_WITH_ATTRIBUTES,
23                 LIST_WITH_ATTRIBUTES
24         };
25
26         struct Value
27         {
28                 std::string value;
29                 std::map<std::string, std::string> parameters;
30         };
31
32         std::string name;
33         Style style;
34         std::string raw_value;
35         std::vector<Value> values;
36
37         Header() = default;
38         Header(const Message &, const std::string &, Style = DEFAULT);
39         Header(const std::string &, const std::string &, Style = DEFAULT);
40
41         static Style get_default_style(const std::string &);
42
43         void parse();
44 };
45
46 } // namespace Http
47 } // namespace Msp
48
49 #endif