Boost logo

Boost-Commit :

From: lists.drrngrvy_at_[hidden]
Date: 2008-05-19 15:17:05


Author: drrngrvy
Date: 2008-05-19 15:17:04 EDT (Mon, 19 May 2008)
New Revision: 45556
URL: http://svn.boost.org/trac/boost/changeset/45556

Log:
Breaking changes: Accessing request data should only be done using basic_request<>::operator[] now; member functions like basic_request<>::GET() are gone now. Examples have been updated.
Also:
* Internally, data maps are accessed using eg. common::get_vars(impl.var_) where impl.var_ is the Boost.Fusion map of all the request types.
* Added "_data"-less alternatives to get_data, post_data, etc, so you can do eg.
  ``
  assert( request[get]["Hello"] == request[get_data]["hello"]); // note: case insensitive
  ``
* Other minor cleanups/refactoring.

Text files modified:
   sandbox/SOC/2007/cgi/trunk/boost/cgi/basic_request.hpp | 302 ++++++++++-----------------------------
   sandbox/SOC/2007/cgi/trunk/boost/cgi/buffer.hpp | 1
   sandbox/SOC/2007/cgi/trunk/boost/cgi/common/form_parser.hpp | 9
   sandbox/SOC/2007/cgi/trunk/boost/cgi/common/form_parser.ipp | 18 +
   sandbox/SOC/2007/cgi/trunk/boost/cgi/common/request_base.hpp | 76 ++-------
   sandbox/SOC/2007/cgi/trunk/boost/cgi/common/source_enums.hpp | 21 ++
   sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/cgi_service_impl_base.hpp | 10
   sandbox/SOC/2007/cgi/trunk/boost/cgi/error.hpp | 5
   sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/request_service.hpp | 13
   9 files changed, 146 insertions(+), 309 deletions(-)

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/basic_request.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/basic_request.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/basic_request.hpp 2008-05-19 15:17:04 EDT (Mon, 19 May 2008)
@@ -81,12 +81,14 @@
   public:
     typedef basic_request<RequestService, ProtocolService
                          , Role, Allocator > type;
- typedef ::cgi::common::map map_type;
+ typedef ::cgi::common::map map_type;
     typedef RequestService service_type;
     typedef typename service_type::protocol_type protocol_type;
     typedef ProtocolService protocol_service_type;
     typedef boost::shared_ptr<type> pointer;
     typedef typename RequestService::implementation_type implementation_type;
+ typedef typename implementation_type::char_type char_type;
+ typedef typename implementation_type::string_type string_type;
     typedef typename implementation_type::client_type client_type;
 
 
@@ -290,252 +292,75 @@
     }
     */
 
- /// Find the get meta-variable matching name
- /**
- * @throws `boost::system::system_error` if an error occurred. This may
- * fail with `cgi::error::request_aborted` if the request has been aborted
- * by the client.
- */
- std::string GET(const std::string& name)
+ /// Search through environment variables for the matching name
+ string_type var(string_type const& name, boost::system::error_code& ec)
     {
- boost::system::error_code ec;
- std::string ret = this->service.GET(this->implementation, name, ec);
- detail::throw_error(ec);
- return ret;
+ return env_vars(this->implementation)[name.c_str()];
     }
 
- /// Find the get meta-variable matching name
- /**
- * @param ec Set such that `(!ec == false)` if an error occurred. This may
- * fail with `ec == cgi::error::request_aborted` if the request has been
- * aborted by the client.
- */
- std::string GET(const std::string& name, boost::system::error_code& ec)
- {
- return this->service.GET(this->implementation, name, ec);
- }
-
- /// Find the post meta-variable matching name
- /**
- * @param greedy This determines whether more data can be read to find
- * the variable. The default is true to cause least surprise in the common
- * case of having not parsed any of the POST data.
- *
- * @throws `boost::system::system_error` if an error occurred. This may
- * fail with `cgi::error::request_aborted` if the request has been aborted
- * by the client.
- */
- std::string POST(const std::string& name, bool greedy = true)
+ string_type var(string_type const& name)
     {
       boost::system::error_code ec;
- std::string ret
- = this->service.POST(this->implementation, name, ec, greedy);
+ string_type ret (var(name, ec));
       detail::throw_error(ec);
       return ret;
     }
 
- /**
- * @param ec Set such that `(!ec == false)` if an error occurred. This may
- * fail with `ec == cgi::error::request_aborted` if the request has been
- * aborted by the client.
- */
- std::string POST(const std::string& name, boost::system::error_code& ec
- , bool greedy = true)
- {
- return this->service.POST(this->implementation, name, ec, greedy);
- }
-
- /// Find the form variable matching name
- /**
- * Depending on the request's request_method, either the GET or the POST
- * meta-variables are searched.
- *
- * @throws `boost::system::system_error` if an error occurred. This may
- * fail with `cgi::error::request_aborted` if the request has been aborted
- * by the client.
- */
- std::string form(const std::string& name, bool greedy = true)
- {
- boost::system::error_code ec;
- std::string ret = form(name, ec, greedy);
- detail::throw_error(ec);
- return ret;
- }
-
- /**
- * @param ec Set such that `(!ec == false)` if an error occurred. This may
- * fail with `ec == cgi::error::request_aborted` if the request has been
- * aborted by the client.
- */
- std::string form(const std::string& name, boost::system::error_code& ec
- , bool greedy = true)
- {
- std::string rm(request_method());
- if (rm == "GET")
- return this->service.GET(this->implementation, name, ec);
- else
- if (rm == "POST")
- return this->service.POST(this->implementation, name, ec, greedy);
- else
- return "";
- }
-
- /// Find the cookie meta-variable matching name
- /**
- * @throws `boost::system::system_error` if an error occurred. This may
- * fail with `cgi::error::request_aborted` if the request has been aborted
- * by the client.
- */
- std::string cookie(const std::string& name)
- {
- boost::system::error_code ec;
- std::string ret
- = this->service.cookie(this->implementation, name, ec);
- detail::throw_error(ec);
- return ret;
- }
-
- /// Find the cookie meta-variable matching name
- /**
- * @param ec Set such that `(!ec == false)` if an error occurred. This may
- * fail with `ec == cgi::error::request_aborted` if the request has been
- * aborted by the client.
- */
- std::string cookie(const std::string& name, boost::system::error_code& ec)
- {
- return this->service.cookie(this->implementation, name, ec);
- }
-
- /// Find the environment meta-variable matching name
- /**
- * @throws `boost::system::system_error` if an error occurred. This may
- * fail with `cgi::error::request_aborted` if the request has been aborted
- * by the client.
- */
- std::string env(const std::string& name)
- {
- boost::system::error_code ec;
- std::string ret = this->service.env(this->implementation, name, ec);
- detail::throw_error(ec);
- return ret;
- }
-
- /// Find the environment meta-variable matching name
- /**
- * @param ec Set such that `(!ec == false)` if an error occurred. This may
- * fail with `ec == cgi::error::request_aborted` if the request has been
- * aborted by the client.
- */
- std::string env(const std::string& name, boost::system::error_code& ec)
- {
- return this->service.env(this->implementation, name, ec);
- }
-
- /// Search through all meta vars for the meta-variable matching name
- /**
- * The policy w.r.t. POST data (ie. whether it should all
- * be read/parsed and included in this search or not) is
- * to be decided.
- *
- * Notes:
- * One option is to parse everything, making this option
- * very inefficient.
- * Another is to leave this function as a 'lazy' search:
- * it'll search with what it's got and no more. Then, also
- * provide a meta_var_all() function which is greedy; the
- * ugly/long name there to discourage use.
- */
- std::string var(std::string const& name, bool greedy = false)
- {
- boost::system::error_code ec;
- std::string ret = var(name, ec, greedy);
- return this->service.var(this->implementation, name, greedy);
- std::string request_method( env("REQUEST_METHOD") );
-
- std::string tmp;
-
- // If it's not a POST request search meta_get first (to save time)
- if (request_method.empty() || request_method == "GET")
- {
- tmp = GET(name);
- if (!tmp.empty())
- return tmp;
- }
-
- tmp = cookie(name);
- if (!tmp.empty())
- return tmp;
-
- tmp = env(name);
- if (!tmp.empty())
- return tmp;
-
- if (!request_method.empty() && request_method == "POST")
- {
- tmp = POST(name);
- if (!tmp.empty())
- return tmp;
- }
-
- tmp = GET(name);
- return tmp.empty() ? "" : tmp;
- }
-
     // [helper-functions for the basic CGI 1.1 meta-variables.
- std::string auth_type()
- { return env("AUTH_TYPE"); }
+ string_type auth_type()
+ { return env_("AUTH_TYPE"); }
 
- std::string content_length()
- { return env("CONTENT_LENGTH"); }
+ string_type content_length()
+ { return env_("CONTENT_LENGTH"); }
 
- std::string content_type()
- { return env("CONTENT_TYPE"); }
+ string_type content_type()
+ { return env_("CONTENT_TYPE"); }
 
- std::string gateway_interface()
- { return env("GATEWAY_INTERFACE"); }
+ string_type gateway_interface()
+ { return env_("GATEWAY_INTERFACE"); }
 
- std::string path_info()
- { return env("PATH_INFO"); }
+ string_type path_info()
+ { return env_("PATH_INFO"); }
 
- std::string path_translated()
- { return env("PATH_TRANSLATED"); }
+ string_type path_translated()
+ { return env_("PATH_TRANSLATED"); }
 
- std::string query_string()
- { return env("QUERY_STRING"); }
+ string_type query_string()
+ { return env_("QUERY_STRING"); }
 
- std::string remote_addr()
- { return env("REMOTE_ADDR"); }
+ string_type remote_addr()
+ { return env_("REMOTE_ADDR"); }
 
- std::string remote_host()
- { return env("REMOTE_HOST"); }
+ string_type remote_host()
+ { return env_("REMOTE_HOST"); }
 
- std::string remote_ident()
- { return env("REMOTE_IDENT"); }
+ string_type remote_ident()
+ { return env_("REMOTE_IDENT"); }
 
- std::string remote_user()
- { return env("REMOTE_USER"); }
+ string_type remote_user()
+ { return env_("REMOTE_USER"); }
 
- std::string request_method()
- { return env("REQUEST_METHOD"); }
+ string_type request_method()
+ { return env_("REQUEST_METHOD"); }
 
- std::string script_name()
- { return env("SCRIPT_NAME"); }
+ string_type script_name()
+ { return env_("SCRIPT_NAME"); }
 
- std::string server_name()
- { return env("SERVER_NAME"); }
+ string_type server_name()
+ { return env_("SERVER_NAME"); }
 
- std::string server_port()
- { return env("SERVER_PORT"); }
+ string_type server_port()
+ { return env_("SERVER_PORT"); }
 
- std::string server_protocol()
- { return env("SERVER_PROTOCOL"); }
+ string_type server_protocol()
+ { return env_("SERVER_PROTOCOL"); }
 
- std::string server_software()
- { return env("SERVER_SOFTWARE"); }
+ string_type server_software()
+ { return env_("SERVER_SOFTWARE"); }
     // -- end helper-functions]
 
     /// Get the charset from the CONTENT_TYPE header
- std::string charset()
+ string_type charset()
     {
       // Not sure if regex is needlessly heavy-weight here.
       boost::regex re(";[ ]?charset=([-\\w]+);");
@@ -571,40 +396,60 @@
     // compile-time (I hope) retrieval of different data
     // maps.
     //
+
+ // The first three overloads are for directly looking into the
+ // environment.
+ // eg.
+ // string_type& val = req["some name"];
+ env_map& operator[](string_type const& n)
+ {
+ return env_vars(this->implementation.vars_)[n.c_str()];
+ }
+
+ env_map& operator[](const char* n)
+ {
+ return env_vars(this->implementation.vars_)[n];
+ }
+
+ env_map& operator[](common::name const& n)
+ {
+ return env_vars(this->implementation.vars_)[n];
+ }
+
     /// Get a `common::env_map&` of all the environment variables.
     env_map& operator[](common::env_data_type const&)
     {
- return this->implementation.env_vars();
+ return env_vars(this->implementation.vars_);
     }
 
     /// Get a `common::get_map&` of all the GET variables.
     get_map& operator[](common::get_data_type const&)
     {
- return this->implementation.get_vars();
+ return get_vars(this->implementation.vars_);
     }
 
     /// Get a `common::post_map&` of all the POST variables.
     post_map& operator[](common::post_data_type const&)
     {
- return this->implementation.post_vars();
+ return post_vars(this->implementation.vars_);
     }
 
     /// Get a `common::cookie_map&` of all the cookies.
     cookie_map& operator[](common::cookie_data_type const&)
     {
- return this->implementation.cookie_vars();
+ return cookie_vars(this->implementation.vars_);
     }
 
     /// Get a `common::form_map&` of either the GET or POST variables.
     form_map& operator[](common::form_data_type const&)
     {
       if (request_method() == "GET")
- return this->implementation.get_vars();
+ return get_vars(this->implementation.vars_);
       else
       if (request_method() == "POST")
- return this->implementation.post_vars();
+ return post_vars(this->implementation.vars_);
       else
- return this->implementation.env_vars();
+ return env_vars(this->implementation.vars_);
     }
     ////////////////////////////////////////////////////////////
 
@@ -619,6 +464,13 @@
     {
       return this->service.request_id(this->implementation);
     }
+
+ private:
+ // Internal shortcut for named env-var functions (eg. script_name() above).
+ string_type& env_(const char* name)
+ {
+ return env_vars(this->implementation.vars_)[name];
+ }
   };
 
  } // namespace common

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/buffer.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/buffer.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/buffer.hpp 2008-05-19 15:17:04 EDT (Mon, 19 May 2008)
@@ -14,6 +14,7 @@
 namespace cgi {
  namespace common {
 
+ /// Import the Boost.Asio overloads.
   using boost::asio::buffer;
 
  } // namespace common

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/common/form_parser.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/common/form_parser.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/common/form_parser.hpp 2008-05-19 15:17:04 EDT (Mon, 19 May 2008)
@@ -11,17 +11,20 @@
 
 #include "boost/cgi/detail/push_options.hpp"
 
+///////////////////////////////////////////////////////////
 #include <set>
 #include <vector>
 #include <string>
+///////////////////////////////////////////////////////////
 #include <boost/regex.hpp>
 #include <boost/asio/buffer.hpp>
 #include <boost/asio/error.hpp>
 #include <boost/function.hpp>
 #include <boost/system/error_code.hpp>
 #include <boost/algorithm/string/find.hpp>
+///////////////////////////////////////////////////////////
+#include "boost/cgi/common/map.hpp"
 #include "boost/cgi/common/form_part.hpp"
-#include "boost/cgi/basic_client.hpp"
 
 namespace cgi {
  namespace detail {
@@ -101,7 +104,9 @@
  } // namespace detail
 } // namespace cgi
 
-#include "boost/cgi/common/form_parser.ipp"
+#ifndef BOOST_CGI_BUILD_LIB
+# include "boost/cgi/common/form_parser.ipp"
+#endif
 
 #endif // CGI_DETAIL_FORM_PARSER_HPP_INCLUDED__
 

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/common/form_parser.ipp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/common/form_parser.ipp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/common/form_parser.ipp 2008-05-19 15:17:04 EDT (Mon, 19 May 2008)
@@ -9,7 +9,9 @@
 #ifndef CGI_DETAIL_FORM_PARSER_IPP_INCLUDED__
 #define CGI_DETAIL_FORM_PARSER_IPP_INCLUDED__
 
+#include "boost/cgi/basic_client.hpp"
 #include "boost/cgi/common/form_parser.hpp"
+#include "boost/cgi/detail/url_decode.hpp"
 
 namespace cgi {
  namespace detail {
@@ -30,7 +32,7 @@
     boost::system::error_code
       form_parser<T>::parse(boost::system::error_code& ec)
     {
- std::string content_type (impl_.env_vars()["CONTENT_TYPE"]);
+ std::string content_type (env_vars(impl_.vars_)["CONTENT_TYPE"]);
 
       BOOST_ASSERT(!content_type.empty());
 
@@ -40,9 +42,13 @@
         parse_url_encoded_form(ec);
       }
       else
+ if (boost::algorithm::ifind_first(content_type,
+ "multipart/form-data"))
       {
         parse_multipart_form(ec);
       }
+ else
+ return ec = error::invalid_form_type;
 
       return ec;
     }
@@ -88,13 +94,13 @@
             str.append(1, ' ');
             break;
         case ' ': // skip spaces
- continue;
+ break;
         case '=': // the name is complete, now get the corresponding value
             name.swap(str);
             break;
         case '&': // we now have the name/value pair, so save it
             // **FIXME** have to have .c_str() ?
- impl_.post_vars()[name.c_str()] = str;
+ post_vars(impl_.vars_)[name.c_str()] = str;
             str.clear();
             name.clear();
            break;
@@ -105,7 +111,7 @@
       // save the last param (it won't have a trailing &)
       if( !name.empty() )
           // **FIXME** have to have .c_str() ?
- impl_.post_vars()[name.c_str()] = str;
+ post_vars(impl_.vars_)[name.c_str()] = str;
 
       return ec;
     }
@@ -194,7 +200,7 @@
              // = boost::range_iterator<;
              = std::make_pair(matches[1].first, matches[1].second);
             // **FIXME**
- impl_.post_vars()[form_parts_.back().name.c_str()] = matches[1];
+ post_vars(impl_.vars_)[form_parts_.back().name.c_str()] = matches[1];
             //std::ofstream of("c:/cc/log/post_vars.log");
             //of<< "var == " << matches[1] << std::endl;
             offset_ = offset + matches[0].length();
@@ -411,7 +417,7 @@
       form_parser<T>::parse_boundary_marker(boost::system::error_code& ec)
     {
       // get the meta-data appended to the content_type
- std::string content_type_(impl_.env_vars()["CONTENT_TYPE"]);
+ std::string content_type_(env_vars(impl_.vars_)["CONTENT_TYPE"]);
       //BOOST_ASSERT(!content_type.empty());
 
       boost::regex re("; ?boundary=\"?([^\"\n\r]+)\"?");

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/common/request_base.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/common/request_base.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/common/request_base.hpp 2008-05-19 15:17:04 EDT (Mon, 19 May 2008)
@@ -33,44 +33,7 @@
   class request_base
   {
   public:
- /// Find the environment meta-variable matching name
- template<typename ImplType>
- std::string& env(ImplType& impl, std::string const& name
- , boost::system::error_code& ec)
- {
- return impl.env_vars()[name.c_str()];
- }
-
- template<typename ImplType>
- std::string& GET(ImplType& impl, std::string const& name
- , boost::system::error_code& ec)
- {
- return impl.get_vars()[name.c_str()];
- }
-
- /// Find the post meta-variable matching name
- /**
- * @param greedy This determines whether more data can be read to find
- * the variable. The default is true to cause least surprise in the common
- * case of having not parsed any of the POST data.
- */
- template<typename ImplType>
- std::string& POST(ImplType& impl, std::string const& name
- , boost::system::error_code& ec, bool greedy)
- {
- // **FIXME** greedy isn't used: it may be unnecessary now though...
- return impl.post_vars()[name.c_str()];
- }
-
- /// Find the cookie meta-variable matching name
- template<typename ImplType>
- std::string&
- cookie(ImplType& impl, std::string const& name
- , boost::system::error_code& ec)
- {
- return impl.cookie_vars()[name.c_str()];
- }
-
+ /// Get the request ID of a FastCGI request, or 1.
     template<typename ImplType>
     int request_id(ImplType& impl)
     {
@@ -82,15 +45,12 @@
     // implementation_type and should be inherited by it.
     struct impl_base
     {
- typedef std::vector<char> buffer_type;
+ typedef char char_type; // **FIXME**
+ typedef std::basic_string<char_type> string_type;
+ typedef std::vector<char_type> buffer_type;
       typedef boost::asio::const_buffers_1 const_buffers_type;
       typedef boost::asio::mutable_buffers_1 mutable_buffers_type;
  
- common::env_map& env_vars() { return boost::fusion::at_c<0>(vars_); }
- common::get_map& get_vars() { return boost::fusion::at_c<1>(vars_); }
- common::post_map& post_vars() { return boost::fusion::at_c<2>(vars_); }
- common::cookie_map& cookie_vars() { return boost::fusion::at_c<3>(vars_); }
-
       typedef boost::fusion::vector<
           common::env_map, common::get_map
         , common::post_map, common::cookie_map
@@ -108,14 +68,12 @@
       // Make sure the request is in a pre-loaded state
       //BOOST_ASSERT (impl.status() <= unloaded);
 
- std::string const& vars(impl.env_vars()["QUERY_STRING"]);
- if (vars.empty())
- return ec;
-
- detail::extract_params(vars, impl.get_vars()
- , boost::char_separator<char>
- ("", "=&", boost::keep_empty_tokens)
- , ec);
+ std::string const& vars (env_vars(impl.vars_)["QUERY_STRING"]);
+ if (!vars.empty())
+ detail::extract_params(vars, get_vars(impl.vars_)
+ , boost::char_separator<char>
+ ("", "=&", boost::keep_empty_tokens)
+ , ec);
 
       return ec;
     }
@@ -128,14 +86,12 @@
       // Make sure the request is in a pre-loaded state
       //BOOST_ASSERT (impl.status() <= unloaded);
 
- std::string const& vars(impl.env_vars()["HTTP_COOKIE"]);
- if (vars.empty())
- return ec;
-
- detail::extract_params(vars, impl.cookie_vars()
- , boost::char_separator<char>
- ("", "=;", boost::keep_empty_tokens)
- , ec);
+ std::string const& vars (env_vars(impl.vars_)["HTTP_COOKIE"]);
+ if (!vars.empty())
+ detail::extract_params(vars, cookie_vars(impl.vars_)
+ , boost::char_separator<char>
+ ("", "=;", boost::keep_empty_tokens)
+ , ec);
 
       return ec;
     }

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/common/source_enums.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/common/source_enums.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/common/source_enums.hpp 2008-05-19 15:17:04 EDT (Mon, 19 May 2008)
@@ -2,14 +2,25 @@
 #ifndef BOOST_CGI_COMMON_SOURCE_ENUMS_HPP_INCLUDED__
 #define BOOST_CGI_COMMON_SOURCE_ENUMS_HPP_INCLUDED__
 
+#include <boost/fusion/include/at.hpp>
+
 namespace cgi {
  namespace common {
 
- enum get_data_type { get_data };
- enum post_data_type { post_data };
- enum cookie_data_type { cookie_data };
- enum env_data_type { env_data };
- enum form_data_type { form_data };
+ enum env_data_type { env, env_data };
+ enum get_data_type { get, get_data };
+ enum post_data_type { post, post_data };
+ enum cookie_data_type { cookies, cookie_data };
+ enum form_data_type { form, form_data };
+
+ template<typename Impl>
+ env_map& env_vars(Impl& impl) { return boost::fusion::at_c<0>(impl); }
+ template<typename Impl>
+ get_map& get_vars(Impl& impl) { return boost::fusion::at_c<1>(impl); }
+ template<typename Impl>
+ post_map& post_vars(Impl& impl) { return boost::fusion::at_c<2>(impl); }
+ template<typename Impl>
+ cookie_map& cookie_vars(Impl& impl) { return boost::fusion::at_c<3>(impl); }
 
  } // namespace common
 } // namespace cgi

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/cgi_service_impl_base.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/cgi_service_impl_base.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/cgi_service_impl_base.hpp 2008-05-19 15:17:04 EDT (Mon, 19 May 2008)
@@ -114,12 +114,12 @@
       load(implementation_type& impl, bool parse_stdin
           , boost::system::error_code& ec)
     {
- detail::save_environment(impl.env_vars());
- std::string const& cl = impl.env_vars()["CONTENT_LENGTH"];
+ detail::save_environment(env_vars(impl.vars_));
+ std::string const& cl = env_vars(impl.vars_)["CONTENT_LENGTH"];
       impl.characters_left_ = cl.empty() ? 0 : boost::lexical_cast<std::size_t>(cl);
       impl.client_.bytes_left() = impl.characters_left_;
 
- std::string const& request_method = impl.env_vars()["REQUEST_METHOD"];
+ std::string const& request_method = env_vars(impl.vars_)["REQUEST_METHOD"];
       if (request_method == "GET")
         this->parse_get_vars(impl, ec);
       else
@@ -135,7 +135,7 @@
 
       return ec;
     }
-
+/*
     // TODO: use `greedy`
     std::string
       form(implementation_type& impl, const std::string& name
@@ -166,7 +166,7 @@
                         if (rm == "POST")
                           return POST(impl, ec);
                 }
-
+*/
     role_type
       get_role(implementation_type& impl)
     {

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/error.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/error.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/error.hpp 2008-05-19 15:17:04 EDT (Mon, 19 May 2008)
@@ -11,6 +11,8 @@
 // The errors for everything are defined in here. ie. FastCGI,
 // CGI and SCGI errors.
 //
+// **FIXME** This is a mess.
+//
 ////////////////////////////////////////////////////////////////
 #ifndef CGI_ERROR_HPP_INCLUDED__
 #define CGI_ERROR_HPP_INCLUDED__
@@ -52,6 +54,9 @@
 
   invalid_socket,
 
+ // The CONTENT_TYPE for form data wasn't recognised.
+ invalid_form_type,
+
   // Used in basic_connection<tags::stdio>
   // **FIXME**
   broken_pipe,

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/request_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/request_service.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/request_service.hpp 2008-05-19 15:17:04 EDT (Mon, 19 May 2008)
@@ -14,6 +14,7 @@
 #include <boost/fusion/support.hpp>
 ////////////////////////////////////////////////////////////////
 #include "boost/cgi/common/map.hpp"
+#include "boost/cgi/common/source_enums.hpp"
 #include "boost/cgi/common/request_base.hpp"
 #include "boost/cgi/tags.hpp"
 #include "boost/cgi/read.hpp"
@@ -191,10 +192,10 @@
       );
                 
       impl.buffer_.clear();
- impl.get_vars().clear();
- impl.post_vars().clear();
- impl.cookie_vars().clear();
- impl.env_vars().clear();
+ common::get_vars(impl.vars_).clear();
+ common::post_vars(impl.vars_).clear();
+ common::cookie_vars(impl.vars_).clear();
+ common::env_vars(impl.vars_).clear();
       impl.stdin_parsed_ = false;
       impl.http_status_ = http::no_content;
       impl.request_status_ = null;
@@ -264,7 +265,7 @@
         parse_packet(impl, ec);
       }
 
- const std::string& request_method = env(impl, "REQUEST_METHOD", ec);
+ const std::string& request_method = env_vars(impl.vars_)["REQUEST_METHOD"];
       if (request_method == "GET")
         if (parse_get_vars(impl, ec))
           return ec;
@@ -489,7 +490,7 @@
         //std::cerr<< "[hw] data := " << data << std::endl;
 
         // **FIXME**
- impl.env_vars()[name.c_str()] = data;
+ env_vars(impl.vars_)[name.c_str()] = data;
       }
 
       return ec;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk