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