summaryrefslogtreecommitdiffabout
path: root/include/kingate/headers.h
authorMichael Krelin <hacker@klever.net>2005-05-09 11:00:28 (UTC)
committer Michael Krelin <hacker@klever.net>2005-05-09 11:00:28 (UTC)
commit43d47575878e4eaf3c8da84bf609fcd0bde595fb (patch) (side-by-side diff)
treef7ec4d1f0d0a01b43feb5c9b4f414e870036522c /include/kingate/headers.h
parentd9578a5ae0ac4e44ff5e3c13d3f39f400f51bcf2 (diff)
downloadkingate-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
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 */