Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58208 - in sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi: . acgi cgi common detail impl
From: lists.drrngrvy_at_[hidden]
Date: 2009-12-06 21:15:40


Author: drrngrvy
Date: 2009-12-06 21:15:37 EST (Sun, 06 Dec 2009)
New Revision: 58208
URL: http://svn.boost.org/trac/boost/changeset/58208

Log:
Removing acgi elements from code.
Added:
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/data_map_proxy.hpp (contents, props changed)
Removed:
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/acgi/
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/cgi_request_impl_base.hpp
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/cgi_service_impl_base.hpp
Text files modified:
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/basic_client.hpp | 1
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/basic_request.hpp | 117 +++++----------------------------------
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/cgi/request_service.hpp | 25 ++++----
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/cgi/service.hpp | 1
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/has_hidden_io_service.hpp | 4
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/request_base.hpp | 1
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/tags.hpp | 2
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/basic_io_object.hpp | 11 +--
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/protocol_traits.hpp | 61 --------------------
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/impl/form_parser.ipp | 13 ---
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/impl/response.ipp | 4 +
   11 files changed, 44 insertions(+), 196 deletions(-)

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/basic_client.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/basic_client.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/basic_client.hpp 2009-12-06 21:15:37 EST (Sun, 06 Dec 2009)
@@ -103,6 +103,7 @@
         status_ = closed_;
         connection_->close();
       }
+ return ec;
     }
 
     void close(boost::uint64_t app_status = 0)

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/basic_request.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/basic_request.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/basic_request.hpp 2009-12-06 21:15:37 EST (Sun, 06 Dec 2009)
@@ -27,6 +27,7 @@
 ///////////////////////////////////////////////////////////
 #include "boost/cgi/common/map.hpp"
 #include "boost/cgi/common/path_info.hpp"
+#include "boost/cgi/common/data_map_proxy.hpp"
 #include "boost/cgi/common/role_type.hpp"
 #include "boost/cgi/common/source_enums.hpp"
 #include "boost/cgi/common/parse_options.hpp"
@@ -62,15 +63,15 @@
    * Note: By default, synchronous protocols (ie. cgi) auto-load AND parse
    * STDIN,whereas async protocols don't.
    *
- * Note: The alternative functions which take a boost::system::error_code are
- * the non-throwing versions. Instead of a boost::system::system_error being
- * thrown in case of an error, the passed error_code will be set to the value
- * of the error, s.t. if (error) evaluates to true.`
+ * Note: The alternative functions which take a boost::system::error_code
+ * are the non-throwing versions. Instead of a boost::system::system_error
+ * being thrown in case of an error, the passed error_code will be set to
+ * the value of the error, s.t. if (error) evaluates to true.`
    *
    * Note: This class isn't thread safe: carrying around a mutex-per-request
- * seems prohibitively expensive. There could be functions which take a mutex
- * as an argument and lock it. (Async calls could get messy if you need a
- * protected request object).
+ * seems prohibitively expensive. There could be functions which take a
+ * mutex as an argument and lock it. (Async calls could get messy if you
+ * need a protected request object).
   **/
   template<typename RequestService
           , typename ProtocolService
@@ -95,104 +96,17 @@
     typedef typename implementation_type::client_type client_type;
     typedef typename implementation_type::buffer_type buffer_type;
     
- /// A proxy class to provide access to the data maps as member variables.
- /**
- * This 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 any type the user specifies.
- */
- template<typename MapType>
- struct data_map_proxy
- {
- typedef MapType map_type;
- typedef typename map_type::key_type key_type;
- typedef typename map_type::value_type value_type;
- typedef typename map_type::mapped_type mapped_type;
- typedef typename map_type::size_type size_type;
- typedef typename map_type::iterator iterator;
- typedef typename map_type::const_iterator const_iterator;
- typedef typename map_type::reverse_iterator reverse_iterator;
- typedef typename map_type::const_reverse_iterator const_reverse_iterator;
- typedef typename map_type::allocator_type allocator_type;
-
- void set(map_type& data) { impl = &data; }
-
- iterator begin() {
- BOOST_ASSERT(impl); return impl->begin(); }
- iterator end() {
- BOOST_ASSERT(impl); return impl->end(); }
- const_iterator begin() const {
- BOOST_ASSERT(impl); return impl->begin(); }
- const_iterator end() const {
- BOOST_ASSERT(impl); return impl->end(); }
- reverse_iterator rbegin() {
- BOOST_ASSERT(impl); return impl->rbegin(); }
- reverse_iterator rend() {
- BOOST_ASSERT(impl); return impl->rend(); }
- const_reverse_iterator rbegin() const {
- BOOST_ASSERT(impl); return impl->rbegin(); }
- const_reverse_iterator rend() const {
- BOOST_ASSERT(impl); return impl->rend(); }
-
- bool empty() { BOOST_ASSERT(impl); return impl->empty(); }
-
- void clear() { BOOST_ASSERT(impl); return impl->clear(); }
-
- size_type size() const { BOOST_ASSERT(impl); return impl->size(); }
-
- size_type count(const key_type& key) {
- BOOST_ASSERT(impl);
- return impl->count(key);
- }
-
- mapped_type const&
- get(key_type const& key, mapped_type const& default_) const
- {
- BOOST_ASSERT(impl);
- const_iterator iter = impl->find(key);
- return iter == impl->end() ? default_ : iter->second;
- }
-
- template<typename T>
- T as(key_type const& key) {
- BOOST_ASSERT(impl);
- const_iterator iter = impl->find(key);
- return iter == impl->end()
- ? T()
- : boost::lexical_cast<T>(val);
- }
-
- mapped_type& operator[](key_type const& varname) {
- BOOST_ASSERT(impl);
- return (*impl)[varname.c_str()];
- }
-
- mapped_type const& operator[](key_type const& varname) const {
- BOOST_ASSERT(impl);
- return (*impl)[varname.c_str()];
- }
-
- operator map_type&() { BOOST_ASSERT(impl); return *impl; }
- bool operator!() const { return !impl; }
-
- private:
- map_type* impl;
- };
-
- data_map_proxy<env_map> env;
- data_map_proxy<post_map> post;
- data_map_proxy<get_map> get;
- data_map_proxy<form_map> form;
- data_map_proxy<cookie_map> cookies;
+ 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;
 
     basic_request(const parse_options opts = parse_none
       , char** base_env = NULL)
         : detail::basic_io_object<service_type>()
     {
       if (opts > parse_none) load(opts, base_env);
- construct();
     }
 
     // Won't throw
@@ -328,6 +242,9 @@
         //if (content_length() >= BOOST_CGI_POST_MAX)
         // ec = common::error::max_post_exceeded;
         this->service.load(this->implementation, parse_opts, ec);
+
+ if (ec) return ec;
+
         // Load the environment passed by the user.
         if (base_environment)
           this->service.load_environment(
@@ -398,7 +315,7 @@
       this->service.close(this->implementation, http_status,
           program_status, ec);
       // Clear the request data so the object can be reused.
- clear();
+ //clear();
       detail::throw_error(ec);
       return program_status;
     }

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/cgi/request_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/cgi/request_service.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/cgi/request_service.hpp 2009-12-06 21:15:37 EST (Sun, 06 Dec 2009)
@@ -13,7 +13,7 @@
 
 #include "boost/cgi/common/tags.hpp"
 #include "boost/cgi/common/map.hpp"
-#include "boost/cgi/acgi/request_impl.hpp"
+#include "boost/cgi/cgi/request_impl.hpp"
 #include "boost/cgi/import/io_service.hpp"
 #include "boost/cgi/detail/service_base.hpp"
 #include "boost/cgi/detail/extract_params.hpp"
@@ -132,6 +132,10 @@
           && impl.status() <= common::aborted;
     }
 
+ void clear(implementation_type& impl) { }
+
+ int request_id(implementation_type& impl) { return 1; }
+
     /// Return the connection associated with the request
     implementation_type::client_type&
       client(implementation_type& impl)
@@ -139,14 +143,11 @@
       return impl.client_;
     }
 
- void clear(implementation_type& impl) { }
-
- int request_id(implementation_type& impl) { return 1; }
-
     // **FIXME** should return error_code
     int close(implementation_type& impl, common::http::status_code& http_s
       , int status, boost::system::error_code& ec)
     {
+ std::cerr<< "In close." << std::endl;
       impl.status() = common::closed;
       impl.http_status() = http_s;
       return status;
@@ -203,13 +204,6 @@
       return common::responder;
     }
 
- /// Set the http status (this does nothing for aCGI)
- void set_status(
- implementation_type& impl, common::http::status_code&)
- {
- // **FIXME**
- }
-
     /// Set the request status
     void set_status(
        implementation_type& impl, common::request_status status)
@@ -248,6 +242,13 @@
          bytes_read = read_some(impl, ec);
          bytes_left -= bytes_read;
       } while (!ec && bytes_left);
+
+ // Return an error, except ignore EOF, as this is expected.
+ if (ec)
+ if (ec == boost::cgi::common::error::eof)
+ ec = boost::system::error_code();
+ else
+ return ec;
 
       if (!impl.fp_)
         // Construct a form_parser instance.

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/cgi/service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/cgi/service.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/cgi/service.hpp 2009-12-06 21:15:37 EST (Sun, 06 Dec 2009)
@@ -19,6 +19,7 @@
   namespace cgi {
     typedef cgi_service service;
   }
+ typedef cgi_service service;
 
 BOOST_CGI_NAMESPACE_END
 

Added: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/data_map_proxy.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/data_map_proxy.hpp 2009-12-06 21:15:37 EST (Sun, 06 Dec 2009)
@@ -0,0 +1,121 @@
+
+#ifndef BOOST_CGI_DATA_MAP_PROXY_HPP_INCLUDED_20091206_
+#define BOOST_CGI_DATA_MAP_PROXY_HPP_INCLUDED_20091206_
+
+#include <boost/assert.hpp>
+///////////////////////////////////////////////////////////
+#include "boost/cgi/config.hpp"
+
+BOOST_CGI_NAMESPACE_BEGIN
+
+ namespace common {
+
+ /// A proxy class to provide access to the data maps as member variables.
+ /**
+ * This 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 any type the user specifies.
+ */
+ template<typename MapType>
+ struct data_map_proxy
+ {
+ typedef MapType map_type;
+ typedef typename map_type::key_type key_type;
+ typedef typename map_type::value_type value_type;
+ typedef typename map_type::mapped_type mapped_type;
+ typedef typename map_type::size_type size_type;
+ typedef typename map_type::iterator iterator;
+ typedef typename map_type::const_iterator const_iterator;
+ typedef typename map_type::reverse_iterator reverse_iterator;
+ typedef typename map_type::const_reverse_iterator const_reverse_iterator;
+ typedef typename map_type::allocator_type allocator_type;
+
+ void set(map_type& data) { impl = &data; }
+
+ iterator begin() {
+ BOOST_ASSERT(impl); return impl->begin(); }
+ iterator end() {
+ BOOST_ASSERT(impl); return impl->end(); }
+ const_iterator begin() const {
+ BOOST_ASSERT(impl); return impl->begin(); }
+ const_iterator end() const {
+ BOOST_ASSERT(impl); return impl->end(); }
+ reverse_iterator rbegin() {
+ BOOST_ASSERT(impl); return impl->rbegin(); }
+ reverse_iterator rend() {
+ BOOST_ASSERT(impl); return impl->rend(); }
+ const_reverse_iterator rbegin() const {
+ BOOST_ASSERT(impl); return impl->rbegin(); }
+ const_reverse_iterator rend() const {
+ BOOST_ASSERT(impl); return impl->rend(); }
+
+ bool empty() { BOOST_ASSERT(impl); return impl->empty(); }
+
+ void clear() { BOOST_ASSERT(impl); return impl->clear(); }
+
+ size_type size() const { BOOST_ASSERT(impl); return impl->size(); }
+
+ size_type count(const key_type& key) {
+ BOOST_ASSERT(impl);
+ return impl->count(key);
+ }
+
+ mapped_type const&
+ get(key_type const& key, mapped_type const& default_) const
+ {
+ BOOST_ASSERT(impl);
+ const_iterator iter = impl->find(key);
+ return iter == impl->end() ? default_ : iter->second;
+ }
+
+ template<typename T>
+ T get_as(key_type const& key, T const& default_) const
+ {
+ BOOST_ASSERT(impl);
+ const_iterator iter = impl->find(key);
+
+ T val (default_);
+
+ if (iter != impl->end()) {
+ try {
+ val = boost::lexical_cast<T>(iter->second);
+ } catch(...) {
+ // pass
+ }
+ }
+ return val;
+ }
+
+ template<typename T>
+ T as(key_type const& key) {
+ BOOST_ASSERT(impl);
+ const_iterator iter = impl->find(key);
+ return iter == impl->end()
+ ? T()
+ : boost::lexical_cast<T>(val);
+ }
+
+ mapped_type& operator[](key_type const& varname) {
+ BOOST_ASSERT(impl);
+ return (*impl)[varname.c_str()];
+ }
+
+ mapped_type const& operator[](key_type const& varname) const {
+ BOOST_ASSERT(impl);
+ return (*impl)[varname.c_str()];
+ }
+
+ operator map_type&() { BOOST_ASSERT(impl); return *impl; }
+ bool operator!() const { return !impl; }
+
+ private:
+ map_type* impl;
+ };
+
+ } // namespace common
+BOOST_CGI_NAMESPACE_END
+
+#endif // BOOST_CGI_DATA_MAP_PROXY_HPP_INCLUDED_20091206_
+

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/has_hidden_io_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/has_hidden_io_service.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/has_hidden_io_service.hpp 2009-12-06 21:15:37 EST (Sun, 06 Dec 2009)
@@ -24,8 +24,8 @@
    };
 
    template<>
- struct has_hidden_io_service<tags::acgi>
- : boost::mpl::bool_<false>
+ struct has_hidden_io_service<tags::cgi>
+ : boost::mpl::bool_<true>
    {
    };
 

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/request_base.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/request_base.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/request_base.hpp 2009-12-06 21:15:37 EST (Sun, 06 Dec 2009)
@@ -18,6 +18,7 @@
 #include <boost/asio/buffer.hpp>
 #include <boost/system/error_code.hpp>
 #include <boost/algorithm/string/find.hpp>
+#include <boost/fusion/include/vector.hpp>
 ////////////////////////////////////////////////////////////////
 #include "boost/cgi/common/map.hpp"
 #include "boost/cgi/common/form_part.hpp"

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/tags.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/tags.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/tags.hpp 2009-12-06 21:15:37 EST (Sun, 06 Dec 2009)
@@ -30,8 +30,6 @@
 
     // protocol types
     struct cgi {};
- struct async_cgi {}; // call it acgi?
- struct acgi {};
     struct fcgi {};
     struct scgi {};
 

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/basic_io_object.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/basic_io_object.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/basic_io_object.hpp 2009-12-06 21:15:37 EST (Sun, 06 Dec 2009)
@@ -65,7 +65,7 @@
           common::is_async<typename Service::protocol_type>,
           boost::mpl::not_<
             boost::is_same<
- typename Service::protocol_type, tags::acgi
+ typename Service::protocol_type, tags::cgi
>
>
>
@@ -116,13 +116,8 @@
   class basic_io_object<
       Service,
       typename boost::enable_if<
- boost::mpl::or_<
- boost::is_same<
- typename Service::protocol_type, tags::cgi
- >,
- boost::is_same<
- typename Service::protocol_type, tags::acgi
- >
+ boost::is_same<
+ typename Service::protocol_type, tags::cgi
>
>::type
>

Deleted: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/cgi_request_impl_base.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/cgi_request_impl_base.hpp 2009-12-06 21:15:37 EST (Sun, 06 Dec 2009)
+++ (empty file)
@@ -1,87 +0,0 @@
-// -- cgi_request_impl_base.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_REQUEST_IMPL_BASE_HPP_INCLUDED__
-#define CGI_CGI_REQUEST_IMPL_BASE_HPP_INCLUDED__
-
-#include <map>
-#include <string>
-///////////////////////////////////////////////////////////
-#include <boost/shared_ptr.hpp>
-#include <boost/noncopyable.hpp>
-#include <boost/fusion/support.hpp>
-#include <boost/fusion/include/vector.hpp>
-///////////////////////////////////////////////////////////
-#include "boost/cgi/common/map.hpp"
-#include "boost/cgi/common/role_type.hpp"
-#include "boost/cgi/http/status_code.hpp"
-#include "boost/cgi/connections/stdio.hpp"
-#include "boost/cgi/common/request_status.hpp"
-
-BOOST_CGI_NAMESPACE_BEGIN
- namespace detail {
-
- //Forward declaration
- template<typename T>
- class cgi_service_impl_base;
-
-
- /// Implementation for a standard CGI request
- /**
- * Note: This isn't noncopyable since there's no real reason it can't be
- * copied around. Since basic_request is noncopyable, basic copying will be
- * restricted but if someone really wants to copy the data, then they can.
- */
- template<typename Connection>
- class cgi_request_impl_base
-
- {
- public:
- typedef ::BOOST_CGI_NAMESPACE::common::map map_type;
- typedef Connection connection_type;
- typedef
- common::basic_client<Connection, common::tags::acgi> client_type;
- typedef typename connection_type::pointer conn_ptr;
-
- /// Constructor
- cgi_request_impl_base()
- : stdin_parsed_(false)
- , stdin_data_read_(false)
- , stdin_bytes_left_(-1)
- , http_status_(common::http::ok)
- , request_status_(common::unloaded)
- {
- }
-
- bool stdin_parsed() { return stdin_parsed_; }
- common::http::status_code& http_status() { return http_status_; }
- common::request_status& status() { return request_status_; }
-
- conn_ptr& connection() { return connection_; }
- public:
- //conn_ptr connection() { return connection_; }
-
- //friend class cgi_service_impl_base<RequestImpl>;
-
- public:
- bool stdin_parsed_;
- bool stdin_data_read_;
- std::size_t stdin_bytes_left_;
- protected:
-
- common::http::status_code http_status_;
- common::request_status request_status_;
-
- conn_ptr connection_;
- };
-
- } // namespace detail
-BOOST_CGI_NAMESPACE_END
-
-#endif // CGI_CGI_REQUEST_IMPL_BASE_HPP_INCLUDED__
-

Deleted: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/cgi_service_impl_base.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/cgi_service_impl_base.hpp 2009-12-06 21:15:37 EST (Sun, 06 Dec 2009)
+++ (empty file)
@@ -1,261 +0,0 @@
-// -- detail/cgi_service_impl_base.hpp --
-//
-// Copyright (c) Darren Garvey 2007-2008.
-// 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_BASE_HPP_INCLUDED__
-#define CGI_CGI_SERVICE_IMPL_BASE_HPP_INCLUDED__
-
-#include "boost/cgi/detail/push_options.hpp"
-
-#include <string>
-#include <cstdlib>
-///////////////////////////////////////////////////////////
-#include <boost/bind.hpp>
-#include <boost/assert.hpp>
-#include <boost/regex.hpp>
-#include <boost/tokenizer.hpp>
-#include <boost/lexical_cast.hpp>
-#include <boost/system/error_code.hpp>
-#include <boost/algorithm/string/find.hpp>
-///////////////////////////////////////////////////////////
-#include "boost/cgi/common/map.hpp"
-#include "boost/cgi/basic_client.hpp"
-#include "boost/cgi/common/is_async.hpp"
-#include "boost/cgi/common/role_type.hpp"
-#include "boost/cgi/common/form_part.hpp"
-#include "boost/cgi/detail/throw_error.hpp"
-#include "boost/cgi/common/form_parser.hpp"
-#include "boost/cgi/common/request_base.hpp"
-#include "boost/cgi/common/parse_options.hpp"
-#include "boost/cgi/common/request_status.hpp"
-#include "boost/cgi/detail/extract_params.hpp"
-#include "boost/cgi/detail/save_environment.hpp"
-
-BOOST_CGI_NAMESPACE_BEGIN
-// **FIXME** Wrong namespace (should be BOOST_CGI_NAMESPACE::detail?).
-
- template<typename RequestImplType>
- class cgi_service_impl_base
- : public common::request_base<cgi_service_impl_base<RequestImplType> >
- {
- public:
- typedef cgi_service_impl_base<RequestImplType> self_type;
- typedef common::request_base<self_type> base_type;
- typedef ::BOOST_CGI_NAMESPACE::common::map map_type;
- typedef typename
- RequestImplType::protocol_type protocol_type;
-
- struct implementation_type
- : RequestImplType
- , base_type::impl_base
- {
- typedef typename RequestImplType::client_type client_type;
- typedef detail::form_parser form_parser_type;
-
- implementation_type()
- : fp_(NULL)
- {
- }
-
- client_type client_;
-
- // The number of characters left to read (ie. "content_length -
- // bytes_read")
- std::size_t characters_left_;
-
- boost::scoped_ptr<form_parser_type> fp_;
- };
-
- template<typename Service>
- struct callback_functor
- {
- callback_functor(implementation_type& impl, Service* service)
- : impl_(impl)
- , service_(service)
- {
- }
-
- std::size_t operator()(boost::system::error_code& ec)
- {
- return service_->read_some(impl_, ec);
- }
-
- private:
- implementation_type& impl_;
- Service* service_;
- };
-
- cgi_service_impl_base()
- {
- }
-
- template<typename T>
- cgi_service_impl_base(T&)
- {
- }
-
- //typedef implementation_type impl_type;
-
- /// Return if the request is still open
- /**
- * For CGI, this always returns true. However, in the case that a
- * "Location: xxx" header is sent and the header is terminated, the
- * request can be taken to be 'closed'.
- */
- bool is_open(implementation_type& impl)
- {
- return impl.status() >= common::accepted
- && impl.status() <= common::aborted;
- }
-
- /// Return the connection associated with the request
- typename implementation_type::client_type&
- client(implementation_type& impl)
- {
- return impl.client_;
- }
-
- void clear(implementation_type& impl) { }
-
- int request_id(implementation_type& impl) { return 1; }
-
- // **FIXME** should return error_code
- int close(implementation_type& impl, common::http::status_code& http_s
- , int status, boost::system::error_code& ec)
- {
- impl.status() = common::closed;
- impl.http_status() = http_s;
- return status;
- }
-
- /// Synchronously read/parse the request data
- boost::system::error_code&
- load(implementation_type& impl, common::parse_options parse_opts
- , boost::system::error_code& ec)
- {
- if (parse_opts & common::parse_env)
- {
- if (read_env_vars(impl, ec)) // returns an error_code
- return ec;
- }
-
- std::string const& cl = env_vars(impl.vars_)["CONTENT_LENGTH"];
- impl.characters_left_
- = cl.empty() ? 0 : boost::lexical_cast<std::size_t>(cl);
- impl.client_.bytes_left()
- = impl.characters_left_;
- std::string const& request_method
- = env_vars(impl.vars_)["REQUEST_METHOD"];
-
- if ((request_method == "GET" || request_method == "HEAD")
- && parse_opts > common::parse_env
- && parse_opts & common::parse_get_only)
- {
- parse_get_vars(impl, ec);
- }
- else
- if (request_method == "POST"
- && (parse_opts & common::parse_post_only))
- {
- parse_post_vars(impl, ec);
- }
-
- if (ec) return ec;
-
- if (parse_opts & common::parse_cookie_only)
- {
- if (parse_cookie_vars(impl, ec)) // returns an error_code
- return ec;
- }
-
- set_status(impl, common::loaded);
-
- return ec;
- }
-
- common::role_type
- get_role(implementation_type& impl)
- {
- return responder;
- }
-
- /// Set the http status (this does nothing for aCGI)
- void set_status(
- implementation_type& impl, common::http::status_code&)
- {
- // **FIXME**
- }
-
- /// Set the request status
- void set_status(
- implementation_type& impl, common::request_status status)
- {
- impl.status() = status;
- }
-
- std::size_t
- read_some(implementation_type& impl, boost::system::error_code& ec)
- {
- return impl.client_.read_some(impl.prepare(64), ec);
- }
-
- protected:
- /// Read the environment variables into an internal map.
- template<typename RequestImpl>
- boost::system::error_code
- read_env_vars(RequestImpl& impl, boost::system::error_code& ec)
- {
- // Only call this once.
- if (!impl.env_parsed_)
- detail::save_environment(env_vars(impl.vars_));
- impl.env_parsed_ = true;
- return ec;
- }
-
- /// Read and parse the cgi POST meta variables (greedily)
- template<typename RequestImpl>
- boost::system::error_code
- parse_post_vars(RequestImpl& impl, boost::system::error_code& ec)
- {
- // **FIXME** use callback_functor<> in form_parser instead.
- std::size_t& bytes_left (impl.client_.bytes_left_);
- std::size_t bytes_read (0);
- do {
- bytes_read = read_some(impl, ec);
- bytes_left -= bytes_read;
- } while (!ec && bytes_left);
-
- if (!impl.fp_)
- // Construct a form_parser instance.
- impl.fp_.reset(new typename implementation_type::form_parser_type());
-
- // Create a context for this request.
- typename implementation_type::form_parser_type::context
- context
- = { env_vars(impl.vars_)["CONTENT_TYPE"]
- , impl.post_buffer_
- , impl.form_parts_
- , impl.client_.bytes_left_
- , post_vars(impl.vars_)
- , callback_functor<self_type>(impl, this)
- , impl.stdin_parsed_
- , env_vars(impl.vars_)["REMOTE_ADDR"]
- };
-
- // Parse the current request.
- impl.fp_->parse(context, ec);
-
- return ec;
- }
- };
-
-BOOST_CGI_NAMESPACE_END
-
-#include "boost/cgi/detail/pop_options.hpp"
-
-#endif // CGI_CGI_SERVICE_IMPL_HPP_INCLUDED__
-

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/protocol_traits.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/protocol_traits.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/protocol_traits.hpp 2009-12-06 21:15:37 EST (Sun, 06 Dec 2009)
@@ -29,18 +29,6 @@
 BOOST_CGI_NAMESPACE_BEGIN
 
   namespace cgi {}
- namespace acgi
- {
- //class acgi_service;
- class request_service;
- class request_impl;
- typedef common::basic_protocol_service<common::tags::acgi> service;
- typedef
- common::basic_request<
- acgi::request_service, acgi::service
- >
- request;
- }
   namespace fcgi
   {
   class fcgi_request_impl;
@@ -59,20 +47,14 @@
   // Forward declarations
 
   class cgi_request_impl;
- class acgi_request_impl;
- class async_cgi_request_impl;
   class fcgi_request_impl;
 
   class cgi_service_impl;
- class acgi_service_impl;
- class async_cgi_service_impl;
   class fcgi_service_impl;
 
- class acgi_acceptor_service;
   class fcgi_acceptor_service;
 
   class cgi_request_service;
- class acgi_request_service;
   class fcgi_request_service;
 
  namespace detail {
@@ -98,48 +80,7 @@
                 , protocol_service_type
> request_type;
       typedef cgi_service_impl service_impl_type;
- typedef common::basic_connection<tags::stdio> connection_type;
- typedef boost::none_t header_type;
- typedef common::role_type role_type;
- };
-
- template<>
- struct protocol_traits<tags::async_cgi>
- {
- typedef protocol_traits<tags::async_cgi> type;
- typedef async_cgi_request_impl impl_type;
- typedef acgi::request_service request_service_impl;
- typedef common::basic_protocol_service<
- tags::acgi
- > protocol_service_type;
- typedef common::basic_request<
- request_service_impl
- , protocol_service_type
- > request_type;
- typedef async_cgi_service_impl service_impl_type;
- typedef common::basic_connection<
- tags::async_stdio
- > connection_type;
- typedef boost::none_t header_type;
- typedef common::role_type role_type;
- };
-
- template<>
- struct protocol_traits<tags::acgi>
- {
- typedef protocol_traits<tags::acgi> type;
- typedef acgi::request_impl impl_type;
- typedef acgi::request_service request_service_impl;
- typedef common::basic_protocol_service<
- tags::acgi
- > protocol_service_type;
- typedef common::basic_request<
- request_service_impl
- , protocol_service_type
- > request_type;
- typedef common::basic_connection<
- tags::async_stdio
- > connection_type;
+ typedef common::basic_connection<tags::async_stdio> connection_type;
       typedef boost::none_t header_type;
       typedef common::role_type role_type;
     };

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/impl/form_parser.ipp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/impl/form_parser.ipp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/impl/form_parser.ipp 2009-12-06 21:15:37 EST (Sun, 06 Dec 2009)
@@ -16,7 +16,6 @@
 #include "boost/cgi/common/source_enums.hpp"
 #include "boost/cgi/config.hpp"
 
-#include <iostream> // **FIXME**
 #include <fstream>
 #include <boost/lexical_cast.hpp>
 #include <boost/algorithm/string/trim.hpp>
@@ -34,8 +33,6 @@
       
       BOOST_ASSERT(!ctx.content_type.empty());
 
- std::cerr<< "Parsing " << ctx.content_type << " form.\n";
-
       if (ctx.content_type.find(
          "application/x-www-form-urlencoded") != string_type::npos)
         parse_url_encoded_form(ec);
@@ -57,8 +54,6 @@
      string_type result;
      string_type name;
 
- std::cerr<< "Parsing data: " << str << '\n';
-
      if (str.size() == 0)
              return ec;
 
@@ -91,7 +86,6 @@
             break;
          case '&': // we now have the name/value pair, so save it
             // **FIXME** have to have .c_str() ?
- std::cerr<< "Data: " << name << " =" << result << '\n';
             context_->data_map[name.c_str()] = result;
             result.clear();
             name.clear();
@@ -102,8 +96,9 @@
      }
 #if defined(BOOST_CGI_KEEP_EMPTY_VARS)
       // save the last param (it won't have a trailing &)
- if( !name.empty() )
+ if( !name.empty() ) {
           context_->data_map[name.c_str()] = result;
+ }
 #endif // BOOST_CGI_KEEP_EMPTY_VARS
      return ec;
     }
@@ -140,8 +135,6 @@
       
       string_type meta (buffer.substr(offset,end-offset));
       
- std::cerr<< "Meta info: " << meta << std::endl;
-
       // sic - short-cut check for Content-Disposition.
       std::size_t pos1 = meta.find("isposition:"); // sic
       std::size_t pos2 = meta.find(";", pos1);
@@ -194,8 +187,6 @@
           string_type internal_filename(
             BOOST_CGI_UPLOAD_DIRECTORY+filename+"."+user_ip+"."+randomatter);
           part.path = internal_filename;
- std::cerr<< "Internal filename: " << internal_filename
- << std::endl;
           std::ofstream file (
               internal_filename.c_str()
             , std::ios::out | std::ios::binary);

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/impl/response.ipp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/impl/response.ipp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/impl/response.ipp 2009-12-06 21:15:37 EST (Sun, 06 Dec 2009)
@@ -235,7 +235,9 @@
       common::write(sws, headers, boost::asio::transfer_all(), ec);
     }
 
- common::write(sws, buffer_->data(), boost::asio::transfer_all(), ec);
+ // Only write the body if it is non-empty.
+ if (content_length())
+ common::write(sws, buffer_->data(), boost::asio::transfer_all(), ec);
 
     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