summaryrefslogtreecommitdiffabout
path: root/include/kingate/headers.h
Side-by-side diff
Diffstat (limited to 'include/kingate/headers.h') (more/less context) (show whitespace changes)
-rw-r--r--include/kingate/headers.h94
1 files changed, 94 insertions, 0 deletions
diff --git a/include/kingate/headers.h b/include/kingate/headers.h
new file mode 100644
index 0000000..fb37fec
--- a/dev/null
+++ b/include/kingate/headers.h
@@ -0,0 +1,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 */