Boost logo

Boost-Commit :

From: lists.drrngrvy_at_[hidden]
Date: 2007-08-20 20:38:02


Author: drrngrvy
Date: 2007-08-20 20:37:59 EDT (Mon, 20 Aug 2007)
New Revision: 38810
URL: http://svn.boost.org/trac/boost/changeset/38810

Log:
fixing conflicting files
Text files modified:
   sandbox/SOC/2007/cgi/boost/cgi/basic_request.hpp | 51 ++++++++++++++------------
   sandbox/SOC/2007/cgi/boost/cgi/cgi/request_service.hpp | 1
   sandbox/SOC/2007/cgi/boost/cgi/detail/cgi_service_impl_base.hpp | 77 ++++++++++++++++++++++++++++++++-------
   sandbox/SOC/2007/cgi/boost/cgi/detail/extract_params.hpp | 7 ++-
   sandbox/SOC/2007/cgi/boost/cgi/detail/url_decode.hpp | 31 +++++++++------
   sandbox/SOC/2007/cgi/libs/cgi/doc/src/user_guide/tutorial/meta_variables.qbk | 2
   sandbox/SOC/2007/cgi/libs/cgi/example/acgi/Jamfile.v2 | 5 ++
   sandbox/SOC/2007/cgi/libs/cgi/example/acgi/main.cpp | 17 +++-----
   sandbox/SOC/2007/cgi/libs/cgi/util/system/Jamfile.v2 | 2
   9 files changed, 126 insertions(+), 67 deletions(-)

Modified: sandbox/SOC/2007/cgi/boost/cgi/basic_request.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/basic_request.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/basic_request.hpp 2007-08-20 20:37:59 EDT (Mon, 20 Aug 2007)
@@ -77,10 +77,6 @@
                          , Role, Allocator > type;
     typedef RequestService service_type;
     typedef typename service_type::protocol_type protocol_type;
- typedef typename boost::mpl::if_c<is_async<typename RequestService::protocol_type>::value
- , basic_io_object<RequestService>
- , basic_sync_io_object<RequestService>
- >::type base_type;
     typedef ProtocolService protocol_service_type;
     typedef boost::shared_ptr<type> pointer;
 
@@ -363,7 +359,7 @@
     std::string meta_form(const std::string& name, bool greedy = true)
     {
       boost::system::error_code ec;
- std::string ret = this->service.meta_form(this->impl, name, ec, greedy);
+ std::string ret = meta_form(name, ec, greedy);
       detail::throw_error(ec);
       return ret;
     }
@@ -376,7 +372,14 @@
     std::string meta_form(const std::string& name, boost::system::error_code& ec
                          , bool greedy = true)
     {
- return this->service.meta_form(this->impl, name, ec, greedy);
+ std::string rm(request_method());
+ if (rm == "GET")
+ return this->service.meta_get(this->impl, name, ec);
+ else
+ if (rm == "POST")
+ return this->service.meta_post(this->impl, name, ec, greedy);
+ else
+ return "";
     }
 
     /// Get a `cgi::map&` corresponding to all of the HTTP_COOKIE variables
@@ -487,55 +490,55 @@
 
     // Some helper functions for the basic CGI 1.1 meta-variables
     std::string auth_type()
- { return this->service.meta_env(this->impl, "AUTH_TYPE"); }
+ { return meta_env("AUTH_TYPE"); }
 
     std::string content_length()
- { return this->service.meta_env(this->impl, "CONTENT_LENGTH"); }
+ { return meta_env("CONTENT_LENGTH"); }
 
     std::string content_type()
- { return this->service.meta_env(this->impl, "CONTENT_TYPE"); }
+ { return meta_env("CONTENT_TYPE"); }
 
     std::string gateway_interface()
- { return this->service.meta_env(this->impl, "GATEWAY_INTERFACE"); }
+ { return meta_env("GATEWAY_INTERFACE"); }
 
     std::string path_info()
- { return this->service.meta_env(this->impl, "PATH_INFO"); }
+ { return meta_env("PATH_INFO"); }
 
     std::string path_translated()
- { return this->service.meta_env(this->impl, "PATH_TRANSLATED"); }
+ { return meta_env("PATH_TRANSLATED"); }
 
     std::string query_string()
- { return this->service.meta_env(this->impl, "QUERY_STRING"); }
+ { return meta_env("QUERY_STRING"); }
 
     std::string remote_addr()
- { return this->service.meta_env(this->impl, "REMOTE_ADDR"); }
+ { return meta_env("REMOTE_ADDR"); }
 
     std::string remote_host()
- { return this->service.meta_env(this->impl, "REMOTE_HOST"); }
+ { return meta_env("REMOTE_HOST"); }
 
     std::string remote_ident()
- { return this->service.meta_env(this->impl, "REMOTE_IDENT"); }
+ { return meta_env("REMOTE_IDENT"); }
 
     std::string remote_user()
- { return this->service.meta_env(this->impl, "REMOTE_USER"); }
+ { return meta_env("REMOTE_USER"); }
 
     std::string request_method()
- { return this->service.meta_env(this->impl, "REQUEST_METHOD"); }
+ { return meta_env("REQUEST_METHOD"); }
 
     std::string script_name()
- { return this->service.meta_env(this->impl, "SCRIPT_NAME"); }
+ { return meta_env("SCRIPT_NAME"); }
 
     std::string server_name()
- { return this->service.meta_env(this->impl, "SERVER_NAME"); }
+ { return meta_env("SERVER_NAME"); }
 
     std::string server_port()
- { return this->service.meta_env(this->impl, "SERVER_PORT"); }
+ { return meta_env("SERVER_PORT"); }
 
     std::string server_protocol()
- { return this->service.meta_env(this->impl, "SERVER_PROTOCOL"); }
+ { return meta_env("SERVER_PROTOCOL"); }
 
     std::string server_software()
- { return this->service.meta_env(this->impl, "SERVER_SOFTWARE"); }
+ { return meta_env("SERVER_SOFTWARE"); }
 
 
     /// The role that the request is playing
@@ -570,7 +573,7 @@
 
     void set_status(http::status_code status)
     {
- this->service.set_http_status(this->impl, status);
+ this->service.set_status(this->impl, status);
     }
 
     /// Set a user cookie

Modified: sandbox/SOC/2007/cgi/boost/cgi/cgi/request_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/cgi/request_service.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/cgi/request_service.hpp 2007-08-20 20:37:59 EDT (Mon, 20 Aug 2007)
@@ -45,7 +45,6 @@
 
     void construct(implementation_type& impl)
     {
- std::cerr<< "making connection";
       impl.connection() = implementation_type::connection_type::create();
     }
 

Modified: sandbox/SOC/2007/cgi/boost/cgi/detail/cgi_service_impl_base.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/detail/cgi_service_impl_base.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/detail/cgi_service_impl_base.hpp 2007-08-20 20:37:59 EDT (Mon, 20 Aug 2007)
@@ -62,13 +62,11 @@
         , boost::system::error_code& ec)
     {
       const std::string& request_method = meta_env(impl, "REQUEST_METHOD", ec);
- if (request_method == "GET")
- if (parse_get_vars(impl, ec))
- return ec;
+ if (request_method == "GET" && parse_get_vars(impl, ec))
+ return ec;
       else
- if (request_method == "POST" && parse_stdin)
- if (parse_post_vars(impl, ec))
- return ec;
+ if (request_method == "POST" && parse_stdin && parse_post_vars(impl, ec))
+ return ec;
 
       parse_cookie_vars(impl, ec);
       return ec;
@@ -119,7 +117,7 @@
       return "";
     }
 
- std::string meta_get(implementation_type& impl, const std::string& name
+ std::string meta_get(implementation_type& impl, const std::string& name
                         , boost::system::error_code& ec)
     {
       return var(impl.get_vars(), name, ec);
@@ -188,6 +186,11 @@
       return responder;
     }
 
+ /// Set the http status (this does nothing for aCGI)
+ void set_status(implementation_type& impl, http::status_code&)
+ {
+ }
+
   protected:
     /// Read and parse the cgi GET meta variables
     template<typename RequestImpl>
@@ -195,10 +198,10 @@
     parse_get_vars(RequestImpl& impl, boost::system::error_code& ec)
     {
       detail::extract_params(meta_env(impl, "QUERY_STRING", ec)
- , impl.get_vars()
- , boost::char_separator<char>
- ("", "=&", boost::keep_empty_tokens)
- , ec);
+ , impl.get_vars()
+ , boost::char_separator<char>
+ ("", "=&", boost::keep_empty_tokens)
+ , ec);
 
       return ec;
     }
@@ -230,13 +233,57 @@
     parse_post_vars(RequestImpl& impl, boost::system::error_code& ec)
     {
       // Make sure this function hasn't already been called
- //BOOST_ASSERT( impl.post_vars_.empty() );
-
- //# error "Not implemented"
+ std::cerr<< "blah";
+ BOOST_ASSERT (!impl.stdin_parsed());
+ std::cerr<< "wom";
+ std::cerr.flush();
+ std::istream& is(std::cin);
+ char ch;
+ std::string name;
+ std::string str;
+ cgi::map& post_map(impl.post_vars());
+
+ const char* a = ::getenv("content_length");
+ if (a) str = a;
+ else std::cerr<< "no content-length";
+
+ std::cerr<< "content length = ";
+ //var(impl.get_vars(), "CONTENT_LENGTH", ec);
+ std::cerr.flush();
 
- if (impl.stdin_parsed())
+ while( is.get(ch) )
       {
+ std::cerr<< "; ch=" << ch << "; ";
+ switch(ch)
+ {
+ case '%': // unencode a hex character sequence
+ // note: function params are resolved in an undefined order!
+ str += detail::url_decode(is);
+ break;
+ case '+':
+ str += ' ';
+ 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 += ch;
+ }
+ //LOG<< "name=" << name << "; str=" << str << std::endl;
       }
+ // save the last param (it won't have a trailing &)
+ if( !name.empty() )
+ post_map[name] = str;//.empty() ? "" : str;
+
+
 
       return ec;
     }

Modified: sandbox/SOC/2007/cgi/boost/cgi/detail/extract_params.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/detail/extract_params.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/detail/extract_params.hpp 2007-08-20 20:37:59 EDT (Mon, 20 Aug 2007)
@@ -18,6 +18,7 @@
 namespace cgi {
  namespace detail {
 
+ /// Extract name/value pairs from a supplied string buffer
    template<typename Map, typename Separator>
    boost::system::error_code& extract_params(const std::string& input
                                             , Map& destination
@@ -26,9 +27,9 @@
    {
      if( input.empty() )
        return ec;// = boost::system::error_code(34, boost::system::errno_ecat);
-
- typedef typename boost::tokenizer<Separator> tokenizer;
-
+
+ typedef typename boost::tokenizer<Separator> tokenizer;
+
      tokenizer toker(input, separator);
 
      std::string name, current_token;

Modified: sandbox/SOC/2007/cgi/boost/cgi/detail/url_decode.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/detail/url_decode.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/detail/url_decode.hpp 2007-08-20 20:37:59 EDT (Mon, 20 Aug 2007)
@@ -15,19 +15,26 @@
  namespace detail {
 
    /// Take two characters (a hex sequence) and return a char
- char url_decode( const char c1, const char c2 )
+ char url_decode( const char& c1, const char& c2 )
    {
- int ret = ( (c1 >= 'A' && c1 <= 'Z') || (c1 >= 'a' && c1 <= 'z')
- ? ((c1 & 0xdf) - 'A') + 10
- : (c1 - '0')
- ) << 4;
-
- ret += ( (c2 >= 'A' && c2 <= 'Z') || (c2 >= 'a' && c2 <= 'z')
- ? ((c2 & 0xdf) - 'A') + 10
- : (c2 - '0')
+ int ret = ( (c1 >= 'A' && c1 <= 'Z') || (c1 >= 'a' && c1 <= 'z')
+ ? ((c1 & 0xdf) - 'A') + 10
+ : (c1 - '0')
+ ) << 4;
+
+ ret += ( (c2 >= 'A' && c2 <= 'Z') || (c2 >= 'a' && c2 <= 'z')
+ ? ((c2 & 0xdf) - 'A') + 10
+ : (c2 - '0')
             );
 
- return static_cast<char>(ret);
+ 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
@@ -37,7 +44,7 @@
 
      for( unsigned int i=0; i < str.size(); i++ )
      {
- switch( str[i] )
+ switch( str[i] )
        {
          case ' ':
            break;
@@ -52,7 +59,7 @@
            ret += str[i];
        }
      }
-
+
      return ret;
    }
 

Modified: sandbox/SOC/2007/cgi/libs/cgi/doc/src/user_guide/tutorial/meta_variables.qbk
==============================================================================
--- sandbox/SOC/2007/cgi/libs/cgi/doc/src/user_guide/tutorial/meta_variables.qbk (original)
+++ sandbox/SOC/2007/cgi/libs/cgi/doc/src/user_guide/tutorial/meta_variables.qbk 2007-08-20 20:37:59 EDT (Mon, 20 Aug 2007)
@@ -14,7 +14,7 @@
 A request [*must] be [link __loading__ loaded] before the meta-data can be accessed. The ['only] exception to this rule is calling `meta_env()` on CGI and aCGI request objects. These are (essentially) equivalent to a call to [@http://tinyurl.com/3cqrd5 `::getenv()`] and will always work. However, exploit this 'feature' cautiously as it won't work with FastCGI or SCGI requests.
 ]
 
-There are six member functions of `basic_request<>` that provide access to the meta-variables associated to that request.
+In all, there are twelve member functions of [classref cgi::basic_request `basic_request<>`] that provide access to the meta-variables associated to that request. Six of those return a `cgi::map` which you may use like a `std::map` to search through the complete list of variables.
 
 [table Meta-variable accessor functions
   [[Function signature] [Purpose]]

Modified: sandbox/SOC/2007/cgi/libs/cgi/example/acgi/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/libs/cgi/example/acgi/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/libs/cgi/example/acgi/Jamfile.v2 2007-08-20 20:37:59 EDT (Mon, 20 Aug 2007)
@@ -22,3 +22,8 @@
     <define>BOOST_ALL_NO_LIB=1
     <toolset>gcc:<linkflags>-lpthread
   ;
+
+install _
+ : acgi
+ : <location>/var/www/cgi-bin
+ ;
\ No newline at end of file

Modified: sandbox/SOC/2007/cgi/libs/cgi/example/acgi/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/libs/cgi/example/acgi/main.cpp (original)
+++ sandbox/SOC/2007/cgi/libs/cgi/example/acgi/main.cpp 2007-08-20 20:37:59 EDT (Mon, 20 Aug 2007)
@@ -28,26 +28,23 @@
 {
   cgi::acgi_service service;
   cgi::acgi_request req(service);
- req.load();
-
- std::cerr<< "checking in";
+ req.load(true);
 
   std::string buf("Content-type: text/html\r\n\r\nHello there, Universe.");
   cgi::write(req, cgi::buffer(buf.c_str(), buf.size()));
 
- std::cerr<< "checking reply";
-
   cgi::reply rep;
 
- rep<< "Content-type: <br />Yuppers.";
+ rep<< "<br />What's your name?<br />";
+ std::cerr<< std::endl << "name = " << req.meta_form("name") << std::endl;
+ std::cerr.flush();
 
   rep<< "<form method='POST'>"
         "<input name='name' type='text' value='"
- << req.meta_get("name")
+ << req.meta_form("name")
      << "'></input>"
         "<input type='submit'></input>"
- "</form>"
- ;
+ "</form>";
 
   rep.send(req);
 
@@ -67,7 +64,7 @@
   }
   */
 
- rep.flush(req);
+ //rep.flush(req);
 
   return 0;
 }

Modified: sandbox/SOC/2007/cgi/libs/cgi/util/system/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/libs/cgi/util/system/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/libs/cgi/util/system/Jamfile.v2 2007-08-20 20:37:59 EDT (Mon, 20 Aug 2007)
@@ -2,5 +2,5 @@
 
 lib boost_system
   :
- : <file>/usr/local/lib/libboost_system-gcc41.a
+ : <file>/usr/local/lib/libboost_system.a
   ;


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