Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56353 - in sandbox/SOC/2007/cgi/branches/pickmeup: boost/cgi boost/cgi/common boost/cgi/connections boost/cgi/detail boost/cgi/fcgi boost/cgi/impl boost/cgi/utility libs/cgi/example/acgi/cookie_game libs/cgi/example/acgi/cookie_game2 libs/cgi/example/acgi/echo libs/cgi/example/acgi/login libs/cgi/example/cgi libs/cgi/example/cgi/echo libs/cgi/example/cgi/file_browser libs/cgi/example/cgi/hello_world libs/cgi/example/fcgi/echo libs/cgi/example/fcgi/hello_world libs/cgi/example/fcgi/server1 libs/cgi/example/fcgi/server2 libs/cgi/example/fcgi/server3 libs/cgi/example/scgi libs/cgi/test/compile libs/cgi/test/run
From: lists.drrngrvy_at_[hidden]
Date: 2009-09-22 05:37:53


Author: drrngrvy
Date: 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
New Revision: 56353
URL: http://svn.boost.org/trac/boost/changeset/56353

Log:
Fixes for linux. Moved commit.hpp into common/ folder out of utility/ and updated examples to use that rather than return_ macro. Generally fixed up examples to use current style. Removed req[env]-style accessors in favour of req.env, etc.
Added:
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/commit.hpp (contents, props changed)
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/file_browser/Jamfile.v2 (contents, props changed)
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/file_browser/doc.qbk (contents, props changed)
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/scgi/
Removed:
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/utility/commit.hpp
Text files modified:
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/basic_request.hpp | 91 ---------
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/path_info.hpp | 15
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/response.hpp | 8
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/connections/shareable_tcp_socket.hpp | 2
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/connections/stdio.hpp | 2
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/cgi_service_impl_base.hpp | 4
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/common_headers.hpp | 3
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/fcgi/acceptor_service_impl.hpp | 3
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/fcgi/client.hpp | 9
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/fcgi/specification.hpp | 4
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/impl/fcgi_request_service.ipp | 4
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/impl/form_parser.ipp | 8
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/impl/response.ipp | 12 +
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/utility.hpp | 1
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/cookie_game/main.cpp | 3
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/cookie_game2/Jamfile.v2 | 3
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/echo/main.cpp | 17
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/login/CheckCookie.cpp | 12
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/login/Login.cpp | 33 +--
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/login/Logout.cpp | 5
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/Jamfile.v2 | 6
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/echo/main.cpp | 366 ++++++++++-----------------------------
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/file_browser/main.cpp | 375 +++++++++++++++++++++++++++++----------
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/hello_world/main.cpp | 2
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/fcgi/echo/main.cpp | 10
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/fcgi/hello_world/main.cpp | 12 +
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/fcgi/server1/main.cpp | 18 -
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/fcgi/server1/server.hpp | 8
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/fcgi/server2/main.cpp | 28 +-
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/fcgi/server3/main.cpp | 13 -
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/compile/async_stdio_connection.cpp | 2
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/compile/cgi_header_check.cpp | 2
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/compile/shareable_tcp_connection.cpp | 2
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/compile/stdio_connection.cpp | 2
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/compile/tcp_connection.cpp | 2
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/run/acgi_simple_request.cpp | 10
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/run/request_test_template.hpp | 38 ++--
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/run/stdio_connection.cpp | 2
   38 files changed, 523 insertions(+), 614 deletions(-)

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-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -602,97 +602,6 @@
     {
       this->service.set_status(this->implementation, status);
     }
-
- ////////////////////////////////////////////////////////////
- // Note on operator[]
- // ------------------
- //
- // ** DEPRECATED **
- // These operator overloads are deprecated.
- // Use member variables instead, eg.
- // ``
- // request req;
- // req.get["whatever"]
- // req.env["request_method"]
- // ``
- // ** DEPRECATED **
- //
- // It is overloaded on different enum types to allow
- // compile-time retrieval of different data maps.
- //
-
- // The first three overloads are for directly looking into the
- // environment.
- // eg.
- // string_type& val = req["some name"];
-
- /// Get the value of the environment variable with name `n`.
- string_type& operator[](string_type const& n)
- {
- return env_vars(this->implementation.vars_)[n.c_str()];
- }
-
- /// Get the value of the environment variable with name `n`.
- string_type& operator[](const char* n)
- {
- return env_vars(this->implementation.vars_)[n];
- }
-
- /// Get the value of the environment variable with name `n`.
- string_type& operator[](common::name const& n)
- {
- return env_vars(this->implementation.vars_)[n];
- }
-
- /// Set up accessor functions for environment variables
- /**
- * if you have, eg.
- *
- * request req(...);
- * req[get] -> returns a -> get_map&
- * // similarly
- * req[post] -> returns a -> post_map&
- * // but, once gotcha is:
- * req[cookies] -> returns a ->cookie_map&
- *
- * You can use this just like a std::map<>`
- *
- * If you want to add a new data type to a request you need to:
- * > Update this file (just below)
- * > Update source_enums.hpp
- * > Update map.hpp with a new map type
- * > Update `data_map_type` in the `request_base` class
- */
- /// Get a `common::env_map&` of all the environment variables.
- BOOST_CGI_DETAIL_MAP_ACCESS(env)
- /// Get a `common::get_map&` of all the GET variables.
- BOOST_CGI_DETAIL_MAP_ACCESS(get)
- /// Get a `common::post_map&` of all the POST variables.
- BOOST_CGI_DETAIL_MAP_ACCESS(post)
- /// Get a `common::cookie_map&` of all the cookies.
- BOOST_CGI_DETAIL_MAP_ACCESS(cookie)
- /// Get a `common::session_map&` of all the session variables.
- BOOST_CGI_DETAIL_MAP_ACCESS(session)
-
- /// Get a `common::form_map&` of either the GET or POST variables.
- /**
- * Note that this dynamically finds the correct data map, so is
- * less efficient than the `get` or `post` accessors. The latter
- * is looked up statically.
- */
- form_map& operator[](common::form_data_type const&)
- {
- // Save the method as a case-insensitive string (saves on lookups too).
- common::name rm(request_method().c_str());
- if (rm == "GET" || rm == "HEAD")
- return get_vars(this->implementation.vars_);
- else
- if (rm == "POST")
- return post_vars(this->implementation.vars_);
- else
- return env_vars(this->implementation.vars_);
- }
- ////////////////////////////////////////////////////////////
   };
 
  } // namespace common

Added: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/commit.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/commit.hpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -0,0 +1,37 @@
+
+#ifndef BOOST_CGI_COMMIT_HPP_INCLUDED_
+#define BOOST_CGI_COMMIT_HPP_INCLUDED_
+
+#include <map>
+#include <boost/system/error_code.hpp>
+///////////////////////////////////////////////////////////
+#include "boost/cgi/common/return.hpp"
+#include "boost/cgi/detail/throw_error.hpp"
+
+namespace cgi {
+ namespace common {
+
+ /// Send a response to a reqest and close off the request.
+ template<typename Request, typename Response>
+ int commit(Request& req, Response& resp, int program_status = 0)
+ {
+ boost::system::error_code ec;
+ int ret (commit(req, resp, program_status, ec));
+ detail::throw_error(ec);
+ return ret;
+ }
+
+ /// Send a response to a reqest and close off the request.
+ template<typename Request, typename Response>
+ int commit(Request& req, Response& resp, int program_status
+ , boost::system::error_code& ec)
+ {
+ resp.send(req.client(), ec);
+ return ec ? -1 : req.close(resp.status(), program_status, ec);
+ }
+
+ } // namespace common
+} // namespace cgi
+
+#endif // BOOST_CGI_COMMIT_HPP_INCLUDED_
+

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/path_info.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/path_info.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/path_info.hpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -11,8 +11,6 @@
 namespace cgi {
  namespace common {
 
- namespace algo = boost::algorithm;
-
    struct path_info
    {
      typedef std::string value_type;
@@ -22,16 +20,19 @@
 
      template<typename S, typename P, typename A>
      path_info(basic_request<S,P,A> & request)
- : value(algo::trim_copy_if(request["path_info"],
- algo::is_any_of("/")))
+ : value(boost::algorithm::trim_copy_if(request.env["path_info"],
+ boost::algorithm::is_any_of("/")))
      {
- algo::split(parts, value, algo::is_any_of("/"));
+ boost::algorithm::split(
+ parts, value, boost::algorithm::is_any_of("/"));
      }
 
      path_info(value_type const& str)
- : value(algo::trim_copy_if(str, algo::is_any_of("/")))
+ : value(boost::algorithm::trim_copy_if(
+ str, boost::algorithm::is_any_of("/")))
      {
- algo::split(parts, value, algo::is_any_of("/"));
+ boost::algorithm::split(
+ parts, value, boost::algorithm::is_any_of("/"));
      }
      
      value_type& operator[](int i) { return parts[i]; }

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/response.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/response.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/response.hpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -169,11 +169,9 @@
     std::vector<string_type>& headers();
 
   protected:
- // Vector of all the headers, each followed by a CRLF
+ // Vector of all the headers, each followed by a CRLF
     std::vector<string_type> headers_;
     
- string_type charset_;
-
     // The buffer is a shared_ptr, so you can keep it cached elsewhere.
     boost::shared_ptr<common::streambuf> buffer_;
 
@@ -184,7 +182,9 @@
     // True if no more headers can be appended.
     bool headers_terminated_;
 
- private:
+ string_type charset_;
+
+ private:
     // Send the response headers and mark that they've been sent.
     template<typename ConstBufferSequence>
     void prepare_headers(ConstBufferSequence& headers);

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/connections/shareable_tcp_socket.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/connections/shareable_tcp_socket.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/connections/shareable_tcp_socket.hpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -107,7 +107,7 @@
     void wait()
     {
       scoped_lock_type lock(mutex_);
- if (locked_ = false)
+ if (locked_ == false)
         return;
       condition_.wait(lock);
     }

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/connections/stdio.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/connections/stdio.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/connections/stdio.hpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -11,7 +11,7 @@
 
 #include <cstdio>
 #include <string>
-#include <io.h>
+//#include <io.h>
 #include <fcntl.h>
 ///////////////////////////////////////////////////////////
 #include <boost/system/error_code.hpp>

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/cgi_service_impl_base.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/cgi_service_impl_base.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/cgi_service_impl_base.hpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -230,10 +230,10 @@
 
       if (!impl.fp_)
         // Construct a form_parser instance.
- impl.fp_.reset(new implementation_type::form_parser_type());
+ impl.fp_.reset(new typename implementation_type::form_parser_type());
 
       // Create a context for this request.
- implementation_type::form_parser_type::context
+ typename implementation_type::form_parser_type::context
           context
               = { env_vars(impl.vars_)["CONTENT_TYPE"]
                 , impl.post_buffer_

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/common_headers.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/common_headers.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/common_headers.hpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -18,9 +18,10 @@
 #include "boost/cgi/basic_request.hpp"
 #include "boost/cgi/common/header.hpp"
 #include "boost/cgi/common/map.hpp"
-#include "boost/cgi/common/return.hpp"
+#include "boost/cgi/common/commit.hpp"
 #include "boost/cgi/common/response.hpp"
 #include "boost/cgi/common/source_enums.hpp"
+#include "boost/cgi/common/parse_options.hpp"
 #include "boost/cgi/http/status_code.hpp"
 #include "boost/cgi/import/buffer.hpp"
 #include "boost/cgi/import/io_service.hpp"

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/fcgi/acceptor_service_impl.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/fcgi/acceptor_service_impl.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/fcgi/acceptor_service_impl.hpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -20,6 +20,7 @@
 #include <boost/utility/enable_if.hpp>
 #include <boost/system/error_code.hpp>
 ///////////////////////////////////////////////////////////
+#include "boost/cgi/fcgi/error.hpp"
 #include "boost/cgi/fcgi/request.hpp"
 #include "boost/cgi/import/io_service.hpp"
 #include "boost/cgi/detail/throw_error.hpp"
@@ -327,7 +328,7 @@
      {
        // We can't call accept on an open request (close it first).
        if (request.is_open())
- return handler(fcgi::error::accepting_on_an_open_request);
+ return handler(error::accepting_on_an_open_request);
 
        // If the client is open, make sure the request is clean.
        // ie. don't leak data from one request to another!

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/fcgi/client.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/fcgi/client.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/fcgi/client.hpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -196,9 +196,10 @@
         std::cerr<< "-" << new_buf_size << "-";
         // only write a maximum of 65535 bytes
         if (total_buffer_size + new_buf_size
- > fcgi::spec::max_packet_size::value)
+ > static_cast<std::size_t>(fcgi::spec::max_packet_size::value))
         {
- if (new_buf_size > fcgi::spec::max_packet_size::value)
+ if (new_buf_size > static_cast<std::size_t>(
+ fcgi::spec::max_packet_size::value))
           {
             std::cerr<< "Buffer too big." << std::endl;
             total_buffer_size = 65000;
@@ -228,7 +229,7 @@
         }
       }
       //std::cerr<< '\n';
- spec::stdout_header header(request_id_, total_buffer_size);
+ fcgi::spec::stdout_header header(request_id_, total_buffer_size);
       bufs[0] = header.data();
       out_header_[0] = static_cast<unsigned char>(1);
       out_header_[1] = static_cast<unsigned char>(6);
@@ -239,7 +240,7 @@
       out_header_[6] = static_cast<unsigned char>(0);
       out_header_[7] = 0;
       
- bool empty = bufs.empty();
+ //bool empty = bufs.empty();
       std::size_t size = bufs.size();
       typedef std::vector<boost::asio::const_buffer>::const_iterator
         iter_t;

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/fcgi/specification.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/fcgi/specification.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/fcgi/specification.hpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -321,7 +321,7 @@
      */
 
     struct max_packet_size
- : boost::mpl::int_<65535>
+ : boost::mpl::int_<65535u>
     {};
 
     struct header_length
@@ -499,7 +499,7 @@
       static std::string to_string(Array& a)
       {
         using namespace spec_detail;
- switch(begin_request::get_role(a))
+ switch(begin_request::role(a))
         {
         case RESPONDER:
           return "RESPONDER";

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/impl/fcgi_request_service.ipp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/impl/fcgi_request_service.ipp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/impl/fcgi_request_service.ipp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -194,9 +194,9 @@
       }
       else
       if (request_method == "POST"
- && opts > common::parse_env
           && opts & common::parse_post_only)
       {
+ std::cerr<< "Parsing post vars now.\n";
         if (parse_post_vars(impl, ec))
               return ec;
       }
@@ -218,7 +218,7 @@
       }
       else if (ec) return ec;
       
- bool check = impl.client_.is_open();
+ //bool check = impl.client_.is_open();
 
       return ec;
     }

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-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -17,6 +17,7 @@
 
 #include <iostream> // **FIXME**
 #include <fstream>
+#include <boost/lexical_cast.hpp>
 #include <boost/algorithm/string/trim.hpp>
 #include <boost/random/mersenne_twister.hpp>
 
@@ -31,10 +32,12 @@
       
       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);
- else
+ else
       if (ctx.content_type.find(
          "multipart/form-data") != string_type::npos)
         parse_multipart_form(ec);
@@ -52,6 +55,8 @@
      string_type result;
      string_type name;
 
+ std::cerr<< "Parsing data: " << str << '\n';
+
      if (str.size() == 0)
              return ec;
 
@@ -84,6 +89,7 @@
             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();

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-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -69,11 +69,16 @@
   template<typename T> BOOST_CGI_INLINE
   basic_response<T>::basic_response(http::status_code sc)
     : buffer_(new common::streambuf())
+#if defined (BOOST_WINDOWS)
     , ostream_(buffer_.get(), std::ios::out | std::ios::binary)
+#else
+ , ostream_(buffer_.get())
+#endif // defined (BOOST_WINDOWS)
     , http_status_(sc)
     , headers_terminated_(false)
     , charset_("ISO-8859-1")
   {
+ //ostream_.openmode =
   }
 
   /// Construct with a particular buffer
@@ -84,11 +89,16 @@
   template<typename T> BOOST_CGI_INLINE
   basic_response<T>::basic_response(common::streambuf* buf,
       http::status_code sc)
- : ostream_(buf, std::ios::out | std::ios::binary)
+#if defined (BOOST_WINDOWS)
+ : ostream_(buf, std::ios::out | std::ios::binary)
+#else
+ : ostream_(buf)
+#endif // defined (BOOST_WINDOWS)
     , http_status_(sc)
     , headers_terminated_(false)
     , charset_("ISO-8859-1")
   {
+ //ostream_.openmode = std::ios::out | std::ios::binary;
   }
 
   template<typename T> BOOST_CGI_INLINE

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/utility.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/utility.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/utility.hpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -13,6 +13,5 @@
 #include "boost/cgi/utility/has_key.hpp"
 #include "boost/cgi/utility/get.hpp"
 #include "boost/cgi/utility/redirect.hpp"
-#include "boost/cgi/utility/commit.hpp"
 
 #endif // CGI_UTILITY_HPP_INCLUDED__

Deleted: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/utility/commit.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/utility/commit.hpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
+++ (empty file)
@@ -1,37 +0,0 @@
-
-#ifndef BOOST_CGI_COMMIT_HPP_INCLUDED_
-#define BOOST_CGI_COMMIT_HPP_INCLUDED_
-
-#include <map>
-#include <boost/system/error_code.hpp>
-///////////////////////////////////////////////////////////
-#include "boost/cgi/common/return.hpp"
-#include "boost/cgi/detail/throw_error.hpp"
-
-namespace cgi {
- namespace common {
-
- /// Send a response to a reqest and close off the request.
- template<typename Request, typename Response>
- int commit(Request& req, Response& resp, int program_status = 0)
- {
- boost::system::error_code ec;
- int ret (commit(req, resp, program_status, ec));
- detail::throw_error(ec);
- return ret;
- }
-
- /// Send a response to a reqest and close off the request.
- template<typename Request, typename Response>
- int commit(Request& req, Response& resp, int program_status
- , boost::system::error_code& ec)
- {
- resp.send(req.client(), ec);
- return ec ? -1 : req.close(resp.status(), program_status, ec);
- }
-
- } // namespace common
-} // namespace cgi
-
-#endif // BOOST_CGI_COMMIT_HPP_INCLUDED_
-

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/cookie_game/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/cookie_game/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/cookie_game/main.cpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -215,8 +215,7 @@
   {
     resp<< cookie("name")
         << redirect(req, req.script_name()); // redirect them.
- resp.send(req.client());
- return 0;
+ return commit(req, resp);
   }
 
   if (req.form.count("name"))

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/cookie_game2/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/cookie_game2/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/cookie_game2/Jamfile.v2 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -8,13 +8,14 @@
 
 import os ;
 
+lib ctemplate ;
 #lib ctemplate : : <name>ctemplate <search>C:/Packages/ctemplate/lib ;
 
 exe acgi_cookie_game2
   :
     main.cpp
   :
- <library>/user-config/ctemplate
+ <library>ctemplate
   :
     <linkflags>-lctemplate
   ;

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/echo/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/echo/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/echo/main.cpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -20,7 +20,6 @@
 #include <vector>
 ///////////////////////////////////////////////////////////
 #include "boost/cgi/acgi.hpp"
-#include "boost/cgi/utility/has_key.hpp"
 
 using namespace std;
 using namespace boost::acgi;
@@ -109,7 +108,7 @@
         resp<< "You're only allowed to upload 1k of data.\n"
             << "Content-length: " << req.content_length();
         // Exit the application here.
- return_(resp, req, 0);
+ commit(req, resp);
       }
       
       // If execution reaches here we can parse all other
@@ -122,7 +121,7 @@
             << "Error " << ec.value() << ": " << ec.message() << "<p />"
                "--Original message follows--"
                "<p />";
- resp.send(req.client());
+ return commit(req, resp);
       }
 
       resp<< content_type("text/html") <<
@@ -143,11 +142,11 @@
                "Process ID = " << process_id() << "<br />"
                "<form method=POST enctype='application/x-www-form-urlencoded'>"
                  "<input type=text name=name value='"
- << (has_key(req.post,"name") ? req.post["name"] : "")
+ << (req.post.count("name") ? req.post["name"] : "")
           << "' />"
                  "<br />"
                  "<input type=text name=hello value='"
- << (has_key(req.post,"hello") ? req.post["hello"] : "")
+ << (req.post.count("hello") ? req.post["hello"] : "")
           << "' />"
                  "<br />"
                  "<input type=file name=user_file />"
@@ -161,7 +160,7 @@
       format_map(resp, req.post, "POST Variables");
       format_map(resp, req.cookies, "Cookie Variables");
 
- if (req["request_method"] == "GET")
+ if (req.request_method() == "GET")
       {
         resp<< "<pre>";
         BOOST_FOREACH(char& ch, req.post_buffer())
@@ -173,7 +172,7 @@
                "</html>";
       }
 
- return_(resp, req, 0); // All ok.
+ return commit(req, resp); // All ok.
 
     }
     catch(boost::system::system_error& ec)
@@ -182,14 +181,14 @@
       resp<< content_type("text/plain") << "Error " << ec.code() << ": "
           << ec.what()
           << http::internal_server_error; // note the status_code
- return_(resp, req, 1);
+ return commit(req, resp, 1);
     }
     catch(std::exception* e)
     {
       response resp;
       resp<< content_type("text/plain") << "Error: " << e->what()
           << http::internal_server_error;
- return_(resp, req, 2);
+ return commit(req, resp, 2);
     }
 
     // The request object will be destroyed before the next exception handlers

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/login/CheckCookie.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/login/CheckCookie.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/login/CheckCookie.cpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -12,12 +12,10 @@
 
   response resp;
 
- if (!req[cookies]["uuid"].empty())
+ if (req.cookies.count("uuid"))
   { // The cookie has been set correctly!
     boost::system::error_code ec;
- std::string fwd (req[form]["fwd"]);
- resp<< location(fwd);
- // resp<< location(req.form("fwd"));
+ resp<< location(req.form["fwd"]);
   }else
   {
     resp
@@ -31,14 +29,12 @@
          "<p>You have cookies disabled. They are required for logging in.</p>"
                                  "<a href='http://www.google.com/search?q=enabling cookies'>Google it</a>"
                                  " if you're stuck, or return to "
- "<a href='" << req[env_data]["referrer"] << "'>where you came from</a>"
+ "<a href='" << req.env["referrer"] << "'>where you came from</a>"
        "</center>"
        "</body>"
        "</html>";
   }
 
- resp.send(req.client());
-
- return req.close(http::ok);
+ return commit(req, resp);
 }
 

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/login/Login.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/login/Login.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/login/Login.cpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -13,8 +13,8 @@
            "You provided the following data:"
            "<p>"
            "<h3>Form data:</h3>";
- for (boost::acgi::map::iterator i = req[form].begin();
- i != req[form].end();
+ for (boost::acgi::map::iterator i = req.form.begin();
+ i != req.form.end();
        ++i)
   {
     resp<< "<b>" << i->first << "</b> = <i>" << i->second << "</i>";
@@ -44,8 +44,7 @@
   << "</body>"
      "</html>";
 
- resp.send(req.client());
- return req.close(http::ok);
+ return commit(req, resp);
 }
 
 int show_already_logged_in_page(request& req, response& resp)
@@ -55,12 +54,12 @@
   << "<html>"
      "<head><title>Redirecting...</title>"
      "<meta http-equiv='refresh' content='5;url="
- << req[post_data]["fwd"] <<"' />"
+ << req.post["fwd"] <<"' />"
      "</head>"
      "<body>"
      "<center>"
      "You are already logged in. You should be redirected "
- "<a href='"<< req[post_data]["fwd"] <<"'>here</a>"
+ "<a href='"<< req.post["fwd"] <<"'>here</a>"
      " in five seconds."
      "</center>";
      show_passed_variables(req, resp);
@@ -68,8 +67,7 @@
   << "</body>"
      "</html>";
   
- resp.send(req.client());
- return req.close(http::ok);
+ return commit(req, resp);
 }
 
 int show_name_error_page(request& req, response& resp)
@@ -87,7 +85,7 @@
           "the underscore character."
           "</span>"
           "<input type='text' name='name' value='"
- << req[post]["name"] <<"' />"
+ << req.post["name"] <<"' />"
           "<input type='button' name='cmd' value='login' />"
          "</form>"
        "</center>";
@@ -95,9 +93,9 @@
   resp
   << "</body>"
      "</html>";
+ resp<< http::bad_request; // Set the HTTP status to 400 (Bad Request).
 
- resp.send(req.client());
- return req.close(http::bad_request);
+ return commit(req, resp);
 }
 
 int verify_name(std::string& name)
@@ -135,19 +133,17 @@
 
   // If there's already a session id set, warn them and then redirect
   // them to where they would be going anyway.
- if (!req[cookies]["uuid"].empty()) {
+ if (req.cookies.count("uuid")) {
     return show_already_logged_in_page(req, resp);
   }
 
   // If they haven't asked explicitly to log in, show the default page.
- string cmd (req[post]["cmd"]);
- if (cmd.empty() || cmd != "login") {
+ if (!req.post.count("cmd") || req.post["cmd"] != "login") {
     return show_default_page(req, resp);
   }
 
   // If they're name is invalid, inform them.
- string name (req[post]["name"]);
- if (!verify_name(name)) {
+ if (!verify_name(req.post["name"])) {
     return show_name_error_page(req, resp);
   }
 
@@ -155,8 +151,7 @@
   // Here we give them a 'universally unique id' and forward them to a
   // cookie checking page.
   resp<< cookie("uuid", make_uuid())
- << location("CheckCookie?fwd=" + req[post]["fwd"]);
- resp.send(req.client());
+ << location("CheckCookie?fwd=" + req.post["fwd"]);
 
- return req.close(http::ok);
+ return commit(req, resp);
 }

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/login/Logout.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/login/Logout.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/login/Logout.cpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -14,9 +14,8 @@
 
   resp<< cookie("uuid");
   boost::system::error_code ec;
- resp<< location(req[form]["fwd"]);
+ resp<< location(req.form["fwd"]);
 
- resp.send(req.client());
- return req.close(http::ok);
+ return commit(req, resp);
 }
 

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/Jamfile.v2 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -7,7 +7,8 @@
 # By default, just build the examples
 build-project hello_world ;
 build-project echo ;
-build-project tracing_server ;
+build-project file_browser ;
+#build-project tracing_server ;
 
 # If the user explicitly passes "install" on the command line, build the
 # CGI examples and copy them to $(cgi-bin)
@@ -15,7 +16,8 @@
   :
     hello_world
     echo
- tracing_server
+ file_browser
+ #tracing_server
   :
     <location>$(cgi-bin)
   ;

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/echo/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/echo/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/echo/main.cpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -1,301 +1,123 @@
 // -- main.hpp --
 //
-// Copyright (c) Darren Garvey 2009.
+// 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)
 //
 ////////////////////////////////////////////////////////////////
 //
-//[cgi_file_browser
+//[cgi_echo
 //
-// This example is a simple browser-based file browser.
+// This example simply echoes all variables back to the user. ie.
+// the environment and the parsed GET, POST and cookie variables.
+// Note that GET and cookie variables come from the environment
+// variables QUERY_STRING and HTTP_COOKIE respectively.
 //
-///////////////////////////////////////////////////////////
-#include <istream>
-#include <fstream>
-#include <boost/filesystem.hpp>
-#include <boost/shared_array.hpp>
-#include <boost/algorithm/string/find.hpp>
-#include <boost/algorithm/string/case_conv.hpp>
-///////////////////////////////////////////////////////////
-#include "boost/cgi/cgi.hpp"
-#include "boost/cgi/utility/commit.hpp"
-
-using std::cerr;
-using std::endl;
-using std::ifstream;
-using namespace boost::cgi;
-namespace fs = boost::filesystem;
-namespace algo = boost::algorithm;
 
+#include <boost/cgi/cgi.hpp>
 
-/// Get the MIME type of the file.
-/**
- * @returns The MIME type as a string. Returns an empty string if the
- * file type isn't recognised / supported.
- */
-std::string get_mime_type(fs::path const& file)
-{
- std::string filetype (file.filename());
- // Note: we want the string after the '.'
- std::size_t pos (filetype.rfind(".")+1);
- if (pos == std::string::npos)
- return "";
-
- filetype = filetype.substr(pos);
- algo::to_lower(filetype);
-
- /// Ordinary text files.
- if (filetype == "ini" || filetype == "txt" || filetype == "conf")
- return "text/plain";
- else
- if (filetype == "js")
- return "application/javascript";
- else
- if (filetype == "json")
- return "application/json";
- else
- if (filetype == "css")
- return "text/css";
- else
- /// Structured text files.
- if (filetype == "html" || filetype == "htm")
- return "text/html";
- else
- if (filetype == "xml")
- return "text/xml";
- else
- if (filetype == "csv")
- return "text/csv";
- else
- if (filetype == "rtf")
- return "text/rtf";
- else
- /// Image files.
- if (filetype == "jpg" || filetype == "jpeg")
- return "image/jpeg";
- else
- if (filetype == "gif")
- return "image/gif";
- else
- if (filetype == "bmp")
- return "image/x-ms-bmp";
- else
- if (filetype == "png")
- return "image/png";
- else
- if (filetype == "tiff")
- return "image/tiff";
- else
- /// Audio files.
- if (filetype == "ogg")
- return "audio/ogg";
- else
- if (filetype == "mp3")
- return "audio/mpeg";
- else
- /// Video files.
- if (filetype == "avi")
- return "video/x-msvideo";
- else
- /// Rich media files.
- if (filetype == "pdf")
- return "application/pdf";
- else
- if (filetype == "doc")
- return "application/msword";
- else
- if (filetype == "swf")
- return "application/x-shockwave-flash";
- else
- if (filetype == "xls")
- return "application/vnd.ms-excel";
- /// Compressed files.
- else
- if (filetype == "zip")
- return "application/zip";
- else
- if (filetype == "tar")
- return "application/x-tar";
- /// Other files.
- else
- if (filetype == "pl")
- return "application/x-perl";
- else
- if (filetype == "py")
- return "application/x-python";
- else
- if (filetype == "exe" || filetype == "dll" || filetype == "sys" ||
- filetype == "chm" || filetype == "lib" || filetype == "pdb" ||
- filetype == "obj" || filetype == "dep" || filetype == "idb" ||
- filetype == "pyd" || filetype == "sqm" || filetype == "idb" ||
- filetype == "asm" || filetype == "suo" || filetype == "sbr")
- return ""; // Not allowed to download these file types.
+using namespace boost::cgi;
 
- return "text/plain";
-}
+// The styling information for the page, just to make things look nicer.
+static const char* gCSS_text =
+"body { padding: 0; margin: 3%; border-color: #efe; }"
+".var_map_title"
+ "{ font-weight: bold; font-size: large; }"
+".var_map"
+ "{ border: 1px dotted; padding: 2px 3px 2px 3px; margin-bottom: 3%; }"
+".var_pair"
+ "{ border-top: 1px dotted; overflow: auto; padding: 0; margin: 0; }"
+".var_name"
+ "{ position: relative; float: left; width: 30%; font-weight: bold; }"
+".var_value"
+ "{ position: relative; float: left; width: 65%; left: 1%;"
+ " border-left: 1px solid; padding: 0 5px 0 5px;"
+ " overflow: auto; white-space: pre; }"
+;
 
-template<typename Response, typename Client>
-void show_file(Response& resp, Client& client, fs::path const& file)
+//
+// This function writes the title and map contents to the ostream in an
+// HTML-encoded format (to make them easier on the eye).
+//
+template<typename OStream, typename Request, typename Map>
+void format_map(OStream& os, Request& req, Map& m, const std::string& title)
 {
- if (!fs::exists(file))
- resp<< "File not found.";
+ os<< "<div class=\"var_map\">"
+ "<div class=\"var_map_title\">"
+ << title
+ << "</div>";
+
+ if (m.empty())
+ os<< "<div class=\"var_pair\">EMPTY</div>";
   else
- {
- boost::uintmax_t size (fs::file_size(file));
- cerr<< "size: " << size << endl;
- if (size > 200000000L) // Files must be < 200MB
- resp<< "File too large.";
- else
+ for (typename Map::const_iterator i = m.begin(); i != m.end(); ++i)
     {
- /// Check the file type is allowed.
- std::string mime_type (get_mime_type(file));
- if (!mime_type.empty())
- {
- std::string ctype (content_type(mime_type).content + "\r\n\r\n");
- //write(client, boost::asio::buffer(ctype));
- /// Open the file and read it as binary data.
- ifstream ifs (file.string().c_str(), std::ios::binary);
- if (ifs.is_open())
- {
- resp<< content_type(mime_type);
- //resp.flush(client);
- boost::uintmax_t bufsize = 500;
- boost::uintmax_t read_bytes;
- char buf[500];
- ifs.seekg(0, std::ios::beg);
- while (!ifs.eof() && size > 0)
- {
- ifs.read(buf, size < bufsize ? size : bufsize);
- read_bytes = ifs.gcount();
- size -= read_bytes;
- resp.write(buf, read_bytes);
- //write(client, boost::asio::buffer(buf, read_bytes));
- //resp.flush(client);
- }
- //resp.send(client);
- }
- }
- else
- resp<< "File type not allowed.";
+ os<< "<div class=\"var_pair\">"
+ "<div class=\"var_name\">"
+ << i->first
+ << "</div>"
+ "<div class=\"var_value\">"
+ << i->second
+ << (req.is_file(i->first) ? " (file)" : "")
+ << "</div>"
+ "</div>";
     }
- }
-}
-
-template<typename Response>
-void show_paths(Response& resp, fs::path const& parent, bool recursive = true)
-{
- if (!fs::exists(parent))
- {
- resp<< "File does not exist\n";
- return;
- }
-
- resp<< "<ul>";
- if (fs::is_directory(parent))
- {
- resp<< parent << "\n";
- resp<< "<li class=\"directory\"><a href=\"?dir="
- << parent.string() << "\">.</a></li>\n";
- if (fs::is_directory(parent.parent_path()))
- resp<< "<li class=\"directory\"><a href=\"?dir="
- << parent.parent_path().string() << "\">..</a></li>\n";
- for (fs::directory_iterator iter(parent), end; iter != end; ++iter)
- {
- if (fs::is_directory(*iter))
- {
- resp<< "<li class=\"directory\"><a href=\"?dir="
- << iter->string() << "\">" << iter->path() << "</a></li>\n";
- if (recursive)
- show_paths(resp, iter->path(), recursive);
- }
- else
- {
- // display filename only.
- resp<< "<li class=\"file\"><a href=\"?file="
- << iter->string() << "\">" << iter->path().filename()
- << "</a>";
- //if (fs::is_regular_file(iter->status()))
- // resp<< " [" << fs::file_size(iter->path()) << " bytes]";
- resp<< "</li>\n";
- }
- }
- }
- else
- {
- resp<< "<li class=\"file\">" << "<a href=\"?file="
- << parent.string() << "\">" << parent << "</li>\n";
- }
- resp<< "</ul>";
+ os<< "</div>";
 }
 
-/// This function accepts and handles a single request.
-template<typename Request>
-int handle_request(Request& req)
+std::size_t process_id()
 {
- boost::system::error_code ec;
-
- //
- // Load in the request data so we can access it easily.
- //
- req.load(parse_all); // Read and parse STDIN (ie. POST) data.
-
- //
- // Construct a `response` object (makes writing/sending responses easier).
- //
- response resp;
-
- if (req.get.count("file"))
- {
- show_file(resp, req.client(), req.get["file"]);
- //return req.close(http::ok, 0);
- }
- else
- if (req.get.count("dir"))
- {
- //
- // Responses in CGI programs require at least a 'Content-type' header.
- // The library provides helpers for several common headers:
- //
- resp<< content_type("text/html");
-
- // You can also stream text to a response.
- // All of this just prints out the form
- resp<< "<html>"
- "<head><title>CGI File Browser Example</title><head>"
- "<body>";
-
- show_paths(resp, req.get["dir"], req.get["recurse"] == "1");
-
- resp<< "</body></html>";
- }
- else
- resp<< content_type("text/plain")
- << "No path specified.\n";
-
- resp<< header("CGI-client", "fcgi_file_browser");
- return commit(req, resp, 0);
+#if defined(BOOST_WINDOWS)
+ return _getpid();
+#else
+ return getpid();
+#endif
 }
 
+
 int main()
 {
-try {
+ // A basic CGI request auto-parses everything (including POST data).
+ request req(parse_all);
+ response resp;
 
- request req;
- return handle_request(req);
+ // You can also stream text to a response.
+ // All of this just prints out the form
+ resp<< "<html>"
+ "<head>"
+ "<title>CGI Echo Example</title>"
+ "<style type=\"text/css\">"
+ << gCSS_text <<
+ "</style>"
+ "<head>"
+ "<body>"
+ "Request ID = " << req.id() << "<br />"
+ "Process ID = " << process_id() << "<br />"
+ "<form method=post enctype=\"multipart/form-data\">"
+ "<input type=text name=name value='"
+ << req.post["name"] << "' />"
+ "<br />"
+ "<input type=text name=hello value='"
+ << req.post["hello"] << "' />"
+ "<br />"
+ "<input type=file name=user_file />"
+ "<input type=hidden name=cmd value=multipart_test />"
+ "<br />"
+ "<input type=submit value=submit />"
+ "</form><p />";
+
+ format_map(resp, req, req.env, "Environment Variables");
+ //format_map(resp, req, req.get, "GET Variables");
+ format_map(resp, req, req.form, "Form [" + req.request_method() + "] Variables");
+ format_map(resp, req, req.cookies, "Cookie Variables");
+
+ // Note that this (and any other) HTTP header can go either before or after
+ // the response contents.
+ resp<< content_type("text/html");
 
-}catch(boost::system::system_error const& se){
- // This is the type of error thrown by the library.
- cerr<< "[fcgi] System error: " << se.what() << endl;
- return -1;
-}catch(std::exception const& e){
- // Catch any other exceptions
- cerr<< "[fcgi] Exception: " << e.what() << endl;
- return -1;
-}catch(...){
- cerr<< "[fcgi] Uncaught exception!" << endl;
- return -1;
-}
+ // Send the response to the client that made the request.
+ return commit(req, resp);
 }
 //]
+

Added: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/file_browser/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/file_browser/Jamfile.v2 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -0,0 +1,27 @@
+# Copyright (c) 2007 Darren Garvey
+#
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or copy
+# at http://www.boost.org/LICENSE_1_0.txt)
+
+project boost/cgi/example/cgi/file_browser ;
+
+exe cgi_file_browser
+ :
+ main.cpp
+ :
+ <library>/boost/cgi/
+ <library>/boost/filesystem/
+ ;
+
+
+# Our install rule (builds binaries and copies them to <location>)
+install install
+ :
+ cgi_file_browser
+ :
+ <location>$(cgi-bin)
+ ;
+
+# Only install example if you use `bjam install' or equivalent
+explicit install ;

Added: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/file_browser/doc.qbk
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/file_browser/doc.qbk 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -0,0 +1,11 @@
+
+[section File Browser]
+
+[import main.cpp]
+
+[cgi_file_browser]
+
+See the [@../../example/cgi/file_browser/main.cpp full source listing].
+
+[endsect][/ file_browser]
+

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/file_browser/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/file_browser/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/file_browser/main.cpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -1,125 +1,308 @@
 // -- main.hpp --
 //
-// Copyright (c) Darren Garvey 2007.
+// Copyright (c) Darren Garvey 2009.
 // 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)
 //
 ////////////////////////////////////////////////////////////////
 //
-//[cgi_echo
+//[cgi_file_browser
 //
-// This example simply echoes all variables back to the user. ie.
-// the environment and the parsed GET, POST and cookie variables.
-// Note that GET and cookie variables come from the environment
-// variables QUERY_STRING and HTTP_COOKIE respectively.
+// This example is a simple browser-based file browser.
 //
-
-#include <boost/cgi/cgi.hpp>
-
+///////////////////////////////////////////////////////////
+#include <istream>
+#include <fstream>
+#include <boost/filesystem.hpp>
+#include <boost/shared_array.hpp>
+#include <boost/algorithm/string/find.hpp>
+#include <boost/algorithm/string/case_conv.hpp>
+///////////////////////////////////////////////////////////
+#include "boost/cgi/cgi.hpp"
+
+using std::cerr;
+using std::endl;
+using std::ifstream;
 using namespace boost::cgi;
+namespace fs = boost::filesystem;
+namespace algo = boost::algorithm;
 
-// The styling information for the page, just to make things look nicer.
-static const char* gCSS_text =
-"body { padding: 0; margin: 3%; border-color: #efe; }"
-".var_map_title"
- "{ font-weight: bold; font-size: large; }"
-".var_map"
- "{ border: 1px dotted; padding: 2px 3px 2px 3px; margin-bottom: 3%; }"
-".var_pair"
- "{ border-top: 1px dotted; overflow: auto; padding: 0; margin: 0; }"
-".var_name"
- "{ position: relative; float: left; width: 30%; font-weight: bold; }"
-".var_value"
- "{ position: relative; float: left; width: 65%; left: 1%;"
- " border-left: 1px solid; padding: 0 5px 0 5px;"
- " overflow: auto; white-space: pre; }"
-;
 
-//
-// This function writes the title and map contents to the ostream in an
-// HTML-encoded format (to make them easier on the eye).
-//
-template<typename OStream, typename Request, typename Map>
-void format_map(OStream& os, Request& req, Map& m, const std::string& title)
+/// Get the MIME type of the file.
+/**
+ * @returns The MIME type as a string. Returns an empty string if the
+ * file type isn't recognised / supported.
+ */
+std::string get_mime_type(fs::path const& file)
 {
- os<< "<div class=\"var_map\">"
- "<div class=\"var_map_title\">"
- << title
- << "</div>";
+ std::string filetype (file.filename());
+ // Note: we want the string after the '.'
+ std::size_t pos (filetype.rfind(".")+1);
+ if (pos == std::string::npos)
+ return "";
+
+ filetype = filetype.substr(pos);
+ algo::to_lower(filetype);
+
+ /// Ordinary text files.
+ if (filetype == "ini" || filetype == "txt" || filetype == "conf")
+ return "text/plain";
+ else
+ if (filetype == "js")
+ return "application/javascript";
+ else
+ if (filetype == "json")
+ return "application/json";
+ else
+ if (filetype == "css")
+ return "text/css";
+ else
+ /// Structured text files.
+ if (filetype == "html" || filetype == "htm")
+ return "text/html";
+ else
+ if (filetype == "xml")
+ return "text/xml";
+ else
+ if (filetype == "csv")
+ return "text/csv";
+ else
+ if (filetype == "rtf")
+ return "text/rtf";
+ else
+ /// Image files.
+ if (filetype == "jpg" || filetype == "jpeg")
+ return "image/jpeg";
+ else
+ if (filetype == "gif")
+ return "image/gif";
+ else
+ if (filetype == "bmp")
+ return "image/x-ms-bmp";
+ else
+ if (filetype == "png")
+ return "image/png";
+ else
+ if (filetype == "tiff")
+ return "image/tiff";
+ else
+ /// Audio files.
+ if (filetype == "ogg")
+ return "audio/ogg";
+ else
+ if (filetype == "mp3")
+ return "audio/mpeg";
+ else
+ /// Video files.
+ if (filetype == "avi")
+ return "video/x-msvideo";
+ else
+ /// Rich media files.
+ if (filetype == "pdf")
+ return "application/pdf";
+ else
+ if (filetype == "doc")
+ return "application/msword";
+ else
+ if (filetype == "swf")
+ return "application/x-shockwave-flash";
+ else
+ if (filetype == "xls")
+ return "application/vnd.ms-excel";
+ /// Compressed files.
+ else
+ if (filetype == "zip")
+ return "application/zip";
+ else
+ if (filetype == "tar")
+ return "application/x-tar";
+ /// Other files.
+ else
+ if (filetype == "pl")
+ return "application/x-perl";
+ else
+ if (filetype == "py")
+ return "application/x-python";
+ else
+ if (filetype == "exe" || filetype == "dll" || filetype == "sys" ||
+ filetype == "chm" || filetype == "lib" || filetype == "pdb" ||
+ filetype == "obj" || filetype == "dep" || filetype == "idb" ||
+ filetype == "pyd" || filetype == "sqm" || filetype == "idb" ||
+ filetype == "asm" || filetype == "suo" || filetype == "sbr")
+ return ""; // Not allowed to download these file types.
 
- if (m.empty())
- os<< "<div class=\"var_pair\">EMPTY</div>";
+ return "text/plain";
+}
+
+/// Show the file to the user.
+/**
+ * This will send the file to the user using an appropriate content-type
+ * header. Some browsers (eg. Firefox) will be able to handle many file types
+ * directly, while others (eg. Internet Explorer) will prompt the user to
+ * save / open the file externally.
+ *
+ * This function actually buffers the entire file before sending it to the user,
+ * so this isn't very scalable. You could choose to stream the file directly
+ * instead, but make sure your HTTP server won't buffer the response.
+ *
+ * Files over 200MB won't be displayed.
+ */
+template<typename Response, typename Client>
+void show_file(Response& resp, Client& client, fs::path const& file)
+{
+ if (!fs::exists(file))
+ resp<< "File not found.";
   else
- for (typename Map::const_iterator i = m.begin(); i != m.end(); ++i)
+ {
+ boost::uintmax_t size (fs::file_size(file));
+ if (size > 200000000L) // Files must be < 200MB
+ resp<< "File too large: " << file.string() << " [" << size << ']';
+ else
     {
- os<< "<div class=\"var_pair\">"
- "<div class=\"var_name\">"
- << i->first
- << "</div>"
- "<div class=\"var_value\">"
- << i->second
- << (req.is_file(i->first) ? " (file)" : "")
- << "</div>"
- "</div>";
+ /// Check the file type is allowed.
+ std::string mime_type (get_mime_type(file));
+ if (!mime_type.empty())
+ {
+ std::string ctype (content_type(mime_type).content + "\r\n\r\n");
+ /// Open the file and read it as binary data.
+ ifstream ifs (file.string().c_str(), std::ios::binary);
+ if (ifs.is_open())
+ {
+ resp<< content_type(mime_type);
+ boost::uintmax_t bufsize = 500;
+ boost::uintmax_t read_bytes;
+ char buf[500];
+ ifs.seekg(0, std::ios::beg);
+ while (!ifs.eof() && size > 0)
+ {
+ ifs.read(buf, size < bufsize ? size : bufsize);
+ read_bytes = ifs.gcount();
+ size -= read_bytes;
+ resp.write(buf, read_bytes);
+ }
+ }
+ }
+ else
+ resp<< "File type not allowed.";
     }
- os<< "</div>";
+ }
 }
-
-std::size_t process_id()
+
+template<typename Response>
+void show_paths(Response& resp, fs::path const& parent, bool recursive = true)
 {
-#if defined(BOOST_WINDOWS)
- return _getpid();
-#else
- return getpid();
-#endif
+ if (!fs::exists(parent))
+ {
+ resp<< "File does not exist\n";
+ return;
+ }
+
+ resp<< "<ul>";
+ if (fs::is_directory(parent))
+ {
+ resp<< parent << "\n";
+ resp<< "<li class=\"directory\"><a href=\"?dir="
+ << parent.string() << "\">.</a></li>\n";
+ if (fs::is_directory(parent.parent_path()))
+ resp<< "<li class=\"directory\"><a href=\"?dir="
+ << parent.parent_path().string() << "\">..</a></li>\n";
+ for (fs::directory_iterator iter(parent), end; iter != end; ++iter)
+ {
+ if (fs::is_directory(*iter))
+ {
+ resp<< "<li class=\"directory\"><a href=\"?dir="
+ << iter->string() << "\">" << iter->path() << "</a></li>\n";
+ if (recursive)
+ show_paths(resp, iter->path(), recursive);
+ }
+ else
+ {
+ // display filename only.
+ resp<< "<li class=\"file\"><a href=\"?file="
+ << iter->string() << "\">" << iter->path().filename()
+ << "</a>";
+ //if (fs::is_regular_file(iter->status()))
+ // resp<< " [" << fs::file_size(iter->path()) << " bytes]";
+ resp<< "</li>\n";
+ }
+ }
+ }
+ else
+ {
+ resp<< "<li class=\"file\">" << "<a href=\"?file="
+ << parent.string() << "\">" << parent << "</li>\n";
+ }
+ resp<< "</ul>";
 }
 
-
-int main()
+/// This function accepts and handles a single request.
+template<typename Request>
+int handle_request(Request& req)
 {
- // A basic CGI request auto-parses everything (including POST data).
- request req(parse_all);
+ boost::system::error_code ec;
+
+ //
+ // Load in the request data so we can access it easily.
+ //
+ req.load(parse_all); // Read and parse STDIN (ie. POST) data.
+
+ //
+ // Construct a `response` object (makes writing/sending responses easier).
+ //
   response resp;
 
- // You can also stream text to a response.
- // All of this just prints out the form
- resp<< "<html>"
- "<head>"
- "<title>CGI Echo Example</title>"
- "<style type=\"text/css\">"
- << gCSS_text <<
- "</style>"
- "<head>"
- "<body>"
- "Request ID = " << req.id() << "<br />"
- "Process ID = " << process_id() << "<br />"
- "<form method=post enctype=\"multipart/form-data\">"
- "<input type=text name=name value='"
- << req.post["name"] << "' />"
- "<br />"
- "<input type=text name=hello value='"
- << req.post["hello"] << "' />"
- "<br />"
- "<input type=file name=user_file />"
- "<input type=hidden name=cmd value=multipart_test />"
- "<br />"
- "<input type=submit value=submit />"
- "</form><p />";
-
- format_map(resp, req, req.env, "Environment Variables");
- //format_map(resp, req, req.get, "GET Variables");
- format_map(resp, req, req.form, "Form [" + req.request_method() + "] Variables");
- format_map(resp, req, req.cookies, "Cookie Variables");
-
- // Note that this (and any other) HTTP header can go either before or after
- // the response contents.
- resp<< content_type("text/html");
+ if (req.get.count("file"))
+ {
+ show_file(resp, req.client(), req.get["file"]);
+ //return req.close(http::ok, 0);
+ }
+ else
+ if (req.get.count("dir"))
+ {
+ //
+ // Responses in CGI programs require at least a 'Content-type' header.
+ // The library provides helpers for several common headers:
+ //
+ resp<< content_type("text/html");
+
+ // You can also stream text to a response.
+ // All of this just prints out the form
+ resp<< "<html>"
+ "<head><title>CGI File Browser Example</title><head>"
+ "<body>";
+
+ show_paths(resp, req.get["dir"], req.get["recurse"] == "1");
 
- // Send the response to the client associated with the request.
- resp.send(req.client());
+ resp<< "</body></html>";
+ }
+ else
+ resp<< content_type("text/html")
+ << "No path specified. Search for a path using, eg. "
+ << " <a href=\"?dir=/\">" << req.script_name() << "?dir=/some/path</a>\n";
 
- return 0;
+ resp<< header("CGI-client", "fcgi_file_browser");
+ return commit(req, resp);
 }
-//]
 
+int main()
+{
+try {
+
+ request req;
+ return handle_request(req);
+
+}catch(boost::system::system_error const& se){
+ // This is the type of error thrown by the library.
+ cerr<< "[fcgi] System error: " << se.what() << endl;
+ return -1;
+}catch(std::exception const& e){
+ // Catch any other exceptions
+ cerr<< "[fcgi] Exception: " << e.what() << endl;
+ return -1;
+}catch(...){
+ cerr<< "[fcgi] Uncaught exception!" << endl;
+ return -1;
+}
+}
+//]

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/hello_world/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/hello_world/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/hello_world/main.cpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -30,7 +30,7 @@
       << "Hello there, universe.";
 
   // Leave this function, after sending the response and closing the request.
- return_(resp, req, 0); // Note the underscore: returns "0" to the OS.
+ return commit(req, resp);
 }
 //]
 

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/fcgi/echo/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/fcgi/echo/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/fcgi/echo/main.cpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -19,7 +19,6 @@
 #include <boost/program_options/environment_iterator.hpp>
 ///////////////////////////////////////////////////////////
 #include "boost/cgi/fcgi.hpp"
-#include "boost/cgi/utility/commit.hpp"
 
 //using namespace std;
 using namespace boost::fcgi;
@@ -117,7 +116,7 @@
          "<body>"
            "Request ID = " << req.id() << "<br />"
            "Process ID = " << process_id() << "<br />"
- "<form method=post enctype=\"multipart/form-data\">"
+ "<form method=post>" // enctype=\"multipart/form-data\">"
              "<input type=text name=name value='"
       << req.post["name"] << "' />"
              "<br />"
@@ -168,15 +167,18 @@
 {
 try {
 
+ std::cerr<< "*** Ping! ***" << '\n';
   // Make a `service` (more about this in other examples).
   service s;
   
   using boost::asio::ip::tcp;
 
   // Make an `acceptor` for accepting requests through.
+#if defined (BOOST_WINDOWS)
   acceptor a(s, 8009); // Accept requests on port 8009.
- //cerr<< "Listening" << endl;
- //cerr<< "is_cgi ? " << a.is_cgi() << endl;
+#else
+ acceptor a(s);
+#endif // defined (BOOST_WINDOWS)
 
   //
   // After the initial setup, we can enter a loop to handle one request at a

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/fcgi/hello_world/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/fcgi/hello_world/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/fcgi/hello_world/main.cpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -17,7 +17,6 @@
 #include <boost/asio.hpp>
 #include <boost/system/system_error.hpp>
 #include <boost/cgi/fcgi.hpp>
-#include <boost/cgi/utility/commit.hpp>
 
 using namespace std;
 using namespace boost::fcgi;
@@ -64,7 +63,16 @@
   try
   {
     service s; // This becomes useful with async operations.
- acceptor a(s, 8008); // The acceptor is for accepting requests
+#if defined (BOOST_WINDOWS)
+ // On Windows, set up an external server to listen on port 8008.
+ // You will need to set your HTTP server to use port 8008.
+ acceptor a(s, 8008);
+#else
+ // On Linux, you can do the above, or just accept on the default
+ // socket. This means setup of your HTTP server is simpler and
+ // FastCGI processes can be started automatically by your server.
+ acceptor a(s);
+#endif // defined (BOOST_WINDOWS)
 
     for (;;)
     {

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/fcgi/server1/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/fcgi/server1/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/fcgi/server1/main.cpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -20,6 +20,7 @@
 // This is very similar to the fcgi_echo example.
 //
 
+#include <iostream>
 #include "boost/cgi/fcgi.hpp"
 #include "./server.hpp"
 
@@ -53,25 +54,16 @@
       << "Hello there, universe!<p />";
 
   // Use the function defined above to show some of the request data.
- format_map(resp, req[env], "Environment Variables");
- format_map(resp, req[get], "GET Variables");
- format_map(resp, req[cookies], "Cookie Variables");
+ format_map(resp, req.env, "Environment Variables");
+ format_map(resp, req.get, "GET Variables");
+ format_map(resp, req.cookies, "Cookie Variables");
    // Response headers can be added at any time before send/flushing it:
   resp<< "<h3>Response Length</h3>" << resp.content_length()
       // response::content_length() returns the length of the *body*
       // of the response (ie. not including the headers).
       << content_length(resp);
 
- // This funky macro finishes up:
- return_(resp, req, 0);
- // It is equivalent to the below, where the third argument is represented by
- // `program_status`:
- //
- // resp.send(req.client());
- // req.close(resp.status(), program_status);
- // return program_status;
- //
- // Note: in this case `program_status == 0`.
+ return commit(req, resp);
 }
 
 ///////////////////////////////////////////////////////////

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/fcgi/server1/server.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/fcgi/server1/server.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/fcgi/server1/server.hpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -59,14 +59,14 @@
       }
 
       // Load in the request data so we can access it easily.
- new_request->load(ec, true); // The 'true' means read and parse POST data.
+ // Read and parse POST data.
+ new_request->load(boost::fcgi::parse_post, ec);
 
- // Call the request handler and capture the result of handling the request.
+ // Call the request handler and capture the result of handling
+ // the request.
       ret = handler_(*new_request, ec);
 
       // A non-zero return value indicates an error.
- // Note: bailing out here isn't strictly necessary, but easier and safer,
- // given the current state of the library.
       if (ret)
         break;
     }

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/fcgi/server2/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/fcgi/server2/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/fcgi/server2/main.cpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -65,22 +65,13 @@
       << "Hello there, universe!<p />";
 
   // Use the function defined above to show some of the request data.
- format_map(resp, req[env], "Environment Variables");
- format_map(resp, req[get], "GET Variables");
- format_map(resp, req[cookies], "Cookie Variables");
+ format_map(resp, req.env, "Environment Variables");
+ format_map(resp, req.get, "GET Variables");
+ format_map(resp, req.cookies, "Cookie Variables");
 
   //log_<< "Handled request, handling another." << std::endl;
 
- // This funky macro finishes up:
- return_(resp, req, 0);
- // It is equivalent to the below, where the third argument is represented by
- // `program_status`:
- //
- // resp.send(req.client());
- // req.close(resp.status(), program_status);
- // return program_status;
- //
- // Note: in this case `program_status == 0`.
+ return commit(req, resp);
 }
 
 
@@ -134,16 +125,16 @@
                           );
   }
 
- void handle_accept(request_type::pointer req
+ int handle_accept(request_type::pointer req
                     , boost::system::error_code ec)
   {
     if (ec)
     {
       //std::cerr<< "Error accepting request: " << ec.message() << std::endl;
- return;
+ return -1;
     }
 
- req->load(ec, true);
+ req->load(parse_all, ec);
 
     //req->async_load(boost::bind(&server::handle_request, this
     // , req, boost::asio::placeholders::error)
@@ -157,13 +148,14 @@
     requests_.insert(new_request);
 
     start_accept(new_request);
+ return 0;
   }
 
   void handle_request(request_type::pointer req
                      , boost::system::error_code ec)
   {
- handler_(*req, ec);
- if (ec)
+
+ if (handler_(*req, ec) || ec)
     {
       //std::cerr<< "Request handled, but ended in error: " << ec.message()
       // << std::endl;

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/fcgi/server3/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/fcgi/server3/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/fcgi/server3/main.cpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -50,16 +50,7 @@
 
     //log_<< "Handled request, handling another." << std::endl;
 
- // This funky macro finishes up:
- return_(resp, req, 0);
- // It is equivalent to the below, where the third argument is represented by
- // `program_status`:
- //
- // resp.send(req.client());
- // req.close(resp.status(), program_status);
- // return program_status;
- //
- // Note: in this case `program_status == 0`.
+ return commit(req, resp);
   }
 
 /// The server is used to abstract away protocol-specific setup of requests.
@@ -107,7 +98,7 @@
       }
   
       // Load in the request data so we can access it easily.
- new_request->load(ec, parse_post | parse_cookies); // Read and parse POST data and cookies.
+ new_request->load(parse_all, ec); // Read and parse POST data and cookies.
 
       ret = handler_(*new_request, ec);
 

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/compile/async_stdio_connection.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/compile/async_stdio_connection.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/compile/async_stdio_connection.cpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -3,7 +3,7 @@
 int main()
 {
   cgi::common::io_service ios;
- cgi::common::async_stdio_connection conn(ios);
+ cgi::common::connections::async_stdio conn(ios);
 
   return 0;
 }

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/compile/cgi_header_check.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/compile/cgi_header_check.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/compile/cgi_header_check.cpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -2,7 +2,7 @@
 
 int main()
 {
- cgi::cgi_request req;
+ boost::cgi::request req;
 
   return 0;
 }

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/compile/shareable_tcp_connection.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/compile/shareable_tcp_connection.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/compile/shareable_tcp_connection.cpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -3,7 +3,7 @@
 int main()
 {
   cgi::common::io_service ios;
- cgi::common::connection::shareable_tcp conn(ios);
+ cgi::common::connections::shareable_tcp conn(ios);
 
   return 0;
 }

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/compile/stdio_connection.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/compile/stdio_connection.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/compile/stdio_connection.cpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -2,7 +2,7 @@
 
 int main()
 {
- cgi::common::connection::stdio conn;
+ cgi::common::connections::stdio conn;
 
   return 0;
 }

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/compile/tcp_connection.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/compile/tcp_connection.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/compile/tcp_connection.cpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -3,7 +3,7 @@
 int main()
 {
   cgi::common::io_service ios;
- cgi::common::connection::tcp conn(ios);
+ cgi::common::connections::tcp conn(ios);
 
   return 0;
 }

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/run/acgi_simple_request.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/run/acgi_simple_request.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/run/acgi_simple_request.cpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -34,7 +34,7 @@
 
   using namespace boost::acgi;
   service s;
- request req(s, true);
+ request req(s, parse_all);
 
   TEST_ENV_DATA(req);
 }
@@ -43,7 +43,7 @@
 {
   using namespace boost::acgi;
   service s;
- request req(s, true);
+ request req(s, parse_all);
 
   TEST_GET_DATA(req);
 }
@@ -54,7 +54,7 @@
 
   {
     service s;
- request req(s, true);
+ request req(s, parse_all);
     TEST_ONE_COOKIE(req);
   }
   
@@ -63,7 +63,7 @@
     setenv("HTTP_COOKIE", "foo=bar;another_one=stuff", 1);
 
     service s;
- request req(s, true);
+ request req(s, parse_all);
     TEST_TWO_COOKIES(req);
   }
 
@@ -72,7 +72,7 @@
     setenv("HTTP_COOKIE", "foo=bar; encoded=%22%C2%A3$%^$*^hh%%thd@:", 1);
 
     service s;
- request req(s, true);
+ request req(s, parse_all);
     TEST_ENCODED_COOKIE(req);
   }
 }

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/run/request_test_template.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/run/request_test_template.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/run/request_test_template.hpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -2,14 +2,14 @@
 #define TEST_ENV_DATA(req) \
                                                                                  \
   /* Check environment parsing */ \
- BOOST_CHECK( req[env_data].size() ); \
- BOOST_CHECK_EQUAL( req[env]["HTTP_HOST"], "localhost" ); \
- BOOST_CHECK_EQUAL( req[env]["EMPTY_VAR"], "" ); \
- BOOST_CHECK_EQUAL( req[env]["UGLY_VAR"], "$££$^%%£&&^%@%26$ £_abcd" ); \
- BOOST_CHECK_EQUAL( req[env]["QUERY_STRING"] \
+ BOOST_CHECK( req.env.size() ); \
+ BOOST_CHECK_EQUAL( req.env["HTTP_HOST"], "localhost" ); \
+ BOOST_CHECK_EQUAL( req.env["EMPTY_VAR"], "" ); \
+ BOOST_CHECK_EQUAL( req.env["UGLY_VAR"], "$££$^%%£&&^%@%26$ £_abcd" ); \
+ BOOST_CHECK_EQUAL( req.env["QUERY_STRING"] \
                    , "hello=world&foo=bar&encoded=%22!%C2%A3$%^$*^hh%%thd@:~" ); \
   /* Check case-insensitive name comparing */ \
- BOOST_CHECK_EQUAL( req[env]["http_host"], "localhost" ); \
+ BOOST_CHECK_EQUAL( req.env["http_host"], "localhost" ); \
   /* Check helper function (need to test them all?) */ \
   BOOST_CHECK_EQUAL( req.script_name(), "some/test/script" );
 
@@ -20,34 +20,34 @@
   BOOST_CHECK_EQUAL( req.request_method(), "GET" ); \
                                                                                 \
   /* Check GET data/query string parsing */ \
- BOOST_CHECK( req[get].size() ); \
- BOOST_CHECK_EQUAL( req[get]["hello"], "world" ); \
- BOOST_CHECK_EQUAL( req[get]["foo"], "bar" ); \
+ BOOST_CHECK( req.get.size() ); \
+ BOOST_CHECK_EQUAL( req.get["hello"], "world" ); \
+ BOOST_CHECK_EQUAL( req.get["foo"], "bar" ); \
   /* Case-insensitive check */ \
- BOOST_CHECK_EQUAL( req[get]["FOO"], "bar" ); \
+ BOOST_CHECK_EQUAL( req.get["FOO"], "bar" ); \
   /* Value should be case-sensitive */ \
- BOOST_CHECK_NE( req[get]["foo"], "BAR" ); \
+ BOOST_CHECK_NE( req.get["foo"], "BAR" ); \
   /* Check url-decoding */ \
- BOOST_CHECK_EQUAL( req[get]["encoded"], "\"!£$%^$*^hh%%thd@:~" );
+ BOOST_CHECK_EQUAL( req.get["encoded"], "\"!£$%^$*^hh%%thd@:~" );
 
 
 #define TEST_ONE_COOKIE(req) \
                                                                                 \
     /* Check cookie parsing */ \
- BOOST_CHECK( req[cookies].size() ); \
- BOOST_CHECK_EQUAL( req[cookies]["foo"], "bar" ); \
+ BOOST_CHECK( req.cookies.size() ); \
+ BOOST_CHECK_EQUAL( req.cookies["foo"], "bar" ); \
     /* Check case-insensitive name comparison */ \
- BOOST_CHECK_EQUAL( req[cookies]["FOO"], "bar" );
+ BOOST_CHECK_EQUAL( req.cookies["FOO"], "bar" );
 
 #define TEST_TWO_COOKIES(req) \
                                                                                 \
- BOOST_CHECK_EQUAL( req[cookies]["foo"], "bar" ); \
- BOOST_CHECK_EQUAL( req[cookies]["another_one"], "stuff" );
+ BOOST_CHECK_EQUAL( req.cookies["foo"], "bar" ); \
+ BOOST_CHECK_EQUAL( req.cookies["another_one"], "stuff" );
 
 #define TEST_ENCODED_COOKIE(req) \
                                                                                 \
- BOOST_CHECK_EQUAL( req[cookies]["foo"], "bar" ); \
- BOOST_CHECK_EQUAL( req[cookies]["encoded"], "\"£$%^$*^hh%%thd@:" );
+ BOOST_CHECK_EQUAL( req.cookies["foo"], "bar" ); \
+ BOOST_CHECK_EQUAL( req.cookies["encoded"], "\"£$%^$*^hh%%thd@:" );
 
 
 #include <string>

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/run/stdio_connection.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/run/stdio_connection.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/run/stdio_connection.cpp 2009-09-22 05:37:49 EDT (Tue, 22 Sep 2009)
@@ -4,7 +4,7 @@
 
 int main()
 {
- cgi::common::connection::stdio conn;
+ cgi::common::connections::stdio conn;
 
   boost::system::error_code 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