|
Boost-Commit : |
From: lists.drrngrvy_at_[hidden]
Date: 2007-11-19 22:00:42
Author: drrngrvy
Date: 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
New Revision: 41245
URL: http://svn.boost.org/trac/boost/changeset/41245
Log:
Again, not a particularly atomic commit, but:
* Added some examples;
* Allow use of boost::cgi, boost::acgi, boost::fcgi, boost::scgi;
* Added listen(), bind(), assign() and open() functions to acceptor classes (at least, to the SCGI ones);
* Fixed tcp_connection static create() function;
* other minor changes.
Added:
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/doc/src/library_organisation.qbk (contents, props changed)
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/doc/src/responses.qbk (contents, props changed)
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/cookie_game/ (props changed)
- copied from r41131, /sandbox/SOC/2007/cgi/branches/cgi_work/libs/cgi/example/acgi/cookie_game/
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/cookie_game/Jamfile.v2
- copied, changed from r41244, /sandbox/SOC/2007/cgi/branches/cgi_work/libs/cgi/example/acgi/cookie_game/Jamfile.v2
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/cookie_game/main.cpp
- copied, changed from r41244, /sandbox/SOC/2007/cgi/branches/cgi_work/libs/cgi/example/acgi/cookie_game/main.cpp
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/echo/
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/echo/Jamfile.v2 (contents, props changed)
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/echo/main.cpp (contents, props changed)
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/hello_world/
- copied from r41131, /sandbox/SOC/2007/cgi/branches/cgi_work/libs/cgi/example/acgi/hello_world/
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/hello_world/Jamfile.v2
- copied, changed from r41244, /sandbox/SOC/2007/cgi/branches/cgi_work/libs/cgi/example/acgi/hello_world/Jamfile.v2
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/hello_world/main.cpp
- copied, changed from r41244, /sandbox/SOC/2007/cgi/branches/cgi_work/libs/cgi/example/acgi/hello_world/main.cpp
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/login/
- copied from r41131, /sandbox/SOC/2007/cgi/branches/cgi_work/libs/cgi/example/acgi/login/
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/login/CheckCookie.cpp
- copied unchanged from r41244, /sandbox/SOC/2007/cgi/branches/cgi_work/libs/cgi/example/acgi/login/CheckCookie.cpp
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/login/Jamfile.v2 (contents, props changed)
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/login/Login.cpp
- copied, changed from r41244, /sandbox/SOC/2007/cgi/branches/cgi_work/libs/cgi/example/acgi/login/Login.cpp
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/login/Logout.cpp
- copied unchanged from r41244, /sandbox/SOC/2007/cgi/branches/cgi_work/libs/cgi/example/acgi/login/Logout.cpp
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/
- copied from r41171, /sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/scgi/hello_world/
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/hello_world/
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/hello_world/Jamfile.v2
- copied, changed from r41171, /sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/scgi/hello_world/Jamfile.v2
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/scgi/hello_world/main.cpp (contents, props changed)
Removed:
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/Jamfile.v2
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/main.cpp
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/Jamfile.v2
Properties modified:
sandbox/SOC/2007/cgi/branches/acceptor_work/ (props changed)
Text files modified:
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/acgi.hpp | 7 +++++
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_client.hpp | 15 ++++++++++
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_request_acceptor.hpp | 51 ++++++++++++++++++++++++++++++------
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/cgi.hpp | 7 +++++
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/connections/tcp_socket.hpp | 14 +++++++--
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/detail/protocol_traits.hpp | 27 ++++++++++++-------
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi.hpp | 7 +++++
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/request_service.hpp | 2
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/response.hpp | 16 ++++++++---
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/scgi.hpp | 7 +++++
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/scgi/acceptor_service_impl.hpp | 50 +++++++++++++++++++++++++++++------
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/scgi/client.hpp | 5 ++-
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/scgi/request.hpp | 3 +
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/scgi/request_acceptor_service.hpp | 28 ++++++++++++++++++--
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/scgi/request_service.hpp | 13 ++++++++-
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/Jamfile.v2 | 21 +++++---------
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/cookie_game/Jamfile.v2 | 35 +++++++++++++-----------
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/cookie_game/main.cpp | 55 +++++++++++++++++++++------------------
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/hello_world/Jamfile.v2 | 12 +++++---
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/hello_world/main.cpp | 4 +-
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/login/Login.cpp | 12 +++++---
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/hello_world/Jamfile.v2 | 12 +++++---
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/scgi/hello_world/Jamfile.v2 | 3 +
23 files changed, 287 insertions(+), 119 deletions(-)
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/acgi.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/acgi.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/acgi.hpp 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -34,4 +34,11 @@
} // namespace acgi
} // namespace cgi
+/// Dump acgi stuff into the boost namespace
+namespace boost {
+ namespace acgi {
+ using namespace ::cgi::acgi;
+ } // namespace acgi
+} // namespace boost
+
#endif // CGI_ACGI_HPP_INCLUDED__
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_client.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_client.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_client.hpp 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -65,6 +65,18 @@
connection_->close();
}
+ /// Associate a connection with this client
+ /**
+ * Note: the connection must have been created using the new operator
+ *
+ bool set_connection(connection_type* conn)
+ {
+ // make sure there isn't already a connection associated with the client
+ if (!connection_) return false;
+ connection_.reset(conn);
+ return true;
+ }*/
+
//io_service& io_service() { return io_service_; }
/// Associate a connection with this client
@@ -74,7 +86,8 @@
bool set_connection(typename connection_type::pointer& conn)
{
// make sure there isn't already a connection associated with the client
- if (!connection_) return false;
+ //if (!connection_) return false;
+ BOOST_ASSERT(conn != NULL);
connection_ = conn;
return true;
}
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_request_acceptor.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_request_acceptor.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_request_acceptor.hpp 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -13,6 +13,7 @@
#include <boost/system/error_code.hpp>
#include <boost/asio/basic_io_object.hpp>
+#include <boost/asio/ip/basic_endpoint.hpp>
#include "boost/cgi/detail/throw_error.hpp"
namespace cgi {
@@ -25,25 +26,57 @@
{
public:
// typedef impl_type;
- typedef RequestAcceptorService service_type;
- typedef typename service_type::protocol_type protocol_type;
- typedef int port_number_type;
+ typedef RequestAcceptorService service_type;
+ typedef typename service_type::protocol_type protocol_type;
+ typedef unsigned short port_number_type;
template<typename IoServiceProvider>
- explicit basic_request_acceptor(basic_protocol_service<
- protocol_type, IoServiceProvider>& ps)
+ explicit basic_request_acceptor(
+ basic_protocol_service<protocol_type, IoServiceProvider>& ps)
: boost::asio::basic_io_object<RequestAcceptorService>(ps.io_service())
{
this->service.set_protocol_service(this->implementation, ps);
}
template<typename IoServiceProvider>
- explicit basic_request_acceptor(basic_protocol_service<
- protocol_type, IoServiceProvider>& ps
- , port_number_type port_num)
+ explicit basic_request_acceptor(
+ basic_protocol_service<protocol_type, IoServiceProvider>& ps,
+ port_number_type port_num)
: boost::asio::basic_io_object<RequestAcceptorService>(ps.io_service())
{
this->service.set_protocol_service(this->implementation, ps);
+
+ using boost::asio::ip::tcp;
+ // This strange-looking conditional checks there's no error at each
+ // stage of preparation.
+ boost::system::error_code ec;
+ if (this->service.open(this->implementation, tcp::v4(), ec)
+ || this->service.bind(this->implementation
+ , tcp::endpoint(tcp::v4(), port_num), ec)
+ || this->service.listen(this->implementation, ec))
+ {
+ detail::throw_error(ec);
+ }
+ }
+
+ template<typename IoServiceProvider, typename InternetProtocol>
+ explicit basic_request_acceptor(
+ basic_protocol_service<protocol_type, IoServiceProvider>& ps,
+ const boost::asio::ip::basic_endpoint<InternetProtocol>& endpoint,
+ bool reuse_addr = true)
+ : boost::asio::basic_io_object<RequestAcceptorService>(ps.io_service())
+ {
+ this->service.set_protocol_service(this->implementation, ps);
+
+ // This strange-looking conditional checks there's no error at each
+ // stage of preparation.
+ boost::system::error_code ec;
+ if (this->service.open(this->implementation, endpoint.protocol(), ec)
+ || this->service.bind(this->implementation, endpoint, ec)
+ || this->service.listen(this->implementation, ec))
+ {
+ detail::throw_error(ec);
+ }
}
~basic_request_acceptor()
@@ -106,7 +139,7 @@
/// Accept one request
template<typename CommonGatewayRequest>
- boost::system::error_code&
+ boost::system::error_code
accept(CommonGatewayRequest& request, boost::system::error_code& ec)
{
return this->service.accept(this->implementation, request, ec);
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/cgi.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/cgi.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/cgi.hpp 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -23,4 +23,11 @@
} // namespace cgi
+/// Dump acgi stuff into the boost namespace
+namespace boost {
+ namespace cgi {
+ using namespace ::cgi::cgi;
+ } // namespace acgi
+} // namespace boost
+
#endif // CGI_CGI_HPP_INCLUDED__
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/connections/tcp_socket.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/connections/tcp_socket.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/connections/tcp_socket.hpp 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -24,8 +24,9 @@
: public connection_base
{
public:
- typedef boost::shared_ptr<basic_connection<tags::tcp_socket> >
- pointer;
+ typedef basic_connection<tags::tcp_socket> type;
+ typedef boost::shared_ptr<type> pointer;
+ typedef boost::asio::ip::tcp::socket next_layer_type;
basic_connection(io_service& ios)
: sock_(ios)
@@ -44,7 +45,7 @@
static pointer create(io_service& ios)
{
- return static_cast<pointer>(new basic_connection<tags::tcp_socket>(ios));
+ return pointer(new basic_connection<tags::tcp_socket>(ios));
}
template<typename MutableBufferSequence>
@@ -84,8 +85,13 @@
{
sock_.async_write_some(buf, handler);
}
+
+ next_layer_type& next_layer()
+ {
+ return sock_;
+ }
private:
- boost::asio::ip::tcp::socket sock_;
+ next_layer_type sock_;
};
typedef basic_connection<tags::tcp_socket> tcp_connection;
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/detail/protocol_traits.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/detail/protocol_traits.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/detail/protocol_traits.hpp 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -6,6 +6,13 @@
// http://www.boost.org/LICENSE_1_0.txt)
//
////////////////////////////////////////////////////////////////
+//
+// Wow this is messy. It's not expected to last though; it's
+// merely here to make things more separated than they need to
+// be, so everything can be meshed together slowly.
+// (or something like that)
+//
+/////////////////////////////////////////////////////////////////
#ifndef CGI_REQUEST_TRAITS_HPP_INCLUDED__
#define CGI_REQUEST_TRAITS_HPP_INCLUDED__
@@ -72,9 +79,9 @@
{
typedef protocol_traits<tags::cgi> type;
typedef cgi_request_impl impl_type;
- typedef cgi_request_service request_service_type;
+ typedef cgi_request_service request_service_impl;
typedef basic_protocol_service<tags::cgi> protocol_service_type;
- typedef basic_request<request_service_type, protocol_service_type>
+ typedef basic_request<request_service_impl, protocol_service_type>
request_type;
typedef cgi_service_impl service_impl_type;
typedef basic_connection<tags::stdio> connection_type;
@@ -87,9 +94,9 @@
{
typedef protocol_traits<tags::async_cgi> type;
typedef async_cgi_request_impl impl_type;
- typedef acgi_request_service request_service_type;
+ typedef acgi_request_service request_service_impl;
typedef basic_protocol_service<tags::acgi> protocol_service_type;
- typedef basic_request<request_service_type, protocol_service_type>
+ typedef basic_request<request_service_impl, protocol_service_type>
request_type;
typedef async_cgi_service_impl service_impl_type;
typedef basic_connection<tags::async_stdio> connection_type;
@@ -103,9 +110,9 @@
{
typedef protocol_traits<tags::acgi> type;
typedef acgi_request_impl impl_type;
- typedef acgi_request_service request_service_type;
+ typedef acgi_request_service request_service_impl;
typedef basic_protocol_service<tags::acgi> protocol_service_type;
- typedef basic_request<request_service_type, protocol_service_type>
+ typedef basic_request<request_service_impl, protocol_service_type>
request_type;
typedef acgi_service_impl service_impl_type;
typedef basic_connection<tags::async_stdio> connection_type;
@@ -118,9 +125,9 @@
{
typedef protocol_traits<tags::fcgi> type;
typedef fcgi_request_impl impl_type;
- typedef fcgi_request_service request_service_type;
+ typedef fcgi_request_service request_service_impl;
typedef basic_protocol_service<tags::fcgi> protocol_service_type;
- typedef basic_request<request_service_type, protocol_service_type>
+ typedef basic_request<request_service_impl, protocol_service_type>
request_type;
typedef fcgi_service_impl service_impl_type;
typedef basic_connection<tags::tcp_socket> connection_type;
@@ -133,9 +140,9 @@
{
typedef protocol_traits<tags::scgi> type;
typedef scgi::scgi_request_impl impl_type;
- typedef scgi::scgi_request_service request_service_type;
+ typedef scgi::scgi_request_service request_service_impl;
typedef basic_protocol_service<tags::scgi> protocol_service_type;
- typedef basic_request<request_service_type, protocol_service_type>
+ typedef basic_request<request_service_impl, protocol_service_type>
request_type;
typedef scgi::scgi_service_impl service_impl_type;
typedef scgi::scgi_acceptor_service acceptor_service_impl;
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi.hpp 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -11,4 +11,11 @@
// #include all fcgi-related files only
+/// Dump acgi stuff into the boost namespace
+namespace boost {
+ namespace fcgi {
+ using namespace ::cgi::fcgi;
+ } // namespace acgi
+} // namespace boost
+
#endif // CGI_FCGI_HPP_INCLUDED__
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/request_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/request_service.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/request_service.hpp 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -35,7 +35,7 @@
: public detail::service_base<request_service<Protocol> >
{
// The platform-specific implementation (only one for now)
- typedef typename detail::protocol_traits<Protocol>::service_impl_type
+ typedef typename detail::protocol_traits<Protocol>::request_service_impl
service_impl_type;
public:
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/response.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/response.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/response.hpp 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -361,6 +361,10 @@
//response& operator<< (response& r1, response& r2)
//{
// r1.
+ bool headers_terminated() const
+ {
+ return headers_terminated_;
+ }
protected:
// Vector of all the headers, each followed by a CRLF
std::vector<std::string> headers_;
@@ -406,7 +410,7 @@
* no further headers are added to the response. It has no other side-
* effects; for instance, it won't write any data to the client.
* ]
- */
+ * /
template<typename T>
response& operator<<(response& resp, const ::cgi::basic_header<std::basic_string<T> >& hdr)
{
@@ -419,9 +423,10 @@
resp.set_header(hdr.content);
return resp;
}
- }
- template<typename StringT>
- response& operator<<(response& resp, const ::cgi::basic_header<StringT>& hdr)
+ }*/
+
+ template<>
+ response& operator<<(response& resp, const ::cgi::header& hdr)
{
if (hdr.content.empty()) {
resp.headers_terminated_ = true;
@@ -446,8 +451,9 @@
* library.
*/
template<typename T>
- response& operator<<(response& resp, typename basic_cookie<T> ck)
+ response& operator<<(response& resp, basic_cookie<T> ck)
{
+ BOOST_ASSERT(!resp.headers_terminated());
resp.set_header("Set-cookie", ck.to_string());
return resp;
}
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/scgi.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/scgi.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/scgi.hpp 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -28,4 +28,11 @@
} // namespace cgi
*/
+/// Dump acgi stuff into the boost namespace
+namespace boost {
+ namespace scgi {
+ using namespace ::cgi::scgi;
+ } // namespace acgi
+} // namespace boost
+
#endif // CGI_SCGI_HPP_INCLUDED__
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/scgi/acceptor_service_impl.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/scgi/acceptor_service_impl.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/scgi/acceptor_service_impl.hpp 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -47,7 +47,7 @@
*/
template<typename Protocol = ::cgi::scgi_>
class acceptor_service_impl
- : public detail::service_base<request_service<Protocol> >
+ : public detail::service_base<acceptor_service_impl<Protocol> >
{
public:
@@ -83,7 +83,7 @@
//typedef typename acceptor_service_type::native_type native_type;
explicit acceptor_service_impl(::cgi::io_service& ios)
- : detail::service_base<request_service<Protocol> >(ios)
+ : detail::service_base<acceptor_service_impl<Protocol> >(ios)
, acceptor_service_(boost::asio::use_service<acceptor_service_type>(ios))
{
}
@@ -133,22 +133,49 @@
return acceptor_service_.open(impl.acceptor_, protocol, ec);
}
+ template<typename Endpoint>
+ boost::system::error_code
+ bind(implementation_type& impl, Endpoint& endpoint
+ , boost::system::error_code& ec)
+ {
+ acceptor_service_.set_option(impl.acceptor_,
+ boost::asio::socket_base::reuse_address(true), ec);
+ return acceptor_service_.bind(impl.acceptor_, endpoint, ec);
+ }
+
/// Assign an existing native acceptor to a *socket* acceptor.
boost::system::error_code
assign(implementation_type& impl, const native_protocol_type& protocol
, const native_type& native_acceptor
, boost::system::error_code& ec)
{
- return acceptor_service_.assign(impl.acceptor_, protocol, native_acceptor
- , ec);
+ return acceptor_service_.assign(impl.acceptor_, protocol
+ , native_acceptor, ec);
}
+ boost::system::error_code
+ listen(implementation_type& impl, boost::system::error_code& ec)
+ {
+ return acceptor_service_.listen(impl.acceptor_,
+ boost::asio::socket_base::max_connections, ec);
+ }
+
/// Accepts one request.
template<typename CommonGatewayRequest>
boost::system::error_code
accept(implementation_type& impl, CommonGatewayRequest& request
, boost::system::error_code& ec)
{
+ /* THIS BIT IS BROKEN:
+ *-- The noncopyable semantics of a basic_request<> don't allow the
+ assignment. There are a couple of ways around this; the one that
+ seems sensible is to keep the basic_request<>s noncopyable, but
+ allow the actual data be copied. At the moment the actual data is
+ held in a vector<string> headers container and a cgi::streambuf.
+ These two bits should really be factored out into a message type.
+ IOW, the message type will be copyable (but should probably have
+ unique-ownership semantics).
+ --*
{
boost::mutex::scoped_lock lk(impl.mutex_);
if (!impl.waiting_requests_.empty())
@@ -158,7 +185,9 @@
return ec;
}
}
- return impl.acceptor_.accept(request.client().connection(), ec);
+ */
+ return acceptor_service_.accept(impl.acceptor_,
+ request.client().connection()->next_layer(), 0, ec);
}
/// Asynchronously accepts one request.
@@ -167,8 +196,9 @@
, Handler handler, boost::system::error_code& ec)
{
this->io_service().post(
- boost::bind(&scgi_request_acceptor_service::check_for_waiting_request
- , boost::ref(impl), boost::ref(request), handler, ec));
+ boost::bind(
+ &acceptor_service_impl<protocol_type>::check_for_waiting_request,
+ boost::ref(impl), boost::ref(request), handler, ec));
}
private:
template<typename CommonGatewayRequest, typename Handler>
@@ -176,6 +206,7 @@
, CommonGatewayRequest& request
, Handler handler)
{
+ /*
{
boost::mutex::scoped_lock lk(impl.mutex_);
if (!impl.waiting_requests_.empty())
@@ -185,8 +216,9 @@
return handler(ec); // this could be `io_service::post`ed again
}
}
- return accceptor_service_.async_accept(request.client().connection()
- , handler);
+ */
+ return accceptor_service_.async_accept(
+ request.client().connection()->next_layer(), handler);
}
private:
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/scgi/client.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/scgi/client.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/scgi/client.hpp 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -9,10 +9,11 @@
#ifndef CGI_SCGI_CLIENT_HPP_INCLUDED__
#define CGI_SCGI_CLIENT_HPP_INCLUDED__
+#include <boost/shared_ptr.hpp>
#include "boost/cgi/map.hpp"
#include "boost/cgi/io_service.hpp"
#include "boost/cgi/basic_client.hpp"
-
+#error BOOST_HAS_RVALUE_REFS
namespace cgi {
namespace scgi {
@@ -66,7 +67,7 @@
{
// make sure there isn't already a connection associated with the client
if (!connection_) return false;
- connection_ = conn;
+ connection_.reset(conn);
return true;
}
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/scgi/request.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/scgi/request.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/scgi/request.hpp 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -11,7 +11,7 @@
#include "boost/cgi/tags.hpp"
#include "boost/cgi/basic_request_fwd.hpp"
-#include "boost/cgi/request_service_fwd.hpp"
+//#include "boost/cgi/request_service_fwd.hpp"
#include "boost/cgi/scgi/request_service.hpp"
#include "boost/cgi/scgi/service.hpp"
namespace cgi {
@@ -27,6 +27,7 @@
} // namespace scgi
} // namespace cgi
+//#include "boost/cgi/request_service.hpp"
#include "boost/cgi/basic_request.hpp"
#endif // CGI_SCGI_REQUEST_HPP_INCLUDED__
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/scgi/request_acceptor_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/scgi/request_acceptor_service.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/scgi/request_acceptor_service.hpp 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -33,7 +33,7 @@
*/
template<typename Protocol = scgi_>
class scgi_request_acceptor_service
- : public detail::service_base<request_service<Protocol> >
+ : public detail::service_base<scgi_request_acceptor_service<Protocol> >
{
public:
//typedef typename service_impl_type::impl_type impl_type;
@@ -47,7 +47,7 @@
//static boost::asio::io_service::id id;
scgi_request_acceptor_service(::cgi::io_service& ios)
- : detail::service_base<request_service<Protocol> >(ios)
+ : detail::service_base<scgi_request_acceptor_service<Protocol> >(ios)
, service_impl_(ios)
{
}
@@ -77,8 +77,30 @@
return service_impl_.close(impl);
}
+ template<typename Protocol>
+ boost::system::error_code
+ open(implementation_type& impl, Protocol& protocol
+ , boost::system::error_code& ec)
+ {
+ return service_impl_.open(impl, protocol, ec);
+ }
+
+ template<typename Endpoint>
+ boost::system::error_code
+ bind(implementation_type& impl, Endpoint& endpoint
+ , boost::system::error_code& ec)
+ {
+ return service_impl_.bind(impl, endpoint, ec);
+ }
+
+ boost::system::error_code
+ listen(implementation_type& impl, boost::system::error_code& ec)
+ {
+ return service_impl_.listen(impl, ec);
+ }
+
template<typename CommonGatewayRequest>
- boost::system::error_code&
+ boost::system::error_code
accept(implementation_type& impl, CommonGatewayRequest& request
, boost::system::error_code& ec)
{
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/scgi/request_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/scgi/request_service.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/scgi/request_service.hpp 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -71,7 +71,6 @@
scgi_request_service(::cgi::io_service& ios)
: detail::service_base<scgi_request_service>(ios)
- //, io_service_(ios)
{
}
@@ -81,9 +80,11 @@
void construct(implementation_type& impl)
{
- impl.client_.set_connection(
+ std::cerr<< "Creating connection" << std::endl;
+ impl.client_.set_connection(//new implementation_type::connection_type(this->io_service()));
implementation_type::connection_type::create(this->io_service())
);
+ std::cerr<< "conn.is_open() == " << impl.client_.is_open() << std::endl;
}
void destroy(implementation_type& impl)
@@ -135,6 +136,7 @@
*/ return ec;
}
+ /* These Don't Belong Here.
template<typename MutableBufferSequence>
std::size_t read_some(implementation_type& impl
, const MutableBufferSequence& buf
@@ -153,6 +155,7 @@
}
//template<typename VarType> map_type& var(implementation_type&) const;
+ ********************************************/
std::string GET(implementation_type& impl, const std::string& name
, boost::system::error_code& ec)
@@ -222,6 +225,12 @@
return responder;
}
+ implementation_type::client_type&
+ client(implementation_type& impl)
+ {
+ return impl.client_;
+ }
+
protected:
/// Extract the var value from
std::string var(map_type& _data, const std::string& _name
Added: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/doc/src/library_organisation.qbk
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/doc/src/library_organisation.qbk 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -0,0 +1,24 @@
+
+[section Library Organisation]
+
+* All of the library's header files are in the directory `BOOST_ROOT/boost/cgi/`.
+
+* There are some convenience headers included to make your life easier:
+ * `BOOST_ROOT/boost/cgi.hpp` - includes ['all] headers related to this library.
+ * `BOOST_ROOT/boost/cgi/cgi.hpp` - includes CGI-specific headers, plus common headers.
+ * `BOOST_ROOT/boost/cgi/scgi.hpp` - includes SCGI-specific headers, plus common headers.
+ * `BOOST_ROOT/boost/cgi/fcgi.hpp` - includes FastCGI-specific headers, plus common headers.
+
+* CGI-specific bits are kept in the `BOOST_ROOT/boost/cgi/cgi/` directory. The same applies for the other protocols (eg. FastCGI -> `BOOST_ROOT/boost/cgi/fcgi/`).
+
+* Three namespaces are dumped into the `boost` namespace, these are:
+ * `boost::cgi`
+ * `boost::scgi`
+ * `boost::fcgi`
+
+[note
+Shared components and types live in the namespace `boost::cgi::common`, but are brought into the three namespaces above, where necessary and/or relevant. You should never have to use `boost::cgi::common::*` in your code; if you find you do, kindly [link __bugs__ report it] as a bug.
+]
+
+[endsect][/ library_organisation]
+
Added: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/doc/src/responses.qbk
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/doc/src/responses.qbk 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -0,0 +1,57 @@
+
+[section:responses Writing Responses]
+
+While you may sometimes want to respond to a request by writing directly back to the client, more often that not it is preferable to buffer your response. You can never tell how successful a request is going to be from the start(or when an exception is going to be throw), so being able to rewrite your response at any time is a requirement.
+
+The library provides the [classref cgi::response] class to make buffering your response simpler. Here is an example of using it:
+
+[section:example Short Example]
+
+[import __doxamples__/response_1.cpp]
+
+First, include the correct header.
+
+[includes]
+
+Then define your `response` object.
+
+[enter_main]
+
+Now we can write to `resp` like we would with any other output stream. Below you can see how you can stream [classref cgi::header] objects to the response, which are completely independent of the response body. After all, if we're going to buffer our reply, we may as well take advantage of it. As you can see, we can explicitly mark that no more headers can be added by streaming a default-constructed `header` object. This is useful if you have flushed the response (more on this later) and the header block has already been sent to the client.
+
+[stream_headers]
+
+If for any reason we need to get rid of the headers we have two options. One is `response::clear_headers()`, which simply deletes the current headers. This will assert if the headers have already been terminated. The alternative is `response::reset_headers()`, which indescriminately clears the headers and resets the 'terminated' toggle (__FIXME__ This could probably do with being a bit uglier, or at least providing a warning).
+
+[clear_headers]
+
+The file <boost/cgi/header.hpp> defines some helper classes so you can stream known types of header with the assurance that typos won't slip into a compiled program. A complete list of these can be found [link __FIXME__ here].
+
+[helper_types]
+
+You may also set headers directly. In the second call, we are using __boost_lexical_cast__ to cast the response content length into a string so it can be set in the header. If you're not familiar with `lexical_cast<>`, you should take a look at it.
+
+[set_headers_directly]
+
+Finally, we need to send the response somewhere. This can be done to any model of the __SyncReadStream__ concept. This could be anything from a IP/TCP socket, to a remote database, whatever you like. As noted, a request from this library is a special case, so you can just pass it directly, even though it doesn't deal with reading or writing itself.
+
+[sending]
+
+And that's most of what you need to know to get using the `response`. Check out the [classref cgi::response] for the rest.
+
+[endsect][/ example]
+
+[section:api `cgi::response` Interface]
+
+[variablelist Interface
+
+[
+
+]
+
+]
+
+[endsect][/ api]
+
+[endsect][/ responses]
+
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/Jamfile.v2 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -5,22 +5,17 @@
# at http://www.boost.org/LICENSE_1_0.txt)
-import os ;
-local BOOST_ROOT = [ os.environ BOOST_ROOT ] ;
-
-
-
-install examples
- : # the sources
- ecgi
- acgi
- #reply
- : <location>/var/www/cgi-bin
- ;
+#install examples
+# : # the sources
+# ecgi
+# acgi
+# #reply
+# : <location>/var/www/cgi-bin
+# ;
#install scgi
# : # the sources
# scgi
# : <location>/var/www/scgi-bin
-# ;
\ No newline at end of file
+# ;
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/Jamfile.v2 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
+++ (empty file)
@@ -1,34 +0,0 @@
-# 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)
-
-import os ;
-
-
-local BOOST_ROOT = [ os.environ BOOST_ROOT ] ;
-
-
-SOURCES = main ;
-
-exe acgi
- :
- $(SOURCES).cpp
- : requirements
- <include>$(BOOST_ROOT)
- <include>"../../../../"
- <library>../../util/system//boost_system
- #<library>libboost_system
- <define>BOOST_ALL_NO_LIB=1
- <toolset>gcc:<linkflags>-lpthread
- :
- ;
-
-# uncomment this if you want to test the example with your HTTP server
-#install _
-# : acgi
-# : # this is where the compiled executable is copied to
-# # ie. change this to your server's /cgi-bin/
-# <location>/var/www/cgi-bin
-# ;
Copied: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/cookie_game/Jamfile.v2 (from r41244, /sandbox/SOC/2007/cgi/branches/cgi_work/libs/cgi/example/acgi/cookie_game/Jamfile.v2)
==============================================================================
--- /sandbox/SOC/2007/cgi/branches/cgi_work/libs/cgi/example/acgi/cookie_game/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/cookie_game/Jamfile.v2 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -4,31 +4,34 @@
# (See accompanying file LICENSE_1_0.txt or copy
# at http://www.boost.org/LICENSE_1_0.txt)
-import os ;
-
-
-local BOOST_ROOT = [ os.environ BOOST_ROOT ] ;
-
+project boost.cgi.examples.acgi.cookie_game
+ : build-dir
+ $(PROJECT_ROOT)/bin.v2
+ ;
SOURCES = main ;
exe acgi
:
$(SOURCES).cpp
- : requirements
+ :
<include>$(BOOST_ROOT)
- <include>"../../../../"
- <library>../../util/system//boost_system
+ <include>$(PROJECT_ROOT)
+ #<library>../../util/system//boost_system
#<library>libboost_system
- <define>BOOST_ALL_NO_LIB=1
- <toolset>gcc:<linkflags>-lpthread
+ #<define>BOOST_ALL_NO_LIB=1
+ #<toolset>gcc:<linkflags>-lpthread
+ <define>_CRT_SECURE_NO_WARNINGS
+ <define>_SCL_SECURE_NO_WARNINGS
:
;
# uncomment this if you want to test the example with your HTTP server
-#install _
-# : acgi
-# : # this is where the compiled executable is copied to
-# # ie. change this to your server's /cgi-bin/
-# <location>/var/www/cgi-bin
-# ;
+install _
+ : acgi
+ : # this is where the compiled executable is copied to
+ # ie. change this to your server's /cgi-bin/
+ <location>.
+ ;
+
+explicit install ;
Copied: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/cookie_game/main.cpp (from r41244, /sandbox/SOC/2007/cgi/branches/cgi_work/libs/cgi/example/acgi/cookie_game/main.cpp)
==============================================================================
--- /sandbox/SOC/2007/cgi/branches/cgi_work/libs/cgi/example/acgi/cookie_game/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/cookie_game/main.cpp 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -2,11 +2,19 @@
#include <boost/cgi/response.hpp>
#include <iostream>
+#define SCRIPT_NAME "acgi_cookie_game"
+
+//
+// ISSUES:
+// Currently won't work sometimes because the request data checks aren't case-insensitive,
+// like they should be.
+//
+
// class handler
// {
// public:
-// handler(cgi::request_ostream& ros, cgi::acgi::request& req)
-// : ros_(ros)
+// handler(cgi::response& resp, boost::acgi::request& req)
+// : resp_(resp)
// , req_(req)
// {
// }
@@ -15,13 +23,13 @@
// {
// if (!ec)
// {
-// ros_<< "All ok";
-// ros_.flush(req_);
+// resp_<< "All ok";
+// resp_.flush(req_);
// }
// }
// private:
-// cgi::request_ostream& ros_;
-// cgi::acgi::request& req_;
+// cgi::response& resp_;
+// boost::acgi::request& req_;
// };
/**
@@ -32,7 +40,7 @@
int main()
{
- using namespace cgi::acgi;
+ using namespace boost::acgi;
service srv;
request req(srv);
@@ -42,58 +50,55 @@
response resp;
- if (req.get_("reset") == "true")
+ if (req.GET("reset") == "true")
{
resp<< cookie("name")
- << location("acgi")
- << content_type("text/plain")
- << header();
- resp.send(req);
+ << location(req.script_name())
+ << content_type("text/plain");
+ resp.send(req.client());
return 0;
}
// First, see if they have a cookie set
- std::string& name = req.cookie_()["name"];
+ std::string& name = req.cookie()["name"];
if (!name.empty())
{
resp<< header("Content-type", "text/html")
- << header() // terminate the headers
<< "Hello again " << name << "<p />"
<< "<a href='?reset=true'><input type='submit' value='Reset' /></a>";
- resp.send(req);
+ resp.send(req.client());
return 0;
}
// Now we'll check if they sent us a name in a form
- name = req.form_("name");
+ name = req.form("name");
if (!name.empty())
{
resp<< header("Content-type", "text/html")
<< cookie("name", name)
- << header() // terminate the headers
<< "Hello there, " << "<a href=''>" << name << "</a>";
- resp.send(req);
+ resp.send(req.client());
return 0;
}
//std::string buf("Content-type: text/html\r\n\r\nHello there, Universe.<br />");
//cgi::write(req, cgi::buffer(buf.c_str(), buf.size()));
- resp<< header("Content-type", "text/html")
- << header()
+ resp<< content_type("text/html")
<< "Hello there, Universe.<p />"
<< "What's your name?<br />";
- //std::cerr<< std::endl << "name = " << req.form_("name") << std::endl;
- //std::cerr.flush();
+ std::cerr<< std::endl << "name = " << req.POST("name") << std::endl;
+ std::cerr.flush();
resp<< "<form method='POST'>"
- "<input name='name' type='text' value='" << req.form_("name") << "'>"
+ "<input name='name' type='text' value='" << req.form("name") << "'>"
"</input>"
"<input type='submit'></input>"
- "</form>";
+ "</form>"
+ << "<p><b>SCRIPT_NAME</b> = <i>" << req.script_name() << "</i></p>";
- resp.send(req);
+ resp.send(req.client());
return 0;
}
Added: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/echo/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/echo/Jamfile.v2 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -0,0 +1,20 @@
+
+project boost.cgi.examples.acgi.echo
+ : build-dir
+ $(PROJECT_ROOT)/bin.v2
+ ;
+
+exe acgi_echo
+ : main.cpp
+ :
+ <include>$(PROJECT_ROOT)
+ <include>$(BOOST_ROOT)
+ <define>_CRT_SECURE_NO_WARNINGS
+ <define>_SCL_SECURE_NO_WARNINGS
+ ;
+
+install acgi_echo_install
+ : acgi_echo
+ : <location>.
+ <library>../../../util/system//boost_system
+ ;
Added: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/echo/main.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/echo/main.cpp 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -0,0 +1,35 @@
+#include <boost/cgi/acgi.hpp>
+
+using namespace std;
+using namespace boost::acgi;
+
+template<typename MapT, typename OStreamT>
+void show_map_contents(MapT& m, OStreamT& os, const std::string& title)
+{
+ os<< "<h3>" << title << "</h3>";
+ if (m.empty()) os<< "NONE<br />";
+ for (MapT::iterator i = m.begin(); i != m.end(); ++i)
+ {
+ os<< "<b>" << i->first << "</b> = <i>" << i->second << "</i><br />";
+ }
+}
+
+int main()
+{
+ service s;
+ request req(s);
+
+ req.load(true);
+
+ response resp;
+
+ show_map_contents(req.env(), resp, "Environment Variables");
+ show_map_contents(req.GET(), resp, "GET Variables");
+ show_map_contents(req.POST(), resp, "POST Variables");
+ show_map_contents(req.cookie(), resp, "Cookie Variables");
+
+ resp<< content_type("text/html");
+ resp.send(req.client());
+
+ return 0;
+}
Copied: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/hello_world/Jamfile.v2 (from r41244, /sandbox/SOC/2007/cgi/branches/cgi_work/libs/cgi/example/acgi/hello_world/Jamfile.v2)
==============================================================================
--- /sandbox/SOC/2007/cgi/branches/cgi_work/libs/cgi/example/acgi/hello_world/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/hello_world/Jamfile.v2 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -1,17 +1,19 @@
-#project
-# :
-# ;
+project boost.cgi.examples.acgi.hello_world
+ : build-dir
+ $(PROJECT_ROOT)/bin.v2
+ ;
exe acgi_hello_world
: main.cpp
- : <include>../../../../../
+ : <name>acgi_hw
+ <include>$(PROJECT_ROOT)
<include>$(BOOST_ROOT)
<define>_CRT_SECURE_NO_WARNINGS
<define>_SCL_SECURE_NO_WARNINGS
;
-install acgi_blah
+install acgi_hw_install
: acgi_hello_world
: <location>.
<library>../../../util/system//boost_system
Copied: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/hello_world/main.cpp (from r41244, /sandbox/SOC/2007/cgi/branches/cgi_work/libs/cgi/example/acgi/hello_world/main.cpp)
==============================================================================
--- /sandbox/SOC/2007/cgi/branches/cgi_work/libs/cgi/example/acgi/hello_world/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/hello_world/main.cpp 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -13,7 +13,7 @@
#include <boost/cgi/acgi.hpp>
using namespace std;
-using namespace cgi::acgi;
+using namespace boost::acgi;
int main()
{
@@ -27,4 +27,4 @@
resp.send(req.client());
return 0;
-}
\ No newline at end of file
+}
Added: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/login/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/login/Jamfile.v2 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -0,0 +1,32 @@
+
+project boost.cgi.examples.acgi.login
+ : build-dir
+ $(PROJECT_ROOT)/bin.v2
+ ;
+
+exe Login
+ : Login.cpp
+ : <include>$(PROJECT_ROOT)
+ <include>$(BOOST_ROOT)
+ ;
+
+exe Logout
+ : Logout.cpp
+ : <include>$(PROJECT_ROOT)
+ <include>$(BOOST_ROOT)
+ ;
+
+exe CheckCookie
+ : CheckCookie.cpp
+ : <include>$(PROJECT_ROOT)
+ <include>$(BOOST_ROOT)
+ ;
+
+install _
+ :
+ Login
+ Logout
+ CheckCookie
+ :
+ <location>c:/Apache/Apache2.2/cgi-bin/
+ ;
Copied: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/login/Login.cpp (from r41244, /sandbox/SOC/2007/cgi/branches/cgi_work/libs/cgi/example/acgi/login/Login.cpp)
==============================================================================
--- /sandbox/SOC/2007/cgi/branches/cgi_work/libs/cgi/example/acgi/login/Login.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/login/Login.cpp 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -1,7 +1,9 @@
#include <boost/cgi/acgi.hpp>
+#include <boost/regex.hpp>
+#include <boost/lexical_cast.hpp>
-using namespace cgi::acgi;
+using namespace boost::acgi;
int show_default_page(request& req, response& resp)
{
@@ -22,7 +24,7 @@
"</html>";
resp.send(req.client());
- return req.end(http::ok);
+ return req.close(http::ok);
}
void show_already_logged_in_page(request& req, response resp)
@@ -43,7 +45,7 @@
"</html>";
resp.send(req.client());
- return req.end(http::ok);
+ return req.close(http::ok);
}
int show_name_error_page(request& req, response& resp)
@@ -68,7 +70,7 @@
"</html>";
resp.send(req.client());
- return req.end(http::bad_request);
+ return req.close(http::bad_request);
}
int verify_name(std::string& name)
@@ -129,5 +131,5 @@
<< location("CheckCookie?fwd=" + req.POST("fwd"));
resp.send(req.client());
- return req.end(http::ok);
+ return req.close(http::ok);
}
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/main.cpp 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
+++ (empty file)
@@ -1,99 +0,0 @@
-#include <boost/cgi/acgi.hpp>
-#include <boost/cgi/response.hpp>
-#include <iostream>
-
-// class handler
-// {
-// public:
-// handler(cgi::request_ostream& ros, cgi::acgi::request& req)
-// : ros_(ros)
-// , req_(req)
-// {
-// }
-//
-// void operator()(boost::system::error_code& ec)
-// {
-// if (!ec)
-// {
-// ros_<< "All ok";
-// ros_.flush(req_);
-// }
-// }
-// private:
-// cgi::request_ostream& ros_;
-// cgi::acgi::request& req_;
-// };
-
-/**
- * The following example has a few simple stages.
- * It is best understood by compiling and testing it, and then looking at
- * the source code.
- */
-
-int main()
-{
- using namespace cgi::acgi;
-
- service srv;
- request req(srv);
-
- // Load up the request data
- req.load(true);
-
- response resp;
-
- if (req.get_("reset") == "true")
- {
- resp<< cookie("name")
- << location("acgi")
- << content_type("text/plain")
- << header();
- resp.send(req);
- return 0;
- }
-
- // First, see if they have a cookie set
- std::string& name = req.cookie_()["name"];
- if (!name.empty())
- {
- resp<< header("Content-type", "text/html")
- << header() // terminate the headers
- << "Hello again " << name << "<p />"
- << "<a href='?reset=true'><input type='submit' value='Reset' /></a>";
- resp.send(req);
- return 0;
- }
-
- // Now we'll check if they sent us a name in a form
- name = req.form_("name");
- if (!name.empty())
- {
- resp<< header("Content-type", "text/html")
- << cookie("name", name)
- << header() // terminate the headers
- << "Hello there, " << "<a href=''>" << name << "</a>";
- resp.send(req);
- return 0;
- }
-
- //std::string buf("Content-type: text/html\r\n\r\nHello there, Universe.<br />");
- //cgi::write(req, cgi::buffer(buf.c_str(), buf.size()));
-
- resp<< header("Content-type", "text/html")
- << header()
- << "Hello there, Universe.<p />"
- << "What's your name?<br />";
-
- //std::cerr<< std::endl << "name = " << req.form_("name") << std::endl;
- //std::cerr.flush();
-
- resp<< "<form method='POST'>"
- "<input name='name' type='text' value='" << req.form_("name") << "'>"
- "</input>"
- "<input type='submit'></input>"
- "</form>";
-
- resp.send(req);
-
- return 0;
-}
Deleted: /sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/scgi/hello_world/Jamfile.v2
==============================================================================
--- /sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/scgi/hello_world/Jamfile.v2 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
+++ (empty file)
@@ -1,23 +0,0 @@
-
-project cgi.examples.hello_world
- : build-dir
- $(PROJECT_ROOT)/bin.v2
- ;
-
-exe hw
- :
- main.cpp
- :
- <include>$(BOOST_ROOT)
- <include>$(PROJECT_ROOT)
- #<library>../../util/system//boost_system
- #<define>BOOST_ALL_NO_LIB=1
- <define>_CRT_SECURE_NO_WARNINGS
- <define>_SCL_SECURE_NO_WARNINGS
- ;
-
-install hw_i
- : hw
- : <location>$(BOOST_CGI_BIN_DIR)
- ;
-
Copied: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/hello_world/Jamfile.v2 (from r41171, /sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/scgi/hello_world/Jamfile.v2)
==============================================================================
--- /sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/scgi/hello_world/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/hello_world/Jamfile.v2 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -1,10 +1,10 @@
-project cgi.examples.hello_world
+project cgi.examples.fcgi.hello_world
: build-dir
$(PROJECT_ROOT)/bin.v2
;
-exe hw
+exe fast_hw
:
main.cpp
:
@@ -16,8 +16,10 @@
<define>_SCL_SECURE_NO_WARNINGS
;
-install hw_i
- : hw
- : <location>$(BOOST_CGI_BIN_DIR)
+install fast_hw_install
+ : fast_hw
+ : #<location>$(BOOST_CGI_BIN_DIR)
+ #<location>.
+ <location>C:/Apache/Apache2.2/fcgi-bin
;
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/scgi/hello_world/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/scgi/hello_world/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/scgi/hello_world/Jamfile.v2 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -18,6 +18,7 @@
install hw_i
: hw
- : <location>$(BOOST_CGI_BIN_DIR)
+ : #<location>$(BOOST_CGI_BIN_DIR)
+ <location>.
;
Added: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/scgi/hello_world/main.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/scgi/hello_world/main.cpp 2007-11-19 22:00:40 EST (Mon, 19 Nov 2007)
@@ -0,0 +1,43 @@
+#include <boost/cgi/scgi.hpp>
+#include <fstream>
+
+using namespace cgi::scgi;
+using namespace std;
+
+int main()
+{
+try {
+ ofstream of("C:/Logs/scgi_hello_world.txt");
+ if (!of) std::cerr<< "broken" << endl;
+ service s;
+ acceptor a(s, 9472);
+
+ request req(s);
+ boost::system::error_code ec;
+ a.accept(req, ec);
+ boost::asio::io_service ios;
+ using boost::asio::ip::tcp;
+ tcp::socket sock(ios);
+ if (ec) { of<< "hw accept error: " << ec.message() << endl; return 13; }
+ //cout<< "Hello there." << endl;
+
+ boost::asio::streambuf buf;
+ of<< "Start log:" << endl;
+
+ //for (;;)
+ {
+ size_t br = req.client().read_some(buf.prepare(64), ec);
+ of<< "Client wrote " << br << " bytes." << endl
+ << string(buf.data().begin(), buf.data().end()) << endl;
+ if (ec) { of<< "read error: " << ec.message() << endl; return 5; }
+ }
+
+ return 0;
+}catch(exception& e){
+ cerr<< "hw exception: " << e.what() << endl;
+ return 666;
+}catch(...){
+ cerr<< "hw uncaught exception!" << endl;
+ return 667;
+}
+}
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