summaryrefslogtreecommitdiffabout
path: root/include/kingate/headers.h
Unidiff
Diffstat (limited to 'include/kingate/headers.h') (more/less context) (ignore whitespace changes)
-rw-r--r--include/kingate/headers.h94
1 files changed, 94 insertions, 0 deletions
diff --git a/include/kingate/headers.h b/include/kingate/headers.h
new file mode 100644
index 0000000..fb37fec
--- a/dev/null
+++ b/include/kingate/headers.h
@@ -0,0 +1,94 @@
1#ifndef __KINGATE_HEADERS_H
2#define __KINGATE_HEADERS_H
3
4#include <string>
5#include <map>
6#include <ostream>
7
8/**
9 * @file
10 * @brief the headers -- HTTP headers container class.
11 */
12
13namespace kingate {
14 using namespace std;
15
16 /**
17 * The container class for HTTP headers.
18 */
19 class headers : public multimap<string,string> {
20 public:
21
22 /**
23 * Reference header if one exists.
24 * @param k the header.
25 * @return reference to the content.
26 */
27 const mapped_type& operator[](const key_type& k) const {
28 return get_header(k);
29 }
30 /**
31 * Reference header, creating one if needed.
32 * @param k the header.
33 * @return reference to the content.
34 */
35 mapped_type& operator[](const key_type& k) {
36 return get_header(k);
37 }
38
39 /**
40 * Set HTTP header. Remove all existent occurences of headers with
41 * this name.
42 * @param h header name.
43 * @param c header content.
44 */
45 void set_header(const key_type& h,const mapped_type& c);
46 /**
47 * Add HTTP header.
48 * @param h header name.
49 * @param c header content.
50 */
51 void add_header(const key_type& h,const mapped_type& c);
52 /**
53 * Remove named header.
54 * @param h header name.
55 */
56 void unset_header(const key_type& h);
57 /**
58 * Return const reference to the existing header.
59 * @param h header name.
60 * @return reference to header content.
61 */
62 const mapped_type& get_header(const key_type& h) const;
63 /**
64 * Return reference to the header, creating one if needed.
65 * @param h header name.
66 * @return reference to the content.
67 */
68 mapped_type& get_header(const key_type& h);
69 /**
70 * Return the range of headers with a certain name.
71 * @param h header name.
72 * @return pair of const iterators with the beginning and the end
73 * of range.
74 */
75 pair<const_iterator,const_iterator> get_headers(const key_type& h) const;
76 /**
77 * Return the range of headers with a certain name.
78 * @param h header name.
79 * @return pair of iterators with the beginning and the end
80 * of range.
81 */
82 pair<iterator,iterator> get_headers(const key_type& h);
83 /**
84 * Inquire whether the named header exists.
85 * @param h header name.
86 * @return true if exists.
87 */
88 bool has_header(const key_type& h) const;
89
90 };
91
92}
93
94#endif /* __KINGATE_HEADERS_H */