summaryrefslogtreecommitdiffabout
path: root/src/headers.cc
Side-by-side diff
Diffstat (limited to 'src/headers.cc') (more/less context) (show whitespace changes)
-rw-r--r--src/headers.cc40
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 @@
+#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();
+ }
+}