Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61787 - in sandbox/SOC/2007/cgi/trunk: boost/cgi boost/cgi/cgi boost/cgi/common boost/cgi/detail boost/cgi/fcgi boost/cgi/impl boost/cgi/utility libs/cgi/build/msvc/9.0/Boost.CGI libs/cgi/build/msvc/9.0/Boost.CGI/sessions_quickstart libs/cgi/doc/src libs/cgi/doc/src/utilities/sessions libs/cgi/example/cgi/custom_sessions libs/cgi/example/cgi/echo libs/cgi/example/cgi/sessions libs/cgi/example/cgi/stencil libs/cgi/example/fcgi/async_echo libs/cgi/example/fcgi/echo libs/cgi/example/fcgi/echo_threaded libs/cgi/example/fcgi/file_browser libs/cgi/example/fcgi/upload libs/cgi/test/run
From: lists.drrngrvy_at_[hidden]
Date: 2010-05-05 08:50:29


Author: drrngrvy
Date: 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
New Revision: 61787
URL: http://svn.boost.org/trac/boost/changeset/61787

Log:
* Add support for FastCGI authorizer role.
* Add support for multimaps as request data members.
* Change GET and POST data to use multimaps.
* Add some documentation stubs for examples.
* Minor documentation additions to code.
* Several other cleanups.
Added:
   sandbox/SOC/2007/cgi/trunk/boost/cgi/common/request_data.hpp (contents, props changed)
   sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/is_multimap.hpp (contents, props changed)
   sandbox/SOC/2007/cgi/trunk/libs/cgi/build/msvc/9.0/Boost.CGI/sessions_quickstart/
   sandbox/SOC/2007/cgi/trunk/libs/cgi/build/msvc/9.0/Boost.CGI/sessions_quickstart/sessions_quickstart.vcproj (contents, props changed)
   sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/custom_sessions/Jamfile.v2 (contents, props changed)
   sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/custom_sessions/doc.qbk (contents, props changed)
   sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/sessions/doc.qbk (contents, props changed)
   sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/async_echo/doc.qbk (contents, props changed)
   sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/file_browser/doc.qbk (contents, props changed)
   sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/upload/doc.qbk (contents, props changed)
   sandbox/SOC/2007/cgi/trunk/libs/cgi/test/run/request_data.cpp (contents, props changed)
Text files modified:
   sandbox/SOC/2007/cgi/trunk/boost/cgi/basic_request.hpp | 68 ++++---------------
   sandbox/SOC/2007/cgi/trunk/boost/cgi/cgi/request_service.hpp | 2
   sandbox/SOC/2007/cgi/trunk/boost/cgi/common/data_map_proxy.hpp | 134 ++++++++++++++++++++-------------------
   sandbox/SOC/2007/cgi/trunk/boost/cgi/common/map.hpp | 10 +-
   sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/acceptor_service_impl.hpp | 18 ----
   sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/request_service.hpp | 6
   sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/specification.hpp | 11 +-
   sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/win32_acceptor_service_impl.hpp | 16 ++-
   sandbox/SOC/2007/cgi/trunk/boost/cgi/impl/fcgi_request_service.ipp | 2
   sandbox/SOC/2007/cgi/trunk/boost/cgi/impl/form_parser.ipp | 8 +-
   sandbox/SOC/2007/cgi/trunk/boost/cgi/utility/stencil.hpp | 22 ++++++
   sandbox/SOC/2007/cgi/trunk/libs/cgi/build/msvc/9.0/Boost.CGI/Boost.CGI.sln | 36 +++++++---
   sandbox/SOC/2007/cgi/trunk/libs/cgi/doc/src/cgi.qbk | 13 ---
   sandbox/SOC/2007/cgi/trunk/libs/cgi/doc/src/utilities/sessions/sessions_quickstart.cpp | 17 +++-
   sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/echo/main.cpp | 15 ++++
   sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/stencil/main.cpp | 55 +++++++++++++++
   sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/stencil/stencil.html | 19 ++++
   sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/async_echo/main.cpp | 9 --
   sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/echo/main.cpp | 1
   sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/echo_threaded/main.cpp | 30 ++------
   sandbox/SOC/2007/cgi/trunk/libs/cgi/test/run/Jamfile.v2 | 16 ++--
   21 files changed, 274 insertions(+), 234 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 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -18,10 +18,9 @@
 
 #include <boost/shared_ptr.hpp>
 #include <boost/noncopyable.hpp>
-#include <boost/functional/hash.hpp>
 #include <boost/system/error_code.hpp>
 ///////////////////////////////////////////////////////////
-#include "boost/cgi/common/data_map_proxy.hpp"
+#include "boost/cgi/common/request_data.hpp"
 #include "boost/cgi/common/form_part.hpp"
 #include "boost/cgi/common/map.hpp"
 #include "boost/cgi/common/parse_options.hpp"
@@ -43,15 +42,6 @@
 BOOST_CGI_NAMESPACE_BEGIN
  namespace common {
 
- /// Get a hashed interpretation of the request.
- /**
- * You cannot consider this completely unique to each
- * request, but it should be quite useful anyway.
- * You can use this for logging or tracking, for example.
- */
- template<typename P>
- std::size_t hash_value(basic_request<P> const& req);
-
   /// The basic_request class, primary entry point to the library
   /**
    * Note: By default, synchronous protocols (ie. cgi) auto-load AND parse
@@ -91,12 +81,18 @@
     session_type session;
 #endif // BOOST_CGI_ENABLE_SESSIONS
     
- common::data_map_proxy<env_map> env;
- common::data_map_proxy<post_map> post;
- common::data_map_proxy<get_map> get;
- common::data_map_proxy<form_map> form;
- common::data_map_proxy<cookie_map> cookies;
- common::data_map_proxy<upload_map> uploads;
+ /// The environment data, exposed as a request_data<env_map>.
+ env_data env;
+ /// The GET (ie. query string) data, exposed as a request_data<get_map>.
+ post_data post;
+ /// The POST data, exposed as a request_data<post_map>.
+ get_data get;
+ /// The form data, which is either the GET or POST data.
+ form_data form;
+ /// The cookie data, exposed as a request_data<cookie_map>.
+ cookie_data cookies;
+ /// The file uploads, exposed as a request_data<upload_map>.
+ upload_data uploads;
 
     basic_request(
         int opts
@@ -299,10 +295,7 @@
         if (parse_opts & parse_form_only)
         {
           common::name rm(request_method().c_str());
- form.set(
- (rm == "GET" || rm == "HEAD") ? get :
- rm == "POST" ? post : env
- );
+ form.set(rm == "POST" ? post.impl() : get.impl());
         }
 #ifdef BOOST_CGI_ENABLE_SESSIONS
         if (parse_opts & parse_session_only)
@@ -624,22 +617,11 @@
      * different
      * eg. `authorizer`, or `filter`.
      */
- role_type& role() const
+ role_type role() const
     {
       return this->service.role(this->implementation);
     }
 
- /// Get a hashed interpretation of the request.
- /**
- * You cannot consider this completely unique to each
- * request, but it should be quite useful anyway.
- * You can use this for logging or tracking, for example.
- */
- std::size_t hash()
- {
- return boost::hash<self_type>()(*this);
- }
-
     /// Get / Set the status of a request.
     /**
      * The usual way to set the request status is to set it
@@ -657,26 +639,6 @@
     }
    };
 
- /// Support for Boost.Hash
- /**
- * `basic_request<>` supports Boost.Hash. A request will have the same hash
- * value if all of the following are the same:
- *
- * * PATH_INFO
- * * QUERY_STRING
- * * REQUEST_METHOD
- * * REQUEST_URI
- */
- template<typename P>
- std::size_t hash_value(basic_request<P> const& req)
- {
- boost::hash<typename basic_request<P>::string_type> hasher;
- return hasher(req.env["PATH_INFO"] + ":"
- + req.env["QUERY_STRING"] + ":"
- + req.env["REQUEST_METHOD"] + ":"
- + req.env["REQUEST_URI"]);
- }
-
  } // namespace common
 BOOST_CGI_NAMESPACE_END
 

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/cgi/request_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/cgi/request_service.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/cgi/request_service.hpp 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -167,7 +167,7 @@
 
     /// CGI is always a responser.
     common::role_type
- role(implementation_type& impl) const
+ role(implementation_type const& impl) const
     {
       return common::responder;
     }

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/common/data_map_proxy.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/common/data_map_proxy.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/common/data_map_proxy.hpp 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -5,6 +5,7 @@
 #include <exception>
 #include <boost/assert.hpp>
 #include <boost/lexical_cast.hpp>
+#include <boost/utility/enable_if.hpp>
 ///////////////////////////////////////////////////////////
 #include "boost/cgi/config.hpp"
 
@@ -33,13 +34,14 @@
     }
   };
 
- /// A proxy class to provide access to the data maps as member variables.
+ /// A proxy class to provide access to the request data.
   /**
- * This wraps the underlying data map and exposes a std::map-like
+ * This class wraps the underlying data map and exposes a std::map-like
    * interface for the different data maps.
    *
- * It also includes an as<> member function which casts the found data
- * into a type the user specifies.
+ * The class also adds some helper functions which are commonly used
+ * for CGI programming, such as the member functions for looking up
+ * items and casting them to different types.
    */
   template<typename MapType>
   class data_map_proxy
@@ -58,65 +60,50 @@
     typedef typename map_type::allocator_type allocator_type;
     
     data_map_proxy()
- : impl(NULL)
+ : impl_(NULL)
     {
     }
 
     /// Map iterators.
     
- iterator begin() {
- BOOST_CGI_MAP_ASSERT(impl); return impl->begin(); }
- iterator end() {
- BOOST_CGI_MAP_ASSERT(impl); return impl->end(); }
- const_iterator begin() const {
- BOOST_CGI_MAP_ASSERT(impl); return impl->begin(); }
- const_iterator end() const {
- BOOST_CGI_MAP_ASSERT(impl); return impl->end(); }
- reverse_iterator rbegin() {
- BOOST_CGI_MAP_ASSERT(impl); return impl->rbegin(); }
- reverse_iterator rend() {
- BOOST_CGI_MAP_ASSERT(impl); return impl->rend(); }
- const_reverse_iterator rbegin() const {
- BOOST_CGI_MAP_ASSERT(impl); return impl->rbegin(); }
- const_reverse_iterator rend() const {
- BOOST_CGI_MAP_ASSERT(impl); return impl->rend(); }
+ iterator begin() { return impl().begin(); }
+ iterator end() { return impl().end(); }
+ const_iterator begin() const { return impl().begin(); }
+ const_iterator end() const { return impl().end(); }
+ reverse_iterator rbegin() { return impl().rbegin(); }
+ reverse_iterator rend() { return impl().rend(); }
+ const_reverse_iterator rbegin() const { return impl().rbegin(); }
+ const_reverse_iterator rend() const { return impl().rend(); }
 
     iterator insert( iterator pos, const value_type& pair ) {
- BOOST_CGI_MAP_ASSERT(impl);
- return impl->insert(pos, pair);
+ return impl().insert(pos, pair);
     }
     
     template<typename InputIterator>
     void insert(InputIterator start, InputIterator end) {
- BOOST_CGI_MAP_ASSERT(impl);
- return impl->insert(start, end);
+ return impl().insert(start, end);
     }
     
     std::pair<iterator,bool> insert(const value_type& pair) {
- BOOST_CGI_MAP_ASSERT(impl);
- return impl->insert(pair);
+ return impl().insert(pair);
     }
     
- void set(map_type& data) { impl = &data; }
+ void set(map_type& data) { impl_ = &data; }
 
- bool empty() { BOOST_CGI_MAP_ASSERT(impl); return impl->empty(); }
+ bool empty() { return impl().empty(); }
 
- void clear() { BOOST_CGI_MAP_ASSERT(impl); return impl->clear(); }
+ void clear() { return impl().clear(); }
 
- size_type size() const { BOOST_CGI_MAP_ASSERT(impl); return impl->size(); }
+ size_type size() const { return impl().size(); }
 
- size_type count(const key_type& key) {
- BOOST_CGI_MAP_ASSERT(impl);
- return impl->count(key);
- }
+ size_type count(const key_type& key) { return impl().count(key); }
 
     /// Get a value for the key, with a fallback when not found.
     mapped_type const&
       pick(key_type const& key, mapped_type const& default_value) const
     {
- BOOST_CGI_MAP_ASSERT(impl);
- const_iterator iter = impl->find(key);
- return iter == impl->end() ? default_value : iter->second;
+ const_iterator iter = impl().find(key);
+ return iter == impl().end() ? default_value : iter->second;
     }
 
     /// Get a value for the key as a specified type.
@@ -129,8 +116,7 @@
     template<typename T>
     T as(key_type const& key) const
     {
- BOOST_CGI_MAP_ASSERT(impl);
- return boost::lexical_cast<T>((*impl)[key]);
+ return boost::lexical_cast<T>((impl())[key]);
     }
 
     /// Get a value for the key as a specified type, with fallback.
@@ -141,20 +127,18 @@
      * for the specified key, or the data cannot be converted
      * into the type T, then this value is returned.
      *
- * If the key cannot be found, returns a default-constructed object
- * of type T.
- *
- * If the key is found, attempts to convert the value into the type T.
+ * If the key cannot be found, or the value cannot be lexically cast to
+ * the type T, `pick` returns a default-constructed object of type T.
+ * Otherwise it will return the value for that key as a type T.
      */
     template<typename T>
     T pick(key_type const& key, T const& default_value = T()) const
     {
- BOOST_CGI_MAP_ASSERT(impl);
- const_iterator iter = impl->find(key);
+ const_iterator iter = impl().find(key);
 
       T val (default_value);
 
- if (iter != impl->end()) {
+ if (iter != impl().end()) {
         try {
           val = boost::lexical_cast<T>(iter->second);
         } catch(...) {
@@ -164,33 +148,51 @@
       return val;
     }
 
- mapped_type& operator[](const char* varname) {
- BOOST_CGI_MAP_ASSERT(impl);
- return (*impl)[varname];
+ /// Look up `key` in the data map and return a reference to it.
+ /**
+ * This works just like a std::map<>, whereby if an item is not found
+ * in the map then a new item is created with an empty value and a
+ * reference to the item is returned.
+ *
+ * If you want to avoid creating an item, you can use `pick()` instead.
+ */
+ mapped_type& operator[](const char* key) {
+ return impl()[key];
     }
 
- mapped_type& operator[](const char* varname) const {
- BOOST_CGI_MAP_ASSERT(impl);
- return (*impl)[varname];
+ /// Look up `key` in the data map and return a reference to it.
+ /**
+ * This works just like a std::map<>, whereby if an item is not found
+ * in the map then a new item is created with an empty value and a
+ * reference to the item is returned.
+ *
+ * If you want to avoid creating an item, you can use `pick()` instead.
+ */
+ mapped_type& operator[](key_type const& key) {
+ return impl()[key.c_str()];
     }
 
- mapped_type& operator[](key_type const& varname) {
- BOOST_CGI_MAP_ASSERT(impl);
- return (*impl)[varname.c_str()];
- }
+ /// Get access to the internal map structure.
+ map_type& impl() { BOOST_CGI_MAP_ASSERT(impl_); return *impl_; }
 
- mapped_type const& operator[](key_type const& varname) const {
- BOOST_CGI_MAP_ASSERT(impl);
- return (*impl)[varname.c_str()];
- }
+ /// Get read-only access to the internal map structure.
+ map_type const& impl () const { BOOST_CGI_MAP_ASSERT(impl_); return *impl_; }
 
- operator map_type&() { BOOST_CGI_MAP_ASSERT(impl); return *impl; }
- bool operator!() const { return !impl; }
+ /// A data_map_proxy is implicitly convertible to the underlying map type.
+ operator map_type&() { return impl(); }
 
- private:
- map_type* impl;
+ /// Check if the proxy contains a map.
+ /**
+ * This proxy class keeps a raw pointer to a request data map, which it
+ * refers to. You set it using `set()` and can then use a boolean check
+ * on the object to confirm that the internal pointer is assigned.
+ */
+ bool operator!() const { return !impl_; }
+
+ protected:
+ map_type* impl_;
   };
-
+
  } // namespace common
 BOOST_CGI_NAMESPACE_END
 

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/common/map.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/common/map.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/common/map.hpp 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -2,6 +2,7 @@
 #define BOOST_CGI_COMMON_MAP_HPP_INCLUDED__
 
 #include <map>
+#include <boost/mpl/bool.hpp>
 #include "boost/cgi/common/name.hpp"
 #include "boost/cgi/common/cookie.hpp"
 #include "boost/cgi/common/form_part.hpp"
@@ -26,11 +27,11 @@
     * > Update `data_map_type` in the `request_base` class
     */
   typedef map env_map;
- typedef map get_map;
- typedef map post_map;
- typedef map form_map;
+ typedef multimap get_map;
+ typedef multimap post_map;
+ typedef multimap form_map;
   typedef map cookie_map;
- typedef std::map<
+ typedef std::multimap<
       ::BOOST_CGI_NAMESPACE::common::name,
       ::BOOST_CGI_NAMESPACE::common::form_part
> upload_map;
@@ -40,4 +41,3 @@
 BOOST_CGI_NAMESPACE_END
 
 #endif // BOOST_CGI_COMMON_MAP_HPP_INCLUDED__
-

Added: sandbox/SOC/2007/cgi/trunk/boost/cgi/common/request_data.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/common/request_data.hpp 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -0,0 +1,80 @@
+
+#ifndef BOOST_CGI_REQUEST_DATA_HPP_INCLUDED_20100429_
+#define BOOST_CGI_REQUEST_DATA_HPP_INCLUDED_20100429_
+
+#include <exception>
+#include <boost/assert.hpp>
+#include <boost/lexical_cast.hpp>
+#include <boost/utility/enable_if.hpp>
+///////////////////////////////////////////////////////////
+#include "boost/cgi/config.hpp"
+#include "boost/cgi/common/map.hpp"
+#include "boost/cgi/common/data_map_proxy.hpp"
+#include "boost/cgi/detail/is_multimap.hpp"
+
+BOOST_CGI_NAMESPACE_BEGIN
+
+ namespace common {
+
+ /// The default request_data<T> type is essentially data_map_proxy<T>.
+ template<typename T, class Enable = void>
+ class request_data
+ : public data_map_proxy<T>
+ {
+ public:
+ using data_map_proxy<T>::operator[];
+ };
+
+ /// Specialisation for request_data<T> when T is a multimap.
+ template<typename T>
+ class request_data<T,
+ typename boost::enable_if<detail::is_multimap<T> >::type
+ >
+ : public data_map_proxy<T>
+ {
+ public:
+ typedef typename T::iterator iterator;
+
+ std::pair<iterator, iterator> equal_range( const key_type& key ) {
+ return impl()equal_range(key);
+ }
+
+ bool matches(key_type const& key, mapped_type const& val)
+ {
+ std::pair<iterator, iterator> ret = impl().equal_range(key);
+ for (iterator iter = ret.first, end = ret.second; iter != end; ++iter)
+ if (iter->second == val)
+ return true;
+ return false;
+ }
+
+ mapped_type& operator[](const char* varname) {
+ BOOST_CGI_MAP_ASSERT(impl_);
+ if (impl_->find(varname) == impl_->end()) {
+ using std::make_pair;
+ impl_->insert(make_pair(varname, ""));
+ }
+ return impl_->find(varname)->second;
+ }
+
+ mapped_type& operator[](key_type const& varname) {
+ BOOST_CGI_MAP_ASSERT(impl_);
+ if (impl_->find(varname) == impl_->end()) {
+ using std::make_pair;
+ impl_->insert(make_pair(varname, ""));
+ }
+ return impl_->find(varname)->second;
+ }
+ };
+
+ typedef request_data<env_map> env_data;
+ typedef request_data<post_map> post_data;
+ typedef request_data<get_map> get_data;
+ typedef request_data<form_map> form_data;
+ typedef request_data<cookie_map> cookie_data;
+ typedef request_data<upload_map> upload_data;
+
+ } // namespace common
+BOOST_CGI_NAMESPACE_END
+
+#endif // BOOST_CGI_REQUEST_DATA_HPP_INCLUDED_20100429_

Added: sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/is_multimap.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/is_multimap.hpp 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -0,0 +1,31 @@
+// is_multimap.hpp --
+//
+// Copyright (c) Darren Garvey 2010.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+////////////////////////////////////////////////////////////////
+#ifndef BOOST_CGI_IS_MULTIMAP_INCLUDED_20100430_
+#define BOOST_CGI_IS_MULTIMAP_INCLUDED_20100430_
+
+BOOST_CGI_NAMESPACE_BEGIN
+ namespace detail {
+
+ template<typename T>
+ struct is_multimap
+ : boost::mpl::false_
+ {
+ };
+
+ template<typename T, typename U>
+ struct is_multimap< std::multimap<T,U> >
+ : boost::mpl::true_
+ {
+ };
+
+ } // namespace detail
+BOOST_CGI_NAMESPACE_END
+
+#endif // BOOST_CGI_IS_MULTIMAP_INCLUDED_20100430_
+

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/acceptor_service_impl.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/acceptor_service_impl.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/acceptor_service_impl.hpp 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -1,6 +1,6 @@
-// -- fcgi/acceptor_service_impl.hpp --
+// -- fcgi/acceptor_service_impl.hpp --
 //
-// Copyright (c) Darren Garvey 2007.
+// Copyright (c) Darren Garvey 2007-2010.
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
@@ -62,20 +62,6 @@
   namespace fcgi {
 
   /// The service_impl class for FCGI basic_request_acceptor<>s
- /**
- * Note: this is near enough to being generic. It will hopefully translate
- * directly to the fcgi_acceptor_service_impl. In other words you
- * would then have one acceptor_service_impl<>, so you'd use
- * acceptor_service_impl<scgi> acceptor_service_impl_; // and
- * acceptor_service_impl<fcgi> acceptor_service_impl_; // etc...
- *
- * Note: If the protocol is an asynchronous protocol, which means it
- * requires access to a boost::asio::io_service instance, then this
- * class becomes a model of the Service concept (**LINK**) and must
- * only use the constructor which takes a ProtocolService (**LINK**).
- * If the protocol isn't async then the class can be used without a
- * ProtocolService.
- */
    template<typename Protocol = common::tags::fcgi>
    class acceptor_service_impl
      : public detail::service_base<

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 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -60,7 +60,7 @@
 
       implementation_type()
         : id_(0)
- , request_role_(spec_detail::ANY)
+ , request_role_(spec_detail::NONE)
       {
       }
 
@@ -138,9 +138,9 @@
     /// Returns true if the request environment params have been read.
     bool params_read(implementation_type& impl);
 
- common::role_type role(implementation_type& impl) const
+ common::role_type role(implementation_type const& impl) const
     {
- return common::responder;
+ return static_cast<common::role_type>(impl.request_role_);
     }
 
     client_type&

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/specification.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/specification.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/specification.hpp 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -63,10 +63,11 @@
     const boost::uint16_t MAX_MSG_LEN = 65535;
 
     // Values for role component of BeginRequestBody
- enum role_types { RESPONDER = 1
- , AUTHORIZER = 2
- , FILTER = 3
- , ANY
+ enum role_types {
+ NONE = 0
+ , RESPONDER = 1
+ , AUTHORIZER = 2
+ , FILTER = 3
     };
 
     // Values for protocolStatus component of EndRequestBody
@@ -575,7 +576,7 @@
         case FILTER:
           return "FILTER";
         default:
- return "ANY";
+ return "NONE";
         }
       }
     };

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/win32_acceptor_service_impl.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/win32_acceptor_service_impl.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/win32_acceptor_service_impl.hpp 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -310,10 +310,12 @@
        if (!new_request->is_open() && !new_request->client().keep_connection())
        {
          // ...otherwise accept a new connection.
+ boost::system::error_code ec;
          detail::accept_named_pipe(listen_handle, *new_request->client().connection(), ec);
- strand_.post(
+ if (!ec)
+ strand_.post(
              boost::bind(&self_type::handle_accept
- , this, boost::ref(impl), new_request, handler, _1
+ , this, boost::ref(impl), new_request, handler, ec
              )
          );
        }
@@ -480,13 +482,15 @@
          request.clear();
        }
 
+ boost::system::error_code ec;
        // If we can reuse this request's connection, return.
        if (request.client().keep_connection())
- return handler(boost::system::error_code());
+ return handler(ec);
+
+ // ...otherwise accept a new connection.
 
- // ...otherwise accept a new connection (asynchronously).
- acceptor_service_.async_accept(impl.acceptor_,
- request.client().connection()->next_layer(), 0, handler);
+ detail::accept_named_pipe(listen_handle, *request.client().connection(), ec);
+ strand_.post(handler);
        return 0;
      }
 

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/impl/fcgi_request_service.ipp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/impl/fcgi_request_service.ipp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/impl/fcgi_request_service.ipp 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -129,7 +129,7 @@
       impl.stdin_parsed_ = false;
       impl.http_status_ = common::http::no_content;
       impl.request_status_ = common::null;
- impl.request_role_ = spec_detail::ANY;
+ impl.request_role_ = spec_detail::NONE;
       impl.all_done_ = false;
       impl.client_.status_ = common::none_;
       impl.client_.request_id_ = -1;

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/impl/form_parser.ipp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/impl/form_parser.ipp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/impl/form_parser.ipp 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -84,7 +84,7 @@
             name.swap(result);
             break;
          case '&': // we now have the name/value pair, so save it
- context_->data_map[name.c_str()] = result;
+ context_->data_map.insert(std::make_pair(name.c_str(), result));
             result.clear();
             name.clear();
             break;
@@ -95,7 +95,7 @@
 #if defined(BOOST_CGI_KEEP_EMPTY_VARS)
       // save the last param (it won't have a trailing &)
       if( !name.empty() ) {
- context_->data_map[name.c_str()] = result;
+ context_->data_map.insert(std::make_pair(name.c_str(), result));
       }
 #endif // BOOST_CGI_KEEP_EMPTY_VARS
      return ec;
@@ -189,11 +189,11 @@
               internal_filename.c_str()
             , std::ios::out | std::ios::binary);
           file<< content;
- context_->uploads_map[part.name.c_str()] = part;
+ context_->uploads_map.insert(std::make_pair(part.name.c_str(), part));
         }
       }
       // Load the data to the request's post map.
- context_->data_map[part.name.c_str()] = part.value;
+ context_->data_map.insert(std::make_pair(part.name.c_str(), part.value));
       
       buffer.erase(0, next_pos+marker.length()+2);
       if (buffer.length() >= 2

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/utility/stencil.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/utility/stencil.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/utility/stencil.hpp 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -127,6 +127,17 @@
     return *this;
   }
 
+ /// Show a section.
+ self_type& show(section const& sec, string_type const& value)
+ {
+ impl->SetValueAndShowSection(
+ sec.name,
+ boost::lexical_cast<string_type>(value),
+ sec.name
+ );
+ return *this;
+ }
+
   /// Include a file into the stencil.
   /**
    * @return dictionary The returned sub-dictionary is used to set fields in
@@ -350,6 +361,17 @@
   }
   
   /// Show a section.
+ self_type& show(section const& sec, string_type const& value)
+ {
+ impl->SetValueAndShowSection(
+ sec.name,
+ boost::lexical_cast<string_type>(value),
+ sec.name
+ );
+ return *this;
+ }
+
+ /// Show a section.
   self_type& show(section const& sec)
   {
     if (sec.filename.empty())

Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/build/msvc/9.0/Boost.CGI/Boost.CGI.sln
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/build/msvc/9.0/Boost.CGI/Boost.CGI.sln (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/build/msvc/9.0/Boost.CGI/Boost.CGI.sln 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -39,14 +39,18 @@
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fastcgi_quickstart", "fastcgi_quickstart\fastcgi_quickstart.vcproj", "{4B0D354E-19EE-4D85-8370-B284A59C4AE1}"
 EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fcgi_charts", "fcgi_charts\fcgi_charts.vcproj", "{557CE468-710F-4C6D-A7EC-286B6A7F746A}"
-EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cgi_sessions", "cgi_sessions\cgi_sessions.vcproj", "{5C01290A-DD11-4DD9-971A-9C25CCA7FB96}"
 EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cgi_custom_sessions", "cgi_custom_sessions\cgi_custom_sessions.vcproj", "{FF4B6C26-B292-47FF-89B6-F2930AAA020B}"
-EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sessions_quickstart", "sessions_quickstart\sessions_quickstart.vcproj", "{F254F24F-5249-4A73-A6DA-61DF9BFDC489}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fcgi_authorizer", "cgi_authorizer\cgi_authorizer.vcproj", "{57D4A9D5-FD1E-4B73-86F3-6745CCD1CE99}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fcgi_authenticator", "fcgi_authenticator\fcgi_authenticator.vcproj", "{288631F9-C9AD-4D7E-806C-8246BD1B406C}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fcgi_authorizer", "fcgi_authorizer\fcgi_authorizer.vcproj", "{6317D692-ED4B-4461-8AE2-9F717CCBDE0E}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fcgi_access_checker", "fcgi_access_checker\fcgi_access_checker.vcproj", "{5784B69E-5D2F-48B5-BFA5-B6D8B31918E4}"
+EndProject
 Global
         GlobalSection(SolutionConfigurationPlatforms) = preSolution
                 Debug|Win32 = Debug|Win32
@@ -129,22 +133,30 @@
                 {4B0D354E-19EE-4D85-8370-B284A59C4AE1}.Debug|Win32.Build.0 = Debug|Win32
                 {4B0D354E-19EE-4D85-8370-B284A59C4AE1}.Release|Win32.ActiveCfg = Release|Win32
                 {4B0D354E-19EE-4D85-8370-B284A59C4AE1}.Release|Win32.Build.0 = Release|Win32
- {557CE468-710F-4C6D-A7EC-286B6A7F746A}.Debug|Win32.ActiveCfg = Debug|Win32
- {557CE468-710F-4C6D-A7EC-286B6A7F746A}.Debug|Win32.Build.0 = Debug|Win32
- {557CE468-710F-4C6D-A7EC-286B6A7F746A}.Release|Win32.ActiveCfg = Release|Win32
- {557CE468-710F-4C6D-A7EC-286B6A7F746A}.Release|Win32.Build.0 = Release|Win32
                 {5C01290A-DD11-4DD9-971A-9C25CCA7FB96}.Debug|Win32.ActiveCfg = Debug|Win32
                 {5C01290A-DD11-4DD9-971A-9C25CCA7FB96}.Debug|Win32.Build.0 = Debug|Win32
                 {5C01290A-DD11-4DD9-971A-9C25CCA7FB96}.Release|Win32.ActiveCfg = Release|Win32
                 {5C01290A-DD11-4DD9-971A-9C25CCA7FB96}.Release|Win32.Build.0 = Release|Win32
- {FF4B6C26-B292-47FF-89B6-F2930AAA020B}.Debug|Win32.ActiveCfg = Debug|Win32
- {FF4B6C26-B292-47FF-89B6-F2930AAA020B}.Debug|Win32.Build.0 = Debug|Win32
- {FF4B6C26-B292-47FF-89B6-F2930AAA020B}.Release|Win32.ActiveCfg = Release|Win32
- {FF4B6C26-B292-47FF-89B6-F2930AAA020B}.Release|Win32.Build.0 = Release|Win32
                 {F254F24F-5249-4A73-A6DA-61DF9BFDC489}.Debug|Win32.ActiveCfg = Debug|Win32
                 {F254F24F-5249-4A73-A6DA-61DF9BFDC489}.Debug|Win32.Build.0 = Debug|Win32
                 {F254F24F-5249-4A73-A6DA-61DF9BFDC489}.Release|Win32.ActiveCfg = Release|Win32
                 {F254F24F-5249-4A73-A6DA-61DF9BFDC489}.Release|Win32.Build.0 = Release|Win32
+ {57D4A9D5-FD1E-4B73-86F3-6745CCD1CE99}.Debug|Win32.ActiveCfg = Debug|Win32
+ {57D4A9D5-FD1E-4B73-86F3-6745CCD1CE99}.Debug|Win32.Build.0 = Debug|Win32
+ {57D4A9D5-FD1E-4B73-86F3-6745CCD1CE99}.Release|Win32.ActiveCfg = Release|Win32
+ {57D4A9D5-FD1E-4B73-86F3-6745CCD1CE99}.Release|Win32.Build.0 = Release|Win32
+ {288631F9-C9AD-4D7E-806C-8246BD1B406C}.Debug|Win32.ActiveCfg = Debug|Win32
+ {288631F9-C9AD-4D7E-806C-8246BD1B406C}.Debug|Win32.Build.0 = Debug|Win32
+ {288631F9-C9AD-4D7E-806C-8246BD1B406C}.Release|Win32.ActiveCfg = Release|Win32
+ {288631F9-C9AD-4D7E-806C-8246BD1B406C}.Release|Win32.Build.0 = Release|Win32
+ {6317D692-ED4B-4461-8AE2-9F717CCBDE0E}.Debug|Win32.ActiveCfg = Debug|Win32
+ {6317D692-ED4B-4461-8AE2-9F717CCBDE0E}.Debug|Win32.Build.0 = Debug|Win32
+ {6317D692-ED4B-4461-8AE2-9F717CCBDE0E}.Release|Win32.ActiveCfg = Release|Win32
+ {6317D692-ED4B-4461-8AE2-9F717CCBDE0E}.Release|Win32.Build.0 = Release|Win32
+ {5784B69E-5D2F-48B5-BFA5-B6D8B31918E4}.Debug|Win32.ActiveCfg = Debug|Win32
+ {5784B69E-5D2F-48B5-BFA5-B6D8B31918E4}.Debug|Win32.Build.0 = Debug|Win32
+ {5784B69E-5D2F-48B5-BFA5-B6D8B31918E4}.Release|Win32.ActiveCfg = Release|Win32
+ {5784B69E-5D2F-48B5-BFA5-B6D8B31918E4}.Release|Win32.Build.0 = Release|Win32
         EndGlobalSection
         GlobalSection(SolutionProperties) = preSolution
                 HideSolutionNode = FALSE

Added: sandbox/SOC/2007/cgi/trunk/libs/cgi/build/msvc/9.0/Boost.CGI/sessions_quickstart/sessions_quickstart.vcproj
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/build/msvc/9.0/Boost.CGI/sessions_quickstart/sessions_quickstart.vcproj 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -0,0 +1,203 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="sessions_quickstart"
+ ProjectGUID="{F254F24F-5249-4A73-A6DA-61DF9BFDC489}"
+ RootNamespace="sessions_quickstart"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS"
+ GeneratePreprocessedFile="0"
+ KeepComments="false"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="libctemplate-debug.lib"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine="copy &quot;$(TargetPath)&quot; &quot;\code\c++\boost.cgi\cgi-bin\$(TargetName)&quot;"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="libctemplate.lib"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine="copy &quot;$(TargetPath)&quot; &quot;\code\c++\boost.cgi\cgi-bin\$(TargetName)&quot;"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath="..\..\..\..\..\doc\src\utilities\sessions\sessions_quickstart.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ <File
+ RelativePath=".\index.html"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>

Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/doc/src/cgi.qbk
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/doc/src/cgi.qbk (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/doc/src/cgi.qbk 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -90,24 +90,12 @@
 
 [include:intro introduction.qbk]
 
-[/include quickstart.qbk]
-
 [include tutorial.qbk]
 
 [include overview.qbk]
 
 [include utilities.qbk]
 
-[/include user_guide.qbk]
-
-[/include:tutorial user_guide/tutorial.qbk]
-
-[/include:protocols user_guide/protocols.qbk]
-
-[/include:examples user_guide/examples.qbk]
-
-[/include:ug user_guide.qbk]
-
 [/xinclude ../cgi_dox.xml]
 
 [include:examples examples.qbk]
@@ -127,4 +115,3 @@
 [/xinclude quickref.xml]
 
 [/include reference.qbk]
-

Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/doc/src/utilities/sessions/sessions_quickstart.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/doc/src/utilities/sessions/sessions_quickstart.cpp (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/doc/src/utilities/sessions/sessions_quickstart.cpp 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -160,8 +160,13 @@
 {
   try
   {
- mycgi::request req; // Our custom request type.
- cgi::stencil resp; // A basic wrapper over cTemplate.
+ // Construct our custom request type, auto-parsing the request.
+ mycgi::request req;
+ // A basic wrapper over cTemplate. This constructor takes the directory
+ // where all "stencils" (eg. HTML templates) are kept. Your web server
+ // should be given read access to this directory.
+ cgi::stencil resp("../stencils/");
+ // The dummy user manager defined earlier in this example.
     user_manager user_mgr;
     
     resp.set("last_accessed",
@@ -169,6 +174,7 @@
 
     if (req.form.count("login"))
     {
+ // Allow users to log in to the application.
       if (user_mgr.login(req.form, req.session.info)) {
         // Mark the request so when you call `commit`, the session is saved.
         req.start_session();
@@ -185,20 +191,23 @@
     else
     if (req.form.count("logout"))
     {
+ // Allow users to log out.
       /*<
          We call `stop_session` to close the session. This call deletes the
          session data stored on the server, but leaves the session object
          stored in memory as is. The session cookie itself is only removed
          when you call `commit`, later.
- req.stop_session();
+
          Redirect the user. This causes a "Location" header to be added to
          the response.
>*/
+ req.stop_session();
       resp<< cgi::redirect(req, req.script_name());
     }
     else
     if (!req.session.info.name.empty())
     {
+ // Retrieve the session information for the user.
       resp.set("user_name", req.session.info.name);
       resp.set("user_email", req.session.info.email);
       resp.set("user_location", req.session.info.location);
@@ -222,7 +231,7 @@
        info, take a look at the ctemplate documentation:
        @ http://code.google.com/p/google-ctemplate/
>*/
- resp.expand("../stencils/login.html");
+ resp.expand("login.html");
     resp<< cgi::content_type("text/html");
     
     req.session.last_accessed = boost::posix_time::microsec_clock::universal_time();

Added: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/custom_sessions/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/custom_sessions/Jamfile.v2 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -0,0 +1,29 @@
+# Copyright (c) 2009 Darren Garvey
+#
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or copy
+# at http://www.boost.org/LICENSE_1_0.txt)
+
+project boost/cgi/example/cgi/sesssions ;
+
+exe cgi_sessions
+ :
+ main.cpp
+ :
+ <define>BOOST_CGI_ENABLE_SESSIONS
+ <library>/boost/cgi/
+ <library>/boost/filesystem/
+ <library>/boost/serialization/
+ ;
+
+
+# Our install rule (builds binaries and copies them to <location>)
+install install
+ :
+ cgi_sessions
+ :
+ <location>$(cgi-bin)
+ ;
+
+# Only install example if you use `bjam install' or equivalent
+explicit install ;

Added: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/custom_sessions/doc.qbk
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/custom_sessions/doc.qbk 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -0,0 +1,10 @@
+
+[section Custom Sessions]
+
+[import main.cpp]
+
+[custom_sessions]
+
+See the [@../../example/cgi/custom_sessions/main.cpp full source listing].
+
+[endsect][/ custom_sessions]

Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/echo/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/echo/main.cpp (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/echo/main.cpp 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -95,9 +95,22 @@
              "<input type=text name=name value='"
       << req.post["name"] << "' />"
              "<br />"
+ "<input type=checkbox name=checks value='one'"
+ << (req.post.matches("checks", "one") ? " checked='checked'" : "") << " />One"
+ "<br />"
+ "<input type=checkbox name=checks value='two'"
+ << (req.post.matches("checks", "two") ? " checked='checked'" : "") << " />Two"
+ "<br />"
+ "<input type=checkbox name=checks value='six'"
+ << (req.post.matches("checks", "six") ? " checked='checked'" : "") << " />Six"
+ "<br />"
+ "<input type=checkbox name=checks value='ten'"
+ << (req.post.matches("checks", "ten") ? " checked='checked'" : "") << " />Ten"
+ "<br />"
              "<input type=text name=hello value='"
       << req.post["hello"] << "' />"
              "<br />"
+ "<input type=file name=user_file /><br />"
              "<input type=file name=user_file />"
              "<input type=hidden name=cmd value=multipart_test />"
              "<br />";
@@ -108,7 +121,7 @@
       resp<< "Saved uploaded file to: " << part.path << "<br />";
   }
   resp<< "<input type=submit value=submit />"
- "<br />"
+ "<br />";
          "</form><p />";
 
   format_map(resp, req, req.env, "Environment Variables");

Added: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/sessions/doc.qbk
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/sessions/doc.qbk 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -0,0 +1,11 @@
+
+[section Sessions]
+
+[import main.cpp]
+
+[cgi_sessions]
+
+See the [@../../example/cgi/sessions/main.cpp full source listing].
+
+[endsect][/ cgi_sessions]
+

Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/stencil/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/stencil/main.cpp (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/stencil/main.cpp 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -73,15 +73,66 @@
   
   //// Test 5.
 
+ dictionary test5 = resp.add("test5");
+ test5.add("input")
+ .set("type", "text")
+ .set("name", "text")
+ .set("value", req.form["text"])
+ .show("label", "Text");
+
+ test5.add("input")
+ .set("type", "checkbox")
+ .set("name", "check")
+ .set("value", "one")
+ .show("label", "One")
+ .show(req.post.matches("check", "one") ? "checked" : "");
+ test5.add("input")
+ .set("type", "checkbox")
+ .set("name", "check")
+ .set("value", "two")
+ .show("label", "Two")
+ .show(req.post.matches("check", "two") ? "checked" : "");
+ test5.add("input")
+ .set("type", "checkbox")
+ .set("name", "check")
+ .set("value", "six")
+ .show("label", "Six")
+ .show(req.post.matches("check", "six") ? "checked" : "");
+ test5.add("input")
+ .set("type", "checkbox")
+ .set("name", "check")
+ .set("value", "ten")
+ .show("label", "Ten")
+ .show(req.post.matches("check", "ten") ? "checked" : "");
+
+ test5.add("input")
+ .set("type", "radio")
+ .set("name", "radio")
+ .set("value", "yes")
+ .show("label", "Yes")
+ .show(req.post.matches("radio", "yes") ? "checked" : "");
+ test5.add("input")
+ .set("type", "radio")
+ .set("name", "radio")
+ .set("value", "no")
+ .show("label", "No")
+ .show(req.post.matches("radio", "no") ? "checked " : "");
+
+ test5.add("input")
+ .set("type", "submit")
+ .set("value", "Submit");
+
+ //// Test 6.
+
   resp.add(stencil::section("embedded")).set("test", "passed");
   
- stencil::dictionary dict = resp.add("embedded");
+ dictionary dict = resp.add("embedded");
   dict.add("subsection") // returns a new sub-dictionary.
       .set("test", "passed again")
       .set("other", "(another field)");
   dict.set("test", "passed yet again", stencil::section("subsection"));
 
- //// Test 6.
+ //// Test 7.
 
   // Include another stencil into this one at marker {{>include}}.
   resp.include(

Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/stencil/stencil.html
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/stencil/stencil.html (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/stencil/stencil.html 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -14,7 +14,6 @@
 <html>
 <head>
     <title>CGI Stencils (using Google cTemplate)</title>
- <link rel="stylesheet" type="text/css" href="/css/style.css" />
 </head>
 <body>
 
@@ -75,8 +74,22 @@
     {{/section_with_variable}}
 </fieldset>
 
+{{#test5}}
 <fieldset>
- <legend>Test 5 - Embedded sections</legend>
+ <legend>Test 5 - Inputs</legend>
+ <form method="post">
+ {{#input}}
+ <input type="{{type}}"
+ name="{{name}}" value="{{value}}"{{#checked}} checked="checked"{{/checked}} />
+ {{#label}} : {{label}}{{/label}}
+ {{#input_separator}}<br />{{/input_separator}}
+ {{/input}}
+ </form>
+</fieldset>
+{{/test5}}
+
+<fieldset>
+ <legend>Test 6 - Embedded sections</legend>
     {{#embedded}}
     <ul>
         {{#subsection}}
@@ -87,7 +100,7 @@
 </fieldset>
 
 <fieldset>
- <legend>Test 6 - Include Files</legend>
+ <legend>Test 7 - Include Files</legend>
     {{>include}}
 </fieldset>
 

Added: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/async_echo/doc.qbk
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/async_echo/doc.qbk 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -0,0 +1,11 @@
+
+[section Asynchronous Echo]
+
+[import main.cpp]
+
+[fcgi_async_echo]
+
+See the [@../../example/fcgi/async_echo/main.cpp full source listing].
+
+[endsect][/ async_echo]
+

Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/async_echo/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/async_echo/main.cpp (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/async_echo/main.cpp 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -1,6 +1,6 @@
-// -- main.hpp --
+// -- fcgi/async_echo/main.hpp --
 //
-// Copyright (c) Darren Garvey 2007-2009.
+// Copyright (c) Darren Garvey 2007-2010.
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
@@ -170,12 +170,7 @@
   service s;
   
   // Make an `acceptor` for accepting requests through.
-#if defined (BOOST_WINDOWS)
- // Accept requests on port 8009.
- acceptor a(s, 8009);
-#else
   acceptor a;
-#endif // defined (BOOST_WINDOWS)
 
   //
   // After the initial setup, we can enter a loop to handle one request at a

Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/echo/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/echo/main.cpp (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/echo/main.cpp 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -139,7 +139,6 @@
          "<head>"
          "<body>"
            "Request ID = " << req.id() << "<br />"
- "Request Hash = " << req.hash() << "<br />"
            "Process ID = " << process_id() << "<br />"
            "<form method=post enctype=\"multipart/form-data\">"
              "<input type=text name=name value='"

Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/echo_threaded/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/echo_threaded/main.cpp (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/echo_threaded/main.cpp 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -83,7 +83,7 @@
 
 /// This function accepts and handles a single request.
 template<typename Acceptor, typename Request>
-int handle_request(Acceptor& a, Request& req, boost::system::error_code ec)
+int handle_request(Acceptor& a, Request& req)
 {
   //
   // Load in the request data so we can access it easily.
@@ -154,14 +154,9 @@
   int ret = commit(req, resp, 0);
 
   //a.async_accept(req, boost::bind(&handle_request, boost::ref(a), boost::ref(req), _1));
- a.async_accept(req,
- boost::bind(
- &handle_request<
- boost::fcgi::acceptor
- , boost::fcgi::request
- >
+ a.async_accept(boost::bind(
+ &handle_request<boost::fcgi::acceptor, boost::fcgi::request>
         , boost::ref(a)
- , boost::ref(req)
         , _1));
   
   return ret;
@@ -185,37 +180,26 @@
 
   // Make a `service` (more about this in other examples).
   service s;
-
- using boost::asio::ip::tcp;
 
   // Make an `acceptor` for accepting requests through.
- acceptor a(s, 8019); // The acceptor is for accepting requests.
+ acceptor a(s);
 
   //
   // After the initial setup, we can enter a loop to handle several requests
   // at a time until there's an error of some sort.
   //
- typedef std::vector<boost::shared_ptr<request> > request_queue;
- request_queue requests;
-
   // Handle 50 requests at a time.
- for (int i(0); i < 50; ++i)
+ for (int i(0); i < 2; ++i)
   {
- requests.push_back(request::create(s));
     //
     // Now we asychronously accept a request. This will return immediately.
     //
     // The second argument is the handler that is called when a request is
     // accepted.
     //
- a.async_accept(*requests[i],
- boost::bind(
- &handle_request<
- boost::fcgi::acceptor
- , boost::fcgi::request
- >
+ a.async_accept(boost::bind(
+ &handle_request<boost::fcgi::acceptor, boost::fcgi::request>
           , boost::ref(a)
- , boost::ref(*requests[i])
           , _1));
   }
   

Added: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/file_browser/doc.qbk
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/file_browser/doc.qbk 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -0,0 +1,11 @@
+
+[section File Browser]
+
+[import main.cpp]
+
+[cgi_file_browser]
+
+See the [@../../example/cgi/file_browser/main.cpp full source listing].
+
+[endsect][/ file_browser]
+

Added: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/upload/doc.qbk
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/upload/doc.qbk 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -0,0 +1,11 @@
+
+[section Uploads]
+
+[import main.cpp]
+
+[fcgi_upload]
+
+See the [@../../example/fcgi/upload/main.cpp full source listing].
+
+[endsect][/ uploads]
+

Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/test/run/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/test/run/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/test/run/Jamfile.v2 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -24,15 +24,15 @@
   :
     #[ run [ glob *.cpp ] ]
     
- #[ run cookie.cpp ]
- #[ run response.cpp ]
- #[ run cgi_simple_request.cpp ]
- #[ run name_test.cpp ]
- #[ run map_test.cpp ]
- #[ run parse_options.cpp ]
- #[ run data_map_proxy.cpp ]
+ [ run cookie.cpp ]
+ [ run response.cpp ]
+ [ run cgi_simple_request.cpp ]
+ [ run name_test.cpp ]
+ [ run map_test.cpp ]
+ [ run parse_options.cpp ]
+ [ run data_map_proxy.cpp ]
+ [ run request_data.cpp ]
     [ run sessions.cpp ]
- #[ run has_key.cpp ]
   ;
 
 #test-suite wget_test

Added: sandbox/SOC/2007/cgi/trunk/libs/cgi/test/run/request_data.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/test/run/request_data.cpp 2010-05-05 08:50:26 EDT (Wed, 05 May 2010)
@@ -0,0 +1,80 @@
+
+#include "boost/cgi/common/request_data.hpp"
+#include "boost/cgi/common/source_enums.hpp"
+#include <iostream>
+
+#define BOOST_TEST_MODULE request_data_test_suite
+#include <boost/test/unit_test.hpp>
+
+using namespace boost::cgi::common;
+using std::make_pair;
+
+template<typename Map>
+void test_map(Map& data)
+{
+ /// First check that upper case compares with lower case.
+ data.insert(make_pair("foo", "bar"));
+ data.insert(make_pair("pi", "3.1415962"));
+
+ BOOST_CHECK_EQUAL( data["foo"], "bar" );
+ BOOST_CHECK_EQUAL( data["FOO"], "bar" );
+ BOOST_CHECK_EQUAL( data.count("foo"), 1 );
+
+ // Now check
+
+ request_data<Map> proxy;
+ proxy.set(data);
+
+ BOOST_CHECK_EQUAL( proxy["foo"], "bar" );
+ BOOST_CHECK_EQUAL( proxy["FOO"], "bar" );
+ BOOST_CHECK_EQUAL( proxy.count("foo"), 1 );
+
+ /// Then check that lower case compares with upper case.
+ BOOST_CHECK_EQUAL( proxy.as<double>("pi"), 3.1415962 );
+ BOOST_CHECK_EQUAL( proxy.as<float>("PI"), 3.1415962 );
+
+ // Sanity check.
+ BOOST_CHECK_NE( proxy["nonfoo"], "dfpij" );
+
+ // Get either the value of a variable, or a default value.
+ BOOST_CHECK_EQUAL( proxy.pick("not_in_map", "some_value"), "some_value" );
+
+ // Get either the value of a variable, converted to the specified type, or a default value.
+ BOOST_CHECK_EQUAL( proxy.as<int>("foo", 1234), 1234 );
+ // Get a default-constructed int when "foo" can't be found in the map,
+ // or it's value can't be lexically casted to an int
+ // (works on any type supported by Boost.Lexical_cast).
+ BOOST_CHECK_EQUAL( proxy.as<int>("foo"), int() );
+ // The type of the return value can be automatically deduced.
+ BOOST_CHECK_EQUAL( proxy.as("foo", 1234.56), 1234.56 );
+}
+
+BOOST_AUTO_TEST_CASE( env_map_test )
+{
+ env_data m;
+ test_map(m);
+}
+
+BOOST_AUTO_TEST_CASE( get_map_test )
+{
+ get_data m;
+ test_map(m);
+}
+
+BOOST_AUTO_TEST_CASE( post_map_test )
+{
+ post_data m;
+ test_map(m);
+}
+
+BOOST_AUTO_TEST_CASE( cookie_map_test )
+{
+ cookie_data m;
+ test_map(m);
+}
+
+BOOST_AUTO_TEST_CASE( upload_map_test )
+{
+ upload_data m;
+ test_map(m);
+}


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