blob: 89ac519f29b4372b1913023a5055396f315cd678 (
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
|
#include "kingate/headers.h"
#include "kingate/exception.h"
namespace kingate {
void headers::set_header(const key_type& h,const mapped_type& c) {
erase(h);
insert(value_type(h,c));
}
void headers::add_header(const key_type& h,const mapped_type& c) {
insert(value_type(h,c));
}
void headers::unset_header(const key_type& h) {
erase(h);
}
const headers::mapped_type& headers::get_header(const key_type& h) const {
const_iterator i=find(h);
if(i==end())
throw exception_notfound(CODEPOINT,"No such header");
return i->second;
}
headers::mapped_type& headers::get_header(const key_type& h) {
// XXX: or should it fail if there's no such thing, unlike operator[]?
iterator i=find(h);
if(i==end())
i = insert(value_type(h,""));
return i->second;
}
pair<headers::const_iterator,headers::const_iterator> headers::get_headers(const key_type& h) const {
return equal_range(h);
}
pair<headers::iterator,headers::iterator> headers::get_headers(const key_type& h) {
return equal_range(h);
}
bool headers::has_header(const key_type& h) const {
return find(h)!=end();
}
}
|