Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53331 - in sandbox/SOC/2007/cgi/branches/pickmeup: boost/cgi boost/cgi/common boost/cgi/detail boost/cgi/impl boost/cgi/utility libs/cgi/build/msvc/9.0/Boost.CGI libs/cgi/example/acgi/echo libs/cgi/test/run
From: lists.drrngrvy_at_[hidden]
Date: 2009-05-27 19:28:28


Author: drrngrvy
Date: 2009-05-27 19:28:27 EDT (Wed, 27 May 2009)
New Revision: 53331
URL: http://svn.boost.org/trac/boost/changeset/53331

Log:
* Adding basic_response<>::str() - give a string of the response body.
* Minor bug fixes.

Added:
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/error.hpp (contents, props changed)
Binary files modified:
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/Boost.CGI.ncb
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/Boost.CGI.suo
Text files modified:
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/basic_request.hpp | 28 ++++++++++++++-
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/cookie.hpp | 3 +
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/header.hpp | 16 ++++++++-
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/request_status.hpp | 1
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/response.hpp | 68 +++++++++++++++++++++++++++++++++++++--
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/cgi_service_impl_base.hpp | 2
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/extract_params.hpp | 2 +
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/push_options.hpp | 6 +++
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/save_environment.hpp | 7 ++-
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/impl/basic_request.ipp | 36 ++++++++++----------
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/impl/fcgi_request_service.ipp | 63 +++---------------------------------
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/impl/response.ipp | 18 +++++++--
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/utility/has_key.hpp | 2
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/echo/main.cpp | 22 +++++++++++-
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/run/Jamfile.v2 | 9 ++--
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/run/map_test.cpp | 3 +
   16 files changed, 184 insertions(+), 102 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-05-27 19:28:27 EDT (Wed, 27 May 2009)
@@ -63,6 +63,9 @@
     : public boost::mpl::if_<
                  is_async<typename RequestService::protocol_type>
                , basic_io_object<RequestService>
+ // A basic_sync_io_object is a little more lightweight
+ // than a basic_io_object. It can't handle asynchonous
+ // operations as a consequence.
                , detail::basic_sync_io_object<RequestService>
>::type
   {
@@ -127,7 +130,7 @@
     {
       set_protocol_service(s);
       const parse_options opts = parse_post_now ? parse_post : parse_env;
- if(load_now) load(opts, ec);//this->service.load(this->implementation, false, ec);
+ if (load_now) load(opts, ec);//this->service.load(this->implementation, false, ec);
     }
 
     /// Make a new mutiplexed request from an existing connection.
@@ -347,8 +350,12 @@
     string_type& auth_type()
     { return env_("AUTH_TYPE"); }
 
- string_type& content_length()
- { return env_("CONTENT_LENGTH"); }
+ /// Get the content length as a long.
+ long content_length()
+ { return boost::lexical_cast<long>(env_("CONTENT_LENGTH")); }
+
+ //string_type& content_length()
+ //{ return env_("CONTENT_LENGTH"); }
 
     string_type& content_type()
     { return env_("CONTENT_TYPE"); }
@@ -377,12 +384,27 @@
     string_type& remote_user()
     { return env_("REMOTE_USER"); }
 
+ string_type& method()
+ { return env_("REQUEST_METHOD"); }
+
     string_type& request_method()
     { return env_("REQUEST_METHOD"); }
 
+ string_type& url()
+ { return env_("REQUEST_URL"); }
+
+ string_type& request_url()
+ { return env_("REQUEST_URL"); }
+
     string_type& script_name()
     { return env_("SCRIPT_NAME"); }
 
+ string_type& script_url()
+ { return env_("SCRIPT_URL"); }
+
+ string_type& script_uri()
+ { return env_("SCRIPT_URI"); }
+
     string_type& server_name()
     { return env_("SERVER_NAME"); }
 

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/cookie.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/cookie.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/cookie.hpp 2009-05-27 19:28:27 EDT (Wed, 27 May 2009)
@@ -38,6 +38,7 @@
   template<typename CharT>
   struct basic_cookie
   {
+ typedef basic_cookie<CharT> self_type;
     typedef CharT char_type;
     typedef typename std::basic_string<CharT> string_type;
 
@@ -135,6 +136,8 @@
       if ( http_only ) str += "; HttpOnly";
       return str;
     }
+
+ //friend std::ostream& operator<<(std::ostream& os, self_type const& ck);
   };
 
  } // namespace common

Added: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/error.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/error.hpp 2009-05-27 19:28:27 EDT (Wed, 27 May 2009)
@@ -0,0 +1,130 @@
+// -- error.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)
+//
+// Abstract:
+// ---------
+//
+// The common errors are defined in here.
+//
+// **FIXME** This is a mess.
+//
+////////////////////////////////////////////////////////////////
+#ifndef BOOST_COMMON_ERROR_HPP_INCLUDED__
+#define BOOST_COMMON_ERROR_HPP_INCLUDED__
+
+#include <string>
+#include <boost/system/error_code.hpp>
+
+namespace cgi {
+ namespace common {
+ namespace error {
+
+enum cgi_errors
+{
+ // Tried to read/write from/to the client associated to a request when it
+ // was closed.
+ client_closed = 1,
+
+ // A begin_request packet has come in with an existing request id.
+ duplicate_request,
+
+ // Calling async_accept on a request that hasn't been closed isn't
+ // allowed.
+ accepting_on_an_open_request,
+
+ invalid_socket,
+
+ // The CONTENT_TYPE for form data wasn't recognised.
+ invalid_form_type,
+
+ // Used in basic_connection<tags::stdio>
+ // **FIXME**
+ broken_pipe,
+
+ // **FIXME**
+ bad_read,
+
+ // A client wasn't able to open.
+ client_not_open,
+
+ // End of File (read zero bytes)
+ eof,
+
+ // The first multipart form boundary was not found.
+ multipart_form_boundary_not_found
+};
+
+ namespace detail {
+
+class cgi_category
+ : public boost::system::error_category
+{
+public:
+ const char* name() const { return "CGI Error"; }
+ std::string message(int e) const
+ {
+ switch(e)
+ {
+ case client_closed:
+ return "Attempting to read from or write to a client that has been closed.";
+ case accepting_on_an_open_request:
+ return "`async_accept` called with an open request (ie. it should be closed first).";
+ case multipart_form_boundary_not_found:
+ return "The first multipart form boundary was not found.";
+ case invalid_form_type:
+ return "The CONTENT_TYPE for form data wasn't recognised.";
+ case eof:
+ return "End of File.";
+ case duplicate_request:
+ return "FastCGI: new request received with a duplicate id.";
+ default:
+ return "(CGI) BOOM!!!";
+ }
+ }
+};
+
+ } // namespace detail
+
+inline const boost::system::error_category& get_cgi_category()
+{
+ static detail::cgi_category instance;
+ return instance;
+}
+
+static const boost::system::error_category& cgi_category
+ = ::cgi::common::error::get_cgi_category();
+
+ } // namespace error
+ } // namespace common
+} // namespace cgi
+
+namespace boost {
+ namespace system {
+
+ template<> struct is_error_code_enum< ::cgi::common::error::cgi_errors>
+ {
+ BOOST_STATIC_CONSTANT(bool, value = true);
+ };
+
+ } // namespace system
+} // namespace boost
+
+namespace cgi {
+ namespace common {
+ namespace error {
+
+ inline boost::system::error_code make_error_code(cgi_errors e)
+ {
+ return boost::system::error_code(
+ static_cast<int>(e), get_cgi_category());
+ }
+
+ } // namespace error
+ } // namespace common
+} // namespace cgi
+
+#endif // BOOST_COMMON_ERROR_HPP_INCLUDED__

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/header.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/header.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/header.hpp 2009-05-27 19:28:27 EDT (Wed, 27 May 2009)
@@ -72,8 +72,13 @@
 
 
    //{ Some shortcuts, to cut down on typing errors.
- template<typename CharT, typename StringT> basic_header<CharT>
- content_type(StringT const& str)
+ template<
+ typename CharT
+ , typename Traits
+ , typename Alloc
+ >
+ basic_header<CharT>
+ content_type(std::basic_string<CharT,Traits,Alloc> const& str)
    {
      return basic_header<CharT>("Content-type", str);
    }
@@ -97,6 +102,13 @@
               boost::lexical_cast<std::basic_string<CharT> >(t));
    }
 
+ template<typename CharT> basic_header<CharT>
+ content_length(const CharT * t)
+ {
+ return basic_header<CharT>("Content-length",
+ boost::lexical_cast<std::basic_string<CharT> >(t));
+ }
+
    template<typename CharT, typename T> basic_header<CharT>
      content_length(T t)
    {

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/request_status.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/request_status.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/request_status.hpp 2009-05-27 19:28:27 EDT (Wed, 27 May 2009)
@@ -16,6 +16,7 @@
      { null
      , unloaded
      , activated
+ , accepted = activated
      , loaded
      , ok = loaded
      , aborted

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-05-27 19:28:27 EDT (Wed, 27 May 2009)
@@ -33,6 +33,7 @@
   class basic_response
   {
   public:
+ typedef basic_response<T> self_type;
     typedef T char_type;
     typedef typename std::basic_string<T> string_type;
     typedef typename std::basic_ostream<T> ostream_type;
@@ -136,6 +137,13 @@
     /// Add a header after appending the CRLF sequence.
     basic_response<char_type>&
       set_header(const string_type& value);
+
+ /// Get the contents of the response as a string.
+ /**
+ * This copies the contents of the response into a string.
+ * Headers aren't included in the dump.
+ */
+ string_type str() const;
 
     /// Format and add a header given name and value, appending CRLF.
     basic_response<char_type>&
@@ -157,6 +165,29 @@
 
     /// Get the headers
     std::vector<string_type>& headers();
+
+ //friend std::basic_ostream<char_type>& operator<<(std::basic_ostream<char_type>&, self_type& resp);
+ /*
+ friend self_type& operator<<(self_type& self, basic_cookie<char_type> const&);
+ friend self_type& operator<<(self_type& self, basic_header<char_type> const&);
+ friend self_type& operator<<(self_type& self, basic_response<char_type> const&);
+ friend self_type& operator<<(self_type& self, http::status_code);
+ */
+
+ /*
+ template<typename T>
+ std::basic_ostream<string_type>& operator<<(T& t)
+ {
+ ostream_<< t;
+ return ostream_;
+ }
+
+ template<typename T>
+ self_type& operator<<(const T& t) {
+ ostream_<< t;
+ return *this;
+ }
+ */
 
   protected:
     // Vector of all the headers, each followed by a CRLF
@@ -182,13 +213,30 @@
    typedef basic_response<char> response;
    typedef basic_response<wchar_t> wresponse; // **FIXME** (untested)
 
+ /*
+ std::basic_ostream<char_type>& operator<<(std::basic_ostream<char_type>&, self_type& resp)
+ {
+ os<< "**response**";
+ return os;
+ }
+
+ template<typename CharT>
+ basic_response<CharT>&
+ basic_response<CharT>::operator<< (ostream_type& (*func)(ostream_type&))
+ {
+ ostream_<< func; return *this;
+ }
+ */
+
  } // namespace common
 } // namespace cgi
 
+
+
   /// Generic ostream template
   template<typename CharT, typename T>
   cgi::common::basic_response<CharT>&
- operator<< (cgi::common::basic_response<CharT>& resp, const T& t);
+ operator<< (cgi::common::basic_response<CharT>& resp, T const& t);
 
   template<typename CharT>
   cgi::common::basic_response<CharT>&
@@ -206,10 +254,11 @@
    * http://tinyurl.com/33znkj), but this is outside the scope of this
    * library.
    */
- template<typename charT, typename T>
+ template<typename charT>
   cgi::common::basic_response<charT>&
     operator<< (cgi::common::basic_response<charT>&
- , cgi::common::basic_cookie<T>&);
+ , cgi::common::basic_cookie<charT>);
+
 /*
   template<typename charT, typename T>
   cgi::common::basic_response<charT>&
@@ -225,11 +274,20 @@
   cgi::common::basic_response<charT>&
     operator<< (cgi::common::basic_response<charT>&
                , cgi::common::basic_response<charT>&);
+/*
+inline std::ostream& operator<<(
+std::ios& (*func)(std::ios&)
+){return std::cout << func;};
+inline std::ostream& operator<<(
+std::ios_base& (*func)(std::ios_base&)
+){return std::cout << func;};
+};
+*/
 
 #include "boost/cgi/detail/pop_options.hpp"
 
-//#if !defined(BOOST_CGI_BUILD_LIB)
+#if !defined(BOOST_CGI_BUILD_LIB)
 # include "boost/cgi/impl/response.ipp"
-//#endif
+#endif
 
 #endif // CGI_RESPONSE_HPP_INCLUDED__

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-05-27 19:28:27 EDT (Wed, 27 May 2009)
@@ -104,7 +104,7 @@
      */
     bool is_open(implementation_type& impl)
     {
- return impl.status() >= common::aborted;
+ return impl.status() >= common::accepted && impl.status() <= common::aborted;
     }
 
     /// Return the connection associated with the request

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/extract_params.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/extract_params.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/extract_params.hpp 2009-05-27 19:28:27 EDT (Wed, 27 May 2009)
@@ -56,6 +56,8 @@
 // guaranteed by the CGI spec to be kept, but you might want to use them.
 // You just have to define `BOOST_CGI_KEEP_EMPTY_VARS` (**FIXME** currently
 // on by default).
+// Note that you'll want to check that your server keeps empty query string
+// parameters.
 #if defined(BOOST_CGI_KEEP_EMPTY_VARS)
          if (name.empty())
            destination.insert(std::make_pair(common::name(current_token.c_str()), ""));

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/push_options.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/push_options.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/push_options.hpp 2009-05-27 19:28:27 EDT (Wed, 27 May 2009)
@@ -26,6 +26,12 @@
 # endif
 #endif
 
+#ifdef BOOST_CGI_EXPORTS
+# define BOOST_CGI_API __declspec(dllexport)
+#else
+# define BOOST_CGI_API __declspec(dllimport)
+#endif // BOOST_CGI_EXPORTS
+
 /// Keep empty query string variables.
 /** Empty query string parameters (eg.
  * `empty` in /path/to/script?empty&foo=bar)

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/save_environment.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/save_environment.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/save_environment.hpp 2009-05-27 19:28:27 EDT (Wed, 27 May 2009)
@@ -1,4 +1,4 @@
- // -- detail/save_environment.hpp --
+// -- detail/save_environment.hpp --
 //
 // Copyright (c) Darren Garvey 2007.
 // Distributed under the Boost Software License, Version 1.0.
@@ -36,8 +36,9 @@
         * macro: BOOST_CGI_KEEP_EMPTY_VARS
     */
    template<typename MapT>
- void save_environment(MapT& env_map, char** env =
-#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
+ void save_environment(MapT& env_map, char** env =
+ // Windows calls the environment environ_
+#if BOOST_WINDOWS
         _environ
 #else
          environ

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/impl/basic_request.ipp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/impl/basic_request.ipp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/impl/basic_request.ipp 2009-05-27 19:28:27 EDT (Wed, 27 May 2009)
@@ -59,8 +59,8 @@
   **/
 
     // Throws
- template<typename RS, typename PS, typename A>
- basic_request<RS,PS,A>::basic_request
+ template<typename RequestService, typename ProtocolService, typename Acceptor>
+ basic_request<RequestService,ProtocolService,Acceptor>::basic_request
   (
       bool load_now = true, bool parse_post = true
   )
@@ -70,8 +70,8 @@
   }
 
                 // Won't throw
- template<typename RS, typename PS, typename A>
- basic_request<RS,PS,A>::basic_request
+ template<typename RequestService, typename ProtocolService, typename Acceptor>
+ basic_request<RequestService,ProtocolService,Acceptor>::basic_request
   (
       boost::system::error_code& ec
     , const bool load_now = true
@@ -83,8 +83,8 @@
   }
 
                 // Throws
- template<typename RS, typename PS, typename A>
- basic_request<RS,PS,A>::basic_request
+ template<typename RequestService, typename ProtocolService, typename Acceptor>
+ basic_request<RequestService,ProtocolService,Acceptor>::basic_request
   (
       protocol_service_type& s, const bool load_now = false
     , const bool parse_post = false
@@ -96,8 +96,8 @@
   }
 
                 // Won't throw
- template<typename RS, typename PS, typename A>
- basic_request<RS,PS,A>::basic_request
+ template<typename RequestService, typename ProtocolService, typename Acceptor>
+ basic_request<RequestService,ProtocolService,Acceptor>::basic_request
   (
       protocol_service_type& s
     , boost::system::error_code& ec
@@ -111,8 +111,8 @@
 
     /// Make a new mutiplexed request from an existing connection.
     // Throws.
- template<typename RS, typename PS, typename A>
- basic_request<RS,PS,A>:: basic_request(implementation_type& impl)
+ template<typename RequestService, typename ProtocolService, typename Acceptor>
+ basic_request<RequestService,ProtocolService,Acceptor>:: basic_request(implementation_type& impl)
       : basic_io_object<service_type>(impl.service_->io_service())
     {
       set_protocol_service(*impl.service_);
@@ -124,8 +124,8 @@
 
     /// Make a new mutiplexed request from an existing connection.
     // Won't throw.
- template<typename RS, typename PS, typename A>
- basic_request<RS,PS,A>:: basic_request(implementation_type& impl, boost::system::error_code& ec)
+ template<typename RequestService, typename ProtocolService, typename Acceptor>
+ basic_request<RequestService,ProtocolService,Acceptor>:: basic_request(implementation_type& impl, boost::system::error_code& ec)
       : basic_io_object<service_type>(impl.service_->io_service())
     {
       set_protocol_service(*impl.service_);
@@ -139,21 +139,21 @@
       // close(http::internal_server_error, 0);
     }
 
- template<typename RS, typename PS, typename A>
- basic_request<RS,PS,A>:: static pointer create(protocol_service_type& ps)
+ template<typename RequestService, typename ProtocolService, typename Acceptor>
+ basic_request<RequestService,ProtocolService,Acceptor>:: static pointer create(protocol_service_type& ps)
     {
       return pointer(new type(ps));
     }
 
- template<typename RS, typename PS, typename A>
- basic_request<RS,PS,A>:: void set_protocol_service(protocol_service_type& ps)
+ template<typename RequestService, typename ProtocolService, typename Acceptor>
+ basic_request<RequestService,ProtocolService,Acceptor>:: void set_protocol_service(protocol_service_type& ps)
     {
       this->service.set_service(this->implementation, ps);
     }
 
     /// Return `true` if the request is still open (ie. not aborted or closed)
- template<typename RS, typename PS, typename A>
- basic_request<RS,PS,A>:: bool is_open()
+ template<typename RequestService, typename ProtocolService, typename Acceptor>
+ basic_request<RequestService,ProtocolService,Acceptor>:: bool is_open()
     {
       return this->service.is_open(this->implementation);
     }

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-05-27 19:28:27 EDT (Wed, 27 May 2009)
@@ -31,6 +31,12 @@
 
    namespace detail {
      
+ /// Helper class to asynchronously load a request.
+ /**
+ * This is just a function object that can be posted to another
+ * thread to do the actual work of loading. It's operator()() does
+ * the work.
+ */
      template<typename T, typename Handler>
      struct async_load_helper
      {
@@ -264,63 +270,6 @@
       //# error "Not implemented"
       // **FIXME** should use form_parser, when it's ready.
       // Only works with url-encoded forms (ie. not with multipart forms)
- /*
- std::string name;
- std::string str;
-
- char ch;
- char ch1;
- while( impl.client_.bytes_left_ )
- {
- ch = getchar();
- --impl.client_.bytes_left_;
-
- switch(ch)
- {
- case '%': // unencode a hex character sequence
- if (impl.client_.bytes_left_ >= 2)
- {
- ch = getchar();
- ch1 = getchar();
- if (std::isxdigit(ch) && std::isxdigit(ch1))
- {
- str.append(1, detail::hex_to_char(ch, ch1));
- }
- else // we don't have a hex sequence
- {
- str.append(1, '%').append(1, ch).append(1, ch1);
- }
- impl.client_.bytes_left_ -= 2;
- }
- else // There aren't enough characters to make a hex sequence
- {
- str.append(1, '%');
- --impl.client_.bytes_left_;
- }
- break;
- case '+':
- str.append(1, ' ');
- break;
- case ' ': // skip spaces
- break;
- case '=': // the name is complete, now get the corresponding value
- name.swap(str);
- break;
- case '&': // we now have the name/value pair, so save it
- // **FIXME** have to have .c_str() ?
- ::cgi::common::post_vars(impl.vars_)[name.c_str()] = str;
- str.clear();
- name.clear();
- break;
- default:
- str.append(1, ch);
- }
- }
- // save the last param (it won't have a trailing &)
- if( !name.empty() )
- // **FIXME** have to have .c_str() ?
- ::cgi::common::post_vars(impl.vars_)[name.c_str()] = str;
- */
 
       impl.fp_.reset
       (

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-05-27 19:28:27 EDT (Wed, 27 May 2009)
@@ -300,6 +300,14 @@
     return rdbuf()->size();
   }
 
+ template<typename T> BOOST_CGI_INLINE
+ typename basic_response<T>::string_type
+ basic_response<T>::str() const
+ {
+ return string_type(boost::asio::buffer_cast<const char_type *>(buffer_->data()));
+ }
+
+
   /// Add a header after appending the CRLF sequence.
   template<typename T> BOOST_CGI_INLINE
   basic_response<T>&
@@ -407,7 +415,7 @@
   /// Generic ostream template
   template<typename T, typename U> BOOST_CGI_INLINE
   cgi::common::basic_response<T>&
- operator<< (cgi::common::basic_response<T>& resp, const U& u)
+ operator<< (cgi::common::basic_response<T>& resp, U const& u)
   {
     resp.ostream()<< u;
     return resp;
@@ -428,10 +436,10 @@
    * effects; for instance, it won't write any data to the client.
    * ]
    */
- template<typename T> BOOST_CGI_INLINE
- cgi::common::basic_response<T>&
- operator<< (cgi::common::basic_response<T>& resp
- , cgi::common::basic_header<T> const& hdr)
+ template<typename CharT> BOOST_CGI_INLINE
+ cgi::common::basic_response<CharT>&
+ operator<< (cgi::common::basic_response<CharT>& resp
+ , cgi::common::basic_header<CharT> const& hdr)
   {
     if (hdr.content.empty()) {
       resp.end_headers();

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/utility/has_key.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/utility/has_key.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/utility/has_key.hpp 2009-05-27 19:28:27 EDT (Wed, 27 May 2009)
@@ -40,7 +40,7 @@
     * with the same data `foo=bar`.
     */
     template<typename MapT>
- bool has_key(MapT& data, common::name const& name)
+ bool has_key(MapT& data, typename MapT::key_type const& name)
     {
         if (!data.empty())
             for(typename MapT::const_iterator iter = data.begin(), end = data.end();

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/Boost.CGI.ncb
==============================================================================
Binary files. No diff available.

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/Boost.CGI.suo
==============================================================================
Binary files. No diff available.

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-05-27 19:28:27 EDT (Wed, 27 May 2009)
@@ -94,11 +94,27 @@
     try {
 
       boost::system::error_code ec;
- req.load(parse_all, ec); // parse everything.
+
+ // This spits out a form with a file upload facility (these aren't
+ // stored, just parsed. Before parsing the POST'd form data, first
+ // check that the content-length isn't too long.
+ req.load(parse_env);
+
+ response resp;
+
+ if (req.content_length() > 1000L)
+ {
+ resp<< "You're only allowed to upload 1k of data";
+ // Exit the application here.
+ return_(resp, req, 0);
+ }
+
+ // If execution reaches here we can parse all other
+ // request data (cookies, get, post).
+ req.load(parse_all, ec);
 
       if (ec)
       {
- response resp;
         resp<< content_type("text/html")
             << "Error " << ec.value() << ": " << ec.message() << "<p />"
                "--Original message follows--"
@@ -118,7 +134,7 @@
              "<body>"
                "Request ID = " << req.id() << "<br />"
                "Process ID = " << process_id() << "<br />"
- "<form method=POST enctype='multipart/form-data'>"
+ "<form method=POST enctype='application/x-www-form-urlencoded'>"
                  "<input type=text name=name value='"
           << (has_key(req[post],"name") ? req[post]["name"] : "")
           << "' />"

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/run/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/run/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/run/Jamfile.v2 2009-05-27 19:28:27 EDT (Wed, 27 May 2009)
@@ -5,10 +5,10 @@
 
 project boost/cgi/tests/run
   : requirements
- <library>/boost/test//boost_unit_test_framework/
- <library>/boost/system/
- <library>/boost/thread/
- <library>/boost/regex/
+ #<library>/boost/test//boost_unit_test_framework/
+ #<library>/boost/system/
+ #<library>/boost/thread/
+ #<library>/boost/regex/
   ;
 
 #local rule run-test( name )
@@ -29,6 +29,7 @@
     [ run name_test.cpp ]
     [ run map_test.cpp ]
     [ run parse_options.cpp ]
+ #[ run has_key.cpp ]
   ;
 
 test-suite wget_test

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/run/map_test.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/run/map_test.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/test/run/map_test.cpp 2009-05-27 19:28:27 EDT (Wed, 27 May 2009)
@@ -18,4 +18,7 @@
   m["FATFOO"] = "minibar";
   BOOST_CHECK_EQUAL( m["FATFOO"], "minibar" );
   BOOST_CHECK_EQUAL( m["fatfoo"], "minibar" );
+
+ // Sanity check.
+ BOOST_CHECK_NOT_EQUAL( m["nonfoo"], "dfpij" );
 }


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