Boost logo

Boost-Commit :

From: lists.drrngrvy_at_[hidden]
Date: 2007-08-10 14:12:41


Author: drrngrvy
Date: 2007-08-10 14:12:39 EDT (Fri, 10 Aug 2007)
New Revision: 38579
URL: http://svn.boost.org/trac/boost/changeset/38579

Log:
* Altered basic_request<> so it takes a RequestService as its first template arguement instead of a Protocol (not quite done yet).
* Partly reshuffled directory structure so protocol-specific classes reside in boost/cgi/*cgi/ instead of being scattered around in places like request_impl/*, service_impl/* etc.
* Worked on restructuring docs into 'scripting' and 'advanced' subsections - corresponding to CGI and *CGI, respectively.
Added:
   sandbox/SOC/2007/cgi/boost/cgi/basic_acceptor_fwd.hpp (contents, props changed)
Removed:
   sandbox/SOC/2007/cgi/boost/cgi/logger.hpp
Properties modified:
   sandbox/SOC/2007/cgi/boost/cgi/basic_request_fwd.hpp (contents, props changed)
Text files modified:
   sandbox/SOC/2007/cgi/boost/cgi/basic_request.hpp | 14 ++-
   sandbox/SOC/2007/cgi/boost/cgi/basic_request_fwd.hpp | 5
   sandbox/SOC/2007/cgi/boost/cgi/cgi/acgi_request.hpp | 2
   sandbox/SOC/2007/cgi/boost/cgi/cgi/cgi_request.hpp | 13 ++-
   sandbox/SOC/2007/cgi/boost/cgi/cgi/cgi_service.hpp | 4
   sandbox/SOC/2007/cgi/boost/cgi/connections/tcp_socket.hpp | 28 +++++-
   sandbox/SOC/2007/cgi/boost/cgi/data_sink.hpp | 8 -
   sandbox/SOC/2007/cgi/boost/cgi/detail/common_headers.hpp | 2
   sandbox/SOC/2007/cgi/boost/cgi/detail/protocol_traits.hpp | 31 ++++++++
   sandbox/SOC/2007/cgi/boost/cgi/detail/throw_error.hpp | 2
   sandbox/SOC/2007/cgi/boost/cgi/reply.hpp | 142 ++++++++++++++++++++++++++++++---------
   sandbox/SOC/2007/cgi/boost/cgi/request_impl/cgi_request_impl_base.hpp | 3
   sandbox/SOC/2007/cgi/boost/cgi/request_impl/scgi_request_impl.hpp | 60 ++++++++++++++++
   sandbox/SOC/2007/cgi/boost/cgi/request_ostream.hpp | 82 ++++++++++------------
   sandbox/SOC/2007/cgi/boost/cgi/request_service.hpp | 49 +++++++------
   sandbox/SOC/2007/cgi/boost/cgi/service_impl/cgi_service_impl_base.hpp | 21 ++++-
   sandbox/SOC/2007/cgi/libs/cgi/doc/Jamfile.v2 | 16 +---
   sandbox/SOC/2007/cgi/libs/cgi/doc/src/cgi.qbk | 3
   sandbox/SOC/2007/cgi/libs/cgi/doc/src/user_guide/tutorial/accepting.qbk | 2
   sandbox/SOC/2007/cgi/libs/cgi/doc/src/user_guide/tutorial/meta_data.qbk | 8 +-
   sandbox/SOC/2007/cgi/libs/cgi/example/Jamfile.v2 | 15 ++-
   sandbox/SOC/2007/cgi/libs/cgi/example/acgi/Jamfile.v2 | 4
   sandbox/SOC/2007/cgi/libs/cgi/example/cgi/Jamfile.v2 | 6 -
   23 files changed, 360 insertions(+), 160 deletions(-)

Added: sandbox/SOC/2007/cgi/boost/cgi/basic_acceptor_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/basic_acceptor_fwd.hpp 2007-08-10 14:12:39 EDT (Fri, 10 Aug 2007)
@@ -0,0 +1,19 @@
+// -- basic_acceptor_fwd.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_BASIC_ACCEPTOR_FWD_HPP_INCLUDED__
+#define CGI_BASIC_ACCEPTOR_FWD_HPP_INCLUDED__
+
+namespace cgi {
+
+ template<typename>
+ class basic_acceptor;
+
+} // namespace cgi
+
+#endif // CGI_BASIC_ACCEPTOR_FWD_HPP_INCLUDED__

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-08-10 14:12:39 EDT (Fri, 10 Aug 2007)
@@ -195,7 +195,7 @@
       this->service.end(this->impl, http::internal_server_error);
     }
 
- void set_source(cgi::sink dest = reply)
+ void set_source(cgi::sink dest = stdout_)
     {
       boost::system::error_code ec;
       this->service(this->impl, dest, ec);
@@ -288,9 +288,9 @@
     }
 
     /// Find the cookie meta-variable matching name
- std::string meta_cookie(const std::string& name)
+ std::string cookie(const std::string& name)
     {
- return this->service.meta_cookie(this->impl, name);
+ return this->service.cookie(this->impl, name);
     }
 
     /// Find the environment meta-variable matching name
@@ -328,7 +328,7 @@
           return tmp;
       }
 
- tmp = meta_cookie(name);
+ tmp = cookie(name);
       if (!tmp.empty())
               return tmp;
 
@@ -441,6 +441,12 @@
     }
 
     /// Set a user cookie
+ /**
+ * Note: this must be called before you have finished outputting
+ * the reply headers or it will just appear as normal data
+ *
+ * ** Is this actually necessary? **
+ */
     void set_cookie(const std::string& name, const std::string& value)
     {
       return this->service.set_cookie(this->impl, name, value);

Modified: sandbox/SOC/2007/cgi/boost/cgi/basic_request_fwd.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/basic_request_fwd.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/basic_request_fwd.hpp 2007-08-10 14:12:39 EDT (Fri, 10 Aug 2007)
@@ -17,10 +17,9 @@
 
 namespace cgi {
 
- template<typename Protocol
- , typename Service = request_service<Protocol>
+ template<typename RequestService
+ , typename ProtocolService
           , enum role_type Role = responder
- , typename ProtocolService = basic_protocol_service<Protocol>
           , typename Allocator = std::allocator<char> >
   class basic_request;
 

Modified: sandbox/SOC/2007/cgi/boost/cgi/cgi/acgi_request.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/cgi/acgi_request.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/cgi/acgi_request.hpp 2007-08-10 14:12:39 EDT (Fri, 10 Aug 2007)
@@ -16,7 +16,7 @@
 
 namespace cgi {
 
- typedef basic_request<tags::acgi> acgi_request;
+ typedef basic_request<acgi_request_service> acgi_request;
 
 } // namespace cgi
 

Modified: sandbox/SOC/2007/cgi/boost/cgi/cgi/cgi_request.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/cgi/cgi_request.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/cgi/cgi_request.hpp 2007-08-10 14:12:39 EDT (Fri, 10 Aug 2007)
@@ -9,17 +9,22 @@
 #ifndef CGI_CGI_REQUEST_HPP_INCLUDED__
 #define CGI_CGI_REQUEST_HPP_INCLUDED__
 
+#include "request_service.hpp"
 #include "../tags.hpp"
 #include "../basic_request_fwd.hpp"
-#include "../service_impl/cgi_service_impl.hpp"
-#include "../request_impl/cgi_request_impl.hpp"
+#include "../basic_protocol_service_fwd.hpp"
+//#include "../service_impl/cgi_service_impl.hpp"
+//#include "../request_impl/cgi_request_impl.hpp"
 #include "../basic_request.hpp"
 
 namespace cgi {
 
- class cgi_service_impl;
+ class cgi_request_service;
 
- typedef basic_request<tags::cgi, cgi_service_impl> cgi_request;
+ typedef basic_request<
+ cgi_request_service,
+ basic_protocol_service<tags::cgi>
+ > cgi_request;
 
 } // namespace cgi
 

Modified: sandbox/SOC/2007/cgi/boost/cgi/cgi/cgi_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/cgi/cgi_service.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/cgi/cgi_service.hpp 2007-08-10 14:12:39 EDT (Fri, 10 Aug 2007)
@@ -25,9 +25,10 @@
   typedef basic_protocol_service<tags::acgi> cgi_service;
 
   /// A service 'owned' by a single user-supplied io_service
- typedef basic_protocol_service<tags::acgi, 0> cgi_sub_service;
+ //typedef basic_protocol_service<tags::acgi> cgi_sub_service;
 
   /// A service with a pool of io_services underneath
+ /*
   template<int IoServiceCount, typename PoolingPolicy = tags::round_robin>
   struct cgi_service_pool
     : public basic_protocol_service<tags::acgi, IoServiceCount, PoolingPolicy>
@@ -38,6 +39,7 @@
     {
     }
   };
+ */
 
 } // namespace cgi
 

Modified: sandbox/SOC/2007/cgi/boost/cgi/connections/tcp_socket.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/connections/tcp_socket.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/connections/tcp_socket.hpp 2007-08-10 14:12:39 EDT (Fri, 10 Aug 2007)
@@ -1,4 +1,4 @@
-// -- tcp_connection.hpp --
+// -- connections/tcp_socket.hpp --
 //
 // Copyright (c) Darren Garvey 2007.
 // Distributed under the Boost Software License, Version 1.0.
@@ -6,15 +6,16 @@
 // http://www.boost.org/LICENSE_1_0.txt)
 //
 ////////////////////////////////////////////////////////////////
-#ifndef CGI_TCP_CONNECTION_HPP_INCLUDED__
-#define CGI_TCP_CONNECTION_HPP_INCLUDED__
+#ifndef CGI_CONNECTIONS_TCP_SOCKET_HPP_INCLUDED__
+#define CGI_CONNECTIONS_TCP_SOCKET_HPP_INCLUDED__
 
-#include "../detail/push_options.hpp"
+#include <boost/shared_ptr.hpp>
 
-#include "../basic_connection.hpp"
-#include "../connection_base.hpp"
 #include "../tags.hpp"
 #include "../io_service.hpp"
+#include "../connection_base.hpp"
+#include "../basic_connection.hpp"
+#include "../detail/push_options.hpp"
 
 namespace cgi {
 
@@ -23,11 +24,19 @@
     : public connection_base
   {
   public:
+ typedef boost::shared_ptr<basic_connection<tags::tcp_socket> >
+ pointer;
+
     basic_connection(io_service& ios)
       : sock_(ios)
     {
     }
 
+ static pointer create(io_service& ios)
+ {
+ return static_cast<pointer>(new basic_connection<tags::tcp_socket>(ios));
+ }
+
     template<typename MutableBufferSequence>
     std::size_t read_some(MutableBufferSequence& buf)
     {
@@ -66,6 +75,11 @@
       sock_.async_write_some(buf, handler);
     }
 
+ void stop()
+ {
+ sock_.close();
+ }
+
   private:
     boost::asio::ip::tcp::socket sock_;
   };
@@ -83,4 +97,4 @@
 
 #include "../detail/pop_options.hpp"
 
-#endif // CGI_TCP_CONNECTION_HPP_INCLUDED__
+#endif // CGI_CONNECTIONS_TCP_SOCKET_HPP_INCLUDED__

Modified: sandbox/SOC/2007/cgi/boost/cgi/data_sink.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/data_sink.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/data_sink.hpp 2007-08-10 14:12:39 EDT (Fri, 10 Aug 2007)
@@ -12,11 +12,9 @@
 namespace cgi {
 
   enum sink
- { stdout_
- , stderr_
- , reply
- , log
- , reply_log = reply | log };
+ { stdout_ = 0
+ , stderr_ = 1
+ };
 
  namespace data_sink {
 

Modified: sandbox/SOC/2007/cgi/boost/cgi/detail/common_headers.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/detail/common_headers.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/detail/common_headers.hpp 2007-08-10 14:12:39 EDT (Fri, 10 Aug 2007)
@@ -18,7 +18,7 @@
 #include "../streambuf.hpp"
 #include "../basic_request.hpp"
 //#include "../basic_request_acceptor.hpp"
-//#include "../reply.hpp"
+#include "../reply.hpp"
 //#include "../logger.hpp"
 #include "../read.hpp"
 #include "../write.hpp"

Modified: sandbox/SOC/2007/cgi/boost/cgi/detail/protocol_traits.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/detail/protocol_traits.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/detail/protocol_traits.hpp 2007-08-10 14:12:39 EDT (Fri, 10 Aug 2007)
@@ -10,6 +10,7 @@
 #define CGI_REQUEST_TRAITS_HPP_INCLUDED__
 
 #include "../tags.hpp"
+#include "../basic_request_fwd.hpp"
 #include "../basic_connection_fwd.hpp"
 
 namespace cgi {
@@ -42,6 +43,14 @@
   class scgi_gateway_service;
   template<typename> class gateway_service;
 
+ class acgi_acceptor_service;
+ class scgi_acceptor_service;
+ class fcgi_acceptor_service;
+
+ class cgi_request_service;
+ class acgi_request_service;
+ class fcgi_request_service;
+ class scgi_request_service;
 
  namespace detail {
 
@@ -54,6 +63,10 @@
     struct protocol_traits<tags::cgi>
     {
       typedef cgi_request_impl impl_type;
+ typedef cgi_request_service request_service_type;
+ typedef basic_protocol_service<tags::cgi> protocol_service_type;
+ typedef basic_request<request_service_type, protocol_service_type>
+ request_type;
       typedef cgi_service_impl service_impl_type;
       typedef basic_connection<tags::stdio> connection_type;
 // typedef cgi_gateway_impl gateway_impl_type;
@@ -64,6 +77,10 @@
     struct protocol_traits<tags::async_cgi>
     {
       typedef async_cgi_request_impl impl_type;
+ typedef acgi_request_service request_service_type;
+ typedef basic_protocol_service<tags::acgi> protocol_service_type;
+ typedef basic_request<request_service_type, protocol_service_type>
+ request_type;
       typedef async_cgi_service_impl service_impl_type;
       typedef basic_connection<tags::async_stdio> connection_type;
       typedef async_cgi_gateway_impl gateway_impl_type;
@@ -74,7 +91,12 @@
     struct protocol_traits<tags::acgi>
     // : protocol_traits<tags::async_cgi>
     {
+ typedef protocol_traits<tags::acgi> type;
       typedef acgi_request_impl impl_type;
+ typedef acgi_request_service request_service_type;
+ typedef basic_protocol_service<tags::acgi> protocol_service_type;
+ typedef basic_request<request_service_type, protocol_service_type>
+ request_type;
       typedef acgi_service_impl service_impl_type;
       typedef basic_connection<tags::async_stdio> connection_type;
       typedef acgi_gateway_impl gateway_impl_type;
@@ -85,6 +107,10 @@
     struct protocol_traits<tags::fcgi>
     {
       typedef fcgi_request_impl impl_type;
+ typedef fcgi_request_service request_service_type;
+ typedef basic_protocol_service<tags::fcgi> protocol_service_type;
+ typedef basic_request<request_service_type, protocol_service_type>
+ request_type;
       typedef fcgi_service_impl service_impl_type;
       typedef basic_connection<tags::tcp_socket> connection_type;
       typedef fcgi_gateway_impl gateway_impl_type;
@@ -95,7 +121,12 @@
     struct protocol_traits<tags::scgi>
     {
       typedef scgi_request_impl impl_type;
+ typedef scgi_request_service request_service_type;
+ typedef basic_protocol_service<tags::scgi> protocol_service_type;
+ typedef basic_request<request_service_type, protocol_service_type>
+ request_type;
       typedef scgi_service_impl service_impl_type;
+ typedef scgi_acceptor_service acceptor_service_impl;
       typedef basic_connection<tags::tcp_socket> connection_type;
       typedef scgi_gateway_impl gateway_impl_type;
       typedef scgi_gateway_service gateway_service_type;

Modified: sandbox/SOC/2007/cgi/boost/cgi/detail/throw_error.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/detail/throw_error.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/detail/throw_error.hpp 2007-08-10 14:12:39 EDT (Fri, 10 Aug 2007)
@@ -10,6 +10,7 @@
 #define CGI_THROW_ERROR_HPP_INCLUDED__
 
 #include <boost/system/error_code.hpp>
+//#include <boost/system/system_error.hpp>
 
 namespace cgi {
  namespace detail {
@@ -18,6 +19,7 @@
    {
      if(ec)
        throw ec;
+// throw boost::system::system_error(ec);
    }
 
  } // namespace detail

Deleted: sandbox/SOC/2007/cgi/boost/cgi/logger.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/logger.hpp 2007-08-10 14:12:39 EDT (Fri, 10 Aug 2007)
+++ (empty file)
@@ -1,65 +0,0 @@
-// -- logger.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_LOGGER_HPP_INCLUDED__
-#define CGI_LOGGER_HPP_INCLUDED__
-
-#include "request_ostream.hpp"
-
-namespace cgi {
-
- /// The logger class: a helper class for writing to requests log streams
- /**
- * This simply initialises a cgi::ostream to write logging info to a request.
- *
- * The reply class is analogous to this except this works on the request's
- * error output rather than the standard output.
- */
- class logger
- : public request_ostream
- {
- public:
- /// Default constructor
- explicit logger()
- : request_ostream(tags::stderr)
- {
- }
-
- /// Construct with a particular buffer
- /**
- * Takes a buffer and uses it internally, does nothing with it on
- * destruction.
- */
- logger(std::streambuf* buf)
- : request_ostream(buf, tags::stderr)
- {
- }
-
- /// Construct, taking a buffer from an external source
- /**
- * Gets a buffer from the request/protocol service held by the request.
- *
- * <strike>
- * Takes a buffer from T (can be a model of ProtocolService or
- * CommonGatewayRequest) to use internally.
- * </strike>
- */
- template<typename CommonGatewayRequest>
- logger(CommonGatewayRequest& req)
- : request_ostream(req, tags::stderr)
- {
- }
-
- ~logger()
- {
- }
- };
-
-} // namespace cgi
-
-#endif // CGI_LOGGER_HPP_INCLUDED__

Modified: sandbox/SOC/2007/cgi/boost/cgi/reply.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/reply.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/reply.hpp 2007-08-10 14:12:39 EDT (Fri, 10 Aug 2007)
@@ -9,58 +9,136 @@
 #ifndef CGI_REPLY_HPP_INCLUDED__
 #define CGI_REPLY_HPP_INCLUDED__
 
-#include "detail/push_options.hpp"
-
-#include <ostream>
+#include <string>
 
+#include "detail/push_options.hpp"
 #include "request_ostream.hpp"
+#include "buffer.hpp"
 
 namespace cgi {
 
   /// The reply class: a helper for replying to requests
- /**
- * This simply initialises a cgi::ostream to write replies to a request.
- *
- * The logger class is analogous to this except this works on the request's
- * standard output rather than the error output.
- */
+
+ // The request_ostream is destined to become a basic_request_ostream
+//typedef request_ostream<> reply_;
+
+
   class reply
- : public request_ostream
+ : public cgi::request_ostream
   {
   public:
- /// Default constructor
- explicit reply()
+ reply(http::status_code sc = http::ok)
+ : cgi::request_ostream(sc)
     {
     }
+
+ reply(cgi::streambuf* buf, http::status_code sc = http::ok)
+ : cgi::request_ostream(buf, sc)
+ {
+ }
+
+ ~reply()
+ {
+ }
 
- /// Construct with a particular buffer
- /**
- * Takes a buffer and uses it internally, does nothing with it on
- * destruction.
- */
- reply(std::streambuf* buf)
- : request_ostream(buf)
+ /// Some helper functions for the basic CGI 1.1 meta-variables
+ void auth_type(const std::string& value)
     {
+ std::string str("Auth-type: ");
+ str += value;
+ this->headers_.push_back(cgi::buffer(str.c_str(), str.size()));
     }
 
- /// Construct, taking a buffer from an external source
- /**
- * Gets a buffer from the request/protocol service held by the request.
- *
- * <strike>
- * Takes a buffer from T (can be a model of ProtocolService or
- * CommonGatewayRequest) to use internally.
- * </strike>
- */
- template<typename CommonGatewayRequest>
- reply(CommonGatewayRequest& req)
- : request_ostream(req)
+ void content_length(const std::string& value)
     {
+ std::string str("Content-length: ");
+ str += value;
+ this->headers_.push_back(cgi::buffer(str.c_str(), str.size()));
     }
 
- ~reply()
+ /* void auth_type(const std::string& value)
+ {
+ std::string str("Auth-type: " + value);
+ headers_.push_back(cgi::buffer(str.c_str(), str.size()));
+ }
+
+ void auth_type(const std::string& value)
+ {
+ std::string str("Auth-type: " + value);
+ headers_.push_back(cgi::buffer(str.c_str(), str.size()));
+ }
+
+ void auth_type(const std::string& value)
+ {
+ std::string str("Auth-type: " + value);
+ headers_.push_back(cgi::buffer(str.c_str(), str.size()));
+ }
+
+ void auth_type(const std::string& value)
+ {
+ std::string str("Auth-type: " + value);
+ headers_.push_back(cgi::buffer(str.c_str(), str.size()));
+ }
+
+ void auth_type(const std::string& value)
     {
+ std::string str("Auth-type: " + value);
+ headers_.push_back(cgi::buffer(str.c_str(), str.size()));
     }
+ void content_length(const std::string& value)
+ { return this->service.meta_env(this->impl, "CONTENT_LENGTH"); }
+
+ void content_type(const std::string& value)
+ { return this->service.meta_env(this->impl, "CONTENT_TYPE"); }
+
+ void gateway_interface(const std::string& value)
+ { return this->service.meta_env(this->impl, "GATEWAY_INTERFACE"); }
+
+ void path_info(const std::string& value)
+ { return this->service.meta_env(this->impl, "PATH_INFO"); }
+
+ void path_translated(const std::string& value)
+ { return this->service.meta_env(this->impl, "PATH_TRANSLATED"); }
+
+ void query_string(const std::string& value)
+ { return this->service.meta_env(this->impl, "QUERY_STRING"); }
+
+ void remote_addr(const std::string& value)
+ { return this->service.meta_env(this->impl, "REMOTE_ADDR"); }
+
+ void remote_host(const std::string& value)
+ { return this->service.meta_env(this->impl, "REMOTE_HOST"); }
+
+ void remote_ident(const std::string& value)
+ { return this->service.meta_env(this->impl, "REMOTE_IDENT"); }
+
+ void remote_user(const std::string& value)
+ { return this->service.meta_env(this->impl, "REMOTE_USER"); }
+
+ void request_method(const std::string& value)
+ { return this->service.meta_env(this->impl, "REQUEST_METHOD"); }
+
+ void script_name(const std::string& value)
+ { return this->service.meta_env(this->impl, "SCRIPT_NAME"); }
+
+ void server_name(const std::string& value)
+ { return this->service.meta_env(this->impl, "SERVER_NAME"); }
+
+ void server_port(const std::string& value)
+ { return this->service.meta_env(this->impl, "SERVER_PORT"); }
+
+ void server_protocol(const std::string& value)
+ { return this->service.meta_env(this->impl, "SERVER_PROTOCOL"); }
+
+ void server_software(const std::string& value)
+ { return this->service.meta_env(this->impl, "SERVER_SOFTWARE"); }
+
+ private:
+ char c_;
+
+ };
+
+*/
   };
 
 } // namespace cgi

Modified: sandbox/SOC/2007/cgi/boost/cgi/request_impl/cgi_request_impl_base.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/request_impl/cgi_request_impl_base.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/request_impl/cgi_request_impl_base.hpp 2007-08-10 14:12:39 EDT (Fri, 10 Aug 2007)
@@ -53,9 +53,10 @@
     {
     }
 
- protected:
     conn_ptr connection() { return connection_; }
 
+ protected:
+
     friend class cgi_service_impl_base<RequestImpl>;
 
     map_type get_vars_;

Modified: sandbox/SOC/2007/cgi/boost/cgi/request_impl/scgi_request_impl.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/request_impl/scgi_request_impl.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/request_impl/scgi_request_impl.hpp 2007-08-10 14:12:39 EDT (Fri, 10 Aug 2007)
@@ -0,0 +1,60 @@
+// -- scgi_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_SCGI_REQUEST_IMPL_HPP_INCLUDED__
+#define CGI_SCGI_REQUEST_IMPL_HPP_INCLUDED__
+
+// Make this ProtocolService-independent
+
+namespace cgi {
+
+ /// Implementation for an SCGI request
+ class scgi_request_impl
+ {
+ public:
+ typedef tags::scgi protocol_type;
+
+ scgi_request_impl(protocol_service_type& pserv
+ , const role_type& role = role_type::responder
+ , boost::weak_ptr<connection_base> connection = NULL)
+ : protocol_service_(pserv)
+ , role_(role)
+ , connection_(connection)
+ , data_read_(role_ == role_type::filter ? false : true)
+ , stdin_read_(role_ == role_type::authorizer ? true : false)
+ {
+ }
+
+ protected:
+ protocol_service_type& protocol_service_;
+
+ /// The role the request plays
+ role_type role_;
+
+ map_type env_vars_;
+ map_type cookie_vars_;
+ map_type post_vars_;
+ map_type get_vars_;
+
+ std::string stdin_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_;
+
+ /// Finished reading from data buffer (for Filter requests)
+ bool data_read_;
+
+ private:
+ fcgi_request() // private default constructor
+ friend class fcgi_service_impl;
+ };
+
+} // namespace cgi
+
+#endif // CGI_SCGI_REQUEST_IMPL_HPP_INCLUDED__

Modified: sandbox/SOC/2007/cgi/boost/cgi/request_ostream.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/request_ostream.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/request_ostream.hpp 2007-08-10 14:12:39 EDT (Fri, 10 Aug 2007)
@@ -33,11 +33,14 @@
 #include "detail/push_options.hpp"
 
 #include <ostream>
+#include <sstream>
+#include <vector>
 //#include <streambuf>
 #include <boost/assert.hpp>
 #include <boost/bind.hpp>
 #include <boost/shared_ptr.hpp>
 #include <boost/system/error_code.hpp>
+#include <boost/asio.hpp>
 
 #include "streambuf.hpp"
 #include "buffer.hpp"
@@ -51,12 +54,14 @@
 
 namespace cgi {
 
- class request_ostream;
-
- namespace detail {
-
-
- } // namespace detail
+ /* Notes
+ * -----
+ *
+ * The constructor could take an additional bool which determines
+ * if any default headers are prepended to the message on sending
+ * eg. 'Content-type: text/plain' could by default be added, making
+ * the entry barrier lower and testing simpler.
+ */
 
 
   /// The ostream class: a stream interface for writing to requests
@@ -72,11 +77,9 @@
   public:
     /// Default constructor
     request_ostream(http::status_code sc = http::ok)
- : /*request_(NULL)
- , */buffer_(new cgi::streambuf())
+ : buffer_(new cgi::streambuf())
       , ostream_(buffer_.get())
       , http_status_(sc)
-// , destination_(destination)
     {
     }
 
@@ -85,11 +88,10 @@
      * Takes the buffer and uses it internally, does nothing with it on
      * destruction.
      */
- request_ostream(std::streambuf* buf, http::status_code sc = http::ok)
+ request_ostream(cgi::streambuf* buf, http::status_code sc = http::ok)
       : /*request_(NULL)
- , */ostream_(buf)
+ , */ostream_(buf)
       , http_status_(sc)
-// , destination_(destination)
     {
     }
 
@@ -119,6 +121,7 @@
     void clear()
     {
       ostream_.clear();
+ headers_.clear();
     }
 
     // provide this too?
@@ -133,10 +136,10 @@
       return write(str.c_str(), str.size());
     }
 
- template<typename MutableBufferSequence>
- std::size_t write(MutableBufferSequence& buf)
+ template<typename ConstBufferSequence>
+ std::size_t write(const ConstBufferSequence& buf)
     {
- ostream_.write(buf.data(), buf.size());
+ //ostream_.write(buf.data(), buf.size());
       return buf.size();
     }
 
@@ -159,7 +162,8 @@
     template<typename CommonGatewayRequest>
     void flush(CommonGatewayRequest& req)
     {
- cgi::write(req, cgi::buffer(*ostream_.rdbuf()));
+ cgi::write(req, headers_);
+ cgi::write(req, rdbuf()->data());
       // the above function will throw on an error
       clear();
     }
@@ -173,11 +177,12 @@
     boost::system::error_code& flush(CommonGatewayRequest& req
                                     , boost::system::error_code& ec)
     {
- if(!cgi::write(req, *ostream_.rdbuf(), ec))
+ if(!cgi::write(req, rdbuf()->data(), ec))
         clear();
       return ec;
     }
 
+ // Class for doing post-flush housekeeping (ie. clearing the stream data)
     template<typename Handler>
     class flush_handler
     {
@@ -190,8 +195,7 @@
 
       void operator()(boost::system::error_code& ec)
       {
- if(!ec)
- ostream_.clear();
+ if(!ec) ostream_.clear();
         handler_(ec);
       }
     private:
@@ -207,13 +211,12 @@
     template<typename CommonGatewayRequest, typename Handler>
     void async_flush(CommonGatewayRequest& req, Handler handler)
     {
- cgi::async_write(req, cgi::buffer(*ostream_.rdbuf())
- , cgi::request_ostream::flush_handler<Handler>(*this, handler
- , boost::arg<1>)));
+ cgi::async_write(req, rdbuf()->data()
+ , flush_handler<Handler>
+ (*this, handler, boost::arg<1>()));
     }
 
 
-
     /// Synchronously send the reply to the default request
     /**
      * Note: The data in the stream isn't cleared after this call, but the
@@ -243,6 +246,7 @@
     // return ec;
     //}
 
+
     /// Synchronously send the data via the supplied request
     /**
      * This call uses throwing semantics. ie. an exception will be thrown on
@@ -252,7 +256,7 @@
     template<typename CommonGatewayRequest>
     void send(CommonGatewayRequest& req)
     {
- cgi::write(req, *ostream_.rdbuf(), stdout_);
+ cgi::write(req, rdbuf()->data());
       req.set_status(http_status_);
     }
 
@@ -265,7 +269,7 @@
     boost::system::error_code& send(CommonGatewayRequest& req
                                    , boost::system::error_code& ec)
     {
- cgi::write(req, *ostream_.rdbuf(), ec, data_sink::stdout());
+ cgi::write(req, rdbuf()->data(), ec);
       req.set_status(http_status_);
       return ec;
     }
@@ -278,39 +282,29 @@
     void async_send(CommonGatewayRequest& req, Handler handler)
     {
       req.set_status(http_status_);
- cgi::async_write(req, *ostream_.rdbuf(), handler, data_sink::stdout()));
+ cgi::async_write(req, rdbuf()->data(), handler);
     }
 
     /// Get the buffer associated with the stream
- cgi::streambuf* rdbuf() const
+ cgi::streambuf* rdbuf()
     {
       return static_cast<cgi::streambuf*>(ostream_.rdbuf());
     }
 
- void set_status(http::status_code& num) { http_status_ = num; }
+ void set_status(http::status_code& num)
+ {
+ http_status_ = num;
+ }
 
     http::status_code& get_status()
     {
       return http_status_;
     }
 
- //request_base* request() const
- //{
- // return request_;
- //}
-
-// int destination() const
-// {
-// return destination_;
-// }
-
- private:
- /// The request associated with the ostream; can be NULL
- //request_base* request_;
-
+ protected:
+ std::vector<boost::asio::const_buffer> headers_;
     boost::shared_ptr<cgi::streambuf> buffer_;
     std::ostream ostream_;
-// std::type_info destination_;//data_sink destination_;
     http::status_code http_status_;
 
     template<typename T>
@@ -323,7 +317,7 @@
   template<typename T>
   request_ostream& operator<<(request_ostream& os, const T& t)
   {
- os<< t;
+ os.ostream_<< t;
     return os;
   }
 

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-08-10 14:12:39 EDT (Fri, 10 Aug 2007)
@@ -32,13 +32,7 @@
    */
   template<typename Protocol>
   class request_service
- //: public service_selector<Protocol>
     : public detail::service_base<request_service<Protocol> >
- //boost::enable_if<is_async<protocol_traits<Protocol
- // >::service_impl_type
- // >::value
- // , detail::service_base<request_service>
- // >::type
   {
     // The platform-specific implementation (only one for now)
     typedef typename detail::protocol_traits<Protocol>::service_impl_type
@@ -46,7 +40,8 @@
 
   public:
     typedef typename service_impl_type::impl_type impl_type;
-
+ typedef typename service_impl_type::implementation_type
+ implementation_type;
     typedef Protocol protocol_type;
     typedef basic_protocol_service<Protocol> protocol_service_type;
 
@@ -58,14 +53,12 @@
 
     request_service(cgi::io_service& ios)
       : detail::service_base<request_service<Protocol> >(ios)
- //: boost::asio::io_service::service(ps.io_service())
       , service_impl_(boost::asio::use_service<service_impl_type>(ios))
     {
     }
 
     request_service(protocol_service_type& ps)
       : detail::service_base<request_service<Protocol> >(ps.io_service())
- //: boost::asio::io_service::service(ps.io_service())
       , service_impl_(boost::asio::use_service<service_impl_type>(ps.io_service()))
     {
     }
@@ -111,13 +104,13 @@
       return service_impl_.is_open(impl);
     }
 
- template<typename ConstBufferSequence>
- std::size_t write_some(impl_type& impl, const ConstBufferSequence& buf)
+ boost::system::error_code&
+ set_header(impl_type& impl, const std::string& name
+ , const std::string& value, boost::system::error_code& ec)
     {
- boost::system::error_code ec;
- return service_impl_.write_some(impl, buf, ec);
- detail::throw_error(ec);
+ return service_impl_.set_header(impl, name, value, ec);
     }
+
 
     template<typename ConstBufferSequence>
     std::size_t write_some(impl_type& impl, const ConstBufferSequence& buf
@@ -127,23 +120,31 @@
     }
 
     template<typename MutableBufferSequence>
- std::size_t read_some(impl_type& impl, MutableBufferSequence buf)
+ std::size_t read_some(impl_type& impl, MutableBufferSequence buf
+ , boost::system::error_code& ec)
     {
- boost::system::error_code ec;
       return service_impl_.read_some(impl, buf, ec);
- detail::throw_error(ec);
     }
 
- template<typename MutableBufferSequence>
- std::size_t read_some(impl_type& impl, MutableBufferSequence buf
- , boost::system::error_code& ec)
+ std::string meta_get(impl_type& impl, const std::string& name
+ , boost::system::error_code& ec)
     {
- return service_impl_.read_some(impl, buf, ec);
+ return service_impl_.meta_get(impl, name, ec);
+ }
+
+ std::string meta_post(impl_type& impl, const std::string& name
+ , boost::system::error_code& ec)
+ {
+ return service_impl_.meta_post(impl, name, ec);
     }
+
+ std::string cookie(impl_type& impl, const std::string& name
+ , boost::system::error_code& ec)
+ {
+ return service_impl_.cookie(impl, name, ec);
+ }
+
   private:
- //typename boost::mpl::if_<typename is_async<protocol_type>::value
- // , boost::add_reference<service_impl_type>
- // , service_impl_type>::type
     service_impl_type& service_impl_;
   };
 

Modified: sandbox/SOC/2007/cgi/boost/cgi/service_impl/cgi_service_impl_base.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/service_impl/cgi_service_impl_base.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/service_impl/cgi_service_impl_base.hpp 2007-08-10 14:12:39 EDT (Fri, 10 Aug 2007)
@@ -64,7 +64,8 @@
     }
 
     template<typename MutableBufferSequence>
- std::size_t read_some(implementation_type& impl, const MutableBufferSequence& buf
+ std::size_t read_some(implementation_type& impl
+ , const MutableBufferSequence& buf
                          , boost::system::error_code& ec)
     {
       std::size_t s = impl.connection()->read_some(buf, ec);
@@ -72,7 +73,8 @@
     }
 
     template<typename ConstBufferSequence>
- std::size_t write_some(implementation_type& impl, const ConstBufferSequence& buf
+ std::size_t write_some(implementation_type& impl
+ , const ConstBufferSequence& buf
                           , boost::system::error_code& ec)
     {
       return impl.connection()->write_some(buf, ec);
@@ -87,9 +89,18 @@
       if ((typename map_type::iterator pos = meta_data.find(name))
              != meta_data.end())
       {
- return *pos;
+ return pos->second;
       }
       return std::string();
+ *********
+ for(typename map_type::iterator iter = meta_data.begin()
+ ; iter != meta_data.end()
+ ; ++iter)
+ {
+ if( iter->first == name )
+ return iter->second;
+ }
+ return "";
       **/
 
       if( meta_data.find(name) != meta_data.end() )
@@ -140,8 +151,8 @@
 
 
     /// Find the cookie meta-variable matching name
- std::string meta_cookie(implementation_type& impl, const std::string& name
- , boost::system::error_code& ec)
+ std::string cookie(implementation_type& impl, const std::string& name
+ , boost::system::error_code& ec)
     {
       return var(impl.cookie_vars_, name, ec);
     }

Modified: sandbox/SOC/2007/cgi/libs/cgi/doc/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/libs/cgi/doc/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/libs/cgi/doc/Jamfile.v2 2007-08-10 14:12:39 EDT (Fri, 10 Aug 2007)
@@ -3,15 +3,9 @@
 # subject to 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)
 
-<<<<<<< .mine
-project cgi/doc
- : build-dir ../../../../bin.v2
- ;
-=======
-project cgi/doc
- : build-dir ../../bin.v2
- ;
->>>>>>> .r38435
+#project boost/bwomcgi/doc
+# : build-dir ../../../bin.v2
+# ;
 
 import boostbook : boostbook ;
 import quickbook ;
@@ -49,8 +43,8 @@
     <xsl:param>boost.libraries=/usr/local/src/boost/libs/libraries.htm
     <xsl:param>boost.images=http://beta.boost.org/images
 # <xsl:param>toc.max.depth=10
-# <xsl:param>toc.section.depth=10
- <xsl:param>chunk.section.depth=4
+ <xsl:param>toc.section.depth=3
+ <xsl:param>chunk.section.depth=2
         ;
 
 #install html

Modified: sandbox/SOC/2007/cgi/libs/cgi/doc/src/cgi.qbk
==============================================================================
--- sandbox/SOC/2007/cgi/libs/cgi/doc/src/cgi.qbk (original)
+++ sandbox/SOC/2007/cgi/libs/cgi/doc/src/cgi.qbk 2007-08-10 14:12:39 EDT (Fri, 10 Aug 2007)
@@ -30,6 +30,7 @@
 [def __naming conventions__ [link boost.cgi.intro.naming_conventions naming conventions]]
 
 [def __tutorial__ [link boost.cgi.tutorial tutorial]]
+[def __reference__ [link /doc/html/cgi/reference.html reference]]
 
 [/
 [def __Service__ #link#to#service#concept#description#]
@@ -63,6 +64,8 @@
 
 [include user_guide/tutorial.qbk]
 
+[include user_guide/examples.qbk]
+
 [endsect]
 
 

Modified: sandbox/SOC/2007/cgi/libs/cgi/doc/src/user_guide/tutorial/accepting.qbk
==============================================================================
--- sandbox/SOC/2007/cgi/libs/cgi/doc/src/user_guide/tutorial/accepting.qbk (original)
+++ sandbox/SOC/2007/cgi/libs/cgi/doc/src/user_guide/tutorial/accepting.qbk 2007-08-10 14:12:39 EDT (Fri, 10 Aug 2007)
@@ -13,7 +13,7 @@
 
 All you need do is create an `*_acceptor` by passing an instance of a __ProtocolService__ to its constructor. The following member functions are available:
 
-[table xcgi_acceptor member functions
+[table [/xcgi_acceptor member functions]
   [[Function signature] [Purpose]]
   [
     [`void accept(xcgi_request& empty_request)`]

Modified: sandbox/SOC/2007/cgi/libs/cgi/doc/src/user_guide/tutorial/meta_data.qbk
==============================================================================
--- sandbox/SOC/2007/cgi/libs/cgi/doc/src/user_guide/tutorial/meta_data.qbk (original)
+++ sandbox/SOC/2007/cgi/libs/cgi/doc/src/user_guide/tutorial/meta_data.qbk 2007-08-10 14:12:39 EDT (Fri, 10 Aug 2007)
@@ -16,10 +16,10 @@
 
 [table Meta-data accessor functions
   [[Function signature] [Purpose]]
- [[`std::string meta_env(const std::string& name)`] [Takes the name of the environment variable wanted and returns the value associated with it.]]
- [[`std::string meta_get(const std::string& name)`][Takes the name of the CGI GET variable and returns the value associated with it (if any).]]
- [[`std::string meta_post(const std::string& name, bool greedy = true)`][Takes the name of the CGI POST variable and returns the value associated with it (if any). If `greedy == true` - which it is by default - then more data is read from the request if required until all of the POST data (ie. stdin) has been read.
-]]
+ [[`std::string meta_env(const std::string&)`] [Takes the name of the environment variable wanted and returns the value associated with it.]]
+ [[`std::string meta_get(const std::string&)`][Takes the name of the __GET__ variable and returns the value associated with it (if any).]]
+ [[`std::string meta_post(const std::string&, bool greedy = true)`][Takes the name of the __POST__ variable and returns the value associated with it (if any). If `greedy == true` - which it is by default - then more data is read from the request if required until all of the POST data has been read.]]
+ [[`std::string meta_form(const std::string&, bool greedy = true)`][Takes the name of either a __GET__ or __POST__ variable and returns the value associated with it (if any). If `greedy == true` - which it is by default - then more data is read from the request as required until all of the POST data has been read.]]
   [[`std::string meta_cookie(const std::string& name)`][Takes the name of the cookie variable and returns the value associated with it (if any).]]
   [[`std::string meta_var(const std::string& name, bool greedy = true)`][Takes the name of [*any] meta-variable and returns the value associated with it (if any). If `greedy == true` - which it is by default - then more data is read from the request if required until either the requested variable is found or all of the POST data has been read, which ever comes first.
 ]]

Modified: sandbox/SOC/2007/cgi/libs/cgi/example/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/libs/cgi/example/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/libs/cgi/example/Jamfile.v2 2007-08-10 14:12:39 EDT (Fri, 10 Aug 2007)
@@ -9,16 +9,21 @@
 
 local BOOST_ROOT = [ os.environ BOOST_ROOT ] ;
 
-project boost/cgi/examples
- : build-dir ../../../bin.v2
- ;
+#project boost/cgi/examples
+# : build-dir ../../../bin.v2
+# ;
 
 
 install examples
   : # the sources
- cgi
+ easy_cgi
     acgi
     reply
   : <location>/var/www/cgi-bin
   ;
-
\ No newline at end of file
+
+install scgi
+ : # the sources
+ scgi
+ : <location>/var/www/scgi-bin
+ ;
\ No newline at end of file

Modified: sandbox/SOC/2007/cgi/libs/cgi/example/acgi/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/libs/cgi/example/acgi/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/libs/cgi/example/acgi/Jamfile.v2 2007-08-10 14:12:39 EDT (Fri, 10 Aug 2007)
@@ -9,9 +9,9 @@
 
 local BOOST_ROOT = [ os.environ BOOST_ROOT ] ;
 
-project boost/cgi/examples/acgi
+#project boost/cgi/examples/acgi
 # : build-dir ../bin.v2
- ;
+# ;
 
 SOURCES = main ;
 

Modified: sandbox/SOC/2007/cgi/libs/cgi/example/cgi/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/libs/cgi/example/cgi/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/libs/cgi/example/cgi/Jamfile.v2 2007-08-10 14:12:39 EDT (Fri, 10 Aug 2007)
@@ -9,12 +9,8 @@
 
 local BOOST_ROOT = [ os.environ BOOST_ROOT ] ;
 
-project boost/cgi/examples/cgi
-# : build-dir ../bin.v2
- ;
-
 
-exe cgi
+exe easy_cgi
   :
     main.cpp
   :


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