-rw-r--r-- | src/headers.cc | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/headers.cc b/src/headers.cc new file mode 100644 index 0000000..89ac519 --- a/dev/null +++ b/src/headers.cc | |||
@@ -0,0 +1,40 @@ | |||
1 | #include "kingate/headers.h" | ||
2 | #include "kingate/exception.h" | ||
3 | |||
4 | namespace kingate { | ||
5 | |||
6 | void headers::set_header(const key_type& h,const mapped_type& c) { | ||
7 | erase(h); | ||
8 | insert(value_type(h,c)); | ||
9 | } | ||
10 | void headers::add_header(const key_type& h,const mapped_type& c) { | ||
11 | insert(value_type(h,c)); | ||
12 | } | ||
13 | void headers::unset_header(const key_type& h) { | ||
14 | erase(h); | ||
15 | } | ||
16 | const headers::mapped_type& headers::get_header(const key_type& h) const { | ||
17 | const_iterator i=find(h); | ||
18 | if(i==end()) | ||
19 | throw exception_notfound(CODEPOINT,"No such header"); | ||
20 | return i->second; | ||
21 | } | ||
22 | headers::mapped_type& headers::get_header(const key_type& h) { | ||
23 | // XXX: or should it fail if there's no such thing, unlike operator[]? | ||
24 | iterator i=find(h); | ||
25 | if(i==end()) | ||
26 | i = insert(value_type(h,"")); | ||
27 | return i->second; | ||
28 | } | ||
29 | |||
30 | pair<headers::const_iterator,headers::const_iterator> headers::get_headers(const key_type& h) const { | ||
31 | return equal_range(h); | ||
32 | } | ||
33 | pair<headers::iterator,headers::iterator> headers::get_headers(const key_type& h) { | ||
34 | return equal_range(h); | ||
35 | } | ||
36 | |||
37 | bool headers::has_header(const key_type& h) const { | ||
38 | return find(h)!=end(); | ||
39 | } | ||
40 | } | ||