author | Michael Krelin <hacker@klever.net> | 2005-05-09 11:00:28 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2005-05-09 11:00:28 (UTC) |
commit | 43d47575878e4eaf3c8da84bf609fcd0bde595fb (patch) (unidiff) | |
tree | f7ec4d1f0d0a01b43feb5c9b4f414e870036522c /src/headers.cc | |
parent | d9578a5ae0ac4e44ff5e3c13d3f39f400f51bcf2 (diff) | |
download | kingate-43d47575878e4eaf3c8da84bf609fcd0bde595fb.zip kingate-43d47575878e4eaf3c8da84bf609fcd0bde595fb.tar.gz kingate-43d47575878e4eaf3c8da84bf609fcd0bde595fb.tar.bz2 |
1. http headers container added
2. preliminary cookies support
3. absolutely useless http_quoted_string and http_quote utility functions added
-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 | } | ||