Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50978 - sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail
From: lists.drrngrvy_at_[hidden]
Date: 2009-02-02 17:46:41


Author: drrngrvy
Date: 2009-02-02 17:46:40 EST (Mon, 02 Feb 2009)
New Revision: 50978
URL: http://svn.boost.org/trac/boost/changeset/50978

Log:
Keeping empty query string variables. Adding configuration point `BOOST_CGI_KEEP_EMPTY_VARS`. The point is that the CGI spec doesn't guarantee they'll be sent by the server, so you can't *always* rely on them. That said, most servers I know of do send the and they're quite useful sometimes.
Text files modified:
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/cgi_service_impl_base.hpp | 5 ++++-
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/extract_params.hpp | 13 ++++++++++++-
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/push_options.hpp | 8 ++++++++
   3 files changed, 24 insertions(+), 2 deletions(-)

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/cgi_service_impl_base.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/cgi_service_impl_base.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/cgi_service_impl_base.hpp 2009-02-02 17:46:40 EST (Mon, 02 Feb 2009)
@@ -173,7 +173,10 @@
       load(implementation_type& impl, bool parse_stdin
           , boost::system::error_code& ec)
     {
- return load(impl, parse_stdin ? common::parse_all : (common::parse_env | common::parse_cookie), ec);
+ return load(impl, common::parse_stdin
+ ? common::parse_all
+ : (common::parse_env | common::parse_cookies)
+ , ec);
     }/*
       detail::save_environment(env_vars(impl.vars_));
       std::string const& cl = env_vars(impl.vars_)["CONTENT_LENGTH"];

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/extract_params.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/extract_params.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/extract_params.hpp 2009-02-02 17:46:40 EST (Mon, 02 Feb 2009)
@@ -52,7 +52,16 @@
        }else
        if( *iter == "&" || *iter == ";" )
        {
- destination[name.c_str()] = current_token;
+// Empty parameters (eg. `empty` in /path/to/script?empty&foo=bar) aren't
+// guaranteed by the CGI spec to be kept, but you might want to use them.
+// You just have to define `BOOST_CGI_KEEP_EMPTY_VARS` (**FIXME** currently
+// on by default).
+#if defined(BOOST_CGI_KEEP_EMPTY_VARS)
+ if (name.empty())
+ destination[current_token.c_str()] = "";
+ else
+#endif // BOOST_CGI_KEEP_EMPTY_VARS
+ destination[name.c_str()] = current_token;
          current_token.clear();
          name.clear();
        }else
@@ -61,7 +70,9 @@
        }
      }
      // Save the name if the last n/v pair has no value.
+#if defined(BOOST_CGI_KEEP_EMPTY_VARS)
      if( !name.empty() )
+#endif
        destination[name.c_str()] = current_token;
 
      return ec;

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/push_options.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/push_options.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/push_options.hpp 2009-02-02 17:46:40 EST (Mon, 02 Feb 2009)
@@ -23,3 +23,11 @@
 # endif
 #endif
 
+/// Keep empty query string variables.
+/** Empty query string parameters (eg.
+ * `empty` in /path/to/script?empty&foo=bar)
+ * aren't guaranteed by the CGI spec to be kept, but you might want to use
+ * them. You just have to define `BOOST_CGI_KEEP_EMPTY_VARS` (**FIXME**
+ * currently on by default).
+ */
+#define BOOST_CGI_KEEP_EMPTY_VARS


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