|
Boost-Commit : |
From: lists.drrngrvy_at_[hidden]
Date: 2008-06-16 13:31:27
Author: drrngrvy
Date: 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
New Revision: 46430
URL: http://svn.boost.org/trac/boost/changeset/46430
Log:
* Merged current trunk using svnmerge.py
* Added proper asynchronous I/O support on POSIX systems (using trunk Boost.Asio features).
Added:
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/basic_protocol_service.hpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/basic_protocol_service.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/connection_base.hpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/connection_base.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/cookie.hpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/cookie.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/header.hpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/header.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/io_service_provider.hpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/io_service_provider.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/is_async.hpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/is_async.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/path_info.hpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/path_info.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/request_acceptor_service.hpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/request_acceptor_service.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/request_service.hpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/request_service.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/response.hpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/response.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/return.hpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/return.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/role_type.hpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/role_type.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/status_type.hpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/status_type.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/tags.hpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/tags.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/detail/basic_sync_io_object.hpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/basic_sync_io_object.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/detail/url_decode.ipp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/url_decode.ipp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fwd/
- copied from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/fwd/
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fwd/basic_connection_fwd.hpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/fwd/basic_connection_fwd.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fwd/basic_protocol_service_fwd.hpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/fwd/basic_protocol_service_fwd.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fwd/basic_request_acceptor_fwd.hpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/fwd/basic_request_acceptor_fwd.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fwd/basic_request_fwd.hpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/fwd/basic_request_fwd.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fwd/io_service_provider_fwd.hpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/fwd/io_service_provider_fwd.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fwd/request_service_fwd.hpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/fwd/request_service_fwd.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/impl/
- copied from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/impl/
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/impl/fcgi_request_service.ipp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/impl/fcgi_request_service.ipp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/impl/form_parser.ipp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/impl/form_parser.ipp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/impl/response.ipp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/impl/response.ipp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/import/
- copied from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/import/
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/import/basic_io_object.hpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/import/basic_io_object.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/import/buffer.hpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/import/buffer.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/import/io_service.hpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/import/io_service.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/import/read.hpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/import/read.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/import/streambuf.hpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/import/streambuf.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/import/write.hpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/boost/cgi/import/write.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/doc/src/troubleshooting.qbk
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/libs/cgi/doc/src/troubleshooting.qbk
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/ajax_echo/
- copied from r46095, /sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/ajax_echo/
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/xcgi/
- copied from r46095, /sandbox/SOC/2007/cgi/trunk/libs/cgi/example/xcgi/
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/xcgi/Jamfile.v2
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/libs/cgi/example/xcgi/Jamfile.v2
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/xcgi/basic/
- copied from r46095, /sandbox/SOC/2007/cgi/trunk/libs/cgi/example/xcgi/basic/
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/xcgi/basic/Jamfile.v2
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/libs/cgi/example/xcgi/basic/Jamfile.v2
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/xcgi/basic/doc.qbk
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/libs/cgi/example/xcgi/basic/doc.qbk
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/xcgi/basic/main.cpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/libs/cgi/example/xcgi/basic/main.cpp
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/xcgi/server1/
- copied from r46095, /sandbox/SOC/2007/cgi/trunk/libs/cgi/example/xcgi/server1/
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/xcgi/server1/Jamfile.v2
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/libs/cgi/example/xcgi/server1/Jamfile.v2
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/xcgi/server1/Server.hpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/libs/cgi/example/xcgi/server1/Server.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/xcgi/server1/doc.qbk
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/libs/cgi/example/xcgi/server1/doc.qbk
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/xcgi/server1/main.cpp
- copied unchanged from r46095, /sandbox/SOC/2007/cgi/trunk/libs/cgi/example/xcgi/server1/main.cpp
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/src/
- copied from r46095, /sandbox/SOC/2007/cgi/trunk/libs/cgi/src/
Removed:
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_client_fwd.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_connection_fwd.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_gateway.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_gateway_fwd.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_io_object.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_protocol_service.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_protocol_service_fwd.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_request_acceptor_fwd.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_request_fwd.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_sync_io_object.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/buffer.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/cgi/cgi_service.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/form_parser.ipp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/connection_base.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/cookie.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/header.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/io_service.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/io_service_provider.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/io_service_provider_fwd.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/is_async.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/map.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/read.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/request.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/request_acceptor_service.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/request_base.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/request_ostream.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/request_service.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/request_service_fwd.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/response.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/return.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/role_type.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/status_type.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/streambuf.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/tags.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/write.hpp
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/doc/src/user_guide/tutorial/step_one.qbk
Properties modified:
sandbox/SOC/2007/cgi/branches/acceptor_work/ (props changed)
Text files modified:
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi.hpp | 2
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/acgi.hpp | 11
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/acgi/request.hpp | 14
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/acgi/request_impl.hpp | 26 -
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/acgi/request_service.hpp | 31 +-
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/acgi/service.hpp | 24 -
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_client.hpp | 6
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_request.hpp | 390 +++++++++--------------------
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_request_acceptor.hpp | 17 +
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/cgi/request.hpp | 4
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/cgi/request_impl.hpp | 23
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/cgi/request_service.hpp | 11
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/cgi/service.hpp | 6
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/form_parser.hpp | 31 +
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/name.hpp | 34 +-
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/request_base.hpp | 76 +----
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/source_enums.hpp | 23 +
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/connections/async_stdio.hpp | 88 ++++++
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/connections/shareable_tcp_socket.hpp | 11
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/connections/stdio.hpp | 10
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/connections/tcp_socket.hpp | 8
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/detail/cgi_request_impl_base.hpp | 45 +-
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/detail/cgi_service_impl_base.hpp | 50 ++-
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/detail/common_headers.hpp | 29 +-
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/detail/protocol_traits.hpp | 87 ++++--
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/detail/push_options.hpp | 9
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/detail/url_decode.hpp | 80 -----
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/error.hpp | 5
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi.hpp | 2
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/acceptor_service_impl.hpp | 42 ++
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/client.hpp | 24
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/request.hpp | 7
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/request_acceptor_service.hpp | 28 +
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/request_service.hpp | 532 +++------------------------------------
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/service.hpp | 6
sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/http/status_code.hpp | 144 +++++-----
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/build/Jamfile.v2 | 52 +++
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/doc/src/cgi.qbk | 8
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/doc/src/reference.qbk | 54 +++
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/doc/src/user_guide.qbk | 2
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/doc/src/user_guide/tutorial/tutorial.qbk | 2
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/Jamfile.v2 | 12
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/amortization/main.cpp | 14
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/cookie_game/main.cpp | 13
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/echo/Jamfile.v2 | 4
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/echo/main.cpp | 53 ++-
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/hello_world/main.cpp | 1
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/login/CheckCookie.cpp | 6
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/login/Login.cpp | 20
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/login/Logout.cpp | 2
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/cgi/echo/Jamfile.v2 | 7
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/echo/main.cpp | 37 +
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/hello_world/main.cpp | 43 ++-
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/server1/main.cpp | 8
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/server2/main.cpp | 67 ++--
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/server3/main.cpp | 10
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/server4/main.cpp | 1
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/Jamfile.v2 | 5
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/is_async_test.cpp | 4
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/response.cpp | 2
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/acgi_simple_request.cpp | 2
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/cgi_simple_request.cpp | 1
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/cookie.cpp | 5
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/request_test_template.hpp | 16 +
sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/response.cpp | 2
sandbox/SOC/2007/cgi/branches/acceptor_work/project-root.jam | 62 +++
66 files changed, 1068 insertions(+), 1383 deletions(-)
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -14,6 +14,6 @@
#include "boost/cgi/cgi.hpp"
#include "boost/cgi/acgi.hpp"
#include "boost/cgi/fcgi.hpp"
-#include "boost/cgi/scgi.hpp"
+//#include "boost/cgi/scgi.hpp"
#endif // CGI_HPP_INCLUDED__
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 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -9,15 +9,8 @@
#ifndef CGI_ACGI_HPP_INCLUDED__
#define CGI_ACGI_HPP_INCLUDED__
-// #include all acgi-related headers only
#include "boost/cgi/acgi/service.hpp"
#include "boost/cgi/acgi/request.hpp"
-//#include "boost/cgi/acgi/request_service.hpp"
-//#include "boost/cgi/acgi/request_impl.hpp"
-//#include "gateway_impl/acgi_gateway_impl.hpp"
-//#include "gateway_service/acgi_gateway_service.hpp"
-
-// Include headers common to all protocols
#include "boost/cgi/detail/common_headers.hpp"
namespace cgi {
@@ -26,10 +19,6 @@
#endif
namespace acgi {
- typedef acgi_request request;
- //typedef acgi_service service;
- //typedef acgi_acceptor acceptor;
- using namespace ::cgi; // **FIXME** this line must go.
using namespace ::cgi::common; // import common namespace elements.
} // namespace acgi
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/acgi/request.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/acgi/request.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/acgi/request.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -9,23 +9,23 @@
#ifndef CGI_ACGI_REQUEST_HPP_INCLUDED__
#define CGI_ACGI_REQUEST_HPP_INCLUDED__
+#include "boost/cgi/detail/protocol_traits.hpp"
+#include "boost/cgi/common/tags.hpp"
#include "boost/cgi/acgi/service.hpp"
#include "boost/cgi/acgi/request_impl.hpp"
#include "boost/cgi/acgi/request_service.hpp"
-#include "boost/cgi/tags.hpp"
-#include "boost/cgi/basic_request_fwd.hpp"
-#include "boost/cgi/acgi/request_impl.hpp"
+#include "boost/cgi/fwd/basic_request_fwd.hpp"
namespace cgi {
-
- class acgi_request_service;
+ namespace acgi {
typedef
common::basic_request<
- acgi_request_service, acgi_service
+ acgi::request_service, acgi::service
>
- acgi_request;
+ request;
+ } // namespace acgi
} // namespace cgi
//namespace boost { namespace acgi {
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/acgi/request_impl.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/acgi/request_impl.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/acgi/request_impl.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -11,39 +11,37 @@
#include "boost/cgi/acgi/service.hpp"
#include "boost/cgi/basic_client.hpp"
-#include "boost/cgi/detail/cgi_request_impl_base.hpp"
+#include "boost/cgi/common/status_type.hpp"
#include "boost/cgi/connections/async_stdio.hpp"
+#include "boost/cgi/detail/cgi_request_impl_base.hpp"
// Make this ProtocolService-independent
namespace cgi {
+ namespace acgi {
- // Forward declaration
- class acgi_service_impl;
-
- class acgi_request_impl
- : public cgi_request_impl_base<common::async_stdio_connection>
+ class request_impl
+ : public detail::cgi_request_impl_base<common::async_stdio_connection>
{
public:
- typedef acgi_service protocol_service_type;
- typedef common::async_stdio_connection connection_type;
+ typedef ::cgi::acgi::service protocol_service_type;
+ typedef common::async_stdio_connection connection_type;
typedef
::cgi::common::basic_client<
- connection_type, tags::acgi
+ connection_type, common::tags::acgi
>
client_type;
- acgi_request_impl()
- : cgi_request_impl_base<connection_type>()
+ request_impl()
+ : detail::cgi_request_impl_base<connection_type>()
{
}
protocol_service_type* service_;
- protected:
- //acgi_request_impl(); // private default constructor
- friend class acgi_service_impl;
};
+ } // namespace acgi
} // namespace cgi
#endif // CGI_ASYNC_CGI_REQUEST_IMPL_HPP_INCLUDED__
+
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/acgi/request_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/acgi/request_service.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/acgi/request_service.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -9,33 +9,29 @@
#ifndef CGI_ACGI_SERVICE_IMPL_HPP_INCLUDED__
#define CGI_ACGI_SERVICE_IMPL_HPP_INCLUDED__
-#include "boost/cgi/acgi/request_impl.hpp"
-#include "boost/cgi/tags.hpp"
-#include "boost/cgi/io_service.hpp"
+#include "boost/cgi/common/tags.hpp"
#include "boost/cgi/common/map.hpp"
-#include "boost/cgi/detail/cgi_service_impl_base.hpp"
+#include "boost/cgi/acgi/request_impl.hpp"
+#include "boost/cgi/import/io_service.hpp"
#include "boost/cgi/detail/service_base.hpp"
#include "boost/cgi/detail/extract_params.hpp"
#include "boost/cgi/connections/async_stdio.hpp"
+#include "boost/cgi/detail/cgi_service_impl_base.hpp"
namespace cgi {
+ namespace acgi {
- //template<typename ProtocolService>
- class acgi_request_service
- //: public boost::asio::io_service::service
- : public cgi_service_impl_base<acgi_request_impl>
- , public detail::service_base<acgi_request_service>
+ class request_service
+ : public cgi_service_impl_base<acgi::request_impl>
+ , public detail::service_base<request_service>
{
public:
- typedef acgi_request_service type;
- typedef tags::acgi protocol_type;
- typedef acgi_service protocol_service_type;
-
- /// The unique service identifier
- // static boost::asio::io_service::id id;
+ typedef request_service type;
+ typedef common::tags::acgi protocol_type;
+ typedef acgi::service protocol_service_type;
- acgi_request_service(::cgi::io_service& ios)
- : detail::service_base<acgi_request_service>(ios)
+ request_service(common::io_service& ios)
+ : detail::service_base<request_service>(ios)
{
}
@@ -60,6 +56,7 @@
}
};
+ } // namespace acgi
} // namespace cgi
#endif // CGI_ASYNC_CGI_SERVICE_IMPL_HPP_INCLUDED__
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/acgi/service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/acgi/service.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/acgi/service.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -1,4 +1,4 @@
-// -- cgi_service.hpp --
+// -- acgi_service.hpp --
//
// Copyright (c) Darren Garvey 2007.
// Distributed under the Boost Software License, Version 1.0.
@@ -6,24 +6,17 @@
// http://www.boost.org/LICENSE_1_0.txt)
//
////////////////////////////////////////////////////////////////
-#ifndef CGI_CGI_SERVICE_HPP_INCLUDED__
-#define CGI_CGI_SERVICE_HPP_INCLUDED__
+#ifndef CGI_ACGI_SERVICE_HPP_INCLUDED__
+#define CGI_ACGI_SERVICE_HPP_INCLUDED__
-#include "boost/cgi/tags.hpp"
-//#include "boost/cgi/gateway_impl/acgi_gateway_impl.hpp"
-//#include "boost/cgi/gateway_service/acgi_gateway_service.hpp"
-#include "boost/cgi/basic_protocol_service_fwd.hpp"
+#include "boost/cgi/common/tags.hpp"
+#include "boost/cgi/fwd/basic_protocol_service_fwd.hpp"
namespace cgi {
/// typedef for typical usage
- /**
- * Works with both cgi_request and acgi_request.
- */
- typedef common::basic_protocol_service<tags::acgi> acgi_service;
-
namespace acgi {
- typedef common::basic_protocol_service<tags::acgi> service;
+ typedef common::basic_protocol_service<common::tags::acgi> service;
}
/// A service 'owned' by a single user-supplied io_service
@@ -46,6 +39,7 @@
} // namespace cgi
-#include "boost/cgi/basic_protocol_service.hpp"
+#include "boost/cgi/common/basic_protocol_service.hpp"
+
+#endif // CGI_ACGI_SERVICE_HPP_INCLUDED__
-#endif // CGI_CGI_SERVICE_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 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -10,11 +10,11 @@
#define CGI_BASIC_CLIENT_HPP_INCLUDED__
#include <boost/shared_ptr.hpp>
-
+///////////////////////////////////////////////////////////
#include "boost/cgi/common/map.hpp"
-#include "boost/cgi/role_type.hpp"
-#include "boost/cgi/status_type.hpp"
#include "boost/cgi/http/status_code.hpp"
+#include "boost/cgi/common/role_type.hpp"
+#include "boost/cgi/common/status_type.hpp"
#include "boost/cgi/connections/tcp_socket.hpp"
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_client_fwd.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_client_fwd.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,22 +0,0 @@
-// -- basic_client_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_CLIENT_FWD_HPP_INCLUDED__
-#define CGI_BASIC_CLIENT_FWD_HPP_INCLUDED__
-
-namespace cgi {
- namespace common {
-
- template<typename Connection, typename Protocol>
- class basic_client;
-
- } // namespace common
-} // namespace cgi
-
-#endif // CGI_BASIC_CLIENT_FWD_HPP_INCLUDED__
-
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_connection_fwd.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_connection_fwd.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,21 +0,0 @@
-// -- basic_connection_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_CONNECTION_FWD_HPP_INCLUDED__
-#define CGI_BASIC_CONNECTION_FWD_HPP_INCLUDED__
-
-namespace cgi {
- namespace common {
-
- template<typename ConnectionType>
- class basic_connection;
-
- } // namespace common
-} // namespace cgi
-
-#endif // CGI_BASIC_CONNECTION_FWD_HPP_INCLUDED__
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_gateway.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_gateway.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,192 +0,0 @@
-// -- 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.
- */
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_gateway_fwd.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_gateway_fwd.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,19 +0,0 @@
-// -- 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__
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_io_object.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_io_object.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,78 +0,0 @@
-// -- 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>
- class basic_io_object
- : private boost::noncopyable
- {
- public:
- typedef Service service_type;
-
- ::cgi::io_service&
- io_service()
- {
- return service.io_service();
- }
-
- private:
- typedef typename Service::implementation_type impl_type;
- typedef typename Service::implementation_type implementation_type;
-
- protected:
- explicit basic_io_object(::cgi::io_service& ios)
- : service(boost::asio::use_service<Service>(ios))
- {
- service.construct(implementation);
- }
-
- ~basic_io_object()
- {
- service.destroy(implementation);
- }
-
- implementation_type implementation;
- service_type& service;
- };
-
- /*
- template<>
- class basic_io_object< ::cgi::request>
- : 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;
- boost::asio::io_service io_service;
- };
- */
-
-} // namespace cgi
-
-#endif // CGI_BASIC_IO_OBJECT_HPP_INCLUDED__
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_protocol_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_protocol_service.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,152 +0,0 @@
-// -- basic_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_BASIC_PROTOCOL_SERVICE_HPP_INCLUDED__
-#define CGI_BASIC_PROTOCOL_SERVICE_HPP_INCLUDED__
-
-#include <set>
-#include <queue>
-#include <boost/shared_ptr.hpp>
-#include <boost/asio/strand.hpp>
-#include <boost/detail/workaround.hpp>
-
-#include "boost/cgi/io_service.hpp"
-#include "boost/cgi/io_service_provider.hpp"
-#include "boost/cgi/basic_request_fwd.hpp"
-#include "boost/cgi/detail/protocol_traits.hpp"
-#include "boost/cgi/basic_protocol_service_fwd.hpp"
-
-namespace cgi {
- namespace common {
-
- /// Basic Protocol Service
- /**
- * Holds the request queue and the connection queue.
- * It is also a wrapper around asio::io_service
- */
- template<typename Protocol, typename IoServiceProvider>
- class basic_protocol_service
- //: public protocol_traits<Protocol> // do this!
- {
- public:
- typedef Protocol protocol_type;
- typedef IoServiceProvider ios_provider_type;
- typedef typename detail::protocol_traits<Protocol>::type traits;
- typedef typename traits::request_type request_type;
- typedef typename boost::shared_ptr<request_type> request_ptr;
- typedef std::set<request_ptr> set_type;
- //typename boost::mpl::if_<
- // boost::is_same<protocol_type, tags::acgi>::value
- // , request_type::pointer
- // , std::set<request_type::pointer>
- // >::type
-
- typedef std::queue<request_ptr> queue_type;
-
- basic_protocol_service(int pool_size_hint = 1)
- : ios_provider_(pool_size_hint)
- //, strand_(ios_provider_.io_service())
- //, gateway_(*this)
- {
- }
-
- basic_protocol_service(boost::asio::io_service& ios)
- : ios_provider_(ios)
- //, strand_(ios)
- //, gateway_(*this)
- {
- }
-
- ~basic_protocol_service()
- {
- //gateway_.stop();
- }
-
- /// Run all the io_services contained by this service
- /**
- * This is equivalent to calling run() on each of the io_services held by
- * ios_provider_
- */
- void run()
- {
- ios_provider_.run();
- }
-
- /// Stop all the io_services contained by this service
- /**
- * This is equivalent to calling stop() on each of the io_services held by
- * ios_provider_
- */
- void stop()
- {
- //gateway_.stop();
- ios_provider_.stop();
- }
-
- /// Reset all the io_services contained by this service
- /**
- * This deletes the request queue(s), aborts all running requests and then
- * calls reset() on each of the io_services held by ios_provider_. There is
- * no guarantee that requests will terminate immediately.
- */
- void reset()
- {
- request_queue_.clear();
- //std::for_each(request_set_.begin(), request_set_.end()
- // , boost::bind(&request_type::abort, boost::arg<1>()));
- request_set_.clear();
- ios_provider_.reset();
- }
-
- /// Return an available io_service from the IoServiceProvider
- /**
- * The order in which the underlying io_services are returned is determined
- * by what policy the IoServiceProvider uses.
- */
- ::cgi::io_service& io_service()
- {
- return ios_provider_.get_io_service();
- }
-
- /// Post the handler through an available io_service
- template<typename Handler>
- void post(Handler handler)
- {
- ios_provider_.get_io_service().post(handler);
- }
-
- /// Dispatch a handler through an available io_service
- template<typename Handler>
- void dispatch(Handler handler)
- {
- ios_provider_.get_io_service().dispatch(handler);
- }
-
- private:
- ios_provider_type ios_provider_;
-
- /// A strand is used for guaranteeing handlers are dispatched sequentially
- //boost::asio::strand strand_;
-
- /// A std::set of all the requests.
- set_type request_set_;
- /// A std::queue of the waiting (ie. not-being-handled) requests.
- queue_type request_queue_;
-
-#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400))
- friend typename traits::request_type;//typename request_type;
-#else
- friend class traits::request_type;
-#endif
- //friend class request_type;
- };
-
- } // namespace common
-} // namespace cgi
-
-#endif // CGI_BASIC_PROTOCOL_SERVICE_HPP_INCLUDED__
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_protocol_service_fwd.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_protocol_service_fwd.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,30 +0,0 @@
-// -- basic_protocol_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_BASIC_PROTOCOL_SERVICE_FWD_HPP_INCLUDED__
-#define CGI_BASIC_PROTOCOL_SERVICE_FWD_HPP_INCLUDED__
-
-#if _MSC_VER > 1020
-#pragma once
-#endif
-
-#include "boost/cgi/io_service_provider.hpp"
-
-namespace cgi {
- namespace common {
-
- template<
- typename Protocol,
- typename IoServiceProvider = io_service_provider<>
- >
- class basic_protocol_service;
-
- } // namespace common
-} // namespace cgi
-
-#endif // CGI_BASIC_PROTOCOL_SERVICE_FWD_HPP_INCLUDED__
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_request.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_request.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_request.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -16,83 +16,75 @@
#include "boost/cgi/detail/push_options.hpp"
-#include <boost/noncopyable.hpp>
#include <boost/mpl/if.hpp>
#include <boost/assert.hpp>
-#include <boost/system/error_code.hpp>
#include <boost/shared_ptr.hpp>
+#include <boost/noncopyable.hpp>
#include <boost/asio/io_service.hpp>
+#include <boost/system/error_code.hpp>
#include <boost/asio/basic_io_object.hpp>
-
-#include "boost/cgi/detail/throw_error.hpp"
+///////////////////////////////////////////////////////////
+// **FIXME** Half of these are probably useless
#include "boost/cgi/detail/protocol_traits.hpp"
-#include "boost/cgi/request_base.hpp"
-#include "boost/cgi/role_type.hpp"
-#include "boost/cgi/common/source_enums.hpp"
-#include "boost/cgi/status_type.hpp"
-#include "boost/cgi/is_async.hpp"
-#include "boost/cgi/connection_base.hpp"
-#include "boost/cgi/http/status_code.hpp"
-#include "boost/cgi/request_service.hpp"
-#include "boost/cgi/basic_protocol_service_fwd.hpp"
-#include "boost/cgi/basic_request_fwd.hpp"
-#include "boost/cgi/basic_sync_io_object.hpp"
-#include "boost/cgi/basic_io_object.hpp"
#include "boost/cgi/common/map.hpp"
+#include "boost/cgi/common/is_async.hpp"
+#include "boost/cgi/common/role_type.hpp"
+#include "boost/cgi/http/status_code.hpp"
+#include "boost/cgi/detail/throw_error.hpp"
+#include "boost/cgi/common/status_type.hpp"
+#include "boost/cgi/common/source_enums.hpp"
+#include "boost/cgi/fwd/basic_request_fwd.hpp"
+#include "boost/cgi/common/request_service.hpp"
+#include "boost/cgi/import/basic_io_object.hpp"
+#include "boost/cgi/detail/basic_sync_io_object.hpp"
+#include "boost/cgi/fwd/basic_protocol_service_fwd.hpp"
namespace cgi {
namespace common {
/// The basic_request class, primary entry point to the library
/**
- * Note: This class is supposed to make simple use of the library easy.
- * This comes with some restrictions, such as being noncopyable, and also
- * providing copies of the meta-variables rather than references. This makes
- * sure the internal data is protected.
- * 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: By default, synchronous protocols (ie. cgi) auto-load AND parse STDIN,
- * whereas async protocols don't.
+ * Note: The alternative functions which take a boost::system::error_code are
+ * the non-throwing versions. Instead of a boost::system::system_error being
+ * thrown in case of an error, the passed error_code will be set to the value
+ * of the error, s.t. if (error) evaluates to true.`
*
* 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
- * protected request object)
- *
- * Note: From 10/07/07 this class is going to require a protocol_service be
- * passed to it. This is good for FastCGI/SCGI and asynchronous CGI. A full
- * specialisation of this class for sync CGI can be provided... The reasoning
- * for this is that the added complexity for allowing a non-async CGI request
- * to use the acceptor and this class doesn't seem worth it: it makes the
- * whole library much simpler to do it this way.
- */
+ * protected request object).
+ **/
template<typename RequestService
, typename ProtocolService
, role_type Role
, typename Allocator>
class basic_request
- : //public request_base
- public boost::mpl::if_c<is_async<typename RequestService::protocol_type>::value
- , basic_io_object<RequestService>
- , basic_sync_io_object<RequestService>
- >::type
+ : public boost::mpl::if_c<
+ is_async<typename RequestService::protocol_type>::type::value
+ , basic_io_object<RequestService>
+ , detail::basic_sync_io_object<RequestService>
+ >::type
{
public:
typedef basic_request<RequestService, ProtocolService
, Role, Allocator > type;
- typedef ::cgi::common::map map_type;
+ typedef ::cgi::common::map map_type;
typedef RequestService service_type;
typedef typename service_type::protocol_type protocol_type;
typedef ProtocolService protocol_service_type;
typedef boost::shared_ptr<type> pointer;
typedef typename RequestService::implementation_type implementation_type;
+ typedef typename implementation_type::char_type char_type;
+ typedef typename implementation_type::string_type string_type;
typedef typename implementation_type::client_type client_type;
// Throws
basic_request(bool load_now = true, bool parse_post = true)
- : basic_sync_io_object<service_type>()
+ : detail::basic_sync_io_object<service_type>()
{
if (load_now) load(parse_post);//this->service.load(this->implementation, true, ec);
}
@@ -101,7 +93,7 @@
basic_request(boost::system::error_code& ec
, const bool load_now = true
, const bool parse_post = true)
- : basic_sync_io_object<service_type>()
+ : detail::basic_sync_io_object<service_type>()
{
if (load_now) load(ec, parse_post);//this->service.load(this->implementation, true, ec);
}
@@ -126,6 +118,7 @@
}
/// Make a new mutiplexed request from an existing connection.
+ // Throws.
basic_request(implementation_type& impl)
: basic_io_object<service_type>(impl.service_->io_service())
{
@@ -137,6 +130,7 @@
}
/// Make a new mutiplexed request from an existing connection.
+ // Won't throw.
basic_request(implementation_type& impl, boost::system::error_code& ec)
: basic_io_object<service_type>(impl.service_->io_service())
{
@@ -212,17 +206,20 @@
*
* @returns The value of program_status
*/
- int close(http::status_code http_status = http::ok
+ int close(common::http::status_code http_status = http::ok
, int program_status = 0)
{
//BOOST_ASSERT( request_status_ != status_type::ended );
//this->service.set_status(this->implementation, http_status);
- return this->service.close(this->implementation, http_status
- , program_status);
+ boost::system::error_code ec;
+ this->service.close(this->implementation, http_status,
+ program_status, ec);
+ detail::throw_error(ec);
+ return program_status;
}
- int close(http::status_code http_status
+ int close(common::http::status_code http_status
, int program_status
, boost::system::error_code& ec)
{
@@ -290,252 +287,78 @@
}
*/
- /// Find the get meta-variable matching name
- /**
- * @throws `boost::system::system_error` if an error occurred. This may
- * fail with `cgi::error::request_aborted` if the request has been aborted
- * by the client.
- */
- std::string GET(const std::string& name)
+ /// Search through environment variables for the matching name
+ string_type var(string_type const& name, boost::system::error_code& ec)
{
- boost::system::error_code ec;
- std::string ret = this->service.GET(this->implementation, name, ec);
- detail::throw_error(ec);
- return ret;
+ return env_vars(this->implementation)[name.c_str()];
}
- /// Find the get meta-variable matching name
- /**
- * @param ec Set such that `(!ec == false)` if an error occurred. This may
- * fail with `ec == cgi::error::request_aborted` if the request has been
- * aborted by the client.
- */
- std::string GET(const std::string& name, boost::system::error_code& ec)
- {
- return this->service.GET(this->implementation, name, ec);
- }
-
- /// 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.
- *
- * @throws `boost::system::system_error` if an error occurred. This may
- * fail with `cgi::error::request_aborted` if the request has been aborted
- * by the client.
- */
- std::string POST(const std::string& name, bool greedy = true)
- {
- boost::system::error_code ec;
- std::string ret
- = this->service.POST(this->implementation, name, ec, greedy);
- detail::throw_error(ec);
- return ret;
- }
-
- /**
- * @param ec Set such that `(!ec == false)` if an error occurred. This may
- * fail with `ec == cgi::error::request_aborted` if the request has been
- * aborted by the client.
- */
- std::string POST(const std::string& name, boost::system::error_code& ec
- , bool greedy = true)
- {
- return this->service.POST(this->implementation, name, ec, greedy);
- }
-
- /// Find the form variable matching name
- /**
- * Depending on the request's request_method, either the GET or the POST
- * meta-variables are searched.
- *
- * @throws `boost::system::system_error` if an error occurred. This may
- * fail with `cgi::error::request_aborted` if the request has been aborted
- * by the client.
- */
- std::string form(const std::string& name, bool greedy = true)
+ string_type var(string_type const& name)
{
boost::system::error_code ec;
- std::string ret = form(name, ec, greedy);
+ string_type ret (var(name, ec));
detail::throw_error(ec);
return ret;
}
- /**
- * @param ec Set such that `(!ec == false)` if an error occurred. This may
- * fail with `ec == cgi::error::request_aborted` if the request has been
- * aborted by the client.
- */
- std::string form(const std::string& name, boost::system::error_code& ec
- , bool greedy = true)
- {
- std::string rm(request_method());
- if (rm == "GET")
- return this->service.GET(this->implementation, name, ec);
- else
- if (rm == "POST")
- return this->service.POST(this->implementation, name, ec, greedy);
- else
- return "";
- }
-
- /// Find the cookie meta-variable matching name
- /**
- * @throws `boost::system::system_error` if an error occurred. This may
- * fail with `cgi::error::request_aborted` if the request has been aborted
- * by the client.
- */
- std::string cookie(const std::string& name)
- {
- boost::system::error_code ec;
- std::string ret
- = this->service.cookie(this->implementation, name, ec);
- detail::throw_error(ec);
- return ret;
- }
-
- /// Find the cookie meta-variable matching name
- /**
- * @param ec Set such that `(!ec == false)` if an error occurred. This may
- * fail with `ec == cgi::error::request_aborted` if the request has been
- * aborted by the client.
- */
- std::string cookie(const std::string& name, boost::system::error_code& ec)
- {
- return this->service.cookie(this->implementation, name, ec);
- }
-
- /// Find the environment meta-variable matching name
- /**
- * @throws `boost::system::system_error` if an error occurred. This may
- * fail with `cgi::error::request_aborted` if the request has been aborted
- * by the client.
- */
- std::string env(const std::string& name)
- {
- boost::system::error_code ec;
- std::string ret = this->service.env(this->implementation, name, ec);
- detail::throw_error(ec);
- return ret;
- }
-
- /// Find the environment meta-variable matching name
- /**
- * @param ec Set such that `(!ec == false)` if an error occurred. This may
- * fail with `ec == cgi::error::request_aborted` if the request has been
- * aborted by the client.
- */
- std::string env(const std::string& name, boost::system::error_code& ec)
- {
- return this->service.env(this->implementation, name, ec);
- }
-
- /// Search through all meta vars for the meta-variable matching name
- /**
- * The policy w.r.t. POST data (ie. whether it should all
- * be read/parsed and included in this search or not) is
- * to be decided.
- *
- * Notes:
- * One option is to parse everything, making this option
- * very inefficient.
- * Another is to leave this function as a 'lazy' search:
- * it'll search with what it's got and no more. Then, also
- * provide a meta_var_all() function which is greedy; the
- * ugly/long name there to discourage use.
- */
- std::string var(std::string const& name, bool greedy = false)
- {
- boost::system::error_code ec;
- std::string ret = var(name, ec, greedy);
- return this->service.var(this->implementation, name, greedy);
- std::string request_method( env("REQUEST_METHOD") );
-
- std::string tmp;
-
- // If it's not a POST request search meta_get first (to save time)
- if (request_method.empty() || request_method == "GET")
- {
- tmp = GET(name);
- if (!tmp.empty())
- return tmp;
- }
-
- tmp = cookie(name);
- if (!tmp.empty())
- return tmp;
-
- tmp = env(name);
- if (!tmp.empty())
- return tmp;
-
- if (!request_method.empty() && request_method == "POST")
- {
- tmp = POST(name);
- if (!tmp.empty())
- return tmp;
- }
-
- tmp = GET(name);
- return tmp.empty() ? "" : tmp;
- }
-
// [helper-functions for the basic CGI 1.1 meta-variables.
- std::string auth_type()
- { return env("AUTH_TYPE"); }
+ string_type auth_type()
+ { return env_("AUTH_TYPE"); }
+
+ string_type content_length()
+ { return env_("CONTENT_LENGTH"); }
- std::string content_length()
- { return env("CONTENT_LENGTH"); }
+ string_type content_type()
+ { return env_("CONTENT_TYPE"); }
- std::string content_type()
- { return env("CONTENT_TYPE"); }
+ string_type gateway_interface()
+ { return env_("GATEWAY_INTERFACE"); }
- std::string gateway_interface()
- { return env("GATEWAY_INTERFACE"); }
+ string_type path_info()
+ { return env_("PATH_INFO"); }
- std::string path_info()
- { return env("PATH_INFO"); }
+ string_type path_translated()
+ { return env_("PATH_TRANSLATED"); }
- std::string path_translated()
- { return env("PATH_TRANSLATED"); }
+ string_type query_string()
+ { return env_("QUERY_STRING"); }
- std::string query_string()
- { return env("QUERY_STRING"); }
+ string_type remote_addr()
+ { return env_("REMOTE_ADDR"); }
- std::string remote_addr()
- { return env("REMOTE_ADDR"); }
+ string_type remote_host()
+ { return env_("REMOTE_HOST"); }
- std::string remote_host()
- { return env("REMOTE_HOST"); }
+ string_type remote_ident()
+ { return env_("REMOTE_IDENT"); }
- std::string remote_ident()
- { return env("REMOTE_IDENT"); }
+ string_type remote_user()
+ { return env_("REMOTE_USER"); }
- std::string remote_user()
- { return env("REMOTE_USER"); }
+ string_type request_method()
+ { return env_("REQUEST_METHOD"); }
- std::string request_method()
- { return env("REQUEST_METHOD"); }
+ string_type script_name()
+ { return env_("SCRIPT_NAME"); }
- std::string script_name()
- { return env("SCRIPT_NAME"); }
+ string_type server_name()
+ { return env_("SERVER_NAME"); }
- std::string server_name()
- { return env("SERVER_NAME"); }
+ string_type server_port()
+ { return env_("SERVER_PORT"); }
- std::string server_port()
- { return env("SERVER_PORT"); }
+ string_type server_protocol()
+ { return env_("SERVER_PROTOCOL"); }
- std::string server_protocol()
- { return env("SERVER_PROTOCOL"); }
+ string_type server_software()
+ { return env_("SERVER_SOFTWARE"); }
- std::string server_software()
- { return env("SERVER_SOFTWARE"); }
+ string_type referer()
+ { return env_("HTTP_REFERER"); }
// -- end helper-functions]
/// Get the charset from the CONTENT_TYPE header
- std::string charset()
+ string_type charset()
{
// Not sure if regex is needlessly heavy-weight here.
boost::regex re(";[ ]?charset=([-\\w]+);");
@@ -559,7 +382,7 @@
return this->service.get_role(this->implementation);
}
- void set_status(http::status_code const& status)
+ void set_status(common::http::status_code const& status)
{
this->service.set_status(this->implementation, status);
}
@@ -571,40 +394,60 @@
// compile-time (I hope) retrieval of different data
// maps.
//
+
+ // The first three overloads are for directly looking into the
+ // environment.
+ // eg.
+ // string_type& val = req["some name"];
+ string_type& operator[](string_type const& n)
+ {
+ return env_vars(this->implementation.vars_)[n.c_str()];
+ }
+
+ string_type& operator[](const char* n)
+ {
+ return env_vars(this->implementation.vars_)[n];
+ }
+
+ string_type& operator[](common::name const& n)
+ {
+ return env_vars(this->implementation.vars_)[n];
+ }
+
/// Get a `common::env_map&` of all the environment variables.
env_map& operator[](common::env_data_type const&)
{
- return this->implementation.env_vars();
+ return env_vars(this->implementation.vars_);
}
/// Get a `common::get_map&` of all the GET variables.
get_map& operator[](common::get_data_type const&)
{
- return this->implementation.get_vars();
+ return get_vars(this->implementation.vars_);
}
/// Get a `common::post_map&` of all the POST variables.
post_map& operator[](common::post_data_type const&)
{
- return this->implementation.post_vars();
+ return post_vars(this->implementation.vars_);
}
/// Get a `common::cookie_map&` of all the cookies.
cookie_map& operator[](common::cookie_data_type const&)
{
- return this->implementation.cookie_vars();
+ return cookie_vars(this->implementation.vars_);
}
/// Get a `common::form_map&` of either the GET or POST variables.
form_map& operator[](common::form_data_type const&)
{
if (request_method() == "GET")
- return this->implementation.get_vars();
+ return get_vars(this->implementation.vars_);
else
if (request_method() == "POST")
- return this->implementation.post_vars();
+ return post_vars(this->implementation.vars_);
else
- return this->implementation.env_vars();
+ return env_vars(this->implementation.vars_);
}
////////////////////////////////////////////////////////////
@@ -619,6 +462,13 @@
{
return this->service.request_id(this->implementation);
}
+
+ private:
+ // Internal shortcut for named env-var functions (eg. script_name() above).
+ string_type& env_(const char* name)
+ {
+ return env_vars(this->implementation.vars_)[name];
+ }
};
} // namespace common
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 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -10,13 +10,13 @@
#define CGI_BASIC_REQUEST_ACCEPTOR_HPP_INCLUDED__
#include <boost/noncopyable.hpp>
+#include <boost/asio/ip/tcp.hpp>
#include <boost/system/error_code.hpp>
-
#include <boost/asio/basic_io_object.hpp>
#include <boost/asio/ip/basic_endpoint.hpp>
-#include <boost/asio/ip/tcp.hpp>
-#include <boost/cgi/basic_protocol_service.hpp>
+///////////////////////////////////////////////////////////
#include "boost/cgi/detail/throw_error.hpp"
+#include "boost/cgi/common/basic_protocol_service.hpp"
namespace cgi {
namespace common {
@@ -278,6 +278,17 @@
{
return this->service.local_endpoint(this->implementation, ec);
}
+
+ native_type
+ native()
+ {
+ return this->service.native(this->implementation);
+ }
+
+ bool is_cgi()
+ {
+ return this->service.is_cgi(this->implementation);
+ }
};
} // namespace common
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_request_acceptor_fwd.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_request_acceptor_fwd.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,19 +0,0 @@
-// -- basic_acceptor_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_ACCEPTOR_FWD_HPP_INCLUDED__
-#define CGI_BASIC_ACCEPTOR_FWD_HPP_INCLUDED__
-
-namespace cgi {
-
- template<typename>
- class basic_acceptor;
-
-} // namespace cgi
-
-#endif // CGI_BASIC_ACCEPTOR_FWD_HPP_INCLUDED__
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_request_fwd.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_request_fwd.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,30 +0,0 @@
-// -- 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 {
- namespace common {
-
- template<typename RequestService
- , typename ProtocolService
- , enum role_type Role = responder
- , typename Allocator = std::allocator<char> >
- class basic_request;
-
- } // namespace common
-} // namespace cgi
-
-#endif // CGI_BASIC_REQUEST_FWD_HPP_INCLUDED__
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_sync_io_object.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/basic_sync_io_object.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,44 +0,0 @@
-// -- basic_sync_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_SYNC_IO_OBJECT_HPP_INCLUDED__
-#define CGI_BASIC_SYNC_IO_OBJECT_HPP_INCLUDED__
-
-#include <boost/noncopyable.hpp>
-
-namespace cgi {
- namespace common {
-
- /// basic_io_object alternative when an io_service isn't used
- template<typename Service>
- class basic_sync_io_object
- : private boost::noncopyable
- {
- public:
- typedef Service service_type;
- typedef typename Service::implementation_type implementation_type;
-
- protected:
- explicit basic_sync_io_object()
- {
- service.construct(implementation);
- }
-
- ~basic_sync_io_object()
- {
- service.destroy(implementation);
- }
-
- service_type service;
- implementation_type implementation;
- };
-
- } // namespace common
-} // namespace cgi
-
-#endif // CGI_BASIC_SYNC_IO_OBJECT_HPP_INCLUDED__
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/buffer.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/buffer.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,25 +0,0 @@
-// -- 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 {
- namespace common {
-
- using boost::asio::buffer;
-
- } // namespace common
-
- using common::buffer;
-
-} // namespace cgi
-
-#endif // CGI_HPP_INCLUDED__
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/cgi/cgi_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/cgi/cgi_service.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,46 +0,0 @@
-// -- 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 "boost/cgi/tags.hpp"
-#include "boost/cgi/connections/stdio.hpp"
-#include "boost/cgi/connections/async_stdio.hpp"
-#include "boost/cgi/gateway_impl/acgi_gateway_impl.hpp"
-#include "boost/cgi/gateway_service/acgi_gateway_service.hpp"
-#include "boost/cgi/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> 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__
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/cgi/request.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/cgi/request.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/cgi/request.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -11,8 +11,8 @@
#include "service.hpp"
#include "request_service.hpp"
-#include "boost/cgi/tags.hpp"
-#include "boost/cgi/basic_request_fwd.hpp"
+#include "boost/cgi/common/tags.hpp"
+#include "boost/cgi/fwd/basic_request_fwd.hpp"
#include "boost/cgi/cgi/request_impl.hpp"
#include "boost/cgi/basic_request.hpp"
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/cgi/request_impl.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/cgi/request_impl.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/cgi/request_impl.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -11,15 +11,16 @@
#include <map>
#include <string>
-#include <boost/noncopyable.hpp>
+///////////////////////////////////////////////////////////
#include <boost/shared_ptr.hpp>
-
-#include "boost/cgi/http/status_code.hpp"
+#include <boost/noncopyable.hpp>
+///////////////////////////////////////////////////////////
+#include "boost/cgi/common/map.hpp"
#include "boost/cgi/basic_client.hpp"
+#include "boost/cgi/common/role_type.hpp"
+#include "boost/cgi/http/status_code.hpp"
#include "boost/cgi/connections/stdio.hpp"
-#include "boost/cgi/role_type.hpp"
-#include "boost/cgi/status_type.hpp"
-#include "boost/cgi/common/map.hpp"
+#include "boost/cgi/common/status_type.hpp"
#include "boost/cgi/detail/cgi_request_impl_base.hpp"
// Make this ProtocolService-independent
@@ -38,10 +39,12 @@
* restricted but if someone really wants to copy the data, then they can.
*/
class cgi_request_impl
- : public cgi_request_impl_base<common::stdio_connection>
+ : public detail::cgi_request_impl_base<common::stdio_connection>
{
public:
- typedef ::cgi::common::basic_client<common::stdio_connection, tags::cgi> client_type;
+ typedef common::basic_client<
+ common::stdio_connection, common::tags::cgi
+ > client_type;
/// Constructor
/**
@@ -50,12 +53,12 @@
*/
template<typename ProtocolService>
cgi_request_impl(ProtocolService& pserv)
- : cgi_request_impl_base<connection_type>(pserv)
+ : detail::cgi_request_impl_base<connection_type>(pserv)
{
}
cgi_request_impl()
- : cgi_request_impl_base<connection_type>()
+ : detail::cgi_request_impl_base<connection_type>()
{
}
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/cgi/request_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/cgi/request_service.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/cgi/request_service.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -9,14 +9,15 @@
#ifndef CGI_CGI_SERVICE_IMPL_HPP_INCLUDED__
#define CGI_CGI_SERVICE_IMPL_HPP_INCLUDED__
-#include <string>
#include <map>
+#include <string>
+///////////////////////////////////////////////////////////
#include <boost/system/error_code.hpp>
-
+///////////////////////////////////////////////////////////
#include "boost/cgi/cgi/request_impl.hpp"
-#include "boost/cgi/detail/cgi_service_impl_base.hpp"
-#include "boost/cgi/detail/extract_params.hpp"
#include "boost/cgi/connections/stdio.hpp"
+#include "boost/cgi/detail/extract_params.hpp"
+#include "boost/cgi/detail/cgi_service_impl_base.hpp"
namespace cgi {
@@ -28,7 +29,7 @@
{
public:
typedef cgi_request_impl impl_type;
- typedef tags::cgi protocol_type;
+ typedef common::tags::cgi protocol_type;
cgi_request_service()
: cgi_service_impl_base<cgi_request_impl>()
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/cgi/service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/cgi/service.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/cgi/service.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -9,10 +9,10 @@
#ifndef CGI_CGI_SERVICE_HPP_INCLUDED__
#define CGI_CGI_SERVICE_HPP_INCLUDED__
-#include "boost/cgi/tags.hpp"
+#include "boost/cgi/common/tags.hpp"
#include "boost/cgi/connections/stdio.hpp"
#include "boost/cgi/connections/async_stdio.hpp"
-#include "boost/cgi/basic_protocol_service_fwd.hpp"
+#include "boost/cgi/fwd/basic_protocol_service_fwd.hpp"
namespace cgi {
@@ -20,7 +20,7 @@
/**
* Works with both cgi_request and acgi_request.
*/
- typedef common::basic_protocol_service<tags::acgi> cgi_service;
+ typedef common::basic_protocol_service<common::tags::acgi> cgi_service;
/// A service 'owned' by a single user-supplied io_service
//typedef basic_protocol_service<tags::acgi> cgi_sub_service;
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/form_parser.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/form_parser.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/form_parser.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -11,17 +11,19 @@
#include "boost/cgi/detail/push_options.hpp"
+///////////////////////////////////////////////////////////
#include <set>
#include <vector>
#include <string>
+///////////////////////////////////////////////////////////
#include <boost/regex.hpp>
-#include <boost/asio/buffer.hpp>
-#include <boost/asio/error.hpp>
#include <boost/function.hpp>
-#include <boost/system/error_code.hpp>
+#include <boost/asio/error.hpp>
+#include <boost/asio/buffer.hpp>
#include <boost/algorithm/string/find.hpp>
+///////////////////////////////////////////////////////////
+#include "boost/cgi/common/map.hpp"
#include "boost/cgi/common/form_part.hpp"
-#include "boost/cgi/basic_client.hpp"
namespace cgi {
namespace detail {
@@ -31,13 +33,13 @@
class form_parser
{
public:
- //typedef
- // boost::function<
- // std::size_t (
- // const mutable_buffers_type&
- // , boost::system::error_code& )
- // >
- //callback_type;
+ typedef
+ boost::function<
+ std::size_t (
+ const boost::asio::mutable_buffer&
+ , boost::system::error_code& )
+ >
+ callback_type;
typedef boost::asio::mutable_buffers_1 mutable_buffers_type;
typedef std::vector<char> buffer_type;
@@ -46,6 +48,7 @@
typedef RequestImplType implementation_type;
form_parser(implementation_type& impl);
+ form_parser(implementation_type& impl, callback_type const& callback);
mutable_buffers_type prepare(std::size_t size)
{
@@ -95,13 +98,15 @@
std::list<std::string> boundary_markers;
std::vector<common::form_part> form_parts_;
- //callback_type callback_;
+ const callback_type callback_;
};
} // namespace detail
} // namespace cgi
-#include "boost/cgi/common/form_parser.ipp"
+//#ifndef BOOST_CGI_BUILD_LIB
+# include "boost/cgi/impl/form_parser.ipp"
+//#endif
#endif // CGI_DETAIL_FORM_PARSER_HPP_INCLUDED__
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/form_parser.ipp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/form_parser.ipp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,434 +0,0 @@
-// -- form_parser.ihpp --
-//
-// 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_DETAIL_FORM_PARSER_IPP_INCLUDED__
-#define CGI_DETAIL_FORM_PARSER_IPP_INCLUDED__
-
-#include "boost/cgi/common/form_parser.hpp"
-
-namespace cgi {
- namespace detail {
-
- template<typename T>
- form_parser<T>::form_parser
- (
- implementation_type& impl
- )
- : impl_(impl)
- , bytes_left_(impl.client_.bytes_left_)
- //, stdin_data_read_(impl.stdin_data_read_)
- , offset_(0)
- {
- }
-
- template<typename T>
- boost::system::error_code
- form_parser<T>::parse(boost::system::error_code& ec)
- {
- std::string content_type (impl_.env_vars()["CONTENT_TYPE"]);
-
- BOOST_ASSERT(!content_type.empty());
-
- if (boost::algorithm::ifind_first(content_type,
- "application/x-www-form-urlencoded"))
- {
- parse_url_encoded_form(ec);
- }
- else
- {
- parse_multipart_form(ec);
- }
-
- return ec;
- }
-
- template<typename T>
- boost::system::error_code
- form_parser<T>::parse_url_encoded_form(boost::system::error_code& ec)
- {
- std::string name;
- std::string str;
-
- char ch;
- char ch1;
- while( bytes_left_ )
- {
- ch = getchar();
- --bytes_left_;
-
- switch(ch)
- {
- case '%': // unencode a hex character sequence
- if (bytes_left_ >= 2)
- {
- ch = getchar();
- ch1 = getchar();
- if (std::isxdigit(ch) && std::isxdigit(ch1))
- {
- str.append(1, detail::hex_to_char(ch, ch1));
- }
- else // we don't have a hex sequence
- {
- str.append(1, '%').append(1, ch).append(1, ch1);
- }
- bytes_left_ -= 2;
- }
- else // There aren't enough characters to make a hex sequence
- {
- str.append(1, '%');
- --bytes_left_;
- }
- break;
- case '+':
- str.append(1, ' ');
- break;
- case ' ': // skip spaces
- continue;
- case '=': // the name is complete, now get the corresponding value
- name.swap(str);
- break;
- case '&': // we now have the name/value pair, so save it
- // **FIXME** have to have .c_str() ?
- impl_.post_vars()[name.c_str()] = str;
- str.clear();
- name.clear();
- break;
- default:
- str.append(1, ch);
- }
- }
- // save the last param (it won't have a trailing &)
- if( !name.empty() )
- // **FIXME** have to have .c_str() ?
- impl_.post_vars()[name.c_str()] = str;
-
- return ec;
- }
-
- /// Parse a multipart form.
- template<typename T>
- boost::system::error_code
- form_parser<T>::parse_multipart_form(boost::system::error_code& ec)
- {
- parse_boundary_marker(ec);
-
- move_to_start_of_first_part(ec);
-
- if (ec && ec != boost::asio::error::eof)
- return ec;
-
- do {
- parse_form_part(ec);
- }while( //!impl_.stdin_parsed_
- impl_.client_.bytes_left_ // != 0
- );//&& ec != boost::asio::error::eof );
-
- return ec;
- }
-
-
- template<typename T>
- boost::system::error_code
- form_parser<T>::parse_form_part(boost::system::error_code& ec)
- {
- if (!parse_form_part_meta_data(ec)
- && !parse_form_part_data(ec))
- return ec;
-
- return ec;
- }
-
- template<typename T>
- boost::system::error_code
- form_parser<T>::parse_form_part_data(boost::system::error_code& ec)
- {
- std::string regex("^(.*?)" // the data
- "\\x0D\\x0A" // CR LF
- "--" "(");
- if (boundary_markers.size() > 1)
- {
- std::list<std::string>::iterator i(boundary_markers.begin());
- regex = regex + "(?:" + *i + ")";
- ++i;
- for(; i != boundary_markers.end(); ++i)
- {
- regex = regex + "|(?:" + *i + ")";
- }
- }
- else
- {
- regex += *boundary_markers.begin();
- }
-
- regex += ")(--)?[ ]*\\x0D\\x0A";
- boost::regex re(regex);
-
- typedef buffer_type::iterator buffer_iter;
-
- boost::match_results<buffer_iter> matches;
-
- std::size_t offset = offset_;
-
- //int runs = 0;
- buffer_iter begin(impl_.buffer_.begin() + offset);
- buffer_iter end(impl_.buffer_.end());
-
- for(;;)
- {
- if (!boost::regex_search(begin, end, matches, re
- , boost::match_default
- | boost::match_partial))
- {
- return boost::system::error_code(345, boost::system::system_category);
- }
- else
- {
- if (matches[1].matched)
- {
- form_parts_.back().buffer_
- // = boost::range_iterator<;
- = std::make_pair(matches[1].first, matches[1].second);
- // **FIXME**
- impl_.post_vars()[form_parts_.back().name.c_str()] = matches[1];
- //std::ofstream of("c:/cc/log/post_vars.log");
- //of<< "var == " << matches[1] << std::endl;
- offset_ = offset + matches[0].length();
- pos_ = matches[0].second;
-
- if (matches[3].matched)
- {
- impl_.client_.bytes_left_ = 0; // stop reading completely.
- //impl_.stdin_parsed_ = true;
- }
- return ec;
- }
- else
- {
- std::size_t bytes_read = impl_.client_.read_some(prepare(64), ec);
-
- if (bytes_read == 0 && impl_.client_.bytes_left_ == 0) // **FIXME**
- {
- //stdin_data_read_ = true;
- return ec;
- }
-
- begin = impl_.buffer_.begin() + offset;
- end = impl_.buffer_.end();
-
- if (ec)
- return ec;
- }
- }
- }
-
- return ec;
- }
-
- template<typename T>
- boost::system::error_code
- form_parser<T>::parse_form_part_meta_data(boost::system::error_code& ec)
- {
- // Oh dear this is ugly. The move to Boost.Spirit will have to be sooner than planned.
- // (it's a nested, recursive pattern, which regexes don't suit, apparently)
- boost::regex re( "(?:" // [IGNORE] the line may be empty, as meta-data is optional
- "^"
- "([-\\w]+)" // name
- ":[ ^]*" // separator
- "([-/\\w]+)" // optional(?) value
- ""
- "(?:"
- ";"
- "[ ]*" // additional name/value pairs (don't capture)
- "([-\\w]+)" // name
- "[ \\x0D\\x0A]*=[ \\x0D\\x0A]*" // separator
- "(?:\"?([-.\\w]*)\"?)" // value may be empty
- ")?"
- "(?:"
- ";"
- "[ ]*" // additional name/value pairs (don't capture)
- "([-\\w]+)" // name
- "[ \\x0D\\x0A]*=[ \\x0D\\x0A]*" // separator
- "(?:\"?([-.\\w]*)\"?)" // value may be empty
- ")?" // mark the extra n/v pairs optional
- "\\x0D\\x0A"
- ")"
- "(?:"
- "([-\\w]+)" // name
- ":[ ^]*" // separator
- "([-/\\w]+)" // optional(?) value
- ""
- "(?:"
- ";"
- "[ ]*" // additional name/value pairs (don't capture)
- "([-\\w]+)" // name
- "[ \\x0D\\x0A]*=[ \\x0D\\x0A]*" // separator
- "(?:\"?([-.\\w]*)\"?)" // value may be empty
- ")?"
- "(?:"
- ";"
- "[ ]*" // additional name/value pairs (don't capture)
- "([-\\w]+)" // name
- "[ \\x0D\\x0A]*=[ \\x0D\\x0A]*" // separator
- "(?:\"?([-.\\w]*)\"?)" // value may be empty
- ")?" // mark the extra n/v pairs optional
- "\\x0D\\x0A" // followed by the end of the line
- ")?"
- "(\\x0D\\x0A)"); // followed by the 'header termination' line
-
- typedef buffer_type::iterator buffer_iter;
-
- boost::match_results<buffer_iter> matches;
-
- std::size_t offset = offset_;
- pos_ = impl_.buffer_.begin();
- int runs = 0;
-
- std::size_t bytes_read = 0;
- for(;;)
- {
- buffer_iter begin(impl_.buffer_.begin() + offset);
- buffer_iter end(impl_.buffer_.end());
-
- if (!boost::regex_search(begin, end, matches, re
- , boost::match_default | boost::match_partial))
- {
- impl_.stdin_parsed_ = true;
- return ec;
- }
- if (matches[0].matched)
- {
- common::form_part part;
- for ( unsigned int i = 1
- ; i < matches.size()
- && matches[i].matched
- && !matches[i].str().empty()
- ; i+=2)
- {
- if (matches[i].str() == "name")
- {
- part.name = matches[i+1];
- }
- else
- {
- part.meta_data_[matches[i]]
- = std::make_pair(matches[i+1].first, matches[i+1].second);
- }
- form_parts_.push_back(part);
- }
-
- if (matches[13].str() == "\r\n")
- {
- offset_ = offset + matches[0].length();
- offset += matches[0].length();
- pos_ = matches[0].second;
-
- return ec;
- }
- else
- {
- throw std::runtime_error("Invalid POST data (header wasn't terminated as expected)");
- }
-
- }else{
- bytes_read = impl_.client_.read_some(prepare(64), ec);
- if (ec)
- return ec;
- if (++runs > 40)
- {
- std::cerr<< "Done 40 runs; bailing out" << std::endl;
- break;
- }
- }
- }
-
- return ec;
- }
-
- template<typename T>
- boost::system::error_code
- form_parser<T>::move_to_start_of_first_part(boost::system::error_code& ec)
- {
- boost::regex re("((?:.*)?" // optional leading characters
- //"(?:\\x0D\\x0A)|^" // start of line
- "[\\x0D\\x0A^]*?"
- "("
- "--" + boundary_markers.front() + // two dashes and our marker
- ")"
- "(--)?" // optional two dashes (not sure if this is allowed)
- " *\\x0D\\x0A)");
- // on the first marker.
-
- typedef buffer_type::iterator buffer_iter;
- //std::cerr<< "Regex := " << re << std::endl;
-
- boost::match_results<buffer_iter> matches;
-
- // get data into our buffer until we reach the first boundary marker.
- int runs = 0;
- std::size_t offset = 0;
- std::size_t bytes_read = 0;
- for(;;)
- {
- bytes_read = impl_.client_.read_some(prepare(32), ec);
- if (ec || (bytes_read == 0))
- return ec;
- buffer_iter begin(impl_.buffer_.begin());// + offset);
- buffer_iter end(impl_.buffer_.end());
- if (!boost::regex_search(begin, end //impl.buffer_.begin(), impl.buffer_.end()
- , matches, re, boost::match_default | boost::match_partial))
- {
- offset = impl_.buffer_.size();
- continue;
- }
- else
- {
- if (matches[2].matched)
- {
- impl_.buffer_.erase(impl_.buffer_.begin(), matches[0].second);
- offset_ = 0;
- pos_ = impl_.buffer_.begin();
- return ec;
- }
- else
- {
- if (++runs > 10)
- return ec;
- continue;
- }
- }
- }
- // skip that line and then erase the buffer
- return ec;
- }
-
- template<typename T>
- boost::system::error_code
- form_parser<T>::parse_boundary_marker(boost::system::error_code& ec)
- {
- // get the meta-data appended to the content_type
- std::string content_type_(impl_.env_vars()["CONTENT_TYPE"]);
- //BOOST_ASSERT(!content_type.empty());
-
- boost::regex re("; ?boundary=\"?([^\"\n\r]+)\"?");
- boost::smatch match_results;
- if (!boost::regex_search(content_type_, match_results, re))
- return boost::system::error_code(666, boost::system::system_category);
-
- boundary_marker = match_results[1].str();
- // New boundary markers are added to the front of the list.
- boundary_markers.push_front(match_results[1].str());
-
- return ec;
- }
-
-
- } // namespace detail
-} // namespace cgi
-
-#endif // CGI_DETAIL_FORM_PARSER_IPP_INCLUDED__
-
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/name.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/name.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/name.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -15,7 +15,8 @@
#include <string>
#include <ostream>
-#include <map>
+#include <cstdlib>
+#include <ctype.h>
namespace cgi {
namespace common {
@@ -25,13 +26,13 @@
: std::char_traits<CharT>
{
static bool eq(char c1, char c2)
- { return std::toupper(c1) == std::toupper(c2); }
+ { return toupper(c1) == toupper(c2); }
static bool ne(char c1, char c2)
- { return std::toupper(c1) != std::toupper(c2); }
+ { return toupper(c1) != toupper(c2); }
static bool lt(char c1, char c2)
- { return std::toupper(c1) < std::toupper(c2); }
+ { return toupper(c1) < toupper(c2); }
static int compare( const char* str1
, const char* str2
@@ -39,8 +40,8 @@
{
if (num)
do {
- if (std::toupper(*str1) != std::toupper(*str2))
- return (std::toupper(*str1) - std::toupper(*str2));
+ if (toupper(*str1) != toupper(*str2))
+ return (toupper(*str1) - toupper(*str2));
++str1;
++str2;
} while (--num);
@@ -52,7 +53,7 @@
find(const char* str, int n, char a)
{
do {
- std::toupper(*str) != std::toupper(a);
+ toupper(*str) != toupper(a);
++str;
} while (--n);
return str;
@@ -61,16 +62,17 @@
};
// typedef for typical usage.
- typedef std::basic_string<char, ichar_traits<char> > name;
+ typedef std::basic_string<char, ichar_traits<char> > name;
+ typedef std::basic_string<wchar_t, ichar_traits<wchar_t> > wname;
- // Overload allowing output using standard streams.
- template <typename CharT, typename Traits>
- std::basic_ostream<CharT, Traits>&
- operator<< (std::basic_ostream<CharT, Traits>& os
- , const std::basic_string<CharT, ichar_traits<CharT> >& str)
- {
- return os<< str.c_str();
- }
+ // Allow output using standard streams (conserves original case).
+ template <typename CharT, typename Traits>
+ std::basic_ostream<CharT, Traits>&
+ operator<< (std::basic_ostream<CharT, Traits>& os
+ , std::basic_string<CharT, ichar_traits<CharT> > const& str)
+ {
+ return os<< str.c_str();
+ }
} // namespace common
} // namespace cgi
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/request_base.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/request_base.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/request_base.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -33,44 +33,7 @@
class request_base
{
public:
- /// Find the environment meta-variable matching name
- template<typename ImplType>
- std::string& env(ImplType& impl, std::string const& name
- , boost::system::error_code& ec)
- {
- return impl.env_vars()[name.c_str()];
- }
-
- template<typename ImplType>
- std::string& GET(ImplType& impl, std::string const& name
- , boost::system::error_code& ec)
- {
- return impl.get_vars()[name.c_str()];
- }
-
- /// 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.
- */
- template<typename ImplType>
- std::string& POST(ImplType& impl, std::string const& name
- , boost::system::error_code& ec, bool greedy)
- {
- // **FIXME** greedy isn't used: it may be unnecessary now though...
- return impl.post_vars()[name.c_str()];
- }
-
- /// Find the cookie meta-variable matching name
- template<typename ImplType>
- std::string&
- cookie(ImplType& impl, std::string const& name
- , boost::system::error_code& ec)
- {
- return impl.cookie_vars()[name.c_str()];
- }
-
+ /// Get the request ID of a FastCGI request, or 1.
template<typename ImplType>
int request_id(ImplType& impl)
{
@@ -82,15 +45,12 @@
// implementation_type and should be inherited by it.
struct impl_base
{
- typedef std::vector<char> buffer_type;
+ typedef char char_type; // **FIXME**
+ typedef std::basic_string<char_type> string_type;
+ typedef std::vector<char_type> buffer_type;
typedef boost::asio::const_buffers_1 const_buffers_type;
typedef boost::asio::mutable_buffers_1 mutable_buffers_type;
- common::env_map& env_vars() { return boost::fusion::at_c<0>(vars_); }
- common::get_map& get_vars() { return boost::fusion::at_c<1>(vars_); }
- common::post_map& post_vars() { return boost::fusion::at_c<2>(vars_); }
- common::cookie_map& cookie_vars() { return boost::fusion::at_c<3>(vars_); }
-
typedef boost::fusion::vector<
common::env_map, common::get_map
, common::post_map, common::cookie_map
@@ -108,14 +68,12 @@
// Make sure the request is in a pre-loaded state
//BOOST_ASSERT (impl.status() <= unloaded);
- std::string const& vars(impl.env_vars()["QUERY_STRING"]);
- if (vars.empty())
- return ec;
-
- detail::extract_params(vars, impl.get_vars()
- , boost::char_separator<char>
- ("", "=&", boost::keep_empty_tokens)
- , ec);
+ std::string const& vars (env_vars(impl.vars_)["QUERY_STRING"]);
+ if (!vars.empty())
+ detail::extract_params(vars, get_vars(impl.vars_)
+ , boost::char_separator<char>
+ ("", "=&", boost::keep_empty_tokens)
+ , ec);
return ec;
}
@@ -128,14 +86,12 @@
// Make sure the request is in a pre-loaded state
//BOOST_ASSERT (impl.status() <= unloaded);
- std::string const& vars(impl.env_vars()["HTTP_COOKIE"]);
- if (vars.empty())
- return ec;
-
- detail::extract_params(vars, impl.cookie_vars()
- , boost::char_separator<char>
- ("", "=;", boost::keep_empty_tokens)
- , ec);
+ std::string const& vars (env_vars(impl.vars_)["HTTP_COOKIE"]);
+ if (!vars.empty())
+ detail::extract_params(vars, cookie_vars(impl.vars_)
+ , boost::char_separator<char>
+ ("", "=;", boost::keep_empty_tokens)
+ , ec);
return ec;
}
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/source_enums.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/source_enums.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/common/source_enums.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -2,14 +2,27 @@
#ifndef BOOST_CGI_COMMON_SOURCE_ENUMS_HPP_INCLUDED__
#define BOOST_CGI_COMMON_SOURCE_ENUMS_HPP_INCLUDED__
+#include <boost/fusion/include/at.hpp>
+///////////////////////////////////////////////////////////
+#include "boost/cgi/common/map.hpp"
+
namespace cgi {
namespace common {
- enum get_data_type { get_data };
- enum post_data_type { post_data };
- enum cookie_data_type { cookie_data };
- enum env_data_type { env_data };
- enum form_data_type { form_data };
+ enum env_data_type { env, env_data };
+ enum get_data_type { get, get_data };
+ enum post_data_type { post, post_data };
+ enum cookie_data_type { cookies, cookie_data };
+ enum form_data_type { form, form_data };
+
+ template<typename Impl>
+ env_map& env_vars(Impl& impl) { return boost::fusion::at_c<0>(impl); }
+ template<typename Impl>
+ get_map& get_vars(Impl& impl) { return boost::fusion::at_c<1>(impl); }
+ template<typename Impl>
+ post_map& post_vars(Impl& impl) { return boost::fusion::at_c<2>(impl); }
+ template<typename Impl>
+ cookie_map& cookie_vars(Impl& impl) { return boost::fusion::at_c<3>(impl); }
} // namespace common
} // namespace cgi
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/connection_base.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/connection_base.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,40 +0,0 @@
-// -- connection_base.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_CONNECTION_BASE_HPP_INCLUDED__
-#define CGI_CONNECTION_BASE_HPP_INCLUDED__
-
-namespace cgi {
-
- /// Abstract Base Class for all connection types
- class connection_base
- {
- public:
- virtual ~connection_base() {}
-
- // read functions
- //template<typename MutableBufferSequence>
- //virtual std::size_t read(MutableBufferSequence) = 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, typename Handler>
- //virtual void async_write(ConstBufferSequence, Handler) = 0;
-
- protected:
- //~connection_base() { }
- };
-
-} // namespace cgi
-
-#endif // CGI_CONNECTION_BASE_HPP_INCLUDED__
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/connections/async_stdio.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/connections/async_stdio.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/connections/async_stdio.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -13,15 +13,85 @@
#include <boost/shared_ptr.hpp>
#include <boost/system/error_code.hpp>
#include <boost/enable_shared_from_this.hpp>
-
-#include "boost/cgi/connections/stdio.hpp"
-#include "boost/cgi/io_service.hpp"
-#include "boost/cgi/tags.hpp"
+#include <boost/asio/posix/stream_descriptor.hpp>
+///////////////////////////////////////////////////////////
+#include "boost/cgi/common/tags.hpp"
+#include "boost/cgi/import/io_service.hpp"
+
+#if ! defined(BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR)
+# include "boost/cgi/connections/stdio.hpp"
+#endif // defined(BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR)
namespace cgi {
namespace common {
- // Asynchronous access to stdio
+#if defined(BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR)
+
+ template<>
+ class basic_connection<tags::async_stdio>
+ {
+ public:
+ typedef basic_connection<tags::async_stdio> type;
+ typedef boost::shared_ptr<type> pointer;
+ typedef boost::asio::posix::stream_descriptor next_layer_type;
+
+ basic_connection(common::io_service& ios)
+ : in_(ios, 0)
+ , out_(ios, 1)
+ {
+ }
+
+ bool is_open() const
+ {
+ return in_.is_open() && out_.is_open();
+ }
+
+ void close()
+ {
+ in_.close();
+ out_.close();
+ }
+
+ static pointer create(::cgi::common::io_service& ios)
+ {
+ return pointer(new basic_connection<tags::async_stdio>(ios));
+ }
+
+ template<typename MutableBufferSequence>
+ std::size_t read_some(const MutableBufferSequence& buf, boost::system::error_code& ec)
+ {
+ return in_.read_some(buf, ec);
+ }
+
+ template<typename MutableBufferSequence, typename Handler>
+ void async_read_some(const MutableBufferSequence& buf, Handler handler)
+ {
+ in_.async_read_some(buf, handler);
+ }
+
+ template<typename ConstBufferSequence>
+ std::size_t write_some(const ConstBufferSequence& buf, boost::system::error_code& ec)
+ {
+ return out_.write_some(buf, ec);
+ }
+
+ template<typename ConstBufferSequence, typename Handler>
+ void async_write_some(const ConstBufferSequence& buf, Handler handler)
+ {
+ out_.async_write_some(buf, handler);
+ }
+
+ boost::asio::posix::stream_descriptor in_;
+ boost::asio::posix::stream_descriptor out_;
+ };
+
+#else
+
+ /// Simple, pseudo-asynchronous access to stdio.
+ /**
+ * This will only appear asynchronous if the io_service is being run
+ * in multiple threads. This doesn't spawn any hidden threads.
+ */
template<>
class basic_connection<tags::async_stdio>
: public basic_connection<tags::stdio>
@@ -31,7 +101,7 @@
typedef basic_connection<tags::async_stdio> type;
typedef boost::shared_ptr<type> pointer;
- basic_connection(::cgi::io_service& ios)
+ basic_connection(common::io_service& ios)
: basic_connection<tags::stdio>()
, io_service_(ios)
{
@@ -47,7 +117,7 @@
is_open_ = false;
}
- static pointer create(::cgi::io_service& ios)
+ static pointer create(::cgi::common::io_service& ios)
{
return pointer(new basic_connection<tags::async_stdio>(ios));
}
@@ -119,9 +189,11 @@
}
private:
- ::cgi::io_service& io_service_;
+ ::cgi::common::io_service& io_service_;
};
+#endif // defined(BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR)
+
typedef basic_connection<tags::async_stdio> async_stdio_connection;
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/connections/shareable_tcp_socket.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/connections/shareable_tcp_socket.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/connections/shareable_tcp_socket.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -11,21 +11,20 @@
#include <map>
#include <set>
+///////////////////////////////////////////////////////////
#include <boost/asio.hpp>
#include <boost/cstdint.hpp>
#include <boost/foreach.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/thread.hpp>
-
-#include "boost/cgi/tags.hpp"
+///////////////////////////////////////////////////////////
#include "boost/cgi/error.hpp"
-#include "boost/cgi/io_service.hpp"
-#include "boost/cgi/connection_base.hpp"
+#include "boost/cgi/common/tags.hpp"
#include "boost/cgi/basic_connection.hpp"
+#include "boost/cgi/import/io_service.hpp"
#include "boost/cgi/detail/push_options.hpp"
+#include "boost/cgi/common/connection_base.hpp"
-//#include "boost/cgi/fcgi/client_fwd.hpp"
-//#include "boost/cgi/fcgi/request_fwd.hpp"
#include "boost/cgi/detail/protocol_traits.hpp"
namespace cgi {
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/connections/stdio.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/connections/stdio.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/connections/stdio.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -11,14 +11,14 @@
#include <cstdio>
#include <string>
+///////////////////////////////////////////////////////////
#include <boost/system/error_code.hpp>
#include <boost/asio.hpp>
-
-#include "boost/cgi/basic_connection_fwd.hpp"
-#include "boost/cgi/tags.hpp"
-#include "boost/cgi/connection_base.hpp"
+///////////////////////////////////////////////////////////
#include "boost/cgi/error.hpp"
-//#include "boost/cgi/io_service.hpp"
+#include "boost/cgi/common/tags.hpp"
+#include "boost/cgi/common/connection_base.hpp"
+#include "boost/cgi/fwd/basic_connection_fwd.hpp"
namespace cgi {
namespace common {
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 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -11,12 +11,12 @@
#include <boost/shared_ptr.hpp>
#include <boost/asio/ip/tcp.hpp>
-
-#include "boost/cgi/tags.hpp"
-#include "boost/cgi/io_service.hpp"
-#include "boost/cgi/connection_base.hpp"
+///////////////////////////////////////////////////////////
+#include "boost/cgi/common/tags.hpp"
#include "boost/cgi/basic_connection.hpp"
+#include "boost/cgi/import/io_service.hpp"
#include "boost/cgi/detail/push_options.hpp"
+#include "boost/cgi/common/connection_base.hpp"
namespace cgi {
namespace common {
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/cookie.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/cookie.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,144 +0,0 @@
-// -- cookie.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_COOKIE_HPP_INCLUDED__
-#define CGI_COOKIE_HPP_INCLUDED__
-
-#include <string>
-#include <boost/system/error_code.hpp>
-#include <boost/tokenizer.hpp>
-
-namespace cgi {
-
- template<typename String> struct basic_cookie;
-
- // typedefs for common usage
- typedef basic_cookie<std::string> cookie;
- typedef basic_cookie<std::wstring> wcookie;
-
- /// A `basic_cookie<>` object that can be (out-) streamed
- /**
- * Either set the parameters in the constructor, or set them directly.
- * Note: If you want to set the parameters individually, remember that each
- * parameter must NOT have a trailing semi-colon!
- *
- * TODO
- * - Data should be URL-encoded, or maybe provide an overload for url_decode
- * that takes an HttpCookie?
- * - Add from_string() ?
- */
- template<typename String>
- struct basic_cookie
- {
- typedef String string_type;
-
- basic_cookie() {}
-
- /// Delete the cookie named `_name`.
- basic_cookie(const string_type& _name)
- : name(_name)
- , value()
- , expires("Fri, 05-Jun-1989 15:30:00 GMT")
- , path("/")
- , secure(false)
- , http_only(false)
- {
- }
-
- /// Create a cookie.
- basic_cookie(const string_type& _name, const string_type& _val
- , const string_type& _expires = ""
- , const string_type& _path = "/"
- , const string_type& _domain = ""
- , bool _secure = false
- , bool HttpOnly = false)
- : name(_name)
- , value(_val)
- , expires(_expires)
- , path(_path)
- , domain(_domain)
- , secure(_secure)
- , http_only(HttpOnly)
- {
- }
-
- string_type name;
- string_type value;
- string_type expires;
- string_type path;
- string_type domain;
- bool secure;
- bool http_only;
-
- /// Create a cookie from a const char*
- /**
- * Rules taken from: http://wp.netscape.com/newsref/std/cookie_spec.html
- *
- * Assumes:
- * - Parts of the cookie are delimited by '; '. ie. if there is no space,
- * or multiple spaces after the semi-colon, this function won't work...
- */
- /* Actually, I'm omitting these functions for now, just had a thought...
- static basic_cookie<string_type>
- from_string(const char* str, boost::system::error_code& ec)
- {
- typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
- boost::char_separator<char> sep(";=");
- tokenizer tokens(str, sep);
- for (tokenizer::iterator iter = tokens.begin();
- iter != tokens.end(); ++iter)
- {
-
- }
- return ck;
- }
-
- static basic_cookie<string_type> from_string(const char* str)
- {
- boost::system::error_code ec;
- cookie ck = from_string(ec);
- detail::throw_error(ec);
- return ck;
- }
-
- static basic_cookie<string_type> from_string(std::string& str)
- {
- return from_string(str.c_str());
- }
-
- static basic_cookie<string_type>
- from_string(std::string& str, boost::system::error_code& ec)
- {
- return from_string(str.c_str(), ec);
- }
- */
-
- /// Make a string out of the cookie
- std::string to_string()
- {
- std::string str(name + "=" + value);
- if (!expires.empty()) str += ("; expires=" + expires);
- if (!path.empty() ) str += ("; path=" + path);
- if (!domain.empty() ) str += ("; domain=" + domain);
- if ( secure ) str += "; secure";
- if ( http_only ) str += "; HttpOnly";
- return str;
- }
- };
-
- template<typename OutStream, typename T>
- OutStream& operator<<(OutStream& os, basic_cookie<T>& ck)
- {
- os<< ck.to_string();
- return os;
- }
-
-} // namespace cgi
-
-#endif // CGI_COOKIE_HPP_INCLUDED__
-
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/detail/cgi_request_impl_base.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/detail/cgi_request_impl_base.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/detail/cgi_request_impl_base.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -11,21 +11,20 @@
#include <map>
#include <string>
-#include <boost/noncopyable.hpp>
+///////////////////////////////////////////////////////////
#include <boost/shared_ptr.hpp>
-
+#include <boost/noncopyable.hpp>
+#include <boost/fusion/support.hpp>
+#include <boost/fusion/include/vector.hpp>
+///////////////////////////////////////////////////////////
+#include "boost/cgi/common/map.hpp"
+#include "boost/cgi/common/role_type.hpp"
#include "boost/cgi/http/status_code.hpp"
#include "boost/cgi/connections/stdio.hpp"
-#include "boost/cgi/role_type.hpp"
-#include "boost/cgi/status_type.hpp"
-#include "boost/cgi/common/map.hpp"
-
-#include <boost/fusion/include/vector.hpp>
-#include <boost/fusion/support.hpp>
-
-// Make this ProtocolService-independent
+#include "boost/cgi/common/status_type.hpp"
namespace cgi {
+ namespace detail {
//Forward declaration
template<typename T>
@@ -43,27 +42,27 @@
{
public:
- typedef ::cgi::common::map map_type;
- typedef Connection connection_type;
+ typedef ::cgi::common::map map_type;
+ typedef Connection connection_type;
typedef
- common::basic_client<Connection, tags::acgi> client_type;
- typedef typename connection_type::pointer conn_ptr;
+ common::basic_client<Connection, common::tags::acgi> client_type;
+ typedef typename connection_type::pointer conn_ptr;
/// Constructor
cgi_request_impl_base()
: stdin_parsed_(false)
, stdin_data_read_(false)
, stdin_bytes_left_(-1)
- , http_status_(http::ok)
- , request_status_(unloaded)
+ , http_status_(common::http::ok)
+ , request_status_(common::unloaded)
{
}
- bool stdin_parsed() { return stdin_parsed_; }
- http::status_code& http_status() { return http_status_; }
- status_type& status() { return request_status_; }
+ bool stdin_parsed() { return stdin_parsed_; }
+ common::http::status_code& http_status() { return http_status_; }
+ common::status_type& status() { return request_status_; }
- conn_ptr& connection() { return connection_; }
+ conn_ptr& connection() { return connection_; }
public:
//conn_ptr connection() { return connection_; }
@@ -76,12 +75,14 @@
std::size_t stdin_bytes_left_;
protected:
- http::status_code http_status_;
- status_type request_status_;
+ common::http::status_code http_status_;
+ common::status_type request_status_;
conn_ptr connection_;
};
+ } // namespace detail
} // namespace cgi
#endif // CGI_CGI_REQUEST_IMPL_BASE_HPP_INCLUDED__
+
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/detail/cgi_service_impl_base.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/detail/cgi_service_impl_base.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/detail/cgi_service_impl_base.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -13,32 +13,27 @@
#include <string>
#include <cstdlib>
+///////////////////////////////////////////////////////////
#include <boost/assert.hpp>
#include <boost/regex.hpp>
#include <boost/tokenizer.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/system/error_code.hpp>
#include <boost/algorithm/string/find.hpp>
-
+///////////////////////////////////////////////////////////
#include "boost/cgi/common/map.hpp"
#include "boost/cgi/basic_client.hpp"
-#include "boost/cgi/role_type.hpp"
-#include "boost/cgi/status_type.hpp"
-#include "boost/cgi/detail/extract_params.hpp"
-#include "boost/cgi/detail/save_environment.hpp"
+#include "boost/cgi/common/role_type.hpp"
#include "boost/cgi/common/form_part.hpp"
#include "boost/cgi/detail/throw_error.hpp"
-
+#include "boost/cgi/common/status_type.hpp"
#include "boost/cgi/common/form_parser.hpp"
#include "boost/cgi/common/request_base.hpp"
+#include "boost/cgi/detail/extract_params.hpp"
+#include "boost/cgi/detail/save_environment.hpp"
namespace cgi {
-
- namespace detail {
-
-
- } // namespace detail
-
+// **FIXME** Wrong namespace (should be cgi::detail?).
template<typename RequestImplType>
class cgi_service_impl_base
@@ -87,7 +82,7 @@
*/
bool is_open(implementation_type& impl)
{
- return impl.status() >= aborted;
+ return impl.status() >= common::aborted;
}
/// Return the connection associated with the request
@@ -99,9 +94,11 @@
int request_id(implementation_type& impl) { return 1; }
- int close(implementation_type& impl, http::status_code& http_s, int status)
+ // **FIXME** should return error_code
+ int close(implementation_type& impl, common::http::status_code& http_s
+ , int status, boost::system::error_code& ec)
{
- impl.status() = closed;
+ impl.status() = common::closed;
impl.http_status() = http_s;
return status;
}
@@ -114,12 +111,12 @@
load(implementation_type& impl, bool parse_stdin
, boost::system::error_code& ec)
{
- detail::save_environment(impl.env_vars());
- std::string const& cl = impl.env_vars()["CONTENT_LENGTH"];
+ detail::save_environment(env_vars(impl.vars_));
+ std::string const& cl = env_vars(impl.vars_)["CONTENT_LENGTH"];
impl.characters_left_ = cl.empty() ? 0 : boost::lexical_cast<std::size_t>(cl);
impl.client_.bytes_left() = impl.characters_left_;
- std::string const& request_method = impl.env_vars()["REQUEST_METHOD"];
+ std::string const& request_method = env_vars(impl.vars_)["REQUEST_METHOD"];
if (request_method == "GET")
this->parse_get_vars(impl, ec);
else
@@ -129,13 +126,13 @@
if (ec) return ec;
this->parse_cookie_vars(impl, ec);
- impl.status() = loaded;
+ impl.status() = common::loaded;
//BOOST_ASSERT(impl.status() >= loaded);
return ec;
}
-
+/*
// TODO: use `greedy`
std::string
form(implementation_type& impl, const std::string& name
@@ -166,7 +163,7 @@
if (rm == "POST")
return POST(impl, ec);
}
-
+*/
role_type
get_role(implementation_type& impl)
{
@@ -174,8 +171,17 @@
}
/// Set the http status (this does nothing for aCGI)
- void set_status(implementation_type& impl, http::status_code&)
+ void set_status(implementation_type& impl, common::http::status_code&)
+ {
+ }
+
+ /// Read some data from the client.
+ template<typename MutableBufferSequence>
+ std::size_t
+ read_some(implementation_type& impl, const MutableBufferSequence& buf
+ , boost::system::error_code& ec)
{
+ return impl.client_.read_some(buf,ec);
}
protected:
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/detail/common_headers.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/detail/common_headers.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/detail/common_headers.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -1,4 +1,4 @@
-// -- cgi.hpp --
+// -- common_headers.hpp --
//
// Copyright (c) Darren Garvey 2007.
// Distributed under the Boost Software License, Version 1.0.
@@ -6,23 +6,24 @@
// http://www.boost.org/LICENSE_1_0.txt)
//
////////////////////////////////////////////////////////////////
-#ifndef CGI_CGI_CGI_HPP_INCLUDED__
-#define CGI_CGI_CGI_HPP_INCLUDED__
+#ifndef CGI_DETAIL_COMMON_HEADERS_HPP_INCLUDED__
+#define CGI_DETAIL_COMMON_HEADERS_HPP_INCLUDED__
// #include all protocol-independent headers only. Protocol-specific
// headers can just include this after other headers.
-#include "boost/cgi/buffer.hpp"
+//#include "boost/cgi/logger.hpp"
#include "boost/cgi/common/map.hpp"
-#include "boost/cgi/io_service.hpp"
-#include "boost/cgi/streambuf.hpp"
+#include "boost/cgi/import/read.hpp"
+#include "boost/cgi/import/write.hpp"
#include "boost/cgi/basic_request.hpp"
-//#include "boost/cgi/basic_request_acceptor.hpp"
-#include "boost/cgi/response.hpp"
-//#include "boost/cgi/logger.hpp"
-#include "boost/cgi/read.hpp"
-#include "boost/cgi/write.hpp"
-#include "boost/cgi/header.hpp"
-#include "boost/cgi/return.hpp"
+#include "boost/cgi/import/buffer.hpp"
+#include "boost/cgi/common/header.hpp"
+#include "boost/cgi/common/return.hpp"
+#include "boost/cgi/common/response.hpp"
+#include "boost/cgi/import/streambuf.hpp"
+#include "boost/cgi/http/status_code.hpp"
+#include "boost/cgi/import/io_service.hpp"
+
+#endif // CGI_DETAIL_COMMON_HEADERS_HPP_INCLUDED__
-#endif // CGI_CGI_CGI_HPP_INCLUDED__
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 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -17,15 +17,27 @@
#define CGI_REQUEST_TRAITS_HPP_INCLUDED__
#include <boost/shared_ptr.hpp>
-#include "boost/cgi/tags.hpp"
-#include "boost/cgi/basic_request_fwd.hpp"
-#include "boost/cgi/basic_connection_fwd.hpp"
-#include "boost/cgi/basic_protocol_service_fwd.hpp"
+///////////////////////////////////////////////////////////
+#include "boost/cgi/fwd/basic_protocol_service_fwd.hpp"
+#include "boost/cgi/common/tags.hpp"
+#include "boost/cgi/fwd/basic_request_fwd.hpp"
+#include "boost/cgi/fwd/basic_connection_fwd.hpp"
namespace cgi {
namespace cgi {}
- namespace acgi {}
+ namespace acgi
+ {
+ //class acgi_service;
+ class request_service;
+ class request_impl;
+ typedef common::basic_protocol_service<common::tags::acgi> service;
+ typedef
+ common::basic_request<
+ acgi::request_service, acgi::service
+ >
+ request;
+ }
namespace fcgi
{
class fcgi_request_impl;
@@ -78,6 +90,8 @@
namespace detail {
+ namespace tags = ::cgi::common::tags;
+
template<typename Protocol>
struct protocol_traits
{
@@ -89,12 +103,15 @@
typedef protocol_traits<tags::cgi> type;
typedef cgi_request_impl impl_type;
typedef cgi_request_service request_service_impl;
- typedef common::basic_protocol_service<tags::cgi> protocol_service_type;
+ typedef common::basic_protocol_service<
+ tags::cgi
+ > protocol_service_type;
typedef common::basic_request<
- request_service_impl, protocol_service_type
- > request_type;
+ request_service_impl
+ , protocol_service_type
+ > request_type;
typedef cgi_service_impl service_impl_type;
- typedef common::basic_connection<tags::stdio> connection_type;
+ typedef common::basic_connection<tags::stdio> connection_type;
// typedef cgi_gateway_impl gateway_impl_type;
// typedef cgi_gateway_service gateway_service_impl_type;
};
@@ -104,13 +121,18 @@
{
typedef protocol_traits<tags::async_cgi> type;
typedef async_cgi_request_impl impl_type;
- typedef acgi_request_service request_service_impl;
- typedef common::basic_protocol_service<tags::acgi> protocol_service_type;
+ typedef acgi::request_service request_service_impl;
+ typedef common::basic_protocol_service<
+ tags::acgi
+ > protocol_service_type;
typedef common::basic_request<
- request_service_impl, protocol_service_type
- > request_type;
+ request_service_impl
+ , protocol_service_type
+ > request_type;
typedef async_cgi_service_impl service_impl_type;
- typedef common::basic_connection<tags::async_stdio> connection_type;
+ typedef common::basic_connection<
+ tags::async_stdio
+ > connection_type;
typedef async_cgi_gateway_impl gateway_impl_type;
typedef async_cgi_gateway_service gateway_service_type;
};
@@ -120,14 +142,18 @@
// : protocol_traits<tags::async_cgi>
{
typedef protocol_traits<tags::acgi> type;
- typedef acgi_request_impl impl_type;
- typedef acgi_request_service request_service_impl;
- typedef common::basic_protocol_service<tags::acgi> protocol_service_type;
+ typedef acgi::request_impl impl_type;
+ typedef acgi::request_service request_service_impl;
+ typedef common::basic_protocol_service<
+ tags::acgi
+ > protocol_service_type;
typedef common::basic_request<
- request_service_impl, protocol_service_type
- > request_type;
- typedef acgi_service_impl service_impl_type;
- typedef common::basic_connection<tags::async_stdio> connection_type;
+ request_service_impl
+ , protocol_service_type
+ > request_type;
+ typedef common::basic_connection<
+ tags::async_stdio
+ > connection_type;
typedef acgi_gateway_impl gateway_impl_type;
typedef acgi_gateway_service gateway_service_type;
};
@@ -138,18 +164,21 @@
typedef protocol_traits<tags::fcgi> type;
typedef fcgi::fcgi_request_impl impl_type;
typedef fcgi::fcgi_request_service request_service_impl;
- typedef common::basic_protocol_service<fcgi_> protocol_service_type;
+ typedef common::basic_protocol_service<
+ common::fcgi_
+ > protocol_service_type;
typedef common::basic_request<
- request_service_impl, protocol_service_type
- > request_type;
+ request_service_impl
+ , protocol_service_type
+ > request_type;
typedef boost::shared_ptr<request_type> request_ptr;
//typedef fcgi_request_service
// ::implementation_type request_impl_type;
typedef fcgi::fcgi_service_impl service_impl_type;
typedef fcgi::fcgi_acceptor_service acceptor_service_impl;
typedef common::basic_connection<
- tags::shareable_tcp_socket
- > connection_type;
+ tags::shareable_tcp_socket
+ > connection_type;
//typedef fcgi_gateway_impl gateway_impl_type;
//typedef fcgi_gateway_service gateway_service_type;
};
@@ -171,14 +200,16 @@
//typedef scgi_gateway_service gateway_service_type;
};
+ // **FIXME** (remove)
template<>
- struct protocol_traits< ::cgi::scgi_>
+ struct protocol_traits< ::cgi::common::scgi_>
: protocol_traits<tags::scgi>
{
};
+ // **FIXME** (remove)
template<>
- struct protocol_traits< ::cgi::fcgi_>
+ struct protocol_traits< ::cgi::common::fcgi_>
: protocol_traits<tags::fcgi>
{
};
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/detail/push_options.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/detail/push_options.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/detail/push_options.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -14,3 +14,12 @@
//#pragma warning (disable:4996)
//#endif
+
+#if !defined(BOOST_CGI_INLINE)
+# if defined(BOOST_CGI_BUILD_LIB)
+# define BOOST_CGI_INLINE
+# else
+# define BOOST_CGI_INLINE inline
+# endif
+#endif
+
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/detail/url_decode.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/detail/url_decode.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/detail/url_decode.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -9,89 +9,33 @@
#ifndef CGI_DETAIL_URL_DECODE_HPP_INCLUDED__
#define CGI_DETAIL_URL_DECODE_HPP_INCLUDED__
+#include "boost/cgi/detail/push_options.hpp"
+
#include <string>
namespace cgi {
namespace detail {
/// Convert a char into a hexadecimal value
- std::string char_to_hex(char const& ch)
- {
- return std::string();
- }
+ BOOST_CGI_INLINE std::string char_to_hex(char const& ch);
/// Convert two characters into a single, hex-encoded character
- char hex_to_char(char const& c1, char const& c2)
- {
- int ret ( ( std::isalpha(c1)
- ? ((c1 & 0xdf) - 'A') + 10
- : (c1 - '0')
- ) << 4
- );
-
- ret += ( std::isalpha(c2)
- ? ((c2 & 0xdf) - 'A') + 10
- : (c2 - '0')
- );
-
- return static_cast<char>(ret);
- }
+ BOOST_CGI_INLINE char hex_to_char(char const& c1, char const& c2);
/// Take two characters (a hex sequence) and return a char
// **DEPRECATED**
- 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);
- }
+ BOOST_CGI_INLINE char url_decode( const char& c1, const char& c2 );
/// URL-decode a string
- std::string url_decode( const std::string& str )
- {
- std::string ret;
-
- for( std::string::const_iterator iter = str.begin(), end = str.end()
- ; iter != end; ++iter )
- {
- switch( *iter )
- {
- case ' ':
- break;
- case '+':
- ret.append(1, ' ');
- break;
- case '%':
- if (std::distance(iter, end) >= 2
- && std::isxdigit(*(iter+1))
- && std::isxdigit(*(iter+2)))
- {
- char ch = *++iter; // need this because order of function arg
- // evaluation is UB.
- ret.append(1, hex_to_char(ch, *++iter));
- }
- else // we're not dealing with a properly encoded hex value.
- {
- ret.append(1, '%');
- }
- break;
- default:
- ret.append(1, *iter);
- }
- }
-
- return ret;
- }
+ BOOST_CGI_INLINE std::string url_decode( const std::string& str );
} // namespace detail
} // namespace cgi
+#if !defined( BOOST_CGI_BUILD_LIB )
+# include "boost/cgi/detail/url_decode.ipp"
+#endif
+
+#include "boost/cgi/detail/pop_options.hpp"
+
#endif // CGI_DETAIL_URL_DECODE_HPP_INCLUDED__
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/error.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/error.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/error.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -11,6 +11,8 @@
// The errors for everything are defined in here. ie. FastCGI,
// CGI and SCGI errors.
//
+// **FIXME** This is a mess.
+//
////////////////////////////////////////////////////////////////
#ifndef CGI_ERROR_HPP_INCLUDED__
#define CGI_ERROR_HPP_INCLUDED__
@@ -52,6 +54,9 @@
invalid_socket,
+ // The CONTENT_TYPE for form data wasn't recognised.
+ invalid_form_type,
+
// Used in basic_connection<tags::stdio>
// **FIXME**
broken_pipe,
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -20,7 +20,7 @@
namespace cgi {
namespace fcgi {
- using namespace ::cgi; // **FIXME** this must go.
+ //using namespace ::cgi; // **FIXME** this must go.
using namespace ::cgi::common; // import common elements.
} // namespace fcgi
} // namespace cgi
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/acceptor_service_impl.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/acceptor_service_impl.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/acceptor_service_impl.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -12,22 +12,20 @@
#include "boost/cgi/detail/push_options.hpp"
#include <boost/ref.hpp>
-#include <boost/static_assert.hpp>
#include <boost/bind.hpp>
-#include <boost/asio.hpp>
-#include <boost/shared_ptr.hpp>
+#include <boost/asio.hpp> // **FIXME**
#include <boost/thread.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/static_assert.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/system/error_code.hpp>
-
-//#include "is_async.hpp"
-#include "boost/cgi/io_service.hpp"
+///////////////////////////////////////////////////////////
+#include "boost/cgi/fcgi/request.hpp"
+#include "boost/cgi/import/io_service.hpp"
#include "boost/cgi/detail/throw_error.hpp"
-#include "boost/cgi/detail/protocol_traits.hpp"
-#include "boost/cgi/basic_protocol_service_fwd.hpp"
#include "boost/cgi/detail/service_base.hpp"
-//#include "service_selector.hpp"
-#include "boost/cgi/fcgi/request.hpp"
+#include "boost/cgi/detail/protocol_traits.hpp"
+#include "boost/cgi/fwd/basic_protocol_service_fwd.hpp"
namespace cgi {
@@ -75,7 +73,7 @@
* which takes a ProtocolService (**LINK**). If the protocol isn't async then
* the class can be used without a ProtocolService.
*/
- template<typename Protocol_ = ::cgi::fcgi_>
+ template<typename Protocol_ = ::cgi::common::fcgi_>
class acceptor_service_impl
: public detail::service_base< ::cgi::fcgi::acceptor_service_impl<Protocol_> >
{
@@ -128,7 +126,7 @@
type::implementation_type::endpoint_type endpoint_type;
- explicit acceptor_service_impl(::cgi::io_service& ios)
+ explicit acceptor_service_impl(::cgi::common::io_service& ios)
: detail::service_base< ::cgi::fcgi::acceptor_service_impl<Protocol_> >(ios)
, acceptor_service_(boost::asio::use_service<acceptor_service_type>(ios))
//, endpoint(boost::asio::ip::tcp::v4())
@@ -312,6 +310,26 @@
return acceptor_service_.local_endpoint(impl.acceptor_, ec);
}
+ native_type
+ native(implementation_type& impl)
+ {
+ return acceptor_service_.native(impl.acceptor_);
+ }
+
+ bool
+ is_cgi(implementation_type& impl)
+ {
+ boost::system::error_code ec;
+#if ! defined(BOOST_WINDOWS)
+ socklen_t len
+ = static_cast<socklen_t>(local_endpoint(impl,ec).capacity());
+ int ret = getpeername(native(impl), local_endpoint(impl,ec).data(), &len);
+ return ( ret != 0 && errno == ENOTCONN ) ? false : true;
+#else
+ return false;
+#endif
+ }
+
public:
template<typename CommonGatewayRequest, typename Handler>
void check_for_waiting_request(implementation_type& impl
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/client.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/client.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/client.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -10,22 +10,24 @@
#define CGI_FCGI_CLIENT_HPP_INCLUDED__
#include <vector>
+///////////////////////////////////////////////////////////
#include <boost/shared_ptr.hpp>
#include <boost/logic/tribool.hpp>
#include <boost/asio/buffer.hpp>
-#include "boost/cgi/tags.hpp"
+///////////////////////////////////////////////////////////
+#include "boost/cgi/error.hpp"
#include "boost/cgi/common/map.hpp"
-#include "boost/cgi/io_service.hpp"
+#include "boost/cgi/common/tags.hpp"
+#include "boost/cgi/import/read.hpp"
#include "boost/cgi/basic_client.hpp"
-#include "boost/cgi/connections/shareable_tcp_socket.hpp"
+#include "boost/cgi/import/buffer.hpp"
+#include "boost/cgi/import/io_service.hpp"
#include "boost/cgi/fcgi/specification.hpp"
-#include "boost/cgi/read.hpp"
-#include "boost/cgi/buffer.hpp"
-#include "boost/cgi/error.hpp"
-//#include "boost/cgi/fcgi/request_fwd.hpp"
+#include "boost/cgi/detail/throw_error.hpp"
+#include "boost/cgi/fwd/basic_request_fwd.hpp"
#include "boost/cgi/detail/protocol_traits.hpp"
-#include "boost/cgi/basic_request_fwd.hpp"
-//#error BOOST_HAS_RVALUE_REFS
+#include "boost/cgi/connections/shareable_tcp_socket.hpp"
+
namespace cgi {
namespace common {
@@ -45,7 +47,7 @@
class basic_client<common::shareable_tcp_connection, Protocol>
{
public:
- typedef ::cgi::io_service io_service_type;
+ typedef ::cgi::common::io_service io_service_type;
typedef ::cgi::common::map map_type;
typedef Protocol protocol_type;
typedef common::shareable_tcp_connection connection_type;
@@ -294,7 +296,7 @@
namespace fcgi {
typedef
common::basic_client<
- common::shareable_tcp_connection, ::cgi::fcgi_
+ common::shareable_tcp_connection, ::cgi::common::fcgi_
>
client;
} // namespace fcgi
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/request.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/request.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/request.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -9,11 +9,10 @@
#ifndef CGI_FCGI_REQUEST_HPP_INCLUDED__
#define CGI_FCGI_REQUEST_HPP_INCLUDED__
-#include "boost/cgi/tags.hpp"
-#include "boost/cgi/basic_request_fwd.hpp"
-//#include "boost/cgi/request_service_fwd.hpp"
+#include "boost/cgi/common/tags.hpp"
#include "boost/cgi/fcgi/service.hpp"
#include "boost/cgi/fcgi/request_service.hpp"
+#include "boost/cgi/fwd/basic_request_fwd.hpp"
namespace cgi {
namespace fcgi {
@@ -28,6 +27,6 @@
} // namespace fcgi
} // namespace cgi
-//#include "boost/cgi/basic_request.hpp"
+#include "boost/cgi/basic_request.hpp"
#endif // CGI_FCGI_REQUEST_HPP_INCLUDED__
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/request_acceptor_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/request_acceptor_service.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/request_acceptor_service.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -11,15 +11,13 @@
#include "boost/cgi/detail/push_options.hpp"
#include <boost/utility/enable_if.hpp>
-
-//#include "is_async.hpp"
-#include "boost/cgi/io_service.hpp"
+///////////////////////////////////////////////////////////
+#include "boost/cgi/import/io_service.hpp"
#include "boost/cgi/detail/throw_error.hpp"
-#include "boost/cgi/detail/protocol_traits.hpp"
-#include "boost/cgi/basic_protocol_service_fwd.hpp"
#include "boost/cgi/detail/service_base.hpp"
-//#include "service_selector.hpp"
+#include "boost/cgi/detail/protocol_traits.hpp"
#include "boost/cgi/fcgi/acceptor_service_impl.hpp"
+#include "boost/cgi/fwd/basic_protocol_service_fwd.hpp"
namespace cgi {
@@ -31,7 +29,7 @@
* which takes a ProtocolService (**LINK**). If the protocol isn't async then
* the class can be used without a ProtocolService.
*/
- template<typename Protocol_ = fcgi_>
+ template<typename Protocol_ = common::fcgi_>
class fcgi_request_acceptor_service
: public detail::service_base<fcgi_request_acceptor_service<Protocol_> >
{
@@ -40,7 +38,8 @@
typedef fcgi::acceptor_service_impl<> service_impl_type;
typedef service_impl_type::implementation_type implementation_type;
- typedef typename implementation_type::protocol_type protocol_type;
+ typedef
+ typename implementation_type::protocol_type protocol_type;
typedef implementation_type::endpoint_type endpoint_type;
typedef typename service_impl_type::native_type native_type;
//typedef basic_protocol_service<protocol_type> protocol_service_type;
@@ -48,7 +47,7 @@
/// The unique service identifier
//static boost::asio::io_service::id id;
- fcgi_request_acceptor_service(::cgi::io_service& ios)
+ fcgi_request_acceptor_service(common::io_service& ios)
: detail::service_base<fcgi_request_acceptor_service<protocol_type> >(ios)
, service_impl_(ios)
{
@@ -164,6 +163,17 @@
return service_impl_.assign(impl, protocol, native_acceptor, ec);
}
+ service_impl_type::native_type
+ native(implementation_type& impl)
+ {
+ return service_impl_.native(impl);
+ }
+
+ bool
+ is_cgi(implementation_type& impl)
+ {
+ return service_impl_.is_cgi(impl);
+ }
public:
service_impl_type service_impl_;
};
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/request_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/request_service.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/request_service.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -9,52 +9,25 @@
#ifndef CGI_FCGI_REQUEST_SERVICE_HPP_INCLUDED__
#define CGI_FCGI_REQUEST_SERVICE_HPP_INCLUDED__
+#include <boost/fusion/support.hpp>
#include <boost/system/error_code.hpp>
#include <boost/fusion/include/vector.hpp>
-#include <boost/fusion/support.hpp>
////////////////////////////////////////////////////////////////
#include "boost/cgi/common/map.hpp"
-#include "boost/cgi/common/request_base.hpp"
-#include "boost/cgi/tags.hpp"
-#include "boost/cgi/read.hpp"
-#include "boost/cgi/role_type.hpp"
-#include "boost/cgi/io_service.hpp"
+#include "boost/cgi/common/tags.hpp"
+#include "boost/cgi/fcgi/client.hpp"
+#include "boost/cgi/import/read.hpp"
+#include "boost/cgi/http/status_code.hpp"
+#include "boost/cgi/common/role_type.hpp"
+#include "boost/cgi/import/io_service.hpp"
#include "boost/cgi/detail/throw_error.hpp"
+#include "boost/cgi/common/source_enums.hpp"
+#include "boost/cgi/common/request_base.hpp"
#include "boost/cgi/detail/service_base.hpp"
-#include "boost/cgi/fcgi/client.hpp"
#include "boost/cgi/common/form_parser.hpp"
namespace cgi {
-
- namespace detail {
-
- template<typename T, typename Handler>
- struct async_load_helper
- {
- async_load_helper(T& t, typename T::implementation_type& impl
- , bool parse_stdin, Handler h)
- : type(t)
- , impl_(impl)
- , parse_stdin_(parse_stdin)
- , handler_(h)
- {
- }
-
- void operator()()
- {
- boost::system::error_code ec;
- type.load(impl_, parse_stdin_, ec);
- handler_(ec);
- }
-
- T& type;
- typename T::implementation_type& impl_;
- bool parse_stdin_;
- Handler handler_;
- };
- }
-
- namespace fcgi {
+ namespace fcgi {
/// The IoObjectService class for a FCGI basic_request<>s
class fcgi_request_service
@@ -66,7 +39,7 @@
struct implementation_type
: common::request_base<fcgi_request_service>::impl_base
{
- typedef ::cgi::fcgi_ protocol_type;
+ typedef ::cgi::common::fcgi_ protocol_type;
typedef ::cgi::fcgi::client client_type;
typedef client_type::connection_type connection_type;
typedef client_type::header_buffer_type header_buffer_type;
@@ -80,8 +53,8 @@
implementation_type()
: client_()
, stdin_parsed_(false)
- , http_status_(http::no_content)
- , request_status_(unloaded)
+ , http_status_(::cgi::common::http::no_content)
+ , request_status_(common::unloaded)
, request_role_(spec_detail::ANY)
, all_done_(false)
{
@@ -92,8 +65,8 @@
client_type client_;
bool stdin_parsed_;
- http::status_code http_status_;
- status_type request_status_;
+ ::cgi::common::http::status_code http_status_;
+ common::status_type request_status_;
fcgi::spec_detail::role_t request_role_;
bool all_done_;
@@ -127,7 +100,7 @@
typedef type::implementation_type::protocol_type protocol_type;
typedef type::implementation_type::request_type request_type;
- fcgi_request_service(::cgi::io_service& ios)
+ fcgi_request_service(::cgi::common::io_service& ios)
: detail::service_base<fcgi_request_service>(ios)
{
}
@@ -166,45 +139,14 @@
}
/// Close the request.
- int close(implementation_type& impl, http::status_code& hsc
- , int program_status)
- {
- impl.all_done_ = true;
- impl.client_.close(program_status);
- return program_status;
- }
+ int close(implementation_type& impl, ::cgi::common::http::status_code& hsc
+ , int program_status);
- int close(implementation_type& impl, http::status_code& hsc
- , int program_status, boost::system::error_code& ec)
- {
- impl.all_done_ = true;
- impl.client_.close(program_status, ec);
- return program_status;
- }
+ int close(implementation_type& impl, ::cgi::common::http::status_code& hsc
+ , int program_status, boost::system::error_code& ec);
- void clear(implementation_type& impl)
- {
- BOOST_ASSERT
- ( impl.request_status_ < activated
- && impl.request_status_ > ok
- && "Are you trying to clear() a request without closing it?"
- );
-
- impl.buffer_.clear();
- impl.get_vars().clear();
- impl.post_vars().clear();
- impl.cookie_vars().clear();
- impl.env_vars().clear();
- impl.stdin_parsed_ = false;
- impl.http_status_ = http::no_content;
- impl.request_status_ = null;
- impl.request_role_ = spec_detail::ANY;
- impl.all_done_ = false;
+ void clear(implementation_type& impl);
- impl.client_.status_ = common::none_;
- impl.client_.request_id_ = -1;
- }
-
/// Load the request to a point where it can be usefully used.
/**
* FastCGI:
@@ -217,75 +159,11 @@
*/
boost::system::error_code&
load(implementation_type& impl, bool parse_stdin
- , boost::system::error_code& ec)
- {
- //int header_len( get_length_of_header(impl, ec) );
- BOOST_ASSERT(!ec && "Can't load request due to previous errors.");
-
- impl.client_.construct(impl, ec);
- BOOST_ASSERT(impl.client_.connection_->is_open());
-
- for(;;)
- {
- if (read_header(impl, ec))
- break;
- int id(fcgi::spec::get_request_id(impl.header_buf_));
- if (id == fcgi::spec::null_request_id::value)
- handle_admin_request(impl);
- else
- if (fcgi::spec::get_type(impl.header_buf_)
- == fcgi::spec::begin_request::value)
- {
- impl.id_ = id;
- impl.client_.request_id_ = id;
- if (read_header(impl, ec))
- break;
- impl.request_role_ = fcgi::spec::begin_request::get_role(impl.header_buf_);
- //std::cerr<< "[hw] New request role: " << impl.request_role_
- // << " (" << fcgi::spec::role_type::to_string(impl.header_buf_) << ")"
- // << std::endl;
- impl.client_.keep_connection_
- = fcgi::spec::begin_request::get_flags(impl.header_buf_)
- & fcgi::spec::keep_connection;
- //std::cerr<< "keep connection := " << impl.client_.keep_connection_ << std::endl;
- break;
- }else
- handle_other_request_header(impl);
- }
-
- common::client_status completion_condition
- = parse_stdin ? common::stdin_read : common::params_read;
-
- while(!ec
- && impl.client_.status() < completion_condition
- && impl.request_status_ != loaded)
- {
- //impl.client_.parse_packet(impl, ec);
- parse_packet(impl, ec);
- }
-
- const std::string& request_method = env(impl, "REQUEST_METHOD", ec);
- if (request_method == "GET")
- if (parse_get_vars(impl, ec))
- return ec;
- else
- if (request_method == "POST" && parse_stdin)
- if (parse_post_vars(impl, ec))
- return ec;
-
- parse_cookie_vars(impl, ec);
-
- return ec;
- }
+ , boost::system::error_code& ec);
// **FIXME**
template<typename Handler>
- void async_load(implementation_type& impl, bool parse_stdin, Handler handler)
- {
- this->io_service().post(
- detail::async_load_helper<type, Handler>(this, parse_stdin, handler)
- );
- }
+ void async_load(implementation_type& impl, bool parse_stdin, Handler handler);
role_type get_role(implementation_type& impl)
{
@@ -301,32 +179,12 @@
protected:
/// Read and parse the cgi POST meta variables (greedily)
boost::system::error_code&
- parse_post_vars(implementation_type& impl, boost::system::error_code& ec)
- {
- // Make sure this function hasn't already been called
- //BOOST_ASSERT( impl.post_vars().empty() );
-
- //# error "Not implemented"
-/*
- impl.fp_.reset
- (
- new typename implementation_type::form_parser_type
- ( impl )
- );
- impl.fp_->parse(ec);
-*/
-
- return ec;
- }
+ parse_post_vars(implementation_type& impl, boost::system::error_code& ec);
/// Read and parse a single cgi POST meta variable (greedily)
template<typename RequestImpl>
boost::system::error_code&
- parse_one_post_var(implementation_type& impl, boost::system::error_code& ec)
- {
- //# error "Not implemented"
- return ec;
- }
+ parse_one_post_var(implementation_type& impl, boost::system::error_code& ec);
/***************************************************************************/
public: // Reading stuff goes under here
@@ -336,65 +194,20 @@
template<typename MutableBufferSequence>
std::size_t
read_some(implementation_type& impl, const MutableBufferSequence& buf
- , boost::system::error_code& ec)
- {
- if (impl.client_.status_ == common::closed_)
- {
- ec = error::client_closed;
- return 0;
- }
-
- //if (read_header(ec))
- return -1;
-
- //boost::tribool state = parse_header(impl);
- //std::size_t bytes_read;//( connection_->read_some(buf, ec) );
- //return bytes_read;
- }
-
+ , boost::system::error_code& ec);
+
/// Read a single header, buf do nothing with it.
boost::system::error_code
- read_header(implementation_type& impl, boost::system::error_code& ec)
- {
- // clear the header first (might be unneccesary).
- impl.header_buf_ = implementation_type::header_buffer_type();
-
- if (8 != read(*impl.client_.connection_, buffer(impl.header_buf_)
- , boost::asio::transfer_all(), ec) || ec)
- return ec;
-
- //if (ec) return ec;
-
- /*
- std::cerr<< std::endl
- << "[hw] Header details {" << std::endl
- << " RequestId := " << fcgi::spec::get_request_id(impl.header_buf_) << std::endl
- << " FastCGI version := " << fcgi::spec::get_version(impl.header_buf_) << std::endl
- << " Type := " << fcgi::spec::get_type(impl.header_buf_)
- << " (" << fcgi::spec::request_type::to_string(impl.header_buf_) << ")" << std::endl
- << " Content-length := " << fcgi::spec::get_content_length(impl.header_buf_) << std::endl
- << "}" << std::endl;
- */
-
- return ec;
- }
+ read_header(implementation_type& impl, boost::system::error_code& ec);
/*** Various handlers go below here; they might find a
* better place to live ***/
// **FIXME**
- void handle_admin_request(implementation_type& impl)
- {
- //std::cerr<< std::endl << "**FIXME** " << __FILE__ << ":" << __LINE__
- // << " handle_admin_request()" << std::endl;
- }
+ void handle_admin_request(implementation_type& impl);
// **FIXME**
- void handle_other_request_header(implementation_type& impl)
- {
- //std::cerr<< std::endl << "**FIXME** " << __FILE__ << ":" << __LINE__
- // << " handle_other_request_header()" << std::endl;
- }
+ void handle_other_request_header(implementation_type& impl);
// **FIXME**
boost::system::error_code
@@ -405,140 +218,21 @@
boost::system::error_code
process_abort_request(implementation_type& impl, boost::uint16_t id
, const unsigned char* buf, boost::uint16_t
- , boost::system::error_code& ec)
- {
- if (id == fcgi::spec::get_request_id(impl.header_buf_))
- {
- impl.request_status_ = aborted;
- return ec;
- }
- try {
- //std::cerr<< "**FIXME** request aborted (id = " << id
- // << ") but request not notified." << std::endl;
- //impl.client_.connection_->requests_.at(id - 1)->abort();
- }catch(...){
- ec = error::abort_request_record_recieved_for_invalid_request;
- }
-/*
- connection_type::request_map_type::iterator i
- = connection_->find(id);
-
- if (i == connection_type::request_map_type::iterator())
- {
- return bad_request_id;
- }
-
- //lookup_request(id).abort();
-*/
- return ec;
- }
+ , boost::system::error_code& ec);
boost::system::error_code
process_params(implementation_type& impl, boost::uint16_t id
, const unsigned char* buf, boost::uint16_t len
- , boost::system::error_code& ec)
- {
- if (0 == len)
- { // This is the final param record.
-
- impl.client_.status_ = common::params_read;
-
- //std::cerr<< "[hw] Final PARAM record found." << std::endl;
- return ec;
- }
-
- while(len)
- {
- boost::uint32_t name_len, data_len;
- std::string name, data;
- if (*buf >> 7 == 0)
- {
- name_len = *(buf++);
- --len;
- }
- else
- {
- name_len = ((buf[0] & 0x7F) << 24)
- + (buf[1] << 16)
- + (buf[2] << 8)
- + buf[3];
- buf += 4;
- len -= 4;
- }
-
- if (*buf >> 7 == 0)
- {
- data_len = *(buf++);
- --len;
- }
- else
- {
- data_len = ((buf[0] & 0x7F) << 24)
- + (buf[1] << 16)
- + (buf[2] << 8)
- + buf[3];
- buf += 4;
- len -= 4;
- }
- name.assign(reinterpret_cast<const char*>(buf), name_len);
- data.assign(reinterpret_cast<const char*>(buf)+name_len, data_len);
- buf += (name_len + data_len);
- len -= (name_len + data_len);
-
- //std::cerr<< "[hw] name := " << name << std::endl;
- //std::cerr<< "[hw] data := " << data << std::endl;
-
- // **FIXME**
- impl.env_vars()[name.c_str()] = data;
- }
-
- return ec;
- }
-
+ , boost::system::error_code& ec);
boost::system::error_code
process_stdin(implementation_type& impl, boost::uint16_t id
, const unsigned char* buf, boost::uint16_t len
- , boost::system::error_code& ec)
- {
- if (0 == len)
- {
- impl.client_.status_ = common::stdin_read;
-
- // **FIXME**
- //std::cerr<< "[hw] Final STDIN record found." << std::endl;
- return ec;
- }
-
- // **FIXME**
- //std::cerr<< "[hw] Found some STDIN stuff." << std::endl;
- return ec;
- }
+ , boost::system::error_code& ec);
/// Parse the current header
- boost::tribool parse_header(implementation_type& impl)
- {
- BOOST_ASSERT(fcgi::spec::get_version(impl.header_buf_) == 1
- && "This library is only compatible with FastCGI 1.0");
+ boost::tribool parse_header(implementation_type& impl);
- using namespace fcgi::spec_detail;
-
- switch(fcgi::spec::get_type(impl.header_buf_))
- {
- case BEGIN_REQUEST:
- case PARAMS:
- case STDIN:
- case DATA:
- case GET_VALUES:
- return boost::indeterminate;
- case ABORT_REQUEST:
- return false;
- case UNKNOWN_TYPE:
- default:
- return true;
- }
- }
-
// Mammoth typedef corresponding to function signature of process_*
// functions.
typedef boost::system::error_code
@@ -549,174 +243,34 @@
static const proc_func_t proc_funcs[];
boost::system::error_code
- parse_packet(implementation_type& impl, boost::system::error_code& ec)
- {
- //current_request_ = &req;
-
- if (this->read_header(impl, ec))
- return ec;
-
- boost::tribool state = this->parse_header(impl);
-
- if (state)
- { // the header has been handled and all is ok; continue.
- return ec;
- }else
- if (!state)
- { // The header is confusing; something's wrong. Abort.
- return error::bad_header_type;
- }
- // else route (ie. state == boost::indeterminate)
-
- implementation_type::mutable_buffers_type buf
- = impl.prepare(fcgi::spec::get_length(impl.header_buf_));
-
- if (this->read_body(impl, buf, ec))
- return ec;
-
- this->parse_body(impl, buf, ec);
-
- return ec;
- }
-
+ parse_packet(implementation_type& impl, boost::system::error_code& ec);
+
/// Read the body of the current packet; do nothing with it.
template<typename MutableBuffersType>
boost::system::error_code
read_body(implementation_type& impl, const MutableBuffersType& buffer
- , boost::system::error_code& ec)
- {
- std::size_t bytes_read
- = read(*impl.client_.connection_, buffer, boost::asio::transfer_all(), ec);
-
- BOOST_ASSERT(bytes_read == fcgi::spec::get_length(impl.header_buf_)
- && "Couldn't read all of the record body.");
- return ec;
- }
+ , boost::system::error_code& ec);
template<typename MutableBuffersType>
boost::system::error_code
parse_body(implementation_type& impl, const MutableBuffersType& buffer
- , boost::system::error_code& ec)
- {
- return
- (this->* proc_funcs[fcgi::spec::get_type(impl.header_buf_)])
- (impl, fcgi::spec::get_request_id(impl.header_buf_)
- , boost::asio::buffer_cast<unsigned char*>(buffer)
- , boost::asio::buffer_size(buffer), ec);
- }
-
+ , boost::system::error_code& ec);
boost::system::error_code
begin_request_helper(implementation_type& impl
, implementation_type::header_buffer_type& header
- , boost::system::error_code& ec)
- {
- impl.client_.request_id_ = fcgi::spec::get_request_id(header);
-
- BOOST_STATIC_ASSERT((
- fcgi::spec::begin_request::body::size::value
- == fcgi::spec::header_length::value));
-
- // A begin request body is as long as a header, so we can optimise:
- if (read_header(impl, ec))
- return ec;
-
- impl.request_role_
- = fcgi::spec::begin_request::get_role(impl.header_buf_);
- // **FIXME** (rm impl.request_role_)
- impl.client_.role_ = impl.request_role_;
- impl.client_.keep_connection_
- = fcgi::spec::begin_request::get_flags(impl.header_buf_)
- & fcgi::spec::keep_connection;
- impl.client_.status_ = common::constructed;
-
- return ec;
- }
+ , boost::system::error_code& ec);
};
- //template<>
- const fcgi_request_service::proc_func_t fcgi_request_service::proc_funcs[] =
- { 0
- , &fcgi_request_service::process_begin_request
- , &fcgi_request_service::process_abort_request
- , 0
- , &fcgi_request_service::process_params
- , &fcgi_request_service::process_stdin
- , 0
- , 0
- };
-
} // namespace fcgi
} // namespace cgi
#include "boost/cgi/fcgi/request.hpp"
#include "boost/cgi/basic_request.hpp"
-namespace cgi {
- namespace fcgi {
-
- namespace fdetail {
- typedef fcgi_request_service service_type;
- typedef service_type::implementation_type impl_type;
- typedef impl_type::request_type request_type;
- } // namespace detail
-
-/*
- fdetail::request_type&
- get_or_make_request(fdetail::impl_type& impl, boost::uint16_t id)
- {
- fdetail::impl_type::client_type::connection_type::request_vector_type&
- requests = impl.client_.connection_->requests_;
-
- if (!requests.at(id-1))
- {
- if (requests.size() < (id-1))
- requests.resize(id);
- requests.at(id-1) = fdetail::request_type::create(*impl.service_);
- }
-
- return *requests.at(id-1);
- }
-*/
-
- boost::system::error_code
- fdetail::service_type::process_begin_request
- (
- fdetail::impl_type& impl, boost::uint16_t id, const unsigned char* buf
- , boost::uint16_t, boost::system::error_code& ec
- )
- {
- if (impl.client_.request_id_ == 0) // ie. hasn't been set yet.
- {
- begin_request_helper(impl, impl.header_buf_, ec);
- }
- else
- {
- //std::cerr<< "**FIXME** Role: "
- // << fcgi::spec::begin_request::get_role(impl.header_buf_) << std::endl;
-
- fdetail::impl_type::client_type::connection_type&
- conn = *impl.client_.connection_;
-
- if (conn.get_slot(id, ec))
- { // error
- return ec;
- }
-
- // **FIXME** THIS LEAKS MEMORY!!!!!!!
- //requests.at(id-1)
- request_type* new_request = new request_type(impl, ec);
-
- conn.add_request(id, new_request, true, ec);
-
- return ec;//error::multiplexed_request_incoming;
- }
-
- return ec;
- }
-
-
- } // namespace fcgi
-} // namespace cgi
+#if !defined( BOOST_CGI_BUILD_LIB )
+# include "boost/cgi/impl/fcgi_request_service.ipp"
+#endif
#endif // CGI_FCGI_REQUEST_SERVICE_HPP_INCLUDED__
+
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/service.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/fcgi/service.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -9,8 +9,8 @@
#ifndef CGI_FCGI_SERVICE_HPP_INCLUDED__
#define CGI_FCGI_SERVICE_HPP_INCLUDED__
-#include "boost/cgi/tags.hpp"
-#include "boost/cgi/basic_protocol_service.hpp"
+#include "boost/cgi/common/tags.hpp"
+#include "boost/cgi/common/basic_protocol_service.hpp"
namespace cgi {
@@ -19,7 +19,7 @@
namespace fcgi {
// typedef for standard scgi::service (a model of ProtocolService)
- typedef ::cgi::common::basic_protocol_service< ::cgi::fcgi_> service;
+ typedef ::cgi::common::basic_protocol_service< ::cgi::common::fcgi_> service;
}
} // namespace cgi
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/header.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/header.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,134 +0,0 @@
-// -- header.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_HEADER_HPP_INCLUDED__
-#define CGI_HEADER_HPP_INCLUDED__
-
-#include <string>
-#include <boost/lexical_cast.hpp>
-
-namespace cgi {
- namespace common {
-
- //template<typename StringT = std::string>
- struct header
- {
- typedef std::string string_type;
-
- header()
- : content()
- {
- }
-
-
- /// Templated constructor to allow user-defined types to be converted
- //template<typename T>
- //header(T& t)
- // : content(t.to_string())
- //{
- //}
-
-
- //template<>
- header(const string_type& _content)
- : content(_content)
- {
- }
-
- header(const string_type& name, const string_type& val)
- : content(name + ": " + val)
- {
- }
-
- //header(const std::string& name, const std::string& val)
- // : content(name + ": " + val)
- //{
- //}
-
- /// Construct an header from a cookie.
- template<typename T>
- header(const basic_cookie<T>& ck)
- : content("Set-cookie: " + ck.to_string())
- {
- }
-
- string_type content;
-
- };
-
-/*
- template<typename StringT>
- header<StringT>
- make_header(const StringT& name, const StringT& val)
- {
- return basic_header<StringT>(name, val);
- }* /
-
- template<typename T, typename StringT>
- T make_header(const StringT& name, const StringT& val)
- {
- return basic_header<StringT>(name, val);
- }*/
-
-
- //{ Some shortcuts, to cut down on typing errors.
- template<typename StringT>
- header
- content_type(StringT str)
- {
- return header("Content-type", str);
- }
-
- template<typename StringT>
- header
- content_encoding(const StringT& str)
- {
- return header("Content-encoding", str);
- }
-
- template<typename T>
- header
- content_length(const T& t)
- {
- return header("Content-length", boost::lexical_cast<std::string>(t));
- }
-
- template<typename T, typename Traits, typename Alloc>
- header
- content_length(const std::basic_string<T, Traits, Alloc>& str)
- {
- return header("Content-length", str);
- }
-/*
- template<typename StringT>
- header<StringT>
- location(const StringT& url)
- {
- return header<StringT>("Location", url);
- }
-
- header<std::string>
- location(const std::string& url)
- {
- return header<std::string>("Location", url);
- }*/
- //template<typename T>
- header location(const std::string& url)
- {
- return header("Location", url);
- }
- //}
-
- // typedefs for typical usage
- //typedef basic_header<std::string> header;
- //typedef basic_header<std::wstring> wheader;
-
- } // namespace common
-} // namespace cgi
-
-#endif // CGI_HEADER_HPP_INCLUDED__
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/http/status_code.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/http/status_code.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/http/status_code.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -10,77 +10,82 @@
#define CGI_HTTP_STATUS_CODE_HPP_INCLUDED__
namespace cgi {
- namespace http {
+ namespace common {
+ namespace http {
- /// Standard HTTP status codes
- /**
- * See http://tools.ietf.org/html/rfc2616#section-10
- */
- enum status_code
- {
- /// Informational codes
- continue_ = 100, // note the trailing underscore
- switching_protocols,
- processing,
-
- /// 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
- };
+ /// Standard HTTP status codes
+ /**
+ * See http://tools.ietf.org/html/rfc2616#section-10
+ */
+ enum status_code
+ {
+ /// Informational codes
+ continue_ = 100, // note the trailing underscore
+ switching_protocols,
+ processing,
+
+ /// 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 common
+
+ using namespace common::http; // **FIXME**
- } // namespace http
} // namespace cgi
#endif // CGI_HTTP_STATUS_CODE_HPP_INCLUDED__
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/io_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/io_service.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,30 +0,0 @@
-// -- 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__
-
-//#if _MSC_VER > 1020
-//#pragma once
-//#endif
-
-#include <boost/asio/io_service.hpp>
-
-namespace cgi {
- namespace common {
-
- using boost::asio::io_service;
-
- } // namespace common
-
- // This should go?
- using boost::asio::io_service;
-
-} // namespace cgi
-
-#endif // CGI_IO_SERVICE_HPP_INCLUDED__
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/io_service_provider.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/io_service_provider.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,277 +0,0 @@
-// -- 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__
-
-#if _MSC_VER > 1020
-#pragma once
-#endif
-
-#include "boost/cgi/detail/push_options.hpp"
-
-//#include <list>
-//#include <boost/ref.hpp>
-//#include <boost/bind.hpp>
-//#include <boost/thread.hpp>
-//#include <boost/shared_ptr.hpp>
-#include <boost/noncopyable.hpp>
-
-#include "boost/cgi/io_service.hpp"
-#include "boost/cgi/io_service_provider_fwd.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<typename PoolingPolicy>
- class io_service_provider
- : private boost::noncopyable
- {
- public:
- io_service_provider(int)
- : io_service_()
- {
- }
-
- io_service_provider()
- : io_service_()
- {
- }
-
- ::cgi::common::io_service&
- get_io_service()
- {
- return io_service_;
- }
-
- void run()
- {
- io_service_.run();
- }
-
- void stop()
- {
- io_service_.stop();
- }
-
- void reset()
- {
- io_service_.reset();
- }
- private:
- ::cgi::common::io_service io_service_;
- };
-
-
- /*
- template<>
- class io_service_provider<tags::service_pool>
- {
- public:
- typedef std::list<cgi::io_service> impl_type;
-
- io_service_provider(int pool_size)
- : io_services_(pool_size)
- , current_(io_services_.begin())
- {
- }
-
- cgi::io_service& io_service()
- {
- return *current_++;
- }
-
- void run()
- {
- std::for_each(io_services_.begin(), io_services_.end()
- , boost::bind(&cgi::io_service::run, boost::ref(_1)));
- }
-
- void stop()
- {
- std::for_each(io_services_.begin(), io_services_.end()
- , boost::bind(&cgi::io_service::stop, boost::ref(_1)));
- }
-
- void reset()
- {
- std::for_each(io_services_.begin(), io_services_.end()
- , boost::bind(&cgi::io_service::reset, boost::ref(_1)));
- }
-
- impl_type& impl()
- {
- return io_services_;
- }
-
- private:
- impl_type io_services_;
- impl_type::iterator current_;
- };
- */
-
- /// 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
-
-#include "boost/cgi/detail/pop_options.hpp"
-
-#endif // CGI_IO_SERVICE_PROVIDER_HPP_INCLUDED__
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/io_service_provider_fwd.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/io_service_provider_fwd.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,25 +0,0 @@
-// -- 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__
-
-#if _MSC_VER > 1020
-#pragma once
-#endif
-
-#include "boost/cgi/tags.hpp"
-
-namespace cgi {
-
- template<typename = tags::single_service>
- class io_service_provider;
-
-} // namespace cgi
-
-#endif // CGI_IO_SERVICE_PROVIDER_FWD_HPP_INCLUDED__
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/is_async.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/is_async.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,32 +0,0 @@
-// -- is_async.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_IS_ASYNC_HPP_INCLUDED__
-#define CGI_IS_ASYNC_HPP_INCLUDED__
-
-#include <boost/mpl/bool.hpp>
-
-#include "tags.hpp"
-
-namespace cgi {
-
- template<typename Protocol>
- struct is_async
- : boost::mpl::bool_<true>::type
- {
- };
-
- template<>
- struct is_async<tags::cgi>
- : boost::mpl::bool_<false>::type
- {
- };
-
-} // namespace cgi
-
-#endif // CGI_IS_ASYNC_HPP_INCLUDED__
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/map.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/map.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,16 +0,0 @@
-// -- map.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_MAP_HPP_INCLUDED__
-#define CGI_MAP_HPP_INCLUDED__
-
-#warning This file is deprecated, use common/map.hpp instead.
-
-#include "boost/cgi/common/map.hpp"
-
-#endif // CGI_MAP_HPP_INCLUDED__
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/read.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/read.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,24 +0,0 @@
-// -- 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 {
- namespace common {
-
- using boost::asio::read;
- using boost::asio::async_read;
-
- } // namespace common
-} // namespace cgi
-
-#endif // CGI_READ_HPP_INCLUDED
-
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/request.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/request.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,21 +0,0 @@
-// -- 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_REQUEST_HPP_INCLUDED__
-#define CGI_REQUEST_HPP_INCLUDED__
-
-#include "basic_request.hpp"
-#include "tags.hpp"
-
-namespace cgi {
-
- typedef basic_request<tags::cgi> request;
-
-} // namespace cgi
-
-#endif // CGI_REQUEST_HPP_INCLUDED__
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/request_acceptor_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/request_acceptor_service.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,101 +0,0 @@
-// -- request_acceptor_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_REQUEST_ACCEPTOR_SERVICE_HPP_INCLUDED
-#define CGI_REQUEST_ACCEPTOR_SERVICE_HPP_INCLUDED
-
-#include "detail/throw_error.hpp"
-#include "detail/protocol_traits.hpp"
-#include "detail/service_base.hpp"
-
-namespace cgi {
-
- template<typename Protocol>
- class request_acceptor_service
- : public detail::service_base<request_acceptor_service<Protocol> >
- {
- typedef detail::protocol_traits<Protocol>::acceptor_service_impl
- service_impl_type;
- public:
- typedef typename service_impl_type::impl_type implementation_type;
- typedef Protocol protocol_type;
-
- request_acceptor_service(basic_protocol_service<protocol_type>& s)
- : detail::service_base<request_acceptor_service<Protocol>(s.io_service())
- {
- }
-
- void shutdown_service()
- {
- }
-
- void construct(implementation_type& impl)
- {
- service_impl_.construct(impl);
- }
-
- void destroy(implementation_type& impl)
- {
- service_impl_.destroy(impl);
- }
-
- /// Accept a request
- /**
- * Check if there is a waiting request in the queue. If not, accept a
- * connection, and associate it with the request.
- */
- template<typename CommonGatewayRequest>
- boost::system::error_code&
- accept(implementation_type& impl, CommonGatewayRequest& request
- , boost::system::error_code& ec)
- {
- return service_impl_.accept(impl, request, ec);
- /*
- boost::thread::mutex::scoped_lock lk(io_service_.mutex_);
- if( !io_service_.request_queue_.empty() )
- {
- request = pservice_.request_queue_.front();
- pservice_.request_queue_.pop();
-
- return ec;
- }
- lk.unlock();
- pservice_.gateway_.accept(&request.connection(), ec);
-
- return ec;
- */
- }
-
- /// Asynchronously accept a request
- template<typename CommonGatewayRequest, typename Handler>
- void async_accept(implementation_type& impl, CommonGatewayRequest& request
- , Handler handler)
- {
- service_impl_.async_accept(impl, request, handler);
- /*
- boost::thread::mutex::scoped_lock lk(io_service_.mutex_);
- if( !io_service_.request_queue_.empty() )
- {
- request = pservice_.request_queue_.front();
- pservice_.request_queue_.pop();
-
- return ec;
- }
- lk.unlock();
- pservice_.gateway_.async_accept(request.connection(), handler);
- */
- }
-
- private:
- service_impl_type& service_impl_;
- // basic_protocol_service<protocol_type>& pservice_;
- };
-
-} // namespace cgi
-
-#endif // CGI_REQUEST_ACCEPTOR_SERVICE_HPP_INCLUDED
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/request_base.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/request_base.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,103 +0,0 @@
-#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
- /**
- * This class also allows for the general (rather than generic) verision
- * of cgi::request, which can take any type of request.
- */
- class request_base
- {
- public:
- /// Notify the server that the request has been handled
- /**
- * Under normal circumstances {{ideally}}, this won't be called internally
- * but a user may safely call it anyway, if (for example) they have a lot
- * of post-request-handling housekeeping to do but want the server to
- * finish with that request.
- *
- * @param return_code This is equivalent to the return value from main() in
- * a standard cgi library, or sub_main() in the provided examples. 0 should
- * denote success, anything else an error, however the number will
- * generally be ignored by the server.
- */
- //virtual void end( int return_code ) = 0;
-
- /// Returns the number of bytes available in the read buffer
- //virtual std::size_t available() = 0;
-
- /// Get the streambuf associated with the request
- /**
- * You may want to construct your own i/ostream instead of using the
- * request directly.
- *
- * @note You should NOT use std::cout/std::cin for writes, as they are
- * not thread aware and in some cases won't exist (eg. in a strict fastcgi
- * impletentation).
- *
- * {{should this return an asio::streambuf instead?}}
- */
- //virtual std::streambuf* rdbuf() = 0;
-
- /// Flush the output buffer now
- /**
- * Since the output for a request is buffered until the request has
- * completed (see Design notes), under low-memory or large-output
- * conditions, incrementally flushing the buffer may be necessary
- *
- * @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;
-
- /// Write a message to the error output
- /**
- * In a standard cgi program, this is equivalent to writing to std::cerr,
- * which should be closed in fastcgi (although many implementations leave
- * it writable). In order to write an error message in a cross-platform
- * way, you should use this function.
- *
- * @note On Apache and lighttpd the messages are appended to the server
- * log file, although there is no guarantee that other platforms will
- * recognise it.
- */
- //virtual void log( const std::string& error_message ) = 0;
-
- /// Get the role of the current request
- /**
- * The FastCGI 1.0 protocol specifies three types of request:
- *
- * @li Responder: the familiar type
- *
- * @li Authorizer: the server provides client information and the
- * application responds with a true/false response, plus optional data
- * about where to redirect the client and with what extra variables
- *
- * @li Filter: the program is provided with data and a file, which it is
- * expected to 'filter' and then return to the server. This is poorly
- * supported in production servers {{AFAIK}}
- */
- //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, error_code&) = 0;
-
- protected:
- /// Prevent deletion through this type
- ~request_base()
- {
- }
- };
-
-} // namespace cgi
-
-#endif // CGI_REQUEST_BASE_HPP_INCLUDE_
-
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/request_ostream.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/request_ostream.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,368 +0,0 @@
-// -- 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__
-
-#if 0
-
-// THIS FILE ISN'T USED!
-// **FIXME**
-
-/*********************************
-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 "detail/push_options.hpp"
-
-#include <ostream>
-#include <sstream>
-#include <vector>
-//#include <streambuf>
-#include <boost/assert.hpp>
-#include <boost/bind.hpp>
-#include <boost/shared_ptr.hpp>
-#include <boost/system/error_code.hpp>
-#include <boost/asio.hpp>
-
-#include "streambuf.hpp"
-#include "buffer.hpp"
-#include "write.hpp"
-#include "tags.hpp"
-#include "data_sink.hpp"
-#include "request_base.hpp"
-#include "basic_request.hpp"
-#include "http/status_code.hpp"
-//#include "detail/take_buffer.hpp"
-
-namespace cgi {
-
- /* Notes
- * -----
- *
- * The constructor could take an additional bool which determines
- * if any default headers are prepended to the message on sending
- * eg. 'Content-type: text/plain' could by default be added, making
- * the entry barrier lower and testing simpler.
- */
-
-
- /// 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
- request_ostream(http::status_code sc = http::ok)
- : buffer_(new ::cgi::streambuf())
- , ostream_(buffer_.get())
- , http_status_(sc)
- , headers_sent_(false)
- {
- }
-
- /// 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)
- {
- }
-
- /// 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();
- headers_.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 ConstBufferSequence>
- std::size_t write(const ConstBufferSequence& 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)
- {
- if (!headers_sent_)
- {
- ostream_<< "Content-type: text/plain\r\n\r\n";
- headers_sent_ = true;
- }
- ::cgi::write(req, headers_);
- ::cgi::write(req, rdbuf()->data());
- // 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 (!headers_sent_)
- {
- ostream_<< "Content-type: text/plain\r\n\r\n";
- headers_sent_ = true;
- }
- if(!::cgi::write(req, rdbuf()->data(), ec))
- clear();
- return ec;
- }
-
- // Class for doing post-flush housekeeping (ie. clearing the stream data)
- 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)
- {
- if (!headers_sent_)
- {
- ostream_<< "Content-type: text/plain\r\n\r\n";
- headers_sent_ = true;
- }
- ::cgi::async_write(req, rdbuf()->data()
- , 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)
- {
- if (!headers_sent_)
- {
- ostream_<< "Content-type: text/plain\r\n\r\n";
- headers_sent_ = true;
- }
- ::cgi::write(req.client(), rdbuf()->data());
- 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)
- {
- if (!headers_sent_)
- {
- ostream_<< "Content-type: text/plain\r\n\r\n";
- headers_sent_ = true;
- }
- ::cgi::write(req.client(), rdbuf()->data(), ec);
- 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_);
- if (!headers_sent_)
- {
- ostream_<< "Content-type: text/plain\r\n\r\n";
- headers_sent_ = true;
- }
- ::cgi::async_write(req, rdbuf()->data(), handler);
- }
-
- /// Get the buffer associated with the stream
- ::cgi::streambuf*
- rdbuf()
- {
- return static_cast<::cgi::streambuf*>(ostream_.rdbuf());
- }
-
- void set_status(const http::status_code& num)
- {
- http_status_ = num;
- }
-
- http::status_code& get_status()
- {
- return http_status_;
- }
-
- protected:
- std::vector<boost::asio::const_buffer> headers_;
- boost::shared_ptr<::cgi::streambuf> buffer_;
- std::ostream ostream_;
- http::status_code http_status_;
- bool headers_sent_;
-
- 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.ostream_<< t;
- return os;
- }
-
-} // namespace cgi
-
-#include "boost/cgi/detail/pop_options.hpp"
-
-#endif
-
-#endif // CGI_REQUEST_OSTREAM_HPP_INCLUDED__
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/request_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/request_service.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,168 +0,0 @@
-// -- 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
-// http://www.boost.org/LICENSE_1_0.txt)
-//
-////////////////////////////////////////////////////////////////
-#ifndef CGI_REQUEST_SERVICE_HPP_INCLUDED
-#define CGI_REQUEST_SERVICE_HPP_INCLUDED
-
-#include "boost/cgi/detail/push_options.hpp"
-
-#include <boost/utility/enable_if.hpp>
-
-//#include "is_async.hpp"
-#include "boost/cgi/io_service.hpp"
-#include "boost/cgi/detail/protocol_traits.hpp"
-#include "boost/cgi/basic_protocol_service_fwd.hpp"
-#include "boost/cgi/detail/service_base.hpp"
-//#include "service_selector.hpp"
-
-namespace cgi {
- namespace common {
-
- /// 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
- : public detail::service_base<request_service<Protocol> >
- {
- // The platform-specific implementation (only one for now)
- typedef typename detail::protocol_traits<Protocol>::request_service_impl
- service_impl_type;
-
- public:
- typedef typename service_impl_type::impl_type impl_type;
- typedef typename
- service_impl_type::implementation_type implementation_type;
- typedef Protocol protocol_type;
- typedef common::basic_protocol_service<Protocol> protocol_service_type;
-
- /// The unique service identifier
- //static boost::asio::io_service::id id;
- //explicit request_service()
- //{
- //}
-
- request_service(::cgi::io_service& ios)
- : detail::service_base<request_service<Protocol> >(ios)
- , service_impl_(boost::asio::use_service<service_impl_type>(ios))
- {
- }
-
- request_service(protocol_service_type& ps)
- : detail::service_base<request_service<Protocol> >(ps.io_service())
- , service_impl_(boost::asio::use_service<service_impl_type>(ps.io_service()))
- {
- }
-
- void construct(impl_type& impl)
- {
- service_impl_.construct(impl);
- }
-
- void destroy(impl_type& impl)
- {
- service_impl_.destroy(impl);
- }
-
- void shutdown_service()
- {
- service_impl_.shutdown_service();
- }
-
- impl_type null() const
- {
- return service_impl_.null();
- }
-
- //void construct
-
- boost::system::error_code&
- load(impl_type& impl, bool parse_stdin, boost::system::error_code& ec)
- {
- return service_impl_.load(impl, parse_stdin, ec);
- }
-
-
- template<typename Handler>
- void async_load(impl_type& impl, bool parse_stdin, Handler handler)
- {
- service_impl_.async_load(impl, parse_stdin, handler);
- }
-
- bool is_open(impl_type& impl)
- {
- return service_impl_.is_open(impl);
- }
-
- boost::system::error_code&
- set_header(impl_type& impl, const std::string& name
- , const std::string& value, boost::system::error_code& ec)
- {
- return service_impl_.set_header(impl, name, value, ec);
- }
-
-/*
- template<typename ConstBufferSequence>
- std::size_t write_some(impl_type& impl, const ConstBufferSequence& buf
- , boost::system::error_code& ec)
- {
- return service_impl_.write_some(impl, buf, ec);
- }
-
- template<typename MutableBufferSequence>
- std::size_t read_some(impl_type& impl, MutableBufferSequence buf
- , boost::system::error_code& ec)
- {
- return service_impl_.read_some(impl, buf, ec);
- }
-*/
- std::string
- GET(impl_type& impl, const std::string& name
- , boost::system::error_code& ec)
- {
- return service_impl_.GET(impl, name, ec);
- }
-
- std::string
- POST(impl_type& impl, const std::string& name
- , boost::system::error_code& ec)
- {
- return service_impl_.POST(impl, name, ec);
- }
-
- std::string
- cookie(impl_type& impl, const std::string& name
- , boost::system::error_code& ec)
- {
- return service_impl_.cookie(impl, name, ec);
- }
-
- /*
- std::string
- header(impl_type& impl, const std::string& name
- , boost::system::error_code& ec)
- {
- return "";
- }
-*/
-
- private:
- service_impl_type& service_impl_;
- };
-
- } // namespace common
-} // namespace cgi
-
-#include "boost/cgi/detail/pop_options.hpp"
-
-#endif // CGI_REQUEST_SERVICE_HPP_INCLUDED
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/request_service_fwd.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/request_service_fwd.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,28 +0,0 @@
-// -- 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
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/response.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/response.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,447 +0,0 @@
-// -- response.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_RESPONSE_HPP_INCLUDED__
-#define CGI_RESPONSE_HPP_INCLUDED__
-
-#include "boost/cgi/detail/push_options.hpp"
-
-#include <string>
-#include <fstream> // only for testing
-
-#include <boost/foreach.hpp>
-#include <boost/bind.hpp>
-
-//#include "boost/cgi/request_ostream.hpp"
-#include "boost/cgi/buffer.hpp"
-#include "boost/cgi/cookie.hpp"
-#include "boost/cgi/header.hpp"
-#include "boost/cgi/write.hpp"
-#include "boost/cgi/basic_request_fwd.hpp"
-#include "boost/cgi/http/status_code.hpp"
-#include "boost/cgi/streambuf.hpp"
-#include "boost/cgi/detail/throw_error.hpp"
-
-/// This mess outputs a default Content-type header if the user hasn't set any.
-/** **FIXME** Not implemented; not sure if it should be...
- * BOOST_CGI_ADD_DEFAULT_HEADER should not persiste beyond this file.
- *
- * It basically works like (default first):
- *
- * Debug mode:
- * - Append a "Content-type: text/plain" header;
- * - If BOOST_CGI_DEFAULT_CONTENT_TYPE is defined, set that as the
- * content-type;
- * - If BOOST_CGI_NO_DEFAULT_CONTENT_TYPE is defined, do nothing.
- *
- * Release mode:
- * - Do nothing.
- */
-#if !defined(NDEBUG) && !defined(BOOST_CGI_NO_DEFAULT_CONTENT_TYPE)
-//{
-# if !defined(BOOST_CGI_DEFAULT_CONTENT_TYPE)
-# define BOOST_CGI_DEFAULT_CONTENT_TYPE "Content-type: text/plain"
-# endif // !defined(BOOST_CGI_DEFAULT_CONTENT_TYPE)
-//}
-# define BOOST_CGI_ADD_DEFAULT_HEADER \
- if (headers_.empty()) \
- headers_.push_back(BOOST_CGI_DEFAULT_CONTENT_TYPE"\r\n");
-#else
-# define BOOST_CGI_ADD_DEFAULT_HEADER
-#endif // !defined(NDEBUG) && !defined(BOOST_CGI_NO_DEFAULT_CONTENT_TYPE)
-
-
-namespace cgi {
- namespace common {
-
- /// The response class: a helper for responding to requests.
- class response
- {
- public:
- typedef std::ostream ostream_type;
-
- response(http::status_code sc = http::ok)
- : buffer_(new ::cgi::streambuf())
- , ostream_(buffer_.get())
- , http_status_(sc)
- , headers_terminated_(false)
- {
- }
-
- /// Construct with a particular buffer
- /**
- * Takes the buffer and uses it internally, does nothing with it on
- * destruction.
- */
- response(::cgi::streambuf* buf, http::status_code sc = http::ok)
- : /*request_(NULL)
- , */ostream_(buf)
- , http_status_(sc)
- {
- }
-
- ~response()
- {
- }
-
- /// Clear the response buffer.
- void clear()
- {
- ostream_.clear();
- headers_.clear();
- headers_terminated_ = false;
- //buffer_->consume(
- }
-
- /// Return the response to the 'just constructed' state.
- void reset()
- {
- clear();
- headers_terminated_ = false;
- }
-
- // 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 ConstBufferSequence>
- std::size_t write(const ConstBufferSequence& buf)
- {
- return ostream_.write(buf.begin(), buf.end());
- //return buf.size();
- }
-
- /// Synchronously flush the data to the supplied SyncWriteStream
- /**
- * 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 SyncWriteStream>
- void flush(SyncWriteStream& sws)
- {
- boost::system::error_code ec;
- flush(sws, ec);
- detail::throw_error(ec);
- }
-
- /// 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 SyncWriteStream>
- boost::system::error_code
- flush(SyncWriteStream& sws, boost::system::error_code& ec)
- {
- if (!headers_terminated_)
- {
- std::vector<boost::asio::const_buffer> headers;
- prepare_headers(headers);//, ec);
- common::write(sws, headers, boost::asio::transfer_all(), ec);
- if (ec)
- return ec;
- }
-
- std::size_t bytes_written
- = common::write(sws, buffer_->data(), boost::asio::transfer_all(), ec);
- if (!ec)
- buffer_->consume(bytes_written);
-
- 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 SyncWriteStream>
- void send(SyncWriteStream& sws)
- {
- boost::system::error_code ec;
- send(sws, ec);
- detail::throw_error(ec);
- }
-
- /// Synchronously send the data via the supplied request.
- /**
- * This call will not throw, but will set `ec` such that `ec == true` if
- * an error occurs. Details of the error are held in the `error_code`
- * object.
- */
- template<typename SyncWriteStream>
- boost::system::error_code
- send(SyncWriteStream& sws, boost::system::error_code& ec)
- {
- if (!headers_terminated_)
- {
- /* Not sure if streambuf allows this
- *
- // We want to be able to keep adding to a response, calling send() on
- // it whenever, without resending the headers. Call resend() if you
- // want to send the whole response again.
- headers_terminated_ = true;
- */
- std::vector<boost::asio::const_buffer> headers;
- prepare_headers(headers);//, ec)
- common::write(sws, headers, boost::asio::transfer_all(), ec);
- }
-
- common::write(sws, buffer_->data(), boost::asio::transfer_all(), ec);
-
- return ec;
- }
-
- /// Resend headers + content regardless of value of `headers_terminated_`.
- template<typename SyncWriteStream>
- void resend(SyncWriteStream& sws)
- {
- std::vector<boost::asio::const_buffer> headers;
- prepare_headers(headers);//, ec)
- common::write(sws, headers);
-
- common::write(sws, buffer_->data());
- }
-
- /// Asynchronously send the data through the supplied request
- /**
- * Note: This is quite crude at the moment and not as asynchronous as
- * it could/should be. The data in the stream isn't cleared after
- * this call.
- */
- template<typename AsyncWriteStream, typename Handler>
- void async_send(AsyncWriteStream& aws, Handler handler)
- {
- aws.io_service().post(
- boost::bind(&response::do_async_send, aws, handler)
- );
- }
-
- template<typename AsyncWriteStream, typename Handler>
- void do_async_send(AsyncWriteStream& aws, Handler handler)
- {
-
-
- //req.set_status(http_status_);
- /*
- if (!headers_terminated_)
- {
- ostream_<< "Content-type: text/plain\r\n\r\n";
- headers_terminated_ = true;
- }
- */
- common::async_write(aws, rdbuf()->data(), handler);
- }
-
- /// Get the buffer associated with the stream
- common::streambuf*
- rdbuf()
- {
- return static_cast<common::streambuf*>(ostream_.rdbuf());
- }
-
- /// Set the status code associated with the response.
- response& set_status(const http::status_code& num)
- {
- http_status_ = num;
- return *this;
- }
-
- /// Get the status code associated with the response.
- http::status_code& status()
- {
- return http_status_;
- }
-
- /// Allow more headers to be added (WARNING: avoid using this).
- void unterminate_headers()
- {
- headers_terminated_ = false;
- }
-
- /// Get the length of the body of the response
- std::size_t content_length()
- {
- return rdbuf()->size();
- }
-
- /// Add a header after appending the CRLF sequence.
- response& set_header(const std::string& value)
- {
- BOOST_ASSERT(!headers_terminated_);
- headers_.push_back(value + "\r\n");
- return *this;
- }
-
- /// Format and add a header given name and value, appending CRLF.
- response& set_header(const std::string& name, const std::string& value)
- {
- BOOST_ASSERT(!headers_terminated_);
- headers_.push_back(name + ": " + value + "\r\n");
- return *this;
- }
-
- void clear_headers()
- {
- BOOST_ASSERT(!headers_terminated_);
- headers_.clear();
- }
-
- void reset_headers()
- {
- headers_.clear();
- headers_terminated_ = false;
- }
-
- bool headers_terminated() const
- {
- return headers_terminated_;
- }
- protected:
- // Vector of all the headers, each followed by a CRLF
- std::vector<std::string> headers_;
-
- // The buffer is a shared_ptr, so you can keep it cached elsewhere.
- boost::shared_ptr<common::streambuf> buffer_;
-
- ostream_type ostream_;
-
- http::status_code http_status_;
-
- // True if no more headers can be appended.
- bool headers_terminated_;
-
- template<typename T>
- friend response& operator<<(response& resp, const T& t);
-
- //template<typename A, typename B>
- //friend A& operator<<(A& resp, B b);
-
- private:
-
- // Send the response headers and mark that they've been sent.
- template<typename ConstBufferSequence>
- //boost::system::error_code
- void
- prepare_headers(ConstBufferSequence& headers)//, boost::system::error_code& ec)
- {
- BOOST_CGI_ADD_DEFAULT_HEADER
-
- // Terminate the headers.
- if (!headers_terminated_)
- headers_.push_back("\r\n");
-
- //{ Construct a ConstBufferSequence out of the headers we have.
- //std::vector<boost::asio::const_buffer> headers;
- typedef std::vector<std::string>::iterator iter;
- for (iter i(headers_.begin()), e(headers_.end()); i != e; ++i)
- {
- headers.push_back(common::buffer(*i));
- }
- //}
-
- headers_terminated_ = true;
- //return ec;
- }
- };
-
- /// Generic ostream template
- template<typename T>
- response& operator<<(response& resp, const T& t)
- {
- resp.ostream_<< t;
- return resp;
- }
-
- /// You can stream a cgi::header into a response.
- /**
- * This is just a more convenient way of doing:
- *
- * ``
- * resp.set_header(header_content)
- * ``
- *
- * [tip
- * If you stream a default-constructed header to a response, it
- * 'terminates' the headers. ie. You can do this if you want to ensure
- * 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)
- {
- if (hdr.content.empty()) {
- resp.headers_terminated_ = true;
- return resp;
- }else{
- // We shouldn't allow headers to be sent after they're explicitly ended.
- BOOST_ASSERT(!resp.headers_terminated_);
- resp.set_header(hdr.content);
- return resp;
- }
- }*/
-
- template<>
- response& operator<<(response& resp, const ::cgi::common::header& hdr)
- {
- if (hdr.content.empty()) {
- resp.headers_terminated_ = true;
- return resp;
- }else{
- // We shouldn't allow headers to be sent after they're explicitly ended.
- BOOST_ASSERT(!resp.headers_terminated_);
- resp.set_header(hdr.content);
- return resp;
- }
- }
-
- /// You can stream a cgi::cookie into a response.
- /**
- * This is just a shorthand way of setting a header that will set a
- * client-side cookie.
- *
- * You cannot stream a cookie to a response after the headers have been
- * terminated. In this case, an alternative could be to use the HTML tag:
- * <meta http-equiv="Set-cookie" ...> (see http://tinyurl.com/3bxftv or
- * http://tinyurl.com/33znkj), but this is outside the scope of this
- * library.
- */
- template<typename T>
- response& operator<<(response& resp, basic_cookie<T> ck)
- {
- BOOST_ASSERT(!resp.headers_terminated());
- resp.set_header("Set-cookie", ck.to_string());
- return resp;
- }
-
- template<typename T>
- response& operator<<(response& resp, http::status_code status)
- {
- BOOST_ASSERT(!resp.headers_terminated());
- return resp.set_status(status);
- }
-
- } // namespace common
-} // namespace cgi
-
-#undef BOOST_CGI_ADD_DEFAULT_HEADER
-
-#include "boost/cgi/detail/pop_options.hpp"
-
-#endif // CGI_RESPONSE_HPP_INCLUDED__
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/return.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/return.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,54 +0,0 @@
-// -- return.hpp --
-//
-// Copyright (c) Darren Garvey 2007.
-// Distributed under the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-//
-////////////////////////////////////////////////////////////////
-#ifndef CGI_RETURN_HPP_INCLUDED__
-#define CGI_RETURN_HPP_INCLUDED__
-
-#include "boost/cgi/response.hpp"
-#include "boost/cgi/basic_request.hpp"
-
-namespace cgi {
- namespace common {
-
- template<typename Response, typename Request>
- boost::system::error_code
- return_helper(Response& resp, Request& req, int program_status)
- {
- boost::system::error_code ec;
- resp.send(req.client(), ec);
- if (ec) return ec;
-
- req.close(resp.status(), program_status);
-
- return ec;
- }
-
- } // namespace common
-} // namespace cgi
-
-/// If an error occurs during the sending or closing then `status` will be
-// incremented by the value of this macro.
-#ifndef BOOST_CGI_RETURN_ERROR_INCREMENT
-# define BOOST_CGI_RETURN_ERROR_INCREMENT 100
-#endif
-
-#define BOOST_CGI_RETURN(resp, req, status) \
- if ( ::cgi::common::return_helper(resp, req, status)) \
- /** error **/ \
- return status + BOOST_CGI_RETURN_ERROR_INCREMENT; \
- return status;
-
-namespace cgi {
- namespace common {
-
-#define return_(resp, req, status) BOOST_CGI_RETURN(resp, req, status)
-
- } // namespace common
-} // namespace cgi
-
-#endif // CGI_RETURN_HPP_INCLUDED__
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/role_type.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/role_type.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,22 +0,0 @@
-#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
- { none
- , responder
- , authorizer
- , filter
- };
-
-} // namespace cgi
-
-#endif // CGI_ROLE_TYPE_HPP_INCLUDED__
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/status_type.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/status_type.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,26 +0,0 @@
-// -- status_type.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_STATUS_TYPE_HPP_INCLUDED__
-#define CGI_STATUS_TYPE_HPP_INCLUDED__
-
-namespace cgi {
-
- enum status_type
- { null
- , unloaded
- , activated
- , loaded
- , ok = loaded
- , aborted
- , closed
- };
-
-} // namespace cgi
-
-#endif // CGI_STATUS_TYPE_HPP_INCLUDED__
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/streambuf.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/streambuf.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,25 +0,0 @@
-// -- 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 {
- namespace common {
-
- using boost::asio::streambuf;
-
- } // namespace common
-
- using common::streambuf;
-
-} // namespace cgi
-
-#endif // CGI_STREAMBUF_HPP_INCLUDED__
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/tags.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/tags.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,50 +0,0 @@
-// -- 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__
-
-#if _MSC_VER > 1020
-#pragma once
-#endif
-
-namespace cgi {
-
- /// SCGI (note, this must be removed)
- struct scgi_{};
- /// FastCGI
- struct fcgi_{};
-
- 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 PoolingPolicy types
- struct single_service {};
- struct service_pool {};
- struct round_robin {};
-
- // Connection types
- struct stdio {};
- struct async_stdio {};
- struct tcp_socket {};
- // A shareable tcp_socket (ie. one that can be locked)
- struct shareable_tcp_socket {};
-
- } // namespace tags
-} // namespace cgi
-
-#endif // CGI_TAGS_HPP_INCLUDED__
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/write.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/write.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,27 +0,0 @@
-// -- 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 {
- namespace common {
-
- using boost::asio::write;
- using boost::asio::async_write;
-
- } // namespace common
-
- //using common::write;
- //using common::async_write;
-
-} // namespace cgi
-
-#endif // CGI_WRITE_HPP_INCLUDED
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/build/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/build/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/build/Jamfile.v2 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -1,15 +1,61 @@
-# These are some helper variables, which will need to be checked against
-# user-supplied variables (ie. using modules.peek, I think)
+import modules ;
+
+local DEFINES ;
+
+if [ MATCH "^(--build-cgi)" : [ modules.peek : ARGV ] ]
+{ # compile library
+ DEFINES = <define>BOOST_CGI_BUILD_LIB ;
+}
project boost/cgi
- : usage-requirements
+ : build-dir
+ $(top)/bin.v2
+ : requirements
<include>$(top)
<include>$(boost-root)
<library>/boost/thread/
<library>/boost/system/
+ <library>/boost/regex/
<define>_CRT_SECURE_NO_WARNINGS
<define>_SCL_SECURE_NO_WARNINGS
+ $(DEFINES)
+ : usage-requirements
+ <include>$(top)
+ <include>$(boost-root)
+ <library>/boost/thread/
+ <library>/boost/system/
+ <library>/boost/regex/
+ <linkflags>-pthread
+ $(DEFINES)
;
+if [ MATCH "^(--build-cgi)" : [ modules.peek : ARGV ] ]
+{ # compile library
+ ECHO "Building CGI library" ;
+
+ # make BB recognise .ipp files as .cpp files.
+ import type ;
+ type.register IPP : ipp : CPP ;
+
+ SOURCES = $(top)/libs/cgi/src/library_sources.cpp ;
+
+ lib boost_cgi
+ :
+ $(SOURCES)
+ :
+ <define>BOOST_CGI_BUILD_LIB
+ ;
+}
+else
+{
+ alias boost_cgi ;
+}
+
+install install
+ :
+ boost_cgi
+ :
+ <location>/usr/local/lib
+ ;
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/doc/src/cgi.qbk
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/doc/src/cgi.qbk (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/doc/src/cgi.qbk 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -111,10 +111,16 @@
[/include:ug user_guide.qbk]
-[xinclude ../cgi_dox.xml]
+[/xinclude ../cgi_dox.xml]
+
+[include:examples examples.qbk]
+
+[include:reference reference.qbk]
[include:future future_development.qbk]
[include:server_support user_guide/server_support.qbk]
+[include troubleshooting.qbk]
+
[include acknowledgements.qbk]
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/doc/src/reference.qbk
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/doc/src/reference.qbk (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/doc/src/reference.qbk 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -7,8 +7,58 @@
[section:ref Reference]
+[xinclude ../cgi_dox.xml]
+
+[h2 Quick Reference]
+
Reference coming...
-[/include request_objects.qbk]
+Requests
+
+ * Request Data
+ * environment
+ * operator[""] (operator[] on the environment map)
+ * operator[env] (request meta-data)
+ * operator[get] (GET data)
+ * operator[post] (POST data)
+ * operator[cookies] (cookie data)
+ * member functions
+ * script_name()
+ * request_method()
+ * content_length()
+ * content_encoding()
+ * etc...
+ * constructors
+ * load()
+ * async_load()
+ * close()
+ * clear()
+ * id()
+ * client()
+
+Acceptor
+
+ * constructors
+ * accept()
+ * async_accept()
+ * cancel()
+
+
+Service
+
+ * run()
+ * stop()
+ * reset()
+ * get_io_service()
+
+Responses
+
+ * operator<<
+ * send()
+ * clear()
+ * data()
+ * content_length()
+
+
+[endsect] [/ ref]
-[endsect]
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/doc/src/user_guide.qbk
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/doc/src/user_guide.qbk (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/doc/src/user_guide.qbk 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -19,8 +19,6 @@
[/include:tutorial user_guide/tutorial.qbk]
-[include:examples ../../example/doc.qbk]
-
[include user_guide/tutorial/tutorial.qbk]
[/endsect]
Deleted: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/doc/src/user_guide/tutorial/step_one.qbk
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/doc/src/user_guide/tutorial/step_one.qbk 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
+++ (empty file)
@@ -1,79 +0,0 @@
-
-[section "Hello, World."]
-
-Let's start at the beginning, with the eponymous "Hello world" example:
-
-``
-#include <boost/cgi.hpp>
-using namespace boost::cgi;
-
-int main()
-{
- service s;
- request req(s);
- response resp;
-
- resp<< content_type("text/plain")
- << "Hello, world.";
-
- resp.send(req.client());
-
- return 0;
-}
-``
-
-That should be mostly self-explanatory, here is what is happening:
-
-``
-#include <boost/cgi.hpp>
-using namespace boost::cgi;
-``
-
-The boost/cgi.hpp header includes the headers for CGI, SCGI and FastCGI. If you only want the CGI stuff you can `#include <boost/cgi/cgi.hpp>`, or similarly for the other protocols (scgi.hpp or fcgi.hpp).
-
-``
-service s;
-request req(s);
-``
-
-The use of the `service` class here might seem cumbersome, but its value should become more apparent later on when we try and scale our program.
-
-[note
- Still think it's ugly; I'm trying to think of the best way to remove the need for it without losing the protocol-independence of parts of the library.
-]
-
-``
-response resp;
-``
-
-You aren't required to use the `response` class with this library, but it's highly recommended. [-There is a rationale for the `response` class in the design notes] [/**FIXME**/]. A `response` is independent of protocol and any request you choose to use it with - that makes it easy to reuse.
-
-``
-resp<< content_type("text/plain")
- << "Hello, world.";
-``
-
-You can stream data to a `response` just like you can with `std::cout`. In addition, you can stream things like `content_type("text/html")` and `cookie("whatever", "value")` (more on this later).
-
-`content_type` is one of the ['header factories] provided by the library. In other words it is a function which returns a `header` object, so instead of streaming `content_type("text/plain")` to a `response` you can stream `header("Content-type", "text/plain")`. Both are equivalent, but the former is cleaner and less error prone.
-
-The `response` class understands `header`s and keeps them separate from the rest of the response. This allows you to add headers at any point, so long as you haven't flushed/sent the response already. For instance, you could add a custom header "Running-time", stating the time it took to handle the request, just before you send the response.
-
-``
-resp.send(req.client());
-
-return 0;
-``
-
-As already mentioned, the `response` class buffers your data, so you must send it when it is ready. It is sent to the `client` associated with a request - ie. req.client() - but you don't need to know anything else about the Client concept for now. The library also provides a convenient macro to clean up the above:
-
-``
-return_(resp, req, 0); // 'returns 0' from main.
-``
-
-[tip
- A CGI request is effectively closed when the application exits, but since FastCGI and SCGI can handle multiple requests per process you must explicitly close each one. The `return_()` macro does this properly.
-]
-
-[endsect] [/ hello_world]
-
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/doc/src/user_guide/tutorial/tutorial.qbk
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/doc/src/user_guide/tutorial/tutorial.qbk (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/doc/src/user_guide/tutorial/tutorial.qbk 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -1,7 +1,7 @@
[section Tutorial]
-[include step_one.qbk]
+[include hello_world.qbk]
[section:what_next The next step]
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 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -6,6 +6,7 @@
project boost/cgi/example
: requirements
+ <library>/boost/cgi/
<library>/boost/system/
<library>/boost/thread/
;
@@ -16,6 +17,10 @@
build-project acgi ;
# Build all of the fcgi examples
build-project fcgi ;
+# Build all of the xcgi examples
+build-project xcgi ;
+
+alias all_examples : cgi acgi fcgi xcgi ;
install cgi-install
: # sources
@@ -38,7 +43,12 @@
<location>$(fcgi-bin)
;
-alias install : cgi//install acgi//install fcgi//install ;
+install xcgi-install
+ :
+ xcgi//install
+ ;
+
+alias install : cgi//install acgi//install fcgi//install xcgi//install ;
explicit cgi-install ;
explicit acgi-install ;
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/amortization/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/amortization/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/amortization/main.cpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -38,10 +38,10 @@
template<typename Request>
void fill_amortization_dictionary(google::TemplateDictionary& dict, Request& req)
{
- std::string tmp( req.POST("LoanAmt") );
+ std::string tmp( req[post]["LoanAmt"] );
dict.SetValue("LoanAmt", tmp.empty() ? "$250,000" : tmp);
- tmp = req.POST("YearlyIntRate");
+ tmp = req[post]["YearlyIntRate"];
dict.SetValue("YearlyIntRate", tmp.empty() ? "6.000" : tmp);
boost::array<std::string, 8> year_opts
@@ -52,13 +52,13 @@
dict.SetValueAndShowSection("TermYrs", year, "SELECT_TERM_YEARS");
}
- if (req.POST("Amortize").empty())
+ if (req[post]["Amortize"].empty())
dict.ShowSection("NotAmortize");
else
{
- double P = boost::lexical_cast<double>(string_from_currency(req.POST("LoanAmt")));
- double i = boost::lexical_cast<double>(req.POST("YearlyIntRate")) / 1200;
- double n = boost::lexical_cast<double>(req.POST("TermYrs")) * 12;
+ double P = boost::lexical_cast<double>(string_from_currency(req[post]["LoanAmt"]));
+ double i = boost::lexical_cast<double>(req[post]["YearlyIntRate"]) / 1200;
+ double n = boost::lexical_cast<double>(req[post]["TermYrs"]) * 12;
double monthly_payments = (P*i) / (1 - std::pow((1+i), -n));
google::TemplateDictionary* sub_dict = dict.AddSectionDictionary("RegPmtSummary");
@@ -103,7 +103,7 @@
google::Template* tmpl
= google::Template::GetTemplate("example.tpl", google::STRIP_WHITESPACE);
- std::string arg(req.GET("arg"));
+ std::string arg(req[get]["arg"]);
if (arg.empty())
arg = "4"; // Make this the default
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/cookie_game/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_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 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -1,5 +1,4 @@
#include <boost/cgi/acgi.hpp>
-#include <boost/cgi/response.hpp>
#define SCRIPT_NAME "acgi_cookie_game"
@@ -49,17 +48,17 @@
response resp;
- if (req.GET("reset") == "true")
+ if (req[get]["reset"] == "true")
{
- resp<< cookie("name")
- << location(req.script_name())
- << content_type("text/plain");
+ resp<< cookie("name").to_string()
+ << location (req.script_name()) // redirect them.
+ << content_type ("text/plain");
resp.send(req.client());
return 0;
}
// First, see if they have a cookie set
- std::string name = req[cookie_data]["name"];
+ std::string name = req[cookies]["name"];
if (!name.empty())
{
resp<< header("Content-type", "text/html")
@@ -74,7 +73,7 @@
if (!name.empty())
{
resp<< header("Content-type", "text/html")
- << cookie("name", name)
+ << cookie("name", name).to_string()
<< "Hello there, " << "<a href=''>" << name << "</a>";
resp.send(req.client());
return 0;
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/echo/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/echo/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/echo/Jamfile.v2 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -9,8 +9,8 @@
exe acgi_echo
:
main.cpp
- /boost/regex/
- /boost/thread/
+ :
+ <library>/boost/cgi/
;
# Our install rule (builds binaries and copies them to <location>)
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/echo/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/echo/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/echo/main.cpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -15,8 +15,10 @@
// variables QUERY_STRING and HTTP_COOKIE respectively.
//
-#include <boost/cgi/acgi.hpp>
#include <fstream>
+#include <cstdio>
+///////////////////////////////////////////////////////////
+#include "boost/cgi/acgi.hpp"
using namespace std;
using namespace boost::acgi;
@@ -27,13 +29,25 @@
void show_map_contents(OStreamT& os, MapT& m, const std::string& title)
{
os<< "<h3>" << title << "</h3>";
- if (m.empty()) os<< "NONE<br />";
- for (typename MapT::const_iterator i = m.begin(); i != m.end(); ++i)
- {
- os<< "<b>" << i->first << "</b> = <i>" << i->second << "</i><br />";
- }
+ if (m.empty())
+ os<< "NONE<br />";
+ else
+ for (typename MapT::const_iterator i = m.begin(); i != m.end(); ++i)
+ {
+ os<< "<b>" << i->first << "</b> = <i>" << i->second << "</i><br />";
+ }
}
+std::size_t process_id()
+{
+#if defined(BOOST_WINDOWS)
+ return _getpid();
+#else
+ return getpid();
+#endif
+}
+
+
int main()
{
try{
@@ -52,20 +66,21 @@
if (ec)
{
response resp;
- resp
- << content_type("text/html")
- << "Error " << ec.value() << ": " << ec.message() << "<p />"
- "--Original message follows--"
- "<p />";
+ resp<< content_type("text/html")
+ << "Error " << ec.value() << ": " << ec.message() << "<p />"
+ "--Original message follows--"
+ "<p />";
resp.send(req.client());
}
response resp;
resp<< content_type("text/html")
+ << "Request ID = " << req.id() << "<br />"
+ << "Process ID = " << process_id() << "<br />"
<< "<form method=POST enctype='multipart/form-data'>"
- "<input type=text name=name value='" << req.POST("name") << "' />"
+ "<input type=text name=name value='" << req[post]["name"] << "' />"
"<br />"
- "<input type=text name=hello value='" << req.POST("hello") << "' />"
+ "<input type=text name=hello value='" << req[post]["hello"] << "' />"
"<br />"
"<input type=file name=user_file />"
"<input type=hidden name=cmd value=multipart_test />"
@@ -73,10 +88,10 @@
"<input type=submit value=submit />"
"</form><p />";
- show_map_contents(resp, req[get_data], "GET Variables");
- show_map_contents(resp, req[post_data], "POST Variables");
- show_map_contents(resp, req[cookie_data], "Cookie Variables");
- show_map_contents(resp, req[env_data], "Environment Variables");
+ show_map_contents(resp, req[env], "Environment Variables");
+ show_map_contents(resp, req[get], "GET Variables");
+ show_map_contents(resp, req[post], "POST Variables");
+ show_map_contents(resp, req[cookies], "Cookie Variables");
return_(resp, req, 0); // All ok.
@@ -101,12 +116,12 @@
// are reached.
}catch(std::exception* e){
- std::cerr
+ std::cout
<< content_type("text/plain").content
<< "Exception: " << e->what();
return 3;
}catch(...){
- std::cerr<< content_type("text/plain").content
+ std::cout<< content_type("text/plain").content
<< "Unknown error.";
return 4;
}
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/hello_world/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_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 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -13,7 +13,6 @@
//
#include <boost/cgi/acgi.hpp>
-#include <boost/cgi/return.hpp>
using namespace std;
using namespace boost::acgi;
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/login/CheckCookie.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/login/CheckCookie.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/login/CheckCookie.cpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -12,10 +12,10 @@
response resp;
- if (!req.cookie("uuid").empty())
+ if (!req[cookie_data]["uuid"].empty())
{ // The cookie has been set correctly!
boost::system::error_code ec;
- std::string fwd(req.form("fwd", ec));
+ std::string fwd (req[form_data]["fwd"]);
resp<< location(fwd);
// resp<< location(req.form("fwd"));
}else
@@ -31,7 +31,7 @@
"<p>You have cookies disabled. They are required for logging in.</p>"
"<a href='http://www.google.com/search?q=enabling cookies'>Google it</a>"
" if you're stuck, or return to "
- "<a href='" << req.env("referrer") << "'>where you came from</a>"
+ "<a href='" << req[env_data]["referrer"] << "'>where you came from</a>"
"</center>"
"</body>"
"</html>";
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/login/Login.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/login/Login.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/login/Login.cpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -13,8 +13,8 @@
"You provided the following data:"
"<p>"
"<h3>Form data:</h3>";
- for (boost::acgi::map::iterator i = req.form().begin();
- i != req.form().end();
+ for (boost::acgi::map::iterator i = req[form_data].begin();
+ i != req[form_data].end();
++i)
{
resp<< "<b>" << i->first << "</b> = <i>" << i->second << "</i>";
@@ -54,12 +54,13 @@
<< content_type("text/html")
<< "<html>"
"<head><title>Redirecting...</title>"
- "<meta http-equiv='refresh' content='5;url="<< req.POST("fwd") <<"' />"
+ "<meta http-equiv='refresh' content='5;url="
+ << req[post_data]["fwd"] <<"' />"
"</head>"
"<body>"
"<center>"
"You are already logged in. You should be redirected "
- "<a href='"<< req.POST("fwd") <<"'>here</a>"
+ "<a href='"<< req[post_data]["fwd"] <<"'>here</a>"
" in five seconds."
"</center>";
show_passed_variables(req, resp);
@@ -85,7 +86,8 @@
"<span class='red'>Your user name must only use letters, numbers or "
"the underscore character."
"</span>"
- "<input type='text' name='name' value='"<< req.POST("name") <<"' />"
+ "<input type='text' name='name' value='"
+ << req[post_data]["name"] <<"' />"
"<input type='button' name='cmd' value='login' />"
"</form>"
"</center>";
@@ -133,18 +135,18 @@
// If there's already a session id set, warn them and then redirect
// them to where they would be going anyway.
- if (!req.cookie("uuid").empty()) {
+ if (!req[cookie_data]["uuid"].empty()) {
return show_already_logged_in_page(req, resp);
}
// If they haven't asked explicitly to log in, show the default page.
- string cmd(req.POST("cmd"));
+ string cmd (req[post_data]["cmd"]);
if (cmd.empty() || cmd != "login") {
return show_default_page(req, resp);
}
// If they're name is invalid, inform them.
- string name(req.POST("name"));
+ string name (req[post_data]["name"]);
if (!verify_name(name)) {
return show_name_error_page(req, resp);
}
@@ -153,7 +155,7 @@
// Here we give them a 'universally unique id' and forward them to a
// cookie checking page.
resp<< cookie("uuid", make_uuid())
- << location("CheckCookie?fwd=" + req.POST("fwd"));
+ << location("CheckCookie?fwd=" + req[post_data]["fwd"]);
resp.send(req.client());
return req.close(http::ok);
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/login/Logout.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/login/Logout.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/login/Logout.cpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -14,7 +14,7 @@
resp<< cookie("uuid");
boost::system::error_code ec;
- std::string fwd(req.form("fwd", ec));
+ std::string fwd (req[form_data]["fwd"]);
resp<< location(fwd);
resp.send(req.client());
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/cgi/echo/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/cgi/echo/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/cgi/echo/Jamfile.v2 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -7,9 +7,10 @@
project boost/cgi/example/cgi/echo ;
exe cgi_echo
- : main.cpp
- /boost/thread/
- /boost/regex/
+ :
+ main.cpp
+ :
+ <library>/boost/cgi/
;
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/echo/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/echo/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/echo/main.cpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -16,10 +16,12 @@
//
#include <fstream>
+///////////////////////////////////////////////////////////
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/program_options/environment_iterator.hpp>
-
-#include <boost/cgi/fcgi.hpp>
+///////////////////////////////////////////////////////////
+#include "boost/cgi/fcgi.hpp"
+#include "boost/cgi/common/header.hpp"
using namespace std;
using namespace boost::fcgi;
@@ -28,8 +30,8 @@
#define LOG_FILE "/var/www/log/fcgi_echo.txt"
//
-// This function writes the title and map contents to the ostream in an
-// HTML-encoded format (to make them easier on the eye).
+// Write the title and map contents to the ostream in an HTML-encoded
+// format (to make them easier on the eye).
//
template<typename Map, typename OStream>
void format_map(OStream& os, Map& m, const std::string& title)
@@ -43,6 +45,15 @@
}
}
+std::size_t process_id()
+{
+#if defined(BOOST_WINDOWS)
+ return _getpid();
+#else
+ return getpid();
+#endif
+}
+
/// This function accepts and handles a single request.
template<typename Request, typename LogStream>
int handle_request(Request& req, LogStream& of)
@@ -71,10 +82,11 @@
// You can also stream text to a response object.
<< "Hello there, universe!<p />"
<< "Request id = " << req.id() << "<p />"
+ << "Process id = " << process_id() << "<p />"
<< "<form method=POST enctype='multipart/form-data'>"
- "<input type=text name=name value='" << req.POST("name") << "' />"
+ "<input type=text name=name value='" << req[post]["name"] << "' />"
"<br />"
- "<input type=text name=hello value='" << req.POST("hello") << "' />"
+ "<input type=text name=hello value='" << req[post]["hello"] << "' />"
"<br />"
"<input type=file name=user_file />"
"<input type=hidden name=cmd value=multipart_test />"
@@ -85,16 +97,17 @@
//
// Use the function defined above to show some of the request data.
//
- format_map(resp, req[env_data], "Environment Variables");
- format_map(resp, req[get_data], "GET Variables");
- format_map(resp, req[post_data], "POST Variables");
- format_map(resp, req[cookie_data], "Cookie Variables");
+ format_map(resp, req[env], "Environment Variables");
+ format_map(resp, req[get], "GET Variables");
+ format_map(resp, req[post], "POST Variables");
+ format_map(resp, req[cookies], "Cookie Variables");
//
// Response headers can be added at any time before send/flushing it:
//
- resp<< "<content-length == " << content_length(resp.content_length())
- << content_length(resp.content_length()) << ">";
+ resp<< "<content-length == "
+ << content_length(resp)
+ << content_length(resp) << ">";
//
//
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/hello_world/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/hello_world/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/hello_world/main.cpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -13,33 +13,44 @@
//
#include <boost/cgi/fcgi.hpp>
+#include <boost/cgi.hpp>
using namespace std;
using namespace boost::fcgi;
+=======
+/// Handle a FastCGI request
+template<typename Acceptor>
+int handle_request(Acceptor& a)
+{
+ int ret = 0;
+ for (;;) // Handle requests until something goes wrong
+ // (an exception will be thrown).
+>>>>>>> .r46066
+
int main()
{
try
{
service s; // This becomes useful with async operations.
- acceptor a(s); // This is used to accept requests from the server.
- request req(s); // Our request.
-
- for (;;) // Handle requests until something goes wrong
- // (an exception will be thrown).
+ acceptor a(s);
+
+ for (;;)
{
- a.accept(req);
- response resp; // A response object to make our lives easier.
-
- // This is a minimal response. The content_type(...) may go before or after
- // the response text.
- resp<< content_type("text/plain")
- << "Hello there, universe.";
-
- resp.send(req.client()); // Send the response.
- req.close(resp.status()); // Close the request (we can reuse this object now).
+ request req(s); // Our request.
+
+ for (;;) // Handle requests until something goes wrong
+ // (an exception will be thrown).
+ {
+ a.accept(req);
+ response resp; // A response object to make our lives easier.
+ ret = handle_request(req, resp);
+ if (ret) break; // Use a new request if something went wrong.
+ }
+ if (!a.is_open()) break; // Quit completely if the acceptor bails out.
}
- return 0;
+
+ return ret;
}
catch(boost::system::system_error& err)
{
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/server1/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/server1/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/server1/main.cpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -20,8 +20,8 @@
// This is very similar to the fcgi_echo example.
//
-#include <boost/cgi/fcgi.hpp>
-#include "server.hpp"
+#include "boost/cgi/fcgi.hpp"
+#include "./server.hpp"
using namespace std;
using namespace boost::fcgi;
@@ -41,7 +41,7 @@
}
/// The handle_request function handles a single request.
-int handle_request(fcgi::request& req, boost::system::error_code& ec)
+int handle_request(request& req, boost::system::error_code& ec)
{
// Construct a `response` object (makes writing/sending responses easier).
response resp;
@@ -60,7 +60,7 @@
resp<< "<h3>Response Length</h3>" << resp.content_length()
// response::content_length() returns the length of the *body*
// of the response (ie. not including the headers).
- << content_length(resp.content_length());
+ << content_length(resp);
// This funky macro finishes up:
return_(resp, req, 0);
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/server2/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/server2/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/server2/main.cpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -21,17 +21,16 @@
// Unlike in the server1 example, the server class in this example uses
// asynchronous functions, to increase throughput.
//
-//
-// **FIXME**
-// This is slower than the server1 example, which is stupid.
#include <fstream>
+///////////////////////////////////////////////////////////
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/program_options/environment_iterator.hpp>
-
-#include <boost/cgi/fcgi.hpp>
+///////////////////////////////////////////////////////////
+#include "boost/cgi/fcgi.hpp"
using namespace std;
+using namespace boost;
using namespace boost::fcgi;
@@ -55,34 +54,34 @@
* corresponding to the error.
*/
int handle_request(fcgi::request& req, boost::system::error_code& ec)
- {
- // Construct a `response` object (makes writing/sending responses easier).
- response resp;
+{
+ // Construct a `response` object (makes writing/sending responses easier).
+ response resp;
- // Responses in CGI programs require at least a 'Content-type' header. The
- // library provides helpers for several common headers:
- resp<< content_type("text/html")
- // You can also stream text to a response object.
- << "Hello there, universe!<p />";
-
- // Use the function defined above to show some of the request data.
- format_map(resp, req[env_data], "Environment Variables");
- format_map(resp, req[get_data], "GET Variables");
- format_map(resp, req[cookie_data], "Cookie Variables");
-
- //log_<< "Handled request, handling another." << std::endl;
-
- // This funky macro finishes up:
- return_(resp, req, 0);
- // It is equivalent to the below, where the third argument is represented by
- // `program_status`:
- //
- // resp.send(req.client());
- // req.close(resp.status(), program_status);
- // return program_status;
- //
- // Note: in this case `program_status == 0`.
- }
+ // Responses in CGI programs require at least a 'Content-type' header. The
+ // library provides helpers for several common headers:
+ resp<< content_type("text/html")
+ // You can also stream text to a response object.
+ << "Hello there, universe!<p />";
+
+ // Use the function defined above to show some of the request data.
+ format_map(resp, req[env_data], "Environment Variables");
+ format_map(resp, req[get_data], "GET Variables");
+ format_map(resp, req[cookie_data], "Cookie Variables");
+
+ //log_<< "Handled request, handling another." << std::endl;
+
+ // This funky macro finishes up:
+ return_(resp, req, 0);
+ // It is equivalent to the below, where the third argument is represented by
+ // `program_status`:
+ //
+ // resp.send(req.client());
+ // req.close(resp.status(), program_status);
+ // return program_status;
+ //
+ // Note: in this case `program_status == 0`.
+}
/// The server is used to abstract away protocol-specific setup of requests.
@@ -192,8 +191,8 @@
}catch(boost::system::system_error& se){
cerr<< "[fcgi] System error: " << se.what() << endl;
return 1313;
-}catch(exception& e){
- cerr<< "[fcgi] Exception: " << e.what() << endl;
+}catch(std::exception* e){
+ cerr<< "[fcgi] Exception: " << e->what() << endl;
return 666;
}catch(...){
cerr<< "[fcgi] Uncaught exception!" << endl;
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/server3/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/server3/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/server3/main.cpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -21,13 +21,15 @@
//
#include <fstream>
+///////////////////////////////////////////////////////////
#include <boost/thread.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/program_options/environment_iterator.hpp>
-
-#include <boost/cgi/fcgi.hpp>
+///////////////////////////////////////////////////////////
+#include "boost/cgi/fcgi.hpp"
using namespace std;
+using namespace boost;
using namespace boost::fcgi;
/// Handle one request and return.
@@ -139,8 +141,8 @@
}catch(boost::system::system_error& se){
cerr<< "[fcgi] System error: " << se.what() << endl;
return 1313;
-}catch(exception& e){
- cerr<< "[fcgi] Exception: " << e.what() << endl;
+}catch(std::exception* e){
+ cerr<< "[fcgi] Exception: " << e->what() << endl;
return 666;
}catch(...){
cerr<< "[fcgi] Uncaught exception!" << endl;
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/server4/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/server4/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/fcgi/server4/main.cpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -29,6 +29,7 @@
#include <boost/cgi/fcgi.hpp>
using namespace std;
+using namespace boost;
using namespace boost::fcgi;
/// Handle one request and return.
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/Jamfile.v2 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -15,3 +15,8 @@
build-project compile ;
build-project run ;
build-project compile_fail ;
+
+if [ MATCH "^(--build-examples)" : [ modules.peek : ARGV ] ]
+{
+ build-project ../example//all_examples ;
+}
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/is_async_test.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/is_async_test.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/is_async_test.cpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -1,10 +1,10 @@
#include <boost/static_assert.hpp>
-#include "boost/cgi/is_async.hpp"
+#include "boost/cgi/common/is_async.hpp"
int main()
{
- using namespace cgi;
+ using namespace cgi::common;
BOOST_STATIC_ASSERT(is_async<tags::cgi>::value == false);
BOOST_STATIC_ASSERT(is_async<tags::async_cgi>::value == true);
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/response.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/response.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/response.cpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -1,4 +1,4 @@
-#include <boost/cgi/response.hpp>
+#include <boost/cgi/common/response.hpp>
int main(int, char**)
{
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/acgi_simple_request.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/acgi_simple_request.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/acgi_simple_request.cpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -16,9 +16,9 @@
#include "request_test_template.hpp"
+
void init_env()
{
- using namespace std;
setenv("HTTP_HOST", "localhost", 1);
setenv("SCRIPT_NAME", "some/test/script", 1);
setenv("EMPTY_VAR", "", 1);
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/cgi_simple_request.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/cgi_simple_request.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/cgi_simple_request.cpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -18,7 +18,6 @@
void init_env()
{
- using namespace std;
setenv("HTTP_HOST", "localhost", 1);
setenv("SCRIPT_NAME", "some/test/script", 1);
setenv("EMPTY_VAR", "", 1);
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/cookie.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/cookie.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/cookie.cpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -9,7 +9,7 @@
#include <boost/test/unit_test.hpp>
#include <sstream>
-#include "boost/cgi/cookie.hpp"
+#include "boost/cgi/common/cookie.hpp"
BOOST_AUTO_TEST_CASE( cookie_constructor_delete )
@@ -18,6 +18,7 @@
// delete the cookie. ie. set its value to NULL and give it a date
// in the past
using namespace cgi;
+ using cgi::common::cookie;
using namespace std;
string ex("Fri, 05-Jun-1989 15:30:00 GMT");
@@ -38,6 +39,7 @@
{
// Check the full version of the constructor works (simple test)
using namespace cgi;
+ using cgi::common::cookie;
using namespace std;
string ex("Wed, 03-Oct-2007 16:26:06 GMT");
@@ -62,6 +64,7 @@
// delete the cookie. ie. set its value to NULL and give it a date
// in the past
using namespace cgi;
+ using cgi::common::cookie;
using namespace std;
string cookie_content(
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/request_test_template.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/request_test_template.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/request_test_template.hpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -49,3 +49,19 @@
BOOST_CHECK_EQUAL( req[cookie_data]["foo"], "bar" ); \
BOOST_CHECK_EQUAL( req[cookie_data]["encoded"], "\"£$%^$*^hh%%thd@:" );
+
+#include <string>
+#include <cstdlib>
+#include <boost/config.hpp>
+
+#ifdef BOOST_MSVC
+ // MSVC doesn't support setenv, but it does support putenv
+ void setenv(std::string const& name, std::string const& val, int reset = 0)
+ {
+ if (putenv((name + val).c_str()) != 0)
+ {
+ std::cerr<< "Error adding environment variable." << std::endl;
+ }
+ }
+#endif
+
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/response.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/response.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/response.cpp 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -13,7 +13,7 @@
#define BOOST_TEST_MODULE response_test
#include <boost/test/unit_test.hpp>
-#include "boost/cgi/response.hpp"
+#include "boost/cgi/common/response.hpp"
using namespace std;
using namespace boost;
Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/project-root.jam
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/project-root.jam (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/project-root.jam 2008-06-16 13:31:19 EDT (Mon, 16 Jun 2008)
@@ -1,11 +1,56 @@
import os ;
import modules ;
-path-constant BOOST_BUILD_PATH : [ os.environ BOOST_BUILD_PATH ] ;
+local rule get-boost-root ( )
+{
+ local boost-root = [ MATCH "^--boost-root=(.*)" : [ modules.peek : ARGV ] ] ;
+ if $(boost-root)
+ {
+ return $(boost-root) ;
+ }
+ else
+ {
+ boost-root = [ os.environ BOOST_ROOT ] ;
+ if $(boost-root)
+ {
+ return $(boost-root) ;
+ }
+ else
+ {
+ ERROR "Can't find your Boost source. Either set the environment " ;
+ ERROR "variable BOOST_ROOT or pass --boost-root=/path/to/source on the " ;
+ ERROR "command line." ;
+ }
+ }
+}
+
+# Get the boost root
+path-constant boost-root : [ get-boost-root ] ;
+
+local rule get-bbv2-path ( boost-root * )
+{
+ local bbv2-path = [ os.environ BOOST_BUILD_PATH ] ;
+ if $(bbv2-path)
+ {
+ return $(bbv2-path) ;
+ }
+ else
+ if $(boost-root)
+ {
+ return "$(boost-root)/tools/build/v2" ;
+ }
+ else
+ {
+ ERROR "Can't find Boost Build. Please set either the environment variable " ;
+ ERROR "BOOST_ROOT (to your boost sources) or BOOST_BUILD_PATH (to boost build's " ;
+ ERROR "sources - usually located in BOOST_ROOT/tools/build/v2." ;
+ }
+}
+
+path-constant BOOST_BUILD_PATH : [ get-bbv2-path ] ;
path-constant top : . ;
path-constant include-dir : /usr/local/include ;
-path-constant boost-root : [ os.environ BOOST_ROOT ] ;
# A relative path to boost (for documentation stuff)
path-constant boost-root-relative : $(top)/../../../../boost/trunk/ ;
@@ -40,7 +85,7 @@
}
else
{
- return "$(top)/$(protocol:L)-bin" ;
+ return "$(top)/libs/cgi/example/$(protocol:L)-bin" ;
}
}
}
@@ -90,13 +135,4 @@
use-project /boost/ : $(boost-root) ;
use-project /boost/cgi/ : $(top)/libs/cgi/build ;
-
-project cgi
- : build-dir
- $(top)/bin.v2
- : requirements
- <include>$(boost-root)
- <include>$(top)
- <define>_CRT_SECURE_NO_WARNINGS
- <define>_SCL_SECURE_NO_WARNINGS
- ;
+project anon : build-dir bin.v2 ;
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