Boost logo

Boost-Commit :

From: lists.drrngrvy_at_[hidden]
Date: 2008-04-19 09:23:05


Author: drrngrvy
Date: 2008-04-19 09:23:03 EDT (Sat, 19 Apr 2008)
New Revision: 44573
URL: http://svn.boost.org/trac/boost/changeset/44573

Log:
* Added case-insensitive name type (typedef for std::basic_string<> using a custom traits class).
* Modified cgi::map to use cgi::name as key.
* Also modified files to include common/map.hpp instead of map.hpp.
* Changed code because a std::string isn't automatically convertible to cgi::name
* Fixed it so multiple cookies are parsed correctly.
* Plus, other smallish fixes (cleanup / updating Boost.Thread compatibility).

Added:
   sandbox/SOC/2007/cgi/trunk/boost/cgi/common/map.hpp (contents, props changed)
   sandbox/SOC/2007/cgi/trunk/boost/cgi/common/name.hpp (contents, props changed)
   sandbox/SOC/2007/cgi/trunk/boost/cgi/utility/
Text files modified:
   sandbox/SOC/2007/cgi/trunk/boost/cgi/acgi/request_service.hpp | 2
   sandbox/SOC/2007/cgi/trunk/boost/cgi/basic_client.hpp | 4
   sandbox/SOC/2007/cgi/trunk/boost/cgi/basic_request.hpp | 2
   sandbox/SOC/2007/cgi/trunk/boost/cgi/cgi/request_impl.hpp | 2
   sandbox/SOC/2007/cgi/trunk/boost/cgi/common/form_part.hpp | 2
   sandbox/SOC/2007/cgi/trunk/boost/cgi/connections/shareable_tcp_socket.hpp | 4
   sandbox/SOC/2007/cgi/trunk/boost/cgi/connections/stdio.hpp | 28 -
   sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/cgi_request_impl_base.hpp | 2
   sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/cgi_service_impl_base.hpp | 593 ---------------------------------------
   sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/common_headers.hpp | 2
   sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/extract_params.hpp | 8
   sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/save_environment.hpp | 4
   sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/url_decode.hpp | 7
   sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/client.hpp | 2
   sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/request_service.hpp | 10
   sandbox/SOC/2007/cgi/trunk/boost/cgi/map.hpp | 11
   16 files changed, 39 insertions(+), 644 deletions(-)

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/acgi/request_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/acgi/request_service.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/acgi/request_service.hpp 2008-04-19 09:23:03 EDT (Sat, 19 Apr 2008)
@@ -12,7 +12,7 @@
 #include "boost/cgi/acgi/request_impl.hpp"
 #include "boost/cgi/tags.hpp"
 #include "boost/cgi/io_service.hpp"
-#include "boost/cgi/map.hpp"
+#include "boost/cgi/common/map.hpp"
 #include "boost/cgi/detail/cgi_service_impl_base.hpp"
 #include "boost/cgi/detail/service_base.hpp"
 #include "boost/cgi/detail/extract_params.hpp"

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/basic_client.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/basic_client.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/basic_client.hpp 2008-04-19 09:23:03 EDT (Sat, 19 Apr 2008)
@@ -11,7 +11,7 @@
 
 #include <boost/shared_ptr.hpp>
 
-#include "boost/cgi/map.hpp"
+#include "boost/cgi/common/map.hpp"
 #include "boost/cgi/role_type.hpp"
 #include "boost/cgi/status_type.hpp"
 #include "boost/cgi/http/status_code.hpp"
@@ -143,6 +143,8 @@
   private:
     //io_service& io_service_;
     connection_ptr connection_;
+
+ public: // **FIXME**
     // we should never read more than content-length bytes.
     std::size_t bytes_left_;
   };

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/basic_request.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/basic_request.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/basic_request.hpp 2008-04-19 09:23:03 EDT (Sat, 19 Apr 2008)
@@ -38,7 +38,7 @@
 #include "boost/cgi/basic_request_fwd.hpp"
 #include "boost/cgi/basic_sync_io_object.hpp"
 #include "boost/cgi/basic_io_object.hpp"
-#include "boost/cgi/map.hpp"
+#include "boost/cgi/common/map.hpp"
 
 namespace cgi {
  namespace common {

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/cgi/request_impl.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/cgi/request_impl.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/cgi/request_impl.hpp 2008-04-19 09:23:03 EDT (Sat, 19 Apr 2008)
@@ -19,7 +19,7 @@
 #include "boost/cgi/connections/stdio.hpp"
 #include "boost/cgi/role_type.hpp"
 #include "boost/cgi/status_type.hpp"
-#include "boost/cgi/map.hpp"
+#include "boost/cgi/common/map.hpp"
 #include "boost/cgi/detail/cgi_request_impl_base.hpp"
 
 // Make this ProtocolService-independent

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/common/form_part.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/common/form_part.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/common/form_part.hpp 2008-04-19 09:23:03 EDT (Sat, 19 Apr 2008)
@@ -37,7 +37,7 @@
      pair_t buffer_;
 
      std::string content_type; // must exist
- std::string name; // Has to exist?
+ std::string name; // must exist (?) **FIXME**
 
      // Using a simple map while everything is changing. This will not copy the
      // values when it is properly implemented (it'll hold a pair of iterators

Added: sandbox/SOC/2007/cgi/trunk/boost/cgi/common/map.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/common/map.hpp 2008-04-19 09:23:03 EDT (Sat, 19 Apr 2008)
@@ -0,0 +1,16 @@
+#ifndef BOOST_CGI_COMMON_MAP_HPP_INCLUDED__
+#define BOOST_CGI_COMMON_MAP_HPP_INCLUDED__
+
+#include <map>
+#include "boost/cgi/common/name.hpp"
+
+namespace cgi {
+ namespace common {
+
+ typedef std::map< ::cgi::common::name, std::string> map;
+
+ } // namespace common
+} // namespace cgi
+
+#endif // BOOST_CGI_COMMON_MAP_HPP_INCLUDED__
+

Added: sandbox/SOC/2007/cgi/trunk/boost/cgi/common/name.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/common/name.hpp 2008-04-19 09:23:03 EDT (Sat, 19 Apr 2008)
@@ -0,0 +1,75 @@
+// -- common/name.hpp --
+//
+// Copyright (c) Darren Garvey 2008.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+////////////////////////////////////////////////////////////////
+//
+// Based on (pretty much char for char) Herb Sutter's GoTW #29.
+// (see http://www.gotw.ca/gotw/029.htm)
+//
+#ifndef BOOST_CGI_COMMON_NAME_HPP_INCLUDED__
+#define BOOST_CGI_COMMON_NAME_HPP_INCLUDED__
+
+#include <string>
+#include <ostream>
+#include <map>
+
+namespace cgi {
+ namespace common {
+
+ template <typename CharT>
+ struct ichar_traits
+ : std::char_traits<CharT>
+ {
+ static bool eq(char c1, char c2)
+ { return std::toupper(c1) == std::toupper(c2); }
+
+ static bool ne(char c1, char c2)
+ { return std::toupper(c1) != std::toupper(c2); }
+
+ static bool lt(char c1, char c2)
+ { return std::toupper(c1) < std::toupper(c2); }
+
+ static int compare( const char* str1
+ , const char* str2
+ , std::size_t num )
+ {
+ if ( !(std::toupper(*str1) - std::toupper(*str2)) )
+ return 0;
+
+ int d = 0;
+ while (--num && !(d = std::toupper(*++str1) - std::toupper(*++str2)))
+ ;
+ return d;
+ }
+
+ static const char*
+ find(const char* str, int n, char a)
+ {
+ while( n-- > 0 && std::toupper(*str) != std::toupper(a) )
+ ++str;
+ return str;
+ }
+
+ };
+
+ // typedef for typical usage.
+ typedef std::basic_string<char, ichar_traits<char> > name;
+
+ // Overload allowing output using standard streams.
+ template <typename CharT, typename Traits>
+ std::basic_ostream<CharT, Traits>&
+ operator<< (std::basic_ostream<CharT, Traits>& os
+ , const std::basic_string<CharT, ichar_traits<CharT> >& str)
+ {
+ return os<< str.c_str();
+ }
+
+ } // namespace common
+} // namespace cgi
+
+#endif // BOOST_CGI_COMMON_NAME_HPP_INCLUDED__
+

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/connections/shareable_tcp_socket.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/connections/shareable_tcp_socket.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/connections/shareable_tcp_socket.hpp 2008-04-19 09:23:03 EDT (Sat, 19 Apr 2008)
@@ -63,8 +63,8 @@
     /** End FastCGI stuff **/
 
     // A wrapper to provide condition_type::pointer
- struct condition_type : public boost::condition
- { typedef boost::shared_ptr<boost::condition> pointer; };
+ struct condition_type : public boost::condition_variable
+ { typedef boost::shared_ptr<boost::condition_variable> pointer; };
 
     basic_connection(io_service& ios)
       : sock_(ios)

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/connections/stdio.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/connections/stdio.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/connections/stdio.hpp 2008-04-19 09:23:03 EDT (Sat, 19 Apr 2008)
@@ -59,33 +59,7 @@
     template<typename MutableBufferSequence>
     std::size_t read_some(MutableBufferSequence buf
                          , boost::system::error_code& ec)
- {
- //if (std::cin.eof())
- //{
- //ec = boost::asio::error::eof;
- // return boost::asio::error::eof;
- //}
- //if( buf.data() != in_.rdbuf() )
- // return in_.read(buf.begin(), buf.size());
- //return buf.size();
-
- //std::cerr<< "In stdio::read_some()" << std::endl
- // << "before = {" << std::endl
- // << std::string(boost::asio::buffer_cast<char *>(buf), boost::asio::buffer_size(buf)) << std::endl
- // << "}" << std::endl;
- /*
- std::cin.read(boost::asio::buffer_cast<char *>(buf)
- , boost::asio::buffer_size(buf));
- if (std::cin.fail() && !std::cin.eof())
- {
- ec = boost::system::error_code(654, boost::system::system_category);
- return 0;
- }
- */
- //std::cerr<< "before = {" << std::endl
- // << std::string(boost::asio::buffer_cast<char *>(buf), boost::asio::buffer_size(buf)) << std::endl
- // << "}" << std::endl;
-
+ {
       if (std::fread(boost::asio::buffer_cast<void *>(buf)
                     , boost::asio::buffer_size(buf)
                     , 1, stdin))

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/cgi_request_impl_base.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/cgi_request_impl_base.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/cgi_request_impl_base.hpp 2008-04-19 09:23:03 EDT (Sat, 19 Apr 2008)
@@ -18,7 +18,7 @@
 #include "boost/cgi/connections/stdio.hpp"
 #include "boost/cgi/role_type.hpp"
 #include "boost/cgi/status_type.hpp"
-#include "boost/cgi/map.hpp"
+#include "boost/cgi/common/map.hpp"
 //#include
 
 // Make this ProtocolService-independent

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/cgi_service_impl_base.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/cgi_service_impl_base.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/cgi_service_impl_base.hpp 2008-04-19 09:23:03 EDT (Sat, 19 Apr 2008)
@@ -1,3 +1,11 @@
+// -- detail/cgi_service_impl_base.hpp --
+//
+// Copyright (c) Darren Garvey 2007-2008.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+////////////////////////////////////////////////////////////////
 #ifndef CGI_CGI_SERVICE_IMPL_BASE_HPP_INCLUDED__
 #define CGI_CGI_SERVICE_IMPL_BASE_HPP_INCLUDED__
 
@@ -12,7 +20,7 @@
 #include <boost/system/error_code.hpp>
 #include <boost/algorithm/string/find.hpp>
 
-#include "boost/cgi/map.hpp"
+#include "boost/cgi/common/map.hpp"
 #include "boost/cgi/basic_client.hpp"
 #include "boost/cgi/role_type.hpp"
 #include "boost/cgi/status_type.hpp"
@@ -133,7 +141,7 @@
       var(map_type& meta_data, const std::string& name
          , boost::system::error_code& ec)
     {
- return meta_data[name];
+ return meta_data[name.c_str()];
     }
 
     std::string
@@ -205,6 +213,7 @@
                         if (rm == "POST")
                           return POST(impl, name, ec);
                         else
+ // **FIXME** What about HEAD, PUT ???
                           return "***BOOST_CGI_ERROR_INVALID_REQUEST_METHOD***";
                 }
                 
@@ -303,7 +312,7 @@
 
       detail::extract_params(vars, impl.cookie_vars()
                             , boost::char_separator<char>
- ("", "=&", boost::keep_empty_tokens)
+ ("", "=;", boost::keep_empty_tokens)
                             , ec);
 
       return ec;
@@ -317,95 +326,6 @@
       // Make sure this function hasn't already been called
       //BOOST_ASSERT (!impl.stdin_parsed());
 
- std::string content_type (var(impl.env_vars(), "CONTENT_TYPE", ec));
-
- BOOST_ASSERT(!content_type.empty());
-
- if (boost::algorithm::ifind_first(content_type,
- "application/x-www-form-urlencoded"))
- {
- detail::throw_error(
- parse_url_encoded_form(impl, ec)
- );
- }
- else
- {
- detail::throw_error(
- parse_multipart_form(impl, ec)
- );
- }
-
- return ec;
- }
-
- boost::system::error_code
- parse_url_encoded_form(implementation_type& impl
- , boost::system::error_code& ec)
- {
- std::string name;
- std::string str;
- map_type& post_map(impl.post_vars());
-
- char ch;
- char ch1;
- while( impl.characters_left_ )
- {
- ch = getchar();
- --impl.characters_left_;
-
- switch(ch)
- {
- case '%': // unencode a hex character sequence
- if (impl.characters_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.characters_left_ -= 2;
- }
- else // There aren't enough characters to make a hex sequence
- {
- str.append(1, '%');
- --impl.characters_left_;
- }
- break;
- case '+':
- str.append(1, ' ');
- break;
- case ' ':
- continue;
- case '=': // the name is complete, now get the corresponding value
- name = str;
- str.clear();
- break;
- case '&': // we now have the name/value pair, so save it
- post_map[name] = str;
- str.clear();
- name.clear();
- break;
- default:
- str.append(1, ch);
- }
- }
- // save the last param (it won't have a trailing &)
- if( !name.empty() )
- post_map[name] = str;//.empty() ? "" : str;
-
-
- return ec;
- }
-
- /// Parse a multipart form.
- boost::system::error_code
- parse_multipart_form(implementation_type& impl, boost::system::error_code& ec)
- {
       impl.fp_.reset
       (
         new typename implementation_type::form_parser_type
@@ -414,495 +334,6 @@
       impl.fp_->parse(ec);
       return ec;
     }
- /*
- parse_boundary_marker(impl, ec);
- //parse_one_form_part(impl, ec);
- move_to_start_of_first_part(impl, ec);
- if (ec == boost::asio::error::eof) {
- //cerr<< " -- Parsing done -- " << endl;
- //return ec.clear();
- return boost::system::error_code();
- }
-
- do {
- parse_form_part(impl, ec);
- }while( !impl.stdin_parsed_ && impl.client_.bytes_left() != 0 );
-
- // Do this just for now, for debugging
- parse_url_encoded_form(impl, ec);
- return ec;
- }
-
- boost::system::error_code
- parse_form_part(implementation_type& impl, boost::system::error_code& ec)
- {
- if (!parse_form_part_meta_data(impl, ec)
- && !parse_form_part_data(impl, ec))
- return ec;
-
- return ec;
- }
-
- boost::system::error_code
- parse_form_part_data(implementation_type& impl, boost::system::error_code& ec)
- {
- std::string regex("^(.*?)" // the data
- "\\x0D\\x0A" // CR LF
- "--" "(");
- if (impl.boundary_markers.size() > 1)
- {
- std::list<std::string>::iterator i(impl.boundary_markers.begin());
- regex = regex + "(?:" + *i + ")";
- ++i;
- for(; i != impl.boundary_markers.end(); ++i)
- {
- regex = regex + "|(?:" + *i + ")";
- }
- }
- else
- {
- regex += *impl.boundary_markers.begin();
- }
-
- regex += ")(--)?[ ]*\\x0D\\x0A";
- //cerr<< "Regex: " << regex << endl;
- boost::regex re(regex);
-
- typedef typename
- implementation_type::buffer_type::iterator
- buffer_iter;
-
- boost::match_results<buffer_iter> matches;
-
- std::size_t offset = impl.offset_;
- //cerr<< "offset = " << offset << endl;
-
- //int runs = 0;
- buffer_iter begin(impl.buf_.begin() + offset);
- buffer_iter end(impl.buf_.end());
-
- for(;;)
- {
- //cerr<< "Starting regex_search" << endl;
- if (!boost::regex_search(begin, end, matches, re
- , boost::match_default
- | boost::match_partial))
- {
- // cerr<< "Can't match any of this. {" << endl
- // << std::string(begin, end) << endl
- // << "}" << endl;
- return boost::system::error_code(345, boost::system::system_category);
- }
- else
- {
- for (unsigned int i = 0; i < matches.size(); ++i)
- {
- if (matches[i].length())
- {
- // cerr<< "[" << i << "] == {" << endl
- // << matches[i] << endl
- // << "}" << endl;
- }
- }
- // cerr<< "matches[0] = {" << endl
- // << matches[0].str() << endl
- // << "}" << endl;
- if (matches[1].matched)
- {
- impl.form_parts_.back().buffer_
- // = boost::range_iterator<;
- = std::make_pair(matches[1].first, matches[1].second);
- // cerr<< "Saved buffer (size: "
- // << std::distance(matches[1].first, matches[1].second)
- // << ") := { " << impl.form_parts_.back().name << ", " << matches[1] << " }" << endl;
- impl.post_vars()[impl.form_parts_.back().name] = matches[1];
- impl.offset_ = offset + matches[0].length();
- //offset += matches[0].length();
- impl.pos_ = matches[0].second;
- //cerr<< "offset := " << offset << endl
- // << "impl.offset_ := " << impl.offset_ << endl;
-
- if (matches[3].matched)
- impl.stdin_parsed_ = true;
- //if (impl.client_.bytes_left() == 0)
- //{
- // cerr<< "Read all the bytes up." << endl;
- //impl.stdin_parsed_ = true;
- return ec;
- //}
- }
- else
- {
- //cerr<< "Reading more data." << endl;
- std::size_t bytes_read = impl.client_.read_some(impl.prepare(64), ec);
- //impl.stdin_bytes_read_ += bytes_read;
-
- if (bytes_read == 0)
- {
- impl.stdin_data_read_ = true;
- return ec;
- }
-
- begin = impl.buf_.begin() + offset;
- end = impl.buf_.end();
- //cerr<< "Buffer (+" << bytes_read << ") == {" << endl
- // << std::string(begin, end) << endl
- // << "}" << endl;
-
- if (ec)
- {
- //cerr<< "Error in parse_form_part_data()." << endl;
- return ec;
- }
-
- }
- }
-
- }
-
-
- return ec;
- }
-
- boost::system::error_code
- parse_form_part_meta_data(implementation_type& impl, boost::system::error_code& ec)
- {
- // Oh dear this is ugly. The move to Boost.Spirit will have to be sooner than planned.
- // (it's a nested, recursive pattern, which regexes don't suit, apparently)
- boost::regex re( "(?:" // [IGNORE] the line may be empty, as meta-data is optional
- "^"
- "([-\\w]+)" // name
- ":[ ^]*" // separator
- "([-/\\w]+)" // optional(?) value
- ""
- "(?:"
- ";"
- "[ ]*" // additional name/value pairs (don't capture)
- "([-\\w]+)" // name
- "[ \\x0D\\x0A]*=[ \\x0D\\x0A]*" // separator
- "(?:\"?([-.\\w]*)\"?)" // value may be empty
- ")?"
- "(?:"
- ";"
- "[ ]*" // additional name/value pairs (don't capture)
- "([-\\w]+)" // name
- "[ \\x0D\\x0A]*=[ \\x0D\\x0A]*" // separator
- "(?:\"?([-.\\w]*)\"?)" // value may be empty
- ")?" // mark the extra n/v pairs optional
- "\\x0D\\x0A"
- ")"
- "(?:"
- "([-\\w]+)" // name
- ":[ ^]*" // separator
- "([-/\\w]+)" // optional(?) value
- ""
- "(?:"
- ";"
- "[ ]*" // additional name/value pairs (don't capture)
- "([-\\w]+)" // name
- "[ \\x0D\\x0A]*=[ \\x0D\\x0A]*" // separator
- "(?:\"?([-.\\w]*)\"?)" // value may be empty
- ")?"
- "(?:"
- ";"
- "[ ]*" // additional name/value pairs (don't capture)
- "([-\\w]+)" // name
- "[ \\x0D\\x0A]*=[ \\x0D\\x0A]*" // separator
- "(?:\"?([-.\\w]*)\"?)" // value may be empty
- ")?" // mark the extra n/v pairs optional
- "\\x0D\\x0A" // followed by the end of the line
- ")?"
- "(\\x0D\\x0A)"); // followed by the 'header termination' line
-
- typedef typename
- implementation_type::buffer_type::iterator
- buffer_iter;
-
- boost::match_results<
- typename
- implementation_type::buffer_type::iterator
- > matches;
-
- std::size_t offset = impl.offset_;
- //cerr.flush();
- impl.pos_ = impl.buf_.begin();
- int runs = 0;
- //cerr<< "Entering for() loop." << endl;
- std::size_t bytes_read = 0;
- for(;;)
- {
- buffer_iter begin(impl.buf_.begin() + offset);
- buffer_iter end(impl.buf_.end());
-
- if (!boost::regex_search(begin, end, matches, re
- , boost::match_default | boost::match_partial))
- {
- //cerr<< "No chance of a match, quitting." << endl;
- impl.stdin_parsed_ = true;
- return ec;
- }
- //cerr<< "matches.str() == {" << endl
- // << matches.str() << endl
- // << "}" << endl
- // << matches.size() << " submatches" << endl;
- // for (unsigned i = matches.size(); i != 0; --i)
- // {
- //cerr<< "match[" << i << "] := { " << matches[i] << " }" << endl;
- //}
- if (matches[0].matched)
- {
- common::form_part part;
- for ( unsigned int i = 1
- ; i < matches.size()
- && matches[i].matched
- && !matches[i].str().empty()
- ; i+=2)
- {
- if (matches[i].str() == "name")
- {
- part.name = matches[i+1];
- // cerr<< "Saved name" << endl;
- }
- else
- {
- part.meta_data_[matches[i]]
- = std::make_pair(matches[i+1].first, matches[i+1].second);
- // cerr<< "Part := { " << matches[i] << ", " << matches[i+1] << " }" << endl;
- //= boost::iterator_range<buffer_iter>(matches[3].first, matches[3].second);
- }
- impl.form_parts_.push_back(part);
-
-
- }
-
- if (matches[13].str() == "\r\n")
- {
- impl.offset_ = offset + matches[0].length();
- offset += matches[0].length();
- impl.pos_ = matches[0].second;
-
- //cerr<< "Current buffer == {" << endl
- // << impl.buffer_string() << endl
- // << "}" << endl;
- //cerr<< "Leaving parse_form_part_meta_data()" << endl;
- return ec;
- }
- else
- {
- throw std::runtime_error("Invalid POST data (header wasn't terminated as expected)");
- }
-
- }else{
- // cerr<< "Not read enough data yet, reading more." << endl;
- bytes_read = impl.client_.read_some(impl.prepare(64), ec);
- if (ec)
- {
- // cerr<< "Error reading data: " << ec.message() << endl;
- // cerr<< "Leaving parse_form_part_meta_data()" << endl;
- return ec;
- }
- // cerr<< "Read " << bytes_read << " bytes." << endl;
- //cerr<< "buffer = {" << endl
- // << impl.buffer_string() << endl
- // << "} or {" << endl;
- //<< std::string(impl.pos_, ;
- / *
- for (unsigned int i = 0; i < matches.size(); ++i)
- {
- if (matches[i].length())
- {
- cerr<< "[" << i << "] == {" << endl
- << matches[i] << endl
- << "}" << endl;
- }
- }
- cerr<< "-------buf------" << endl
- << std::string(begin, end) << endl
- << "----------------" << endl;
- * /
- //offset = impl.buf_.end();
- if (++runs > 40)
- {
- // cerr<< "Run 40 times; bailing out." << endl;
- break;
- }
- // cerr<< "Waiting buffer (unparsed) == {" << endl << std::flush
- // << impl.buffer_string() << endl
- // << "}" << endl
- // << "offset = " << offset << endl;
- //if (bytes_read == 0)
- // break;
- }
- }
-
- //cerr<< "impl.part
-
- // cerr<< "Leaving parse_form_part_meta_data()" << endl;
- return ec;
- }
-
- boost::system::error_code
- move_to_start_of_first_part(implementation_type& impl, boost::system::error_code& ec)
- {
- //cerr<< "Marker = " << impl.boundary_markers.front() << endl
- // << "blah" << "--" + impl.boundary_markers.front() + ")" << endl;
- boost::regex re("((?:.*)?" // optional leading characters
- //"(?:\\x0D\\x0A)|^" // start of line
- "[\\x0D\\x0A^]*?"
- "("
- "--" + impl.boundary_markers.front() + // two dashes and our marker
- ")"
- "(--)?" // optional two dashes (not sure if this is allowed)
- " *\\x0D\\x0A)");
- // on the first marker.
-
- typedef typename
- implementation_type::buffer_type::iterator
- buffer_iter;
-
- boost::match_results<
- typename
- implementation_type::buffer_type::iterator
- > matches;
- //cerr<< "Boundary marker == {" << endl
- // << impl.boundary_marker << endl
- // << "}" << endl;
-
- // get data into our buffer until we reach the first boundary marker.
- int runs = 0;
- std::size_t offset = 0;
-// std::size_t bytes_read = impl.client_.read_some(impl.prepare(32), ec);
-// if (ec || (bytes_read == 0))
-// return ec;
- std::size_t bytes_read = 0;
- for(;;)
- {
- bytes_read = impl.client_.read_some(impl.prepare(32), ec);
- if (ec || (bytes_read == 0))
- return ec;
- buffer_iter begin(impl.buf_.begin());// + offset);
- buffer_iter end(impl.buf_.end());
- if (!boost::regex_search(begin, end //impl.buf_.begin(), impl.buf_.end()
- , matches, re, boost::match_default | boost::match_partial))
- {
- // No chance of matching input with expected, so erase it and start again.
- //std::cerr<< " == buffer = " << std::string(impl.buf_.begin(), impl.buf_.end())
- // << " == capacity = " << impl.buf_.capacity() << " ======= ";
- //impl.buf_.clear();
- // cerr<< "No chance of matching." << endl;
- offset = impl.buf_.size();
- //std::cerr<< "Buffer cleared." << endl;
- continue;
- }
- else
- {
- //std::cerr<< "regex_search == true" << std::endl
- // << "matches[0] =={{ " << matches[0] << " }}=== " << std::endl
- // << "matches[1] =={{ " << matches[1] << " }}=== " << std::endl
- // << "matches[2] =={{ " << matches[2] << " }}=== " << std::endl;
- if (matches[2].matched){
- // cerr<< "Found boundary marker... OK!!" << endl;
- //cerr<< "[0] = " << matches[0].str() << endl;
- //cerr<< "[1] = " << matches[1].str() << endl;
- //impl.offset_ = matches[1].length();
- //impl.pos_ = matches[0].second;
- //cerr<< "setting pos_ to < " << std::string(impl.pos_, impl.pos_ + 5) << "... >" << endl
- // << "setting offset_ = " << impl.offset_ << endl;
- // << std::string(matches[1].first, matches[1].second) << endl;
- //impl.pos_ = matches[1].second;
- //cerr<< "deleting {" << endl
- // << std::string(impl.buf_.begin(), matches[0].second) << endl
- // << "} leaving {" << endl
- // << std::string(matches[0].second, impl.buf_.end()) << endl
- // << "}" << endl;
- //cerr<< "bufsize = " << impl.buf_.size() << endl;
- //cerr<< "bufsize = " << impl.buf_.size() << endl;
- // cerr<< "buffer now (before erase) == {" << endl
- // << std::string(impl.buf_.begin(), impl.buf_.end()) << endl
- // << "}" << endl;
- impl.buf_.erase(impl.buf_.begin(), matches[0].second);
- impl.offset_ = 0;
- impl.pos_ = impl.buf_.begin();
- return ec;
- } else {
- // cerr<< "not read enough data" << std::endl;
- //std::cerr<< "; bytes_read = " << bytes_read
- // << "; bufsize = " << impl.buf_.size()
- // << "; capacity = " << impl.buf_.capacity() << std::flush
- // << "; data = {{" << std::string(impl.buf_.begin(), impl.buf_.end()) << "}}";
-
- if (++runs > 10)
- return ec;
- continue;
- }
- }
- }
-
-
- // skip that line and then erase the buffer
- return ec;
- }
-
- boost::system::error_code
- parse_one_form_part(implementation_type& impl, boost::system::error_code& ec)
- {
- // continuously read data while parsing it until one complete form part has
- // been read.
- // Note, this may mean recursing into embedded sub-parts if necessary, but
- // still only the first *complete* part/sub-part would be read.
- //boost::regex re("\r\n--" + impl.boundary_marker + " +
-
- for(;;)
- {
- //if (impl.client_.read_some(impl.prepare(1024), ec))
- // return ec;
- //boost::asio::read_until(impl.client_, impl.buffer_, impl.boundary_marker, ec);
- break;
-
-
- }
-
- return ec;
- }
-
- /// Get the boundary marker from the CONTENT_TYPE header.
- boost::system::error_code
- parse_boundary_marker(implementation_type& impl, boost::system::error_code& ec)
- {
- // get the meta-data appended to the content_type
- std::string content_type(var(impl.env_vars(), "CONTENT_TYPE", ec));
- //BOOST_ASSERT(!content_type.empty());
-
- //boost::algorithm::ifind(var(impl, "CONTENT_TYPE"), "bounday="
-
- boost::regex re("; ?boundary=\"?([^\"\n\r]+)\"?");
- boost::smatch match_results;
- if (!boost::regex_search(content_type, match_results, re))
- return boost::system::error_code(666, boost::system::system_category);
-
- impl.boundary_marker = match_results[1].str();
- // New boundary markers are added to the front of the list.
- impl.boundary_markers.push_front(match_results[1].str());
-
- / *
- cerr<< "full = " << content_type << endl
- << "full search string = " << match_results[0] << endl
- << "marker length = " << match_results[1].length() << endl
- << "marker = " << impl.boundary_marker << endl
- << "_[2] = " << match_results[2] << endl;
- * /
-
- return ec;
- }
-*/
- /// Read and parse a single cgi POST meta variable (greedily)
- template<typename RequestImpl>
- boost::system::error_code
- parse_one_post_var(RequestImpl& impl, boost::system::error_code& ec)
- {
- //# error "Not implemented"
- return ec;
- }
   };
 
 } // namespace cgi

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/common_headers.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/common_headers.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/common_headers.hpp 2008-04-19 09:23:03 EDT (Sat, 19 Apr 2008)
@@ -13,7 +13,7 @@
 // headers can just include this after other headers.
 
 #include "boost/cgi/buffer.hpp"
-#include "boost/cgi/map.hpp"
+#include "boost/cgi/common/map.hpp"
 #include "boost/cgi/io_service.hpp"
 #include "boost/cgi/streambuf.hpp"
 #include "boost/cgi/basic_request.hpp"

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/extract_params.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/extract_params.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/extract_params.hpp 2008-04-19 09:23:03 EDT (Sat, 19 Apr 2008)
@@ -13,7 +13,7 @@
 #include <boost/tokenizer.hpp>
 #include <boost/system/error_code.hpp>
 
-#include "url_decode.hpp"
+#include "boost/cgi/detail/url_decode.hpp"
 
 namespace cgi {
  namespace detail {
@@ -47,9 +47,9 @@
          name = current_token;
          current_token.clear();
        }else
- if( *iter == "&" )
+ if( *iter == "&" || *iter == ";" )
        {
- destination[name] = current_token;
+ destination[name.c_str()] = current_token;
          current_token.clear();
          name.clear();
        }else
@@ -58,7 +58,7 @@
        }
      }
      if( !name.empty() )
- destination[name] = current_token;
+ destination[name.c_str()] = current_token;
 
      return ec;
    }

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/save_environment.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/save_environment.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/save_environment.hpp 2008-04-19 09:23:03 EDT (Sat, 19 Apr 2008)
@@ -12,7 +12,7 @@
 #include <map>
 #include <string>
 #include <cstdlib>
-#include "boost/cgi/map.hpp"
+#include "boost/cgi/common/map.hpp"
 
 // The process' environment
 #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
@@ -48,7 +48,7 @@
        {
          std::string sa(*env, i);
          std::string sb((*env+i+1), j-i-1);
- env_map[sa] = sb;
+ env_map[sa.c_str()] = sb;
        }
      }
    }

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/url_decode.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/url_decode.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/url_decode.hpp 2008-04-19 09:23:03 EDT (Sat, 19 Apr 2008)
@@ -54,13 +54,6 @@
      return static_cast<char>(ret);
    }
 
- /// Workaround for istreams, since the above can't be used directly
- char url_decode(std::istream& is)
- {
- const char c1 = is.get();
- return url_decode(c1, is.get());
- }
-
    /// URL-decode a string
    std::string url_decode( const std::string& str )
    {

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/client.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/client.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/client.hpp 2008-04-19 09:23:03 EDT (Sat, 19 Apr 2008)
@@ -14,7 +14,7 @@
 #include <boost/logic/tribool.hpp>
 #include <boost/asio/buffer.hpp>
 #include "boost/cgi/tags.hpp"
-#include "boost/cgi/map.hpp"
+#include "boost/cgi/common/map.hpp"
 #include "boost/cgi/io_service.hpp"
 #include "boost/cgi/basic_client.hpp"
 #include "boost/cgi/connections/shareable_tcp_socket.hpp"

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/request_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/request_service.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/request_service.hpp 2008-04-19 09:23:03 EDT (Sat, 19 Apr 2008)
@@ -12,7 +12,7 @@
 #include <boost/system/error_code.hpp>
 
 //#include "boost/cgi/scgi/request_impl.hpp"
-#include "boost/cgi/map.hpp"
+#include "boost/cgi/common/map.hpp"
 #include "boost/cgi/tags.hpp"
 #include "boost/cgi/read.hpp"
 #include "boost/cgi/role_type.hpp"
@@ -426,8 +426,9 @@
       return std::string();
       **/
 
- if( _data.find(_name) != _data.end() )
- return _data[_name];
+ if( _data.find(_name.c_str()) != _data.end() )
+ // **FIXME**
+ return _data[_name.c_str()];
       return "";
     }
 
@@ -650,7 +651,8 @@
         //std::cerr<< "[hw] name := " << name << std::endl;
         //std::cerr<< "[hw] data := " << data << std::endl;
 
- impl.env_vars_[name] = data;
+ // **FIXME**
+ impl.env_vars_[name.c_str()] = data;
       }
 
       return ec;

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/map.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/map.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/map.hpp 2008-04-19 09:23:03 EDT (Sat, 19 Apr 2008)
@@ -9,15 +9,8 @@
 #ifndef CGI_MAP_HPP_INCLUDED__
 #define CGI_MAP_HPP_INCLUDED__
 
-#include <map>
-#include <string>
+#warning This file is deprecated, use common/map.hpp instead.
 
-namespace cgi {
- namespace common {
-
- typedef std::map<std::string,std::string> map;
-
- } // namespace common
-} // namespace cgi
+#include "boost/cgi/common/map.hpp"
 
 #endif // CGI_MAP_HPP_INCLUDED__


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