Boost logo

Boost-Commit :

From: drrngrvy_at_[hidden]
Date: 2007-07-15 14:21:07


Author: drrngrvy
Date: 2007-07-15 14:21:05 EDT (Sun, 15 Jul 2007)
New Revision: 7437
URL: http://svn.boost.org/trac/boost/changeset/7437

Log:
Add is_async metafunction to check if a protocol needs an asio::io_service. Then, boost::enable_if is used to select if the services need to be derived from asio::io_service::service. Synchronous basic_request<>s can then use the default constructor (example:
cgi::request req; // works
-- end example)
Add service_id and service_base (from Boost.Asio) for the above.

Added:
   sandbox/SOC/2007/cgi/boost/cgi/detail/service_base.hpp
   sandbox/SOC/2007/cgi/boost/cgi/detail/service_id.hpp
   sandbox/SOC/2007/cgi/boost/cgi/is_async.hpp
   sandbox/SOC/2007/cgi/boost/cgi/map.hpp
Removed:
   sandbox/SOC/2007/cgi/boost/cgi/connections/stdio_connection_impl.hpp
Text files modified:
   sandbox/SOC/2007/cgi/boost/cgi/basic_connection.hpp | 7 ++-
   sandbox/SOC/2007/cgi/boost/cgi/basic_request.hpp | 2
   sandbox/SOC/2007/cgi/boost/cgi/connection_base.hpp | 3 +
   sandbox/SOC/2007/cgi/boost/cgi/connections/async_stdio_connection.hpp | 16 +++++----
   sandbox/SOC/2007/cgi/boost/cgi/connections/stdio_connection.hpp | 18 +++++++---
   sandbox/SOC/2007/cgi/boost/cgi/connections/tcp_connection.hpp | 5 +++
   sandbox/SOC/2007/cgi/boost/cgi/request_impl/async_cgi_request_impl.hpp | 16 +++++++++
   sandbox/SOC/2007/cgi/boost/cgi/request_impl/cgi_request_impl.hpp | 26 ++++----------
   sandbox/SOC/2007/cgi/boost/cgi/request_impl/fcgi_request_impl.hpp | 7 +++-
   sandbox/SOC/2007/cgi/boost/cgi/request_service.hpp | 19 ++++++++---
   sandbox/SOC/2007/cgi/boost/cgi/service_impl/async_cgi_service_impl.hpp | 27 ++++++++++-----
   sandbox/SOC/2007/cgi/boost/cgi/service_impl/cgi_service_impl.hpp | 66 +++++++++++++++++++++++----------------
   12 files changed, 132 insertions(+), 80 deletions(-)

Modified: sandbox/SOC/2007/cgi/boost/cgi/basic_connection.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/basic_connection.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/basic_connection.hpp 2007-07-15 14:21:05 EDT (Sun, 15 Jul 2007)
@@ -16,14 +16,15 @@
 
 namespace cgi {
 
- template<typename ProtocolService, typename ConnectionType>
+ template< typename ConnectionType, typename ProtocolService>
   class basic_connection
   : connection_base
   //, connection_wrapper<ConnectionType>
   {
   public:
- typedef connection_impl<ProtocolService::protocol_type> impl_type;
- typedef boost::shared_ptr<conection_base> pointer;
+ typedef connection_impl<ConnectionType
+ , ProtocolService::protocol_type> impl_type;
+ typedef boost::shared_ptr<conection_base> pointer;
 
     explicit basic_connection(protocol_service_type& ps)
       : impl_(ps)

Modified: sandbox/SOC/2007/cgi/boost/cgi/basic_request.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/basic_request.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/basic_request.hpp 2007-07-15 14:21:05 EDT (Sun, 15 Jul 2007)
@@ -143,7 +143,7 @@
 
     void close(int http_status, int program_status)
     {
-
+ service_.close(http_status, program_status);
     }
 
     /// Reject the request with a standard '500 Internal Server Error' error

Modified: sandbox/SOC/2007/cgi/boost/cgi/connection_base.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/connection_base.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/connection_base.hpp 2007-07-15 14:21:05 EDT (Sun, 15 Jul 2007)
@@ -30,6 +30,9 @@
 
     template<typename ConstBufferSequence, typename Handler>
     virtual void async_write(ConstBufferSequence, Handler) = 0;
+
+ protected:
+ ~connection_base() { }
   };
 
 } // namespace cgi

Modified: sandbox/SOC/2007/cgi/boost/cgi/connections/async_stdio_connection.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/connections/async_stdio_connection.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/connections/async_stdio_connection.hpp 2007-07-15 14:21:05 EDT (Sun, 15 Jul 2007)
@@ -12,16 +12,14 @@
 namespace cgi {
 
  template<typename ProtocolService>
- class basic_connection<tags::stdio_async>
+ class basic_connection<tags::stdio_async, ProtocolService>
     : public connection_base
+ , public basic_connection<ProtocolService, tags::stdio>
   {
   public:
- typedef ProtocolService protocol_service_type;
-
     basic_connection(protocol_service_type& ps)
       : protocol_service_(ps)
- , in_(std::cin)
- , out_(std::cout)
+ , basic_connection<tags::stdio, ProtocolService>()
     {
     }
 
@@ -51,10 +49,14 @@
       
   private:
     protocol_service_type& protocol_service_;
- std::istream& in_;
- std::ostream& out_;
   };
 
+ template<typename ProtocolService = detail::async_cgi_service>
+ struct async_stdio_connection
+ {
+ typedef basic_connection<tags::async_cgi, ProtocolService> type;
+ };
+
 } // namespace cgi
 
 #endif // CGI_ASYNC_STDIO_CONNECTION_IMPL_HPP_INCLUDED__

Modified: sandbox/SOC/2007/cgi/boost/cgi/connections/stdio_connection.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/connections/stdio_connection.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/connections/stdio_connection.hpp 2007-07-15 14:21:05 EDT (Sun, 15 Jul 2007)
@@ -12,7 +12,7 @@
 namespace cgi {
 
   template<typename ProtocolService>
- class basic_connection<tags::stdio>
+ class basic_connection<tags::stdio, ProtocolService>
     : public connection_base
   {
   public:
@@ -31,7 +31,8 @@
     }
 
     template<typename MutableBufferSequence>
- std::size_t read_some(MutableBufferSequence buf, boost::system::error_code& ec)
+ std::size_t read_some(MutableBufferSequence buf
+ , boost::system::error_code& ec)
     {
       if( buf.data() != in_.rdbuf() )
         return in_.read(buf.data(), buf.size());
@@ -39,17 +40,22 @@
     }
 
     template<typename ConstBufferSequence>
- std::size_t write_some(ConstBufferSequence& buf, boost::system::error_code& ec)
+ std::size_t write_some(ConstBufferSequence& buf
+ , boost::system::error_code& ec)
     {
       return out_.write(buf.data(), buf.size());
     }
       
- private:
+ protected:
     std::istream& in_;
     std::ostream& out_;
   };
-
- typedef basic_connection<tags::stdio> stdio_connection;
+
+ template<typename ProtocolService = detail::cgi_service>
+ struct stdio_connection
+ {
+ typedef basic_connection<tags::stdio, ProtocolService> type;
+ };
 
 } // namespace cgi
 

Deleted: sandbox/SOC/2007/cgi/boost/cgi/connections/stdio_connection_impl.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/connections/stdio_connection_impl.hpp 2007-07-15 14:21:05 EDT (Sun, 15 Jul 2007)
+++ (empty file)
@@ -1,56 +0,0 @@
-// -- stdio_connection_impl.hpp --
-//
-// Copyright (c) Darren Garvey 2007.
-// 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 CGI_STDIO_CONNECTION_IMPL_HPP_INCLUDED__
-#define CGI_STDIO_CONNECTION_IMPL_HPP_INCLUDED__
-
-namespace cgi {
-
- template<typename ProtocolService>
- class basic_connection<tags::stdio>
- : public connection_base
- {
- public:
- typedef ProtocolService protocol_service_type;
-
- basic_connection()
- : in_(std::cin)
- , out_(std::cout)
- {
- }
-
- basic_connection(protocol_service_type&)
- : in_(std::cin)
- , out_(std::cout)
- {
- }
-
- template<typename MutableBufferSequence>
- std::size_t read_some(MutableBufferSequence buf, boost::system::error_code& ec)
- {
- if( buf.data() != in_.rdbuf() )
- return in_.read(buf.data(), buf.size());
- return buf.size();
- }
-
- template<typename ConstBufferSequence>
- std::size_t write_some(ConstBufferSequence& buf, boost::system::error_code& ec)
- {
- return out_.write(buf.data(), buf.size());
- }
-
- private:
- std::istream& in_;
- std::ostream& out_;
- };
-
- typedef basic_connection<tags::stdio> stdio_connection;
-
-} // namespace cgi
-
-#endif // CGI_STDIO_CONNECTION_IMPL_HPP_INCLUDED__
\ No newline at end of file

Modified: sandbox/SOC/2007/cgi/boost/cgi/connections/tcp_connection.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/connections/tcp_connection.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/connections/tcp_connection.hpp 2007-07-15 14:21:05 EDT (Sun, 15 Jul 2007)
@@ -34,6 +34,11 @@
     boost::asio::ip::tcp::socket sock_;
   };
 
+ template<typename ProtocolService = detail::fcgi_service>
+ struct tcp_connection
+ {
+ typedef basic_connection<tags::tcp_socket, ProtocolService> type;
+ };
 
 } // namespace cgi
 

Added: sandbox/SOC/2007/cgi/boost/cgi/detail/service_base.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/detail/service_base.hpp 2007-07-15 14:21:05 EDT (Sun, 15 Jul 2007)
@@ -0,0 +1,50 @@
+// -- service_base.hpp --
+// (taken from Boost.Asio)
+//
+// Copyright (c) 2003-2007 Christopher M. Kohlhoff
+// (chris at kohlhoff dot com)
+//
+// 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 CGI_DETAIL_SERVICE_ID_HPP_INCLUDED__
+#define CGI_DETAIL_SERVICE_ID_HPP_INCLUDED__
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
+
+#include <boost/asio/detail/push_options.hpp>
+
+#include <boost/asio/io_service.hpp>
+#include <boost/asio/detail/service_id.hpp>
+
+namespace cgi {
+ namespace detail {
+
+ // Special service base class to keep classes header-file only.
+ template <typename Type>
+ class service_base
+ : public boost::asio::io_service::service
+ {
+ public:
+ static boost::asio::detail::service_id<Type> id;
+
+ // Constructor.
+ service_base(boost::asio::io_service& io_service)
+ : boost::asio::io_service::service(io_service)
+ {
+ }
+ };
+
+ template <typename Type>
+ boost::asio::detail::service_id<Type> service_base<Type>::id;
+
+ } // namespace detail
+} // namespace cgi
+
+#include <boost/asio/detail/pop_options.hpp>
+
+#endif // CGI_DETAIL_SERVICE_ID_HPP_INCLUDED__

Added: sandbox/SOC/2007/cgi/boost/cgi/detail/service_id.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/detail/service_id.hpp 2007-07-15 14:21:05 EDT (Sun, 15 Jul 2007)
@@ -0,0 +1,38 @@
+// -- service_id.hpp --
+// (taken from Boost.Asio)
+//
+// Copyright (c) 2003-2007 Christopher M. Kohlhoff
+// (chris at kohlhoff dot com)
+//
+// 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 CGI_DETAIL_SERVICE_ID_HPP_INCLUDED__
+#define CGI_DETAIL_SERVICE_ID_HPP_INCLUDED__
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
+
+#include <boost/asio/detail/push_options.hpp>
+
+#include <boost/asio/io_service.hpp>
+
+namespace cgi {
+ namespace detail {
+
+ // Special derived service id type to keep classes header-file only.
+ template <typename Type>
+ class service_id
+ : public boost::asio::io_service::id
+ {
+ };
+
+ } // namespace detail
+} // namespace cgi
+
+#include <boost/asio/detail/pop_options.hpp>
+
+#endif // CGI_DETAIL_SERVICE_ID_HPP_INCLUDED__

Added: sandbox/SOC/2007/cgi/boost/cgi/is_async.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/is_async.hpp 2007-07-15 14:21:05 EDT (Sun, 15 Jul 2007)
@@ -0,0 +1,49 @@
+// -- is_async.hpp --
+//
+// Copyright (c) Darren Garvey 2007.
+// 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 CGI_IS_ASYNC_HPP_INCLUDED__
+#define CGI_IS_ASYNC_HPP_INCLUDED__
+
+namespace cgi {
+
+ template<typename Protocol>
+ struct is_aync
+ {
+ };
+
+ template<>
+ struct is_aync<tags::cgi>
+ {
+ typedef boost::mpl::bool_<false> type;
+ typedef type::value value;
+ };
+
+ template<>
+ struct is_aync<tags::async_cgi>
+ {
+ typedef boost::mpl::bool_<true> type;
+ typedef type::value value;
+ };
+
+ template<>
+ struct is_aync<tags::fcgi>
+ {
+ typedef boost::mpl::bool_<true> type;
+ typedef type::value value;
+ };
+
+ template<>
+ struct is_aync<tags::scgi>
+ {
+ typedef boost::mpl::bool_<true> type;
+ typedef type::value value;
+ };
+
+} // namespace cgi
+
+#endif // CGI_IS_ASYNC_HPP_INCLUDED__

Added: sandbox/SOC/2007/cgi/boost/cgi/map.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/map.hpp 2007-07-15 14:21:05 EDT (Sun, 15 Jul 2007)
@@ -0,0 +1,21 @@
+// -- map.hpp --
+//
+// Copyright (c) Darren Garvey 2007.
+// 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 CGI_HPP_INCLUDED__
+#define CGI_HPP_INCLUDED__
+
+#include <map>
+#include <string>
+
+namespace cgi {
+
+ typedef std::map<std::string,std::string> map;
+
+} // namespace cgi
+
+#endif // CGI_HPP_INCLUDED__

Modified: sandbox/SOC/2007/cgi/boost/cgi/request_impl/async_cgi_request_impl.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/request_impl/async_cgi_request_impl.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/request_impl/async_cgi_request_impl.hpp 2007-07-15 14:21:05 EDT (Sun, 15 Jul 2007)
@@ -1,13 +1,26 @@
+// -- async_cgi_request_impl.hpp --
+//
+// Copyright (c) Darren Garvey 2007.
+// 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 CGI_ASYNC_CGI_REQUEST_IMPL_HPP_INCLUDED__
 #define CGI_ASYNC_CGI_REQUEST_IMPL_HPP_INCLUDED__
 
+#include "cgi_service.hpp"
+#include "cgi_request_impl.hpp"
+
+// Make this ProtocolService-independent
+
 namespace cgi {
 
   class async_cgi_request_impl
     : public cgi_request_impl
   {
   public:
- //typedef std::map<std::string,std::string> map_type;
+ typedef cgi_service protocol_service_type;
 
     async_cgi_request_impl(protocol_service_type& protocol_service)
       : cgi_request_impl(protocol_service)
@@ -16,6 +29,7 @@
     }
 
   protected:
+ async_cgi_request_impl(); // private default constructor
     friend class async_cgi_service_impl;
 
     protocol_service_type& protocol_service_;

Modified: sandbox/SOC/2007/cgi/boost/cgi/request_impl/cgi_request_impl.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/request_impl/cgi_request_impl.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/request_impl/cgi_request_impl.hpp 2007-07-15 14:21:05 EDT (Sun, 15 Jul 2007)
@@ -10,13 +10,15 @@
 #define CGI_CGI_REQUEST_IMPL_HPP_INCLUDED__
 
 #include <map>
+#include <string>
 #include <boost/noncopyable.hpp>
 
-namespace cgi {
- namespace detail {
- typename std::map<std::string,std::string> map_type;
- } // namespace detail
+#include "http/status_code.hpp"
+#include
+
+// Make this ProtocolService-independent
 
+namespace cgi {
 
   /// Implementation for a standard CGI request
   /**
@@ -55,18 +57,6 @@
     http::status_code http_status_;
     request_status request_status_;
   };
-
-
- private: // functions
-
-
- private: // variables
- //map_type env_map_;
- map_type http_map_;
- map_type cookie_map_;
- map_type get_map_;
- map_type post_map_;
- };
 
   template<> inline const std::string&
   cgi_request_impl::var<tags::ENV>(const std::string& name)
@@ -89,8 +79,8 @@
   // throw std::logic_error("Can't get all environment vars as a map_type&");
   //}
 
- template<> inline cgi_request_impl::map_type&
- cgi_request_impl::var<tags::HTTP>() { return http_map_; }
+ //template<> inline cgi_request_impl::map_type&
+ //cgi_request_impl::var<tags::HTTP>() { return http_map_; }
 
   template<> inline cgi_request_impl::map_type&
   cgi_request_impl::var<tags::COOKIE>() { return cookie_map_; }

Modified: sandbox/SOC/2007/cgi/boost/cgi/request_impl/fcgi_request_impl.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/request_impl/fcgi_request_impl.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/request_impl/fcgi_request_impl.hpp 2007-07-15 14:21:05 EDT (Sun, 15 Jul 2007)
@@ -9,12 +9,13 @@
 #ifndef CGI_FCGI_REQUEST_IMPL_HPP_INCLUDED__
 #define CGI_FCGI_REQUEST_IMPL_HPP_INCLUDED__
 
+// Make this ProtocolService-independent
+
 namespace cgi {
 
   /// Implementation for a FastCGI request
   class fcgi_request_impl
   {
- fcgi_request() {} // private default constructor
   public:
     typedef tags::fastcgi protocol_type;
 
@@ -41,7 +42,7 @@
     map_type get_vars_;
 
     std::string stdin_buffer_;
- std::string data_buffer_;
+ std::string data_buffer_; // only needed for request_type::filter (not hugely important)
 
     /// Finished reading from stdin buffer (ie. POST data)
     bool stdin_read_;
@@ -49,6 +50,8 @@
     /// Finished reading from data buffer (for Filter requests)
     bool data_read_;
 
+ private:
+ fcgi_request() // private default constructor
     friend class fcgi_service_impl;
   };
 

Modified: sandbox/SOC/2007/cgi/boost/cgi/request_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/request_service.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/request_service.hpp 2007-07-15 14:21:05 EDT (Sun, 15 Jul 2007)
@@ -11,9 +11,21 @@
 
 namespace cgi {
 
+ /// The generic service class for basic_request<>s
+ /**
+ * 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>
   class request_service
- : public boost::asio::io_service::service
+ : public boost::enable_if<is_async<request_traits<Protocol
+ >::service_impl_type
+ >::value
+ , detail::service_base<request_service>
+ >::type
   {
     // The platform-specific implementation (only one for now)
     typedef detail::request_traits<Protocol>::service_impl_type
@@ -29,7 +41,7 @@
 
 
     /// The unique service identifier
- static boost::asio::io_service::id id;
+ //static boost::asio::io_service::id id;
 
     request_service(protocol_service_type& ps)
       : boost::asio::io_service::service(ps.io_service())
@@ -81,9 +93,6 @@
     service_impl_type& service_impl_;
   };
 
- template<typename Protocol>
- boost::asio::io_service::id request_service<Protocol>::id;
-
 } // namespace cgi
 
 #endif // CGI_REQUEST_SERVICE_HPP_INCLUDED

Modified: sandbox/SOC/2007/cgi/boost/cgi/service_impl/async_cgi_service_impl.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/service_impl/async_cgi_service_impl.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/service_impl/async_cgi_service_impl.hpp 2007-07-15 14:21:05 EDT (Sun, 15 Jul 2007)
@@ -1,3 +1,11 @@
+// -- async_cgi_service_impl.hpp --
+//
+// Copyright (c) Darren Garvey 2007.
+// 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 CGI_ASYNC_CGI_SERVICE_IMPL_HPP_INCLUDED__
 #define CGI_ASYNC_CGI_SERVICE_IMPL_HPP_INCLUDED__
 
@@ -34,19 +42,20 @@
     {
     public:
       load_handler(impl_type& impl, bool parse_stdin, Handler handler)
- : impl_(impl)
- , service_(impl.service_)
- , work_(service.io_service())
- , parse_stdin_(parse_stdin)
- , handler_(handler)
+ : impl_(impl)
+ , service_(impl.service_)
+ , work_(service.io_service())
+ , parse_stdin_(parse_stdin)
+ , handler_(handler)
       {
       }
 
- void operator()(const boost::system::error_code& error)
+ void operator()()
       {
- if (error)
- service_.post(boost::bind(&Handler, handler_, error));
-
+ boost::system::error_code ec
+ = cgi_service_impl::load(impl_, ec, handler_);
+
+ service_.post(boost::bind(&Handler, handler_, ec));
       }
     private:
       protocol_service_type& service_;

Modified: sandbox/SOC/2007/cgi/boost/cgi/service_impl/cgi_service_impl.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/service_impl/cgi_service_impl.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/service_impl/cgi_service_impl.hpp 2007-07-15 14:21:05 EDT (Sun, 15 Jul 2007)
@@ -1,6 +1,16 @@
+// -- cgi_service_impl.hpp --
+//
+// Copyright (c) Darren Garvey 2007.
+// 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 CGI_CGI_SERVICE_IMPL_HPP_INCLUDED__
 #define CGI_CGI_SERVICE_IMPL_HPP_INCLUDED__
 
+#include "detail/extract_params.hpp"
+
 namespace cgi {
 
   template<typename RequestImplType>
@@ -33,17 +43,17 @@
     /**
      * @param parse_stdin if true then STDIN data is also read/parsed
      */
- boost::system::error_code& load(boost::system::error_code& ec
- , bool parse_stdin)
+ boost::system::error_code
+ load(boost::system::error_code& ec, bool parse_stdin)
     {
       std::string request_method = meta_get("REQUEST_METHOD");
       if (request_method == "GET")
         if (parse_get_vars(ec))
- return ec;
+ return ec;
       else
       if (request_method == "POST" && parse_stdin)
- if (parse_post_vars(ec))
- return ec;
+ if (parse_post_vars(ec))
+ return ec;
 
       parse_cookie_vars(ec);
       return ec;
@@ -64,7 +74,6 @@
       return impl.connection_->write_some(buf, ec);
     }
 
-
     //template<typename VarType> map_type& var(impl_type&) const;
 
     const std::string& var(map_type& meta_data, const std::string& name
@@ -152,23 +161,22 @@
     }
 
   protected:
- boost::system::error_code& parse_get_vars(impl_type& impl
- , boost::system::error_code& ec)
- {
- // Make sure this function hasn't already been called
- BOOST_ASSERT( impl.get_vars_.empty() );
-
- extract_params(meta_env("QUERY_STRING")
- , impl.get_vars_
- , boost::char_separator<char>
- ("", "=&", boost::keep_empty_tokens)
- , ec);
+ /// Read and parse the cgi GET meta variables
+ boost::system::error_code&
+ parse_get_vars(impl_type& impl, boost::system::error_code& ec)
+ {
+ detail::extract_params(meta_env("QUERY_STRING")
+ , impl.get_vars_
+ , boost::char_separator<char>
+ ("", "=&", boost::keep_empty_tokens)
+ , ec);
 
       return ec;
     }
 
- boost::system::error_code& parse_cookie_vars(impl_type& impl
- , boost::system::error_code& ec)
+ /// Read and parse the HTTP_COOKIE meta variable
+ boost::system::error_code
+ parse_cookie_vars(impl_type& impl, boost::system::error_code& ec)
     {
       // Make sure this function hasn't already been called
       BOOST_ASSERT( impl.cookie_vars_.empty() );
@@ -177,17 +185,18 @@
       if (vars.empty())
         return ec;
 
- extract_params(meta_env("HTTP_COOKIE")
- , impl.cookie_vars_
- , boost::char_separator<char>
- ("", "=&", boost::keep_empty_tokens)
- , ec);
+ detail::extract_params(meta_env("HTTP_COOKIE")
+ , impl.cookie_vars_
+ , boost::char_separator<char>
+ ("", "=&", boost::keep_empty_tokens)
+ , ec);
 
       return ec;
     }
 
- boost::system::error_code& parse_post_vars(impl_type& impl
- , boost::system::error_code& ec)
+ /// Read and parse the cgi POST meta variables (greedily)
+ boost::system::error_code
+ parse_post_vars(impl_type& impl, boost::system::error_code& ec)
     {
       // Make sure this function hasn't already been called
       BOOST_ASSERT( impl.cookie_vars_.empty() );
@@ -201,8 +210,9 @@
       return ec;
     }
 
- boost::system::error_code& parse_one_post_var(impl_type& impl
- , boost::system::error_code& ec)
+ /// Read and parse a single cgi POST meta variable (greedily)
+ boost::system::error_code
+ parse_one_post_var(impl_type& impl, boost::system::error_code& ec)
     {
 # error "Not implemented"
       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