00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef restcgi_env_h
00023 #define restcgi_env_h
00024 #include "apidefs.h"
00025 #include <string>
00026 #include <map>
00027 #ifdef _WIN32
00028 #pragma warning (disable: 4251)
00029 #endif
00030 namespace restcgi {
00058 class RESTCGI_API env {
00059 public:
00060 typedef std::map<std::string, std::string> map_type;
00061
00062 env();
00064 env(const char **pcstr);
00066 env(const map_type& m);
00070 std::string server_software() const;
00073 std::string server_name() const;
00076 std::string gateway_interface() const;
00079 std::string server_protocol() const;
00081 std::string server_port() const;
00084 std::string request_method() const;
00092 std::string path_info() const;
00097 std::string path_translated() const;
00104 std::string script_name() const;
00108 std::string request_uri() const;
00111 std::string script_filename() const;
00116 std::string script_url() const;
00120 std::string script_uri() const;
00125 std::string query_string() const;
00128 std::string remote_host() const;
00130 std::string remote_addr() const;
00134 std::string auth_type() const;
00137 std::string remote_user() const;
00142 std::string remote_ident() const;
00144 std::string redirect_request() const;
00146 std::string redirect_url() const;
00149 std::string redirect_status() const;
00153 std::string content_type() const;
00156 std::string content_length() const;
00162 std::string accept() const;
00165 std::string accept_charset() const;
00168 std::string accept_encoding() const;
00172 std::string accept_language() const;
00176 std::string user_agent() const;
00179 bool hdr_find(const std::string& hname, std::string& value) const;
00181 bool find(const char* name, std::string& value) const;
00184 std::string find(const char* name) const;
00186 class RESTCGI_API hdr_iterator {
00187 public:
00188 typedef std::pair<std::string, std::string> referent_type;
00189 hdr_iterator& operator ++();
00190 hdr_iterator operator ++(int);
00191 bool operator ==(const hdr_iterator& rhs) const;
00192 bool operator !=(const hdr_iterator& rhs) const {return !operator ==(rhs);}
00193 const referent_type& operator *() const;
00194 const referent_type* operator ->() const;
00195 private:
00196 friend class env;
00197 hdr_iterator() : end_(true) {}
00198 hdr_iterator(const env& e);
00199 void increment(bool initialize = false);
00200 bool end_;
00201 char** p_;
00202 map_type::const_iterator it_;
00203 map_type::const_iterator it_end_;
00204 referent_type current_;
00205 };
00206 hdr_iterator hdr_begin() const {return hdr_iterator(*this);}
00207 hdr_iterator hdr_end() const {return hdr_iterator();}
00208
00209 void override(const std::string& name, const std::string& value);
00214 static std::string to_env_name(const std::string& hname);
00216 static std::string from_env_name(const std::string& ename);
00217 private:
00218 friend class hdr_iterator;
00219 bool map_override_mode_;
00220 map_type map_;
00221 };
00222 }
00223 #endif