ChipMaster's trial hacks on C++CMS starting with v1.2.1. Not sure I'll follow on with the v2 since it looks to be breaking and mostly frivolous.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

141 lines
4.0 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (C) 2008-2010 Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>
  4. //
  5. // This program is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU Lesser General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU Lesser General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU Lesser General Public License
  16. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. //
  18. ///////////////////////////////////////////////////////////////////////////////
  19. #ifndef CPPCMS_HTTP_REQUEST_H
  20. #define CPPCMS_HTTP_REQUEST_H
  21. #include "defs.h"
  22. #include <booster/noncopyable.h>
  23. #include <booster/hold_ptr.h>
  24. #include <string>
  25. #include <map>
  26. #include <vector>
  27. namespace cppcms {
  28. namespace impl { namespace cgi { class connection; } }
  29. namespace http {
  30. class cookie;
  31. class file;
  32. class CPPCMS_API request : public booster::noncopyable {
  33. public:
  34. // RFC 3875
  35. std::string auth_type();
  36. unsigned long long content_length();
  37. std::string content_type();
  38. std::string gateway_interface();
  39. std::string path_info();
  40. std::string path_translated();
  41. std::string query_string();
  42. std::string remote_addr();
  43. std::string remote_host();
  44. std::string remote_ident();
  45. std::string remote_user();
  46. std::string request_method();
  47. std::string script_name();
  48. std::string server_name();
  49. unsigned server_port();
  50. std::string server_protocol();
  51. std::string server_software();
  52. // RFC 2616 request headers
  53. std::string http_accept();
  54. std::string http_accept_charset();
  55. std::string http_accept_encoding();
  56. std::string http_accept_language();
  57. std::string http_accept_ranges();
  58. std::string http_authorization();
  59. std::string http_cache_control();
  60. std::string http_connection();
  61. std::string http_cookie();
  62. // std::pair<bool,time_t> http_date();
  63. std::string http_expect();
  64. std::string http_form();
  65. std::string http_host();
  66. std::string http_if_match();
  67. // std::pair<bool,time_t> http_if_modified_since();
  68. std::string http_if_none_match();
  69. // std::pair<bool,time_t> http_if_unmodified_since();
  70. std::pair<bool,unsigned> http_max_forwards();
  71. std::string http_pragma();
  72. std::string http_proxy_authorization();
  73. std::string http_range();
  74. std::string http_referer();
  75. std::string http_te();
  76. std::string http_upgrade();
  77. std::string http_user_agent();
  78. std::string http_via();
  79. std::string http_warn();
  80. // Other
  81. std::string getenv(std::string const &);
  82. std::map<std::string,std::string> getenv();
  83. typedef std::multimap<std::string,std::string> form_type;
  84. typedef std::map<std::string,cookie> cookies_type;
  85. typedef std::vector<file *> files_type;
  86. cookies_type const &cookies();
  87. form_type const &get();
  88. form_type const &post();
  89. form_type const &post_or_get();
  90. files_type files();
  91. std::pair<void *,size_t> raw_post_data();
  92. public:
  93. request(impl::cgi::connection &);
  94. ~request();
  95. private:
  96. friend class impl::cgi::connection;
  97. void set_post_data(std::vector<char> &post_data);
  98. bool prepare();
  99. bool parse_cookies();
  100. std::string urlencoded_decode(char const *,char const *);
  101. bool parse_form_urlencoded(char const *begin,char const *end,form_type &out);
  102. bool read_key_value(
  103. std::string::const_iterator &p,
  104. std::string::const_iterator e,
  105. std::string &key,
  106. std::string &value);
  107. struct data;
  108. form_type get_;
  109. form_type post_;
  110. files_type files_;
  111. cookies_type cookies_;
  112. booster::hold_ptr<data> d;
  113. impl::cgi::connection *conn_;
  114. };
  115. } // namespace http
  116. } // namespace cppcms
  117. #endif