Boost logo

Boost-Commit :

From: lists.drrngrvy_at_[hidden]
Date: 2008-02-10 09:35:43


Author: drrngrvy
Date: 2008-02-10 09:35:42 EST (Sun, 10 Feb 2008)
New Revision: 43208
URL: http://svn.boost.org/trac/boost/changeset/43208

Log:
Adding return_() macro to make closing requests nicer-looking. (just a thought)

Added:
   sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/request_fwd.hpp (contents, props changed)
   sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/return.hpp (contents, props changed)
Text files modified:
   sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi.hpp | 7 +++++++
   sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/request_service.hpp | 9 ++++-----
   sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/response.hpp | 5 +++++
   3 files changed, 16 insertions(+), 5 deletions(-)

Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi.hpp 2008-02-10 09:35:42 EST (Sun, 10 Feb 2008)
@@ -18,6 +18,13 @@
 //#include "boost/cgi/fcgi/request_acceptor_service.hpp"
 #include "boost/cgi/detail/common_headers.hpp"
 
+namespace cgi {
+ namespace fcgi {
+ using namespace ::cgi;
+ using namespace ::cgi::common;
+ } // namespace fcgi
+} // namespace cgi
+
 /// Dump fcgi stuff into the boost namespace
 namespace boost {
  namespace fcgi {

Added: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/request_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/request_fwd.hpp 2008-02-10 09:35:42 EST (Sun, 10 Feb 2008)
@@ -0,0 +1,26 @@
+// -- fcgi/request_fwd.hpp --
+//
+// Copyright (c) Darren Garvey 2007.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+////////////////////////////////////////////////////////////////
+#ifndef CGI_FCGI_REQUEST_FWD_HPP_INCLUDED__
+#define CGI_FCGI_REQUEST_FWD_HPP_INCLUDED__
+
+#include "boost/cgi/basic_request_fwd.hpp"
+
+namespace cgi {
+ namespace fcgi {
+
+ typedef service service_t;
+ class fcgi_request_service;
+
+ typedef basic_request<fcgi_request_service, service_t> request;
+
+ } // namespace fcgi
+} // namespace cgi
+
+#endif // CGI_FCGI_REQUEST_FWD_HPP_INCLUDED__
+

Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/request_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/request_service.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/request_service.hpp 2008-02-10 09:35:42 EST (Sun, 10 Feb 2008)
@@ -221,18 +221,18 @@
         //impl.client_.parse_packet(impl, ec);
         parse_packet(impl, ec);
       }
-/*
+
       const std::string& request_method = env(impl, "REQUEST_METHOD", ec);
       if (request_method == "GET")
         if (parse_get_vars(impl, ec))
- return ec;
+ return ec;
+/** FIXME **
       else
       if (request_method == "POST" && parse_stdin)
         if (parse_post_vars(impl, ec))
               return ec;
-
- parse_cookie_vars(impl, ec);
 */
+ parse_cookie_vars(impl, ec);
 
       std::cerr<< "done!" << std::endl;
       return ec;
@@ -369,7 +369,6 @@
     }
 
     /// Read and parse the HTTP_COOKIE meta variable
- template<typename RequestImpl>
     boost::system::error_code&
     parse_cookie_vars(implementation_type& impl, boost::system::error_code& ec)
     {

Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/response.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/response.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/response.hpp 2008-02-10 09:35:42 EST (Sun, 10 Feb 2008)
@@ -247,6 +247,11 @@
       return http_status_;
     }
 
+ http::status_code& status()
+ {
+ return http_status_;
+ }
+
     /// Allow more headers to be added (WARNING: avoid using this).
     void unterminate_headers()
     {

Added: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/return.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/return.hpp 2008-02-10 09:35:42 EST (Sun, 10 Feb 2008)
@@ -0,0 +1,51 @@
+// -- return.hpp --
+//
+// Copyright (c) Darren Garvey 2007.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+////////////////////////////////////////////////////////////////
+#ifndef CGI_RETURN_HPP_INCLUDED__
+#define CGI_RETURN_HPP_INCLUDED__
+
+#include "boost/cgi/response.hpp"
+#include "boost/cgi/basic_request.hpp"
+
+namespace cgi {
+ namespace common {
+
+ template<typename Response, typename Request>
+ int return_helper(Response& resp, Request& req, int program_status)
+ {
+ boost::system::error_code ec;
+ resp.send(req, ec);
+ if (ec) return ec;
+
+ req.close(resp.status(), program_status);
+
+ return program_status;
+ }
+
+ template<typename R1, typename R2>
+ void send_helper(R1& resp, R2& req)
+ {
+ resp.send(req.client());
+ }
+
+ void close_helper(response& resp, boost::fcgi::request& req, int prog_status)
+ {
+ req.close(resp.status(), prog_status);
+ }
+
+#define return_(RESP, REQ, STATUS) \
+ send_helper(RESP, REQ); \
+ ::cgi::common::close_helper(RESP, REQ, STATUS); \
+ return STATUS;
+
+//return return_helper(resp, req, status)
+
+ } // namespace common
+} // namespace cgi
+
+#endif // CGI_RETURN_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