Boost logo

Boost-Commit :

From: lists.drrngrvy_at_[hidden]
Date: 2008-06-02 17:54:09


Author: drrngrvy
Date: 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
New Revision: 46058
URL: http://svn.boost.org/trac/boost/changeset/46058

Log:
Merged revisions 43980-46057 via svnmerge from
https://svn.boost.org/svn/boost/sandbox/SOC/2007/cgi/trunk

........
  r44571 | drrngrvy | 2008-04-19 14:05:37 +0100 (Sat, 19 Apr 2008) | 1 line
  
  Factoring form_parser body into an ipp file.
........
  r44573 | drrngrvy | 2008-04-19 14:23:03 +0100 (Sat, 19 Apr 2008) | 9 lines
  
  * Added case-insensitive name type (typedef for std::basic_string<> using a custom traits class).
  * Modified cgi::map to use cgi::name as key.
  * Also modified files to include common/map.hpp instead of map.hpp.
  * Changed code because a std::string isn't automatically convertible to cgi::name
  * Fixed it so multiple cookies are parsed correctly.
  * Plus, other smallish fixes (cleanup / updating Boost.Thread compatibility).
........
  r44574 | drrngrvy | 2008-04-19 14:25:08 +0100 (Sat, 19 Apr 2008) | 1 line
  
  Small fixes to examples.
........
  r44576 | drrngrvy | 2008-04-19 14:32:06 +0100 (Sat, 19 Apr 2008) | 1 line
  
  Add a test which uses wget to check the output of the *cgi_hello_world examples through a server. It's not used by default, but has the BBv2 id of wget_test.
........
  r44577 | drrngrvy | 2008-04-19 14:34:48 +0100 (Sat, 19 Apr 2008) | 1 line
  
  Added basic tests for cgi::name and cgi::map and another for a cgi::request.
........
  r44578 | drrngrvy | 2008-04-19 14:40:56 +0100 (Sat, 19 Apr 2008) | 1 line
  
  Added simple test for acgi::request.
........
  r44879 | drrngrvy | 2008-04-29 13:22:22 +0100 (Tue, 29 Apr 2008) | 1 line
  
  Fix ichar_traits<>::compare(). Minor optimisations to ichar_traits<>::find() and save_environment().
........
  r44880 | drrngrvy | 2008-04-29 13:23:50 +0100 (Tue, 29 Apr 2008) | 1 line
  
  Extracting out cgi/acgi test commonality. Checking name(bar) < name(foo) in name_test too.
........
  r44898 | drrngrvy | 2008-04-29 22:08:35 +0100 (Tue, 29 Apr 2008) | 5 lines
  
  * Added basic_request<>::id() member function.
  * Changed basic_request<>::operator[] so that it decides at compile-time rather than runtime what data map is being accessed.
  * Added additional typedefs env_map, get_map, post_map, cookie_map, form_map corresponding to the dataset they obviously refer to - for now they are just typedefs to cgi::common::map, but eventually they may change - only to make code safer (eg. protect the user against XSS vulnerabilities).
........
  r44899 | drrngrvy | 2008-04-29 23:24:00 +0100 (Tue, 29 Apr 2008) | 1 line
  
  Moved a couple of common bits from cgi_service_impl_base and fcgi_request_service into common::request_base<>.
........
  r44908 | drrngrvy | 2008-04-30 03:31:09 +0100 (Wed, 30 Apr 2008) | 1 line
  
  Refactoring/housekeeping. Lots of common stuff has moved into common::request_base<> (this *isn't* the same as ::cgi::request_base - an old class that will be removed/replaced).
........
  r44909 | drrngrvy | 2008-04-30 03:31:32 +0100 (Wed, 30 Apr 2008) | 1 line
  
  Fix examples because of an interface change.
........
  r45554 | drrngrvy | 2008-05-19 20:03:57 +0100 (Mon, 19 May 2008) | 1 line
  
  Made response, cookie and header parameterised on a char type.
........
  r45555 | drrngrvy | 2008-05-19 20:06:45 +0100 (Mon, 19 May 2008) | 1 line
  
  Fix name.hpp
........
  r45556 | drrngrvy | 2008-05-19 20:17:04 +0100 (Mon, 19 May 2008) | 10 lines
  
  Breaking changes: Accessing request data should only be done using basic_request<>::operator[] now; member functions like basic_request<>::GET() are gone now. Examples have been updated.
  Also:
  * Internally, data maps are accessed using eg. common::get_vars(impl.var_) where impl.var_ is the Boost.Fusion map of all the request types.
  * Added "_data"-less alternatives to get_data, post_data, etc, so you can do eg.
    ``
    assert( request[get]["Hello"] == request[get_data]["hello"]); // note: case insensitive
    ``
  * Other minor cleanups/refactoring.
........
  r45557 | drrngrvy | 2008-05-19 20:21:20 +0100 (Mon, 19 May 2008) | 1 line
  
  Updating tests and examples.
........
  r45558 | drrngrvy | 2008-05-19 20:25:17 +0100 (Mon, 19 May 2008) | 1 line
  
  Updated project-root.jam
........
  r45579 | drrngrvy | 2008-05-20 17:08:38 +0100 (Tue, 20 May 2008) | 1 line
  
  Refactoring; lots of things moved - boost/cgi/ -> boost/cgi/common/; lots more cleanups that are long overdue.
........
  r45581 | drrngrvy | 2008-05-20 17:10:37 +0100 (Tue, 20 May 2008) | 1 line
  
  Missing file.
........
  r45582 | drrngrvy | 2008-05-20 17:14:12 +0100 (Tue, 20 May 2008) | 1 line
  
  Removing files properly...
........
  r45583 | drrngrvy | 2008-05-20 17:23:37 +0100 (Tue, 20 May 2008) | 1 line
  
  Fixing operator<< overload for name.hpp
........
  r45584 | drrngrvy | 2008-05-20 17:30:05 +0100 (Tue, 20 May 2008) | 1 line
  
  Missing include in fcgi/client.hpp
........
  r45605 | drrngrvy | 2008-05-21 13:25:47 +0100 (Wed, 21 May 2008) | 1 line
  
  More refactorings. Plus a couple of minor bug fixes (like multiple-definition of things in url_decode.hpp
........
  r45610 | drrngrvy | 2008-05-21 17:06:46 +0100 (Wed, 21 May 2008) | 4 lines
  
  * Adding ability to compile a library by passing --build-cgi on the bjam command line (seems to work).
  * Fixing examples and tests as per refactoring.
........
  r45611 | drrngrvy | 2008-05-21 17:16:18 +0100 (Wed, 21 May 2008) | 4 lines
  
  * More refactoring: Moving things imported from Boost.Asio into the import folder.
  * Adding/fixing a couple of hooks for the *option* of building a library out of the headers.
........
  r45612 | drrngrvy | 2008-05-21 17:25:27 +0100 (Wed, 21 May 2008) | 1 line
  
  1of2 - fixing corrupted repository.
........
  r45613 | drrngrvy | 2008-05-21 17:43:19 +0100 (Wed, 21 May 2008) | 1 line
  
  Removing typo-file.
........
  r45614 | drrngrvy | 2008-05-21 17:46:33 +0100 (Wed, 21 May 2008) | 1 line
  
  2of2: fixing corrupted repository.
........
  r45615 | drrngrvy | 2008-05-21 17:48:54 +0100 (Wed, 21 May 2008) | 1 line
  
  Fixes related to refactoring.
........
  r45628 | drrngrvy | 2008-05-21 22:40:58 +0100 (Wed, 21 May 2008) | 1 line
  
  Missing file.
........
  r45655 | drrngrvy | 2008-05-22 15:19:21 +0100 (Thu, 22 May 2008) | 1 line
  
  End of spring cleaning (hopefully).
........
  r45656 | drrngrvy | 2008-05-22 15:19:43 +0100 (Thu, 22 May 2008) | 1 line
  
  End of spring cleaning (hopefully).
........

Added:
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/common/basic_protocol_service.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/basic_protocol_service.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/common/connection_base.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/connection_base.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/common/cookie.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/cookie.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/common/header.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/header.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/common/io_service_provider.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/io_service_provider.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/common/is_async.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/is_async.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/common/map.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/map.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/common/name.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/name.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/common/request_acceptor_service.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/request_acceptor_service.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/common/request_base.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/request_base.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/common/request_service.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/request_service.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/common/response.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/response.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/common/return.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/return.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/common/role_type.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/role_type.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/common/source_enums.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/source_enums.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/common/status_type.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/status_type.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/common/tags.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/common/tags.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/basic_sync_io_object.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/basic_sync_io_object.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/url_decode.ipp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/url_decode.ipp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/fwd/
      - copied from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/fwd/
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/fwd/basic_connection_fwd.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/fwd/basic_connection_fwd.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/fwd/basic_protocol_service_fwd.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/fwd/basic_protocol_service_fwd.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/fwd/basic_request_acceptor_fwd.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/fwd/basic_request_acceptor_fwd.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/fwd/basic_request_fwd.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/fwd/basic_request_fwd.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/fwd/io_service_provider_fwd.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/fwd/io_service_provider_fwd.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/fwd/request_service_fwd.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/fwd/request_service_fwd.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/impl/
      - copied from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/impl/
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/impl/form_parser.ipp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/impl/form_parser.ipp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/impl/response.ipp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/impl/response.ipp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/import/
      - copied from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/import/
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/import/basic_io_object.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/import/basic_io_object.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/import/buffer.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/import/buffer.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/import/io_service.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/import/io_service.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/import/read.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/import/read.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/import/streambuf.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/import/streambuf.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/import/write.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/import/write.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/utility/
      - copied from r45656, /sandbox/SOC/2007/cgi/trunk/boost/cgi/utility/
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/doc/src/troubleshooting.qbk
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/libs/cgi/doc/src/troubleshooting.qbk
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/fcgi/server1/server.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/server1/server.hpp
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/test/run/acgi_simple_request.cpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/libs/cgi/test/run/acgi_simple_request.cpp
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/test/run/cgi_simple_request.cpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/libs/cgi/test/run/cgi_simple_request.cpp
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/test/run/hello_world.cpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/libs/cgi/test/run/hello_world.cpp
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/test/run/map_test.cpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/libs/cgi/test/run/map_test.cpp
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/test/run/name_test.cpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/libs/cgi/test/run/name_test.cpp
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/test/run/request_test_template.hpp
      - copied unchanged from r45656, /sandbox/SOC/2007/cgi/trunk/libs/cgi/test/run/request_test_template.hpp
Removed:
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_client_fwd.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_connection_fwd.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_gateway.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_gateway_fwd.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_io_object.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_protocol_service.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_protocol_service_fwd.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_request_acceptor_fwd.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_request_fwd.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_sync_io_object.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/buffer.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/connection_base.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/cookie.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/data_sink.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/data_source.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/header.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/io_service.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/io_service_provider.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/io_service_provider_fwd.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/is_async.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/map.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/read.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/request.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/request_acceptor_service.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/request_base.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/request_ostream.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/request_service.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/request_service_fwd.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/response.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/return.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/role_type.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/status_type.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/streambuf.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/tags.hpp
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/write.hpp
Properties modified:
   sandbox/SOC/2007/cgi/branches/release/ (props changed)
Text files modified:
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/acgi.hpp | 9
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/acgi/request.hpp | 5
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/acgi/request_impl.hpp | 11
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/acgi/request_service.hpp | 14
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/acgi/service.hpp | 12
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_client.hpp | 10
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_request.hpp | 478 +++++++----------------
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_request_acceptor.hpp | 6
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/cgi/request.hpp | 4
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/cgi/request_impl.hpp | 59 --
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/cgi/request_service.hpp | 13
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/cgi/service.hpp | 6
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/common/form_parser.hpp | 400 ++------------------
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/common/form_part.hpp | 2
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/connections/async_stdio.hpp | 12
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/connections/shareable_tcp_socket.hpp | 15
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/connections/stdio.hpp | 38 -
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/connections/tcp_socket.hpp | 8
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/cgi_request_impl_base.hpp | 55 +-
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/cgi_service_impl_base.hpp | 786 +--------------------------------------
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/common_headers.hpp | 22
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/extract_params.hpp | 8
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/protocol_traits.hpp | 67 ++-
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/push_options.hpp | 9
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/save_environment.hpp | 11
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/url_decode.hpp | 85 ---
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/error.hpp | 5
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/fcgi.hpp | 2
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/fcgi/acceptor_service_impl.hpp | 22
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/fcgi/client.hpp | 29
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/fcgi/request.hpp | 7
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/fcgi/request_acceptor_service.hpp | 14
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/fcgi/request_service.hpp | 334 +++-------------
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/fcgi/service.hpp | 6
   sandbox/SOC/2007/cgi/branches/release/boost/cgi/http/status_code.hpp | 144 +++---
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/build/Jamfile.v2 | 49 ++
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/doc/src/cgi.qbk | 6
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/doc/src/reference.qbk | 54 ++
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/Jamfile.v2 | 5
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/amortization/main.cpp | 14
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/cookie_game/main.cpp | 13
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/doc.qbk | 4
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/echo/Jamfile.v2 | 4
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/echo/main.cpp | 53 +
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/hello_world/main.cpp | 1
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/login/CheckCookie.cpp | 6
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/login/Login.cpp | 20
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/login/Logout.cpp | 2
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/cgi/echo/Jamfile.v2 | 7
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/cgi/echo/main.cpp | 21
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/fcgi/echo/main.cpp | 94 +++-
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/fcgi/server1/main.cpp | 193 ++-------
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/fcgi/server2/main.cpp | 67 +-
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/fcgi/server3/main.cpp | 10
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/fcgi/server4/main.cpp | 1
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/test/Jamfile.v2 | 5
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/test/compile/is_async_test.cpp | 4
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/test/compile/response.cpp | 2
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/test/run/Jamfile.v2 | 8
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/test/run/cookie.cpp | 5
   sandbox/SOC/2007/cgi/branches/release/libs/cgi/test/run/response.cpp | 15
   sandbox/SOC/2007/cgi/branches/release/project-root.jam | 62 ++
   62 files changed, 1039 insertions(+), 2394 deletions(-)

Modified: sandbox/SOC/2007/cgi/branches/release/boost/cgi/acgi.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/acgi.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/acgi.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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 {
@@ -29,7 +22,7 @@
    typedef acgi_request request;
    //typedef acgi_service service;
    //typedef acgi_acceptor acceptor;
- using namespace ::cgi; // **FIXME** this line must go.
+ //using namespace ::cgi; // **FIXME** this line must go.
    using namespace ::cgi::common; // import common namespace elements.
 
  } // namespace acgi

Modified: sandbox/SOC/2007/cgi/branches/release/boost/cgi/acgi/request.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/acgi/request.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/acgi/request.hpp 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
@@ -9,12 +9,11 @@
 #ifndef CGI_ACGI_REQUEST_HPP_INCLUDED__
 #define CGI_ACGI_REQUEST_HPP_INCLUDED__
 
+#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 {
 

Modified: sandbox/SOC/2007/cgi/branches/release/boost/cgi/acgi/request_impl.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/acgi/request_impl.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/acgi/request_impl.hpp 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
@@ -11,8 +11,9 @@
 
 #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
 
@@ -22,20 +23,19 @@
   class acgi_service_impl;
 
   class acgi_request_impl
- : public cgi_request_impl_base<common::async_stdio_connection>
+ : 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::common::basic_client<
- connection_type, tags::acgi
+ connection_type, common::tags::acgi
>
     client_type;
- //typedef async_stdio_connection client_type;
 
     acgi_request_impl()
- : cgi_request_impl_base<connection_type>()
+ : detail::cgi_request_impl_base<connection_type>()
     {
     }
 
@@ -48,3 +48,4 @@
 } // namespace cgi
 
 #endif // CGI_ASYNC_CGI_REQUEST_IMPL_HPP_INCLUDED__
+

Modified: sandbox/SOC/2007/cgi/branches/release/boost/cgi/acgi/request_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/acgi/request_service.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/acgi/request_service.hpp 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
@@ -9,14 +9,14 @@
 #ifndef CGI_ACGI_SERVICE_IMPL_HPP_INCLUDED__
 #define CGI_ACGI_SERVICE_IMPL_HPP_INCLUDED__
 
+#include "boost/cgi/common/tags.hpp"
+#include "boost/cgi/common/map.hpp"
 #include "boost/cgi/acgi/request_impl.hpp"
-#include "boost/cgi/tags.hpp"
-#include "boost/cgi/io_service.hpp"
-#include "boost/cgi/map.hpp"
-#include "boost/cgi/detail/cgi_service_impl_base.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 {
 
@@ -28,15 +28,13 @@
   {
   public:
     typedef acgi_request_service type;
- typedef acgi_request_impl impl_type;
- typedef ::cgi::common::map map_type;
- typedef tags::acgi protocol_type;
+ typedef common::tags::acgi protocol_type;
     typedef acgi_service protocol_service_type;
 
     /// The unique service identifier
     // static boost::asio::io_service::id id;
 
- acgi_request_service(::cgi::io_service& ios)
+ acgi_request_service(common::io_service& ios)
       : detail::service_base<acgi_request_service>(ios)
     {
     }

Modified: sandbox/SOC/2007/cgi/branches/release/boost/cgi/acgi/service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/acgi/service.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/acgi/service.hpp 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
@@ -9,10 +9,8 @@
 #ifndef CGI_CGI_SERVICE_HPP_INCLUDED__
 #define CGI_CGI_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 {
 
@@ -20,10 +18,10 @@
   /**
    * Works with both cgi_request and acgi_request.
    */
- typedef common::basic_protocol_service<tags::acgi> acgi_service;
+ typedef common::basic_protocol_service<common::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 +44,6 @@
 
 } // namespace cgi
 
-#include "boost/cgi/basic_protocol_service.hpp"
+#include "boost/cgi/common/basic_protocol_service.hpp"
 
 #endif // CGI_CGI_SERVICE_HPP_INCLUDED__

Modified: sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_client.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_client.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_client.hpp 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
@@ -10,11 +10,11 @@
 #define CGI_BASIC_CLIENT_HPP_INCLUDED__
 
 #include <boost/shared_ptr.hpp>
-
-#include "boost/cgi/map.hpp"
-#include "boost/cgi/role_type.hpp"
-#include "boost/cgi/status_type.hpp"
+///////////////////////////////////////////////////////////
+#include "boost/cgi/common/map.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"
 
 
@@ -143,6 +143,8 @@
   private:
     //io_service& io_service_;
     connection_ptr connection_;
+
+ public: // **FIXME**
     // we should never read more than content-length bytes.
     std::size_t bytes_left_;
   };

Deleted: sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_client_fwd.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_client_fwd.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/basic_connection_fwd.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_connection_fwd.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/basic_gateway.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_gateway.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/basic_gateway_fwd.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_gateway_fwd.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/basic_io_object.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_io_object.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/basic_protocol_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_protocol_service.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/basic_protocol_service_fwd.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_protocol_service_fwd.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/basic_request.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_request.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_request.hpp 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
@@ -16,29 +16,28 @@
 
 #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>
-
+///////////////////////////////////////////////////////////
+// **FIXME** Half of these are probably useless
+#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/protocol_traits.hpp"
-#include "boost/cgi/request_base.hpp"
-#include "boost/cgi/role_type.hpp"
-#include "boost/cgi/data_source.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/map.hpp"
+#include "boost/cgi/detail/basic_sync_io_object.hpp"
+#include "boost/cgi/fwd/basic_protocol_service_fwd.hpp"
 
 namespace cgi {
  namespace common {
@@ -72,27 +71,29 @@
           , 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 +102,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);
     }
@@ -212,7 +213,7 @@
      *
      * @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 );
@@ -222,7 +223,7 @@
                                 , 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)
     {
@@ -261,34 +262,6 @@
       return this->service.client(this->implementation);
     }
 
- /// Set the output for the request
- /**
- * Not Implemented Yet ******************
- *
- * Set the output sink as `stdout_`, `stderr_`, or `stdout_ | stderr_`
- */
- /*
- void set_output(cgi::sink dest = stdout_)
- {
- boost::system::error_code ec;
- this->service(this->implementation, dest, ec);
- detail::throw_error(ec);
- }
- */
-/*
- void read_some()
- {
- boost::system::error_code ec;
- this->service.read_some(this->implementationementation,ec);
- detail::throw_error(ec);
- }
-
- boost::system::error_code
- read_some(boost::system::error_code& ec)
- {
- return this->service.read_some(this->implementationementation, ec);
- }
-*/
     template<typename MutableBufferSequence>
     void read_some(const MutableBufferSequence& buf)
     {
@@ -318,285 +291,75 @@
     }
     */
 
- /// Get a `cgi::map&` corresponding to all of the GET variables
- map_type& GET()
+ /// Search through environment variables for the matching name
+ string_type var(string_type const& name, boost::system::error_code& ec)
     {
- return this->service.GET(this->implementation);
+ return env_vars(this->implementation)[name.c_str()];
     }
 
- /// 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)
+ string_type var(string_type const& name)
     {
       boost::system::error_code ec;
- std::string ret = this->service.GET(this->implementation, name, ec);
+ string_type ret (var(name, ec));
       detail::throw_error(ec);
       return ret;
     }
 
- /// 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);
- }
-
- /// Get a `cgi::map&` corresponding to all of the POST variables
- map_type& POST()
- {
- return this->service.POST(this->implementation);
- }
-
- /// 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);
- }
-
- /// Get a `cgi::map&` corresponding to all of the form variables
- map_type& form(bool greedy = true)
- {
- boost::system::error_code ec;
- map_type& data = this->service.form(this->implementation, ec, greedy);
- detail::throw_error(ec);
- return data;
- }
-
- /// 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)
- {
- boost::system::error_code ec;
- std::string ret = form(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 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 "";
- }
-
- /// Get a `cgi::map&` corresponding to all of the HTTP_COOKIE variables
- map_type& cookie()
- {
- return this->service.cookie(this->implementation);
- }
-
- /// 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);
- }
-
- /// Get a `cgi::map&` corresponding to all of the environment variables
- map_type& env()
- {
- return this->service.env(this->implementation);
- }
-
- /// 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(const std::string& 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"); }
 
- std::string content_length()
- { return env("CONTENT_LENGTH"); }
+ string_type content_length()
+ { return env_("CONTENT_LENGTH"); }
 
- std::string content_type()
- { return env("CONTENT_TYPE"); }
+ string_type content_type()
+ { return env_("CONTENT_TYPE"); }
 
- std::string gateway_interface()
- { return env("GATEWAY_INTERFACE"); }
+ string_type gateway_interface()
+ { return env_("GATEWAY_INTERFACE"); }
 
- std::string path_info()
- { return env("PATH_INFO"); }
+ string_type path_info()
+ { return env_("PATH_INFO"); }
 
- std::string path_translated()
- { return env("PATH_TRANSLATED"); }
+ string_type path_translated()
+ { return env_("PATH_TRANSLATED"); }
 
- std::string query_string()
- { return env("QUERY_STRING"); }
+ string_type query_string()
+ { return env_("QUERY_STRING"); }
 
- std::string remote_addr()
- { return env("REMOTE_ADDR"); }
+ string_type remote_addr()
+ { return env_("REMOTE_ADDR"); }
 
- std::string remote_host()
- { return env("REMOTE_HOST"); }
+ string_type remote_host()
+ { return env_("REMOTE_HOST"); }
 
- std::string remote_ident()
- { return env("REMOTE_IDENT"); }
+ string_type remote_ident()
+ { return env_("REMOTE_IDENT"); }
 
- std::string remote_user()
- { return env("REMOTE_USER"); }
+ string_type remote_user()
+ { return env_("REMOTE_USER"); }
 
- std::string request_method()
- { return env("REQUEST_METHOD"); }
+ string_type request_method()
+ { return env_("REQUEST_METHOD"); }
 
- std::string script_name()
- { return env("SCRIPT_NAME"); }
+ string_type script_name()
+ { return env_("SCRIPT_NAME"); }
 
- std::string server_name()
- { return env("SERVER_NAME"); }
+ string_type server_name()
+ { return env_("SERVER_NAME"); }
 
- std::string server_port()
- { return env("SERVER_PORT"); }
+ string_type server_port()
+ { return env_("SERVER_PORT"); }
 
- std::string server_protocol()
- { return env("SERVER_PROTOCOL"); }
+ string_type server_protocol()
+ { return env_("SERVER_PROTOCOL"); }
 
- std::string server_software()
- { return env("SERVER_SOFTWARE"); }
+ string_type server_software()
+ { return env_("SERVER_SOFTWARE"); }
     // -- 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]+);");
@@ -620,43 +383,92 @@
       return this->service.get_role(this->implementation);
     }
 
- /// Get the strand associated with the request (if any)
- // Not sure if the strand concept should be kept separate or a member
- // function like basic_request<>::wrap() should be provided: in the case of
- // a synchronous request type the wrapping would still function as expected
- // and there would be no need for protocol-specific code in user programs.
- /* boost::asio::strand* strand()
+ void set_status(common::http::status_code const& status)
     {
- return this->implementation.strand();
+ this->service.set_status(this->implementation, status);
     }
- */
 
- /// Get the implementation type for the request
- //implementation_type* impl()
- //{
- // return &(this->implementation);
- //}
+ ////////////////////////////////////////////////////////////
+ // Note on operator[]
+ // ------------------
+ // It is overloaded on different enum types to allow
+ // compile-time (I hope) retrieval of different data
+ // maps.
+ //
 
- void set_status(http::status_code status)
+ // The first three overloads are for directly looking into the
+ // environment.
+ // eg.
+ // string_type& val = req["some name"];
+ env_map& operator[](string_type const& n)
     {
- this->service.set_status(this->implementation, status);
+ return env_vars(this->implementation.vars_)[n.c_str()];
+ }
+
+ env_map& operator[](const char* n)
+ {
+ return env_vars(this->implementation.vars_)[n];
+ }
+
+ env_map& 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 env_vars(this->implementation.vars_);
+ }
+
+ /// Get a `common::get_map&` of all the GET variables.
+ get_map& operator[](common::get_data_type const&)
+ {
+ 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 post_vars(this->implementation.vars_);
+ }
+
+ /// Get a `common::cookie_map&` of all the cookies.
+ cookie_map& operator[](common::cookie_data_type const&)
+ {
+ 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 get_vars(this->implementation.vars_);
+ else
+ if (request_method() == "POST")
+ return post_vars(this->implementation.vars_);
+ else
+ return env_vars(this->implementation.vars_);
+ }
+ ////////////////////////////////////////////////////////////
+
+ /// The id of this request.
+ /**
+ * This is 1 for CGI/aCGI requests, but may be != 1 for FastCGI requests.
+ * Note that for FastCGI requests, the id's are assigned on a
+ * *per-connection* policy, so in one application you may have several
+ * requests with the same id.
+ */
+ int id()
+ {
+ return this->service.request_id(this->implementation);
     }
 
- map_type& operator[](common::data_source source)
+ private:
+ // Internal shortcut for named env-var functions (eg. script_name() above).
+ string_type& env_(const char* name)
     {
- switch(source)
- {
- case get_data: return this->implementation.get_vars_;
- case post_data: return this->implementation.post_vars_;
- case cookie_data: return this->implementation.cookie_vars_;
- case env_data: return this->implementation.env_vars_;
- case form_data:
- default:
- std::string rm( request_method() );
- if (rm == "GET") return this->implementation.get_vars_;
- else if (rm == "POST") return this->implementation.post_vars_;
- else return this->implementation.env_vars_;
- }
+ return env_vars(this->implementation.vars_)[name];
     }
   };
 

Modified: sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_request_acceptor.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_request_acceptor.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_request_acceptor.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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 {

Deleted: sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_request_acceptor_fwd.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_request_acceptor_fwd.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/basic_request_fwd.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_request_fwd.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/basic_sync_io_object.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/basic_sync_io_object.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/buffer.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/buffer.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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__

Modified: sandbox/SOC/2007/cgi/branches/release/boost/cgi/cgi/request.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/cgi/request.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/cgi/request.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/cgi/request_impl.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/cgi/request_impl.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/cgi/request_impl.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/map.hpp"
+#include "boost/cgi/common/status_type.hpp"
 #include "boost/cgi/detail/cgi_request_impl_base.hpp"
 
 // Make this ProtocolService-independent
@@ -38,11 +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 stdio_connection client_type;
- 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
     /**
@@ -51,52 +53,19 @@
      */
     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>()
     {
     }
 
   protected:
- friend class cgi_service_impl;//<cgi_request_impl>;
+ friend class cgi_service_impl;
   };
 
- //template<> inline const std::string&
- //cgi_request_impl::var<tags::ENV>(const std::string& name)
- //{
- // return ::getenv(name.c_str());
- //}
-
- /// Get a request map of all the environment meta-variables (slow)
- /**
- * -- NOT IMPLEMENTED FOR NOW --
- *
- * In the case of a CGI request, the environment meta-data is usually stored
- * in the process environment, which means there is no direct access to all
- * of them as a map_type&. In other words, this function call will have to
- * load all of the variables into memory and then return the map
- */
- //template<> inline cgi_request_impl::map_type&
- //cgi_request_impl::var<tags::ENV>()
- //{
- // throw std::logic_error("Can't get all environment vars as a map_type&");
- //}
-
- //template<> inline cgi_request_impl::map_type&
- //cgi_request_impl::var<tags::HTTP>() { return http_map_; }
-
- //template<> inline cgi_request_impl::map_type&
- //cgi_request_impl::var<tags::COOKIE>() { return cookie_map_; }
-
- //template<> inline cgi_request_impl::map_type&
- //cgi_request_impl::var<tags::GET>() { return get_map_; }
-
- //template<> inline cgi_request_impl::map_type&
- //cgi_request_impl::var<tags::POST>() { return post_map_; }
-
 } // namespace cgi
 
 #endif // CGI_CGI_REQUEST_IMPL_HPP_INCLUDED__

Modified: sandbox/SOC/2007/cgi/branches/release/boost/cgi/cgi/request_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/cgi/request_service.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/cgi/request_service.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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 {
 
@@ -26,11 +27,9 @@
   class cgi_request_service
    : public cgi_service_impl_base<cgi_request_impl>
   {
- typedef ::cgi::common::map map_type;
   public:
     typedef cgi_request_impl impl_type;
- typedef tags::cgi protocol_type;
- //typedef cgi_service_impl_base<cgi_request_impl> base;
+ typedef common::tags::cgi protocol_type;
 
     cgi_request_service()
       : cgi_service_impl_base<cgi_request_impl>()

Modified: sandbox/SOC/2007/cgi/branches/release/boost/cgi/cgi/service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/cgi/service.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/cgi/service.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/common/form_parser.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/common/form_parser.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/common/form_parser.hpp 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
@@ -1,18 +1,29 @@
+// -- form_parser.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_DETAIL_FORM_PARSER_HPP_INCLUDED__
 #define CGI_DETAIL_FORM_PARSER_HPP_INCLUDED__
 
 #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 {
@@ -36,388 +47,55 @@
 
     typedef RequestImplType implementation_type;
 
- implementation_type& impl_;
- std::size_t& bytes_left_;
- buffer_type::iterator pos_;
- bool& stdin_data_read_;
- std::size_t offset_;
-
- std::string boundary_marker;
- std::list<std::string> boundary_markers;
- std::vector<common::form_part> form_parts_;
-
- form_parser(implementation_type& impl)
- : impl_(impl)
- , bytes_left_(impl.characters_left_)
- , stdin_data_read_(impl.stdin_data_read_)
- , offset_(0)
- {
- }
- /*
- form_parser(std::size_t& cl, buffer_type& buf, map_type& m
- , unsigned int& client_bytes, bool& sp, bool& sdr
- , std::string ct, callback_type const & cb)
- : bytes_left_(cl)
- , buf_(buf)
- , map_(m)
- , client_bytes_left_(client_bytes)
- , stdin_parsed_flag_(sp)
- , stdin_data_read_(sdr)
- , offset_(0)
- , content_type_(ct)
- //, client_(c)
- , callback_(cb)
- {
-
- }
- */
+ form_parser(implementation_type& impl);
 
     mutable_buffers_type prepare(std::size_t size)
     {
- std::size_t bufsz(impl_.buf_.size());
- impl_.buf_.resize(bufsz + size);
- return boost::asio::buffer(&impl_.buf_[bufsz], size);
+ std::size_t bufsz(impl_.buffer_.size());
+ impl_.buffer_.resize(bufsz + size);
+ return boost::asio::buffer(&impl_.buffer_[bufsz], size);
     }
       
     std::string buffer_string()
     {
- return std::string(impl_.buf_.begin() + offset_, impl_.buf_.end());
+ return std::string(impl_.buffer_.begin() + offset_, impl_.buffer_.end());
     }
     
     boost::system::error_code
- parse(boost::system::error_code& ec)
- {
- parse_boundary_marker(ec);
- //parse_one_form_part(impl, ec);
-
- move_to_start_of_first_part(ec);
-
- if (ec == boost::asio::error::eof) {
- return boost::system::error_code();
- }else
- if (ec)
- return ec;
-
- do {
- parse_form_part(ec);
- }while( !impl_.stdin_parsed_
- && impl_.client_.bytes_left() != 0
- );//&& ec != boost::asio::error::eof );
-
- return ec;
- }
+ parse(boost::system::error_code& ec);
 
     boost::system::error_code
- parse_form_part(boost::system::error_code& ec)
- {
- if (!parse_form_part_meta_data(ec)
- && !parse_form_part_data(ec))
- return ec;
-
- return ec;
- }
+ parse_url_encoded_form(boost::system::error_code& ec);
 
     boost::system::error_code
- 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_.buf_.begin() + offset);
- buffer_iter end(impl_.buf_.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);
- impl_.post_vars_[form_parts_.back().name] = matches[1];
- offset_ = offset + matches[0].length();
- pos_ = matches[0].second;
-
- if (matches[3].matched)
- impl_.stdin_parsed_ = true;
- return ec;
- }
- else
- {
- std::size_t bytes_read = impl_.client_.read_some(prepare(64), ec);
-
- if (bytes_read == 0)
- {
- stdin_data_read_ = true;
- return ec;
- }
-
- begin = impl_.buf_.begin() + offset;
- end = impl_.buf_.end();
-
- if (ec)
- return ec;
- }
- }
- }
-
- return ec;
- }
+ parse_multipart_form(boost::system::error_code& ec);
 
     boost::system::error_code
- 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_.buf_.begin();
- int runs = 0;
-
- std::size_t bytes_read = 0;
- for(;;)
- {
- buffer_iter begin(impl_.buf_.begin() + offset);
- buffer_iter end(impl_.buf_.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;
- }
+ parse_form_part(boost::system::error_code& ec);
 
     boost::system::error_code
- 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_.buf_.begin());// + offset);
- buffer_iter end(impl_.buf_.end());
- if (!boost::regex_search(begin, end //impl.buf_.begin(), impl.buf_.end()
- , matches, re, boost::match_default | boost::match_partial))
- {
- offset = impl_.buf_.size();
- continue;
- }
- else
- {
- if (matches[2].matched)
- {
- impl_.buf_.erase(impl_.buf_.begin(), matches[0].second);
- offset_ = 0;
- pos_ = impl_.buf_.begin();
- return ec;
- }
- else
- {
- if (++runs > 10)
- return ec;
- continue;
- }
- }
- }
- // skip that line and then erase the buffer
- return ec;
- }
+ parse_form_part_data(boost::system::error_code& ec);
 
     boost::system::error_code
- parse_one_form_part(boost::system::error_code& ec)
- {
- // continuously read data while parsing it until one complete form part has
- // been read.
- // Note, this may mean recursing into embedded sub-parts if necessary, but
- // still only the first *complete* part/sub-part would be read.
- //boost::regex re("\r\n--" + boundary_marker + " +
-
- for(;;)
- {
- //if (impl.client_->read_some(impl.prepare(1024), ec))
- // return ec;
- //boost::asio::read_until(impl.client_-> impl.buffer_, boundary_marker, ec);
- break;
-
-
- }
+ parse_form_part_meta_data(boost::system::error_code& ec);
 
- return ec;
- }
+ boost::system::error_code
+ move_to_start_of_first_part(boost::system::error_code& ec);
 
     /// Get the boundary marker from the CONTENT_TYPE header.
     boost::system::error_code
- 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;
- }
+ parse_boundary_marker(boost::system::error_code& ec);
 
   private:
- //std::set<std::string> boundary_markers_;
- //std::vector<common::form_part> form_parts_;
+ implementation_type& impl_;
+ std::size_t& bytes_left_;
+ buffer_type::iterator pos_;
+ //bool& stdin_data_read_;
+ std::size_t offset_;
 
- //buffer_type& buffer_;
+ std::string boundary_marker;
+ std::list<std::string> boundary_markers;
+ std::vector<common::form_part> form_parts_;
 
     //callback_type callback_;
   };
@@ -425,5 +103,9 @@
  } // namespace detail
 } // namespace cgi
 
+#ifndef BOOST_CGI_BUILD_LIB
+# include "boost/cgi/impl/form_parser.ipp"
+#endif
+
 #endif // CGI_DETAIL_FORM_PARSER_HPP_INCLUDED__
 

Modified: sandbox/SOC/2007/cgi/branches/release/boost/cgi/common/form_part.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/common/form_part.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/common/form_part.hpp 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
@@ -37,7 +37,7 @@
      pair_t buffer_;
 
      std::string content_type; // must exist
- std::string name; // Has to exist?
+ std::string name; // must exist (?) **FIXME**
 
      // Using a simple map while everything is changing. This will not copy the
      // values when it is properly implemented (it'll hold a pair of iterators

Deleted: sandbox/SOC/2007/cgi/branches/release/boost/cgi/connection_base.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/connection_base.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/connections/async_stdio.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/connections/async_stdio.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/connections/async_stdio.hpp 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
@@ -13,10 +13,10 @@
 #include <boost/shared_ptr.hpp>
 #include <boost/system/error_code.hpp>
 #include <boost/enable_shared_from_this.hpp>
-
+///////////////////////////////////////////////////////////
+#include "boost/cgi/common/tags.hpp"
 #include "boost/cgi/connections/stdio.hpp"
-#include "boost/cgi/io_service.hpp"
-#include "boost/cgi/tags.hpp"
+#include "boost/cgi/import/io_service.hpp"
 
 namespace cgi {
  namespace common {
@@ -31,7 +31,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 +47,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,7 +119,7 @@
     }
 
   private:
- ::cgi::io_service& io_service_;
+ ::cgi::common::io_service& io_service_;
   };
 
   typedef basic_connection<tags::async_stdio> async_stdio_connection;

Modified: sandbox/SOC/2007/cgi/branches/release/boost/cgi/connections/shareable_tcp_socket.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/connections/shareable_tcp_socket.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/connections/shareable_tcp_socket.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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 {
@@ -63,8 +62,8 @@
     /** End FastCGI stuff **/
 
     // A wrapper to provide condition_type::pointer
- struct condition_type : public boost::condition
- { typedef boost::shared_ptr<boost::condition> pointer; };
+ struct condition_type : public boost::condition_variable
+ { typedef boost::shared_ptr<boost::condition_variable> pointer; };
 
     basic_connection(io_service& ios)
       : sock_(ios)

Modified: sandbox/SOC/2007/cgi/branches/release/boost/cgi/connections/stdio.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/connections/stdio.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/connections/stdio.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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 {
@@ -59,33 +59,7 @@
     template<typename MutableBufferSequence>
     std::size_t read_some(MutableBufferSequence buf
                          , boost::system::error_code& ec)
- {
- //if (std::cin.eof())
- //{
- //ec = boost::asio::error::eof;
- // return boost::asio::error::eof;
- //}
- //if( buf.data() != in_.rdbuf() )
- // return in_.read(buf.begin(), buf.size());
- //return buf.size();
-
- //std::cerr<< "In stdio::read_some()" << std::endl
- // << "before = {" << std::endl
- // << std::string(boost::asio::buffer_cast<char *>(buf), boost::asio::buffer_size(buf)) << std::endl
- // << "}" << std::endl;
- /*
- std::cin.read(boost::asio::buffer_cast<char *>(buf)
- , boost::asio::buffer_size(buf));
- if (std::cin.fail() && !std::cin.eof())
- {
- ec = boost::system::error_code(654, boost::system::system_category);
- return 0;
- }
- */
- //std::cerr<< "before = {" << std::endl
- // << std::string(boost::asio::buffer_cast<char *>(buf), boost::asio::buffer_size(buf)) << std::endl
- // << "}" << std::endl;
-
+ {
       if (std::fread(boost::asio::buffer_cast<void *>(buf)
                     , boost::asio::buffer_size(buf)
                     , 1, stdin))

Modified: sandbox/SOC/2007/cgi/branches/release/boost/cgi/connections/tcp_socket.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/connections/tcp_socket.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/connections/tcp_socket.hpp 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
@@ -11,11 +11,11 @@
 
 #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/common/connection_base.hpp"
 #include "boost/cgi/basic_connection.hpp"
+#include "boost/cgi/import/io_service.hpp"
 #include "boost/cgi/detail/push_options.hpp"
 
 namespace cgi {

Deleted: sandbox/SOC/2007/cgi/branches/release/boost/cgi/cookie.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/cookie.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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__
-

Deleted: sandbox/SOC/2007/cgi/branches/release/boost/cgi/data_sink.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/data_sink.hpp 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
+++ (empty file)
@@ -1,27 +0,0 @@
-// -- data_sink.hpp --
-//
-// Copyright (c) Darren Garvey 2007.
-// Distributed under the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-//
-////////////////////////////////////////////////////////////////
-#ifndef CGI_DATA_SINK_HPP_INCLUDED__
-#define CGI_DATA_SINK_HPP_INCLUDED__
-
-namespace cgi {
-
- enum sink
- { stdout_ = 0
- , stderr_ = 1
- };
-
- namespace data_sink {
-
- //struct stdout_ {};
- //struct stderr_ {};
-
- } // namespace data_sink
-} // namespace cgi
-
-#endif // CGI_DATA_SINK_HPP_INCLUDED__

Deleted: sandbox/SOC/2007/cgi/branches/release/boost/cgi/data_source.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/data_source.hpp 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
+++ (empty file)
@@ -1,30 +0,0 @@
-// -- data_source.hpp --
-//
-// Copyright (c) Darren Garvey 2007.
-// Distributed under the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-//
-////////////////////////////////////////////////////////////////
-#ifndef CGI_DATA_SOURCE_HPP_INCLUDED__
-#define CGI_DATA_SOURCE_HPP_INCLUDED__
-
-namespace cgi {
-
- enum source
- { stdin_ };
-
- namespace common {
-
- enum data_source
- { get_data
- , post_data
- , cookie_data
- , env_data
- , form_data
- };
-
- } // namespace common
-} // namespace cgi
-
-#endif // CGI_DATA_SOURCE_HPP_INCLUDED__

Modified: sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/cgi_request_impl_base.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/cgi_request_impl_base.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/cgi_request_impl_base.hpp 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
@@ -11,19 +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/map.hpp"
-//#include
-
-// Make this ProtocolService-independent
+#include "boost/cgi/common/status_type.hpp"
 
 namespace cgi {
+ namespace detail {
 
   //Forward declaration
   template<typename T>
@@ -38,58 +39,50 @@
    */
   template<typename Connection>
   class cgi_request_impl_base
+
   {
   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)
     {
     }
 
- map_type& env_vars() { return env_vars_; }
- map_type& get_vars() { return get_vars_; }
- map_type& post_vars() { return post_vars_; }
- map_type& cookie_vars() { return cookie_vars_; }
-
- 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_; }
- //std::string& null_str() { return null_str_; }
+ conn_ptr& connection() { return connection_; }
 
   public:
     //conn_ptr connection() { return connection_; }
 
     //friend class cgi_service_impl_base<RequestImpl>;
 
- map_type env_vars_;
- map_type get_vars_;
- map_type post_vars_;
- map_type cookie_vars_;
-
   public:
     bool stdin_parsed_;
     bool stdin_data_read_;
     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/release/boost/cgi/detail/cgi_service_impl_base.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/cgi_service_impl_base.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/cgi_service_impl_base.hpp 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
@@ -1,3 +1,11 @@
+// -- detail/cgi_service_impl_base.hpp --
+//
+// Copyright (c) Darren Garvey 2007-2008.
+// 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_IMPL_BASE_HPP_INCLUDED__
 #define CGI_CGI_SERVICE_IMPL_BASE_HPP_INCLUDED__
 
@@ -5,34 +13,31 @@
 
 #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/map.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
+ : public common::request_base<cgi_service_impl_base<RequestImplType> >
   {
   public:
     //typedef RequestImplType implementation_type;
@@ -49,11 +54,11 @@
 
     struct implementation_type
       : RequestImplType
+ , common::request_base<
+ cgi_service_impl_base<RequestImplType>
+ >::impl_base
     {
- typedef boost::asio::const_buffers_1 const_buffers_type;
- typedef boost::asio::mutable_buffers_1 mutable_buffers_type;
       typedef typename RequestImplType::client_type client_type;
- typedef std::vector<char> buffer_type;
       typedef detail::form_parser<implementation_type> form_parser_type;
 
       implementation_type()
@@ -66,12 +71,7 @@
       // The number of characters left to read (ie. "content_length - bytes_read")
       std::size_t characters_left_;
       
- buffer_type buf_;
-
- std::vector<common::form_part> form_parts_;
-
       boost::scoped_ptr<form_parser_type> fp_;
-
     };
 
     /// Return if the request is still open
@@ -82,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
@@ -92,9 +92,12 @@
       return impl.client_;
     }
 
- int close(implementation_type& impl, http::status_code& http_s, int status)
+ int request_id(implementation_type& impl) { return 1; }
+
+ int close(implementation_type& impl, common::http::status_code& http_s
+ , int status)
     {
- impl.status() = closed;
+ impl.status() = common::closed;
       impl.http_status() = http_s;
       return status;
     }
@@ -107,91 +110,28 @@
       load(implementation_type& impl, bool parse_stdin
           , boost::system::error_code& ec)
     {
- detail::save_environment(impl.env_vars());
- const std::string& cl = var(impl.env_vars(), "CONTENT_LENGTH", ec);
+ 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_;
 
- const std::string& request_method = var(impl.env_vars(), "REQUEST_METHOD", ec);
+ std::string const& request_method = env_vars(impl.vars_)["REQUEST_METHOD"];
       if (request_method == "GET")
- parse_get_vars(impl, ec);
+ this->parse_get_vars(impl, ec);
       else
       if (request_method == "POST" && parse_stdin)
         parse_post_vars(impl, ec);
 
       if (ec) return ec;
 
- parse_cookie_vars(impl, ec);
- impl.status() = loaded;
+ this->parse_cookie_vars(impl, ec);
+ impl.status() = common::loaded;
 
       //BOOST_ASSERT(impl.status() >= loaded);
 
       return ec;
     }
-
- std::string&
- var(map_type& meta_data, const std::string& name
- , boost::system::error_code& ec)
- {
- return meta_data[name];
- }
-
- std::string
- GET(implementation_type& impl, const std::string& name
- , boost::system::error_code& ec)
- {
- //BOOST_ASSERT(impl.status() >= loaded);
- return var(impl.get_vars(), name, ec);
- }
-
- map_type&
- GET(implementation_type& impl)
- {
- //BOOST_ASSERT(impl.status() >= loaded);
- return impl.get_vars();
- }
-
- /// Find the post meta-variable matching name
- /**
- * @param greedy This determines whether more data can be read to find
- * the variable. The default is true to cause least surprise in the common
- * case of having not parsed any of the POST data.
-
- -----------------------------------------------
- Should this return a pair of iterators instead?
- What about url_decoding?
- -----------------------------------------------
-
- */
- std::string
- POST(implementation_type& impl, const std::string& name
- , boost::system::error_code& ec, bool greedy = true)
- {
- //BOOST_ASSERT(impl.status() >= loaded);
- const std::string& val = var(impl.post_vars(), name, ec);
- if (val.empty() && greedy && !ec)
- {
-
- }
-
- return val;
- }
-
- map_type&
- POST(implementation_type& impl)
- {
- //BOOST_ASSERT(impl.status() >= loaded);
- return impl.post_vars();
- }
-
- // prefer this to the above
- map_type&
- POST(implementation_type& impl, boost::system::error_code& ec)
- {
- //BOOST_ASSERT(impl.status() >= loaded);
- return impl.post_vars();
- }
-
+/*
     // TODO: use `greedy`
     std::string
       form(implementation_type& impl, const std::string& name
@@ -205,6 +145,7 @@
                         if (rm == "POST")
                           return POST(impl, name, ec);
                         else
+ // **FIXME** What about HEAD, PUT ???
                           return "***BOOST_CGI_ERROR_INVALID_REQUEST_METHOD***";
                 }
                 
@@ -221,42 +162,7 @@
                         if (rm == "POST")
                           return POST(impl, ec);
                 }
-
- /// Find the cookie meta-variable matching name
- std::string
- cookie(implementation_type& impl, const std::string& name
- , boost::system::error_code& ec)
- {
- //BOOST_ASSERT(impl.status() >= loaded);
- return var(impl.cookie_vars(), name, ec);
- }
-
- map_type&
- cookie(implementation_type& impl)
- {
- //BOOST_ASSERT(impl.status() >= loaded);
- return impl.cookie_vars();
- }
-
-
- /// Find the environment meta-variable matching name
- std::string
- env(implementation_type& impl, const std::string& name
- , boost::system::error_code& ec)
- {
- //BOOST_ASSERT(impl.status() >= loaded);
- const char* c = ::getenv(name.c_str());
- return c ? c : std::string();
- }
-
- map_type&
- env(implementation_type& impl)
- {
- //BOOST_ASSERT(impl.status() >= loaded);
- return impl.env_vars();
- }
-
-
+*/
     role_type
       get_role(implementation_type& impl)
     {
@@ -264,51 +170,11 @@
     }
 
     /// 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&)
     {
     }
 
   protected:
- /// Read and parse the cgi GET meta variables
- template<typename RequestImpl>
- boost::system::error_code
- parse_get_vars(RequestImpl& impl, boost::system::error_code& ec)
- {
- // Make sure the request is in a pre-loaded state
- //BOOST_ASSERT (impl.status() <= unloaded);
-
- std::string& 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);
-
- return ec;
- }
-
- /// Read and parse the HTTP_COOKIE meta variable
- template<typename RequestImpl>
- boost::system::error_code
- parse_cookie_vars(RequestImpl& impl, boost::system::error_code& ec)
- {
- // Make sure the request is in a pre-loaded state
- //BOOST_ASSERT (impl.status() <= unloaded);
-
- std::string& 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);
-
- return ec;
- }
-
     /// Read and parse the cgi POST meta variables (greedily)
     template<typename RequestImpl>
     boost::system::error_code
@@ -317,95 +183,6 @@
       // Make sure this function hasn't already been called
       //BOOST_ASSERT (!impl.stdin_parsed());
 
- std::string content_type (var(impl.env_vars(), "CONTENT_TYPE", ec));
-
- BOOST_ASSERT(!content_type.empty());
-
- if (boost::algorithm::ifind_first(content_type,
- "application/x-www-form-urlencoded"))
- {
- detail::throw_error(
- parse_url_encoded_form(impl, ec)
- );
- }
- else
- {
- detail::throw_error(
- parse_multipart_form(impl, ec)
- );
- }
-
- return ec;
- }
-
- boost::system::error_code
- parse_url_encoded_form(implementation_type& impl
- , boost::system::error_code& ec)
- {
- std::string name;
- std::string str;
- map_type& post_map(impl.post_vars());
-
- char ch;
- char ch1;
- while( impl.characters_left_ )
- {
- ch = getchar();
- --impl.characters_left_;
-
- switch(ch)
- {
- case '%': // unencode a hex character sequence
- if (impl.characters_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);
- }
- impl.characters_left_ -= 2;
- }
- else // There aren't enough characters to make a hex sequence
- {
- str.append(1, '%');
- --impl.characters_left_;
- }
- break;
- case '+':
- str.append(1, ' ');
- break;
- case ' ':
- continue;
- case '=': // the name is complete, now get the corresponding value
- name = str;
- str.clear();
- break;
- case '&': // we now have the name/value pair, so save it
- post_map[name] = str;
- str.clear();
- name.clear();
- break;
- default:
- str.append(1, ch);
- }
- }
- // save the last param (it won't have a trailing &)
- if( !name.empty() )
- post_map[name] = str;//.empty() ? "" : str;
-
-
- return ec;
- }
-
- /// Parse a multipart form.
- boost::system::error_code
- parse_multipart_form(implementation_type& impl, boost::system::error_code& ec)
- {
       impl.fp_.reset
       (
         new typename implementation_type::form_parser_type
@@ -414,495 +191,6 @@
       impl.fp_->parse(ec);
       return ec;
     }
- /*
- parse_boundary_marker(impl, ec);
- //parse_one_form_part(impl, ec);
- move_to_start_of_first_part(impl, ec);
- if (ec == boost::asio::error::eof) {
- //cerr<< " -- Parsing done -- " << endl;
- //return ec.clear();
- return boost::system::error_code();
- }
-
- do {
- parse_form_part(impl, ec);
- }while( !impl.stdin_parsed_ && impl.client_.bytes_left() != 0 );
-
- // Do this just for now, for debugging
- parse_url_encoded_form(impl, ec);
- return ec;
- }
-
- boost::system::error_code
- parse_form_part(implementation_type& impl, boost::system::error_code& ec)
- {
- if (!parse_form_part_meta_data(impl, ec)
- && !parse_form_part_data(impl, ec))
- return ec;
-
- return ec;
- }
-
- boost::system::error_code
- parse_form_part_data(implementation_type& impl, boost::system::error_code& ec)
- {
- std::string regex("^(.*?)" // the data
- "\\x0D\\x0A" // CR LF
- "--" "(");
- if (impl.boundary_markers.size() > 1)
- {
- std::list<std::string>::iterator i(impl.boundary_markers.begin());
- regex = regex + "(?:" + *i + ")";
- ++i;
- for(; i != impl.boundary_markers.end(); ++i)
- {
- regex = regex + "|(?:" + *i + ")";
- }
- }
- else
- {
- regex += *impl.boundary_markers.begin();
- }
-
- regex += ")(--)?[ ]*\\x0D\\x0A";
- //cerr<< "Regex: " << regex << endl;
- boost::regex re(regex);
-
- typedef typename
- implementation_type::buffer_type::iterator
- buffer_iter;
-
- boost::match_results<buffer_iter> matches;
-
- std::size_t offset = impl.offset_;
- //cerr<< "offset = " << offset << endl;
-
- //int runs = 0;
- buffer_iter begin(impl.buf_.begin() + offset);
- buffer_iter end(impl.buf_.end());
-
- for(;;)
- {
- //cerr<< "Starting regex_search" << endl;
- if (!boost::regex_search(begin, end, matches, re
- , boost::match_default
- | boost::match_partial))
- {
- // cerr<< "Can't match any of this. {" << endl
- // << std::string(begin, end) << endl
- // << "}" << endl;
- return boost::system::error_code(345, boost::system::system_category);
- }
- else
- {
- for (unsigned int i = 0; i < matches.size(); ++i)
- {
- if (matches[i].length())
- {
- // cerr<< "[" << i << "] == {" << endl
- // << matches[i] << endl
- // << "}" << endl;
- }
- }
- // cerr<< "matches[0] = {" << endl
- // << matches[0].str() << endl
- // << "}" << endl;
- if (matches[1].matched)
- {
- impl.form_parts_.back().buffer_
- // = boost::range_iterator<;
- = std::make_pair(matches[1].first, matches[1].second);
- // cerr<< "Saved buffer (size: "
- // << std::distance(matches[1].first, matches[1].second)
- // << ") := { " << impl.form_parts_.back().name << ", " << matches[1] << " }" << endl;
- impl.post_vars()[impl.form_parts_.back().name] = matches[1];
- impl.offset_ = offset + matches[0].length();
- //offset += matches[0].length();
- impl.pos_ = matches[0].second;
- //cerr<< "offset := " << offset << endl
- // << "impl.offset_ := " << impl.offset_ << endl;
-
- if (matches[3].matched)
- impl.stdin_parsed_ = true;
- //if (impl.client_.bytes_left() == 0)
- //{
- // cerr<< "Read all the bytes up." << endl;
- //impl.stdin_parsed_ = true;
- return ec;
- //}
- }
- else
- {
- //cerr<< "Reading more data." << endl;
- std::size_t bytes_read = impl.client_.read_some(impl.prepare(64), ec);
- //impl.stdin_bytes_read_ += bytes_read;
-
- if (bytes_read == 0)
- {
- impl.stdin_data_read_ = true;
- return ec;
- }
-
- begin = impl.buf_.begin() + offset;
- end = impl.buf_.end();
- //cerr<< "Buffer (+" << bytes_read << ") == {" << endl
- // << std::string(begin, end) << endl
- // << "}" << endl;
-
- if (ec)
- {
- //cerr<< "Error in parse_form_part_data()." << endl;
- return ec;
- }
-
- }
- }
-
- }
-
-
- return ec;
- }
-
- boost::system::error_code
- parse_form_part_meta_data(implementation_type& impl, 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 typename
- implementation_type::buffer_type::iterator
- buffer_iter;
-
- boost::match_results<
- typename
- implementation_type::buffer_type::iterator
- > matches;
-
- std::size_t offset = impl.offset_;
- //cerr.flush();
- impl.pos_ = impl.buf_.begin();
- int runs = 0;
- //cerr<< "Entering for() loop." << endl;
- std::size_t bytes_read = 0;
- for(;;)
- {
- buffer_iter begin(impl.buf_.begin() + offset);
- buffer_iter end(impl.buf_.end());
-
- if (!boost::regex_search(begin, end, matches, re
- , boost::match_default | boost::match_partial))
- {
- //cerr<< "No chance of a match, quitting." << endl;
- impl.stdin_parsed_ = true;
- return ec;
- }
- //cerr<< "matches.str() == {" << endl
- // << matches.str() << endl
- // << "}" << endl
- // << matches.size() << " submatches" << endl;
- // for (unsigned i = matches.size(); i != 0; --i)
- // {
- //cerr<< "match[" << i << "] := { " << matches[i] << " }" << endl;
- //}
- 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];
- // cerr<< "Saved name" << endl;
- }
- else
- {
- part.meta_data_[matches[i]]
- = std::make_pair(matches[i+1].first, matches[i+1].second);
- // cerr<< "Part := { " << matches[i] << ", " << matches[i+1] << " }" << endl;
- //= boost::iterator_range<buffer_iter>(matches[3].first, matches[3].second);
- }
- impl.form_parts_.push_back(part);
-
-
- }
-
- if (matches[13].str() == "\r\n")
- {
- impl.offset_ = offset + matches[0].length();
- offset += matches[0].length();
- impl.pos_ = matches[0].second;
-
- //cerr<< "Current buffer == {" << endl
- // << impl.buffer_string() << endl
- // << "}" << endl;
- //cerr<< "Leaving parse_form_part_meta_data()" << endl;
- return ec;
- }
- else
- {
- throw std::runtime_error("Invalid POST data (header wasn't terminated as expected)");
- }
-
- }else{
- // cerr<< "Not read enough data yet, reading more." << endl;
- bytes_read = impl.client_.read_some(impl.prepare(64), ec);
- if (ec)
- {
- // cerr<< "Error reading data: " << ec.message() << endl;
- // cerr<< "Leaving parse_form_part_meta_data()" << endl;
- return ec;
- }
- // cerr<< "Read " << bytes_read << " bytes." << endl;
- //cerr<< "buffer = {" << endl
- // << impl.buffer_string() << endl
- // << "} or {" << endl;
- //<< std::string(impl.pos_, ;
- / *
- for (unsigned int i = 0; i < matches.size(); ++i)
- {
- if (matches[i].length())
- {
- cerr<< "[" << i << "] == {" << endl
- << matches[i] << endl
- << "}" << endl;
- }
- }
- cerr<< "-------buf------" << endl
- << std::string(begin, end) << endl
- << "----------------" << endl;
- * /
- //offset = impl.buf_.end();
- if (++runs > 40)
- {
- // cerr<< "Run 40 times; bailing out." << endl;
- break;
- }
- // cerr<< "Waiting buffer (unparsed) == {" << endl << std::flush
- // << impl.buffer_string() << endl
- // << "}" << endl
- // << "offset = " << offset << endl;
- //if (bytes_read == 0)
- // break;
- }
- }
-
- //cerr<< "impl.part
-
- // cerr<< "Leaving parse_form_part_meta_data()" << endl;
- return ec;
- }
-
- boost::system::error_code
- move_to_start_of_first_part(implementation_type& impl, boost::system::error_code& ec)
- {
- //cerr<< "Marker = " << impl.boundary_markers.front() << endl
- // << "blah" << "--" + impl.boundary_markers.front() + ")" << endl;
- boost::regex re("((?:.*)?" // optional leading characters
- //"(?:\\x0D\\x0A)|^" // start of line
- "[\\x0D\\x0A^]*?"
- "("
- "--" + impl.boundary_markers.front() + // two dashes and our marker
- ")"
- "(--)?" // optional two dashes (not sure if this is allowed)
- " *\\x0D\\x0A)");
- // on the first marker.
-
- typedef typename
- implementation_type::buffer_type::iterator
- buffer_iter;
-
- boost::match_results<
- typename
- implementation_type::buffer_type::iterator
- > matches;
- //cerr<< "Boundary marker == {" << endl
- // << impl.boundary_marker << endl
- // << "}" << endl;
-
- // 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 = impl.client_.read_some(impl.prepare(32), ec);
-// if (ec || (bytes_read == 0))
-// return ec;
- std::size_t bytes_read = 0;
- for(;;)
- {
- bytes_read = impl.client_.read_some(impl.prepare(32), ec);
- if (ec || (bytes_read == 0))
- return ec;
- buffer_iter begin(impl.buf_.begin());// + offset);
- buffer_iter end(impl.buf_.end());
- if (!boost::regex_search(begin, end //impl.buf_.begin(), impl.buf_.end()
- , matches, re, boost::match_default | boost::match_partial))
- {
- // No chance of matching input with expected, so erase it and start again.
- //std::cerr<< " == buffer = " << std::string(impl.buf_.begin(), impl.buf_.end())
- // << " == capacity = " << impl.buf_.capacity() << " ======= ";
- //impl.buf_.clear();
- // cerr<< "No chance of matching." << endl;
- offset = impl.buf_.size();
- //std::cerr<< "Buffer cleared." << endl;
- continue;
- }
- else
- {
- //std::cerr<< "regex_search == true" << std::endl
- // << "matches[0] =={{ " << matches[0] << " }}=== " << std::endl
- // << "matches[1] =={{ " << matches[1] << " }}=== " << std::endl
- // << "matches[2] =={{ " << matches[2] << " }}=== " << std::endl;
- if (matches[2].matched){
- // cerr<< "Found boundary marker... OK!!" << endl;
- //cerr<< "[0] = " << matches[0].str() << endl;
- //cerr<< "[1] = " << matches[1].str() << endl;
- //impl.offset_ = matches[1].length();
- //impl.pos_ = matches[0].second;
- //cerr<< "setting pos_ to < " << std::string(impl.pos_, impl.pos_ + 5) << "... >" << endl
- // << "setting offset_ = " << impl.offset_ << endl;
- // << std::string(matches[1].first, matches[1].second) << endl;
- //impl.pos_ = matches[1].second;
- //cerr<< "deleting {" << endl
- // << std::string(impl.buf_.begin(), matches[0].second) << endl
- // << "} leaving {" << endl
- // << std::string(matches[0].second, impl.buf_.end()) << endl
- // << "}" << endl;
- //cerr<< "bufsize = " << impl.buf_.size() << endl;
- //cerr<< "bufsize = " << impl.buf_.size() << endl;
- // cerr<< "buffer now (before erase) == {" << endl
- // << std::string(impl.buf_.begin(), impl.buf_.end()) << endl
- // << "}" << endl;
- impl.buf_.erase(impl.buf_.begin(), matches[0].second);
- impl.offset_ = 0;
- impl.pos_ = impl.buf_.begin();
- return ec;
- } else {
- // cerr<< "not read enough data" << std::endl;
- //std::cerr<< "; bytes_read = " << bytes_read
- // << "; bufsize = " << impl.buf_.size()
- // << "; capacity = " << impl.buf_.capacity() << std::flush
- // << "; data = {{" << std::string(impl.buf_.begin(), impl.buf_.end()) << "}}";
-
- if (++runs > 10)
- return ec;
- continue;
- }
- }
- }
-
-
- // skip that line and then erase the buffer
- return ec;
- }
-
- boost::system::error_code
- parse_one_form_part(implementation_type& impl, boost::system::error_code& ec)
- {
- // continuously read data while parsing it until one complete form part has
- // been read.
- // Note, this may mean recursing into embedded sub-parts if necessary, but
- // still only the first *complete* part/sub-part would be read.
- //boost::regex re("\r\n--" + impl.boundary_marker + " +
-
- for(;;)
- {
- //if (impl.client_.read_some(impl.prepare(1024), ec))
- // return ec;
- //boost::asio::read_until(impl.client_, impl.buffer_, impl.boundary_marker, ec);
- break;
-
-
- }
-
- return ec;
- }
-
- /// Get the boundary marker from the CONTENT_TYPE header.
- boost::system::error_code
- parse_boundary_marker(implementation_type& impl, boost::system::error_code& ec)
- {
- // get the meta-data appended to the content_type
- std::string content_type(var(impl.env_vars(), "CONTENT_TYPE", ec));
- //BOOST_ASSERT(!content_type.empty());
-
- //boost::algorithm::ifind(var(impl, "CONTENT_TYPE"), "bounday="
-
- 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);
-
- impl.boundary_marker = match_results[1].str();
- // New boundary markers are added to the front of the list.
- impl.boundary_markers.push_front(match_results[1].str());
-
- / *
- cerr<< "full = " << content_type << endl
- << "full search string = " << match_results[0] << endl
- << "marker length = " << match_results[1].length() << endl
- << "marker = " << impl.boundary_marker << endl
- << "_[2] = " << match_results[2] << endl;
- * /
-
- return ec;
- }
-*/
- /// Read and parse a single cgi POST meta variable (greedily)
- template<typename RequestImpl>
- boost::system::error_code
- parse_one_post_var(RequestImpl& impl, boost::system::error_code& ec)
- {
- //# error "Not implemented"
- return ec;
- }
   };
 
 } // namespace cgi

Modified: sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/common_headers.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/common_headers.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/common_headers.hpp 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
@@ -12,17 +12,17 @@
 // #include all protocol-independent headers only. Protocol-specific
 // headers can just include this after other headers.
 
-#include "boost/cgi/buffer.hpp"
-#include "boost/cgi/map.hpp"
-#include "boost/cgi/io_service.hpp"
-#include "boost/cgi/streambuf.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/common/map.hpp"
+#include "boost/cgi/import/read.hpp"
+#include "boost/cgi/import/write.hpp"
+#include "boost/cgi/basic_request.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_CGI_CGI_HPP_INCLUDED__

Modified: sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/extract_params.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/extract_params.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/extract_params.hpp 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
@@ -13,7 +13,7 @@
 #include <boost/tokenizer.hpp>
 #include <boost/system/error_code.hpp>
 
-#include "url_decode.hpp"
+#include "boost/cgi/detail/url_decode.hpp"
 
 namespace cgi {
  namespace detail {
@@ -47,9 +47,9 @@
          name = current_token;
          current_token.clear();
        }else
- if( *iter == "&" )
+ if( *iter == "&" || *iter == ";" )
        {
- destination[name] = current_token;
+ destination[name.c_str()] = current_token;
          current_token.clear();
          name.clear();
        }else
@@ -58,7 +58,7 @@
        }
      }
      if( !name.empty() )
- destination[name] = current_token;
+ destination[name.c_str()] = current_token;
 
      return ec;
    }

Modified: sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/protocol_traits.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/protocol_traits.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/protocol_traits.hpp 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
@@ -17,10 +17,11 @@
 #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 {
 
@@ -78,6 +79,8 @@
 
  namespace detail {
 
+ namespace tags = ::cgi::common::tags;
+
    template<typename Protocol>
     struct protocol_traits
     {
@@ -89,12 +92,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;
     };
@@ -105,12 +111,17 @@
       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 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;
     };
@@ -122,12 +133,17 @@
       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 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 acgi_service_impl service_impl_type;
- typedef common::basic_connection<tags::async_stdio> connection_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 +154,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 +190,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/release/boost/cgi/detail/push_options.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/push_options.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/push_options.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/detail/save_environment.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/save_environment.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/save_environment.hpp 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
@@ -12,7 +12,7 @@
 #include <map>
 #include <string>
 #include <cstdlib>
-#include "boost/cgi/map.hpp"
+#include "boost/cgi/common/map.hpp"
 
 // The process' environment
 #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
@@ -34,6 +34,9 @@
    template<typename MapT>
    void save_environment(MapT& env_map, char** env = environ)
    {
+ std::string sa;
+ std::string sb;
+
      for(; *env; ++env)
      {
        int i=0;
@@ -46,9 +49,9 @@
        // we are free to ignore them too.
        if ((*env)[i+1] != '\0')
        {
- std::string sa(*env, i);
- std::string sb((*env+i+1), j-i-1);
- env_map[sa] = sb;
+ sa.assign(*env, i);
+ sb.assign((*env+i+1), j-i-1);
+ env_map[sa.c_str()] = sb;
        }
      }
    }

Modified: sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/url_decode.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/url_decode.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/detail/url_decode.hpp 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
@@ -9,96 +9,31 @@
 #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);
- }
-
- /// Workaround for istreams, since the above can't be used directly
- char url_decode(std::istream& is)
- {
- const char c1 = is.get();
- return url_decode(c1, is.get());
- }
+ 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
 
+#include "boost/cgi/detail/url_decode.ipp"
+
+#include "boost/cgi/detail/pop_options.hpp"
+
 #endif // CGI_DETAIL_URL_DECODE_HPP_INCLUDED__

Modified: sandbox/SOC/2007/cgi/branches/release/boost/cgi/error.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/error.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/error.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/fcgi.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/fcgi.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/fcgi.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/fcgi/acceptor_service_impl.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/fcgi/acceptor_service_impl.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/fcgi/acceptor_service_impl.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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())

Modified: sandbox/SOC/2007/cgi/branches/release/boost/cgi/fcgi/client.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/fcgi/client.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/fcgi/client.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/map.hpp"
-#include "boost/cgi/io_service.hpp"
+///////////////////////////////////////////////////////////
+#include "boost/cgi/error.hpp"
+#include "boost/cgi/common/map.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;
@@ -254,10 +256,13 @@
       return keep_connection_;
     }
 
+ //int id() { return request_id_; }
+
   public:
     friend class fcgi_request_service;
     boost::uint16_t request_id_;
     client_status status_;
+ std::size_t bytes_left_;
     //request_impl_type* current_request_;
     
     /// A marker to say if the final STDIN (and/or DATA) packets have been
@@ -291,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/release/boost/cgi/fcgi/request.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/fcgi/request.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/fcgi/request.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/fcgi/request_acceptor_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/fcgi/request_acceptor_service.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/fcgi/request_acceptor_service.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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_> >
   {
@@ -48,7 +46,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)
     {

Modified: sandbox/SOC/2007/cgi/branches/release/boost/cgi/fcgi/request_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/fcgi/request_service.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/fcgi/request_service.hpp 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
@@ -9,19 +9,22 @@
 #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/cgi/scgi/request_impl.hpp"
-#include "boost/cgi/map.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/fusion/include/vector.hpp>
+////////////////////////////////////////////////////////////////
+#include "boost/cgi/common/map.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/detail/extract_params.hpp"
-//#include "boost/cgi/basic_request.hpp"
-#include "boost/cgi/fcgi/client.hpp"
+#include "boost/cgi/common/form_parser.hpp"
 
 namespace cgi {
 
@@ -58,21 +61,16 @@
   /// The IoObjectService class for a FCGI basic_request<>s
   class fcgi_request_service
     : public detail::service_base<fcgi_request_service>
+ , public common::request_base<fcgi_request_service>
   {
   public:
     /// The actual implementation date for an FCGI request.
     struct implementation_type
+ : common::request_base<fcgi_request_service>::impl_base
     {
- typedef ::cgi::common::map map_type;
- //typedef shareable_tcp_connection connection_type;
- typedef ::cgi::fcgi_ protocol_type;
- //typedef basic_client<
- // connection_type, protocol_type
- //> client_type;
+ typedef ::cgi::common::fcgi_ protocol_type;
       typedef ::cgi::fcgi::client client_type;
       typedef client_type::connection_type connection_type;
- typedef std::vector<char> buffer_type;
- typedef boost::asio::mutable_buffers_1 mutable_buffers_type;
       typedef client_type::header_buffer_type header_buffer_type;
       typedef detail::protocol_traits<
         protocol_type
@@ -84,8 +82,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)
       {
@@ -96,18 +94,10 @@
       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_;
 
- buffer_type buffer_;
-
- map_type env_vars_;
- map_type get_vars_;
- map_type post_vars_;
- map_type cookie_vars_;
-
- std::string null_str_;
       bool all_done_;
 
       mutable_buffers_type prepare(std::size_t size)
@@ -122,18 +112,6 @@
         //{
           buffer_.resize(bufsz + size);
         //}
- /*
- cerr<< "Pre-read buffer (size: " << buffer_.size()
- << "|capacity: " << buffer_.capacity() << ") == {" << endl
- << std::string(buffer_.begin(), buffer_.end()) << endl
- // << "-----end buffer-----" << endl
- // << "-------buffer-------" << endl
- // << std::string(&buf_[0], &buf_[buf_.size()]) << endl
- << "}" << endl;
- ;
- */
- //return boost::asio::buffer(&(*(buf_.end())), size);
- // return boost::asio::buffer(&(*(buf_.begin())) + bufsz, size);
         return boost::asio::buffer(&buffer_[bufsz], size);
       }
 
@@ -141,15 +119,17 @@
      /************** New stuff *****************/
       header_buffer_type header_buf_;
       boost::uint16_t id_;
- };
+ typedef detail::form_parser<implementation_type> form_parser_type;
+
+ boost::scoped_ptr<form_parser_type> fp_;
+ };
 
     typedef fcgi_request_service type;
     typedef ::cgi::fcgi::fcgi_request_service full_type;
     typedef type::implementation_type::protocol_type protocol_type;
- typedef type::implementation_type::map_type map_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)
     {
     }
@@ -160,11 +140,9 @@
 
     void construct(implementation_type& impl)
     {
- //std::cerr<< "request_service.hpp:83 Creating connection" << std::endl;
       impl.client_.set_connection(//new implementation_type::connection_type(this->io_service()));
         implementation_type::connection_type::create(this->io_service())
       );
- //std::cerr<< "conn.is_open() == " << impl.client_.is_open() << std::endl;
     }
 
     void destroy(implementation_type& impl)
@@ -190,7 +168,7 @@
     }
 
     /// Close the request.
- int close(implementation_type& impl, http::status_code& hsc
+ int close(implementation_type& impl, ::cgi::common::http::status_code& hsc
               , int program_status)
     {
       impl.all_done_ = true;
@@ -198,7 +176,7 @@
       return program_status;
     }
 
- int close(implementation_type& impl, http::status_code& hsc
+ int close(implementation_type& impl, ::cgi::common::http::status_code& hsc
              , int program_status, boost::system::error_code& ec)
     {
       impl.all_done_ = true;
@@ -209,19 +187,19 @@
     void clear(implementation_type& impl)
     {
       BOOST_ASSERT
- ( impl.request_status_ < activated
- && impl.request_status_ > ok
+ ( impl.request_status_ < common::activated
+ && impl.request_status_ > common::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();
+ common::get_vars(impl.vars_).clear();
+ common::post_vars(impl.vars_).clear();
+ common::cookie_vars(impl.vars_).clear();
+ common::env_vars(impl.vars_).clear();
       impl.stdin_parsed_ = false;
- impl.http_status_ = http::no_content;
- impl.request_status_ = null;
+ impl.http_status_ = common::http::no_content;
+ impl.request_status_ = common::null;
       impl.request_role_ = spec_detail::ANY;
       impl.all_done_ = false;
 
@@ -244,7 +222,6 @@
           , boost::system::error_code& ec)
     {
       //int header_len( get_length_of_header(impl, ec) );
- //std::cerr<< "Loading request...";
       BOOST_ASSERT(!ec && "Can't load request due to previous errors.");
 
       impl.client_.construct(impl, ec);
@@ -283,25 +260,23 @@
 
       while(!ec
         && impl.client_.status() < completion_condition
- && impl.request_status_ != loaded)
+ && impl.request_status_ != common::loaded)
       {
         //impl.client_.parse_packet(impl, ec);
         parse_packet(impl, ec);
       }
 
- const std::string& request_method = env(impl, "REQUEST_METHOD", ec);
+ const std::string& request_method = env_vars(impl.vars_)["REQUEST_METHOD"];
       if (request_method == "GET")
         if (parse_get_vars(impl, ec))
           return ec;
-/** FIXME **
       else
       if (request_method == "POST" && parse_stdin)
         if (parse_post_vars(impl, ec))
               return ec;
-*/
+
       parse_cookie_vars(impl, ec);
 
- //std::cerr<< "done!" << std::endl;
       return ec;
     }
 
@@ -314,93 +289,6 @@
       );
     }
 
- /* These Don't Belong Here.
- template<typename MutableBufferSequence>
- std::size_t read_some(implementation_type& impl
- , const MutableBufferSequence& buf
- , boost::system::error_code& ec)
- {
- std::size_t s = impl.connection()->read_some(buf, ec);
- return s;
- }
-
- template<typename ConstBufferSequence>
- std::size_t write_some(implementation_type& impl
- , const ConstBufferSequence& buf
- , boost::system::error_code& ec)
- {
- return impl.connection()->write_some(buf, ec);
- }
-
- //template<typename VarType> map_type& var(implementation_type&) const;
- ********************************************/
-
- std::string GET(implementation_type& impl, const std::string& name
- , boost::system::error_code& ec)
- {
- return var(impl.get_vars_, name, ec);
- }
-
- map_type& GET(implementation_type& impl)
- {
- return impl.get_vars_;
- }
-
- /// Find the post meta-variable matching name
- /**
- * @param greedy This determines whether more data can be read to find
- * the variable. The default is true to cause least surprise in the common
- * case of having not parsed any of the POST data.
-
- -----------------------------------------------
- Should this return a pair of iterators instead?
- What about url_decoding?
- -----------------------------------------------
-
- */
- std::string POST(implementation_type& impl, const std::string& name
- , boost::system::error_code& ec
- , bool greedy = true)
- {
- const std::string& val = var(impl.post_vars_, name, ec);
- if (val.empty() && greedy && !ec)
- {
-
- }
-
- return val;
- }
-
- map_type& POST(implementation_type& impl)
- {
- return impl.post_vars_;
- }
-
-
- /// Find the cookie meta-variable matching name
- std::string cookie(implementation_type& impl, const std::string& name
- , boost::system::error_code& ec)
- {
- return var(impl.cookie_vars_, name, ec);
- }
-
- map_type& cookie(implementation_type& impl)
- {
- return impl.cookie_vars_;
- }
-
- /// Find the environment meta-variable matching name
- std::string env(implementation_type& impl, const std::string& name
- , boost::system::error_code& ec)
- {
- return var(impl.env_vars_, name, ec);
- }
-
- map_type& env(implementation_type& impl)
- {
- return impl.env_vars_;
- }
-
     role_type get_role(implementation_type& impl)
     {
       return responder;
@@ -413,70 +301,22 @@
     }
 
   protected:
- /// Extract the var value from
- std::string var(map_type& _data, const std::string& _name
- , boost::system::error_code& ec)
- {
- /* Alt:
- if ((typename map_type::iterator pos = meta_data.find(name))
- != meta_data.end())
- {
- return *pos;
- }
- return std::string();
- **/
-
- if( _data.find(_name) != _data.end() )
- return _data[_name];
- return "";
- }
-
- /// Read and parse the cgi GET meta variables
- boost::system::error_code&
- parse_get_vars(implementation_type& impl, boost::system::error_code& ec)
- {
- detail::extract_params(env(impl, "QUERY_STRING", ec)
- , impl.get_vars_
- , boost::char_separator<char>
- ("", "=&", boost::keep_empty_tokens)
- , ec);
-
- return ec;
- }
-
- /// Read and parse the HTTP_COOKIE meta variable
- boost::system::error_code&
- parse_cookie_vars(implementation_type& impl, boost::system::error_code& ec)
- {
- // Make sure this function hasn't already been called
- //BOOST_ASSERT( impl.cookie_vars_.empty() );
-
- std::string vars = env(impl, "HTTP_COOKIE", ec);
- if (vars.empty())
- return ec;
-
- detail::extract_params(env(impl, "HTTP_COOKIE", ec)
- , impl.cookie_vars_
- , boost::char_separator<char>
- ("", "=&", boost::keep_empty_tokens)
- , ec);
-
- return ec;
- }
-
     /// Read and parse the cgi POST meta variables (greedily)
- template<typename RequestImpl>
     boost::system::error_code&
     parse_post_vars(implementation_type& impl, boost::system::error_code& ec)
     {
       // Make sure this function hasn't already been called
- //BOOST_ASSERT( impl.post_vars_.empty() );
+ //BOOST_ASSERT( impl.post_vars().empty() );
           
       //# error "Not implemented"
-
- if (impl.stdin_parsed_)
- {
- }
+/*
+ impl.fp_.reset
+ (
+ new typename implementation_type::form_parser_type
+ ( impl )
+ );
+ impl.fp_->parse(ec);
+*/
 
       return ec;
     }
@@ -571,7 +411,7 @@
     {
       if (id == fcgi::spec::get_request_id(impl.header_buf_))
       {
- impl.request_status_ = aborted;
+ impl.request_status_ = common::aborted;
         return ec;
       }
       try {
@@ -650,7 +490,8 @@
         //std::cerr<< "[hw] name := " << name << std::endl;
         //std::cerr<< "[hw] data := " << data << std::endl;
 
- impl.env_vars_[name] = data;
+ // **FIXME**
+ env_vars(impl.vars_)[name.c_str()] = data;
       }
 
       return ec;
@@ -725,13 +566,10 @@
       }else
       if (!state)
       { // The header is confusing; something's wrong. Abort.
- //std::cerr<< "Bad header received (this isn't implemented properly yet"
- // << std::endl;
         return error::bad_header_type;
       }
       // else route (ie. state == boost::indeterminate)
 
- //std::cerr<< "Got to read more stuff now I think." << std::endl;
       implementation_type::mutable_buffers_type buf
         = impl.prepare(fcgi::spec::get_length(impl.header_buf_));
 
@@ -762,62 +600,41 @@
       parse_body(implementation_type& impl, const MutableBuffersType& buffer
                 , boost::system::error_code& ec)
     {
- return //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);
     }
 
-/*
- implementation_type::request_type&
- get_or_make_request(implementation_type& impl, boost::uint16_t id);
 
- request_type::pointer ret
-
- try {
- ret = &requests.at(id - 1);
- BOOST_ASSERT(req != 0); // should throw
- return *ret;
- }catch(...){
- req = request_type::create(impl.service_);
- if (requests.size() < (id - 1))
- requests.resize(id);
- requests.at(id-1) = *req;
- return req->impl(); // same as *ret
- }
- }
-*/
- 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::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));
+ 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;
         
- // 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_;
- //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;
-
- impl.client_.status_ = common::constructed;
- 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;
+ }
+ };
 
   //template<>
   const fcgi_request_service::proc_func_t fcgi_request_service::proc_funcs[] =
@@ -905,3 +722,4 @@
 } // namespace cgi
 
 #endif // CGI_FCGI_REQUEST_SERVICE_HPP_INCLUDED__
+

Modified: sandbox/SOC/2007/cgi/branches/release/boost/cgi/fcgi/service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/fcgi/service.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/fcgi/service.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/header.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/header.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/http/status_code.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/http/status_code.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/boost/cgi/http/status_code.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/io_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/io_service.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/io_service_provider.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/io_service_provider.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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 boost::ref(*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/release/boost/cgi/io_service_provider_fwd.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/io_service_provider_fwd.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/is_async.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/is_async.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/map.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/map.hpp 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
+++ (empty file)
@@ -1,23 +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__
-
-#include <map>
-#include <string>
-
-namespace cgi {
- namespace common {
-
- typedef std::map<std::string,std::string> map;
-
- } // namespace common
-} // namespace cgi
-
-#endif // CGI_MAP_HPP_INCLUDED__

Deleted: sandbox/SOC/2007/cgi/branches/release/boost/cgi/read.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/read.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/request.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/request.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/request_acceptor_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/request_acceptor_service.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/request_base.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/request_base.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/request_ostream.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/request_ostream.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/request_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/request_service.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/request_service_fwd.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/request_service_fwd.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/response.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/response.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/return.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/return.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/role_type.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/role_type.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/status_type.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/status_type.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/streambuf.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/streambuf.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/tags.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/tags.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/boost/cgi/write.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/boost/cgi/write.hpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/libs/cgi/build/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/libs/cgi/build/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/branches/release/libs/cgi/build/Jamfile.v2 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
@@ -3,13 +3,60 @@
 # user-supplied variables (ie. using modules.peek, I think)
 
 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
+ : usage-requirements
+ <include>$(top)
+ <include>$(boost-root)
+ <library>/boost/thread/
+ <library>/boost/system/
+ <library>/boost/regex/
+ <linkflags>-pthread
   ;
 
 
+import modules ;
+
+# make BB recognise .ipp files as .cpp files.
+import type ;
+type.register IPP : ipp : CPP ;
+
+path-constant impl : $(top)/boost/cgi/impl ;
+
+SOURCES =
+ $(impl)/form_parser.ipp
+ $(impl)/response.ipp
+ ;
+
+
+if [ MATCH "^(--build-cgi)" : [ modules.peek : ARGV ] ]
+{ # compile library
+ ECHO "Building CGI library" ;
+
+ lib boost_cgi
+ :
+ $(SOURCES)
+ :
+ <define>BOOST_CGI_BUILD_LIBRARY
+ ;
+}
+else
+{
+ alias boost_cgi ;
+}
+
+install install
+ :
+ boost_cgi
+ :
+ <location>/usr/local/lib
+ ;
+

Modified: sandbox/SOC/2007/cgi/branches/release/libs/cgi/doc/src/cgi.qbk
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/libs/cgi/doc/src/cgi.qbk (original)
+++ sandbox/SOC/2007/cgi/branches/release/libs/cgi/doc/src/cgi.qbk 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
@@ -111,10 +111,14 @@
 
 [/include:ug user_guide.qbk]
 
-[xinclude ../cgi_dox.xml]
+[/xinclude ../cgi_dox.xml]
+
+[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/release/libs/cgi/doc/src/reference.qbk
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/libs/cgi/doc/src/reference.qbk (original)
+++ sandbox/SOC/2007/cgi/branches/release/libs/cgi/doc/src/reference.qbk 2008-06-02 17:54:00 EDT (Mon, 02 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/release/libs/cgi/example/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/Jamfile.v2 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
@@ -6,6 +6,7 @@
 
 project boost/cgi/example
 : requirements
+ <library>/boost/cgi/
       <library>/boost/system/
       <library>/boost/thread/
   ;
@@ -17,6 +18,8 @@
 # Build all of the fcgi examples
 build-project fcgi ;
 
+alias all_examples : cgi acgi fcgi ;
+
 install cgi-install
  : # sources
    cgi//install
@@ -38,6 +41,8 @@
     <location>$(fcgi-bin)
   ;
 
+alias install : cgi//install acgi//install fcgi//install ;
+
 explicit cgi-install ;
 explicit acgi-install ;
 explicit fcgi-install ;

Modified: sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/amortization/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/amortization/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/amortization/main.cpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/libs/cgi/example/acgi/cookie_game/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/cookie_game/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/cookie_game/main.cpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/libs/cgi/example/acgi/doc.qbk
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/doc.qbk (original)
+++ sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/doc.qbk 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
@@ -1,6 +1,10 @@
 
 [section aCGI Examples]
 
+Things in the `acgi` namespace are 'Asio-enabled' versions of those in the `cgi` namespace. The aCGI (*a* for asynchronous) parts of the library are especially useful if you are writing long-running CGI applications that could benefit from using asynchronous I/O or asynchronous event dispatching.
+
+If not, there may be a small speed/size gain to be had from the plain CGI components.
+
 [include hello_world/doc.qbk]
 
 [include echo/doc.qbk]

Modified: sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/echo/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/echo/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/echo/Jamfile.v2 2008-06-02 17:54:00 EDT (Mon, 02 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/release/libs/cgi/example/acgi/echo/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/echo/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/echo/main.cpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/libs/cgi/example/acgi/hello_world/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/hello_world/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/hello_world/main.cpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/libs/cgi/example/acgi/login/CheckCookie.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/login/CheckCookie.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/login/CheckCookie.cpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/libs/cgi/example/acgi/login/Login.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/login/Login.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/login/Login.cpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/libs/cgi/example/acgi/login/Logout.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/login/Logout.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/acgi/login/Logout.cpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/libs/cgi/example/cgi/echo/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/cgi/echo/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/cgi/echo/Jamfile.v2 2008-06-02 17:54:00 EDT (Mon, 02 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/release/libs/cgi/example/cgi/echo/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/cgi/echo/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/cgi/echo/main.cpp 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
@@ -19,27 +19,30 @@
 
 using namespace boost::cgi;
 
+//
 // This function writes the title and map contents to the ostream in an
 // HTML-encoded format (to make them easier on the eye).
+//
 template<typename OStreamT, typename MapT>
 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::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 />";
 }
 
 int main()
 {
- request req;
-
- req.load(true); // The 'true' means parse STDIN data too.
-
+ request req; // A basic CGI request auto-parses everything (including POST data).
   response resp;
 
+ resp<< "Request id = " << req.id() << "<p/>";
+
   show_map_contents(resp, req[env_data], "Environment Variables");
   show_map_contents(resp, req[get_data], "GET Variables");
   show_map_contents(resp, req[post_data], "POST Variables");

Modified: sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/fcgi/echo/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/fcgi/echo/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/fcgi/echo/main.cpp 2008-06-02 17:54:00 EDT (Mon, 02 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;
@@ -27,10 +29,12 @@
 // This is a file to put internal logging info into
 #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(Map& m, OStream& os, const std::string& title)
+void format_map(OStream& os, Map& m, const std::string& title)
 {
   os<< "<h2>" << title << "</h2>";
   if (m.empty()) os<< "NONE<br />";
@@ -41,46 +45,75 @@
   }
 }
 
-/// This function accepts and handles a single request.
-template<typename Service, typename Acceptor, typename LogStream>
-int handle_request(Service& s, Acceptor& a, LogStream& of)
+std::size_t process_id()
 {
- // First we construct a `request` object.
- request req(s); // This is in a protocol-specific state at the moment.
+#if defined(BOOST_WINDOWS)
+ return _getpid();
+#else
+ return getpid();
+#endif
+}
 
- of<< "Constructed request" << endl;
+/// This function accepts and handles a single request.
+template<typename Request, typename LogStream>
+int handle_request(Request& req, LogStream& of)
+{
   boost::system::error_code ec;
   
- // The program blocks here until a request arrives.
- a.accept(req, ec);
-
   of<< "Called accept" << endl;
   // Result should be "Success".
   of<< "Accept had result: " << ec.message() << endl;
 
+ //
   // Load in the request data so we can access it easily.
+ //
   req.load(ec, true); // The 'true' means read and parse STDIN (ie. POST) data.
 
+ //
   // 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 />";
+ << "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"] << "' />"
+ "<br />"
+ "<input type=text name=hello value='" << req[post]["hello"] << "' />"
+ "<br />"
+ "<input type=file name=user_file />"
+ "<input type=hidden name=cmd value=multipart_test />"
+ "<br />"
+ "<input type=submit value=submit />"
+ "</form><p />";
 
+ //
   // Use the function defined above to show some of the request data.
- format_map(req.env(), resp, "Environment Variables");
- format_map(req.GET(), resp, "GET Variables");
- format_map(req.cookie(), resp, "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) << ">";
 
+ //
+ //
   // This funky macro finishes up:
   return_(resp, req, 0);
+ //
   // It is equivalent to the below, where the third argument is represented by
   // `program_status`:
   //
@@ -89,6 +122,7 @@
   // return program_status;
   //
   // Note: in this case `program_status == 0`.
+ //
 }
 
 int main()
@@ -110,15 +144,27 @@
   // Make an `acceptor` for accepting requests through.
   acceptor a(s);
 
+ //
   // After the initial setup, we can enter a loop to handle one request at a
   // time until there's an error of some sort.
+ //
   int ret(0);
   for (;;)
   {
- ret = handle_request(s, a, of);
- of<< "handle_request() returned: " << ret << endl;
- if (ret)
- break;
+ request req(s);
+ //
+ // Now we enter another loop that reuses the request's connection (and
+ // memory - makes things more efficient). You should always do this for
+ // now; this requirement will be removed in future.
+ //
+ for (;;)
+ {
+ a.accept(req);
+ ret = handle_request(req, of);
+ of<< "handle_request() returned: " << ret << endl;
+ if (ret)
+ break;
+ }
   }
   
   return ret;

Modified: sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/fcgi/server1/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/fcgi/server1/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/fcgi/server1/main.cpp 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
@@ -20,23 +20,16 @@
 // This is very similar to the fcgi_echo example.
 //
 
-#include <fstream>
-#include <boost/bind.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"
+#include "./server.hpp"
 
 using namespace std;
 using namespace boost::fcgi;
 
-// This is a file to put internal logging info into
-#define LOG_FILE "/var/www/log/fcgi_server1.txt"
-
 // This function writes 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(Map& m, OStream& os, const std::string& title)
+template<typename OStream, typename Map>
+void format_map(OStream& os, Map& m, const std::string& title)
 {
   os<< "<h2>" << title << "</h2>";
   if (m.empty()) os<< "NONE<br />";
@@ -47,150 +40,62 @@
   }
 }
 
-/// The handle_request member function is used to handle requests.
-/**
- * A struct is used here just so a single log file can be shared between
- * requests. Note that access to the log file isn't synchronised (this doesn't
- * matter with this example).
- */
-struct request_handler
-{
- request_handler(const std::string& file_name)
- : log_(file_name.c_str())
- {
- if (!log_)
- {
- std::cerr<< "[fcgi] Couldn't open file: \"" LOG_FILE "\"." << endl;
- throw std::runtime_error("Couldn't open log file");
- }
-
- log_<< boost::posix_time::second_clock::local_time() << endl;
- }
-
- int handle_request(fcgi::request& req, boost::system::error_code& ec)
- {
- std::ofstream log_(LOG_FILE, std::ios::app);
- //log_<< "Handling request" << endl
- // << "QUERY_STRING := " << req.query_string() << std::endl;
-
- // 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(req.env(), resp, "Environment Variables");
- format_map(req.GET(), resp, "GET Variables");
- format_map(req.cookie(), resp, "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());
-
- //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`.
- }
-
-private:
- std::ofstream log_;
-};
-
-
-/// The server is used to abstract away protocol-specific setup of requests.
-/**
- * This server only works with FastCGI, but as you can see in the
- * request_handler::handle_request() function above, the request in there could
- * just as easily be a cgi::request.
- *
- * Later examples will demonstrate making protocol-independent servers.
- * (**FIXME**)
- */
-class server
+/// The handle_request function handles a single request.
+int handle_request(request& req, boost::system::error_code& ec)
 {
-public:
- typedef fcgi::request request_type;
- typedef boost::function<
- int ( request_type&
- , boost::system::error_code&)
- > function_type;
-
- server(const function_type& handler)
- : handler_(handler)
- , service_()
- , acceptor_(service_)
- {}
+ // Construct a `response` object (makes writing/sending responses easier).
+ response resp;
 
- int run()
- {
- // Create a new request (on the heap - uses boost::shared_ptr<>).
- request_type::pointer new_request = request_type::create(service_);
- // Add the request to the set of existing requests.
- requests_.insert(new_request);
-
- int ret(0);
- for (;;)
- {
- boost::system::error_code ec;
-
- acceptor_.accept(*new_request, ec);
-
- if (ec)
- {
- std::cerr<< "Error accepting: " << ec.message() << std::endl;
- return 5;
- }
-
- // Load in the request data so we can access it easily.
- new_request->load(ec, true); // The 'true' means read and parse POST data.
-
- ret = handler_(*new_request, ec);
-
- if (ret)
- break;
- }
- return ret;
- }
-
-private:
- function_type handler_;
- fcgi::service service_;
- fcgi::acceptor acceptor_;
- std::set<request_type::pointer> requests_;
-};
+ // 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");
+ // Response headers can be added at any time before send/flushing it:
+ 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);
+
+ // 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`.
+}
 
+///////////////////////////////////////////////////////////
 int main()
+///////////////////////////////////////////////////////////
 try
 {
- request_handler rh(LOG_FILE);
-
- server s(boost::bind(&request_handler::handle_request
- , &rh, _1, _2)
- );
+ server4 s(&handle_request);
 
   return s.run();
-
-}catch(boost::system::system_error& se){
- cerr<< "[fcgi] System error: " << se.what() << endl;
+
+}
+catch(boost::system::system_error& se){
+ cerr<< "[fcgi] System error (" << se.code() << "): "
+ << se.what() << endl;
   return 1313;
-}catch(exception& e){
+}
+catch(exception& e){
   cerr<< "[fcgi] Exception: " << e.what() << endl;
   return 666;
-}catch(...){
- cerr<< "[fcgi] Uncaught exception!" << endl;
+}
+catch(...){
+ cerr<< "[fcgi] Unknown exception!" << endl;
   return 667;
 }
 //]
+

Modified: sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/fcgi/server2/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/fcgi/server2/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/fcgi/server2/main.cpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/libs/cgi/example/fcgi/server3/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/fcgi/server3/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/fcgi/server3/main.cpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/libs/cgi/example/fcgi/server4/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/fcgi/server4/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/libs/cgi/example/fcgi/server4/main.cpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/libs/cgi/test/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/libs/cgi/test/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/branches/release/libs/cgi/test/Jamfile.v2 2008-06-02 17:54:00 EDT (Mon, 02 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/release/libs/cgi/test/compile/is_async_test.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/libs/cgi/test/compile/is_async_test.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/libs/cgi/test/compile/is_async_test.cpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/libs/cgi/test/compile/response.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/libs/cgi/test/compile/response.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/libs/cgi/test/compile/response.cpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/libs/cgi/test/run/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/libs/cgi/test/run/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/branches/release/libs/cgi/test/run/Jamfile.v2 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
@@ -9,6 +9,7 @@
     <library>/boost/test//boost_unit_test_framework/
     <library>/boost/system/
     <library>/boost/thread/
+ <library>/boost/regex/
   ;
 
 #local rule run-test( name )
@@ -24,11 +25,16 @@
     
     [ run cookie.cpp ]
     [ run response.cpp ]
+ [ run cgi_simple_request.cpp ]
+ [ run acgi_simple_request.cpp ]
+ [ run name_test.cpp ]
+ [ run map_test.cpp ]
   ;
 
 test-suite wget_test
   :
- [ run wget.cpp : "--log_level=message" ]
+ #[ run wget.cpp : "--log_level=message" ]
+ [ run hello_world.cpp /boost/filesystem/ ]
   ;
 
 explicit wget_test ;

Modified: sandbox/SOC/2007/cgi/branches/release/libs/cgi/test/run/cookie.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/libs/cgi/test/run/cookie.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/libs/cgi/test/run/cookie.cpp 2008-06-02 17:54:00 EDT (Mon, 02 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/release/libs/cgi/test/run/response.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/libs/cgi/test/run/response.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/release/libs/cgi/test/run/response.cpp 2008-06-02 17:54:00 EDT (Mon, 02 Jun 2008)
@@ -1,8 +1,19 @@
-// Test the cgi::response class works as advertised
+// -- response.hpp --
+//
+// Copyright (c) Darren Garvey 2007-2008.
+// 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)
+//
+////////////////////////////////////////////////////////////////
+//
+// Test the cgi::response class works as advertised.
+//
+
 #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/release/project-root.jam
==============================================================================
--- sandbox/SOC/2007/cgi/branches/release/project-root.jam (original)
+++ sandbox/SOC/2007/cgi/branches/release/project-root.jam 2008-06-02 17:54:00 EDT (Mon, 02 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