|
Boost-Commit : |
From: drrngrvy_at_[hidden]
Date: 2007-07-20 04:14:05
Author: drrngrvy
Date: 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
New Revision: 7487
URL: http://svn.boost.org/trac/boost/changeset/7487
Log:
Adding basic tests; added some forward-declaration headers; also added various asio functions/classes to the cgi namespace (eg. io_service, (async_)read, (async_)write, buffer, streambuf); added cgi::map
Added:
sandbox/SOC/2007/cgi/boost/cgi/basic_gateway.hpp
sandbox/SOC/2007/cgi/boost/cgi/basic_gateway_fwd.hpp
sandbox/SOC/2007/cgi/boost/cgi/basic_io_object.hpp
sandbox/SOC/2007/cgi/boost/cgi/basic_request_fwd.hpp
sandbox/SOC/2007/cgi/boost/cgi/buffer.hpp
sandbox/SOC/2007/cgi/boost/cgi/cgi/
sandbox/SOC/2007/cgi/boost/cgi/cgi/acgi_request.hpp
sandbox/SOC/2007/cgi/boost/cgi/cgi/cgi_protocol_service.hpp
sandbox/SOC/2007/cgi/boost/cgi/cgi/cgi_request.hpp
sandbox/SOC/2007/cgi/boost/cgi/cgi/cgi_service.hpp
sandbox/SOC/2007/cgi/boost/cgi/connections/async_stdio.hpp
sandbox/SOC/2007/cgi/boost/cgi/connections/stdio.hpp
sandbox/SOC/2007/cgi/boost/cgi/connections/tcp_socket.hpp
sandbox/SOC/2007/cgi/boost/cgi/data_sink.hpp
sandbox/SOC/2007/cgi/boost/cgi/data_source.hpp
sandbox/SOC/2007/cgi/boost/cgi/detail/protocol_traits.hpp
sandbox/SOC/2007/cgi/boost/cgi/detail/throw_error.hpp
sandbox/SOC/2007/cgi/boost/cgi/gateway_impl/
sandbox/SOC/2007/cgi/boost/cgi/gateway_impl/acgi_gateway_impl.hpp
sandbox/SOC/2007/cgi/boost/cgi/gateway_impl/async_cgi_gateway_impl.hpp
sandbox/SOC/2007/cgi/boost/cgi/gateway_impl/cgi_gateway_impl.hpp
sandbox/SOC/2007/cgi/boost/cgi/gateway_service/
sandbox/SOC/2007/cgi/boost/cgi/gateway_service/acgi_gateway_service.hpp
sandbox/SOC/2007/cgi/boost/cgi/gateway_service/async_cgi_gateway_service.hpp
sandbox/SOC/2007/cgi/boost/cgi/gateway_service/cgi_gateway_service.hpp
sandbox/SOC/2007/cgi/boost/cgi/io_service.hpp
sandbox/SOC/2007/cgi/boost/cgi/io_service_provider.hpp
sandbox/SOC/2007/cgi/boost/cgi/io_service_provider_fwd.hpp
sandbox/SOC/2007/cgi/boost/cgi/read.hpp
sandbox/SOC/2007/cgi/boost/cgi/request_ostream.hpp
sandbox/SOC/2007/cgi/boost/cgi/request_service_fwd.hpp
sandbox/SOC/2007/cgi/boost/cgi/role_type.hpp
sandbox/SOC/2007/cgi/boost/cgi/service_impl/cgi_service_impl_base.hpp
sandbox/SOC/2007/cgi/boost/cgi/streambuf.hpp
sandbox/SOC/2007/cgi/boost/cgi/tags.hpp
sandbox/SOC/2007/cgi/boost/cgi/write.hpp
sandbox/SOC/2007/cgi/libs/cgi/test/compile/
sandbox/SOC/2007/cgi/libs/cgi/test/compile/acgi_request.cpp
sandbox/SOC/2007/cgi/libs/cgi/test/compile/async_stdio_connection.cpp
sandbox/SOC/2007/cgi/libs/cgi/test/compile/cgi_request.cpp
sandbox/SOC/2007/cgi/libs/cgi/test/compile/cgi_service.cpp
sandbox/SOC/2007/cgi/libs/cgi/test/compile/fcgi_service.cpp
sandbox/SOC/2007/cgi/libs/cgi/test/compile/is_async_test.cpp
sandbox/SOC/2007/cgi/libs/cgi/test/compile/reply.cpp
sandbox/SOC/2007/cgi/libs/cgi/test/compile/stdio_connection.cpp
sandbox/SOC/2007/cgi/libs/cgi/test/compile/tcp_connection.cpp
sandbox/SOC/2007/cgi/libs/cgi/test/run/
sandbox/SOC/2007/cgi/libs/cgi/test/run/stdio_connection.cpp
Removed:
sandbox/SOC/2007/cgi/boost/cgi/cgi_request_service.hpp
sandbox/SOC/2007/cgi/boost/cgi/connections/async_stdio_connection.hpp
sandbox/SOC/2007/cgi/boost/cgi/connections/stdio_connection.hpp
sandbox/SOC/2007/cgi/boost/cgi/connections/tcp_connection.hpp
sandbox/SOC/2007/cgi/boost/cgi/detail/request_traits.hpp
sandbox/SOC/2007/cgi/boost/cgi/gateway.hpp
sandbox/SOC/2007/cgi/boost/cgi/ostream.hpp
sandbox/SOC/2007/cgi/boost/cgi/protocols.hpp
Text files modified:
sandbox/SOC/2007/cgi/boost/cgi.hpp | 2
sandbox/SOC/2007/cgi/boost/cgi/basic_connection.hpp | 74 +++++--
sandbox/SOC/2007/cgi/boost/cgi/basic_protocol_service.hpp | 93 +++++----
sandbox/SOC/2007/cgi/boost/cgi/basic_request.hpp | 266 ++++++++++++++--------------
sandbox/SOC/2007/cgi/boost/cgi/connection_base.hpp | 18
sandbox/SOC/2007/cgi/boost/cgi/detail/extract_params.hpp | 20 +
sandbox/SOC/2007/cgi/boost/cgi/detail/service_base.hpp | 60 +++---
sandbox/SOC/2007/cgi/boost/cgi/detail/url_decode.hpp | 34 +-
sandbox/SOC/2007/cgi/boost/cgi/gateway_service.hpp | 93 +++++----
sandbox/SOC/2007/cgi/boost/cgi/http/status_code.hpp | 154 ++++++++--------
sandbox/SOC/2007/cgi/boost/cgi/is_async.hpp | 35 --
sandbox/SOC/2007/cgi/boost/cgi/logger.hpp | 12
sandbox/SOC/2007/cgi/boost/cgi/map.hpp | 7
sandbox/SOC/2007/cgi/boost/cgi/reply.hpp | 14
sandbox/SOC/2007/cgi/boost/cgi/request.hpp | 198 --------------------
sandbox/SOC/2007/cgi/boost/cgi/request_base.hpp | 30 +-
sandbox/SOC/2007/cgi/boost/cgi/request_impl/async_cgi_request_impl.hpp | 2
sandbox/SOC/2007/cgi/boost/cgi/request_impl/cgi_request_impl.hpp | 60 +++---
sandbox/SOC/2007/cgi/boost/cgi/request_service.hpp | 63 ++++--
sandbox/SOC/2007/cgi/boost/cgi/service_impl/async_cgi_service_impl.hpp | 7
sandbox/SOC/2007/cgi/boost/cgi/service_impl/cgi_service_impl.hpp | 222 ++---------------------
sandbox/SOC/2007/cgi/libs/cgi/build/Jamfile.v2 | 14
sandbox/SOC/2007/cgi/libs/cgi/doc/Jamfile.v2 | 65 ++++---
sandbox/SOC/2007/cgi/libs/cgi/doc/cgi.qbk | 370 ++-------------------------------------
sandbox/SOC/2007/cgi/libs/cgi/test/Jamfile.v2 | 20 +
25 files changed, 681 insertions(+), 1252 deletions(-)
Modified: sandbox/SOC/2007/cgi/boost/cgi.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -12,5 +12,7 @@
// #include all headers except for cgi/cgi.hpp, cgi/fcgi.hpp, cgi/scgi.hpp
#include "cgi/basic_request.hpp"
+#include "cgi/request.hpp"
+#include "cgi/reply.hpp"
#endif // CGI_HPP_INCLUDED__
Modified: sandbox/SOC/2007/cgi/boost/cgi/basic_connection.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/basic_connection.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/basic_connection.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -12,38 +12,72 @@
#include <istream>
#include <ostream>
#include <boost/asio.hpp>
+
+#include "tags.hpp"
#include "connection_base.hpp"
+//#include "connections/async_stdio_connection_impl.hpp"
namespace cgi {
- template< typename ConnectionType, typename ProtocolService>
- class basic_connection
- : connection_base
+ template<typename ConnectionType>
+ class basic_connection;
+
+/*
+ : public connection_base
//, connection_wrapper<ConnectionType>
{
public:
- typedef connection_impl<ConnectionType
- , ProtocolService::protocol_type> impl_type;
- typedef boost::shared_ptr<conection_base> pointer;
-
- explicit basic_connection(protocol_service_type& ps)
- : impl_(ps)
- {
- }
-
- static pointer create()
- {
- return new basic_connection<protocol_service_type
- , connection_type>(impl_.protocol_service());
- }
+ // typedef ConnectionType impl_type;
+ // //typedef boost::shared_ptr<conection_base> pointer;
+
+ // explicit basic_connection(protocol_service_type& ps)
+ // : impl_(ps)
+ // {
+ // }
+
+ // static pointer create()
+ // {
+ // return new basic_connection<protocol_service_type
+ // , connection_type>(impl_.protocol_service());
+ // }
- private:
- impl_type impl_;
+ //private:
+ // impl_type impl_;
};
+*/
+
+ // template<typename ProtocolService>
+ //class async_stdio_connection_impl;
+
+ //template<typename ProtocolService>
+ //class stdio_connection_impl;
+
+
+ //#include "connections/stdio_connection_impl.hpp"
+
+ //template<typename ProtocolService>
+ // class basic_connection<tags::stdio, ProtocolService>
+ // : public stdio_connection_impl<ProtocolService>
+ //{
+ //};
+
+ //typedef basic_connection<tags::stdio, stdio_connection
+
+
+ //#include "connections/async_stdio_connection_impl.hpp"
+
+ //template<typename ProtocolService>
+ //class basic_connection<tags::async_stdio, ProtocolService>
+ // : public async_stdio_connection_impl<ProtocolService>
+ //{
+ //};
- typedef basic_connection<tags::tcp> tcp_connection;
+ //typedef basic_connection<tags::tcp> tcp_connection;
//typedef basic_connection<tags::pipe> pipe_connection; // not implemented
+//#include "connections/stdio_connection.hpp"
+//#include "connections/async_stdio_connection.hpp"
+//#include "connections/tcp_connection.hpp"
} // namespace cgi
Added: sandbox/SOC/2007/cgi/boost/cgi/basic_gateway.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/basic_gateway.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,192 @@
+// -- basic_gateway.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_BASIC_GATEWAY_HPP_INCLUDED__
+#define CGI_BASIC_GATEWAY_HPP_INCLUDED__
+
+#include <boost/bind.hpp>
+#include <boost/shared_ptr.hpp>
+
+#include "basic_protocol_service_fwd.hpp"
+//#include "basic_connection.hpp"
+#include "detail/protocol_traits.hpp"
+
+namespace cgi {
+
+ /// The gateway class manages connections
+ /**
+ * New connections are accepted through here, via a call to accept();
+ * used/corrupted connections are closed via a call to stop(conn_ptr);
+ * all connections are closed via a call to stop_all().
+ *
+ * If you want to use the gateway after a call to stop_all(), you must
+ * call reset() and pass it the maximum number of connections the gateway
+ * can take.
+ */
+ template<typename Protocol>
+ class basic_gateway
+ {
+ public:
+ //typedef CommonGatewayService service_type;
+ //typedef typename CommonGatewayService::protocol_type protocol_type;
+ typedef Protocol protocol_type;
+ typedef basic_protocol_service<protocol_type> protocol_service_type;
+
+ typedef detail::protocol_traits<protocol_type> traits;
+ typedef typename traits::connection_type connection_type;
+ typedef typename traits::gateway_impl_type impl_type;
+ typedef typename traits::gateway_service_type service_type;
+ typedef boost::shared_ptr<connection_type> conn_ptr;
+
+ /// Constructors
+ explicit basic_gateway(protocol_service_type& pservice)
+ : service_(pservice)
+ {
+ service_.construct(impl_);
+ }
+
+ explicit basic_gateway()
+ {
+ service_.construct(impl_);
+ }
+
+ /// Destructor
+ ~basic_gateway()
+ {
+ service_.destroy(impl_);
+ }
+
+ /// Start a sychronous accept
+ /**
+ * This returns false unless the connection is already established. This is
+ * true with standard CGI, for example, where the connection is simply a
+ * wrapper over standard input/output.
+ *
+ * If there is a need to differentiate between a fail and a 'waiting' accept
+ * then a tribool could be returned from here.
+ */
+/* ** NOT BELONGING HERE ** (should be encapsulated in the acceptor classes)
+ template<typename Request>
+ boost::system::error_code&
+ accept(Request& request, boost::system::error_code& ec)
+ {
+ if( service_.accept(request.connection(), ec) )
+ {
+ connections_.insert(request.connection());
+ }
+
+ return ec;
+
+ //conn_ptr new_conn(connection_type::create());
+ //acceptor_.accept(new_conn->socket()
+ // , boost::bind(&cgi::gateway::handle_accept
+ // , this, new_conn
+ // , boost::placeholders::error));
+ //return false;
+ }
+
+ /// Start an asynchronous accept
+ template<typename Handler>
+ void async_accept(conn_ptr conn, Handler handler)
+ {
+ service_.async_accept(handler);
+ }
+*/
+ /// Cleanly start the connection
+ void start(conn_ptr cptr)
+ {
+ service_.start(impl_, cptr);
+ //cptr->start();
+ //protocol_service_.connections_.insert(cptr);
+ }
+
+ /// Cleanly stop the connection
+ void stop(conn_ptr cptr)
+ {
+ //service_.stop(impl_, cptr);
+ //BOOST_ASSERT(protocol_service_.connections_.find(cptr));
+
+ //cptr->stop();
+ //protocol_service_.connections_.erase(cptr);
+ }
+
+ /// Cleanly stop all connections
+ void stop()
+ {
+ service_.stop(impl_);
+ //std::for_each(protocol_service_.connection_.begin()
+ // , protocol_service_.connections_.end()
+ // , boost::bind(&connection_type::stop, _1));
+ //protocol_service_.connections_.clear();
+ }
+
+ /// Reset the gateway
+ /**
+ * All connections are gracefully closed and then the gateway is set up for
+ * reuse.
+ *
+ * @param max_connections the available slots is reset to this value
+ */
+ void reset(int max_connections)
+ {
+ service_.reset(impl_);
+ //stop();
+ //available_slots_ = max_connections;
+ }
+
+ private:
+ //protocol_service_type& protocol_service_;
+ service_type service_;
+ impl_type impl_;
+ //std::set<conn_ptr> connections_;
+ };
+
+
+
+ //template<>
+ //class gateway<cgi_service>
+ //{
+ //public:
+ // gateway()
+ // {
+ // }
+ //private:
+ //
+ //};
+
+ /*
+ template<>
+ class gateway::acceptor<tags::fastcgi>
+ {
+ public:
+ gateway::acceptor
+ {
+ }
+ private:
+ boost::asio::ip::tcp::acceptor<
+ };
+ */
+
+} // namespace cgi
+
+#endif // CGI_BASIC_GATEWAY_HPP_INCLUDED__
+
+/*
+ * Notes:
+ *
+ * 1. A FastCGI server doesn't have to use tcp sockets: it can use pipes
+ * instead. Support for these will only come in when Boost.Asio supports them.
+ *
+ * 2. For now each request object could hold a pointer/reference to the
+ * connection that it's associated with. For the forseable future that's going
+ * to be enough. However, since the FastCGI spec doesn't say otherwise,
+ * eventually it could happen that the response can be sent back via ANY open
+ * connection. In that case, the request would have to query the gateway to
+ * find an available connection before sending through it. For now, that's
+ * unneccesary.
+ */
Added: sandbox/SOC/2007/cgi/boost/cgi/basic_gateway_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/basic_gateway_fwd.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,19 @@
+// -- basic_gateway_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_BASIC_GATEWAY_FWD_HPP_INCLUDED__
+#define CGI_BASIC_GATEWAY_FWD_HPP_INCLUDED__
+
+namespace cgi {
+
+ template<typename>
+ class basic_gateway;
+
+} // namespace cgi
+
+#endif // CGI_BASIC_GATEWAY_FWD_HPP_INCLUDED__
Added: sandbox/SOC/2007/cgi/boost/cgi/basic_io_object.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/basic_io_object.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,67 @@
+// -- basic_io_object.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_BASIC_IO_OBJECT_HPP_INCLUDED__
+#define CGI_BASIC_IO_OBJECT_HPP_INCLUDED__
+
+#include <boost/noncopyable.hpp>
+#include <boost/asio/io_service.hpp>
+
+namespace cgi {
+
+ template<typename Service, bool UseIoService = true>
+ class basic_io_object
+ : private boost::noncopyable
+ {
+ public:
+ typedef Service service_type;
+ private:
+ typedef typename Service::impl_type impl_type;
+
+ protected:
+ explicit basic_io_object(boost::asio::io_service& ios)
+ : service(boost::asio::use_service<Service>(ios))
+ {
+ service.construct(impl);
+ }
+
+ ~basic_io_object()
+ {
+ service.destroy(impl);
+ }
+
+ impl_type impl;
+ service_type& service;
+ };
+
+ template<typename Service>
+ class basic_io_object<Service, false>
+ : private boost::noncopyable
+ {
+ public:
+ typedef Service service_type;
+ typedef typename Service::impl_type impl_type;
+
+ protected:
+ explicit basic_io_object()
+ {
+ service.construct(impl);
+ }
+
+ ~basic_io_object()
+ {
+ service.destroy(impl);
+ }
+
+ impl_type impl;
+ service_type service;
+ };
+
+} // namespace cgi
+
+#endif // CGI_BASIC_IO_OBJECT_HPP_INCLUDED__
Modified: sandbox/SOC/2007/cgi/boost/cgi/basic_protocol_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/basic_protocol_service.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/basic_protocol_service.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -10,10 +10,15 @@
#define CGI_BASIC_PROTOCOL_SERVICE_HPP_INCLUDED__
#include <set>
+#include <queue>
+#include <boost/shared_ptr.hpp>
#include <boost/asio/io_service.hpp>
+#include "io_service_provider.hpp"
#include "basic_gateway.hpp"
-#include "connection.hpp"
+//#include "basic_connection_fwd.hpp"
+#include "basic_acceptor_fwd.hpp"
+#include "basic_request_fwd.hpp"
namespace cgi {
@@ -22,86 +27,88 @@
* Holds the request queue and the connection queue.
* It is also a wrapper around asio::io_service
*/
- template<typename Protocol, typename TypeTraits = type_traits<Protocol> >
+ template<typename Protocol, int IoServiceCount, typename PoolingPolicy>
class basic_protocol_service
+ //: public protocol_traits<Protocol> // do this!
{
public:
- typedef basic_gateway<Protocol> gateway_type;
- typedef basic_acceptor<Protocol> acceptor_type;
- typedef basic_request<Protocol> request_type;
-
+ typedef Protocol protocol_type;
+ typedef io_service_provider<IoServiceCount, PoolingPolicy>
+ ios_provider_type;
+ //typedef protocol_traits<Protocol> traits;
+ //typedef typename traits::gateway_type gateway_type;
+ typedef basic_gateway<Protocol> gateway_type;
+ typedef basic_request<Protocol> request_type;
+ typedef boost::shared_ptr<request_type> request_ptr;
+ typedef basic_acceptor<Protocol> acceptor_type;
+
+
+ basic_protocol_service(int pool_size_hint = 0)
+ : ios_provider_(pool_size_hint)
+// , mutex_()
+ , gateway_(*this)
+ {
+ }
- basic_protocol_service()
- : io_service_()
- , mutex_()
- , gateway_(this)
+ basic_protocol_service(boost::asio::io_service& io_service)
+ : ios_provider_(io_service)
+// , mutex_()
+ , gateway_(*this)
{
}
~basic_protocol_service()
{
- gateway_.stop_all();
+ gateway_.stop();
}
void run()
{
- io_service_.run();
+ ios_provider_.run();
}
void stop()
{
- gateway_.stop_all();
- io_service_.stop();
+ gateway_.stop();
+ ios_provider_.stop();
}
+ /// Return an available io_service from the IoServiceProvider
boost::asio::io_service& io_service()
{
- return io_service_;
+ return ios_provider_.io_service();
}
+ /// Post the handler through an available io_service
template<typename Handler>
void post(Handler handler)
{
- io_service_.post(handler);
+ ios_provider_.io_service().post(handler);
}
+ /// Dispatch a handler through an available io_service
template<typename Handler>
void dispatch(Handler handler)
{
- io_service_.dispatch(handler);
- }
-
- /*
- void add_request(request_ptr new_request)
- {
- boost::thread::mutex::scoped_lock lk(mutex_);
- requests_.push_back(new_request);
+ ios_provider_.io_service().dispatch(handler);
}
- bool del_request(request_ptr request)
- {
- boost::thread::mutex::scoped_lock lk(mutex_);
- if( !requests_.find(request) == requests_.end() )
- return false;
- **/
-
private:
- boost::asio::io_service io_service_;
- boost::thread::mutex mutex_;
- boost::thread::condition condition_;
+ ios_provider_type ios_provider_;
+// boost::thread::mutex mutex_;
+// boost::thread::condition condition_;
/// A strand is used for guaranteeing handlers are dispatched sequentially
- boost::asio::strand strand_;
+// boost::asio::strand strand_;
+
+ std::set<request_ptr> request_set_;
+ std::queue<request_ptr> request_queue_;
- std::set<request_type::pointer> request_set_;
- std::queue<request_type::pointer> request_queue_;
- //std::set<connection_ptr> connections_;
gateway_type gateway_;
-
- friend class gateway_type;
- friend class gateway_service<protocol_type>;
- friend class acceptor_type;
- friend class request_type;
+
+ friend class basic_gateway<protocol_type>;//gateway_type;
+ friend class basic_acceptor<protocol_type>;//class acceptor_type;
+ friend class basic_request<protocol_type>;//typename request_type;
};
} // namespace cgi
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-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -1,6 +1,6 @@
// -- basic_request.hpp --
//
-// Copyright (c) Darren Garvey 2007.
+// 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)
@@ -11,17 +11,35 @@
#include <iostream>
#include <boost/noncopyable.hpp>
-
-#include "detail/request_traits.hpp"
+#include <boost/assert.hpp>
+#include <boost/system/error_code.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/asio/io_service.hpp>
+
+#include "detail/throw_error.hpp"
+#include "detail/protocol_traits.hpp"
+#include "request_base.hpp"
+#include "role_type.hpp"
+#include "data_source.hpp"
+#include "data_sink.hpp"
+#include "status_type.hpp"
+#include "is_async.hpp"
+#include "basic_io_object.hpp"
+#include "connection_base.hpp"
+#include "http/status_code.hpp"
+#include "request_service.hpp"
+#include "basic_protocol_service_fwd.hpp"
+#include "basic_request_fwd.hpp"
namespace cgi {
+ /*
enum status_type
{ ok
, aborted
, ended
};
-
+ */
/// The basic_request class, primary entry point to the library
/**
@@ -32,6 +50,9 @@
* The underlying impl_type classes aren't like this (and as such aren't
* quite as 'safe' to use) but they may be more suited to certain needs.
*
+ * Note: By default, synchronous protocols (ie. cgi) auto-load AND parse STDIN,
+ * whereas async protocols don't.
+ *
* Note: This class isn't thread safe: carrying around a mutex-per-request
* seems prohibitively expensive. There could be functions which take a mutex
* as an arguement and lock it. (Async calls could get messy if you need a
@@ -45,49 +66,66 @@
* whole library much simpler to do it this way.
*/
template<typename Protocol
- , typename Service = request_traits<Protocol>::service_type
- , enum Role = role_type::responder
- , typename ProtocolService = basic_protocol_service<Protocol>
- , typename Allocator = std::allocator<char> >
+ , typename Service
+ , role_type Role
+ , typename ProtocolService
+ , typename Allocator>
class basic_request
: public request_base
- //, public boost::asio::basic_io_object<Service>
- , private boost::noncopyable
+ , public basic_io_object<Service, is_async<Protocol>::value>
{
public:
typedef basic_request<Protocol, Service, Role
, ProtocolService, Allocator > type;
typedef Protocol protocol_type;
- typedef Role role_type;
+ //typedef Role role_type;
typedef ProtocolService protocol_service_type;
typedef boost::shared_ptr<type> pointer;
- typedef Service service_type;
- typedef Service::impl_type impl_type;
- typedef boost::shared_ptr<connection_base> connection_ptr;
+ //typedef Service service_type;
+ //typedef typename Service::impl_type impl_type;
+ //typedef boost::shared_ptr<connection_base> connection_ptr;
- explicit basic_request(protocol_service_type& s, bool load_now = false)
- :// boost::asio::basic_io_object<Service>(s.io_service())
- next_layer_(s)
- , service_(boost::asio::use_service<Service>(next_layer_.io_service()))
- , impl_(service_.null())
- , status_num_(0)
+ // Throws
+ basic_request(bool load_now = true, bool parse_post = true)
+ : basic_io_object<Service, false>()
{
- service_.construct(impl_);
- if( load_now ) service_.load(impl_);
+ if (load_now) load(parse_post);//this->service.load(this->impl, true, ec);
}
- ~basic_request()
+ basic_request(boost::system::error_code& ec
+ , const bool load_now = true
+ , const bool parse_post = true)
+ : basic_io_object<Service, false>()
{
- service_.destroy(impl_);
+ if (load_now) load(ec, parse_post);//this->service.load(this->impl, true, ec);
+ }
+
+ basic_request(protocol_service_type& s, const bool load_now = false
+ , const bool parse_post = false)
+ : basic_io_object<Service, true>(s.io_service())
+ {
+ if (load_now) load(parse_post);//this->service.load(this->impl, false, ec);
}
- boost::asio::io_service& io_service()
+ basic_request(protocol_service_type& s
+ , boost::system::error_code& ec
+ , const bool load_now = false, const bool parse_post = false)
+ : basic_io_object<Service, true>(s.io_service())
{
- return next_layer_.io_service();
+ if(load_now) load(ec, parse_post);//this->service.load(this->impl, false, ec);
}
+ ~basic_request()
+ {
+ }
+
+ //boost::asio::io_service& io_service()
+ //{
+ // return this->service.io_service(this->impl);
+ //}
+
/// Synchronously read/parse the request meta-data
/**
* Note: 'loading' including reading/parsing STDIN if parse_stdin == true
@@ -96,15 +134,15 @@
void load(bool parse_stdin = false)
{
boost::system::error_code ec;
- service_.load(impl_, parse_stdin);
- boost::throw_error(ec);
+ this->service.load(this->impl, parse_stdin, ec);
+ detail::throw_error(ec);
}
// Error-code semantics
boost::system::error_code& load(boost::system::error_code& ec
- , bool parse_stdin = false)
+ , bool parse_stdin = false)
{
- return service_.load(impl_, parse_stdin, ec);
+ return this->service.load(this->impl, parse_stdin, ec);
}
@@ -115,7 +153,7 @@
template<typename Handler>
void async_load(Handler handler, bool parse_stdin = false)
{
- service_.async_load(impl_, parse_stdin, handler);
+ this->service.async_load(this->impl, parse_stdin, handler);
}
/// Notify the server the request has finished being handled
@@ -131,59 +169,63 @@
*/
void close(http::status_code http_status, int program_status)
{
- BOOST_ASSERT( request_status_ != status_type::ended );
+ //BOOST_ASSERT( request_status_ != status_type::ended );
- service_.set_status(request_status_ = status_type::ended;
- http_status_ = http_status;
- program_status_ = program_status;
- service_.end(impl_, http_status);
+ this->service.set_status(this->impl, http_status);
+ //http_status_ = http_status;
+ //program_status_ = program_status;
+ this->service.end(this->impl, http_status);
//io_service_.dispatch(set_status(status_type::ended));
- //impl_.end_request(this, status_code);
+ //this->impl.end_request(this, status_code);
}
void close(int http_status, int program_status)
{
- service_.close(http_status, program_status);
+ this->service.close(this->impl, http_status, program_status);
}
/// Reject the request with a standard '500 Internal Server Error' error
void reject()
{
- service_.set_status(impl_, status_type::aborted);
- service_.end(impl_, http::status_code::internal_server_error);
+ this->service.set_status(this->impl, aborted);
+ this->service.end(this->impl, http::internal_server_error);
}
/// Read some data from the request
- template<typename MutableBufferSequence>
- std::size_t read_some(const MutableBufferSequence& buf)
+ template<typename MutableBufferSequence, typename Source>
+ std::size_t read_some(const MutableBufferSequence& buf
+ , Source source = data_source::stdin())
{
- error_code ec;
- std::size_t s = service.read_some(buf, ec);
- boost::throw_error(ec);
+ boost::system::error_code ec;
+ std::size_t s = this->service.read_some(this->impl, buf, ec);
+ detail::throw_error(ec);
return s;
}
- template<typename MutableBufferSequence>
+ template<typename MutableBufferSequence, typename Source>
std::size_t read_some(const MutableBufferSequence& buf
- , boost::system::error_code& ec)
+ , boost::system::error_code& ec
+ , Source source = data_source::stdin())
{
- return service.read_some(buf, ec);
+ return this->service.read_some(this->impl, buf, ec);
}
- template<typename ConstBufferSequence>
- std::size_t write_some(const ConstBufferSequence& buf)
+ template<typename ConstBufferSequence, typename Sink>
+ std::size_t write_some(const ConstBufferSequence& buf
+ , Sink dest = data_sink::stdout())
{
- error_code ec;
- std::size_t s = service.write_some(buf, ec);
- boost::throw_error(ec);
+ boost::system::error_code ec;
+ std::size_t s = this->service.write_some(this->impl, buf, ec);
+ detail::throw_error(ec);
return s;
}
- template<typename ConstBufferSequence>
+ template<typename ConstBufferSequence, typename Sink>
std::size_t write_some(const ConstBufferSequence& buf
- , boost::system::error_code& ec)
+ , boost::system::error_code& ec
+ , Sink dest = data_sink::stdout())
{
- return service.write_some(buf, ec);
+ return this->service.write_some(this->impl, buf, ec);
}
/* Not sure if these are needed; leaving it for open discussion to decide.
@@ -191,7 +233,7 @@
template<class VarType = ENV>
const std::string& var(const std::string& name) const
{
- return impl_.var<VarType>(name);
+ return this->impl.var<VarType>(name);
}
template<typename ToType, class VarType = ENV>
@@ -204,7 +246,7 @@
/// Find the get meta-variable matching name
std::string meta_get(const std::string& name) const
{
- return service_.meta_get(impl_, name);
+ return this->service.meta_get(this->impl, name);
}
/// Find the post meta-variable matching name
@@ -215,19 +257,19 @@
*/
std::string meta_post(const std::string& name, bool greedy = true)
{
- return service_.meta_post(impl_, name, greedy);
+ return this->service.meta_post(this->impl, name, greedy);
}
/// Find the cookie meta-variable matching name
std::string meta_cookie(const std::string& name) const
{
- return service_.meta_cookie(impl_, name);
+ return this->service.meta_cookie(this->impl, name);
}
/// Find the environment meta-variable matching name
std::string meta_env(const std::string& name) const
{
- return service_.meta_env(impl_, name);
+ return this->service.meta_env(this->impl, name);
}
/// Search through all meta vars for the meta-variable matching name
@@ -246,6 +288,7 @@
*/
std::string meta_var(const std::string& name, bool greedy = false) const
{
+ return this->service.meta_var(this->impl, name, greedy);
std::string request_method( meta_env("REQUEST_METHOD") );
std::string tmp;
@@ -260,11 +303,11 @@
tmp = meta_cookie(name);
if (!tmp.empty())
- return tmp;
+ return tmp;
tmp = meta_env(name);
if (!tmp.empty())
- return tmp;
+ return tmp;
if (!request_method.empty() && request_method == "POST")
{
@@ -279,55 +322,55 @@
// Some helper functions for the basic CGI 1.1 meta-variables
std::string auth_type()
- { return service_.meta_env(impl_, "AUTH_TYPE"); }
+ { return this->service.meta_env(this->impl, "AUTH_TYPE"); }
std::string content_length()
- { return service_.meta_env(impl_, "CONTENT_LENGTH"); }
+ { return this->service.meta_env(this->impl, "CONTENT_LENGTH"); }
std::string content_type()
- { return service_.meta_env(impl_, "CONTENT_TYPE"); }
+ { return this->service.meta_env(this->impl, "CONTENT_TYPE"); }
std::string gateway_interface()
- { return service_.meta_env(impl_, "GATEWAY_INTERFACE"); }
+ { return this->service.meta_env(this->impl, "GATEWAY_INTERFACE"); }
std::string path_info()
- { return service_.meta_env(impl_, "PATH_INFO"); }
+ { return this->service.meta_env(this->impl, "PATH_INFO"); }
std::string path_translated()
- { return service_.meta_env(impl_, "PATH_TRANSLATED"); }
+ { return this->service.meta_env(this->impl, "PATH_TRANSLATED"); }
std::string query_string()
- { return service_.meta_env(impl_, "QUERY_STRING"); }
+ { return this->service.meta_env(this->impl, "QUERY_STRING"); }
std::string remote_addr()
- { return service_.meta_env(impl_, "REMOTE_ADDR"); }
+ { return this->service.meta_env(this->impl, "REMOTE_ADDR"); }
std::string remote_host()
- { return service_.meta_env(impl_, "REMOTE_HOST"); }
+ { return this->service.meta_env(this->impl, "REMOTE_HOST"); }
std::string remote_ident()
- { return service_.meta_env(impl_, "REMOTE_IDENT"); }
+ { return this->service.meta_env(this->impl, "REMOTE_IDENT"); }
std::string remote_user()
- { return service_.meta_env(impl_, "REMOTE_USER"); }
+ { return this->service.meta_env(this->impl, "REMOTE_USER"); }
std::string request_method()
- { return service_.meta_env(impl_, "REQUEST_METHOD"); }
+ { return this->service.meta_env(this->impl, "REQUEST_METHOD"); }
std::string script_name()
- { return service_.meta_env(impl_, "SCRIPT_NAME"); }
+ { return this->service.meta_env(this->impl, "SCRIPT_NAME"); }
std::string server_name()
- { return service_.meta_env(impl_, "SERVER_NAME"); }
+ { return this->service.meta_env(this->impl, "SERVER_NAME"); }
std::string server_port()
- { return service_.meta_env(impl_, "SERVER_PORT"); }
+ { return this->service.meta_env(this->impl, "SERVER_PORT"); }
std::string server_protocol()
- { return service_.meta_env(impl_, "SERVER_PROTOCOL"); }
+ { return this->service.meta_env(this->impl, "SERVER_PROTOCOL"); }
std::string server_software()
- { return service_.meta_env(impl_, "SERVER_SOFTWARE"); }
+ { return this->service.meta_env(this->impl, "SERVER_SOFTWARE"); }
/// The role that the request is playing
@@ -340,7 +383,7 @@
*/
role_type& role()
{
- return service_.get_role(impl_);
+ return this->service.get_role(this->impl);
}
/// Get the strand associated with the request (if any)
@@ -350,30 +393,30 @@
// and there would be no need for protocol-specific code in user programs.
/* boost::asio::strand* strand()
{
- return impl_.strand();
+ return this->impl.strand();
}
*/
/// Get the implementation type for the request
- impl_type& impl() const
- {
- return impl_;
- }
+ //impl_type& impl() const
+ //{
+ // return this->impl;
+ //}
void set_status(http::status_code status)
{
- service_.set_http_status(impl_, status);
+ this->service.set_http_status(this->impl, status);
}
bool is_open()
{
- return service_.is_open(impl_);
+ return this->service.is_open(this->impl);
}
private:
//connection_ptr conn_;
- service_type& service_;
- impl_type impl_;
+ //service_type& service;
+ //impl_type impl_;
//int app_status_; // what to return to the server on request completion
//http::status_code http_status_;
@@ -384,34 +427,11 @@
/// The data for the request is held in its own struct
//data_type* data_;
- /// The actual data held by the request
- //std::auto_ptr<meta_data> data_;
-
-
};
- //template<typename T>
- //std::string& basic_request<T>::var<GET>(const std::string& name) const
- //{
- // return data_.get_var(name);
- //}
-
- //template<typename T>
- //std::string& basic_request<T>::var<POST>(const std::string& name) const
- //{
- // return data_.post_var(name);
- //}
-
- //template<typename T>
- //std::string& basic_request<T>::var<COOKIE>(const std::string& name) const
- //{
- // return data_.cookie_var(name);
- //}
-
-
//template<>
//class basic_request<protocol::cgi>::meta_data
//{
@@ -479,26 +499,6 @@
// var_map post_vars_;
//};
- //template<>
- //class basic_request<protocol::fcgi>::meta_data
- //{
- //public:
- // std::string get_var(const std::string& name)
- // std::string post_var(const std::string& name)
- // std::string cookie_var(const std::string& name)
- // std::string env_var(const std::string& name)
- //private:
- //};
-
- //template<>
- //class basic_request<protocol::scgi>::meta_data
- //{
- // std::string get_var(const std::string& name)
- // std::string post_var(const std::string& name)
- // std::string cookie_var(const std::string& name)
- // std::string env_var(const std::string& name)
- //};
-
} // namespace cgi
#endif // CGI_BASIC_REQUEST_HPP_INCLUDED__
Added: sandbox/SOC/2007/cgi/boost/cgi/basic_request_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/basic_request_fwd.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,29 @@
+// -- basic_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_BASIC_REQUEST_FWD_HPP_INCLUDED__
+#define CGI_BASIC_REQUEST_FWD_HPP_INCLUDED__
+
+#include <memory>
+
+#include "request_service_fwd.hpp"
+#include "role_type.hpp"
+#include "basic_protocol_service_fwd.hpp"
+
+namespace cgi {
+
+ template<typename Protocol
+ , typename Service = request_service<Protocol>
+ , enum role_type Role = responder
+ , typename ProtocolService = basic_protocol_service<Protocol>
+ , typename Allocator = std::allocator<char> >
+ class basic_request;
+
+} // namespace cgi
+
+#endif // CGI_BASIC_REQUEST_FWD_HPP_INCLUDED__
Added: sandbox/SOC/2007/cgi/boost/cgi/buffer.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/buffer.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,20 @@
+// -- buffer.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_BUFFER_HPP_INCLUDED__
+#define CGI_BUFFER_HPP_INCLUDED__
+
+#include <boost/asio/buffer.hpp>
+
+namespace cgi {
+
+ using boost::asio::buffer;
+
+} // namespace cgi
+
+#endif // CGI_HPP_INCLUDED__
Added: sandbox/SOC/2007/cgi/boost/cgi/cgi/acgi_request.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/cgi/acgi_request.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,25 @@
+// -- acgi_request.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_ACGI_REQUEST_HPP_INCLUDED__
+#define CGI_ACGI_REQUEST_HPP_INCLUDED__
+
+#include "../tags.hpp"
+#include "../basic_request_fwd.hpp"
+#include "../request_impl/acgi_request_impl.hpp"
+#include "../service_impl/acgi_service_impl.hpp"
+
+namespace cgi {
+
+ typedef basic_request<tags::acgi> acgi_request;
+
+} // namespace cgi
+
+#include "../basic_request.hpp"
+
+#endif // CGI_ACGI_REQUEST_HPP_INCLUDED__
Added: sandbox/SOC/2007/cgi/boost/cgi/cgi/cgi_protocol_service.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/cgi/cgi_protocol_service.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,18 @@
+// -- cgi_protocol_service.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_CGI_PROTOCOL_SERVICE_HPP_INCLUDED__
+#define CGI_CGI_PROTOCOL_SERVICE_HPP_INCLUDED__
+
+namespace cgi {
+
+ typedef basic_protocol_service<tags::async_cgi> service;
+
+} // namespace cgi
+
+#endif // CGI_CGI_PROTOCOL_SERVICE_HPP_INCLUDED__
Added: sandbox/SOC/2007/cgi/boost/cgi/cgi/cgi_request.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/cgi/cgi_request.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,26 @@
+// -- cgi_request.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_CGI_REQUEST_HPP_INCLUDED__
+#define CGI_CGI_REQUEST_HPP_INCLUDED__
+
+#include "../tags.hpp"
+#include "../basic_request_fwd.hpp"
+#include "../service_impl/cgi_service_impl.hpp"
+#include "../request_impl/cgi_request_impl.hpp"
+#include "../basic_request.hpp"
+
+namespace cgi {
+
+ class cgi_service_impl;
+
+ typedef basic_request<tags::cgi, cgi_service_impl> cgi_request;
+
+} // namespace cgi
+
+#endif // CGI_CGI_REQUEST_HPP_INCLUDED__
Added: sandbox/SOC/2007/cgi/boost/cgi/cgi/cgi_service.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/cgi/cgi_service.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,44 @@
+// -- cgi_service.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_CGI_SERVICE_HPP_INCLUDED__
+#define CGI_CGI_SERVICE_HPP_INCLUDED__
+
+#include "../tags.hpp"
+#include "../connections/stdio.hpp"
+#include "../connections/async_stdio.hpp"
+#include "../gateway_impl/acgi_gateway_impl.hpp"
+#include "../gateway_service/acgi_gateway_service.hpp"
+#include "../basic_protocol_service.hpp"
+
+namespace cgi {
+
+ /// typedef for typical usage
+ /**
+ * Works with both cgi_request and acgi_request.
+ */
+ typedef basic_protocol_service<tags::acgi> cgi_service;
+
+ /// A service 'owned' by a single user-supplied io_service
+ typedef basic_protocol_service<tags::acgi, 0> cgi_sub_service;
+
+ /// A service with a pool of io_services underneath
+ template<int IoServiceCount, typename PoolingPolicy = tags::round_robin>
+ struct cgi_service_pool
+ : public basic_protocol_service<tags::acgi, IoServiceCount, PoolingPolicy>
+ {
+ cgi_service_pool(int concurrency_hint = 0)
+ : basic_protocol_service<tags::acgi, IoServiceCount, PoolingPolicy>
+ (concurrency_hint)
+ {
+ }
+ };
+
+} // namespace cgi
+
+#endif // CGI_CGI_SERVICE_HPP_INCLUDED__
Deleted: sandbox/SOC/2007/cgi/boost/cgi/cgi_request_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/cgi_request_service.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
+++ (empty file)
@@ -1,19 +0,0 @@
-#ifndef CGI_CGI_REQUEST_SERVICE_HPP_INCLUDED
-#define CGI_CGI_REQUEST_SERVICE_HPP_INCLUDED
-
-namespace cgi {
-
-template<>
-class basic_request_service<protocol::cgi>
-{
- basic_request_service()
- : in_buf_(std::cin.rdbuf())
- , out_buf_(std::cout.rdbuf())
- {
- }
-
-};
-
-} // namespace cgi
-
-#endif // CGI_CGI_REQUEST_SERVICE_HPP_INCLUDED
Modified: sandbox/SOC/2007/cgi/boost/cgi/connection_base.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/connection_base.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/connection_base.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -18,21 +18,21 @@
virtual ~connection_base() {}
// read functions
- template<typename MutableBufferSequence>
- virtual std::size_t read(MutableBufferSequence) = 0;
+ //template<typename MutableBufferSequence>
+ //virtual std::size_t read(MutableBufferSequence) = 0;
- template<typename MutableBufferSequence, typename Handler>
- virtual void async_read(MutableBufferSequence, Handler) = 0;
+ //template<typename MutableBufferSequence, typename Handler>
+ //virtual void async_read(MutableBufferSequence, Handler) = 0;
// write functions
- template<typename ConstBufferSequence>
- virtual std::size_t write(ConstBufferSequence) = 0;
+ //template<typename ConstBufferSequence>
+ //virtual std::size_t write(ConstBufferSequence) = 0;
- template<typename ConstBufferSequence, typename Handler>
- virtual void async_write(ConstBufferSequence, Handler) = 0;
+ //template<typename ConstBufferSequence, typename Handler>
+ //virtual void async_write(ConstBufferSequence, Handler) = 0;
protected:
- ~connection_base() { }
+ //~connection_base() { }
};
} // namespace cgi
Added: sandbox/SOC/2007/cgi/boost/cgi/connections/async_stdio.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/connections/async_stdio.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,124 @@
+// -- async_stdio.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_ASYNC_STDIO_HPP_INCLUDED__
+#define CGI_ASYNC_STDIO_HPP_INCLUDED__
+
+#include <boost/bind.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/system/error_code.hpp>
+#include <boost/enable_shared_from_this.hpp>
+
+#include "stdio.hpp"
+#include "../io_service.hpp"
+#include "../tags.hpp"
+
+namespace cgi {
+
+ // Asynchronous access to stdio
+ template<>
+ class basic_connection<tags::async_stdio>
+ : public basic_connection<tags::stdio>
+ , public boost::enable_shared_from_this<basic_connection<tags::async_stdio> >
+ {
+ public:
+ typedef basic_connection<tags::async_stdio> type;
+ typedef boost::shared_ptr<type> pointer;
+
+ basic_connection(io_service& ios)
+ : basic_connection<tags::stdio>()
+ , io_service_(ios)
+ {
+ }
+
+ template<typename ConnectionPtr, typename MutableBufferSequence
+ , typename Handler>
+ class read_handler
+ {
+ public:
+ read_handler(ConnectionPtr cptr, MutableBufferSequence& buf
+ , boost::system::error_code& ec, Handler handler)
+ : cptr_(cptr)
+ , buf_(buf)
+ , ec_(ec)
+ , handler_(handler)
+ {
+ }
+
+ void operator()()
+ {
+ std::size_t bytes_read = cptr_->read_some(buf_, ec_);
+ handler_(ec_, bytes_read);
+ }
+
+ private:
+ ConnectionPtr cptr_;
+ MutableBufferSequence& buf_;
+ boost::system::error_code& ec_;
+ Handler handler_;
+ };
+
+ template<typename MutableBufferSequence, typename Handler>
+ void async_read_some(MutableBufferSequence buf, boost::system::error_code& ec
+ , Handler handler)
+ {
+ io_service_.post(read_handler<pointer, MutableBufferSequence, Handler>
+ (shared_from_this(), buf, ec, handler));
+ }
+
+ template<typename ConnectionPtr, typename ConstBufferSequence
+ , typename Handler>
+ class write_handler
+ {
+ public:
+ write_handler(ConnectionPtr cptr, ConstBufferSequence& buf
+ , boost::system::error_code& ec, Handler handler)
+ : cptr_(cptr)
+ , buf_(buf)
+ , ec_(ec)
+ , handler_(handler)
+ {
+ }
+
+ void operator()()
+ {
+ std::size_t bytes_written = cptr_->write_some(buf_, ec_);
+ handler_(ec_, bytes_written);
+ }
+
+ private:
+ ConnectionPtr cptr_;
+ ConstBufferSequence& buf_;
+ boost::system::error_code& ec_;
+ Handler handler_;
+ };
+
+ template<typename ConstBufferSequence, typename Handler>
+ void async_write_some(ConstBufferSequence& buf, boost::system::error_code& ec
+ , Handler handler)
+ {
+ io_service_.post(write_handler<pointer, ConstBufferSequence, Handler>
+ (shared_from_this(), buf, ec, handler));
+ }
+
+ private:
+ io_service& io_service_;
+ };
+
+ typedef basic_connection<tags::async_stdio> async_stdio_connection;
+
+
+ // template<typename ProtocolService = detail::async_cgi_service>
+ //struct async_stdio_connection
+ //{
+ // typedef basic_connection<tags::async_cgi, ProtocolService> type;
+ //};
+
+} // namespace cgi
+
+#endif // CGI_ASYNC_STDIO_HPP_INCLUDED__
Deleted: sandbox/SOC/2007/cgi/boost/cgi/connections/async_stdio_connection.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/connections/async_stdio_connection.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
+++ (empty file)
@@ -1,62 +0,0 @@
-// -- async_stdio_connection_impl.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_ASYNC_STDIO_CONNECTION_IMPL_HPP_INCLUDED__
-#define CGI_ASYNC_STDIO_CONNECTION_IMPL_HPP_INCLUDED__
-
-namespace cgi {
-
- template<typename ProtocolService>
- class basic_connection<tags::stdio_async, ProtocolService>
- : public connection_base
- , public basic_connection<ProtocolService, tags::stdio>
- {
- public:
- basic_connection(protocol_service_type& ps)
- : protocol_service_(ps)
- , basic_connection<tags::stdio, ProtocolService>()
- {
- }
-
- template<typename MutableBufferSequence, typename Handler>
- void async_read_some(MutableBufferSequence buf, boost::system::error_code& ec
- , Handler handler)
- {
- std::size_t bytes_read;
- if( buf.data() != in_.rdbuf() )
- bytes_read = in_.read(buf.data(), buf.size());
- else
- bytes_read = buf.size();
-
- protocol_service_.post(boost::bind(&Handler
- , handler
- , boost::system::system_error()
- , bytes_read ));
- }
-
- template<typename ConstBufferSequence, typename Handler>
- void async_write_some(ConstBufferSequence& buf, boost::system::error_code& ec
- , Handler handler)
- {
- out_.write(buf.data(), buf.size());
- protocol_service_.post(handler);
- }
-
- private:
- protocol_service_type& protocol_service_;
- };
-
- template<typename ProtocolService = detail::async_cgi_service>
- struct async_stdio_connection
- {
- typedef basic_connection<tags::async_cgi, ProtocolService> type;
- };
-
-} // namespace cgi
-
-#endif // CGI_ASYNC_STDIO_CONNECTION_IMPL_HPP_INCLUDED__
Added: sandbox/SOC/2007/cgi/boost/cgi/connections/stdio.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/connections/stdio.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,76 @@
+// -- stdio.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_STDIO_CONNECTION_IMPL_HPP_INCLUDED__
+#define CGI_STDIO_CONNECTION_IMPL_HPP_INCLUDED__
+
+#include <iostream>
+#include <istream>
+#include <ostream>
+#include <boost/system/error_code.hpp>
+
+#include "../basic_connection_fwd.hpp"
+#include "../tags.hpp"
+#include "../connection_base.hpp"
+//#include "../io_service.hpp"
+
+namespace cgi {
+
+ template<>
+ class basic_connection<tags::stdio>
+ : public connection_base
+ {
+ public:
+ basic_connection()
+ : in_(std::cin)
+ , out_(std::cout)
+ , err_(std::cerr)
+ {
+ }
+
+ template<typename T>
+ basic_connection(T&)
+ : in_(std::cin)
+ , out_(std::cout)
+ , err_(std::cerr)
+ {
+ }
+
+ template<typename MutableBufferSequence>
+ std::size_t read_some(MutableBufferSequence buf
+ , boost::system::error_code& ec)
+ {
+ if( buf.data() != in_.rdbuf() )
+ return in_.read(buf.data(), buf.size());
+ return buf.size();
+ }
+
+ template<typename ConstBufferSequence>
+ std::size_t write_some(ConstBufferSequence& buf
+ , boost::system::error_code& ec)
+ {
+ return out_.write(buf.data(), buf.size());
+ }
+
+ protected:
+ std::istream& in_;
+ std::ostream& out_;
+ std::ostream& err_;
+ };
+
+ typedef basic_connection<tags::stdio> stdio_connection;
+
+ // template<typename ProtocolService = detail::cgi_service>
+ //struct stdio_connection
+ //{
+ // typedef basic_connection<tags::stdio, ProtocolService> type;
+ //};
+
+} // namespace cgi
+
+#endif // CGI_STDIO_CONNECTION_IMPL_HPP_INCLUDED__
Deleted: sandbox/SOC/2007/cgi/boost/cgi/connections/stdio_connection.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/connections/stdio_connection.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
+++ (empty file)
@@ -1,62 +0,0 @@
-// -- stdio_connection_impl.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_STDIO_CONNECTION_IMPL_HPP_INCLUDED__
-#define CGI_STDIO_CONNECTION_IMPL_HPP_INCLUDED__
-
-namespace cgi {
-
- template<typename ProtocolService>
- class basic_connection<tags::stdio, ProtocolService>
- : public connection_base
- {
- public:
- typedef ProtocolService protocol_service_type;
-
- basic_connection()
- : in_(std::cin)
- , out_(std::cout)
- {
- }
-
- basic_connection(protocol_service_type&)
- : in_(std::cin)
- , out_(std::cout)
- {
- }
-
- template<typename MutableBufferSequence>
- std::size_t read_some(MutableBufferSequence buf
- , boost::system::error_code& ec)
- {
- if( buf.data() != in_.rdbuf() )
- return in_.read(buf.data(), buf.size());
- return buf.size();
- }
-
- template<typename ConstBufferSequence>
- std::size_t write_some(ConstBufferSequence& buf
- , boost::system::error_code& ec)
- {
- return out_.write(buf.data(), buf.size());
- }
-
- protected:
- std::istream& in_;
- std::ostream& out_;
- };
-
- template<typename ProtocolService = detail::cgi_service>
- struct stdio_connection
- {
- typedef basic_connection<tags::stdio, ProtocolService> type;
- };
-
-} // namespace cgi
-
-#endif // CGI_STDIO_CONNECTION_IMPL_HPP_INCLUDED__
\ No newline at end of file
Deleted: sandbox/SOC/2007/cgi/boost/cgi/connections/tcp_connection.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/connections/tcp_connection.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
+++ (empty file)
@@ -1,45 +0,0 @@
-// -- tcp_connection_impl.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_TCP_CONNECTION_IMPL_HPP_INCLUDED__
-#define CGI_TCP_CONNECTION_IMPL_HPP_INCLUDED__
-
-namespace cgi {
-
- template<typename ProtocolService>
- class basic_connection<ProtocolService, tags::tcp_socket>
- : public connection_base
- {
- public:
- typedef ProtocolService protocol_service_type;
-
- basic_connection(protocol_service_type& ps)
- : protocol_service_(ps)
- , sock_(ps.io_service())
- {
- }
-
- template<typename ConstBufferSequence, typename Handler>
- void async_write(ConstBufferSequence& buf, Handler handler)
- {
- }
-
- private:
- protocol_service_type protocol_service_;
- boost::asio::ip::tcp::socket sock_;
- };
-
- template<typename ProtocolService = detail::fcgi_service>
- struct tcp_connection
- {
- typedef basic_connection<tags::tcp_socket, ProtocolService> type;
- };
-
-} // namespace cgi
-
-#endif // CGI_TCP_CONNECTION_IMPL_HPP_INCLUDED__
Added: sandbox/SOC/2007/cgi/boost/cgi/connections/tcp_socket.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/connections/tcp_socket.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,82 @@
+// -- tcp_connection.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_TCP_CONNECTION_HPP_INCLUDED__
+#define CGI_TCP_CONNECTION_HPP_INCLUDED__
+
+#include "../basic_connection.hpp"
+#include "../connection_base.hpp"
+#include "../tags.hpp"
+#include "../io_service.hpp"
+
+namespace cgi {
+
+ template<>
+ class basic_connection<tags::tcp_socket>
+ : public connection_base
+ {
+ public:
+ basic_connection(io_service& ios)
+ : sock_(ios)
+ {
+ }
+
+ template<typename MutableBufferSequence>
+ std::size_t read_some(MutableBufferSequence& buf)
+ {
+ return sock_.read_some(buf);
+ }
+
+ template<typename MutableBufferSequence>
+ std::size_t read_some(MutableBufferSequence& buf
+ , boost::system::error_code& ec)
+ {
+ return sock_.read_some(buf, ec);
+ }
+
+ template<typename MutableBufferSequence, typename Handler>
+ void async_read_some(MutableBufferSequence& buf, Handler handler)
+ {
+ sock_.async_read_some(buf, handler);
+ }
+
+ template<typename ConstBufferSequence>
+ std::size_t write_some(ConstBufferSequence& buf)
+ {
+ return sock_.write_some(buf);
+ }
+
+ template<typename ConstBufferSequence>
+ std::size_t write_some(ConstBufferSequence& buf
+ , boost::system::error_code& ec)
+ {
+ return sock_.write_some(buf, ec);
+ }
+
+ template<typename ConstBufferSequence, typename Handler>
+ void async_write_some(ConstBufferSequence& buf, Handler handler)
+ {
+ sock_.async_write_some(buf, handler);
+ }
+
+ private:
+ boost::asio::ip::tcp::socket sock_;
+ };
+
+ typedef basic_connection<tags::tcp_socket> tcp_connection;
+
+
+ //template<typename ProtocolService = detail::fcgi_service>
+ //struct tcp_connection
+ //{
+ // typedef basic_connection<tags::tcp_socket, ProtocolService> type;
+ //};
+
+} // namespace cgi
+
+#endif // CGI_TCP_CONNECTION_HPP_INCLUDED__
Added: sandbox/SOC/2007/cgi/boost/cgi/data_sink.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/data_sink.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,21 @@
+// -- data_sink.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_DATA_SINK_HPP_INCLUDED__
+#define CGI_DATA_SINK_HPP_INCLUDED__
+
+namespace cgi {
+ namespace data_sink {
+
+ struct stdout {};
+ struct stderr {};
+
+ } // namespace data_sink
+} // namespace cgi
+
+#endif // CGI_DATA_SINK_HPP_INCLUDED__
Added: sandbox/SOC/2007/cgi/boost/cgi/data_source.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/data_source.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,20 @@
+// -- data_source.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_DATA_SOURCE_HPP_INCLUDED__
+#define CGI_DATA_SOURCE_HPP_INCLUDED__
+
+namespace cgi {
+ namespace data_source {
+
+ struct stdin {};
+
+ } // namespace data_source
+} // namespace cgi
+
+#endif // CGI_DATA_SOURCE_HPP_INCLUDED__
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-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -9,6 +9,12 @@
#ifndef CGI_DETAIL_EXTRACT_PARAMS_HPP_INCLUDED__
#define CGI_DETAIL_EXTRACT_PARAMS_HPP_INCLUDED__
+#include <string>
+#include <boost/tokenizer.hpp>
+#include <boost/system/error_code.hpp>
+
+#include "url_decode.hpp"
+
namespace cgi {
namespace detail {
@@ -19,15 +25,15 @@
, boost::system::error_code& ec)
{
if( input.empty() )
- return boost::system::error_code(34, boost::system::errno_ecat);
+ return ec = boost::system::error_code(34, boost::system::errno_ecat);
- typedef boost::tokenizer<Separator> tokenizer;
+ typedef typename boost::tokenizer<Separator> tokenizer;
- tokenizer toker(input, sep);
+ tokenizer toker(input, separator);
std::string name, current_token;
- for(tokenizer::iterator iter = toker.begin()
+ for(typename tokenizer::iterator iter = toker.begin()
; iter != toker.end()
; ++iter)
{
@@ -42,7 +48,7 @@
}else
if( *iter == "&" )
{
- impl_.get_vars_[name] = current_token;
+ destination[name] = current_token;
current_token.clear();
name.clear();
}else
@@ -51,7 +57,9 @@
}
}
if( !name.empty() )
- impl_.get_vars_[name] = current_token;
+ destination[name] = current_token;
+
+ return ec;
}
} // namespace detail
Added: sandbox/SOC/2007/cgi/boost/cgi/detail/protocol_traits.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/detail/protocol_traits.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,107 @@
+// -- protocol_traits.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_REQUEST_TRAITS_HPP_INCLUDED__
+#define CGI_REQUEST_TRAITS_HPP_INCLUDED__
+
+#include "../tags.hpp"
+#include "../basic_connection_fwd.hpp"
+
+namespace cgi {
+
+ // Forward declarations
+
+ class cgi_request_impl;
+ class acgi_request_impl;
+ class async_cgi_request_impl;
+ class fcgi_request_impl;
+ class scgi_request_impl;
+
+ //template<typename>
+ class cgi_service_impl;
+ class acgi_service_impl;
+ class async_cgi_service_impl;
+ class fcgi_service_impl;
+ class scgi_service_impl;
+
+ class cgi_gateway_impl;
+ class acgi_gateway_impl;
+ class async_cgi_gateway_impl;
+ class fcgi_gateway_impl;
+ class scgi_gateway_impl;
+
+ class cgi_gateway_service;
+ class acgi_gateway_service;
+ class async_cgi_gateway_service;
+ class fcgi_gateway_service;
+ class scgi_gateway_service;
+ template<typename> class gateway_service;
+
+
+ namespace detail {
+
+ template<typename Protocol>
+ struct protocol_traits
+ {
+ };
+
+ template<>
+ struct protocol_traits<tags::cgi>
+ {
+ typedef cgi_request_impl impl_type;
+ typedef cgi_service_impl service_impl_type;
+ typedef basic_connection<tags::stdio> connection_type;
+// typedef cgi_gateway_impl gateway_impl_type;
+// typedef cgi_gateway_service gateway_service_impl_type;
+ };
+
+ template<>
+ struct protocol_traits<tags::async_cgi>
+ {
+ typedef async_cgi_request_impl impl_type;
+ typedef async_cgi_service_impl service_impl_type;
+ typedef basic_connection<tags::async_stdio> connection_type;
+ typedef async_cgi_gateway_impl gateway_impl_type;
+ typedef async_cgi_gateway_service gateway_service_type;
+ };
+
+ template<>
+ struct protocol_traits<tags::acgi>
+ // : protocol_traits<tags::async_cgi>
+ {
+ typedef acgi_request_impl impl_type;
+ typedef acgi_service_impl service_impl_type;
+ typedef basic_connection<tags::async_stdio> connection_type;
+ typedef acgi_gateway_impl gateway_impl_type;
+ typedef acgi_gateway_service gateway_service_type;
+ };
+
+ template<>
+ struct protocol_traits<tags::fcgi>
+ {
+ typedef fcgi_request_impl impl_type;
+ typedef fcgi_service_impl service_impl_type;
+ typedef basic_connection<tags::tcp_socket> connection_type;
+ typedef fcgi_gateway_impl gateway_impl_type;
+ typedef fcgi_gateway_service gateway_service_type;
+ };
+
+ template<>
+ struct protocol_traits<tags::scgi>
+ {
+ typedef scgi_request_impl impl_type;
+ typedef scgi_service_impl service_impl_type;
+ typedef basic_connection<tags::tcp_socket> connection_type;
+ typedef scgi_gateway_impl gateway_impl_type;
+ typedef scgi_gateway_service gateway_service_type;
+ };
+
+ } // namespace detail
+} // namespace cgi
+
+#endif // CGI_REQUEST_TRAITS_HPP_INCLUDED__
Deleted: sandbox/SOC/2007/cgi/boost/cgi/detail/request_traits.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/detail/request_traits.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
+++ (empty file)
@@ -1,49 +0,0 @@
-#ifndef CGI_REQUEST_TRAITS_HPP_INCLUDED__
-#define CGI_REQUEST_TRAITS_HPP_INCLUDED__
-
-#include "request_type.hpp"
-
-namespace cgi {
- namespace detail {
-
- template<typename Protocol, typename RequestType = request_type::responder>
- struct request_traits
- {
- };
-
- template<>
- struct request_traits<protocol::cgi>
- {
- typedef cgi_request_impl impl_type;
- //typedef request_service<protocol::cgi> service_type;
- typedef cgi_service_impl service_impl_type;
- };
-
- template<>
- struct request_traits<protocol::async_cgi>
- {
- typedef async_cgi_request_impl impl_type;
- //typedef request_service<protocol::async_cgi> service_type;
- typedef async_cgi_service_impl service_impl_type;
- };
-
- template<>
- struct request_traits<protocol::fcgi>
- {
- typedef fcgi_request_impl impl_type;
- //typedef request_service<protocol::fcgi> service_type;
- typedef fcgi_service_impl service_impl_type;
- };
-
- template<>
- struct request_traits<protocol::scgi>
- {
- typedef scgi_request_impl impl_type;
- //typedef request_service<protocol::scgi> service_type;
- typedef scgi_service_impl service_impl_type;
- };
-
- } // namespace detail
-} // namespace cgi
-
-#endif // CGI_REQUEST_TRAITS_HPP_INCLUDED__
Modified: sandbox/SOC/2007/cgi/boost/cgi/detail/service_base.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/detail/service_base.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/detail/service_base.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -11,40 +11,40 @@
////////////////////////////////////////////////////////////////
#ifndef CGI_DETAIL_SERVICE_ID_HPP_INCLUDED__
#define CGI_DETAIL_SERVICE_ID_HPP_INCLUDED__
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1200)
-# pragma once
-#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
-
-#include <boost/asio/detail/push_options.hpp>
-
-#include <boost/asio/io_service.hpp>
-#include <boost/asio/detail/service_id.hpp>
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
+
+#include <boost/asio/detail/push_options.hpp>
+
+#include <boost/asio/io_service.hpp>
+#include "service_id.hpp"
namespace cgi {
namespace detail {
-
- // Special service base class to keep classes header-file only.
- template <typename Type>
- class service_base
- : public boost::asio::io_service::service
- {
- public:
- static boost::asio::detail::service_id<Type> id;
-
- // Constructor.
- service_base(boost::asio::io_service& io_service)
- : boost::asio::io_service::service(io_service)
- {
- }
- };
-
- template <typename Type>
- boost::asio::detail::service_id<Type> service_base<Type>::id;
-
+
+ // Special service base class to keep classes header-file only.
+ template <typename Type>
+ class service_base
+ : public boost::asio::io_service::service
+ {
+ public:
+ static boost::asio::detail::service_id<Type> id;
+
+ // Constructor.
+ service_base(boost::asio::io_service& io_service)
+ : boost::asio::io_service::service(io_service)
+ {
+ }
+ };
+
+ template <typename Type>
+ boost::asio::detail::service_id<Type> service_base<Type>::id;
+
} // namespace detail
} // namespace cgi
-#include <boost/asio/detail/pop_options.hpp>
-
+#include <boost/asio/detail/pop_options.hpp>
+
#endif // CGI_DETAIL_SERVICE_ID_HPP_INCLUDED__
Added: sandbox/SOC/2007/cgi/boost/cgi/detail/throw_error.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/detail/throw_error.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,26 @@
+// -- throw_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)
+//
+////////////////////////////////////////////////////////////////
+#ifndef CGI_THROW_ERROR_HPP_INCLUDED__
+#define CGI_THROW_ERROR_HPP_INCLUDED__
+
+#include <boost/system/error_code.hpp>
+
+namespace cgi {
+ namespace detail {
+
+ void throw_error(boost::system::error_code& ec)
+ {
+ if(ec)
+ throw ec;
+ }
+
+ } // namespace detail
+} // namespace cgi
+
+#endif // CGI_THROW_ERROR_HPP_INCLUDED__
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-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -9,9 +9,27 @@
#ifndef CGI_DETAIL_URL_DECODE_HPP_INCLUDED__
#define CGI_DETAIL_URL_DECODE_HPP_INCLUDED__
+#include <string>
+
namespace cgi {
namespace detail {
+ /// Take two characters (a hex sequence) and return a char
+ 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')
+ );
+
+ return static_cast<char>(ret);
+ }
+
/// URL-decode a string
std::string url_decode( const std::string& str )
{
@@ -38,22 +56,6 @@
return ret;
}
- /// Take two characters (a hex sequence) and return a char
- 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')
- );
-
- return static_cast<char>(ret);
- }
-
} // namespace detail
} // namespace cgi
Deleted: sandbox/SOC/2007/cgi/boost/cgi/gateway.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/gateway.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
+++ (empty file)
@@ -1,167 +0,0 @@
-// -- gateway.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_GATEWAY_HPP_INCLUDED__
-#define CGI_GATEWAY_HPP_INCLUDED__
-
-#include <boost/bind.hpp>
-#include <boost/shared_ptr.hpp>
-
-namespace cgi {
-
- /// The gateway class manages connections
- /**
- * New connections are accepted through here, via a call to accept();
- * used/corrupted connections are closed via a call to stop(conn_ptr);
- * all connections are closed via a call to stop_all().
- *
- * If you want to use the gateway after a call to stop_all(), you must
- * call reset() and pass it the maximum number of connections the gateway
- * can take.
- */
- template< typename CommonGatewayService >
- class gateway
- {
- public:
- typedef CommonGatewayService service_type;
- typedef typename CommonGatewayService::protocol_type protocol_type;
- typedef basic_protocol_service<protocol_type> protocol_service_type;
- typedef connection<protocol_type> connection_type;
- typedef boost::shared_ptr<connection_base> conn_ptr;
-
- /// Constructor
- explicit gateway(protocol_service_type& pservice)
- : service_(pservice)
- //, acceptor_(pservice.io_service())
- {
- //accept();
- }
-
- /// Destructor
- ~gateway()
- {
- stop_all();
- }
-
- /// Start a sychronous accept
- /**
- * This returns false unless the connection is already established. This is
- * true with standard CGI, for example, where the connection is simply a
- * wrapper over standard input/output.
- *
- * If there is a need to differentiate between a fail and a 'waiting' accept
- * then a tribool could be returned from here.
- */
- boost::system::error_code& accept(conn_ptr conn, boost::system::error_code& ec)
- {
- if( service_.accept(conn, ec) )
- {
- connections_.insert(conn);
- }
-
-
- conn_ptr new_conn(connection_type::create());
- acceptor_.accept(new_conn->socket()
- , boost::bind(&cgi::gateway::handle_accept
- , this, new_conn
- , boost::placeholders::error));
- return false;
- }
-
- /// Start an asynchronous accept
- template<typename Handler>
- void async_accept(conn_ptr conn, Handler handler)
- {
- service_.async_accept(handler);
- }
-
- /// Cleanly start the connection
- void start(conn_ptr cptr)
- {
- cptr->start();
- connections_.insert(cptr);
- }
-
- /// Cleanly stop the connection
- void stop(conn_ptr cptr)
- {
- cptr->stop();
- connections_.erase(cptr);
- }
-
- /// Cleanly stop all connections
- void stop_all()
- {
- std::for_each( connection_.begin(), connections_.end()
- , boost::bind(&gateway::stop, _1)
- );
- connections_.clear();
- }
-
- /// Reset the gateway
- /**
- * All connections are gracefully closed and then the gateway is set up for
- * reuse.
- *
- * @param max_connections the available slots is reset to this value
- */
- void reset(int max_connections)
- {
- stop_all();
- available_slots_ = max_connections;
- }
-
- private:
- service_type& service_;
- std::set<conn_ptr> connections_;
- };
-
-
-
- template<>
- class gateway<cgi_protocol_service>
- {
- public:
- gateway()
- {
- }
- private:
-
- };
-
- /*
- template<>
- class gateway::acceptor<tags::fastcgi>
- {
- public:
- gateway::acceptor
- {
- }
- private:
- boost::asio::ip::tcp::acceptor<
- };
- */
-
-} // namespace cgi
-
-#endif // CGI_GATEWAY_HPP_INCLUDED__
-
-/*
- * Notes:
- *
- * 1. A FastCGI server doesn't have to use tcp sockets: it can use pipes
- * instead. Support for these will only come in when Boost.Asio supports them.
- *
- * 2. For now each request object could hold a pointer/reference to the
- * connection that it's associated with. For the forseable future that's going
- * to be enough. However, since the FastCGI spec doesn't say otherwise,
- * eventually it could happen that the response can be sent back via ANY open
- * connection. In that case, the request would have to query the gateway to
- * find an available connection before sending through it. For now, that's
- * unneccesary.
- */
Added: sandbox/SOC/2007/cgi/boost/cgi/gateway_impl/acgi_gateway_impl.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/gateway_impl/acgi_gateway_impl.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,32 @@
+// -- acgi_gateway_impl.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_ACGI_GATEWAY_IMPL_HPP_INCLUDED__
+#define CGI_ACGI_GATEWAY_IMPL_HPP_INCLUDED__
+
+#include "cgi_gateway_impl.hpp"
+
+namespace cgi {
+
+ // Forward declaration
+ class acgi_gateway_service;
+
+
+ class acgi_gateway_impl
+ : public cgi_gateway_impl
+ {
+ public:
+ acgi_gateway_impl() {}
+ ~acgi_gateway_impl() {}
+ private:
+ friend class acgi_gateway_service;
+ };
+
+} // namespace cgi
+
+#endif // CGI_ACGI_GATEWAY_IMPL_HPP_INCLUDED__
Added: sandbox/SOC/2007/cgi/boost/cgi/gateway_impl/async_cgi_gateway_impl.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/gateway_impl/async_cgi_gateway_impl.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,32 @@
+// -- async_cgi_gateway_impl.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_ASYNC_CGI_GATEWAY_IMPL_HPP_INCLUDED__
+#define CGI_ASYNC_CGI_GATEWAY_IMPL_HPP_INCLUDED__
+
+#include "cgi_gateway_impl.hpp"
+
+namespace cgi {
+
+ // Forward declaration
+ class async_cgi_gateway_service;
+
+
+ class async_cgi_gateway_impl
+ : public cgi_gateway_impl
+ {
+ public:
+ async_cgi_gateway_impl() {}
+ ~async_cgi_gateway_impl() {}
+ private:
+ friend class async_cgi_gateway_service;
+ };
+
+} // namespace cgi
+
+#endif // CGI_ASYNC_CGI_GATEWAY_IMPL_HPP_INCLUDED__
Added: sandbox/SOC/2007/cgi/boost/cgi/gateway_impl/cgi_gateway_impl.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/gateway_impl/cgi_gateway_impl.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,32 @@
+// -- cgi_gateway_impl.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_CGI_GATEWAY_IMPL_HPP_INCLUDED__
+#define CGI_CGI_GATEWAY_IMPL_HPP_INCLUDED__
+
+#include <boost/noncopyable.hpp>
+
+namespace cgi {
+
+ // Forward declaration
+ class cgi_gateway_service;
+
+
+ class cgi_gateway_impl
+ : private boost::noncopyable
+ {
+ public:
+ cgi_gateway_impl() {}
+ ~cgi_gateway_impl() {}
+ protected:
+ friend class cgi_gateway_service;
+ };
+
+} // namespace cgi
+
+#endif // CGI_CGI_GATEWAY_IMPL_HPP_INCLUDED__
Modified: sandbox/SOC/2007/cgi/boost/cgi/gateway_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/gateway_service.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/gateway_service.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -19,7 +19,7 @@
public:
typedef Protocol protocol_type;
typedef ProtocolService io_service_type;
- typedef boost::shared_ptr<connection_base> conn_ptr;
+ typedef boost::shared_ptr<connection_type> conn_ptr;
gateway_service(io_service_type& ios)
@@ -27,53 +27,56 @@
{
}
-
- boost::system::error_code&
- accept_impl(conn_ptr conn, boost::system::error_code& ec)
- {
- boost::asio::acceptor(
- }
-
- boost::system::error_code&
- accept(conn_ptr conn, boost::system::error_code& ec)
+ void stop(impl_type& impl)
{
- conn = create_connection();
- if( accept_impl(conn, ec) )
- {
- io_service_.connections_.insert(conn);
- return ec;
- }
-
- // else change the current connection type held by the service, and try again
- // (when implemented by asio & server front-ends)
- // for now just set an error and return
- ec = boost::system::system_error(666);
- return ec;
- }
-
- template<typename Handler>
- class accept_handler
- {
- public:
- accept_handler(Handler handler)
- : handler_(handler)
- {
- }
-
- void operator()(const boost::system::error_code& ec)
- {
- handler_(ec);
- }
-
- private:
- Handler handler_;
- };
- template<typename Handler>
- void async_accept(Handler handler)
- {
- }
+ //boost::system::error_code&
+ //accept(impl_type& impl, conn_ptr conn, boost::system::error_code& ec)
+ //{
+ // boost::asio::acceptor(
+ //}
+
+ //boost::system::error_code&
+ //accept(conn_ptr conn, boost::system::error_code& ec)
+ //{
+ // conn = create_connection();
+
+ // if( accept_impl(conn, ec) )
+ // {
+ // io_service_.connections_.insert(conn);
+ // return ec;
+ // }
+
+ // // else change the current connection type held by the service, and try again
+ // // (when implemented by asio & server front-ends)
+ // // for now just set an error and return
+ // ec = boost::system::system_error(666);
+ // return ec;
+ //}
+
+ //template<typename Handler>
+ //class accept_handler
+ //{
+ //public:
+ // accept_handler(Handler handler)
+ // : handler_(handler)
+ // {
+ // }
+
+ // void operator()(const boost::system::error_code& ec)
+ // {
+ // handler_(ec);
+ // }
+
+ //private:
+ // Handler handler_;
+ //};
+
+ //template<typename Handler>
+ //void async_accept(Handler handler)
+ //{
+ //}
private:
Added: sandbox/SOC/2007/cgi/boost/cgi/gateway_service/acgi_gateway_service.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/gateway_service/acgi_gateway_service.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,30 @@
+// -- acgi_gateway_service.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_ACGI_GATEWAY_SERVICE_HPP_INCLUDED__
+#define CGI_ACGI_GATEWAY_SERVICE_HPP_INCLUDED__
+
+#include "cgi_gateway_service.hpp"
+
+namespace cgi {
+
+ class acgi_gateway_service
+ : public cgi_gateway_service
+ {
+ public:
+ template<typename T>
+ acgi_gateway_service(T&) {}
+
+ acgi_gateway_service() {}
+
+ ~acgi_gateway_service() {}
+ };
+
+} // namespace cgi
+
+#endif // CGI_ACGI_GATEWAY_SERVICE_HPP_INCLUDED__
Added: sandbox/SOC/2007/cgi/boost/cgi/gateway_service/async_cgi_gateway_service.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/gateway_service/async_cgi_gateway_service.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,30 @@
+// -- async_cgi_gateway_service.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_ASYNC_CGI_GATEWAY_SERVICE_HPP_INCLUDED__
+#define CGI_ASYNC_CGI_GATEWAY_SERVICE_HPP_INCLUDED__
+
+#include "cgi_gateway_service.hpp"
+
+namespace cgi {
+
+ class async_cgi_gateway_service
+ : public cgi_gateway_service
+ {
+ public:
+ template<typename T>
+ async_cgi_gateway_service(T&) {}
+
+ async_cgi_gateway_service() {}
+
+ ~async_cgi_gateway_service() {}
+ };
+
+} // namespace cgi
+
+#endif // CGI_ASYNC_CGI_GATEWAY_SERVICE_HPP_INCLUDED__
Added: sandbox/SOC/2007/cgi/boost/cgi/gateway_service/cgi_gateway_service.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/gateway_service/cgi_gateway_service.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,30 @@
+// -- cgi_gateway_service.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_CGI_GATEWAY_SERVICE_HPP_INCLUDED__
+#define CGI_CGI_GATEWAY_SERVICE_HPP_INCLUDED__
+
+namespace cgi {
+
+ class cgi_gateway_service
+ {
+ public:
+ cgi_gateway_service() {}
+ ~cgi_gateway_service() {}
+
+ template<typename T> void construct(T&) {}
+ template<typename T> void destroy(T&) {}
+ template<typename T> void start(T&) {}
+ template<typename T> void stop(T&) {}
+ void stop() {}
+ void reset() {}
+ };
+
+} // namespace cgi
+
+#endif // CGI_CGI_GATEWAY_SERVICE_HPP_INCLUDED__
Modified: sandbox/SOC/2007/cgi/boost/cgi/http/status_code.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/http/status_code.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/http/status_code.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -1,82 +1,82 @@
// -- http/status_code.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
+// 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_HTTP_STATUS_CODE_HPP_INCLUDED__
-#define CGI_HTTP_STATUS_CODE_HPP_INCLUDED__
-
-namespace cgi {
- namespace http {
-
- /// Standard HTTP status codes
- /**
- * See http://tools.ietf.org/html/rfc2616#section-10
- */
- enum status_code
- {
- /// Success codes
- ok = 200,
- created
- accepted,
- non_authorative_information,
- no_content,
- reset_content,
- partial_content,
- multi_status,
-
- /// Redirect codes
- multiple_choices = 300,
- moved_permanently,
- found,
- see_other,
- not_modified,
- use_proxy,
- switch_proxy,
- temporary_redirect,
-
- /// Domain error codes
- bad_request = 400,
- unauthorized,
- payment_required,
- forbidden,
- not_found,
- method_not_allowed,
- not_acceptable,
- proxy_authentication_required,
- request_timeout,
- conflict,
- gone,
- length_required,
- precondition_failed,
- request_entity_too_large,
- request_uri_too_long,
- unsupported_media_type,
- request_range_not_satisfiable,
- expectation_failed,
- unprocessable_entity = 422,
- locked,
- failed_dependency,
- unordered_collection,
- upgrade_required,
- retry_with = 449,
-
- /// Internal error codes
- internal_server_error = 500,
- not_implemented,
- bad_gateway,
- service_unavailable,
- gateway_timeout,
- http_version_not_supported,
- insufficient_storage,
- bandwidth_limit_exceeded = 509
- };
-
- } // namespace http
-} // namespace cgi
-
-#endif // CGI_HTTP_STATUS_CODE_INCLUDED_HPP__
-
+#ifndef CGI_HTTP_STATUS_CODE_HPP_INCLUDED__
+#define CGI_HTTP_STATUS_CODE_HPP_INCLUDED__
+
+namespace cgi {
+ namespace http {
+
+ /// Standard HTTP status codes
+ /**
+ * See http://tools.ietf.org/html/rfc2616#section-10
+ */
+ enum status_code
+ {
+ /// Success codes
+ ok = 200,
+ created,
+ accepted,
+ non_authorative_information,
+ no_content,
+ reset_content,
+ partial_content,
+ multi_status,
+
+ /// Redirect codes
+ multiple_choices = 300,
+ moved_permanently,
+ found,
+ see_other,
+ not_modified,
+ use_proxy,
+ switch_proxy,
+ temporary_redirect,
+
+ /// Domain error codes
+ bad_request = 400,
+ unauthorized,
+ payment_required,
+ forbidden,
+ not_found,
+ method_not_allowed,
+ not_acceptable,
+ proxy_authentication_required,
+ request_timeout,
+ conflict,
+ gone,
+ length_required,
+ precondition_failed,
+ request_entity_too_large,
+ request_uri_too_long,
+ unsupported_media_type,
+ request_range_not_satisfiable,
+ expectation_failed,
+ unprocessable_entity = 422,
+ locked,
+ failed_dependency,
+ unordered_collection,
+ upgrade_required,
+ retry_with = 449,
+
+ /// Internal error codes
+ internal_server_error = 500,
+ not_implemented,
+ bad_gateway,
+ service_unavailable,
+ gateway_timeout,
+ http_version_not_supported,
+ insufficient_storage,
+ bandwidth_limit_exceeded = 509
+ };
+
+ } // namespace http
+} // namespace cgi
+
+#endif // CGI_HTTP_STATUS_CODE_INCLUDED_HPP__
+
Added: sandbox/SOC/2007/cgi/boost/cgi/io_service.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/io_service.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,20 @@
+// -- io_service.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_IO_SERVICE_HPP_INCLUDED__
+#define CGI_IO_SERVICE_HPP_INCLUDED__
+
+#include <boost/asio/io_service.hpp>
+
+namespace cgi {
+
+ using boost::asio::io_service;
+
+} // namespace cgi
+
+#endif // CGI_IO_SERVICE_HPP_INCLUDED__
Added: sandbox/SOC/2007/cgi/boost/cgi/io_service_provider.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/io_service_provider.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,213 @@
+// -- io_service_provider.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_IO_SERVICE_PROVIDER_HPP_INCLUDED__
+#define CGI_IO_SERVICE_PROVIDER_HPP_INCLUDED__
+
+
+#include <boost/ref.hpp>
+#include <boost/bind.hpp>
+#include <boost/thread.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/noncopyable.hpp>
+#include <boost/asio/io_service.hpp>
+//#include <boost/asio/strand.hpp>
+
+#include "tags.hpp"
+
+namespace cgi {
+
+ /// Hold a set number of io_services and return them based on the Policy
+ /**
+ * Contains six member functions:
+ * io_service() - returns a reference to an io_service
+ * stop() - stops all io_services
+ * run() - runs all io_services
+ * reset() - resets all io_services
+
+ * (strike) stop_one() - stops one (running) io_service
+ * (strike) run_one() - runs one (not-yet-started/reset) io_service
+ *
+ * It can also be set up so that only required io_services are run:
+ * each call to io_service() can get an io_service, call io_service::run() on
+ * it and then return it.
+ */
+ template<int IoServiceCount, typename Policy = tags::round_robin>
+ class io_service_provider
+ : private boost::noncopyable
+ {
+ public:
+ io_service_provider(int)
+ // : pos_(0)
+ // , io_services_()
+ // , strand_(io_services_[0])
+ {
+ }
+
+ // void run()
+ //{
+ // boost::shared_ptr<boost:thread>
+ // thread(boost::bind(
+ //}
+
+ // NOT THREAD-SAFE (but should be)
+ //boost::asio::io_service& io_service()
+ //{
+ // return io_services_[pos_++];
+ //}
+ private:
+ //int pos_;
+ //boost::asio::io_service io_services_[IoServiceCount];
+ //boost::asio::io_service::work works_[IoServiceCount];
+ //boost::asio::io_service::strand strand_;
+ };
+
+
+
+ /// Specialization for multi-queue/single-io_service strategy
+ /**
+ * Holds a reference to a passed in io_service. Use of this requires the
+ * user passes in an io_service on construction of the
+ * basic_protocol_service<>.
+ */
+/********************************
+ template<typename Policy>
+ class io_service_provider<0, Policy>
+ : private boost::noncopyable
+ {
+ public:
+ io_service_provider(boost::asio::io_service& ios)
+ : io_service_(ios)
+ {
+ }
+
+ boost::asio:io_service& io_service()
+ {
+ return io_service_;
+ }
+
+ void run()
+ {
+ io_service_.run();
+ }
+
+ void stop()
+ {
+ io_service_.stop();
+ }
+
+ void reset()
+ {
+ io_service_.reset();
+ }
+ private:
+ boost::asio::io_service& io_service_;
+ };
+********************************/
+
+
+ /// Specialization for io_service-per-queue strategy
+ template<typename Policy>
+ class io_service_provider<1, Policy>//tags::>
+ : private boost::noncopyable
+ {
+ public:
+ io_service_provider(int)
+ : io_service_()
+ , work_(io_service_)
+ {
+ }
+
+ io_service_provider()
+ : io_service_()
+ , work_(io_service_)
+ {
+ }
+
+ boost::asio::io_service& io_service()
+ {
+ return io_service_;
+ }
+ private:
+ boost::asio::io_service io_service_;
+ boost::asio::io_service::work work_;
+ };
+
+
+
+ /// Specialization for a variable number of io_services
+ template<typename Policy>
+ class io_service_provider<-1, Policy>//tags::round_robin_pool>
+ : private boost::noncopyable
+ {
+ typedef boost::shared_ptr<boost::asio::io_service> io_service_ptr;
+ typedef boost::shared_ptr<boost::asio::io_service::work> work_ptr;
+
+ public:
+ io_service_provider(int pool_size = 7)
+ : pos_(0)
+ , io_services_()
+// , strand_(io_services_[0])
+ {
+ if (pool_size == 0)
+ throw std::runtime_error("io_service_pool size is 0");
+
+ // Give all the io_services work to do so that their run() functions will
+ // not exit until they are explicitly stopped.
+ for (std::size_t i = 0; i < pool_size; ++i)
+ {
+ io_service_ptr io_service(new boost::asio::io_service);
+ work_ptr work(new boost::asio::io_service::work(*io_service));
+ io_services_.push_back(io_service);
+ work_.push_back(work);
+ }
+ }
+
+ void run()
+ {
+ // Create a pool of threads to run all of the io_services.
+ std::vector<boost::shared_ptr<boost::thread> > threads;
+ for (std::size_t i = 0; i < io_services_.size(); ++i)
+ {
+ boost::shared_ptr<boost::thread>
+ thread(new boost::thread(boost::bind(&boost::asio::io_service::run
+ , io_services_[i])));
+ threads.push_back(thread);
+ }
+
+ // Wait for all threads in the pool to exit.
+ for (std::size_t i = 0; i < threads.size(); ++i)
+ threads[i]->join();
+ }
+
+ void stop()
+ {
+ // Explicitly stop all io_services.
+ for (std::size_t i = 0; i < io_services_.size(); ++i)
+ io_services_[i]->stop();
+ }
+
+ // NOT THREAD-SAFE (but should be)
+ boost::asio::io_service& io_service()
+ {
+ boost::asio::io_service& io_service = *io_services_[pos_];
+ if (++pos_ == io_services_.size())
+ pos_ = 0;
+ return io_service;
+ }
+ private:
+ int pos_;
+ std::vector<io_service_ptr> io_services_;
+ std::vector<work_ptr> work_;
+
+ //boost::asio::io_service::strand strand_;
+ };
+
+} // namespace cgi
+
+#endif // CGI_IO_SERVICE_PROVIDER_HPP_INCLUDED__
Added: sandbox/SOC/2007/cgi/boost/cgi/io_service_provider_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/io_service_provider_fwd.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,19 @@
+// -- io_service_provider_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_IO_SERVICE_PROVIDER_FWD_HPP_INCLUDED__
+#define CGI_IO_SERVICE_PROVIDER_FWD_HPP_INCLUDED__
+
+namespace cgi {
+
+ template<int, typename>
+ class io_service_provider;
+
+} // namespace cgi
+
+#endif // CGI_IO_SERVICE_PROVIDER_FWD_HPP_INCLUDED__
Modified: sandbox/SOC/2007/cgi/boost/cgi/is_async.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/is_async.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/is_async.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -1,6 +1,6 @@
// -- is_async.hpp --
//
-// Copyright (c) Darren Garvey 2007.
+// 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)
@@ -9,39 +9,22 @@
#ifndef CGI_IS_ASYNC_HPP_INCLUDED__
#define CGI_IS_ASYNC_HPP_INCLUDED__
-namespace cgi {
+#include <boost/mpl/bool.hpp>
- template<typename Protocol>
- struct is_aync
- {
- };
-
- template<>
- struct is_aync<tags::cgi>
- {
- typedef boost::mpl::bool_<false> type;
- typedef type::value value;
- };
+#include "tags.hpp"
- template<>
- struct is_aync<tags::async_cgi>
- {
- typedef boost::mpl::bool_<true> type;
- typedef type::value value;
- };
+namespace cgi {
- template<>
- struct is_aync<tags::fcgi>
+ template<typename Protocol>
+ struct is_async
+ : boost::mpl::bool_<true>
{
- typedef boost::mpl::bool_<true> type;
- typedef type::value value;
};
template<>
- struct is_aync<tags::scgi>
+ struct is_async<tags::cgi>
+ : boost::mpl::bool_<false>::type
{
- typedef boost::mpl::bool_<true> type;
- typedef type::value value;
};
} // namespace cgi
Modified: sandbox/SOC/2007/cgi/boost/cgi/logger.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/logger.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/logger.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -1,6 +1,6 @@
// -- logger.hpp --
//
-// Copyright (c) Darren Garvey 2007.
+// 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)
@@ -9,6 +9,8 @@
#ifndef CGI_LOGGER_HPP_INCLUDED__
#define CGI_LOGGER_HPP_INCLUDED__
+#include "request_ostream.hpp"
+
namespace cgi {
/// The logger class: a helper class for writing to requests log streams
@@ -19,12 +21,12 @@
* error output rather than the standard output.
*/
class logger
- : public ostream
+ : public request_ostream
{
public:
/// Default constructor
explicit logger()
- : ostream(tags::stderr)
+ : request_ostream(tags::stderr)
{
}
@@ -34,7 +36,7 @@
* destruction.
*/
logger(std::streambuf* buf)
- : ostream(buf, tags::stderr)
+ : request_ostream(buf, tags::stderr)
{
}
@@ -49,7 +51,7 @@
*/
template<typename CommonGatewayRequest>
logger(CommonGatewayRequest& req)
- : ostream(req, tags::stderr)
+ : request_ostream(req, tags::stderr)
{
}
Modified: sandbox/SOC/2007/cgi/boost/cgi/map.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/map.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/map.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -6,8 +6,8 @@
// http://www.boost.org/LICENSE_1_0.txt)
//
////////////////////////////////////////////////////////////////
-#ifndef CGI_HPP_INCLUDED__
-#define CGI_HPP_INCLUDED__
+#ifndef CGI_MAP_HPP_INCLUDED__
+#define CGI_MAP_HPP_INCLUDED__
#include <map>
#include <string>
@@ -18,4 +18,4 @@
} // namespace cgi
-#endif // CGI_HPP_INCLUDED__
+#endif // CGI_MAP_HPP_INCLUDED__
Deleted: sandbox/SOC/2007/cgi/boost/cgi/ostream.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/ostream.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
+++ (empty file)
@@ -1,278 +0,0 @@
-// -- ostream.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_OSTREAM_HPP_INCLUDED__
-#define CGI_OSTREAM_HPP_INCLUDED__
-
-/*********************************
-ISSUES:
--------
-* async_flush()
-The other flush() functions clear the buffer after flushing the data to the
-request. It's trickier with async_flush(), but for now the buffer is still
-cleared after the flush completes. This means you can't write to the ostream
-until an async_flush completes; that's probably true of any async operation
-however so it seems a reasonable restriction.
-
-* Is ostream the best name for this? request_ostream?
-
-* This class could do more: the functions basic_request<>::write() could write
-to the request unbuffered. ie. a write call would instantly wrap the supplied
-buffer in suitable headers and send it straight away, rather than buffering it
-first. That would also mean the ostream class is of more use than it is now.
-
-* This should probably derive from std::ostream, as users would probably expect
-that.
-*********************************/
-
-#include <ostream>
-
-#include "detail/take_buffer.hpp"
-
-namespace cgi {
-
- /// The ostream class: a stream interface for writing to requests
- /**
- * This is simply a wrapper around an ostream with a few extra details that
- * aid writing to a request's output or error sinks.
- *
- * This is a generalisation of the cgi::reply and cgi::logger classes.
- */
- class ostream
- // derive from std::ostream? (yes, basically)
- {
- public:
- /// Default constructor
- explicit ostream(int destination = tags::stdout)
- : request_(NULL)
- , destination_(destination)
- {
- }
-
- /// Construct with a particular buffer
- /**
- * Takes the buffer and uses it internally, does nothing with it on
- * destruction.
- */
- ostream(std::streambuf* buf, int destination = tags::stdout)
- : ostream_(buf)
- , request_(NULL)
- , destination_(destination)
- {
- }
-
- /// Construct, taking a buffer from an external source
- /**
- * Gets a buffer from the request/protocol service held by the request.
- * <strike>
- * Takes a buffer from T (can be a model of ProtocolService or
- * CommonGatewayRequest) to use internally.
- * </strike>
- */
- template<typename CommonGatewayRequest>
- ostream(CommonGatewayRequest& req, int destination = tags::stdout)
- : ostream_(detail::take_buffer(req))
- , request_(&req)
- , destination_(destination)
- {
- }
-
- ~ostream()
- {
- if( request_ ) send();
- }
-
- void clear()
- {
- ostream_.clear();
- }
-
- // provide this too?
- std::size_t write(const char* str, std::size_t len)
- {
- return ostream_.write(str, len);
- }
-
- std::size_t write(const std::string& str)
- {
- return ostream_.write(str);
- }
-
- template<typename MutableBufferSequence>
- std::size_t write(MutableBufferSequence& buf)
- {
- return ostream_.write(buf.data(), buf.size());
- }
-
- /// Synchronously flush the data to the current request
- /**
- * If there is no error, the buffer is cleared.
- */
- void flush()
- {
- BOOST_ASSERT(request_ != NULL);
- flush(*request_);
- }
-
- /// Synchronously flush the data to the supplied request
- /**
- * This call uses throwing semantics. ie. an exception will be thrown on
- * any failure.
- * If there is no error, the buffer is cleared.
- */
- template<typename CommonGatewayRequest>
- void flush(CommonGatewayRequest& req)
- {
- req.write(ostream_.rdbuf());
- clear();
- }
-
- /// Synchronously flush the data via the supplied request
- /**
- * This call uses error_code semantics. ie. ec is set if an error occurs.
- * If there is no error, the buffer is cleared.
- */
- template<typename CommonGatewayRequest>
- boost::system::error_code& flush(CommonGatewayRequest& req
- , boost::system::error_code& ec)
- {
- if(!req.write(ostream_.rdbuf(), ec))
- clear();
- return ec;
- }
-
- template<typename Handler>
- class flush_handler
- {
- public:
- flush_handler(ostream& os, Handler handler)
- : ostream_(os)
- , handler_(handler)
- {
- }
-
- void operator()(boost::system::error_code& ec)
- {
- if( !ec )
- ostream_.clear();
- handler(ec);
- }
- private:
- ostream& ostream_;
- Handler handler_;
- };
-
- /// Asynchronously flush the data through the supplied request
- /**
- * If there is no error, the buffer is cleared *after* the write has
- * finished.
- */
- template<typename CommonGatewayRequest, typename Handler>
- void async_flush(CommonGatewayRequest& req, Handler handler)
- {
- req.async_write(ostream_.rdbuf()
- , flush_handler<Handler>(*this, handler
- , boost::arg<1>)));
- }
-
-
-
- /// Synchronously send the reply to the default request
- /**
- * Note: The data in the stream isn't cleared after this call, but the
- * request held in the ostream is removed. ie. send() can't be called
- * twice without an arguement (unless you add another request - something
- * not possible yet).
- */
- void send()
- {
- BOOST_ASSERT(request_ != NULL);
- send(*request_);
- request_ = NULL;
- }
-
- /// Synchronously send the reply to the default request
- /**
- * Note: The data in the stream isn't cleared after this call. If the send
- * is sucessful, the request held in the ostream is removed. ie. send()
- * can't be called twice without an arguement (unless you add another
- * request - something not possible yet).
- */
- boost::system::error_code& send(boost::system::error_code& ec)
- {
- BOOST_ASSERT(request_ != NULL);
- if(!send(*request_, destination_, ec))
- request_ = NULL;
- return ec;
- }
-
- /// Synchronously send the data via the supplied request
- /**
- * This call uses throwing semantics. ie. an exception will be thrown on
- * any failure.
- * Note: The data in the stream isn't cleared after this call.
- */
- template<typename CommonGatewayRequest>
- void send(CommonGatewayRequest& req)
- {
- req.write(ostream_.rdbuf(), destination_);
- req.set_status(http_status_);
- }
-
- /// Synchronously send the data via the supplied request
- /**
- * This call uses error_code semantics. ie. ec is set if an error occurs.
- * Note: The data in the stream isn't cleared after this call.
- */
- template<typename CommonGatewayRequest>
- boost::system::error_code& send(CommonGatewayRequest& req
- , boost::system::error_code& ec)
- {
- req.write(ostream_.rdbuf(), destination_, ec);
- req.set_status(http_status_);
- }
-
- /// Asynchronously send the data through the supplied request
- /**
- * Note: The data in the stream isn't cleared after this call.
- */
- template<typename CommonGatewayRequest, typename Handler>
- void async_send(CommonGatewayRequest& req, Handler handler)
- {
- req.set_status(http_status_);
- req.async_write(ostream_.rdbuf(), destination_, handler));
- }
-
- /// Get the buffer associated with the stream
- std::streambuf* rdbuf() const { return ostream_.rdbuf(); }
-
- void set_status(http::status_code& num) { http_status_ = num; }
- http::status_code& get_status() const { return http_status_; }
-
- private:
- http::status_code http_status_;
- std::ostream ostream_;
- int destination_;
-
- /// The request associated with the ostream; can be NULL
- request_base* request_;
-
- friend template<typename T> ostream& operator<<(ostream&, const T&);
- };
-
- /// Operator<< overload for basic outputting ability
- template<typename T>
- ostream& operator<<(ostream& rep, const T& t)
- {
- ostream_<< t;
- return rep;
- }
-
-} // namespace cgi
-
-#endif // CGI_OSTREAM_HPP_INCLUDED__
Deleted: sandbox/SOC/2007/cgi/boost/cgi/protocols.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/protocols.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
+++ (empty file)
@@ -1,23 +0,0 @@
-// -- protocols.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_PROTOCOLS_HPP_INCLUDED__
-#define CGI_PROTOCOLS_HPP_INCLUDED__
-
-namespace cgi {
- namespace protocols {
-
- struct cgi;
- struct async_cgi; // acgi?
- struct fcgi;
- struct scgi;
-
- } // namespace protocols
-} // namespace cgi
-
-#endif // CGI_PROTOCOLS_HPP_INCLUDED__
Added: sandbox/SOC/2007/cgi/boost/cgi/read.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/read.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,22 @@
+// -- read.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_READ_HPP_INCLUDED
+#define CGI_READ_HPP_INCLUDED
+
+#include <boost/asio/read.hpp>
+
+namespace cgi {
+
+ using boost::asio::read;
+ using boost::asio::async_read;
+
+} // namespace cgi
+
+#endif // CGI_READ_HPP_INCLUDED
+
Modified: sandbox/SOC/2007/cgi/boost/cgi/reply.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/reply.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/reply.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -1,8 +1,8 @@
// -- reply.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
+// 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)
//
////////////////////////////////////////////////////////////////
@@ -11,7 +11,7 @@
#include <ostream>
-#include "detail/buffer_ops.hpp"
+#include "request_ostream.hpp"
namespace cgi {
@@ -23,7 +23,7 @@
* standard output rather than the error output.
*/
class reply
- : public ostream
+ : public request_ostream
{
public:
/// Default constructor
@@ -37,7 +37,7 @@
* destruction.
*/
reply(std::streambuf* buf)
- : ostream(buf)
+ : request_ostream(buf)
{
}
@@ -52,7 +52,7 @@
*/
template<typename CommonGatewayRequest>
reply(CommonGatewayRequest& req)
- : ostream(req)
+ : request_ostream(req)
{
}
Modified: sandbox/SOC/2007/cgi/boost/cgi/request.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/request.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/request.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -1,201 +1,21 @@
-<<<<<<< .mine
-//
-// request.hpp
-// -----------
-//
-// Copyright (c) 2007 Darren Garvey
+// -- request.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)
-///////////////////////////////////////////////////////////////////////////////
-
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+////////////////////////////////////////////////////////////////
#ifndef CGI_REQUEST_HPP_INCLUDED__
#define CGI_REQUEST_HPP_INCLUDED__
-#include <boost/noncopyable.hpp>
-#include "request_base.hpp"
-#include "basic_cgi_service_fwd.hpp"
-#include "basic_cgi_request_fwd.hpp"
+#include "basic_request.hpp"
+#include "tags.hpp"
namespace cgi {
-/// The 'request' class that is the user's main entry point into this library
-/**
- * By default the class will work with 'any' service type to provide uniform
- * access to requests handled by any cgi::service type. If no service is
- * provided to the constructor, the object is assumed to be a standard cgi
- * object.
- *
- * @par Example
- * @code
- * void f()
- * {
- * cgi::request r; // standard cgi object
- * }
- *
- * void g()
- * {
- * cgi::fcgi_service service; // fastcgi service
- * cgi::request(service); // fastcgi request
- * }
- * @endcode
- *
- * If runtime linkage is insufficient, a macro can be defined to instead use
- * compile-time linking. Available macros:
- *
- * - @code BOOST_CGI_IMPLICIT_CGI @endcode -> standard cgi
- * - @code BOOST_CGI_IMPLICIT_FCGI @endcode -> fastcgi
- *
- * {{can modern compilers optimize away the runtime element of the general
- * version of request?}}
- */
-
-#if defined(BOOST_CGI_IMPLICIT_CGI)
- typedef basic_cgi_request<protocol::cgi> request;
-#elif defined(BOOST_CGI_IMPLICIT_FCGI)
- typedef basic_cgi_request<protocol::fcgi> request;
-#elif defined(BOOST_CGI_IMPLICIT_SCGI)
-# error "SCGI driver not implemented yet"
-#else
-
- // Below is the 'general' request class
- class request
- : private boost::noncopyable
- {
- boost::shared_ptr<request_base> impl_;
- public:
- template< typename Protocol, typename Allocator = std::allocator() >
- explicit request(basic_cgi_service<Protocol, Allocator>& service)
- : impl_(&service.get_request())
- {
- }
-
- template< typename ServiceType, typename Allocator = std::allocator() >
- request(basic_cgi_request<ServiceType, Allocator>& request)
- : impl_(&request)
- {
- }
-
- template< typename Allocator = std::allocator() >
- request()
- : impl_(new basic_cgi_request< basic_cgi_service<protocol::cgi, Allocator>
- , Allocator
- > request
- )
- {
- }
-
- void end( int return_code )
- {
- impl_->end(return_code);
- }
-
- // more functions
- };
+ typedef basic_request<tags::cgi> request;
} // namespace cgi
#endif // CGI_REQUEST_HPP_INCLUDED__
-
-=======
-//
-// request.hpp
-// -----------
-//
-// 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)
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef __CGI_REQUEST_HPP_INCLUDE_
-#define __CGI_REQUEST_HPP_INCLUDE_
-
-#include <boost/noncopyable.hpp>
-#include "request_base.hpp"
-#include "basic_cgi_service_fwd.hpp"
-#include "basic_cgi_request_fwd.hpp"
-
-namespace cgi {
-
-/// The 'request' class that is the user's main entry point into this library
-/**
- * By default the class will work with 'any' service type to provide uniform
- * access to requests handled by any cgi::service type. If no service is
- * provided to the constructor, the object is assumed to be a standard cgi
- * object.
- *
- * @par Example
- * @code
- * void f()
- * {
- * cgi::request r; // standard cgi object
- * }
- *
- * void g()
- * {
- * cgi::fcgi_service service; // fastcgi service
- * cgi::request(service); // fastcgi request
- * }
- * @endcode
- *
- * If runtime linkage is insufficient, a macro can be defined to instead use
- * compile-time linking. Available macros:
- *
- * @li @code BOOST_CGI_IMPLICIT_CGI @endcode -> standard cgi
- * @li @code BOOST_CGI_IMPLICIT_FCGI @endcode -> fastcgi
- *
- * {{can modern compilers optimize away the runtime element of the general
- * version of request?}}
- */
-
-#if defined(BOOST_CGI_IMPLICIT_CGI)
- typedef basic_cgi_request<protocol::cgi> request;
-#elif defined(BOOST_CGI_IMPLICIT_FCGI)
- typedef basic_cgi_request<protocol::fcgi> request;
-#elif defined(BOOST_CGI_IMPLICIT_SCGI)
-# error "SCGI driver not implemented yet"
-#else
-
- // Below is the 'general' request class
- class request
- : private boost::noncopyable
- {
- boost::shared_ptr<request_base> impl_;
- public:
- template< typename Protocol, typename Allocator = std::allocator() >
- explicit request(basic_cgi_service<Protocol, Allocator>& service)
- : impl_(&service.get_request())
- {
- }
-
- template< typename ServiceType, typename Allocator = std::allocator() >
- request(basic_cgi_request<ServiceType, Allocator>& request)
- : impl_(&request)
- {
- }
-
- template< typename Allocator = std::allocator() >
- request()
- : impl_(new basic_cgi_request< basic_cgi_service<protocol::cgi, Allocator>
- , Allocator
- > request
- )
- {
- }
-
- void end( int return_code )
- {
- impl_->end(return_code);
- }
-
- // more functions
- };
-
-} // namespace cgi
-
-#endif // __CGI_REQUEST_HPP_INCLUDE_
-
->>>>>>> .r7365
Modified: sandbox/SOC/2007/cgi/boost/cgi/request_base.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/request_base.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/request_base.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -1,6 +1,8 @@
#ifndef CGI_REQUEST_BASE_HPP_INCLUDE_
#define CGI_REQUEST_BASE_HPP_INCLUDE_
+//#include "role_type.hpp"
+
namespace cgi {
/// ABC that defines the basic interface for cgi::basic_cgi_request<>s
@@ -11,8 +13,6 @@
class request_base
{
public:
- virtual ~request() { }
-
/// Notify the server that the request has been handled
/**
* Under normal circumstances {{ideally}}, this won't be called internally
@@ -25,10 +25,10 @@
* denote success, anything else an error, however the number will
* generally be ignored by the server.
*/
- virtual void end( int return_code ) = 0;
+ //virtual void end( int return_code ) = 0;
/// Returns the number of bytes available in the read buffer
- virtual std::size_t available() = 0;
+ //virtual std::size_t available() = 0;
/// Get the streambuf associated with the request
/**
@@ -41,7 +41,7 @@
*
* {{should this return an asio::streambuf instead?}}
*/
- virtual std::streambuf* rdbuf() = 0;
+ //virtual std::streambuf* rdbuf() = 0;
/// Flush the output buffer now
/**
@@ -52,7 +52,7 @@
* @note If something goes awry after calling this, the user will
* be left with half a reply, rather than a (cleaner) error page.
*/
- virtual void flush() = 0;
+ //virtual void flush() = 0;
/// Write a message to the error output
/**
@@ -65,7 +65,7 @@
* log file, although there is no guarantee that other platforms will
* recognise it.
*/
- virtual void log( const std::string& error_message ) = 0;
+ //virtual void log( const std::string& error_message ) = 0;
/// Get the role of the current request
/**
@@ -81,14 +81,20 @@
* expected to 'filter' and then return to the server. This is poorly
* supported in production servers {{AFAIK}}
*/
- virtual role_type role() = 0;
+ //virtual role_type role() = 0;
/* SyncReadStream function */
- template<typename MutableBufferSequence>
- virtual std::size_t read_some(MutableBufferSequence) = 0;
+ //template<typename MutableBufferSequence>
+ //virtual std::size_t read_some(MutableBufferSequence) = 0;
+
+ //template<typename MutableBufferSequence>
+ //virtual std::size_t read_some(MutableBufferSequence, error_code&) = 0;
- template<typename MutableBufferSequence>
- virtual std::size_t read_some(MutableBufferSequence, error_code&) = 0;
+ protected:
+ /// Prevent deletion through this type
+ ~request_base()
+ {
+ }
};
} // namespace cgi
Modified: sandbox/SOC/2007/cgi/boost/cgi/request_impl/async_cgi_request_impl.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/request_impl/async_cgi_request_impl.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/request_impl/async_cgi_request_impl.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -1,6 +1,6 @@
// -- async_cgi_request_impl.hpp --
//
-// Copyright (c) Darren Garvey 2007.
+// 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)
Modified: sandbox/SOC/2007/cgi/boost/cgi/request_impl/cgi_request_impl.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/request_impl/cgi_request_impl.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/request_impl/cgi_request_impl.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -1,6 +1,6 @@
// -- cgi_request_impl.hpp --
//
-// Copyright (c) Darren Garvey 2007.
+// 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)
@@ -12,14 +12,24 @@
#include <map>
#include <string>
#include <boost/noncopyable.hpp>
+#include <boost/shared_ptr.hpp>
-#include "http/status_code.hpp"
-#include
+#include "../http/status_code.hpp"
+#include "../connections/stdio.hpp"
+#include "../role_type.hpp"
+#include "../status_type.hpp"
+#include "../map.hpp"
+#include "cgi_request_impl_base.hpp"
// Make this ProtocolService-independent
namespace cgi {
+ // Forward declaration
+ //template<typename>
+ class cgi_service_impl;
+
+
/// Implementation for a standard CGI request
/**
* Note: This isn't noncopyable since there's no real reason it can't be
@@ -27,10 +37,9 @@
* restricted but if someone really wants to copy the data, then they can.
*/
class cgi_request_impl
+ : public cgi_request_impl_base<cgi_request_impl, stdio_connection>
{
public:
- typedef std::map<std::string, std::string> map_type;
-
/// Constructor
/**
* Since this request type is synchronous, there is no need for an
@@ -38,31 +47,24 @@
*/
template<typename ProtocolService>
cgi_request_impl(ProtocolService& pserv)
- : stdin_read_(false)
- , http_status_(http::status_code::ok)
- , request_status_(request_status::unloaded)
+ : cgi_request_impl_base<cgi_request_impl, stdio_connection>(pserv)
{
}
- private:
- friend class cgi_service_impl;
+ cgi_request_impl()
+ : cgi_request_impl_base<cgi_request_impl, stdio_connection>()
+ {
+ }
protected:
- map_type get_vars_;
- map_type post_vars_;
- map_type cookie_vars_;
-
- bool stdin_read_;
-
- http::status_code http_status_;
- request_status request_status_;
+ friend class cgi_service_impl;//<cgi_request_impl>;
};
- template<> inline const std::string&
- cgi_request_impl::var<tags::ENV>(const std::string& name)
- {
- return ::getenv(name);
- }
+ //template<> inline const std::string&
+ //cgi_request_impl::var<tags::ENV>(const std::string& name)
+ //{
+ // return ::getenv(name.c_str());
+ //}
/// Get a request map of all the environment meta-variables (slow)
/**
@@ -82,14 +84,14 @@
//template<> inline cgi_request_impl::map_type&
//cgi_request_impl::var<tags::HTTP>() { return http_map_; }
- template<> inline cgi_request_impl::map_type&
- cgi_request_impl::var<tags::COOKIE>() { return cookie_map_; }
+ //template<> inline cgi_request_impl::map_type&
+ //cgi_request_impl::var<tags::COOKIE>() { return cookie_map_; }
- template<> inline cgi_request_impl::map_type&
- cgi_request_impl::var<tags::GET>() { return get_map_; }
+ //template<> inline cgi_request_impl::map_type&
+ //cgi_request_impl::var<tags::GET>() { return get_map_; }
- template<> inline cgi_request_impl::map_type&
- cgi_request_impl::var<tags::POST>() { return post_map_; }
+ //template<> inline cgi_request_impl::map_type&
+ //cgi_request_impl::var<tags::POST>() { return post_map_; }
} // namespace cgi
Added: sandbox/SOC/2007/cgi/boost/cgi/request_ostream.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/request_ostream.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,328 @@
+// -- request_ostream.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_REQUEST_OSTREAM_HPP_INCLUDED__
+#define CGI_REQUEST_OSTREAM_HPP_INCLUDED__
+
+/*********************************
+ISSUES:
+-------
+* async_flush()
+The other flush() functions clear the buffer after flushing the data to the
+request. It's trickier with async_flush(), but for now the buffer is still
+cleared after the flush completes. This means you can't write to the ostream
+until an async_flush completes; that's probably true of any async operation
+however so it seems a reasonable restriction.
+
+* Is ostream the best name for this? request_ostream?
+
+* This class could do more: the functions basic_request<>::write() could write
+to the request unbuffered. ie. a write call would instantly wrap the supplied
+buffer in suitable headers and send it straight away, rather than buffering it
+first. That would also mean the ostream class is of more use than it is now.
+
+* This should probably derive from std::ostream, as users would probably expect
+that.
+*********************************/
+
+#include <ostream>
+//#include <streambuf>
+#include <boost/assert.hpp>
+#include <boost/bind.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/system/error_code.hpp>
+
+#include "streambuf.hpp"
+#include "buffer.hpp"
+#include "write.hpp"
+#include "tags.hpp"
+#include "data_sink.hpp"
+#include "request_base.hpp"
+#include "http/status_code.hpp"
+//#include "detail/take_buffer.hpp"
+
+namespace cgi {
+
+ class request_ostream;
+
+ namespace detail {
+
+
+ } // namespace detail
+
+
+ /// The ostream class: a stream interface for writing to requests
+ /**
+ * This is simply a wrapper around an ostream with a few extra details that
+ * aid writing to a request's output or error sinks.
+ *
+ * This is a generalisation of the cgi::reply and cgi::logger classes.
+ */
+ class request_ostream
+ // derive from std::ostream? (yes, basically)
+ {
+ public:
+ /// Default constructor
+ explicit request_ostream(http::status_code sc = http::ok)
+ : request_(NULL)
+ , buffer_(new cgi::streambuf())
+ , ostream_(buffer_.get())
+ , http_status_(sc)
+// , destination_(destination)
+ {
+ }
+
+ /// Construct with a particular buffer
+ /**
+ * Takes the buffer and uses it internally, does nothing with it on
+ * destruction.
+ */
+ request_ostream(cgi::streambuf* buf, http::status_code sc = http::ok)
+ : request_(NULL)
+ , ostream_(buf)
+ , http_status_(sc)
+// , destination_(destination)
+ {
+ }
+
+ /// Construct, taking a buffer from an external source
+ /**
+ * Gets a buffer from the request/protocol service held by the request.
+ * <strike>
+ * Takes a buffer from T (can be a model of ProtocolService or
+ * CommonGatewayRequest) to use internally.
+ * </strike>
+ */
+ template<typename CommonGatewayRequest>
+ request_ostream(CommonGatewayRequest& req, http::status_code sc = http::ok)
+ : request_(&req)
+ , buffer_(new cgi::streambuf())
+ , ostream_(buffer_.get()) //detail::take_buffer(req))
+ , http_status_(sc)
+// , destination_(destination)
+ {
+ }
+
+ ~request_ostream()
+ {
+ if (request_) send();
+ }
+
+ void clear()
+ {
+ ostream_.clear();
+ }
+
+ // provide this too?
+ std::size_t write(const char* str, std::size_t len)
+ {
+ ostream_.write(str, len);
+ return len;
+ }
+
+ std::size_t write(const std::string& str)
+ {
+ return write(str.c_str(), str.size());
+ }
+
+ template<typename MutableBufferSequence>
+ std::size_t write(MutableBufferSequence& buf)
+ {
+ ostream_.write(buf.data(), buf.size());
+ return buf.size();
+ }
+
+ /// Synchronously flush the data to the current request
+ /**
+ * If there is no error, the buffer is cleared.
+ */
+ void flush()
+ {
+ BOOST_ASSERT(request_ != NULL);
+ flush(*request_);
+ }
+
+ /// Synchronously flush the data to the supplied request
+ /**
+ * This call uses throwing semantics. ie. an exception will be thrown on
+ * any failure.
+ * If there is no error, the buffer is cleared.
+ */
+ template<typename CommonGatewayRequest>
+ void flush(CommonGatewayRequest& req)
+ {
+ cgi::write(req, *ostream_.rdbuf());
+ // the above function will throw on an error
+ clear();
+ }
+
+ /// Synchronously flush the data via the supplied request
+ /**
+ * This call uses error_code semantics. ie. ec is set if an error occurs.
+ * If there is no error, the buffer is cleared.
+ */
+ template<typename CommonGatewayRequest>
+ boost::system::error_code& flush(CommonGatewayRequest& req
+ , boost::system::error_code& ec)
+ {
+ if(!cgi::write(req, *ostream_.rdbuf(), ec))
+ clear();
+ return ec;
+ }
+
+ template<typename Handler>
+ class flush_handler
+ {
+ public:
+ flush_handler(request_ostream& os, Handler handler)
+ : ostream_(os)
+ , handler_(handler)
+ {
+ }
+
+ void operator()(boost::system::error_code& ec)
+ {
+ if(!ec)
+ ostream_.clear();
+ handler_(ec);
+ }
+ private:
+ request_ostream& ostream_;
+ Handler handler_;
+ };
+
+ /// Asynchronously flush the data through the supplied request
+ /**
+ * If there is no error, the buffer is cleared *after* the write has
+ * finished.
+ */
+ template<typename CommonGatewayRequest, typename Handler>
+ void async_flush(CommonGatewayRequest& req, Handler handler)
+ {
+ cgi::async_write(req, cgi::buffer(*ostream_.rdbuf())
+ , cgi::request_ostream::flush_handler<Handler>(*this, handler
+ , boost::arg<1>)));
+ }
+
+
+
+ /// Synchronously send the reply to the default request
+ /**
+ * Note: The data in the stream isn't cleared after this call, but the
+ * request held in the ostream is removed. ie. send() can't be called
+ * twice without an arguement (unless you add another request - something
+ * not possible yet).
+ */
+ void send()
+ {
+ BOOST_ASSERT(request_ != NULL);
+ send(*request_);
+ request_ = NULL;
+ }
+
+ /// Synchronously send the reply to the default request
+ /**
+ * Note: The data in the stream isn't cleared after this call. If the send
+ * is sucessful, the request held in the ostream is removed. ie. send()
+ * can't be called twice without an arguement (unless you add another
+ * request - something not possible yet).
+ */
+ boost::system::error_code& send(boost::system::error_code& ec)
+ {
+ BOOST_ASSERT(request_ != NULL);
+ if(!send(*request_, ec))
+ request_ = NULL;
+ return ec;
+ }
+
+ /// Synchronously send the data via the supplied request
+ /**
+ * This call uses throwing semantics. ie. an exception will be thrown on
+ * any failure.
+ * Note: The data in the stream isn't cleared after this call.
+ */
+ template<typename CommonGatewayRequest>
+ void send(CommonGatewayRequest& req)
+ {
+ cgi::write(req, *ostream_.rdbuf(), data_sink::stdout());
+ req.set_status(http_status_);
+ }
+
+ /// Synchronously send the data via the supplied request
+ /**
+ * This call uses error_code semantics. ie. ec is set if an error occurs.
+ * Note: The data in the stream isn't cleared after this call.
+ */
+ template<typename CommonGatewayRequest>
+ boost::system::error_code& send(CommonGatewayRequest& req
+ , boost::system::error_code& ec)
+ {
+ cgi::write(req, *ostream_.rdbuf(), ec, data_sink::stdout());
+ req.set_status(http_status_);
+ return ec;
+ }
+
+ /// Asynchronously send the data through the supplied request
+ /**
+ * Note: The data in the stream isn't cleared after this call.
+ */
+ template<typename CommonGatewayRequest, typename Handler>
+ void async_send(CommonGatewayRequest& req, Handler handler)
+ {
+ req.set_status(http_status_);
+ cgi::async_write(req, *ostream_.rdbuf(), handler, data_sink::stdout()));
+ }
+
+ /// Get the buffer associated with the stream
+ boost::shared_ptr<cgi::streambuf> rdbuf() const
+ {
+ return ostream_.rdbuf();
+ }
+
+ void set_status(http::status_code& num) { http_status_ = num; }
+ http::status_code& get_status() const
+ {
+ return http_status_;
+ }
+
+ request_base* request() const
+ {
+ return request_;
+ }
+
+// int destination() const
+// {
+// return destination_;
+// }
+
+ private:
+ /// The request associated with the ostream; can be NULL
+ request_base* request_;
+
+ boost::shared_ptr<cgi::streambuf> buffer_;
+ std::ostream ostream_;
+// std::type_info destination_;//data_sink destination_;
+ http::status_code http_status_;
+
+ template<typename T>
+ friend request_ostream& operator<<(request_ostream&, const T&);
+ };
+
+
+
+ /// Operator<< overload for basic outputting ability
+ template<typename T>
+ request_ostream& operator<<(request_ostream& os, const T& t)
+ {
+ os<< t;
+ return os;
+ }
+
+} // namespace cgi
+
+#endif // CGI_REQUEST_OSTREAM_HPP_INCLUDED__
Modified: sandbox/SOC/2007/cgi/boost/cgi/request_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/request_service.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/request_service.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -1,14 +1,23 @@
// -- request_service.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
+// 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_REQUEST_SERVICE_HPP_INCLUDED
#define CGI_REQUEST_SERVICE_HPP_INCLUDED
+#include <boost/utility/enable_if.hpp>
+
+//#include "is_async.hpp"
+#include "io_service.hpp"
+#include "detail/protocol_traits.hpp"
+#include "basic_protocol_service_fwd.hpp"
+#include "detail/service_base.hpp"
+//#include "service_selector.hpp"
+
namespace cgi {
/// The generic service class for basic_request<>s
@@ -21,37 +30,47 @@
*/
template<typename Protocol>
class request_service
- : public boost::enable_if<is_async<request_traits<Protocol
- >::service_impl_type
- >::value
- , detail::service_base<request_service>
- >::type
+ //: public service_selector<Protocol>
+ : public detail::service_base<request_service<Protocol> >
+ //boost::enable_if<is_async<protocol_traits<Protocol
+ // >::service_impl_type
+ // >::value
+ // , detail::service_base<request_service>
+ // >::type
{
// The platform-specific implementation (only one for now)
- typedef detail::request_traits<Protocol>::service_impl_type
+ typedef typename detail::protocol_traits<Protocol>::service_impl_type
service_impl_type;
public:
- typedef service_impl_type::impl_type impl_type;
-
+ typedef typename service_impl_type::impl_type impl_type;
+
typedef Protocol protocol_type;
typedef basic_protocol_service<Protocol> protocol_service_type;
- typedef basic_request<Protocol> request_type;
- //typedef request_impl<Protocol>
-
/// The unique service identifier
//static boost::asio::io_service::id id;
+ //explicit request_service()
+ //{
+ //}
+
+ request_service(io_service& ios)
+ : detail::service_base<request_service<Protocol> >(ios)
+ //: boost::asio::io_service::service(ps.io_service())
+ , service_impl_(boost::asio::use_service<service_impl_type>(ios))
+ {
+ }
request_service(protocol_service_type& ps)
- : boost::asio::io_service::service(ps.io_service())
+ : detail::service_base<request_service<Protocol> >(ps.io_service())
+ //: boost::asio::io_service::service(ps.io_service())
, service_impl_(boost::asio::use_service<service_impl_type>(ps.io_service()))
{
}
- void create(impl_type& impl)
+ void construct(impl_type& impl)
{
- service_impl_.create(impl);
+ service_impl_.construct(impl);
}
void destroy(impl_type& impl)
@@ -71,9 +90,10 @@
//void construct
- boost::system::error_code& load(bool parse_stdin, boost::system::error_code& ec)
+ boost::system::error_code& load(impl_type& impl, bool parse_stdin
+ , boost::system::error_code& ec)
{
- return service_impl_.load(parse_stdin, ec);
+ return service_impl_.load(impl, parse_stdin, ec);
}
@@ -84,12 +104,15 @@
service_impl_.async_load(impl, parse_stdin, ec, handler);
}
- bool is_open(impl_type& impl);
+ bool is_open(impl_type& impl)
{
return service_impl_.is_open(impl);
}
private:
+ //typename boost::mpl::if_<typename is_async<protocol_type>::value
+ // , boost::add_reference<service_impl_type>
+ // , service_impl_type>::type
service_impl_type& service_impl_;
};
Added: sandbox/SOC/2007/cgi/boost/cgi/request_service_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/request_service_fwd.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,28 @@
+// -- request_service_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_REQUEST_SERVICE_FWD_HPP_INCLUDED
+#define CGI_REQUEST_SERVICE_FWD_HPP_INCLUDED
+
+
+namespace cgi {
+
+ /// The generic service class for basic_request<>s
+ /**
+ * Note: If the protocol is an asynchronous protocol, which means it requires
+ * access to a boost::asio::io_service instance, then this class becomes a
+ * model of the Service concept (**LINK**) and must only use the constructor
+ * which takes a ProtocolService (**LINK**). If the protocol isn't async then
+ * the class can be used without a ProtocolService.
+ */
+ template<typename Protocol>
+ class request_service;
+
+} // namespace cgi
+
+#endif // CGI_REQUEST_SERVICE_FWD_HPP_INCLUDED
Added: sandbox/SOC/2007/cgi/boost/cgi/role_type.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/role_type.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,21 @@
+#ifndef CGI_ROLE_TYPE_HPP_INCLUDED__
+#define CGI_ROLE_TYPE_HPP_INCLUDED__
+
+namespace cgi {
+ namespace role {
+
+ struct responder {};
+ struct authorizer {};
+ struct filter {};
+
+ } // namespace role
+
+ enum role_type
+ { responder
+ , authorizer
+ , filter
+ };
+
+} // namespace cgi
+
+#endif // CGI_ROLE_TYPE_HPP_INCLUDED__
Modified: sandbox/SOC/2007/cgi/boost/cgi/service_impl/async_cgi_service_impl.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/service_impl/async_cgi_service_impl.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/service_impl/async_cgi_service_impl.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -1,6 +1,6 @@
// -- async_cgi_service_impl.hpp --
//
-// Copyright (c) Darren Garvey 2007.
+// 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)
@@ -9,11 +9,14 @@
#ifndef CGI_ASYNC_CGI_SERVICE_IMPL_HPP_INCLUDED__
#define CGI_ASYNC_CGI_SERVICE_IMPL_HPP_INCLUDED__
+#include "../request_impl/async_cgi_request_impl.hpp"
+#include "cgi_service_impl.hpp"
+
namespace cgi {
class async_cgi_service_impl
: public boost::asio::io_service::service
- , public cgi_service_impl<async_cgi_request_impl>
+ , public cgi_service_impl_base<async_cgi_request_impl>
{
public:
typedef tags::async_cgi protocol_type;
Modified: sandbox/SOC/2007/cgi/boost/cgi/service_impl/cgi_service_impl.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/service_impl/cgi_service_impl.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/service_impl/cgi_service_impl.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -1,6 +1,6 @@
// -- cgi_service_impl.hpp --
//
-// Copyright (c) Darren Garvey 2007.
+// 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)
@@ -9,213 +9,41 @@
#ifndef CGI_CGI_SERVICE_IMPL_HPP_INCLUDED__
#define CGI_CGI_SERVICE_IMPL_HPP_INCLUDED__
-#include "detail/extract_params.hpp"
+#include <string>
+#include <map>
+#include <boost/system/error_code.hpp>
+
+//#include "../detail/extract_params.hpp"
+//#include "../role_type.hpp"
+//#include "../http/status_code.hpp"
+//#include "../map.hpp"
+//#include "../request_impl/cgi_request_impl.hpp"
+#include "cgi_service_impl_base.hpp"
+#include "../detail/extract_params.hpp"
+#include "../request_impl/cgi_request_impl.hpp"
namespace cgi {
- template<typename RequestImplType>
+ //class cgi_request_impl;
+
+ //template<typename RequestImplType>
class cgi_service_impl
+ : public cgi_service_impl_base<cgi_request_impl>
{
+ typedef ::cgi::map map_type;
public:
- typedef RequestImplType impl_type;
-
- explicit cgi_service_impl()
- {
- }
-
- explicit cgi_service_impl(protocol_service_type&)
- {
- }
-
- void shutdown_service()
- {
- }
+ typedef cgi_request_impl impl_type;
+ //typedef cgi_service_impl_base<cgi_request_impl> base;
- void create(impl_type& impl)
+ cgi_service_impl()
+ : cgi_service_impl_base<cgi_request_impl>()
{
}
- void destroy(impl_type& impl)
- {
- }
-
- /// Synchronously read/parse the request meta-data
- /**
- * @param parse_stdin if true then STDIN data is also read/parsed
- */
- boost::system::error_code
- load(boost::system::error_code& ec, bool parse_stdin)
- {
- std::string request_method = meta_get("REQUEST_METHOD");
- if (request_method == "GET")
- if (parse_get_vars(ec))
- return ec;
- else
- if (request_method == "POST" && parse_stdin)
- if (parse_post_vars(ec))
- return ec;
-
- parse_cookie_vars(ec);
- return ec;
- }
-
- template<typename ConnectionPtr, typename MutableBufferSequence>
- std::size_t read_some(impl_type& impl, const MutableBufferSequence& buf
- , boost::system::error_code& ec)
- {
- std::size_t s = impl.connection_->read_some(buf, ec);
- return s;
- }
-
- template<typename ConnectionPtr, typename ConstBufferSequence>
- std::size_t write_some(impl_type& impl, const ConstBufferSequence& buf
- , boost::system::error_code& ec)
- {
- return impl.connection_->write_some(buf, ec);
- }
-
- //template<typename VarType> map_type& var(impl_type&) const;
-
- const std::string& var(map_type& meta_data, const std::string& name
- , boost::system::error_code& ec) const
- {
- if ((map_type::iterator pos = meta_data.find(name)) != meta_data.end())
- {
- return *pos;
- }
- return std::string();
-
- /* Alt:
- if( meta_data.find(name) != meta_data.end() )
- return meta_data[name];
- return std::string();
- **/
- }
-
- const std::string& meta_get(impl_type& impl, const std::string& name
- , boost::system::error_code& ec) const
- {
- return var(impl.get_vars_, name, ec);
- }
-
- map_type& meta_get(impl_type& impl) const
- {
- return impl.get_vars_;
- }
-
- /// Find the post meta-variable matching name
- /**
- * @param greedy This determines whether more data can be read to find
- * the variable. The default is true to cause least surprise in the common
- * case of having not parsed any of the POST data.
-
- -----------------------------------------------
- Should this return a pair of iterators instead?
- What about url_decoding?
- -----------------------------------------------
-
- */
- const std::string& meta_post(impl_type& impl, const std::string& name
- , boost::system::error_code& ec
- , bool greedy = true)
- {
- const std::string& val = var(impl.post_vars_, name, ec);
- if (var.empty() && greedy && !ec)
- {
-
- }
-
- return val;
- }
-
- map_type& meta_post(impl_type& impl) const
- {
- return impl.post_vars_;
- }
-
-
- /// Find the cookie meta-variable matching name
- const std::string& meta_cookie(impl_type& impl, const std::string& name
- , boost::system::error_code& ec) const
- {
- return var(impl.cookie_vars_, name, ec, false);
- }
-
- map_type& meta_cookie(impl_type& impl) const
- {
- return impl.cookie_vars_;
- }
-
-
- /// Find the environment meta-variable matching name
- const std::string& meta_env(impl_type& impl, const std::string& name,
- , boost::system::error_code& ec) const
- {
- return ::getenv(name);
- }
-
-
- role_type get_role(impl_type& impl) const
- {
- return role_type::responder;
- }
-
- protected:
- /// Read and parse the cgi GET meta variables
- boost::system::error_code&
- parse_get_vars(impl_type& impl, boost::system::error_code& ec)
- {
- detail::extract_params(meta_env("QUERY_STRING")
- , impl.get_vars_
- , boost::char_separator<char>
- ("", "=&", boost::keep_empty_tokens)
- , ec);
-
- return ec;
- }
-
- /// Read and parse the HTTP_COOKIE meta variable
- boost::system::error_code
- parse_cookie_vars(impl_type& impl, boost::system::error_code& ec)
- {
- // Make sure this function hasn't already been called
- BOOST_ASSERT( impl.cookie_vars_.empty() );
-
- std::string vars = meta_env("HTTP_COOKIE");
- if (vars.empty())
- return ec;
-
- detail::extract_params(meta_env("HTTP_COOKIE")
- , impl.cookie_vars_
- , boost::char_separator<char>
- ("", "=&", boost::keep_empty_tokens)
- , ec);
-
- return ec;
- }
-
- /// Read and parse the cgi POST meta variables (greedily)
- boost::system::error_code
- parse_post_vars(impl_type& impl, boost::system::error_code& ec)
- {
- // Make sure this function hasn't already been called
- BOOST_ASSERT( impl.cookie_vars_.empty() );
-
-# error "Not implemented"
-
- if (impl_.stdin_parsed_)
- {
- }
-
- return ec;
- }
-
- /// Read and parse a single cgi POST meta variable (greedily)
- boost::system::error_code
- parse_one_post_var(impl_type& impl, boost::system::error_code& ec)
+ template<typename T>
+ cgi_service_impl(T&)
+ : cgi_service_impl_base<cgi_request_impl>()
{
-# error "Not implemented"
- return ec;
}
};
Added: sandbox/SOC/2007/cgi/boost/cgi/service_impl/cgi_service_impl_base.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/service_impl/cgi_service_impl_base.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,234 @@
+#ifndef CGI_CGI_SERVICE_IMPL_BASE_HPP_INCLUDED__
+#define CGI_CGI_SERVICE_IMPL_BASE_HPP_INCLUDED__
+
+#include <string>
+#include <cstdlib>
+#include <boost/assert.hpp>
+#include <boost/tokenizer.hpp>
+#include <boost/system/error_code.hpp>
+
+#include "../map.hpp"
+#include "../role_type.hpp"
+#include "../detail/extract_params.hpp"
+
+namespace cgi {
+
+ namespace detail {
+
+
+ } // namespace detail
+
+
+ template<typename RequestImplType>
+ class cgi_service_impl_base
+ {
+ public:
+ typedef RequestImplType implementation_type;
+ typedef ::cgi::map map_type;
+
+ cgi_service_impl_base()
+ {
+ }
+
+ template<typename T>
+ cgi_service_impl_base(T&)
+ {
+ }
+
+ void construct(implementation_type& impl)
+ {
+ }
+
+ void destroy(implementation_type& impl)
+ {
+ }
+
+ /// Synchronously read/parse the request meta-data
+ /**
+ * @param parse_stdin if true then STDIN data is also read/parsed
+ */
+ boost::system::error_code&
+ load(implementation_type& impl, bool parse_stdin
+ , boost::system::error_code& ec)
+ {
+ std::string request_method = meta_get(impl, "REQUEST_METHOD", ec);
+ if (request_method == "GET")
+ if (parse_get_vars(impl, ec))
+ return ec;
+ else
+ if (request_method == "POST" && parse_stdin)
+ if (parse_post_vars(impl, ec))
+ return ec;
+
+ parse_cookie_vars(impl, ec);
+ return ec;
+ }
+
+ template<typename ConnectionPtr, typename MutableBufferSequence>
+ std::size_t read_some(implementation_type& impl, const MutableBufferSequence& buf
+ , boost::system::error_code& ec)
+ {
+ std::size_t s = impl.connection_->read_some(buf, ec);
+ return s;
+ }
+
+ template<typename ConnectionPtr, typename ConstBufferSequence>
+ std::size_t write_some(implementation_type& impl, const ConstBufferSequence& buf
+ , boost::system::error_code& ec)
+ {
+ return impl.connection_->write_some(buf, ec);
+ }
+
+ //template<typename VarType> map_type& var(implementation_type&) const;
+
+ std::string var(map_type& meta_data, const std::string& name
+ , boost::system::error_code& ec) const
+ {
+ /* Alt:
+ if ((typename map_type::iterator pos = meta_data.find(name))
+ != meta_data.end())
+ {
+ return *pos;
+ }
+ return std::string();
+ **/
+
+ if( meta_data.find(name) != meta_data.end() )
+ return meta_data[name];
+ return "";
+ }
+
+ std::string meta_get(implementation_type& impl, const std::string& name
+ , boost::system::error_code& ec) const
+ {
+ return var(impl.get_vars_, name, ec);
+ }
+
+ map_type& meta_get(implementation_type& impl) const
+ {
+ return impl.get_vars_;
+ }
+
+ /// Find the post meta-variable matching name
+ /**
+ * @param greedy This determines whether more data can be read to find
+ * the variable. The default is true to cause least surprise in the common
+ * case of having not parsed any of the POST data.
+
+ -----------------------------------------------
+ Should this return a pair of iterators instead?
+ What about url_decoding?
+ -----------------------------------------------
+
+ */
+ std::string meta_post(implementation_type& impl, const std::string& name
+ , boost::system::error_code& ec
+ , bool greedy = true)
+ {
+ const std::string& val = var(impl.post_vars_, name, ec);
+ if (val.empty() && greedy && !ec)
+ {
+
+ }
+
+ return val;
+ }
+
+ map_type& meta_post(implementation_type& impl) const
+ {
+ return impl.post_vars_;
+ }
+
+
+ /// Find the cookie meta-variable matching name
+ std::string meta_cookie(implementation_type& impl, const std::string& name
+ , boost::system::error_code& ec) const
+ {
+ return var(impl.cookie_vars_, name, ec);
+ }
+
+ map_type& meta_cookie(implementation_type& impl) const
+ {
+ return impl.cookie_vars_;
+ }
+
+
+ /// Find the environment meta-variable matching name
+ std::string meta_env(implementation_type& impl, const std::string& name
+ , boost::system::error_code& ec)
+ {
+ return ::getenv(name.c_str());
+ }
+
+
+ role_type get_role(implementation_type& impl) const
+ {
+ return responder;
+ }
+
+ protected:
+ /// Read and parse the cgi GET meta variables
+ template<typename RequestImpl>
+ boost::system::error_code&
+ 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);
+
+ return ec;
+ }
+
+ /// Read and parse the HTTP_COOKIE meta variable
+ template<typename RequestImpl>
+ boost::system::error_code&
+ parse_cookie_vars(RequestImpl& impl, boost::system::error_code& ec)
+ {
+ // Make sure this function hasn't already been called
+ BOOST_ASSERT( impl.cookie_vars_.empty() );
+
+ std::string vars = meta_env(impl, "HTTP_COOKIE", ec);
+ if (vars.empty())
+ return ec;
+
+ detail::extract_params(meta_env(impl, "HTTP_COOKIE", ec)
+ , impl.cookie_vars_
+ , boost::char_separator<char>
+ ("", "=&", boost::keep_empty_tokens)
+ , ec);
+
+ return ec;
+ }
+
+ /// Read and parse the cgi POST meta variables (greedily)
+ template<typename RequestImpl>
+ boost::system::error_code&
+ parse_post_vars(RequestImpl& impl, boost::system::error_code& ec)
+ {
+ // Make sure this function hasn't already been called
+ BOOST_ASSERT( impl.cookie_vars_.empty() );
+
+ //# error "Not implemented"
+
+ if (impl.stdin_parsed_)
+ {
+ }
+
+ 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
+
+#endif // CGI_CGI_SERVICE_IMPL_HPP_INCLUDED__
Added: sandbox/SOC/2007/cgi/boost/cgi/streambuf.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/streambuf.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,20 @@
+// -- streambuf.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_STREAMBUF_HPP_INCLUDED__
+#define CGI_STREAMBUF_HPP_INCLUDED__
+
+#include <boost/asio/streambuf.hpp>
+
+namespace cgi {
+
+ using boost::asio::streambuf;
+
+} // namespace cgi
+
+#endif // CGI_STREAMBUF_HPP_INCLUDED__
Added: sandbox/SOC/2007/cgi/boost/cgi/tags.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/tags.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,36 @@
+// -- tags.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_TAGS_HPP_INCLUDED__
+#define CGI_TAGS_HPP_INCLUDED__
+
+namespace cgi {
+ namespace tags {
+
+ // the null tag type
+ struct null {};
+
+ // protocol types
+ struct cgi {};
+ struct async_cgi {}; // call it acgi?
+ struct acgi {};
+ struct fcgi {};
+ struct scgi {};
+
+ // IoServiceProvider Policy types
+ struct round_robin {};
+
+ // Connection types
+ struct stdio {};
+ struct async_stdio {};
+ struct tcp_socket {};
+
+ } // namespace tags
+} // namespace cgi
+
+#endif // CGI_TAGS_HPP_INCLUDED__
Added: sandbox/SOC/2007/cgi/boost/cgi/write.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/boost/cgi/write.hpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,21 @@
+// -- write.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_WRITE_HPP_INCLUDED
+#define CGI_WRITE_HPP_INCLUDED
+
+#include <boost/asio/write.hpp>
+
+namespace cgi {
+
+ using boost::asio::write;
+ using boost::asio::async_write;
+
+} // namespace cgi
+
+#endif // CGI_WRITE_HPP_INCLUDED
Modified: sandbox/SOC/2007/cgi/libs/cgi/build/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/libs/cgi/build/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/libs/cgi/build/Jamfile.v2 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -1,10 +1,12 @@
-project cgi
- : requirements
- <include>$(BOOST_ROOT)
- : usage-requirements
- <include>$(BOOST_ROOT)
+## Nothing to build for now
+
+#project cgi
+# : requirements
+# <include>$(BOOST_ROOT)
+# : usage-requirements
+# <include>$(BOOST_ROOT)
#source-location = ../src
- ;
+# ;
#SOURCES
Modified: sandbox/SOC/2007/cgi/libs/cgi/doc/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/libs/cgi/doc/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/libs/cgi/doc/Jamfile.v2 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -10,37 +10,46 @@
import doxygen ;
# compile the doxygen sources here
-doxygen cgi_dox
- :
-# [ glob-tree ../../../boost/cgi/*.hpp : .svn ]
-# [ glob-tree ../../../boost/libs/cgi/src/*.cpp : .svn ]
- [ glob ../../../boost/cgi/*.hpp ]
- [ glob ../../../boost/cgi/detail/*.hpp ]
- [ glob ../../../boost/libs/cgi/src/*.cpp ]
- [ glob ../../../boost/libs/cgi/src/detail/*.cpp ]
- :
- <doxygen:param>HIDE_UNDOC_MEMBERS=YES
- <doxygen:param>EXTRACT_PRIVATE=NO
- <doxygen:param>EXTRACT_ALL=NO
- ;
+doxygen autodoc
+ :
+# [ glob-tree ../../../boost/cgi/*.hpp : .svn ]
+# [ glob-tree ../../../boost/libs/cgi/src/*.cpp : .svn ]
+
+ [ glob ../../../boost/cgi/*.hpp ]
+ [ glob ../../../boost/cgi/gateway_impl/*.hpp ]
+ [ glob ../../../boost/cgi/gateway_service/*.hpp ]
+ [ glob ../../../boost/cgi/http/*.hpp ]
+ [ glob ../../../boost/cgi/connections/*.hpp ]
+ [ glob ../../../boost/cgi/request_impl/*.hpp ]
+ [ glob ../../../boost/cgi/request_service/*.hpp ]
+ :
+ <doxygen:param>HIDE_UNDOC_MEMBERS=YES
+ <doxygen:param>EXTRACT_PRIVATE=NO
+ <doxygen:param>EXTRACT_ALL=YES
+ <doxygen:param>SEARCH_INCLUDES=YES
+ <doxygen:param>INCLUDE_PATH=$(BOOST_ROOT)
+ ;
xml cgi_xml : cgi.qbk ;
boostbook standalone
- :
- cgi_xml
- cgi_dox
- :
- <xsl:param>boost.root=/usr/local/src/boost
- <xsl:param>boost.libraries=/usr/local/src/boost/libs/libraries.htm
- <xsl:param>boost.images=http://boost.org/images
- <xsl:param>toc.max.depth=10
- <xsl:param>toc.section.depth=10
- <xsl:param>chunk.section.depth=10
- ;
+ :
+ cgi_xml
+ autodoc
+# cgi_dox
+ :
+ <xsl:param>boost.root=/usr/local/src/boost
+ <xsl:param>boost.libraries=/usr/local/src/boost/libs/libraries.htm
+ <xsl:param>boost.images=http://boost.org/images
+ <xsl:param>toc.max.depth=10
+ <xsl:param>toc.section.depth=10
+ <xsl:param>chunk.section.depth=10
-install html
- :
- /boost//doc/html/boostbook.css
- /bin/doc/$(toolset)/debug/cgi_xml.xml
+# <dependency>autodoc
;
+
+#install html
+# :
+# /boost//doc/html/boostbook.css
+# /bin/doc/$(toolset)/debug/cgi_xml.xml
+# ;
Modified: sandbox/SOC/2007/cgi/libs/cgi/doc/cgi.qbk
==============================================================================
--- sandbox/SOC/2007/cgi/libs/cgi/doc/cgi.qbk (original)
+++ sandbox/SOC/2007/cgi/libs/cgi/doc/cgi.qbk 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -1,365 +1,47 @@
+[/
+ / 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)
+ /]
+
[article CGI
- [quickbook 1.5]
+ [quickbook 1.3]
[version 0.01]
[id cgi]
[dirname the_document_dir]
[copyright 2007 Darren Garvey]
[purpose Thoughts about CGI implementation]
[authors [Garvey, Darren]]
+ [license
+ 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])
+ ]
]
-[section Introduction]
-
-This library is an aid to writing portable CGI/FastCGI/SCGI programs. etc...
-
-[endsect]
-
-[section Design Notes]
-
-[section Concepts]
-
-[section Gateway]
-
-The purpose of the Gateway is to accept a connection and return it. For any particular protocol, there can be multiple types of valid connection (eg. FastCGI connections can be "any reliable full-duplex connection") so the Gateway simplifies the act of iterating through the different allowed (and supported) connection types and notifying the caller when one is established.
-
-[endsect]
-
-[endsect]
-
-[endsect]
-
-
-
-
-
-
-
-
-[section Old Stuff]
-
-[note There are many technicalities to the different protocols that aren't discussed in the SoC proposal, or even this document. Examples of these include issues about automatic parsing of CGI POST variables, security issues with external FastCGI 'servers' and different FastCGI process types (ie. Responder, Authorizer and Filter). Queries about issues like these can be brought up either through the boost mailing list or via personal email ( lists.drrngrvy '''[ @ ] gmail [ . ]''' com ).]
-
-[section Links]
-
-These links relate to the Summer of Code proposal.
-
-[section References]
-
-'''[CGI]''' - version 1.1 - [@http://www.ietf.org/rfc/rfc3875] [br]
-(version 1.2 (draft '''[outdated/irrelevant?]''') - [@http://cgi-spec.golux.com/cgi-120-00a.html])
-
-'''[FCGI]''' - [@http://www.fastcgi.com/devkit/doc/fcgi-spec.html]
-
-'''[SCGI]''' - [@http://python.ca/scgi/protocol.txt]
-
-[endsect]
-
-[section Further Discussion]
-
-http://www.fastcgi.com - Links to documents about FastCGI, explaining rationale and performance benefits.
-
-http://cryp.to/libfastcgi - The only known FastCGI implementation specifically for C++. It is currently lacking IO facilities (+ a minor bug).
-
-[endsect]
-
-[endsect]
-
-[section Code Examples]
-
-These examples are just thoughts based on what I have already coded. They are likely to change based on input from boost mailing lists and further research, but not due to technical considerations.
-Note: `#include`s are expunged from the code below.
+[def __cgi__ [@http://en.wikipedia.org/wiki/Common_Gateway_Interface CGI]]
+[def __scgi__ [@http://en.wikipedia.org/wiki/Simple_Common_Gateway_Interface SCGI]]
+[def __fcgi__ [@http://en.wikipedia.org/wiki/FastCGI FastCGI]]
-[section Basic CGI Example]
+[def __asio__ [@http://asio.sourceforge.net Asio]]
-``
-int main(int, char**)
-{
- cgi::request req;
- req.status(200); // This would output "Status: 200 OK\r\n" for an nph file; a NOP otherwise
- req.header("Content-type: text/html");
- req<< "Hello world";
- return 0;
-}
-``
-[endsect]
-[section Simple FastCGI Example]
-
-Below are two alternatives to handle multiple requests sequentially within the same program. The function `cgi::request::accept()` is inspired by the FastCGI reference implementation, although alternatives might be `reset()` or `renew()`
-``
-int main(int, char**)
-{
- cgi::fcgi_service service;
-
- cgi::request req(&service);
- do {
- req.header("Content-type: text/plain");
- req<< "Hello world";
- } while( req.reset() );
-
- return 0;
-}
-``
-An alternative to this, fitting closer to the FastCGI reference implementation might be the following:
-(NB.this approach would change the code slightly in the FastCGI example [link cgi.code_examples.realistic_fastcgi_example below])
-``
-int main(int, char**)
-{
- cgi::fcgi_service service; // equivalent to cgi::basic_cgi_service<cgi::fcgi> service;
-
- cgi::request req(&service, false); // false => don't load a request yet
- while( req.accept() )
- {
- req.status(204); // would output "204 No Content\r\n" for SCGI
- // "Status: 204 No Content\r\n" for FastCGI
- // and would be a NOP for stdCGI
- req.header("Content-type: text/plain");
- req<< "Hello world";
- }
-}
-``
-
-[endsect]
-[section Realistic FastCGI Example]
-
-The following is an example of a CGI program that exploits the benefits of handling many requests per program. This setup allows alot of flexibility in how responsive a process should be to incoming requests.
-``
-void sub_main( cgi::reqest& req )
-{
- do {
- req.header("Content-type: text/plain");
- req<< "Hello, world";
- } while( req.renew() );
-}
-
-class event_handler : public cgi::event_handler
-{
- boost::thread_group work_threads_;
- boost::mutex mutex_;
- int available_threads_;
-public:
- typedef boost::mutex::scoped_lock scoped_lock;
-
- event_handler( int max_threads )
- : available_threads_(max_threads)
- { }
-
- virtual ~event_handler()
- {
- work_threads_.join_all();
- }
-
- virtual void operator() ( cgi::event_type event, cgi::request* req, )
- {
- scoped_lock lk(&mutex_);
- if( event == cgi::event_type::new_request && available_threads_ )
- {
- --available_threads_;
- work_threads_.create_thread( boost::bind( &sub_main
- , boost::ref(*req)
- )
- );
- }
- if( event == cgi::event_type::request_not_renewed ) // just a thought
- /* this event_type would be sent when a request is closed without
- being renewed. If this example was extended and the loop in
- sub_main could be broken, that would imply destruction of a
- thread */
- ++available_threads_;
- }
-};
-
-int main(int, char**)
-{
- event_handler listener(50);
- cgi::fcgi_service service( listener );
- return 0;
-}
-``
-
-The above shows how my FastCGI implementation currently uses an external event handler. Personally, I'd prefer to have an internal scheduler, which could make `main()` above become something like:
-
-``
-int main(int, char**)
-{
- // ideally this would just be 'cgi::options' with no code generation for
- // options that don't work with that particular flavour of service
- // is this possible? worthwhile?
- cgi::fcgi_options opt;
- // up to 50 threads are spawned to handle new requests, assuming a thread
- // isn't waiting for a new one
- opt.set_option(cgi::max_threads, 50);
- // if the max threads are in use and the queue size reaches this limit,
- // start rejecting incoming requests by returning FCGI_OVERLOADED to the
- // server
- opt.set_option(cgi::max_queue_size, 30);
- cgi::fcgi_service service( &sub_main, opt );
- return 0;
-}
-``
-
-This would remove the need for the nasty-looking event handler, make the simplest "hello world" case more practicable and possibly make the code more portable by removing the need for applications to detect if threads are available. The reason I've kept the external event handler for now is that I'm still not sure that there are no cases where the added insight into the workings of the `fcgi_service` is needed. I'm not sure if it's still necessary though, and I like the cleaner, internal-handler approach better. (Thoughts, please?)
-
-What I'm wondering now:
-
-* Is the first approach better, or can the second approach (ie. dynamic options) plus an incremental check (from `main`) as to the status of the `fcgi_service` offer more flexibility?
- * Essentially this boils down to: can every fringe case be handled with an option setting?
-* Rather than hard-coding the spawn/serve/reject rules in the second approach, would using an internal handler - which could be replaced by a user-defined handler - add significant/any overhead? Hmmm.
-
-[endsect]
-
-[section Simple SCGI example]
-
-The following is essentially the same as above, but using the SCGI protcol.
-``
-int main(int, char**)
-{
- cgi::scgi_service service; // the only line changed
-
- cgi::request req(&service);
- while( req.accept() )
- {
- req.status(206); // would output "206 Partial Content\r\n"
- req.header("Content-type: text/plain");
- std::cout(&req.rdbuf()); // this has to work too
- std::cout<< "Hello world";
- }
-}
-``
-[endsect]
-
-[endsect]
-
-[section Discussion]
-
-[section The `cgi::request` object]
-
-To clarify some of the discussion in the proposal, the referenced `request` object will likely be a 'bridge' object (correct nomenclature?) and could take the following form:
-
-``
-template<typename CGI_Service>
-class request : boost:noncopyable
-{
- service_type* service_;
- request_type* request_impl_;
- bool std_cgi_;
-public:
- typedef basic_cgi_service<CGI_Service> service_type;
- typedef basic_cgi_request<CGI_Service> request_type;
-
- request( service_type* service = NULL
- , bool load_now = true )
- : service_(service)
- , std_cgi_(false)
- {
- if( !service )
- {// default to standard CGI
- std_cgi_ = true;
- service_ = new basic_cgi_service<cgi>;
- }
- if( load_now )
- request_impl_ = service_.yield_one(); // get a request from the request queue
- }
-
- ~request()
- {
- service_.end_request(request_impl_); // housekeeping
- if( std_cgi_ ) delete service_;
- }
-
- int accept()
- {
- if( std_cgi_ ) return 0;
- return service_.yield_one()
-
- // ...
-};
-``
-[endsect]
-
-[section C++'s use as a CGI language]
-
-Some thoughts:
-
-* C++ is designed to aid large-scale developments, which modern web-based applications are a prime example of;
-* C++0x will likely bring with it facilities (such as regular expressions and threads) which make the language well suited to this domain;
-* An emerging trend (I use the term loosely) as web applications and language-binding technologies mature, is for components to be first developed using an RAD language like Python and later when the code settles for it to be ported to C++. Access to a scalable C++ CGI library would aid and encourage this development style;
-* Given how widely practised and understood CGI programming is, with all the home-grown CGI libraries around, C++ should really have a robust CGI library with a standard API.
+[def __reading_the_docs__ [link cgi.intro.reading_the_docs reading the docs]]
+[def __naming conventions__ [link cgi.intro.naming_conventions naming conventions]]
-[endsect]
-
-
-
-[section Justification for seperation of `cgi::service` and `cgi::request`]
-
-It is actually possible to create a library capable of dealing with CGI, FastCGI and SCGI protocols with the simple 'hello world' example below. The logic for doing so [link cgi.discussion.logic follows this section].
-``
-int main(int, char**)
-{
- cgi::request q;
- q.header("Content-type: text/plain");
- q<< "Hello world";
- return 0;
-}
-``
-This approach is poor C++ style for several reasons:
-
-* First - and most importantly - the assumption made to differentiate between FastCGI and SCGI is not guaranteed to always remain valid. In that case, the `service` and `request` objects would have to be separated, breaking any code using the library.
-* Second, it is guaranteed to provide suboptimal performance by clarifying program function at run-time when it could very simply be achieved at compile-time.
-* Thirdly, the syntax implies a closer tying of request and protocol service than an implementation is likely to provide: in reality, protocols will provide control mechanisms to the program which bear no relation to the processing request. Programmers should be able to distinguish between the two targets rather than making ambiguous-looking calls on a `request` object when it in fact bears no relation to that request.
-* Finally, separation provides flexibility. A `cgi::basic_cgi_service<>` object has to provide no more than a guarantee to interpret functions into a `cgi::basic_cgi_request<>` format - which will hopefully be very unrestrictive - in order to be useable. As an hypothetical example, a program using this library could potentially be a standalone HTTP server, as long as the '`http_service`' (eg. a `typedef` of `cgi::basic_cgi_service<cgi::http>`) handled everything, except for CGI requests, which it loads into an `http_request` and adds to the request queue. (I like this idea, although it's far beyond the scope of the proposal)
-
-A more subtle point is that some systems allow CGI variables to be sent via the command line. Since this is uncommon practice, the example above should work in the vast majority of cases. Since I consider taking over `main()` a no-go, this fringe case can easily be handled by a `cgi::service` whose constructor takes the program command line arguements.
-
-All but the first point are also justification for not just proposing a FastCGI-only library.
-
-[endsect]
-
-[section:logic Differentiating Between CGI, SCGI and FastCGI Automatically]
+[include preface.qbk]
-Below is a brief explanation how the differences between these protocols could ['currently] be exploited to provide a library that can automagically guess which protocol it's being called with.
+[include introduction.qbk]
-Note: This is essentially a 'trick', which works on the basis of several (high-probability) assumptions. It's something I shrugged off for good reason before even attempting to implement it. It is here as a curiosity, so skip it if you're pressed for time.
+[section Tutorial]
-``
-// Guarantee: FCGI_LISTENSOCK_FILENO equals STDIN_FILENO
-if ( ! (getpeername(FCGI_LISTENSOCK_FILENO) == -1 && errno == ENOTCONN ) )
- // we have a standard CGI object; end of guessing
-``
-
-# SCGI always reports the message length followed by a colon before the packet starts. This message length does not include the stdin characters.
-# Then CGI environment variables are passed through the socket (these add to the message length) with the format `NAME<00>VALUE<00>` where `<00>` is the NULL character.
-# A guarantee of SCGI is that variable `CONTENT_LENGTH` is set even if it is zero. There must also be a variable `SCGI` with a value of 1. That makes the shortest message length 24 - from `CONTENT_LENGTH<00>0<00>SCGI<00>1<00>`.
-This means that the first two characters sent to the program must be either "24" or numerically larger ("25", "26", etc.).
-# With FastCGI the first character is the version number, which is currently 1. The second character would have to be either 1 (`FCGI_BEGIN_REQUEST`) or 9 (`FCGI_GET_VALUES` - used by the server to query the program about its multiplexing capabilities: currently this isn't used by either apache, lighttpd or Zeus)
-# [*Now the theory starts getting speculative]
-# The SCGI protocol states that the server ['should] pass the standard CGI variables through the socket, this would push the message length (ie. the first two+ characters) well over 24.
-# The FastCGI 1.0 specification has been around for over a decade. The assumption here is that the number isn't likely to increment at a fast pace (probable, but crude)
-# Even if FastCGI 2.0 came out, the only possible failing scenario is if the server queries with FCGI_GET_VALUES: the SCGI equivalent arises with the minimum message described above with an environment variable whose name<00>value<00> combined length is 5, called via the POST method (ie. QUERY_STRING will probably not be set). This is unlikely (but possible) since REQUEST_METHOD is always likely to be set as either GET or POST, adding at least 19 to the message length value.
+The tutorial is broken up into several parts, corresponding to the different protocols you can use.
-Thus, this hypothetical all-inclusive library would probably function until the implementation of a FastCGI 4 - compatible server. Considering FastCGI 1.0 is still very poorly supported by servers, this is not exactly a 'jaws senario'. The guessing penalty would even become insignificant if the program ran for long enough. Heh, in the end, this just isn't C++, is it? Besides, a service capable of doing this could easily be implemented using the proposed framework.
+[include tutorial.qbk]
[endsect]
-[section To Do]
-* Signal handling (see [@http://www.fastcgi.com/docs/faq.html#Signals] for FastCGI-specific information; inquire about SCGI)
-* Change outputting for `cgi::fcgi_service` to use Boost.Iostreams (probably a `filtering_streambuf` so it can be added to a chain - in case a user wants to format output, for instance)
-* ...
+[xinclude autodoc.boostbook]
-[endsect]
-
-[section Moving fcgi::service::event_handler into an internal one]
-
-Possible signals for the `event_handler` (and what they're likely to be used for), assuming efficiency wasn't an issue:
-
-* New request
- * Taken by existing thread
- * Not taken by existing thread (ie. spawn a new thread to handle it)
-* Request not renewed (aka. thread not reused/thread closed naturally)
-* Request aborted (FastCGI-specific, I think)
-
-[endsect]
-
-[endsect]
-
-[endsect]
+[include reference.qbk]
Modified: sandbox/SOC/2007/cgi/libs/cgi/test/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/libs/cgi/test/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/libs/cgi/test/Jamfile.v2 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -1,7 +1,21 @@
import testing ;
-test-suite "cgi"
- : # [ run test_1.cpp ]
- ;
+test-suite cgi
+ :
+ [ compile compile/stdio_connection.cpp ]
+ [ compile compile/async_stdio_connection.cpp ]
+ [ compile compile/tcp_connection.cpp ]
+ [ compile compile/cgi_service.cpp ]
+# [ compile compile/fcgi_service.cpp ]
+ [ compile compile/is_async_test.cpp ]
+ [ compile compile/cgi_request.cpp ]
+ [ compile compile/acgi_request.cpp ]
+ [ compile compile/reply.cpp ]
+
+# [ run run/stdio_connection.cpp ]
+ :
+ <include>$(BOOST_ROOT)
+ <include>"../../../"
+ ;
Added: sandbox/SOC/2007/cgi/libs/cgi/test/compile/acgi_request.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/libs/cgi/test/compile/acgi_request.cpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,11 @@
+//#include "boost/cgi/io_service.hpp"
+#include "boost/cgi/cgi/cgi_service.hpp"
+#include "boost/cgi/cgi/acgi_request.hpp"
+
+int main()
+{
+ cgi::cgi_service service;
+ cgi::acgi_request req(service);
+
+ return 0;
+}
Added: sandbox/SOC/2007/cgi/libs/cgi/test/compile/async_stdio_connection.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/libs/cgi/test/compile/async_stdio_connection.cpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,9 @@
+#include "boost/cgi/connections/async_stdio.hpp"
+
+int main()
+{
+ cgi::io_service ios;
+ cgi::async_stdio_connection conn(ios);
+
+ return 0;
+}
Added: sandbox/SOC/2007/cgi/libs/cgi/test/compile/cgi_request.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/libs/cgi/test/compile/cgi_request.cpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,8 @@
+#include "boost/cgi/cgi/cgi_request.hpp"
+
+int main()
+{
+ cgi::cgi_request req;
+
+ return 0;
+}
Added: sandbox/SOC/2007/cgi/libs/cgi/test/compile/cgi_service.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/libs/cgi/test/compile/cgi_service.cpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,8 @@
+#include "boost/cgi/cgi/cgi_service.hpp"
+
+int main()
+{
+ cgi::cgi_service s;
+
+ return 0;
+}
Added: sandbox/SOC/2007/cgi/libs/cgi/test/compile/fcgi_service.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/libs/cgi/test/compile/fcgi_service.cpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,8 @@
+#include "boost/cgi/fcgi/fcgi_service.hpp"
+
+int main()
+{
+ cgi::fcgi_service s;
+
+ return 0;
+}
Added: sandbox/SOC/2007/cgi/libs/cgi/test/compile/is_async_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/libs/cgi/test/compile/is_async_test.cpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,15 @@
+#include <boost/static_assert.hpp>
+#include "boost/cgi/is_async.hpp"
+
+
+int main()
+{
+ using namespace cgi;
+
+ BOOST_STATIC_ASSERT(is_async<tags::cgi>::value == false);
+ BOOST_STATIC_ASSERT(is_async<tags::async_cgi>::value == true);
+ BOOST_STATIC_ASSERT(is_async<tags::fcgi>::value == true);
+ BOOST_STATIC_ASSERT(is_async<tags::scgi>::value == true);
+
+ return 0;
+}
Added: sandbox/SOC/2007/cgi/libs/cgi/test/compile/reply.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/libs/cgi/test/compile/reply.cpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,8 @@
+#include "boost/cgi/reply.hpp"
+
+int main()
+{
+ cgi::reply rep;
+
+ return 0;
+}
Added: sandbox/SOC/2007/cgi/libs/cgi/test/compile/stdio_connection.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/libs/cgi/test/compile/stdio_connection.cpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,8 @@
+#include "boost/cgi/connections/stdio.hpp"
+
+int main()
+{
+ cgi::stdio_connection conn;
+
+ return 0;
+}
Added: sandbox/SOC/2007/cgi/libs/cgi/test/compile/tcp_connection.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/libs/cgi/test/compile/tcp_connection.cpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,9 @@
+#include "boost/cgi/connections/tcp.hpp"
+
+int main()
+{
+ cgi::io_service ios;
+ cgi::tcp_connection conn(ios);
+
+ return 0;
+}
Added: sandbox/SOC/2007/cgi/libs/cgi/test/run/stdio_connection.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/libs/cgi/test/run/stdio_connection.cpp 2007-07-20 04:13:59 EDT (Fri, 20 Jul 2007)
@@ -0,0 +1,14 @@
+#include <boost/system/error_code.hpp"
+#include "boost/cgi/buffer.hpp"
+#include "boost/cgi/connections/stdio.hpp"
+
+int main()
+{
+ cgi::stdio_connection conn;
+
+ boost::system::error_code ec;
+
+ conn.write_some(cgi::buffer("Hello, world"), ec);
+
+ return 0;
+}
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