From 43d47575878e4eaf3c8da84bf609fcd0bde595fb Mon Sep 17 00:00:00 2001 From: Michael Krelin Date: Mon, 09 May 2005 11:00:28 +0000 Subject: 1. http headers container added 2. preliminary cookies support 3. absolutely useless http_quoted_string and http_quote utility functions added --- (limited to 'include/kingate/headers.h') 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 +#include +#include + +/** + * @file + * @brief the headers -- HTTP headers container class. + */ + +namespace kingate { + using namespace std; + + /** + * The container class for HTTP headers. + */ + class headers : public multimap { + 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 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 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 */ -- cgit v0.9.0.2