From 701e10100bd6697e4ba408107310181e0851806d Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Tue, 6 Sep 2011 10:19:31 +1000 Subject: [PATCH 001/196] WIP: Gutting the beast. --- boost/network/protocol/http/client.hpp | 4 + .../protocol/http/client/async_impl.hpp | 42 +-- .../http/client/connection/async_base.hpp | 7 +- .../http/client/connection/async_normal.hpp | 34 +- .../connection_delegate_factory.hpp | 35 +- .../connection/resolver_delegate_factory.hpp | 31 ++ .../http/client/connection_manager.hpp | 40 +++ boost/network/protocol/http/client/facade.hpp | 309 +++++++++--------- .../protocol/http/client/parameters.hpp | 8 +- .../http/policies/async_connection.hpp | 101 +++--- .../http/policies/async_connection.ipp | 113 +++++++ .../protocol/http/policies/async_resolver.hpp | 75 ++--- 12 files changed, 479 insertions(+), 320 deletions(-) create mode 100644 boost/network/protocol/http/client/connection/resolver_delegate_factory.hpp create mode 100644 boost/network/protocol/http/client/connection_manager.hpp create mode 100644 boost/network/protocol/http/policies/async_connection.ipp diff --git a/boost/network/protocol/http/client.hpp b/boost/network/protocol/http/client.hpp index 78a0619bf..9fdf0eeee 100644 --- a/boost/network/protocol/http/client.hpp +++ b/boost/network/protocol/http/client.hpp @@ -62,6 +62,9 @@ namespace boost { namespace network { namespace http { // -- the name of the directory from // which the certificate authority // files can be found + // _connection_manager : shared_ptr + // -- The connection manager to use for + // this client. BOOST_PARAMETER_CONSTRUCTOR( basic_client, (base_facade_type), tag, @@ -71,6 +74,7 @@ namespace boost { namespace network { namespace http { (cache_resolved, (bool)) (openssl_certificate, (string_type)) (openssl_verify_path, (string_type)) + (connection_manager, (shared_ptr)) )) // diff --git a/boost/network/protocol/http/client/async_impl.hpp b/boost/network/protocol/http/client/async_impl.hpp index a7e178d16..2fbd5d488 100644 --- a/boost/network/protocol/http/client/async_impl.hpp +++ b/boost/network/protocol/http/client/async_impl.hpp @@ -20,15 +20,8 @@ namespace boost { namespace network { namespace http { namespace impl { template - struct async_client : - connection_policy::type + struct async_client { - typedef - typename connection_policy::type - connection_base; - typedef - typename resolver::type - resolver_type; typedef typename string::type string_type; @@ -37,17 +30,12 @@ namespace boost { namespace network { namespace http { function const &, system::error_code const &)> body_callback_function_type; - async_client(bool cache_resolved, bool follow_redirect, optional const & certificate_filename, optional const & verify_path) - : connection_base(cache_resolved, follow_redirect), - service_ptr(new boost::asio::io_service), + async_client(shared_ptr connection_manager) + : service_ptr(new boost::asio::io_service), service_(*service_ptr), - resolver_(service_), sentinel_(new boost::asio::io_service::work(service_)), - certificate_filename_(certificate_filename), - verify_path_(verify_path) + connection_manager_(connection_manager) { - connection_base::resolver_strand_.reset(new - boost::asio::io_service::strand(service_)); lifetime_thread_.reset(new boost::thread( boost::bind( &boost::asio::io_service::run, @@ -55,20 +43,19 @@ namespace boost { namespace network { namespace http { ))); } - async_client(bool cache_resolved, bool follow_redirect, boost::asio::io_service & service, optional const & certificate_filename, optional const & verify_path) - : connection_base(cache_resolved, follow_redirect), - service_ptr(0), + async_client(boost::asio::io_service & service, + shared_ptr connection_manager) + : service_ptr(0), service_(service), - resolver_(service_), sentinel_(new boost::asio::io_service::work(service_)), - certificate_filename_(certificate_filename), - verify_path_(verify_path) + connection_manager_(connection_manager) { } ~async_client() throw () { sentinel_.reset(); + connection_manager_->reset(); if (lifetime_thread_.get()) { lifetime_thread_->join(); lifetime_thread_.reset(); @@ -83,17 +70,18 @@ namespace boost { namespace network { namespace http { body_callback_function_type callback ) { - typename connection_base::connection_ptr connection_; - connection_ = connection_base::get_connection(resolver_, request_, certificate_filename_, verify_path_); - return connection_->send_request(method, request_, get_body, callback); + shared_ptr connection_; + connection_ = connection_manager_->get_connection(service_, request_); + shared_ptr response = connection_->send_request( + method, request_, get_body, callback); + return *response; } boost::asio::io_service * service_ptr; boost::asio::io_service & service_; - resolver_type resolver_; boost::shared_ptr sentinel_; boost::shared_ptr lifetime_thread_; - optional certificate_filename_, verify_path_; + shared_ptr connection_manager_; }; } // namespace impl diff --git a/boost/network/protocol/http/client/connection/async_base.hpp b/boost/network/protocol/http/client/connection/async_base.hpp index 943ca2106..1cdf85486 100644 --- a/boost/network/protocol/http/client/connection/async_base.hpp +++ b/boost/network/protocol/http/client/connection/async_base.hpp @@ -42,10 +42,13 @@ namespace boost { namespace network { namespace http { namespace impl { async_connection; typedef typename delegate_factory::type delegate_factory_type; connection_ptr temp; + typedef typename resolver_delegate_factory::type + resolver_delegate_factory_type; temp.reset( new async_connection( - resolver, - resolve, + resolver_delegate_factory_type::new_resolver_delegate( + resolve, + resolver), follow_redirect, delegate_factory_type::new_connection_delegate( resolver.get_io_service(), diff --git a/boost/network/protocol/http/client/connection/async_normal.hpp b/boost/network/protocol/http/client/connection/async_normal.hpp index f1d0e9e3b..0595d408c 100644 --- a/boost/network/protocol/http/client/connection/async_normal.hpp +++ b/boost/network/protocol/http/client/connection/async_normal.hpp @@ -59,15 +59,14 @@ namespace boost { namespace network { namespace http { namespace impl { typedef typename delegate_factory_type::connection_delegate_ptr connection_delegate_ptr; - http_async_connection(resolver_type & resolver, - resolve_function resolve, + http_async_connection(resolver_delegate_ptr resolver_delegate, + asio::io_service & io_service, bool follow_redirect, connection_delegate_ptr delegate) : follow_redirect_(follow_redirect), - resolver_(resolver), - resolve_(resolve), - request_strand_(resolver.get_io_service()), + request_strand_(io_service), + resolver_delegate_(resolver_delegate), delegate_(delegate) {} // This is the main entry point for the connection/request pipeline. We're @@ -83,17 +82,17 @@ namespace boost { namespace network { namespace http { namespace impl { std::ostreambuf_iterator::type>(&command_streambuf)); this->method = method; boost::uint16_t port_ = port(request); - resolve_(resolver_, - host(request), - port_, - request_strand_.wrap( - boost::bind(&this_type::handle_resolved, - this_type::shared_from_this(), - port_, - get_body, - callback, - _1, - _2))); + resolver_delegate_->resolve(host(request), + port_, + request_strand_.wrap( + boost::bind( + &this_type::handle_resolved, + this_type::shared_from_this(), + port_, + get_body, + callback, + _1, + _2))); return response_; } @@ -419,9 +418,8 @@ namespace boost { namespace network { namespace http { namespace impl { } bool follow_redirect_; - resolver_type & resolver_; - resolve_function resolve_; boost::asio::io_service::strand request_strand_; + resolver_delegate_ptr resolver_delegate_; connection_delegate_ptr delegate_; boost::asio::streambuf command_streambuf; string_type method; diff --git a/boost/network/protocol/http/client/connection/connection_delegate_factory.hpp b/boost/network/protocol/http/client/connection/connection_delegate_factory.hpp index eca673666..05991c6d4 100644 --- a/boost/network/protocol/http/client/connection/connection_delegate_factory.hpp +++ b/boost/network/protocol/http/client/connection/connection_delegate_factory.hpp @@ -20,33 +20,38 @@ struct ssl_delegate; struct normal_delegate; -template struct connection_delegate_factory { typedef shared_ptr connection_delegate_ptr; - typedef typename string::type string_type; // This is the factory method that actually returns the delegate instance. // TODO Support passing in proxy settings when crafting connections. static connection_delegate_ptr new_connection_delegate( asio::io_service & service, bool https, - optional certificate_filename, - optional verify_path) { - connection_delegate_ptr delegate; - if (https) { + optional certificate_filename, + optional verify_path); +}; + +connection_delegate_factory::connection_delegate_ptr +connection_delegate_factory::new_connection_delegate( + asio::io_service & service, + bool https, + optional certificate_filename, + optional verify_path) { + connection_delegate_ptr delegate; + if (https) { #ifdef BOOST_NETWORK_ENABLE_HTTPS - delegate.reset(new ssl_delegate(service, - certificate_filename, - verify_path)); + delegate.reset(new ssl_delegate(service, + certificate_filename, + verify_path)); #else - BOOST_THROW_EXCEPTION(std::runtime_error("HTTPS not supported.")); + BOOST_THROW_EXCEPTION(std::runtime_error("HTTPS not supported.")); #endif /* BOOST_NETWORK_ENABLE_HTTPS */ - } else { - delegate.reset(new normal_delegate(service)); - } - return delegate; + } else { + delegate.reset(new normal_delegate(service)); } -}; + return delegate; +} } /* impl */ } /* http */ diff --git a/boost/network/protocol/http/client/connection/resolver_delegate_factory.hpp b/boost/network/protocol/http/client/connection/resolver_delegate_factory.hpp new file mode 100644 index 000000000..e754473f6 --- /dev/null +++ b/boost/network/protocol/http/client/connection/resolver_delegate_factory.hpp @@ -0,0 +1,31 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_FACTORY_HPP_20110930 +#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_FACTORY_HPP_20110930 + +// Copyright 2011 Dean Michael Berris (dberris@google.com). +// Copyright 2011 Google, Inc. +// 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) + +#include + +namespace boost { namespace network { namespace http { namespace impl { + +struct resolver_base; + +template +struct resolver_delegate_factory; + +template +struct resolver_delegate_factory >::type> { + typedef shared_ptr resolver_delegate_ptr; + // TODO Implement this! + resolver_delegate_ptr new_resolver_delegate(...); +}; + +} /* impl */ +} /* http */ +} /* network */ +} /* boost */ + +#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_FACTORY_HPP_20110930 */ diff --git a/boost/network/protocol/http/client/connection_manager.hpp b/boost/network/protocol/http/client/connection_manager.hpp new file mode 100644 index 000000000..aca063ee8 --- /dev/null +++ b/boost/network/protocol/http/client/connection_manager.hpp @@ -0,0 +1,40 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_MANAGER_HPP_20110930 +#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_MANAGER_HPP_20110930 + +// Copyright 2011 Dean Michael Berris (dberris@google.com). +// Copyright 2011 Google, Inc. +// 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) + +namespace boost { namespace network { namespace http { + +struct request_base; + +struct response_base; + +struct client_connection { + typedef function const &, + system::error_code const &)> + callback_type; + virtual shared_ptr send_request(std::string const & method, + request_base const & request, + bool get_body, + callback_type callback) = 0; + virtual void reset() = 0; + virtual ~client_connection() = 0; +}; + +struct connection_manager { + virtual shared_ptr get_connection( + asio::io_service & service, + request_base const & request) = 0; + virtual void reset() = 0; + virtual ~connection_manager() = 0; +}; + +} /* http */ +} /* network */ +} /* boost */ + +#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_MANAGER_HPP_20110930 */ diff --git a/boost/network/protocol/http/client/facade.hpp b/boost/network/protocol/http/client/facade.hpp index 639fb7277..a47f78c7b 100644 --- a/boost/network/protocol/http/client/facade.hpp +++ b/boost/network/protocol/http/client/facade.hpp @@ -13,160 +13,161 @@ namespace boost { namespace network { namespace http { - template - struct basic_request; - - template - struct basic_response; - - template - struct basic_client_facade { - - typedef typename string::type string_type; - typedef basic_request request; - typedef basic_response response; - typedef basic_client_impl pimpl_type; - typedef function const &,system::error_code const &)> body_callback_function_type; - - template - basic_client_facade(ArgPack const & args) - { - init_pimpl(args, - typename mpl::if_< - is_same< - typename parameter::value_type::type, - void - >, - no_io_service, - has_io_service - >::type()); - } - - BOOST_PARAMETER_MEMBER_FUNCTION((response const), head, tag, (required (request,(request const &)))) { - return pimpl->request_skeleton(request, "HEAD", false, body_callback_function_type()); - } - - BOOST_PARAMETER_MEMBER_FUNCTION((response const), get , tag, - (required - (request,(request const &)) - ) - (optional - (body_handler,(body_callback_function_type),body_callback_function_type()) - ) - ) { - return pimpl->request_skeleton(request, "GET", true, body_handler); - } - - BOOST_PARAMETER_MEMBER_FUNCTION((response const), post, tag, - (required - (request,(request)) // yes sir, we make a copy of the original request. - ) - (optional - (body,(string_type const &),string_type()) - (content_type,(string_type const &),string_type()) - (body_handler,(body_callback_function_type),body_callback_function_type()) - ) - ) { - if (body != string_type()) { - request << remove_header("Content-Length") - << header("Content-Length", boost::lexical_cast(body.size())) - << boost::network::body(body); - } - typename headers_range >::type content_type_headers = - headers(request)["Content-Type"]; - if (content_type != string_type()) { - if (!boost::empty(content_type_headers)) - request << remove_header("Content-Type"); - request << header("Content-Type", content_type); - } else { - if (boost::empty(content_type_headers)) { - typedef typename char_::type char_type; - static char_type content_type[] = "x-application/octet-stream"; - request << header("Content-Type", content_type); - } - } - return pimpl->request_skeleton(request, "POST", true, body_handler); - } - - BOOST_PARAMETER_MEMBER_FUNCTION((response const), put , tag, - (required - (request,(request)) // yes sir, we make a copy of the original request. - ) - (optional - (body,(string_type const &),string_type()) - (content_type,(string_type const &),string_type()) - (body_handler,(body_callback_function_type),body_callback_function_type()) - ) - ) { - if (body != string_type()) { - request << remove_header("Content-Length") - << header("Content-Length", boost::lexical_cast(body.size())) - << boost::network::body(body); - } - typename headers_range >::type content_type_headers = - headers(request)["Content-Type"]; - if (content_type != string_type()) { - if (!boost::empty(content_type_headers)) - request << remove_header("Content-Type"); - request << header("Content-Type", content_type); - } else { - if (boost::empty(content_type_headers)) { - typedef typename char_::type char_type; - static char_type content_type[] = "x-application/octet-stream"; - request << header("Content-Type", content_type); - } - } - return pimpl->request_skeleton(request, "PUT", true, body_handler); - } - - BOOST_PARAMETER_MEMBER_FUNCTION((response const), delete_, tag, - (required - (request,(request const &)) - ) - (optional - (body_handler,(body_callback_function_type),body_callback_function_type()) - ) - ) { - return pimpl->request_skeleton(request, "DELETE", true, body_handler); - } - - void clear_resolved_cache() { - pimpl->clear_resolved_cache(); - } - - protected: - - struct no_io_service {}; - struct has_io_service {}; - - boost::shared_ptr pimpl; - - template - void init_pimpl(ArgPack const & args, no_io_service) { - pimpl.reset( - new pimpl_type( - args[_cache_resolved|false] - , args[_follow_redirects|false] - , optional(args[_openssl_certificate|optional()]) - , optional(args[_openssl_verify_path|optional()]) - ) - ); - } - - template - void init_pimpl(ArgPack const & args, has_io_service) { - pimpl.reset( - new pimpl_type( - args[_cache_resolved|false] - , args[_follow_redirects|false] - , args[_io_service] - , optional(args[_openssl_certificate|optional()]) - , optional(args[_openssl_verify_path|optional()]) - ) - ); - } - - }; +template +struct basic_request; + +template +struct basic_response; + +template +struct basic_client_facade { + + typedef typename string::type string_type; + typedef basic_request request; + typedef basic_response response; + typedef basic_client_impl pimpl_type; + typedef function const &,system::error_code const &)> body_callback_function_type; + + template + basic_client_facade(ArgPack const & args) { + init_pimpl(args, + typename mpl::if_< + is_same< + typename parameter::value_type::type, + void + >, + no_io_service, + has_io_service + >::type()); + } + + BOOST_PARAMETER_MEMBER_FUNCTION((response const), head, tag, (required (request,(request const &)))) { + return pimpl->request_skeleton(request, "HEAD", false, body_callback_function_type()); + } + + BOOST_PARAMETER_MEMBER_FUNCTION((response const), get , tag, + (required + (request,(request const &)) + ) + (optional + (body_handler,(body_callback_function_type),body_callback_function_type()) + )) { + return pimpl->request_skeleton(request, "GET", true, body_handler); + } + + BOOST_PARAMETER_MEMBER_FUNCTION((response const), post, tag, + (required + (request,(request)) // yes sir, we make a copy of the original request. + ) + (optional + (body,(string_type const &),string_type()) + (content_type,(string_type const &),string_type()) + (body_handler,(body_callback_function_type),body_callback_function_type()) + )) { + if (body != string_type()) { + request << remove_header("Content-Length") + << header("Content-Length", boost::lexical_cast(body.size())) + << boost::network::body(body); + } + + typename headers_range >::type content_type_headers = + headers(request)["Content-Type"]; + if (content_type != string_type()) { + if (!boost::empty(content_type_headers)) + request << remove_header("Content-Type"); + request << header("Content-Type", content_type); + } else { + if (boost::empty(content_type_headers)) { + typedef typename char_::type char_type; + static char_type content_type[] = "x-application/octet-stream"; + request << header("Content-Type", content_type); + } + } + return pimpl->request_skeleton(request, "POST", true, body_handler); + } + + BOOST_PARAMETER_MEMBER_FUNCTION((response const), put , tag, + (required + (request,(request)) // yes sir, we make a copy of the original request. + ) + (optional + (body,(string_type const &),string_type()) + (content_type,(string_type const &),string_type()) + (body_handler,(body_callback_function_type),body_callback_function_type()) + )) { + if (body != string_type()) { + request << remove_header("Content-Length") + << header("Content-Length", boost::lexical_cast(body.size())) + << boost::network::body(body); + } + + typename headers_range >::type content_type_headers = + headers(request)["Content-Type"]; + if (content_type != string_type()) { + if (!boost::empty(content_type_headers)) + request << remove_header("Content-Type"); + request << header("Content-Type", content_type); + } else { + if (boost::empty(content_type_headers)) { + typedef typename char_::type char_type; + static char_type content_type[] = "x-application/octet-stream"; + request << header("Content-Type", content_type); + } + } + return pimpl->request_skeleton(request, "PUT", true, body_handler); + } + + BOOST_PARAMETER_MEMBER_FUNCTION((response const), delete_, tag, + (required + (request,(request const &)) + ) + (optional + (body_handler,(body_callback_function_type),body_callback_function_type()) + )) { + return pimpl->request_skeleton(request, "DELETE", true, body_handler); + } + + void clear_resolved_cache() { + pimpl->clear_resolved_cache(); + } + + protected: + + struct no_io_service {}; + struct has_io_service {}; + + boost::scoped_ptr pimpl; + + template + void init_pimpl(ArgPack const & args, no_io_service) { + pimpl.reset(new pimpl_type(this->get_connection_manager(args))); + } + + template + void init_pimpl(ArgPack const & args, has_io_service) { + pimpl.reset(new pimpl_type(args[_io_service], this->get_connection_manager(args))); + } + + private: + + template + shared_ptr get_connection_manager(ArgPack const & args) { + shared_ptr connection_manager_ = ptr; + if (!connection_manager_.get()) { + // Because there's no explicit connection manager, we use the default + // implementation as provided by the tag. + typedef typename async_connection_policy::type + default_connection_manager_type; + connection_manager_.reset( + new default_connection_manager_type(args[_cache_resolved|false], + args[_follow_redirects|false], + args[_openssl_certificate|optional()], + args[_openssl_verify_path|optional()])); + } + + return connection_manager_; + } +}; } // namespace http diff --git a/boost/network/protocol/http/client/parameters.hpp b/boost/network/protocol/http/client/parameters.hpp index dade4e756..19c213fe1 100644 --- a/boost/network/protocol/http/client/parameters.hpp +++ b/boost/network/protocol/http/client/parameters.hpp @@ -14,16 +14,16 @@ namespace boost { namespace network { namespace http { BOOST_PARAMETER_NAME(cache_resolved) BOOST_PARAMETER_NAME(openssl_certificate) BOOST_PARAMETER_NAME(openssl_verify_path) - + BOOST_PARAMETER_NAME(request) BOOST_PARAMETER_NAME(body) BOOST_PARAMETER_NAME(content_type) BOOST_PARAMETER_NAME(body_handler) - + + BOOST_PARAMETER_NAME(connection_manager) + } /* http */ - } /* network */ - } /* boost */ #endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_PARAMETERS_HPP_2010127 */ diff --git a/boost/network/protocol/http/policies/async_connection.hpp b/boost/network/protocol/http/policies/async_connection.hpp index ea8638d6b..145aff05c 100644 --- a/boost/network/protocol/http/policies/async_connection.hpp +++ b/boost/network/protocol/http/policies/async_connection.hpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -22,64 +23,48 @@ namespace boost { namespace network { namespace http { - template - struct async_connection_policy : resolver_policy::type { - protected: - - typedef typename string::type string_type; - typedef typename resolver_policy::type resolver_base; - typedef typename resolver_base::resolver_type resolver_type; - typedef typename resolver_base::resolve_function resolve_function; - typedef function const &, system::error_code const &)> body_callback_function_type; - - struct connection_impl { - connection_impl( - bool follow_redirect, - resolve_function resolve, - resolver_type & resolver, - bool https, - optional const & certificate_filename, - optional const & verify_path - ) - { - pimpl = impl::async_connection_base::new_connection(resolve, resolver, follow_redirect, https, certificate_filename, verify_path); - } - - basic_response send_request(string_type const & method, basic_request const & request_, bool get_body, body_callback_function_type callback) { - return pimpl->start(request_, method, get_body, callback); - } - - private: - - shared_ptr > pimpl; - - }; - - typedef boost::shared_ptr connection_ptr; - connection_ptr get_connection(resolver_type & resolver, basic_request const & request_, optional const & certificate_filename = optional(), optional const & verify_path = optional()) { - string_type protocol_ = protocol(request_); - connection_ptr connection_( - new connection_impl( - follow_redirect_ - , boost::bind( - &async_connection_policy::resolve, - this, - _1, _2, _3, _4 - ) - , resolver - , boost::iequals(protocol_, string_type("https")) - , certificate_filename - , verify_path)); - return connection_; - } - - void cleanup() { } - - async_connection_policy(bool cache_resolved, bool follow_redirect) - : resolver_base(cache_resolved), follow_redirect_(follow_redirect) {} - - bool follow_redirect_; - }; +struct simple_async_connection_manager : connection_manager { + simple_async_connection_manager(bool cache_resolved, + bool follow_redirects, + optional openssl_certificate, + optional openssl_verify_path); + virtual shared_ptr get_connection( + asio::io_service & service, + request_base const & request); // override + virtual void reset(); // override + virtual ~simple_async_connection_manager(); // override + protected: + bool cache_resolved_, follow_redirects_; + mutex shared_resolver_mutex; + shared_ptr shared_resolver_delegate; +}; + +struct http_1_1_async_connection_manager_pimpl; + +struct http_1_1_async_connection_manager : connection_manager { + http_1_1_async_connection_manager(bool cache_resolved, + bool follow_redirects, + optional openssl_certificate, + optional openssl_verify_path); + virtual shared_ptr get_connection( + asio::io_service & service, + request_base const & request); // override + virtual void reset(); // override + virtual ~http_1_1_async_connection_manager(); // override +}; + +template +struct async_connection_policy; + +template +struct async_connection_policy { // HTTP/1.0 + typedef simple_async_connection_manager type; +} + +template +struct async_connection_policy { // HTTP/1.1 + typedef http_1_1_connection_manager type; +} } // namespace http diff --git a/boost/network/protocol/http/policies/async_connection.ipp b/boost/network/protocol/http/policies/async_connection.ipp new file mode 100644 index 000000000..4fc264788 --- /dev/null +++ b/boost/network/protocol/http/policies/async_connection.ipp @@ -0,0 +1,113 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_POLICIES_ASYNC_CONNECTION_IPP_20110930 +#define BOOST_NETWORK_PROTOCOL_HTTP_POLICIES_ASYNC_CONNECTION_IPP_20110930 + +// Copyright 2011 Dean Michael Berris (dberris@google.com). +// Copyright 2011 Google, Inc. +// 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) + +namespace boost { namespace network { namespace http { + +struct simple_async_client_connection : client_connection { + simple_async_client_connection(asio::io_service & service, + bool follow_redirects, + shared_ptr resolver_delegate, + shared_ptr connection_delegate); + virtual shared_ptr send_request(std::string const & method, + request_base const & request, + bool get_body, + callback_type callback); // override + virtual void reset(); // override + virtual ~client_connection(); // override + protected: + asio::io_service & service_; + bool follow_redirects_; + shared_ptr resolver_delegate_; + shared_ptr connection_delegate_; + shared_ptr connection_; +}; + +simple_async_client_connection::simple_async_client_connection( + asio::io_service & service, + bool follow_redirects, + shared_ptr resolver_delegate, + shared_ptr connection_delegate) +: service_(service), + follow_redirects_(follow_redirects), + resolver_delegate_(resolver_delegate), + connection_delegate_(connection_delegate), +{} + +shared_ptr send_request(std::string const & method, + request_base const & request, + bool get_body, + callback_type callback) { + shared_ptr response; + shared_ptr connection_; + connection_.reset(new impl::async_connection(resolver_delegate_, + follow_redirects_, + connection_delegate_)) + response = connection_->start(request, method, get_body, callback); + return response +} + +} /* http */ +} /* network */ +} /* boost */ + +boost::network::http::simple_async_connection_manager(bool cache_resolved, + bool follow_redirects, + boost::optional openssl_certificate, + boost::optional openssl_verify_path) +: cache_resolved_(cache_resolved), + follow_redirects_(follow_redirects), + openssl_certificate_(openssl_certificate), + openssl_verify_path_(openssl_verify_path), +{} + +boost::shared_ptr +boost::network::http::simple_async_connection_manager::get_connection( + boost::asio::io_service & service, + request_base const & request) { + // TODO move out calls to new to a factory, taken as a parameter at + // construction time so that we are not tied to actual hard-coded + // dependencies. + shared_ptr connection; + shared_ptr resolver_delegate; + if (cache_resolved_) { + scoped_lock delegate_lock(this->resolver_mutex); + if (!this->shared_resolver_delegate.get()) + this->shared_resolver_delegate.reset( + new (std::nothrow) async_resolver_delegate(service)); + resolver_delegate = this->shared_resolver_delegate; + if (!resolver_delegate_.get()) + BOOST_THROW_EXCEPTION(std::runtime_error("Insufficient memory.")); + } else { + resolver_delegate.reset(new(std::nothrow) async_resolver(service)); + if (!resolver_delegate_.get()) + BOOST_THROW_EXCEPTION(std::runtime_error("Insuffucuent memory.")); + } + shared_ptr connection_delegate; + bool https = (scheme(request) == "https"); + connection_delegate = + connection_delegate_factory::new_connection_delegate( + service, openssl_certificate_, openssl_verify_path_); + connection.reset( + new(std::nothrow) simple_async_client_connection(service, + follow_redirects_, + resolver_delegate, + connection_delegate)); + if (!connection.get()) + BOOST_THROW_EXCEPTION(std::runtime_error("Insufficient memory.")); + return connection; +} + +void boost::network::http::simple_async_connection_manager::reset() { + if (cache_resolved_) { + scoped_lock delegate_lock(this->resolver_mutex); + this->shared_resolver_delegate.reset(); + } +} + +#endif /* BOOST_NETWORK_PROTOCOL_HTTP_POLICIES_ASYNC_CONNECTION_IPP_20110930 */ diff --git a/boost/network/protocol/http/policies/async_resolver.hpp b/boost/network/protocol/http/policies/async_resolver.hpp index cb49a09cc..12745c0e0 100644 --- a/boost/network/protocol/http/policies/async_resolver.hpp +++ b/boost/network/protocol/http/policies/async_resolver.hpp @@ -12,51 +12,42 @@ namespace boost { namespace network { namespace http { namespace policies { - template - struct async_resolver - : boost::enable_shared_from_this > - { - typedef typename resolver::type resolver_type; - typedef typename resolver_type::iterator resolver_iterator; - typedef typename resolver_type::query resolver_query; - typedef std::pair resolver_iterator_pair; - typedef typename string::type string_type; - typedef boost::unordered_map endpoint_cache; - typedef boost::function resolve_completion_function; - typedef boost::function resolve_function; - protected: - bool cache_resolved_; - endpoint_cache endpoint_cache_; - boost::shared_ptr service_; - boost::shared_ptr resolver_strand_; +struct async_resolver : enable_shared_from_this { + typedef asio::ip::resolver::iterator resolver_iterator; + typedef asio::ip::resolver::query resolver_query; + typedef std::pair resolver_iterator_pair; + typedef boost::unordered_map endpoint_cache; + typedef boost::function resolve_completion_function; + typedef boost::function resolve_function; + protected: + bool cache_resolved_; + endpoint_cache endpoint_cache_; + boost::shared_ptr resolver_strand_; - explicit async_resolver(bool cache_resolved) - : cache_resolved_(cache_resolved), endpoint_cache_() - { - - } + async_resolver(bool cache_resolved): + cache_resolved_(cache_resolved), + endpoint_cache_() + {} + + void resolve( + resolver_type & resolver_, + std::string const & host, + boost::uint16_t port, + resolve_completion_function once_resolved) { + if (cache_resolved_) { + typename endpoint_cache::iterator iter = + endpoint_cache_.find(boost::to_lower_copy(host)); + if (iter != endpoint_cache_.end()) { + boost::system::error_code ignored; + once_resolved(ignored, iter->second); + return; + } + } - void resolve( - resolver_type & resolver_, - string_type const & host, - boost::uint16_t port, - resolve_completion_function once_resolved - ) - { - if (cache_resolved_) { - typename endpoint_cache::iterator iter = - endpoint_cache_.find(boost::to_lower_copy(host)); - if (iter != endpoint_cache_.end()) { - boost::system::error_code ignored; - once_resolved(ignored, iter->second); - return; - } - } - typename resolver_type::query q( resolver_type::protocol_type::v4() , host - , lexical_cast(port)); + , lexical_cast(port)); resolver_.async_resolve( q, resolver_strand_->wrap( @@ -73,8 +64,8 @@ namespace boost { namespace network { namespace http { namespace policies { } void handle_resolve( - string_type const & host, - resolve_completion_function once_resolved, + std::string const & host, + resolve_completion_function once_resolved, boost::system::error_code const & ec, resolver_iterator endpoint_iterator ) From 8651d163bf737edb5abad4768b1bdaf14cc6118d Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Fri, 9 Sep 2011 14:28:48 +1000 Subject: [PATCH 002/196] Incremental changes to slowly support persistent connections in HTTP/1.1 Async mode. --- .../http/policies/async_connection.hpp | 14 ++++++-- .../http/policies/async_connection.ipp | 34 ++++++++++++------- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/boost/network/protocol/http/policies/async_connection.hpp b/boost/network/protocol/http/policies/async_connection.hpp index 145aff05c..ace3d7137 100644 --- a/boost/network/protocol/http/policies/async_connection.hpp +++ b/boost/network/protocol/http/policies/async_connection.hpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -39,9 +40,9 @@ struct simple_async_connection_manager : connection_manager { shared_ptr shared_resolver_delegate; }; -struct http_1_1_async_connection_manager_pimpl; +struct http_1_1_async_connection; -struct http_1_1_async_connection_manager : connection_manager { +struct http_1_1_async_connection_manager : connection_manager, enable_shared_from_this { http_1_1_async_connection_manager(bool cache_resolved, bool follow_redirects, optional openssl_certificate, @@ -51,6 +52,15 @@ struct http_1_1_async_connection_manager : connection_manager { request_base const & request); // override virtual void reset(); // override virtual ~http_1_1_async_connection_manager(); // override + + protected: + friend struct http_1_1_async_connection; + void add_ready_connection(shared_ptr connection_ptr); + shared_ptr get_ready_connection(std::string const & host); + bool cache_resolved, follow_redirects_; + mutex shared_resolver_mutex; + shared_ptr shared_resolver_delegate; + unordered_map > ready_connections; }; template diff --git a/boost/network/protocol/http/policies/async_connection.ipp b/boost/network/protocol/http/policies/async_connection.ipp index 4fc264788..d638688bd 100644 --- a/boost/network/protocol/http/policies/async_connection.ipp +++ b/boost/network/protocol/http/policies/async_connection.ipp @@ -10,8 +10,7 @@ namespace boost { namespace network { namespace http { struct simple_async_client_connection : client_connection { - simple_async_client_connection(asio::io_service & service, - bool follow_redirects, + simple_async_client_connection(bool follow_redirects, shared_ptr resolver_delegate, shared_ptr connection_delegate); virtual shared_ptr send_request(std::string const & method, @@ -21,7 +20,6 @@ struct simple_async_client_connection : client_connection { virtual void reset(); // override virtual ~client_connection(); // override protected: - asio::io_service & service_; bool follow_redirects_; shared_ptr resolver_delegate_; shared_ptr connection_delegate_; @@ -29,12 +27,10 @@ struct simple_async_client_connection : client_connection { }; simple_async_client_connection::simple_async_client_connection( - asio::io_service & service, bool follow_redirects, shared_ptr resolver_delegate, shared_ptr connection_delegate) -: service_(service), - follow_redirects_(follow_redirects), +: follow_redirects_(follow_redirects), resolver_delegate_(resolver_delegate), connection_delegate_(connection_delegate), {} @@ -45,9 +41,12 @@ shared_ptr send_request(std::string const & method, callback_type callback) { shared_ptr response; shared_ptr connection_; - connection_.reset(new impl::async_connection(resolver_delegate_, - follow_redirects_, - connection_delegate_)) + connection_.reset(new(std::nothrow) impl::async_connection( + resolver_delegate_, + follow_redirects_, + connection_delegate_)) + if (!connection_.get()) + BOOST_THROW_EXCEPTION(std::runtime_error("Insufficient memory.")); response = connection_->start(request, method, get_body, callback); return response } @@ -86,7 +85,7 @@ boost::network::http::simple_async_connection_manager::get_connection( } else { resolver_delegate.reset(new(std::nothrow) async_resolver(service)); if (!resolver_delegate_.get()) - BOOST_THROW_EXCEPTION(std::runtime_error("Insuffucuent memory.")); + BOOST_THROW_EXCEPTION(std::runtime_error("Insuffucient memory.")); } shared_ptr connection_delegate; bool https = (scheme(request) == "https"); @@ -94,8 +93,7 @@ boost::network::http::simple_async_connection_manager::get_connection( connection_delegate_factory::new_connection_delegate( service, openssl_certificate_, openssl_verify_path_); connection.reset( - new(std::nothrow) simple_async_client_connection(service, - follow_redirects_, + new(std::nothrow) simple_async_client_connection(follow_redirects_, resolver_delegate, connection_delegate)); if (!connection.get()) @@ -110,4 +108,16 @@ void boost::network::http::simple_async_connection_manager::reset() { } } +namespace boost { namespace network { namespace http { + +struct http_1_1_async_connection : client_connection { + http_1_1_async_connection(bool follow_redirects, + shared_ptr resolver_delegate, + shared_ptr connection_delegate) +} + +} /* http */ +} /* network */ +} /* boost */ + #endif /* BOOST_NETWORK_PROTOCOL_HTTP_POLICIES_ASYNC_CONNECTION_IPP_20110930 */ From b75493987fca84fd1df36be5c175be2b83f07fc5 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sat, 10 Sep 2011 23:23:43 +1000 Subject: [PATCH 003/196] Gutting the Beast Part 2. In this commit I remove all traces of traits and metafunctions that can all be replaced by dynamic dispatch. This also prepares to remove the divergence between the synchronous and asynchronous implementation of the messages/client. The goal is to actually just implement the asynchronous version without bothering with a synchronous version. The rationale for this is so that the implementation can grow and be generic while at the same time require that the implementation rely on Boost.Thread in a real way. Part of this commit is the beginnings of the segmented request storage base that will use Boost.IOStreams to support a unified interface to the message implementation while making the underlying storage mechanism replaceable and optimizable as releases go forward. This all leads to simplification of the implementation while remaining source-compatible as far as the interface is concerned. Unfortunately all the interfaces will change, but hopefully majority of the users will not have to change their usage of the library. --- boost/network/constants.hpp | 2 - boost/network/message.hpp | 3 - .../directives/detail/string_directive.hpp | 2 - boost/network/message/directives/header.hpp | 3 - .../message/directives/remove_header.hpp | 3 - .../network/message/modifiers/add_header.hpp | 2 - boost/network/message/modifiers/body.hpp | 1 - .../message/modifiers/clear_headers.hpp | 2 - .../network/message/modifiers/destination.hpp | 1 - .../message/modifiers/remove_header.hpp | 2 - boost/network/message/modifiers/source.hpp | 2 - boost/network/message/traits/body.hpp | 2 - boost/network/message/traits/destination.hpp | 2 - boost/network/message/traits/headers.hpp | 4 - boost/network/message/traits/source.hpp | 2 - boost/network/message/wrappers/body.hpp | 1 - .../network/message/wrappers/destination.hpp | 3 - boost/network/message/wrappers/headers.hpp | 2 - boost/network/message/wrappers/source.hpp | 4 - boost/network/protocol/http/client.hpp | 121 +++++------- .../http/client/connection/ssl_delegate.hpp | 2 - boost/network/protocol/http/client/pimpl.hpp | 3 - boost/network/protocol/http/client_fwd.hpp | 10 +- boost/network/protocol/http/errors.hpp | 10 +- boost/network/protocol/http/impl/response.ipp | 3 - boost/network/protocol/http/message.hpp | 147 --------------- .../http/message/directives/status.hpp | 2 - .../message/directives/status_message.hpp | 1 - .../protocol/http/message/directives/uri.hpp | 1 - .../http/message/directives/version.hpp | 1 - .../network/protocol/http/message/header.hpp | 62 +++--- .../protocol/http/message/message_base.hpp | 3 - .../protocol/http/message/modifiers/body.hpp | 3 - .../http/message/modifiers/clear_headers.hpp | 3 - .../http/message/modifiers/destination.hpp | 3 - .../http/message/modifiers/headers.hpp | 1 - .../http/message/modifiers/method.hpp | 1 - .../http/message/modifiers/source.hpp | 3 - .../http/message/modifiers/status.hpp | 1 - .../http/message/modifiers/status_message.hpp | 1 - .../protocol/http/message/modifiers/uri.hpp | 1 - .../http/message/modifiers/version.hpp | 2 - .../protocol/http/message/traits/status.hpp | 2 - .../http/message/traits/status_message.hpp | 4 - .../protocol/http/message/traits/version.hpp | 4 - .../http/message/wrappers/headers.hpp | 3 - .../http/policies/async_connection.ipp | 63 ++++++- .../protocol/http/policies/async_resolver.hpp | 104 +++------- .../http/policies/pooled_connection.hpp | 177 ------------------ .../http/policies/simple_connection.hpp | 117 ------------ .../protocol/http/policies/sync_resolver.hpp | 86 --------- boost/network/protocol/http/request.hpp | 39 ++-- boost/network/protocol/http/response.hpp | 1 - .../protocol/http/support/is_client.hpp | 1 - .../protocol/http/support/is_server.hpp | 1 - boost/network/protocol/http/tags.hpp | 50 ----- boost/network/protocol/http/traits.hpp | 18 -- .../http/traits/connection_keepalive.hpp | 24 --- .../http/traits/connection_policy.hpp | 55 ------ .../protocol/http/traits/delegate_factory.hpp | 39 ---- .../protocol/http/traits/impl/chunk_cache.ipp | 36 ---- .../protocol/http/traits/impl/content.ipp | 44 ----- .../protocol/http/traits/impl/cookie_name.ipp | 26 --- .../http/traits/impl/cookie_value.ipp | 26 --- .../http/traits/impl/cookies_container.ipp | 32 ---- .../protocol/http/traits/impl/delimiters.ipp | 40 ---- .../protocol/http/traits/impl/header_name.ipp | 26 --- .../http/traits/impl/header_value.ipp | 26 --- .../protocol/http/traits/impl/headers.ipp | 85 --------- .../http/traits/impl/headers_container.ipp | 45 ----- .../protocol/http/traits/impl/method.ipp | 28 --- .../http/traits/impl/post_content.ipp | 26 --- .../http/traits/impl/query_container.ipp | 31 --- .../protocol/http/traits/impl/query_name.ipp | 26 --- .../http/traits/impl/query_string.ipp | 26 --- .../protocol/http/traits/impl/query_value.ipp | 26 --- .../http/traits/impl/request_methods.ipp | 49 ----- .../protocol/http/traits/impl/resource.ipp | 26 --- .../http/traits/impl/response_code.ipp | 42 ----- .../http/traits/impl/response_message.ipp | 80 -------- .../http/traits/impl/status_message.ipp | 27 --- .../protocol/http/traits/message_traits.hpp | 63 ------- .../protocol/http/traits/parser_traits.hpp | 70 ------- .../network/protocol/http/traits/resolver.hpp | 60 ------ .../protocol/http/traits/resolver_policy.hpp | 41 ---- boost/network/protocol/http/traits/vector.hpp | 38 ---- boost/network/support/is_async.hpp | 25 --- boost/network/support/is_default_string.hpp | 24 --- boost/network/support/is_default_wstring.hpp | 24 --- boost/network/support/is_http.hpp | 24 --- boost/network/support/is_keepalive.hpp | 24 --- boost/network/support/is_pod.hpp | 24 --- boost/network/support/is_simple.hpp | 24 --- boost/network/support/is_sync.hpp | 25 --- boost/network/support/is_tcp.hpp | 26 --- boost/network/support/is_udp.hpp | 27 --- boost/network/support/pod_or_normal.hpp | 25 --- boost/network/support/sync_only.hpp | 33 ---- boost/network/tags.hpp | 52 ----- boost/network/traits/char.hpp | 39 ---- boost/network/traits/headers_container.hpp | 28 --- boost/network/traits/istream.hpp | 42 ----- boost/network/traits/istringstream.hpp | 44 ----- boost/network/traits/ostream_iterator.hpp | 37 ---- boost/network/traits/ostringstream.hpp | 44 ----- boost/network/traits/string.hpp | 52 ----- boost/network/traits/vector.hpp | 36 ---- boost/network/uri/uri.hpp | 1 - 108 files changed, 188 insertions(+), 2753 deletions(-) delete mode 100644 boost/network/protocol/http/message.hpp delete mode 100644 boost/network/protocol/http/policies/pooled_connection.hpp delete mode 100644 boost/network/protocol/http/policies/simple_connection.hpp delete mode 100644 boost/network/protocol/http/policies/sync_resolver.hpp delete mode 100644 boost/network/protocol/http/tags.hpp delete mode 100644 boost/network/protocol/http/traits.hpp delete mode 100644 boost/network/protocol/http/traits/connection_keepalive.hpp delete mode 100644 boost/network/protocol/http/traits/connection_policy.hpp delete mode 100644 boost/network/protocol/http/traits/delegate_factory.hpp delete mode 100644 boost/network/protocol/http/traits/impl/chunk_cache.ipp delete mode 100644 boost/network/protocol/http/traits/impl/content.ipp delete mode 100644 boost/network/protocol/http/traits/impl/cookie_name.ipp delete mode 100644 boost/network/protocol/http/traits/impl/cookie_value.ipp delete mode 100644 boost/network/protocol/http/traits/impl/cookies_container.ipp delete mode 100644 boost/network/protocol/http/traits/impl/delimiters.ipp delete mode 100644 boost/network/protocol/http/traits/impl/header_name.ipp delete mode 100644 boost/network/protocol/http/traits/impl/header_value.ipp delete mode 100644 boost/network/protocol/http/traits/impl/headers.ipp delete mode 100644 boost/network/protocol/http/traits/impl/headers_container.ipp delete mode 100644 boost/network/protocol/http/traits/impl/method.ipp delete mode 100644 boost/network/protocol/http/traits/impl/post_content.ipp delete mode 100644 boost/network/protocol/http/traits/impl/query_container.ipp delete mode 100644 boost/network/protocol/http/traits/impl/query_name.ipp delete mode 100644 boost/network/protocol/http/traits/impl/query_string.ipp delete mode 100644 boost/network/protocol/http/traits/impl/query_value.ipp delete mode 100644 boost/network/protocol/http/traits/impl/request_methods.ipp delete mode 100644 boost/network/protocol/http/traits/impl/resource.ipp delete mode 100644 boost/network/protocol/http/traits/impl/response_code.ipp delete mode 100644 boost/network/protocol/http/traits/impl/response_message.ipp delete mode 100644 boost/network/protocol/http/traits/impl/status_message.ipp delete mode 100644 boost/network/protocol/http/traits/message_traits.hpp delete mode 100644 boost/network/protocol/http/traits/parser_traits.hpp delete mode 100644 boost/network/protocol/http/traits/resolver.hpp delete mode 100644 boost/network/protocol/http/traits/resolver_policy.hpp delete mode 100644 boost/network/protocol/http/traits/vector.hpp delete mode 100644 boost/network/support/is_async.hpp delete mode 100644 boost/network/support/is_default_string.hpp delete mode 100644 boost/network/support/is_default_wstring.hpp delete mode 100644 boost/network/support/is_http.hpp delete mode 100644 boost/network/support/is_keepalive.hpp delete mode 100644 boost/network/support/is_pod.hpp delete mode 100644 boost/network/support/is_simple.hpp delete mode 100644 boost/network/support/is_sync.hpp delete mode 100644 boost/network/support/is_tcp.hpp delete mode 100644 boost/network/support/is_udp.hpp delete mode 100644 boost/network/support/pod_or_normal.hpp delete mode 100644 boost/network/support/sync_only.hpp delete mode 100644 boost/network/tags.hpp delete mode 100644 boost/network/traits/char.hpp delete mode 100644 boost/network/traits/headers_container.hpp delete mode 100644 boost/network/traits/istream.hpp delete mode 100644 boost/network/traits/istringstream.hpp delete mode 100644 boost/network/traits/ostream_iterator.hpp delete mode 100644 boost/network/traits/ostringstream.hpp delete mode 100644 boost/network/traits/string.hpp delete mode 100644 boost/network/traits/vector.hpp diff --git a/boost/network/constants.hpp b/boost/network/constants.hpp index f2b100760..3f03d6d6c 100644 --- a/boost/network/constants.hpp +++ b/boost/network/constants.hpp @@ -6,8 +6,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include #include namespace boost { namespace network { diff --git a/boost/network/message.hpp b/boost/network/message.hpp index 190018b67..fcddc7e1b 100644 --- a/boost/network/message.hpp +++ b/boost/network/message.hpp @@ -7,9 +7,6 @@ #define __NETWORK_MESSAGE_HPP__ #include -#include -#include -#include #include #include #include diff --git a/boost/network/message/directives/detail/string_directive.hpp b/boost/network/message/directives/detail/string_directive.hpp index 6f2da4430..885777da4 100644 --- a/boost/network/message/directives/detail/string_directive.hpp +++ b/boost/network/message/directives/detail/string_directive.hpp @@ -6,11 +6,9 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include #include #include #include -#include #include #include #include diff --git a/boost/network/message/directives/header.hpp b/boost/network/message/directives/header.hpp index e20c95cd9..182d643d3 100644 --- a/boost/network/message/directives/header.hpp +++ b/boost/network/message/directives/header.hpp @@ -7,9 +7,6 @@ #ifndef __NETWORK_MESSAGE_DIRECTIVES_HEADER_HPP__ #define __NETWORK_MESSAGE_DIRECTIVES_HEADER_HPP__ -#include -#include -#include #include #include #include diff --git a/boost/network/message/directives/remove_header.hpp b/boost/network/message/directives/remove_header.hpp index 051d35f78..16d863e15 100644 --- a/boost/network/message/directives/remove_header.hpp +++ b/boost/network/message/directives/remove_header.hpp @@ -8,9 +8,6 @@ #define NETWORK_MESSAGE_DIRECTIVES_REMOVE_HEADER_HPP -#include - - namespace boost { namespace network { template diff --git a/boost/network/message/modifiers/add_header.hpp b/boost/network/message/modifiers/add_header.hpp index f92e9c21f..c93fe2edb 100644 --- a/boost/network/message/modifiers/add_header.hpp +++ b/boost/network/message/modifiers/add_header.hpp @@ -7,8 +7,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include #include #include #include diff --git a/boost/network/message/modifiers/body.hpp b/boost/network/message/modifiers/body.hpp index 317264c68..f9b595818 100644 --- a/boost/network/message/modifiers/body.hpp +++ b/boost/network/message/modifiers/body.hpp @@ -6,7 +6,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include #include namespace boost { namespace network { diff --git a/boost/network/message/modifiers/clear_headers.hpp b/boost/network/message/modifiers/clear_headers.hpp index b44ff1207..a983b695a 100644 --- a/boost/network/message/modifiers/clear_headers.hpp +++ b/boost/network/message/modifiers/clear_headers.hpp @@ -6,8 +6,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include #include #include #include diff --git a/boost/network/message/modifiers/destination.hpp b/boost/network/message/modifiers/destination.hpp index b04b07129..8ff362e08 100644 --- a/boost/network/message/modifiers/destination.hpp +++ b/boost/network/message/modifiers/destination.hpp @@ -7,7 +7,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include #include namespace boost { namespace network { diff --git a/boost/network/message/modifiers/remove_header.hpp b/boost/network/message/modifiers/remove_header.hpp index c2ab29bf1..e7b098875 100644 --- a/boost/network/message/modifiers/remove_header.hpp +++ b/boost/network/message/modifiers/remove_header.hpp @@ -7,8 +7,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include #include #include #include diff --git a/boost/network/message/modifiers/source.hpp b/boost/network/message/modifiers/source.hpp index fad8c00f3..11acb9071 100644 --- a/boost/network/message/modifiers/source.hpp +++ b/boost/network/message/modifiers/source.hpp @@ -7,8 +7,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include - namespace boost { namespace network { namespace impl { diff --git a/boost/network/message/traits/body.hpp b/boost/network/message/traits/body.hpp index 25cb14961..5d539d7f4 100644 --- a/boost/network/message/traits/body.hpp +++ b/boost/network/message/traits/body.hpp @@ -7,8 +7,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include #include #include #include diff --git a/boost/network/message/traits/destination.hpp b/boost/network/message/traits/destination.hpp index 92c5435ad..39da83de9 100644 --- a/boost/network/message/traits/destination.hpp +++ b/boost/network/message/traits/destination.hpp @@ -7,8 +7,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include #include #include #include diff --git a/boost/network/message/traits/headers.hpp b/boost/network/message/traits/headers.hpp index e1d34abe8..a51023675 100644 --- a/boost/network/message/traits/headers.hpp +++ b/boost/network/message/traits/headers.hpp @@ -7,10 +7,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include -#include -#include #include #include #include diff --git a/boost/network/message/traits/source.hpp b/boost/network/message/traits/source.hpp index 231a5e0d3..9d2237e1e 100644 --- a/boost/network/message/traits/source.hpp +++ b/boost/network/message/traits/source.hpp @@ -6,8 +6,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include #include #include #include diff --git a/boost/network/message/wrappers/body.hpp b/boost/network/message/wrappers/body.hpp index 507d87e07..b2199eca7 100644 --- a/boost/network/message/wrappers/body.hpp +++ b/boost/network/message/wrappers/body.hpp @@ -7,7 +7,6 @@ #ifndef __NETWORK_MESSAGE_WRAPPERS_BODY_HPP__ #define __NETWORK_MESSAGE_WRAPPERS_BODY_HPP__ -#include #include #include diff --git a/boost/network/message/wrappers/destination.hpp b/boost/network/message/wrappers/destination.hpp index 935e9c101..f1c485269 100644 --- a/boost/network/message/wrappers/destination.hpp +++ b/boost/network/message/wrappers/destination.hpp @@ -8,9 +8,6 @@ #define __NETWORK_MESSAGE_WRAPPERS_DESTINATION_HPP__ -#include - - namespace boost { namespace network { namespace impl { diff --git a/boost/network/message/wrappers/headers.hpp b/boost/network/message/wrappers/headers.hpp index 37a2e611c..ce2e0bf25 100644 --- a/boost/network/message/wrappers/headers.hpp +++ b/boost/network/message/wrappers/headers.hpp @@ -7,8 +7,6 @@ #ifndef __NETWORK_MESSAGE_WRAPPERS_HEADERS_HPP__ #define __NETWORK_MESSAGE_WRAPPERS_HEADERS_HPP__ -#include -#include #include #include #include diff --git a/boost/network/message/wrappers/source.hpp b/boost/network/message/wrappers/source.hpp index 42579895c..378e80628 100644 --- a/boost/network/message/wrappers/source.hpp +++ b/boost/network/message/wrappers/source.hpp @@ -7,10 +7,6 @@ #ifndef __NETWORK_MESSAGE_WRAPPERS_SOURCE_HPP__ #define __NETWORK_MESSAGE_WRAPPERS_SOURCE_HPP__ - -#include - - namespace boost { namespace network { namespace impl { diff --git a/boost/network/protocol/http/client.hpp b/boost/network/protocol/http/client.hpp index 9fdf0eeee..2d45ff2df 100644 --- a/boost/network/protocol/http/client.hpp +++ b/boost/network/protocol/http/client.hpp @@ -7,86 +7,63 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include #include #include namespace boost { namespace network { namespace http { - template - struct basic_client - : basic_client_facade - { - private: - typedef basic_client_facade - base_facade_type; - public: - typedef basic_request request; - typedef basic_response response; - typedef typename string::type string_type; - typedef Tag tag_type; - - // Constructor - // ================================================================= - // This is a Boost.Parameter-based constructor forwarder, whose - // implementation is actually forwarded to the base type. - // - // The supported parameters are: - // _follow_redirects : bool -- whether to follow HTTP redirect - // responses (default: false) - // _cache_resolved : bool -- whether to cache the resolved - // endpoints (default: false) - // _io_service : boost::asio::io_service & - // -- supply an io_service to the - // client - // _openssl_certificate : string - // -- the name of the certificate file - // to use - // _openssl_verify_path : string - // -- the name of the directory from - // which the certificate authority - // files can be found - // _connection_manager : shared_ptr - // -- The connection manager to use for - // this client. - - BOOST_PARAMETER_CONSTRUCTOR( - basic_client, (base_facade_type), tag, - (optional - (in_out(io_service), (boost::asio::io_service&)) - (follow_redirects, (bool)) - (cache_resolved, (bool)) - (openssl_certificate, (string_type)) - (openssl_verify_path, (string_type)) - (connection_manager, (shared_ptr)) - )) - - // - // ================================================================= - - }; - -#ifndef BOOST_NETWORK_HTTP_CLIENT_DEFAULT_TAG -#define BOOST_NETWORK_HTTP_CLIENT_DEFAULT_TAG tags::http_async_8bit_udp_resolve -#endif - - typedef basic_client client; +template +struct basic_client : basic_client_facade { + private: + typedef basic_client_facade + base_facade_type; + public: + typedef basic_request request; + typedef basic_response response; + typedef String string_type; + + // Constructor + // ================================================================= + // This is a Boost.Parameter-based constructor forwarder, whose + // implementation is actually forwarded to the base type. + // + // The supported parameters are: + // _follow_redirects : bool -- whether to follow HTTP redirect + // responses (default: false) + // _cache_resolved : bool -- whether to cache the resolved + // endpoints (default: false) + // _io_service : boost::asio::io_service & + // -- supply an io_service to the + // client + // _openssl_certificate : string + // -- the name of the certificate file + // to use + // _openssl_verify_path : string + // -- the name of the directory from + // which the certificate authority + // files can be found + // _connection_manager : shared_ptr + // -- The connection manager to use for + // this client. + + BOOST_PARAMETER_CONSTRUCTOR( + basic_client, (base_facade_type), tag, + (optional + (in_out(io_service), (boost::asio::io_service&)) + (follow_redirects, (bool)) + (cache_resolved, (bool)) + (openssl_certificate, (string_type)) + (openssl_verify_path, (string_type)) + (connection_manager, (shared_ptr)) + )) + + // + // ================================================================= + +}; } // namespace http diff --git a/boost/network/protocol/http/client/connection/ssl_delegate.hpp b/boost/network/protocol/http/client/connection/ssl_delegate.hpp index a1cb9a0c6..d07281df7 100644 --- a/boost/network/protocol/http/client/connection/ssl_delegate.hpp +++ b/boost/network/protocol/http/client/connection/ssl_delegate.hpp @@ -12,8 +12,6 @@ #include #include #include -#include -#include namespace boost { namespace network { namespace http { namespace impl { diff --git a/boost/network/protocol/http/client/pimpl.hpp b/boost/network/protocol/http/client/pimpl.hpp index 55df10f57..2f0cab2af 100644 --- a/boost/network/protocol/http/client/pimpl.hpp +++ b/boost/network/protocol/http/client/pimpl.hpp @@ -6,14 +6,11 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include #include #include #include #include -#include #include #include diff --git a/boost/network/protocol/http/client_fwd.hpp b/boost/network/protocol/http/client_fwd.hpp index c57ad70cc..de67671f7 100644 --- a/boost/network/protocol/http/client_fwd.hpp +++ b/boost/network/protocol/http/client_fwd.hpp @@ -8,15 +8,15 @@ #define __NETWORK_PROTOCOL_HTTP_CLIENT_20080923_1_HPP__ #include -#include +#include namespace boost { namespace network { namespace http { - //! Forward declaration of basic_client template. - template - class basic_client; +//! Forward declaration of basic_client template. +template +class basic_client; - typedef basic_client client; +typedef basic_client client; } // namespace http diff --git a/boost/network/protocol/http/errors.hpp b/boost/network/protocol/http/errors.hpp index 70952e3ec..dff069d36 100644 --- a/boost/network/protocol/http/errors.hpp +++ b/boost/network/protocol/http/errors.hpp @@ -7,18 +7,14 @@ #ifndef __NETWORK_PROTOCOL_HTTP_ERRORS_20080516_HPP__ #define __NETWORK_PROTOCOL_HTTP_ERRORS_20080516_HPP__ -#include #include namespace boost { namespace network { namespace http { namespace errors { - template - struct connection_timeout_exception : - std::runtime_error - { - }; +struct connection_timeout_exception : std::runtime_error +{}; - typedef connection_timeout_exception<> connection_timeout; +typedef connection_timeout_exception connection_timeout; } // namespace errors diff --git a/boost/network/protocol/http/impl/response.ipp b/boost/network/protocol/http/impl/response.ipp index 2eb669dba..0708575e8 100644 --- a/boost/network/protocol/http/impl/response.ipp +++ b/boost/network/protocol/http/impl/response.ipp @@ -16,9 +16,6 @@ #include #include -#include -#include -#include #include namespace boost { namespace network { namespace http { diff --git a/boost/network/protocol/http/message.hpp b/boost/network/protocol/http/message.hpp deleted file mode 100644 index b7256c9d1..000000000 --- a/boost/network/protocol/http/message.hpp +++ /dev/null @@ -1,147 +0,0 @@ -// This file is part of the Boost Network library -// Based on the Pion Network Library (r421) -// Copyright Atomic Labs, Inc. 2007-2008 -// See http://cpp-netlib.sourceforge.net for library home page. -// -// 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) -// -// Some changes Copyright (c) Dean Michael Berris 2008 - -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HPP -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HPP - -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace network { namespace http { - - /// base class for HTTP messages (requests and responses) - template - struct message_impl : public basic_message { - - typedef typename string::type string_type; - - /// escapes URL-encoded strings (a%20value+with%20spaces) - static string_type const url_decode(string_type const & str); - - /// encodes strings so that they are safe for URLs (with%20spaces) - static string_type const url_encode(string_type const & str); - - /// builds an HTTP query string from a collection of query parameters - static string_type const make_query_string(typename query_container::type const & query_params); - - /** - * creates a "Set-Cookie" header - * - * @param name the name of the cookie - * @param value the value of the cookie - * @param path the path of the cookie - * @param has_max_age true if the max_age value should be set - * @param max_age the life of the cookie, in seconds (0 = discard) - * - * @return the new "Set-Cookie" header - */ - static string_type const make_set_cookie_header(string_type const & name, - string_type const & value, - string_type const & path, - bool const has_max_age = false, - unsigned long const max_age = 0); - - /** decodes base64-encoded strings - * - * @param input base64 encoded string - * @param output decoded string ( may include non-text chars) - * @return true if successful, false if input string contains non-base64 symbols - */ - static bool const base64_decode(string_type const &input, string_type & output); - - /** encodes strings using base64 - * - * @param input arbitrary string ( may include non-text chars) - * @param output base64 encoded string - * @return true if successful - */ - static bool const base64_encode(string_type const &input, string_type & output); - - protected: - mutable string_type version_; - mutable boost::uint16_t status_; - mutable string_type status_message_; - - private: - typedef basic_message base_type; - - public: - - message_impl() - : base_type(), version_(), status_(0u), status_message_() - {} - - message_impl(message_impl const & other) - : base_type(other), version_(other.version_), status_(other.status_), status_message_(other.status_message_) - {} - - void version(string_type const & version) const { - version_ = version; - } - - string_type const version() const { - return version_; - } - - void status(boost::uint16_t status) const { - status_ = status; - } - - boost::uint16_t const status() const { - return status_; - } - - void status_message(string_type const & status_message) const { - status_message_ = status_message; - } - - string_type const status_message() const { - return status_message_; - } - - message_impl & operator=(message_impl rhs) { - rhs.swap(*this); - return *this; - } - - void swap(message_impl & other) { - base_type & base_ref(other), - & this_ref(*this); - std::swap(this_ref, base_ref); - std::swap(status_, other.status_); - std::swap(status_message_, other.status_message_); - std::swap(version_, other.version_); - } - - }; - - template - inline void swap(message_impl & lhs, message_impl & rhs) { - lhs.swap(rhs); - } - - typedef message_impl message; - -} // namespace http - -} // namespace network - -} // namespace boost - -// import implementation file -#include - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HPP diff --git a/boost/network/protocol/http/message/directives/status.hpp b/boost/network/protocol/http/message/directives/status.hpp index 2f3b3916c..bfd68354c 100644 --- a/boost/network/protocol/http/message/directives/status.hpp +++ b/boost/network/protocol/http/message/directives/status.hpp @@ -7,8 +7,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include #include #include #include diff --git a/boost/network/protocol/http/message/directives/status_message.hpp b/boost/network/protocol/http/message/directives/status_message.hpp index 93463990b..3ac16d06b 100644 --- a/boost/network/protocol/http/message/directives/status_message.hpp +++ b/boost/network/protocol/http/message/directives/status_message.hpp @@ -7,7 +7,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include #include namespace boost { namespace network { namespace http { diff --git a/boost/network/protocol/http/message/directives/uri.hpp b/boost/network/protocol/http/message/directives/uri.hpp index f5fe4a7d1..1ae91a53e 100644 --- a/boost/network/protocol/http/message/directives/uri.hpp +++ b/boost/network/protocol/http/message/directives/uri.hpp @@ -7,7 +7,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include #include namespace boost { namespace network { namespace http { diff --git a/boost/network/protocol/http/message/directives/version.hpp b/boost/network/protocol/http/message/directives/version.hpp index f3eedf0ef..88f2d1c5a 100644 --- a/boost/network/protocol/http/message/directives/version.hpp +++ b/boost/network/protocol/http/message/directives/version.hpp @@ -7,7 +7,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include #include namespace boost { namespace network { namespace http { diff --git a/boost/network/protocol/http/message/header.hpp b/boost/network/protocol/http/message/header.hpp index 22de2a728..052ece94b 100644 --- a/boost/network/protocol/http/message/header.hpp +++ b/boost/network/protocol/http/message/header.hpp @@ -13,16 +13,16 @@ #ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_HPP_20101122 #define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_HPP_20101122 -#include +#include +#include +#include #include #include -#include -#include namespace boost { namespace network { namespace http { - template - struct unsupported_tag; + template + struct unsupported_string; struct request_header_narrow { typedef std::string string_type; @@ -34,18 +34,20 @@ namespace boost { namespace network { namespace http { std::wstring name, value; }; - template - struct request_header - : mpl::if_< - is_default_string, - request_header_narrow, - typename mpl::if_< - is_default_wstring, - request_header_wide, - unsupported_tag - >::type - > - {}; + template + struct request_header { + typedef unsupported_string type; + }; + + template + struct request_header >::type> { + typedef request_header_narrow type; + }; + + template + struct request_header >::type> { + typedef request_header_wide type; + }; inline void swap(request_header_narrow & l, request_header_narrow & r) { swap(l.name, r.name); @@ -67,18 +69,20 @@ namespace boost { namespace network { namespace http { std::wstring name, value; }; - template - struct response_header - : mpl::if_< - is_default_string, - response_header_narrow, - typename mpl::if_< - is_default_wstring, - response_header_wide, - unsupported_tag - >::type - > - {}; + template + struct response_header { + typedef unsupported_string type; + }; + + template + struct response_header >::type> { + typedef response_header_wide type; + }; + + template + struct response_header >::type> { + typedef response_header_narrow type; + }; inline void swap(response_header_narrow & l, response_header_narrow & r) { std::swap(l.name, r.name); diff --git a/boost/network/protocol/http/message/message_base.hpp b/boost/network/protocol/http/message/message_base.hpp index 885d74dbb..bc27bd03c 100644 --- a/boost/network/protocol/http/message/message_base.hpp +++ b/boost/network/protocol/http/message/message_base.hpp @@ -7,9 +7,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include - namespace boost { namespace network { namespace http { template diff --git a/boost/network/protocol/http/message/modifiers/body.hpp b/boost/network/protocol/http/message/modifiers/body.hpp index d88961dd3..40523b4ea 100644 --- a/boost/network/protocol/http/message/modifiers/body.hpp +++ b/boost/network/protocol/http/message/modifiers/body.hpp @@ -6,9 +6,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include -#include #include #include #include diff --git a/boost/network/protocol/http/message/modifiers/clear_headers.hpp b/boost/network/protocol/http/message/modifiers/clear_headers.hpp index 33e9f5854..8cf2806aa 100644 --- a/boost/network/protocol/http/message/modifiers/clear_headers.hpp +++ b/boost/network/protocol/http/message/modifiers/clear_headers.hpp @@ -6,9 +6,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include -#include #include namespace boost { namespace network { namespace http { diff --git a/boost/network/protocol/http/message/modifiers/destination.hpp b/boost/network/protocol/http/message/modifiers/destination.hpp index f0532abba..d67958653 100644 --- a/boost/network/protocol/http/message/modifiers/destination.hpp +++ b/boost/network/protocol/http/message/modifiers/destination.hpp @@ -6,9 +6,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include -#include #include #include diff --git a/boost/network/protocol/http/message/modifiers/headers.hpp b/boost/network/protocol/http/message/modifiers/headers.hpp index d789a7452..9bfcec4fc 100644 --- a/boost/network/protocol/http/message/modifiers/headers.hpp +++ b/boost/network/protocol/http/message/modifiers/headers.hpp @@ -6,7 +6,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include #include #include diff --git a/boost/network/protocol/http/message/modifiers/method.hpp b/boost/network/protocol/http/message/modifiers/method.hpp index 52afe2696..bc23dc78d 100644 --- a/boost/network/protocol/http/message/modifiers/method.hpp +++ b/boost/network/protocol/http/message/modifiers/method.hpp @@ -6,7 +6,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include #include namespace boost { namespace network { namespace http { diff --git a/boost/network/protocol/http/message/modifiers/source.hpp b/boost/network/protocol/http/message/modifiers/source.hpp index 0f4df485d..4fa537b6a 100644 --- a/boost/network/protocol/http/message/modifiers/source.hpp +++ b/boost/network/protocol/http/message/modifiers/source.hpp @@ -6,11 +6,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include #include #include -#include #include namespace boost { namespace network { namespace http { diff --git a/boost/network/protocol/http/message/modifiers/status.hpp b/boost/network/protocol/http/message/modifiers/status.hpp index 5e541f95f..dfcd305e8 100644 --- a/boost/network/protocol/http/message/modifiers/status.hpp +++ b/boost/network/protocol/http/message/modifiers/status.hpp @@ -7,7 +7,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include #include namespace boost { namespace network { namespace http { diff --git a/boost/network/protocol/http/message/modifiers/status_message.hpp b/boost/network/protocol/http/message/modifiers/status_message.hpp index 8149e6575..bcd92bcb8 100644 --- a/boost/network/protocol/http/message/modifiers/status_message.hpp +++ b/boost/network/protocol/http/message/modifiers/status_message.hpp @@ -7,7 +7,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include #include namespace boost { namespace network { namespace http { diff --git a/boost/network/protocol/http/message/modifiers/uri.hpp b/boost/network/protocol/http/message/modifiers/uri.hpp index aaa198ea3..e96525df5 100644 --- a/boost/network/protocol/http/message/modifiers/uri.hpp +++ b/boost/network/protocol/http/message/modifiers/uri.hpp @@ -7,7 +7,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include #include namespace boost { namespace network { namespace http { diff --git a/boost/network/protocol/http/message/modifiers/version.hpp b/boost/network/protocol/http/message/modifiers/version.hpp index e0b267c71..0077ca4f6 100644 --- a/boost/network/protocol/http/message/modifiers/version.hpp +++ b/boost/network/protocol/http/message/modifiers/version.hpp @@ -7,8 +7,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include #include #include diff --git a/boost/network/protocol/http/message/traits/status.hpp b/boost/network/protocol/http/message/traits/status.hpp index 2eabedea8..2ff22dcae 100644 --- a/boost/network/protocol/http/message/traits/status.hpp +++ b/boost/network/protocol/http/message/traits/status.hpp @@ -6,9 +6,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include #include -#include namespace boost { namespace network { namespace http { diff --git a/boost/network/protocol/http/message/traits/status_message.hpp b/boost/network/protocol/http/message/traits/status_message.hpp index 8469c01ff..9b0a47ccf 100644 --- a/boost/network/protocol/http/message/traits/status_message.hpp +++ b/boost/network/protocol/http/message/traits/status_message.hpp @@ -6,10 +6,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include -#include - namespace boost { namespace network { namespace http { namespace traits { diff --git a/boost/network/protocol/http/message/traits/version.hpp b/boost/network/protocol/http/message/traits/version.hpp index 15ac4e848..748bb71c6 100644 --- a/boost/network/protocol/http/message/traits/version.hpp +++ b/boost/network/protocol/http/message/traits/version.hpp @@ -6,10 +6,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include -#include -#include #include #include diff --git a/boost/network/protocol/http/message/wrappers/headers.hpp b/boost/network/protocol/http/message/wrappers/headers.hpp index 69447d30b..0b9a13b13 100644 --- a/boost/network/protocol/http/message/wrappers/headers.hpp +++ b/boost/network/protocol/http/message/wrappers/headers.hpp @@ -7,9 +7,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include - namespace boost { namespace network { namespace http { template diff --git a/boost/network/protocol/http/policies/async_connection.ipp b/boost/network/protocol/http/policies/async_connection.ipp index d638688bd..2fbc15f31 100644 --- a/boost/network/protocol/http/policies/async_connection.ipp +++ b/boost/network/protocol/http/policies/async_connection.ipp @@ -18,12 +18,11 @@ struct simple_async_client_connection : client_connection { bool get_body, callback_type callback); // override virtual void reset(); // override - virtual ~client_connection(); // override + virtual ~simple_async_client_connection(); // override protected: bool follow_redirects_; shared_ptr resolver_delegate_; shared_ptr connection_delegate_; - shared_ptr connection_; }; simple_async_client_connection::simple_async_client_connection( @@ -35,10 +34,11 @@ simple_async_client_connection::simple_async_client_connection( connection_delegate_(connection_delegate), {} -shared_ptr send_request(std::string const & method, - request_base const & request, - bool get_body, - callback_type callback) { +shared_ptr simple_async_client_connection::send_request( + std::string const & method, + request_base const & request, + bool get_body, + callback_type callback) { shared_ptr response; shared_ptr connection_; connection_.reset(new(std::nothrow) impl::async_connection( @@ -51,6 +51,12 @@ shared_ptr send_request(std::string const & method, return response } +void simple_async_client_connection::reset() { + // Do nothing here +} + +simple_async_client_connection::~simple_async_client_connection() {} + } /* http */ } /* network */ } /* boost */ @@ -113,9 +119,52 @@ namespace boost { namespace network { namespace http { struct http_1_1_async_connection : client_connection { http_1_1_async_connection(bool follow_redirects, shared_ptr resolver_delegate, - shared_ptr connection_delegate) + shared_ptr connection_delegate); + virtual shared_ptr send_request(std::string const & method, + request_base const & request, + bool get_body, + callback_type callback); //override + virtual void reset(); // override + virtual ~http_1_1_async_connection(); // override + protected: + bool follow_redirects_; + shared_ptr resolver_delegate_; + shared_ptr connection_delegate_; + shared_ptr connection_; +}; + +http_1_1_async_connection::http_1_1_async_connection( + bool follow_redirects, + shared_ptr resolver_delegate, + shared_ptr connection_delegate) +: follow_redirects_(follow_redirects), + resolver_delegate_(resolver_delegate), + connection_delegate_(connection_delegate) +{ + connection_.reset(new(std::nothrow) impl::async_connection( + resolver_delegate_, + follow_redirects_, + connection_delegate_)) +} + +shared_ptr http_1_1_async_connection::send_request( + std::string const & method, + request_base const & request, + bool get_body, + callback_type callback) { + if (!connection_.get()) + BOOST_THROW_EXCEPTION(std::runtime_error("Insufficient memory.")); + response = connection_->start(request, method, get_body, callback); + return response; } +void http_1_1_async_connection::reset() { + connection_.reset(); +} + +http_1_1_async_connection::~http_1_1_async_connection() +{} + } /* http */ } /* network */ } /* boost */ diff --git a/boost/network/protocol/http/policies/async_resolver.hpp b/boost/network/protocol/http/policies/async_resolver.hpp index 12745c0e0..c7cacfbdf 100644 --- a/boost/network/protocol/http/policies/async_resolver.hpp +++ b/boost/network/protocol/http/policies/async_resolver.hpp @@ -1,95 +1,37 @@ #ifndef BOOST_NETWORK_PROTOCOL_HTTP_POLICIES_ASYNC_RESOLVER_20100622 #define BOOST_NETWORK_PROTOCOL_HTTP_POLICIES_ASYNC_RESOLVER_20100622 -// Copyright Dean Michael Berris 2010. +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. // 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) -#include -#include -#include +#include +#include +#include namespace boost { namespace network { namespace http { namespace policies { -struct async_resolver : enable_shared_from_this { - typedef asio::ip::resolver::iterator resolver_iterator; - typedef asio::ip::resolver::query resolver_query; - typedef std::pair resolver_iterator_pair; - typedef boost::unordered_map endpoint_cache; - typedef boost::function resolve_completion_function; - typedef boost::function resolve_function; - protected: - bool cache_resolved_; - endpoint_cache endpoint_cache_; - boost::shared_ptr resolver_strand_; - - async_resolver(bool cache_resolved): - cache_resolved_(cache_resolved), - endpoint_cache_() - {} - - void resolve( - resolver_type & resolver_, - std::string const & host, - boost::uint16_t port, - resolve_completion_function once_resolved) { - if (cache_resolved_) { - typename endpoint_cache::iterator iter = - endpoint_cache_.find(boost::to_lower_copy(host)); - if (iter != endpoint_cache_.end()) { - boost::system::error_code ignored; - once_resolved(ignored, iter->second); - return; - } - } +struct async_resolver_pimpl; - typename resolver_type::query q( - resolver_type::protocol_type::v4() - , host - , lexical_cast(port)); - resolver_.async_resolve( - q, - resolver_strand_->wrap( - boost::bind( - &async_resolver::handle_resolve, - async_resolver::shared_from_this(), - boost::to_lower_copy(host), - once_resolved, - boost::asio::placeholders::error, - boost::asio::placeholders::iterator - ) - ) - ); - } +struct async_resolver { + typedef asio::ip::udp::resolver::iterator resolver_iterator; + typedef std::pair + iterator_pair; + typedef function + resolve_completion_function; - void handle_resolve( - std::string const & host, - resolve_completion_function once_resolved, - boost::system::error_code const & ec, - resolver_iterator endpoint_iterator - ) - { - typename endpoint_cache::iterator iter; - bool inserted = false; - if (!ec && cache_resolved_) { - boost::fusion::tie(iter, inserted) = - endpoint_cache_.insert( - std::make_pair( - host, - std::make_pair( - endpoint_iterator, - resolver_iterator() - ) - ) - ); - once_resolved(ec, iter->second); - } else { - once_resolved(ec, std::make_pair(endpoint_iterator,resolver_iterator())); - } - } + explicit async_resolver(asio::io_service & service); + void resolve(std::string const & host, + uint16_t port, + resolve_completion_function once_resolved); + void clear_resolved_cache(); + ~async_resolver(); - }; + protected: + shared_ptr pimpl; +}; } // namespace policies @@ -99,4 +41,8 @@ struct async_resolver : enable_shared_from_this { } // namespace boost +#ifdef BOOST_NETWORK_NO_LIB +#include +#endif + #endif // BOOST_NETWORK_PROTOCOL_HTTP_POLICIES_ASYNC_RESOLVER_20100622 diff --git a/boost/network/protocol/http/policies/pooled_connection.hpp b/boost/network/protocol/http/policies/pooled_connection.hpp deleted file mode 100644 index 31be06f8e..000000000 --- a/boost/network/protocol/http/policies/pooled_connection.hpp +++ /dev/null @@ -1,177 +0,0 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_POOLED_CONNECTION_POLICY_20091214 -#define BOOST_NETWORK_PROTOCOL_HTTP_POOLED_CONNECTION_POLICY_20091214 - -// Copyright Dean Michael Berris 2009. -// 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) - -#include - -#include -#include -#include -#include -#include -#include - -#ifndef BOOST_NETWORK_HTTP_MAXIMUM_REDIRECT_COUNT -#define BOOST_NETWORK_HTTP_MAXIMUM_REDIRECT_COUNT 5 -#endif // BOOST_NETWORK_HTTP_MAXIMUM_REDIRECT_COUNT - -namespace boost { namespace network { namespace http { - - template - struct pooled_connection_policy : resolver_policy::type { - protected: - - typedef typename string::type string_type; - typedef typename resolver_policy::type resolver_base; - typedef typename resolver_base::resolver_type resolver_type; - typedef function resolver_function_type; - typedef function const &, system::error_code const &)> body_callback_function_type; - - void cleanup() { - host_connection_map().swap(host_connections); - } - - struct connection_impl { - typedef function(resolver_type &,basic_request const &,optional const &, optional const &)> get_connection_function; - - connection_impl(resolver_type & resolver, bool follow_redirect, string_type const & host, string_type const & port, resolver_function_type resolve, get_connection_function get_connection, bool https, optional const & certificate_file=optional(), optional const & verify_path=optional()) - : pimpl(impl::sync_connection_base::new_connection(resolver, resolve, https, certificate_file, verify_path)) - , resolver_(resolver) - , connection_follow_redirect_(follow_redirect) - , get_connection_(get_connection) - , certificate_filename_(certificate_file) - , verify_path_(verify_path) - {} - - basic_response send_request(string_type const & method, basic_request request_, bool get_body, body_callback_function_type callback) { - return send_request_impl(method, request_, get_body); - } - - private: - - basic_response send_request_impl(string_type const & method, basic_request request_, bool get_body) { - boost::uint8_t count = 0; - bool retry = false; - do { - if (count >= BOOST_NETWORK_HTTP_MAXIMUM_REDIRECT_COUNT) - boost::throw_exception(std::runtime_error("Redirection exceeds maximum redirect count.")); - - basic_response response_; - // check if the socket is open first - if (!pimpl->is_open()) { - pimpl->init_socket(request_.host(), lexical_cast(request_.port())); - } - response_ = basic_response(); - response_ << ::boost::network::source(request_.host()); - - pimpl->send_request_impl(method, request_); - boost::asio::streambuf response_buffer; - - try { - pimpl->read_status(response_, response_buffer); - } catch (boost::system::system_error & e) { - if (!retry && e.code() == boost::asio::error::eof) { - retry = true; - pimpl->init_socket(request_.host(), lexical_cast(request_.port())); - continue; - } - throw; // it's a retry, and there's something wrong. - } - - pimpl->read_headers(response_, response_buffer); - - if ( - get_body && response_.status() != 304 - && (response_.status() != 204) - && !(response_.status() >= 100 && response_.status() <= 199) - ) { - pimpl->read_body(response_, response_buffer); - } - - typename headers_range >::type connection_range = headers(response_)["Connection"]; - if (version_major == 1 && version_minor == 1 && !empty(connection_range) && boost::begin(connection_range)->second == string_type("close")) { - pimpl->close_socket(); - } else if (version_major == 1 && version_minor == 0) { - pimpl->close_socket(); - } - - if (connection_follow_redirect_) { - boost::uint16_t status = response_.status(); - if (status >= 300 && status <= 307) { - typename headers_range >::type location_range = headers(response_)["Location"]; - typename range_iterator >::type>::type location_header = boost::begin(location_range); - if (location_header != boost::end(location_range)) { - request_.uri(location_header->second); - connection_ptr connection_; - connection_ = get_connection_(resolver_, request_, certificate_filename_, verify_path_); - ++count; - continue; - } else boost::throw_exception(std::runtime_error("Location header not defined in redirect response.")); - } - } - return response_; - } while(true); - } - - shared_ptr > pimpl; - resolver_type & resolver_; - bool connection_follow_redirect_; - get_connection_function get_connection_; - optional certificate_filename_, verify_path_; - }; - - typedef shared_ptr connection_ptr; - - typedef unordered_map host_connection_map; - host_connection_map host_connections; - bool follow_redirect_; - - connection_ptr get_connection(resolver_type & resolver, basic_request const & request_, optional const & certificate_filename = optional(), optional const & verify_path = optional()) { - string_type index = (request_.host() + ':') + lexical_cast(request_.port()); - connection_ptr connection_; - typename host_connection_map::iterator it = - host_connections.find(index); - if (it == host_connections.end()) { - connection_.reset(new connection_impl( - resolver - , follow_redirect_ - , request_.host() - , lexical_cast(request_.port()) - , boost::bind( - &pooled_connection_policy::resolve, - this, - _1, _2, _3 - ) - , boost::bind( - &pooled_connection_policy::get_connection, - this, - _1, _2, _3, _4 - ) - , boost::iequals(request_.protocol(), string_type("https")) - , certificate_filename - , verify_path - ) - ); - host_connections.insert(std::make_pair(index, connection_)); - return connection_; - } - return it->second; - } - - pooled_connection_policy(bool cache_resolved, bool follow_redirect) - : resolver_base(cache_resolved), host_connections(), follow_redirect_(follow_redirect) {} - - }; - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_POOLED_CONNECTION_POLICY_20091214 - diff --git a/boost/network/protocol/http/policies/simple_connection.hpp b/boost/network/protocol/http/policies/simple_connection.hpp deleted file mode 100644 index 16d9fd1a8..000000000 --- a/boost/network/protocol/http/policies/simple_connection.hpp +++ /dev/null @@ -1,117 +0,0 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_POLICIES_SIMPLE_CONNECTION_20091214 -#define BOOST_NETWORK_PROTOCOL_HTTP_POLICIES_SIMPLE_CONNECTION_20091214 - -// Copyright Dean Michael Berris 2009. -// 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) - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace network { namespace http { - - template - struct simple_connection_policy : resolver_policy::type { - protected: - - typedef typename string::type string_type; - typedef typename resolver_policy::type resolver_base; - typedef typename resolver_base::resolver_type resolver_type; - typedef function resolver_function_type; - typedef function const &, system::error_code const &)> body_callback_function_type; - - struct connection_impl { - connection_impl(resolver_type & resolver, bool follow_redirect, string_type const & hostname, string_type const & port, resolver_function_type resolve, bool https, optional const & certificate_filename = optional(), optional const & verify_path = optional()) - : pimpl() - , follow_redirect_(follow_redirect) - { - pimpl.reset(impl::sync_connection_base::new_connection(resolver, resolve, https, certificate_filename, verify_path)); - } - - basic_response send_request(string_type const & method, basic_request request_, bool get_body, body_callback_function_type callback) { - basic_response response_; - do { - pimpl->init_socket(request_.host(), lexical_cast(request_.port())); - pimpl->send_request_impl(method, request_); - - response_ = basic_response(); - response_ << network::source(request_.host()); - - boost::asio::streambuf response_buffer; - pimpl->read_status(response_, response_buffer); - pimpl->read_headers(response_, response_buffer); - if (get_body) pimpl->read_body(response_, response_buffer); - - if (follow_redirect_) { - boost::uint16_t status = response_.status(); - if (status >= 300 && status <= 307) { - typename headers_range >::type location_range = headers(response_)["Location"]; - typename range_iterator >::type>::type location_header = boost::begin(location_range); - if (location_header != boost::end(location_range)) { - request_.uri(location_header->second); - } else throw std::runtime_error("Location header not defined in redirect response."); - } else break; - } else break; - } while(true); - return response_; - } - - private: - - shared_ptr > pimpl; - bool follow_redirect_; - - }; - - typedef boost::shared_ptr connection_ptr; - connection_ptr get_connection(resolver_type & resolver, basic_request const & request_ - , optional const & certificate_file = optional() - , optional const & verify_file = optional() - ) { - connection_ptr connection_( - new connection_impl( - resolver - , follow_redirect_ - , request_.host() - , lexical_cast(request_.port()) - , boost::bind( - &simple_connection_policy::resolve, - this, - _1, _2, _3 - ) - , boost::iequals(request_.protocol(), string_type("https")) - , certificate_file - , verify_file - ) - ); - return connection_; - } - - void cleanup() { } - - simple_connection_policy(bool cache_resolved, bool follow_redirect) - : resolver_base(cache_resolved), follow_redirect_(follow_redirect) {} - - // member variables - bool follow_redirect_; - - }; - -} // namespace http - -} // namespace network - -} // namespace boost - - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_POLICIES_SIMPLE_CONNECTION_20091214 - diff --git a/boost/network/protocol/http/policies/sync_resolver.hpp b/boost/network/protocol/http/policies/sync_resolver.hpp deleted file mode 100644 index 9702425e9..000000000 --- a/boost/network/protocol/http/policies/sync_resolver.hpp +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_POLICIES_SYNC_RESOLVER_20091214 -#define BOOST_NETWORK_PROTOCOL_HTTP_POLICIES_SYNC_RESOLVER_20091214 - -// Copyright Dean Michael Berris 2009. -// 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) - -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace network { namespace http { namespace policies { - - template - struct sync_resolver { - - typedef typename resolver::type resolver_type; - typedef typename resolver_type::iterator resolver_iterator; - typedef typename resolver_type::query resolver_query; - typedef std::pair resolver_iterator_pair; - - protected: - - typedef typename string::type string_type; - typedef boost::unordered_map resolved_cache; - resolved_cache endpoint_cache_; - bool cache_resolved_; - - sync_resolver(bool cache_resolved) : cache_resolved_(cache_resolved) {} - - resolver_iterator_pair resolve(resolver_type & resolver_, string_type const & hostname, string_type const & port) { - if (cache_resolved_) { - typename resolved_cache::iterator cached_iterator = - endpoint_cache_.find(hostname); - if (cached_iterator == endpoint_cache_.end()) { - bool inserted = false; - boost::fusion::tie(cached_iterator, inserted) = - endpoint_cache_.insert( - std::make_pair( - boost::to_lower_copy(hostname), - std::make_pair( - resolver_.resolve( - resolver_query( - hostname, - port, - resolver_query::numeric_service - ) - ) - , resolver_iterator() - ) - ) - ); - }; - return cached_iterator->second; - }; - - return std::make_pair( - resolver_.resolve( - resolver_query( - hostname, - port, - resolver_query::numeric_service - ) - ) - , - resolver_iterator() - ); - }; - - }; - -} // namespace policies - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_POLICIES_SYNC_RESOLVER_20091214 - diff --git a/boost/network/protocol/http/request.hpp b/boost/network/protocol/http/request.hpp index 7ac1fa412..ef5927ba5 100644 --- a/boost/network/protocol/http/request.hpp +++ b/boost/network/protocol/http/request.hpp @@ -1,22 +1,18 @@ - -// Copyright Dean Michael Berris 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 __NETWORK_PROTOCOL_HTTP_REQUEST_20070908_1_HPP__ #define __NETWORK_PROTOCOL_HTTP_REQUEST_20070908_1_HPP__ -// Implement the HTTP Request Object +// Copyright Dean Michael Berris 2007. +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) -#include -#include #include #include #include #include - #include #include #include @@ -49,8 +45,10 @@ // forward declarations namespace boost { namespace network { namespace http { - template - struct basic_request; +struct request_base; + +template +struct basic_request; } // namespace http @@ -58,19 +56,16 @@ namespace boost { namespace network { namespace http { } // namespace boost -#include +#include namespace boost { namespace network { namespace http { - template - basic_request & operator<<( - basic_request & message, - Directive const & directive - ) - { - directive(message); - return message; - } +template +request_base & operator<< (request_base & request, + Directive const & directive) { + directive(request); + return request; +} } // namespace http diff --git a/boost/network/protocol/http/response.hpp b/boost/network/protocol/http/response.hpp index cf36cceb0..459f938b8 100644 --- a/boost/network/protocol/http/response.hpp +++ b/boost/network/protocol/http/response.hpp @@ -32,7 +32,6 @@ #include #include -#include #include #include #include diff --git a/boost/network/protocol/http/support/is_client.hpp b/boost/network/protocol/http/support/is_client.hpp index e15b89603..0958401e8 100644 --- a/boost/network/protocol/http/support/is_client.hpp +++ b/boost/network/protocol/http/support/is_client.hpp @@ -6,7 +6,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include #include namespace boost { namespace network { namespace http { diff --git a/boost/network/protocol/http/support/is_server.hpp b/boost/network/protocol/http/support/is_server.hpp index 067e16c08..934e36a07 100644 --- a/boost/network/protocol/http/support/is_server.hpp +++ b/boost/network/protocol/http/support/is_server.hpp @@ -6,7 +6,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include #include namespace boost { namespace network { namespace http { diff --git a/boost/network/protocol/http/tags.hpp b/boost/network/protocol/http/tags.hpp deleted file mode 100644 index 93db37a69..000000000 --- a/boost/network/protocol/http/tags.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_TAGS_HPP_20101019 -#define BOOST_NETWORK_PROTOCOL_HTTP_TAGS_HPP_20101019 - -// Copyright Dean Michael Berris 2010. -// 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) - -#include - -namespace boost { namespace network { namespace http { namespace tags { - - struct http { typedef mpl::true_::type is_http; }; - struct keepalive { typedef mpl::true_::type is_keepalive; }; - struct simple { typedef mpl::true_::type is_simple; }; - struct server { typedef mpl::true_::type is_server; }; - struct client { typedef mpl::true_::type is_client; }; - - using namespace boost::network::tags; - - template - struct components; - - typedef mpl::vector http_default_8bit_tcp_resolve_tags; - typedef mpl::vector http_default_8bit_udp_resolve_tags; - typedef mpl::vector http_keepalive_8bit_tcp_resolve_tags; - typedef mpl::vector http_keepalive_8bit_udp_resolve_tags; - typedef mpl::vector http_async_8bit_udp_resolve_tags; - typedef mpl::vector http_async_8bit_tcp_resolve_tags; - typedef mpl::vector http_server_tags; - typedef mpl::vector http_async_server_tags; - - BOOST_NETWORK_DEFINE_TAG(http_default_8bit_tcp_resolve); - BOOST_NETWORK_DEFINE_TAG(http_default_8bit_udp_resolve); - BOOST_NETWORK_DEFINE_TAG(http_keepalive_8bit_tcp_resolve); - BOOST_NETWORK_DEFINE_TAG(http_keepalive_8bit_udp_resolve); - BOOST_NETWORK_DEFINE_TAG(http_async_8bit_udp_resolve); - BOOST_NETWORK_DEFINE_TAG(http_async_8bit_tcp_resolve); - BOOST_NETWORK_DEFINE_TAG(http_server); - BOOST_NETWORK_DEFINE_TAG(http_async_server); - -} /* tags */ - -} /* http */ - -} /* network */ - -} /* boost */ - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_TAGS_HPP_20101019 */ diff --git a/boost/network/protocol/http/traits.hpp b/boost/network/protocol/http/traits.hpp deleted file mode 100644 index b527a31cf..000000000 --- a/boost/network/protocol/http/traits.hpp +++ /dev/null @@ -1,18 +0,0 @@ -// This file is part of the Boost Network library -// Based on the Pion Network Library (r421) -// Copyright Atomic Labs, Inc. 2007-2008 -// See http://cpp-netlib.sourceforge.net for library home page. -// -// 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 BOOST_NETWORK_PROTOCOL_HTTP_TRAITS_HPP -#define BOOST_NETWORK_PROTOCOL_HTTP_TRAITS_HPP - -// Convenience header for including different traits implementations. -#include -//#include -#include - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_TRAITS_HPP diff --git a/boost/network/protocol/http/traits/connection_keepalive.hpp b/boost/network/protocol/http/traits/connection_keepalive.hpp deleted file mode 100644 index 55d929020..000000000 --- a/boost/network/protocol/http/traits/connection_keepalive.hpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) Dean Michael Berris 2010. -// 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 BOOST_NETWORK_PROTOCOL_HTTP_TRAITS_CONECTION_KEEPALIVE_20091218 -#define BOOST_NETWORK_PROTOCOL_HTTP_TRAITS_CONECTION_KEEPALIVE_20091218 - -#include -#include - -namespace boost { namespace network { namespace http { - - template - struct connection_keepalive : is_keepalive {}; - -} /* http */ - -} /* network */ - -} /* boost */ - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_TRAITS_CONECTION_KEEPALIVE_20091218 - diff --git a/boost/network/protocol/http/traits/connection_policy.hpp b/boost/network/protocol/http/traits/connection_policy.hpp deleted file mode 100644 index 6e35570cd..000000000 --- a/boost/network/protocol/http/traits/connection_policy.hpp +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CONNECTION_POLICY_20091214 -#define BOOST_NETWORK_PROTOCOL_HTTP_CONNECTION_POLICY_20091214 - -// Copyright Dean Michael Berris 2009. -// 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) - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace network { namespace http { - - template - struct unsupported_tag; - - template - struct connection_policy - { - typedef unsupported_tag type; - }; - - template - struct connection_policy >::type> - { - typedef async_connection_policy type; - }; - - template - struct connection_policy, mpl::not_ > > >::type> - { - typedef simple_connection_policy type; - }; - - template - struct connection_policy, mpl::not_ > > >::type> - { - typedef pooled_connection_policy type; - }; - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_CONNECTION_POLICY_20091214 - diff --git a/boost/network/protocol/http/traits/delegate_factory.hpp b/boost/network/protocol/http/traits/delegate_factory.hpp deleted file mode 100644 index 714fc590e..000000000 --- a/boost/network/protocol/http/traits/delegate_factory.hpp +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_TRAITS_DELEGATE_FACTORY_HPP_20110819 -#define BOOST_NETWORK_PROTOCOL_HTTP_TRAITS_DELEGATE_FACTORY_HPP_20110819 - -// Copyright 2011 Dean Michael Berris (dberris@google.com). -// Copyright 2011 Google, Inc. -// 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) - -#include - -namespace boost { namespace network { namespace http { - -namespace impl { - -template -struct connection_delegate_factory; - -} /* impl */ - -template struct unsupported_tag; - -template -struct delegate_factory { - typedef unsupported_tag type; -}; - -template -struct delegate_factory >::type> { - typedef impl::connection_delegate_factory type; -}; - -} /* http */ -} /* network */ -} /* boost */ - - - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_TRAITS_DELEGATE_FACTORY_HPP_20110819 */ diff --git a/boost/network/protocol/http/traits/impl/chunk_cache.ipp b/boost/network/protocol/http/traits/impl/chunk_cache.ipp deleted file mode 100644 index 724b13011..000000000 --- a/boost/network/protocol/http/traits/impl/chunk_cache.ipp +++ /dev/null @@ -1,36 +0,0 @@ - -// Copyright Dean Michael Berris 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 BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_CHUNK_CACHE_CONTAINER_IPP -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_CHUNK_CACHE_CONTAINER_IPP - -#include -#include - -#include -#include - -namespace boost { namespace network { namespace http { - - template - struct chunk_cache { - // TODO define the allocator using an allocator_traits? - typedef std::list< - std::vector< - typename char_::type - > - > type; - }; - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_CHUNK_CACHE_CONTAINER_IPP - - diff --git a/boost/network/protocol/http/traits/impl/content.ipp b/boost/network/protocol/http/traits/impl/content.ipp deleted file mode 100644 index 2af19b58f..000000000 --- a/boost/network/protocol/http/traits/impl/content.ipp +++ /dev/null @@ -1,44 +0,0 @@ - -// Copyright Dean Michael Berris 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 BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_CONTENT_IPP -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_CONTENT_IPP - -#include - -namespace boost { namespace network { namespace http { - - template <> - struct content { - static char const * const type_html() { - static char const * const TYPE_HTML = "text/html"; - return TYPE_HTML; - }; - - static char const * const type_text() { - static char const * const TYPE_TEXT = "text/plain"; - return TYPE_TEXT; - }; - - static char const * const type_xml() { - static char const * const TYPE_XML = "text/xml"; - return TYPE_XML; - }; - - static char const * const type_urlencoded() { - static char const * const TYPE_URLENCODED = "application/x-www-form-urlencoded"; - return TYPE_URLENCODED; - }; - }; - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_CONTENT_IPP - diff --git a/boost/network/protocol/http/traits/impl/cookie_name.ipp b/boost/network/protocol/http/traits/impl/cookie_name.ipp deleted file mode 100644 index 5389b5a67..000000000 --- a/boost/network/protocol/http/traits/impl/cookie_name.ipp +++ /dev/null @@ -1,26 +0,0 @@ - -// Copyright Dean Michael Berris 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 BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_COOKIE_NAME_IPP -#define BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_COOKIE_NAME_IPP - -#include - -namespace boost { namespace network { namespace http { - - template <> - struct cookie_name { - static boost::uint32_t const MAX = 1024u; - }; - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_COOKIE_NAME_IPP - diff --git a/boost/network/protocol/http/traits/impl/cookie_value.ipp b/boost/network/protocol/http/traits/impl/cookie_value.ipp deleted file mode 100644 index 9905b67b4..000000000 --- a/boost/network/protocol/http/traits/impl/cookie_value.ipp +++ /dev/null @@ -1,26 +0,0 @@ - -// Copyright Dean Michael Berris 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 BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_COOKIE_VALUE_IPP -#define BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_COOKIE_VALUE_IPP - -#include - -namespace boost { namespace network { namespace http { - - template <> - struct cookie_value { - static boost::uint32_t const MAX = 1024u * 1024u; - }; - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_COOKIE_VALUE_IPP - diff --git a/boost/network/protocol/http/traits/impl/cookies_container.ipp b/boost/network/protocol/http/traits/impl/cookies_container.ipp deleted file mode 100644 index d6dbe74f1..000000000 --- a/boost/network/protocol/http/traits/impl/cookies_container.ipp +++ /dev/null @@ -1,32 +0,0 @@ - -// Copyright Dean Michael Berris 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 BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_COOKIES_CONTAINER_IPP -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_COOKIES_CONTAINER_IPP - -#include - -#include - -namespace boost { namespace network { namespace http { - - template - struct cookies_container { - typedef std::multimap< - typename string::type, - typename string::type - > type; - }; - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_COOKIES_CONTAINER_IPP - - diff --git a/boost/network/protocol/http/traits/impl/delimiters.ipp b/boost/network/protocol/http/traits/impl/delimiters.ipp deleted file mode 100644 index 621f02433..000000000 --- a/boost/network/protocol/http/traits/impl/delimiters.ipp +++ /dev/null @@ -1,40 +0,0 @@ - -// Copyright Dean Michael Berris 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 BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_DELIMITERS_IPP -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_DELIMITERS_IPP - -#include - -namespace boost { namespace network { namespace http { - - // specialize on the tags::http_default_8bit_tcp_resolve type - template <> - struct delimiters { - static char const * const string_crlf() { - static char const * const CRLF = "\x0D\x0A"; - return CRLF; - }; - - static char const * const string_http_version() { - static char const * const HTTP_VERSION = "HTTP/1.1"; - return HTTP_VERSION; - }; - - static char const * const header_name_value_delimiter() { - static char const * const HEADER_NAME_VALUE_DELIMITER = ": "; - return HEADER_NAME_VALUE_DELIMITER; - }; - }; - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_DELIMITERS_IPP - diff --git a/boost/network/protocol/http/traits/impl/header_name.ipp b/boost/network/protocol/http/traits/impl/header_name.ipp deleted file mode 100644 index 66b502753..000000000 --- a/boost/network/protocol/http/traits/impl/header_name.ipp +++ /dev/null @@ -1,26 +0,0 @@ - -// Copyright Dean Michael Berris 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 BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_HEADER_NAME_IPP -#define BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_HEADER_NAME_IPP - -#include - -namespace boost { namespace network { namespace http { - - template <> - struct header_name { - static boost::uint32_t const MAX = 1024u; - }; - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_HEADER_NAME_IPP - diff --git a/boost/network/protocol/http/traits/impl/header_value.ipp b/boost/network/protocol/http/traits/impl/header_value.ipp deleted file mode 100644 index 2dfce49b6..000000000 --- a/boost/network/protocol/http/traits/impl/header_value.ipp +++ /dev/null @@ -1,26 +0,0 @@ - -// Copyright Dean Michael Berris 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 BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_HEADER_VALUE_IPP -#define BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_HEADER_VALUE_IPP - -#include - -namespace boost { namespace network { namespace http { - - template <> - struct header_value { - static boost::uint32_t const MAX = 1024u * 1024u; - }; - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_HEADER_VALUE_IPP - diff --git a/boost/network/protocol/http/traits/impl/headers.ipp b/boost/network/protocol/http/traits/impl/headers.ipp deleted file mode 100644 index d13831118..000000000 --- a/boost/network/protocol/http/traits/impl/headers.ipp +++ /dev/null @@ -1,85 +0,0 @@ - -// Copyright Dean Michael Berris 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 BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_HEADERS_HPP -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_HEADERS_HPP - -#include - -namespace boost { namespace network { namespace http { - - template <> - struct headers_ { - static char const * const host() { - static char const * const HOST = "Host"; - return HOST; - }; - - static char const * const cookie() { - static char const * const COOKIE = "Cookie"; - return COOKIE; - }; - - static char const * const set_cookie() { - static char const * const SET_COOKIE = "Set-Cookie"; - return SET_COOKIE; - }; - - static char const * const connection() { - static char const * const CONNECTION = "Connection"; - return CONNECTION; - }; - - static char const * const content_type() { - static char const * const CONTENT_TYPE = "Content-Type"; - return CONTENT_TYPE; - }; - - static char const * const content_length() { - static char const * const CONTENT_LENGTH = "Content-Length"; - return CONTENT_LENGTH; - }; - - static char const * const content_location() { - static char const * const CONTENT_LOCATION = "Content-Location"; - return CONTENT_LOCATION; - }; - - static char const * const last_modified() { - static char const * const LAST_MODIFIED = "Last-Modified"; - return LAST_MODIFIED; - }; - - static char const * const if_modified_since() { - static char const * const IF_MODIFIED_SINCE = "If-Modified-Since"; - return IF_MODIFIED_SINCE; - }; - - static char const * const transfer_encoding() { - static char const * const TRANSFER_ENCODING = "Transfer-Encoding"; - return TRANSFER_ENCODING; - }; - - static char const * const location() { - static char const * const LOCATION = "Location"; - return LOCATION; - }; - - static char const * const authorization() { - static char const * const AUTHORIZATION = "Authorization"; - return AUTHORIZATION; - }; - - }; - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_HEADERS_HPP - diff --git a/boost/network/protocol/http/traits/impl/headers_container.ipp b/boost/network/protocol/http/traits/impl/headers_container.ipp deleted file mode 100644 index 42f455da7..000000000 --- a/boost/network/protocol/http/traits/impl/headers_container.ipp +++ /dev/null @@ -1,45 +0,0 @@ - -// Copyright Dean Michael Berris 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 BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_HEADERS_CONTAINER_IPP -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_HEADERS_CONTAINER_IPP - -#include -#include -#include -#include -#include - -namespace boost { namespace network { - - template <> - struct headers_container { - - // Moving implementation from original - // message_traits implementation by - // Atomic Labs, Inc. - // -- - // returns true if str1 < str2 (ignoring case) - struct is_less_ignore_case { - inline bool operator() ( - string::type const & str1, - string::type const & str2) const { - return to_lower_copy(str1) < to_lower_copy(str2); - }; - }; - - typedef std::multimap< - string::type, - string::type, - is_less_ignore_case> type; - }; - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_HEADERS_CONTAINER_IPP - diff --git a/boost/network/protocol/http/traits/impl/method.ipp b/boost/network/protocol/http/traits/impl/method.ipp deleted file mode 100644 index 52af0d19d..000000000 --- a/boost/network/protocol/http/traits/impl/method.ipp +++ /dev/null @@ -1,28 +0,0 @@ - -// Copyright Dean Michael Berris 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 BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_METHOD_IPP -#define BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_METHOD_IPP - -#include - -namespace boost { namespace network { namespace http { - - template <> - struct method { - static boost::uint32_t const MAX = 1024u; - }; - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_METHOD_IPP - - - diff --git a/boost/network/protocol/http/traits/impl/post_content.ipp b/boost/network/protocol/http/traits/impl/post_content.ipp deleted file mode 100644 index 1a02c38c7..000000000 --- a/boost/network/protocol/http/traits/impl/post_content.ipp +++ /dev/null @@ -1,26 +0,0 @@ - -// Copyright Dean Michael Berris 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 BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_POST_CONTENT_IPP -#define BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_POST_CONTENT_IPP - -#include - -namespace boost { namespace network { namespace http { - - template <> - struct post_content { - static boost::uint32_t const MAX = 1024u * 1024u; - }; - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_POST_CONTENT_IPP - diff --git a/boost/network/protocol/http/traits/impl/query_container.ipp b/boost/network/protocol/http/traits/impl/query_container.ipp deleted file mode 100644 index deefc7e7c..000000000 --- a/boost/network/protocol/http/traits/impl/query_container.ipp +++ /dev/null @@ -1,31 +0,0 @@ - -// Copyright Dean Michael Berris 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 BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_QUERY_CONTAINER_IPP -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_QUERY_CONTAINER_IPP - -#include - -#include - -namespace boost { namespace network { namespace http { - - template - struct query_container { - typedef std::multimap< - typename string::type, - typename string::type - > type; - }; - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_QUERY_CONTAINER_IPP - diff --git a/boost/network/protocol/http/traits/impl/query_name.ipp b/boost/network/protocol/http/traits/impl/query_name.ipp deleted file mode 100644 index 35a12ac4f..000000000 --- a/boost/network/protocol/http/traits/impl/query_name.ipp +++ /dev/null @@ -1,26 +0,0 @@ - -// Copyright Dean Michael Berris 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 BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_QUERY_NAME_IPP -#define BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_QUERY_NAME_IPP - -#include - -namespace boost { namespace network { namespace http { - - template <> - struct query_name { - static boost::uint32_t const MAX = 1024u; - }; - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_QUERY_NAME_IPP - diff --git a/boost/network/protocol/http/traits/impl/query_string.ipp b/boost/network/protocol/http/traits/impl/query_string.ipp deleted file mode 100644 index 98e1b3cee..000000000 --- a/boost/network/protocol/http/traits/impl/query_string.ipp +++ /dev/null @@ -1,26 +0,0 @@ - -// Copyright Dean Michael Berris 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 BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_QUERY_STRING_IPP -#define BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_QUERY_STRING_IPP - -#include - -namespace boost { namespace network { namespace http { - - template <> - struct query_string { - static boost::uint32_t const MAX = 1024u * 1024u; - }; - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_QUERY_STRING_IPP - diff --git a/boost/network/protocol/http/traits/impl/query_value.ipp b/boost/network/protocol/http/traits/impl/query_value.ipp deleted file mode 100644 index 64343be0c..000000000 --- a/boost/network/protocol/http/traits/impl/query_value.ipp +++ /dev/null @@ -1,26 +0,0 @@ - -// Copyright Dean Michael Berris 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 BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_QUERY_VALUE_IPP -#define BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_QUERY_VALUE_IPP - -#include - -namespace boost { namespace network { namespace http { - - template <> - struct query_value { - static boost::uint32_t const MAX = 1024u * 1024u; - }; - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_QUERY_VALUE_IPP - diff --git a/boost/network/protocol/http/traits/impl/request_methods.ipp b/boost/network/protocol/http/traits/impl/request_methods.ipp deleted file mode 100644 index 50a4acff8..000000000 --- a/boost/network/protocol/http/traits/impl/request_methods.ipp +++ /dev/null @@ -1,49 +0,0 @@ - -// Copyright Dean Michael Berris 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 BOOST_NETWORK_PROTOCOL_HTTP_TRAITS_REQUEST_METHODS_IPP -#define BOOST_NETWORK_PROTOCOL_HTTP_TRAITS_REQUEST_METHODS_IPP - -#include - -namespace boost { namespace network { namespace http { - - template <> - struct request_methods { - static char const * const head() { - static char const * const HEAD = "HEAD"; - return HEAD; - }; - - static char const * const get() { - static char const * const GET = "GET"; - return GET; - }; - - static char const * const put() { - static char const * const PUT = "PUT"; - return PUT; - }; - - static char const * const post() { - static char const * const POST = "POST"; - return POST; - }; - - static char const * const delete_() { - static char const * const DELETE_ = "DELETE"; - return DELETE_; - }; - }; - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_TRAITS_REQUEST_METHODS_IPP - diff --git a/boost/network/protocol/http/traits/impl/resource.ipp b/boost/network/protocol/http/traits/impl/resource.ipp deleted file mode 100644 index 897cbf3b3..000000000 --- a/boost/network/protocol/http/traits/impl/resource.ipp +++ /dev/null @@ -1,26 +0,0 @@ - -// Copyright Dean Michael Berris 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 BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_RESOURCE_IPP -#define BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_RESOURCE_IPP - -#include - -namespace boost { namespace network { namespace http { - - template <> - struct resource { - static boost::uint32_t const MAX = 1024u * 256u; - }; - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_RESOURCE_IPP - diff --git a/boost/network/protocol/http/traits/impl/response_code.ipp b/boost/network/protocol/http/traits/impl/response_code.ipp deleted file mode 100644 index 42f7815ae..000000000 --- a/boost/network/protocol/http/traits/impl/response_code.ipp +++ /dev/null @@ -1,42 +0,0 @@ - -// Copyright Dean Michael Berris 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 BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_RESPONSE_CODE_IPP -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_RESPONSE_CODE_IPP - -#include -#include - -namespace boost { namespace network { namespace http { - - /* This glob doesn't have a specialization on the tags::http_default_8bit_tcp_resolve - * yet because it doesn't need to define different behaviour/types - * on different message tags -- for example, it doesn't need to - * determine the type or change the values of the data no matter - * what the tag type is provided. - */ - template - struct response_code { - static boost::uint16_t const OK = 200u; - static boost::uint16_t const CREATED = 201u; - static boost::uint16_t const NO_CONTENT = 204u; - static boost::uint16_t const UNAUTHORIZED = 401u; - static boost::uint16_t const FORBIDDEN = 403u; - static boost::uint16_t const NOT_FOUND = 404u; - static boost::uint16_t const METHOD_NOT_ALLOWED = 405u; - static boost::uint16_t const NOT_MODIFIED = 304u; - static boost::uint16_t const BAD_REQUEST = 400u; - static boost::uint16_t const SERVER_ERROR = 500u; - static boost::uint16_t const NOT_IMPLEMENTED = 501u; - }; - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_RESPONSE_CODE_IPP diff --git a/boost/network/protocol/http/traits/impl/response_message.ipp b/boost/network/protocol/http/traits/impl/response_message.ipp deleted file mode 100644 index de031276e..000000000 --- a/boost/network/protocol/http/traits/impl/response_message.ipp +++ /dev/null @@ -1,80 +0,0 @@ - -// Copyright Dean Michael Berris 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 BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_RESPONSE_MESSAGE_IPP -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_RESPONSE_MESSAGE_IPP - -#include - -namespace boost { namespace network { namespace http { - - template <> - struct response_message { - static char const * const ok() { - static char const * const OK = "OK"; - return OK; - }; - - static char const * const created() { - static char const * const CREATED = "Created"; - return CREATED; - }; - - static char const * const no_content() { - static char const * const NO_CONTENT = "NO Content"; - return NO_CONTENT; - }; - - static char const * const unauthorized() { - static char const * const UNAUTHORIZED = "Unauthorized"; - return UNAUTHORIZED; - }; - - static char const * const forbidden() { - static char const * const FORBIDDEN = "Fobidden"; - return FORBIDDEN; - }; - - static char const * const not_found() { - static char const * const NOT_FOUND = "Not Found"; - return NOT_FOUND; - }; - - static char const * const method_not_allowed() { - static char const * const METHOD_NOT_ALLOWED = "Method Not Allowed"; - return METHOD_NOT_ALLOWED; - }; - - static char const * const not_modified() { - static char const * const NOT_MODIFIED = "Not Modified"; - return NOT_MODIFIED; - }; - - static char const * const bad_request() { - static char const * const BAD_REQUEST = "Bad Request"; - return BAD_REQUEST; - }; - - static char const * const server_error() { - static char const * const SERVER_ERROR = "Server Error"; - return SERVER_ERROR; - }; - - static char const * const not_implemented() { - static char const * const NOT_IMPLEMENTED = "Not Implemented"; - return NOT_IMPLEMENTED; - }; - - }; - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_RESPONSE_MESSAGE_IPP - diff --git a/boost/network/protocol/http/traits/impl/status_message.ipp b/boost/network/protocol/http/traits/impl/status_message.ipp deleted file mode 100644 index 71c77d462..000000000 --- a/boost/network/protocol/http/traits/impl/status_message.ipp +++ /dev/null @@ -1,27 +0,0 @@ - -// Copyright Dean Michael Berris 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 BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_STATUS_MESSAGE_IPP -#define BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_STATUS_MESSAGE_IPP - -#include - -namespace boost { namespace network { namespace http { - - template <> - struct status_message_text { - static boost::uint32_t const MAX = 1024u; - }; - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_STATUS_MESSAGE_IPP - - diff --git a/boost/network/protocol/http/traits/message_traits.hpp b/boost/network/protocol/http/traits/message_traits.hpp deleted file mode 100644 index deb41df42..000000000 --- a/boost/network/protocol/http/traits/message_traits.hpp +++ /dev/null @@ -1,63 +0,0 @@ - -// This file is part of the Boost Network library -// Based on the Pion Network Library (r421) -// Copyright Atomic Labs, Inc. 2007-2008 -// See http://cpp-netlib.sourceforge.net for library home page. -// -// 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) -// -// Some changes Copyright (c) Dean Michael Berris 2008 - -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_HPP -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_HPP - -namespace boost { namespace network { namespace http { - - template - struct delimiters; - - template - struct headers_; - - template - struct content; - - template - struct request_methods; - - template - struct response_message; - - template - struct response_code; - - template - struct query_container; - - template - struct cookies_container; - - template - struct chunk_cache; - -} // namespace http - -} // namespace network - -} // namespace boost - -// Defer definition in implementation files -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_TRAITS_HPP diff --git a/boost/network/protocol/http/traits/parser_traits.hpp b/boost/network/protocol/http/traits/parser_traits.hpp deleted file mode 100644 index c5465e544..000000000 --- a/boost/network/protocol/http/traits/parser_traits.hpp +++ /dev/null @@ -1,70 +0,0 @@ -// This file is part of the Boost Network library -// Based on the Pion Network Library (r421) -// Copyright Atomic Labs, Inc. 2007-2008 -// See http://cpp-netlib.sourceforge.net for library home page. -// -// 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) -// -// Some changes Copyright 2008 (c) Dean Michael Berris - -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_HPP -#define BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_HPP - -namespace boost { namespace network { namespace http { - - template - struct status_message_text; - - template - struct method; - - template - struct resource; - - template - struct query_string; - - template - struct header_name; - - template - struct header_value; - - template - struct query_name; - - template - struct query_value; - - template - struct cookie_name; - - template - struct cookie_value; - - template - struct post_content; - -} // namespace http - -} // namespace network - -} // namespace boost - -// Include implementation files -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_PARSER_TRAITS_HPP - diff --git a/boost/network/protocol/http/traits/resolver.hpp b/boost/network/protocol/http/traits/resolver.hpp deleted file mode 100644 index c2a31fe68..000000000 --- a/boost/network/protocol/http/traits/resolver.hpp +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_TRAITS_RESOLVER_20091214 -#define BOOST_NETWORK_PROTOCOL_HTTP_TRAITS_RESOLVER_20091214 - -// Copyright Dean Michael Berris 2009. -// 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) - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace network { namespace http { - - template - struct unsupported_tag; - - template - struct resolver : - mpl::if_< - mpl::and_< - is_tcp, - is_http - >, - boost::asio::ip::tcp::resolver, - typename mpl::if_< - mpl::and_< - is_udp, - is_http - >, - boost::asio::ip::udp::resolver, - unsupported_tag - >::type - > - { - BOOST_STATIC_ASSERT(( - mpl::not_< - mpl::and_< - is_udp, - is_tcp - > - >::value - )); - }; - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_TRAITS_RESOLVER_20091214 - diff --git a/boost/network/protocol/http/traits/resolver_policy.hpp b/boost/network/protocol/http/traits/resolver_policy.hpp deleted file mode 100644 index 50359a90a..000000000 --- a/boost/network/protocol/http/traits/resolver_policy.hpp +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_RESOLVER_POLICY_20091214 -#define BOOST_NETWORK_PROTOCOL_HTTP_RESOLVER_POLICY_20091214 - -// Copyright Dean Michael Berris 2009. -// 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) - -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace network { namespace http { - - template - struct unsupported_tag; - - template - struct resolver_policy : - mpl::if_< - mpl::and_< is_async,is_http >, - policies::async_resolver, - typename mpl::if_, - policies::sync_resolver, - unsupported_tag - >::type - > - {}; - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_RESOLVER_POLICY_20091214 - diff --git a/boost/network/protocol/http/traits/vector.hpp b/boost/network/protocol/http/traits/vector.hpp deleted file mode 100644 index 61b2f5b2f..000000000 --- a/boost/network/protocol/http/traits/vector.hpp +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_TRAITS_VECTOR_HPP_20101019 -#define BOOST_NETWORK_PROTOCOL_HTTP_TRAITS_VECTOR_HPP_20101019 - -// Copyright (c) Dean Michael Berris 2010. -// 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) - -#include -#include - -namespace boost { namespace network { - - template <> - struct vector { - - template - struct apply { - typedef std::vector type; - }; - - }; - - template <> - struct vector { - - template - struct apply { - typedef std::vector type; - }; - - }; - -} /* network */ - -} /* boost */ - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_TRAITS_VECTOR_HPP_20101019 */ diff --git a/boost/network/support/is_async.hpp b/boost/network/support/is_async.hpp deleted file mode 100644 index d6e1f99f5..000000000 --- a/boost/network/support/is_async.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef BOOST_NETWORK_SUPPORT_IS_ASYNC_HPP_20100608 -#define BOOST_NETWORK_SUPPORT_IS_ASYNC_HPP_20100608 - -// Copyright 2010 (c) Dean Michael Berris -// Copyright 2010 (c) Sinefunc, Inc. -// 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) - -#include -#include - -namespace boost { namespace network { - - template - struct is_async : mpl::false_ {}; - - template - struct is_async::type> : mpl::true_ {}; - -} // namespace network - -} // namespace boost - -#endif //BOOST_NETWORK_SUPPORT_IS_ASYNC_HPP_2010608 diff --git a/boost/network/support/is_default_string.hpp b/boost/network/support/is_default_string.hpp deleted file mode 100644 index 2a0fd824e..000000000 --- a/boost/network/support/is_default_string.hpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright Dean Michael Berris 2010 -// 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 BOOST_NETWORK_SUPPORT_STRING_CHECK_20100808 -#define BOOST_NETWORK_SUPPORT_STRING_CHECK_20100808 - -#include -#include - -namespace boost { namespace network { - - template - struct is_default_string : mpl::false_ {}; - - template - struct is_default_string::type> : mpl::true_ {}; - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_SUPPORT_STRING_CHECK_20100808 diff --git a/boost/network/support/is_default_wstring.hpp b/boost/network/support/is_default_wstring.hpp deleted file mode 100644 index c414353e1..000000000 --- a/boost/network/support/is_default_wstring.hpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright Dean Michael Berris 2010 -// 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 BOOST_NETWORK_SUPPORT_WSTRING_CHECK_20100808 -#define BOOST_NETWORK_SUPPORT_WSTRING_CHECK_20100808 - -#include -#include - -namespace boost { namespace network { - - template - struct is_default_wstring : mpl::false_ {}; - - template - struct is_default_wstring::type> : mpl::true_ {}; - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_SUPPORT_STRING_CHECK_20100808 diff --git a/boost/network/support/is_http.hpp b/boost/network/support/is_http.hpp deleted file mode 100644 index c104e7b42..000000000 --- a/boost/network/support/is_http.hpp +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef BOOST_NETWORK_SUPPORT_IS_HTTP_HPP_20100622 -#define BOOST_NETWORK_SUPPORT_IS_HTTP_HPP_20100622 - -// Copyright 2010 (c) Dean Michael Berris -// 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) - -#include -#include - -namespace boost { namespace network { - - template - struct is_http : mpl::false_ {}; - - template - struct is_http::type> : mpl::true_ {}; - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_SUPPORT_IS_HTTP_HPP_20100622 diff --git a/boost/network/support/is_keepalive.hpp b/boost/network/support/is_keepalive.hpp deleted file mode 100644 index 6607cd10f..000000000 --- a/boost/network/support/is_keepalive.hpp +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef BOOST_NETWORK_SUPPORT_IS_KEEPALIVE_HPP_20100927 -#define BOOST_NETWORK_SUPPORT_IS_KEEPALIVE_HPP_20100927 - -// Copyright 2010 (c) Dean Michael Berris -// 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) - -#include -#include - -namespace boost { namespace network { - - template - struct is_keepalive : mpl::false_ {}; - - template - struct is_keepalive::type> : mpl::true_ {}; - -} /* network */ - -} /* boost */ - -#endif /* BOOST_NETWORK_SUPPORT_IS_KEEPALIVE_HPP_20100927 */ diff --git a/boost/network/support/is_pod.hpp b/boost/network/support/is_pod.hpp deleted file mode 100644 index 5c1e1065c..000000000 --- a/boost/network/support/is_pod.hpp +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef BOOST_NETWORK_SUPPORT_IS_POD_HPP_20101120 -#define BOOST_NETWORK_SUPPORT_IS_POD_HPP_20101120 - -// Copyright 2010 Dean Michael Berris. -// 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) - -#include -#include - -namespace boost { namespace network { - - template - struct is_pod : mpl::false_ {}; - - template - struct is_pod::type> : mpl::true_ {}; - -} /* network */ - -} /* boost */ - -#endif /* BOOST_NETWORK_SUPPORT_IS_POD_HPP_20101120 */ diff --git a/boost/network/support/is_simple.hpp b/boost/network/support/is_simple.hpp deleted file mode 100644 index 98406d41a..000000000 --- a/boost/network/support/is_simple.hpp +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef BOOST_NETWORK_SUPPORT_IS_SIMPLE_HPP_20100927 -#define BOOST_NETWORK_SUPPORT_IS_SIMPLE_HPP_20100927 - -// Copyright 2010 (c) Dean Michael Berris -// 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) - -#include -#include - -namespace boost { namespace network { - - template - struct is_simple : mpl::false_ {}; - - template - struct is_simple::type> : mpl::true_ {}; - -} /* network */ - -} /* boost */ - -#endif /* BOOST_NETWORK_SUPPORT_IS_SIMPLE_HPP_20100927 */ diff --git a/boost/network/support/is_sync.hpp b/boost/network/support/is_sync.hpp deleted file mode 100644 index 0ff0f7130..000000000 --- a/boost/network/support/is_sync.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef BOOST_NETWORK_SUPPORT_IS_SYNC_HPP_20100623 -#define BOOST_NETWORK_SUPPORT_IS_SYNC_HPP_20100623 - -// Copyright 2010 (c) Dean Michael Berris -// 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) - -#include -#include - -namespace boost { namespace network { - - template - struct is_sync : mpl::false_ {}; - - template - struct is_sync::type> : mpl::true_ {}; - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_SUPPORT_IS_SYNC_HPP_20100623 - diff --git a/boost/network/support/is_tcp.hpp b/boost/network/support/is_tcp.hpp deleted file mode 100644 index c041f125f..000000000 --- a/boost/network/support/is_tcp.hpp +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef BOOST_NETWORK_SUPPORT_IS_TCP_HPP_20100622 -#define BOOST_NETWORK_SUPPORT_IS_TCP_HPP_20100622 - -// Copyright 2010 (c) Dean Michael Berris -// 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) - -#include -#include -#include -#include - -namespace boost { namespace network { - - template - struct is_tcp : mpl::false_ {}; - - template - struct is_tcp::type> : mpl::true_ {}; - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_SUPPORT_IS_TCP_HPP_20100622 \ No newline at end of file diff --git a/boost/network/support/is_udp.hpp b/boost/network/support/is_udp.hpp deleted file mode 100644 index cacbc5e0e..000000000 --- a/boost/network/support/is_udp.hpp +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef BOOST_NETWORK_SUPPORT_IS_UDP_HPP_20100622 -#define BOOST_NETWORK_SUPPORT_IS_UDP_HPP_20100622 - -// Copyright 2010 (c) Dean Michael Berris -// 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) - -#include -#include -#include -#include -#include - -namespace boost { namespace network { - - template - struct is_udp : mpl::false_ {}; - - template - struct is_udp::type> : mpl::true_ {}; - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_SUPPORT_IS_UDP_HPP_20100622 \ No newline at end of file diff --git a/boost/network/support/pod_or_normal.hpp b/boost/network/support/pod_or_normal.hpp deleted file mode 100644 index fdfcf4c12..000000000 --- a/boost/network/support/pod_or_normal.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SUPPORT_POD_OR_NORMAL_HPP_20101128 -#define BOOST_NETWORK_PROTOCOL_HTTP_SUPPORT_POD_OR_NORMAL_HPP_20101128 - -// Copyright 2010 Dean Michael Berris. -// 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) - -#include -#include -#include - -namespace boost { namespace network { - - template - struct pod_or_normal { typedef tags::normal type; }; - - template - struct pod_or_normal::type> : tags::pod {}; - -} /* network */ - -} /* boost */ - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_SUPPORT_POD_OR_NORMAL_HPP_20101128 */ diff --git a/boost/network/support/sync_only.hpp b/boost/network/support/sync_only.hpp deleted file mode 100644 index 4fbdde818..000000000 --- a/boost/network/support/sync_only.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef BOOST_NETWORK_SUPPORT_SYNC_ONLY_HPP_20100927 -#define BOOST_NETWORK_SUPPORT_SYNC_ONLY_HPP_20100927 - -// Copyright Dean Michael Berris 2010. -// 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) - -#include -#include -#include -#include -#include - -namespace boost { namespace network { - - template - struct sync_only : - mpl::inherit_linearly< - typename mpl::replace_if< - typename tags::components::type, - is_same, - tags::sync - >::type - , mpl::inherit - > - {}; - -} /* network */ - -} /* boost */ - -#endif /* BOOST_NETWORK_SUPPORT_SYNC_ONLY_HPP_20100927 */ diff --git a/boost/network/tags.hpp b/boost/network/tags.hpp deleted file mode 100644 index df74703a3..000000000 --- a/boost/network/tags.hpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright Dean Michael Berris 2008, 2009. -// Glyn Matthews 2009 -// 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 BOOST_NETWORK_TAG_INCLUDED_20100808 -#define BOOST_NETWORK_TAG_INCLUDED_20100808 - -#include -#include -#include -#include - -namespace boost { namespace network { namespace tags { - - struct pod { typedef mpl::true_::type is_pod; }; - struct normal { typedef mpl::true_::type is_normal; }; - struct async { typedef mpl::true_::type is_async; }; - struct tcp { typedef mpl::true_::type is_tcp; }; - struct udp { typedef mpl::true_::type is_udp; }; - struct sync { typedef mpl::true_::type is_sync; }; - struct default_string - { typedef mpl::true_::type is_default_string; }; - struct default_wstring - { typedef mpl::true_::type is_default_wstring; }; - - template - struct components; - - // Tag Definition Macro Helper -#ifndef BOOST_NETWORK_DEFINE_TAG -#define BOOST_NETWORK_DEFINE_TAG(name) \ - struct name : mpl::inherit_linearly< \ - name##_tags, \ - mpl::inherit \ - >::type {}; \ - template <> struct components { \ - typedef name##_tags type; \ - }; -#endif // BOOST_NETWORK_DEFINE_TAG - - typedef default_string default_; - -} // namespace tags - -} // namespace network - -} // namespace boost - -#endif // __BOOST_NETWORK_TAGS_INC__ diff --git a/boost/network/traits/char.hpp b/boost/network/traits/char.hpp deleted file mode 100644 index 79e73441d..000000000 --- a/boost/network/traits/char.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) Dean Michael Berris 2008, 2009. -// 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 BOOST_NETWORK_TRAITS_CHAR_HPP -#define BOOST_NETWORK_TRAITS_CHAR_HPP - -#include -#include - -namespace boost { namespace network { - - template - struct unsupported_tag; - - template - struct char_ - { - typedef unsupported_tag type; - }; - - template - struct char_ >::type> - { - typedef char type; - }; - - template - struct char_ >::type> - { - typedef wchar_t type; - }; - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_TRAITS_CHAR_HPP diff --git a/boost/network/traits/headers_container.hpp b/boost/network/traits/headers_container.hpp deleted file mode 100644 index f852312d2..000000000 --- a/boost/network/traits/headers_container.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Glyn Matthews 2009. -// 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 __BOOST_NETWORK_TRAITS_HEADERS_CONTAINER_INC__ -# define __BOOST_NETWORK_TRAITS_HEADERS_CONTAINER_INC__ - -# include -# include -# include - -namespace boost { namespace network { - - template - struct headers_container { - typedef std::multimap< - typename string::type, - typename string::type - > type; - }; - -} // namespace network -} // namespace boost - - -#endif // __BOOST_NETWORK_TRAITS_HEADERS_CONTAINER_INC__ diff --git a/boost/network/traits/istream.hpp b/boost/network/traits/istream.hpp deleted file mode 100644 index 7f50bb291..000000000 --- a/boost/network/traits/istream.hpp +++ /dev/null @@ -1,42 +0,0 @@ - -#ifndef BOOST_NETWORK_TRAITS_ISTREAM_HPP_20100924 -#define BOOST_NETWORK_TRAITS_ISTREAM_HPP_20100924 - -// Copyright 2010 (C) Dean Michael Berris -// 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) - -#include -#include -#include -#include - -namespace boost { namespace network { - - template - struct unsupported_tag; - - template - struct istream - { - typedef unsupported_tag type; - }; - - template - struct istream >::type> - { - typedef std::istream type; - }; - - template - struct istream >::type> - { - typedef std::wistream type; - }; - -} /* network */ - -} /* boost */ - -#endif /* BOOST_NETWORK_TRAITS_ISTREAM_HPP_20100924 */ diff --git a/boost/network/traits/istringstream.hpp b/boost/network/traits/istringstream.hpp deleted file mode 100644 index 776385b2a..000000000 --- a/boost/network/traits/istringstream.hpp +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) Glyn Matthews 2009. -// Copyright (c) Dean Michael Berris 2009. -// 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 BOOST_NETWORK_TRAITS_ISTRINGSTREAM_INC -# define BOOST_NETWORK_TRAITS_ISTRINGSTREAM_INC - -# include -# include -#include -#include - -namespace boost { namespace network { - - template - struct unsupported_tag; - - template - struct istringstream - { - typedef unsupported_tag type; - }; - - template - struct istringstream >::type> - { - typedef std::istringstream type; - }; - - template - struct istringstream >::type> - { - typedef std::basic_istringstream type; - }; - -} // namespace network - -} // namespace boost - - -#endif // BOOST_NETWORK_TRAITS_ISTRINGSTREAM_INC - diff --git a/boost/network/traits/ostream_iterator.hpp b/boost/network/traits/ostream_iterator.hpp deleted file mode 100644 index 1f40a7129..000000000 --- a/boost/network/traits/ostream_iterator.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef BOOST_NETWORK_TRAITS_OSTREAM_ITERATOR_HPP_20100815 -#define BOOST_NETWORK_TRAITS_OSTREAM_ITERATOR_HPP_20100815 - -// Copyright 2010 (C) Dean Michael Berris -// 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) - -#include -#include -#include -#include - -namespace boost { namespace network { - - template - struct unsupported_tag; - - template - struct ostream_iterator; - - template - struct ostream_iterator : mpl::if_< - is_default_string, - std::ostream_iterator, - typename mpl::if_< - is_default_wstring, - std::ostream_iterator, - unsupported_tag - >::type - > {}; - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_TRAITS_OSTREAM_ITERATOR_HPP_20100815 diff --git a/boost/network/traits/ostringstream.hpp b/boost/network/traits/ostringstream.hpp deleted file mode 100644 index 58e09a638..000000000 --- a/boost/network/traits/ostringstream.hpp +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) Glyn Matthews 2009. -// Copyright (c) Dean Michael Berris 2009, 2010. -// 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 BOOST_NETWORK_TRAITS_OSTRINGSTREAM_INC -# define BOOST_NETWORK_TRAITS_OSTRINGSTREAM_INC - -# include -# include -# include -# include -# include - -namespace boost { namespace network { - - template - struct unsupported_tag; - - template - struct ostringstream - { - typedef unsupported_tag type; - }; - - template - struct ostringstream >::type> - { - typedef std::ostringstream type; - }; - - template - struct ostringstream >::type> - { - typedef std::wostringstream type; - }; - -} // namespace network - -} // namespace boost - - -#endif // BOOST_NETWORK_TRAITS_OSTRINGSTREAM_INC diff --git a/boost/network/traits/string.hpp b/boost/network/traits/string.hpp deleted file mode 100644 index 92cd88e6d..000000000 --- a/boost/network/traits/string.hpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) Dean Michael Berris 2008, 2009. -// Glyn Matthews 2009. -// 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 BOOST_NETWORK_TRAITS_STRING_INC -#define BOOST_NETWORK_TRAITS_STRING_INC - -# include -# include -# include -# include - -#ifndef BOOST_NETWORK_DEFAULT_STRING -#define BOOST_NETWORK_DEFAULT_STRING std::string -#endif - -#ifndef BOOST_NETWORK_DEFAULT_WSTRING -#define BOOST_NETWORK_DEFAULT_WSTRING std::wstring -#endif - -namespace boost { namespace network { - - template - struct unsupported_tag; - - template - struct string - { - typedef unsupported_tag type; - }; - - template - struct string >::type> - { - typedef BOOST_NETWORK_DEFAULT_STRING type; - }; - - template - struct string >::type> - { - typedef BOOST_NETWORK_DEFAULT_WSTRING type; - }; - -} // namespace network - -} // namespace boost - - -#endif // BOOST_NETWORK_TRAITS_STRING_INC diff --git a/boost/network/traits/vector.hpp b/boost/network/traits/vector.hpp deleted file mode 100644 index 210a13c68..000000000 --- a/boost/network/traits/vector.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Dean Michael Berris 2008, 2009. -// 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 BOOST_NETWORK_TRAITS_VECTOR_HPP -#define BOOST_NETWORK_TRAITS_VECTOR_HPP - -#include -#include - -namespace boost { namespace network { - - template - struct unsupported_tag; - - template - struct vector { - - template - struct apply : - mpl::if_< - is_default_string - , std::vector - , unsupported_tag - > - {}; - - }; - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_TRAITS_VECTOR_HPP - diff --git a/boost/network/uri/uri.hpp b/boost/network/uri/uri.hpp index 0e5768794..0ddecf0d4 100644 --- a/boost/network/uri/uri.hpp +++ b/boost/network/uri/uri.hpp @@ -8,7 +8,6 @@ # define __BOOST_NETWORK_URI_INC__ -# include # include # include # ifdef BOOST_NETWORK_NO_LIB From 158004fb8d89ed8eae5bf79a42d9fbd4e46accea Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sun, 11 Sep 2011 00:44:38 +1000 Subject: [PATCH 004/196] WIP: Working on wrapper implementations. --- boost/network/message/directives/header.hpp | 94 ++++--------- boost/network/message/wrappers/headers.hpp | 120 ++++++----------- boost/network/message/wrappers/headers.ipp | 69 ++++++++++ boost/network/message_base.hpp | 39 ++++++ .../protocol/http/policies/async_resolver.ipp | 124 ++++++++++++++++++ boost/network/protocol/http/request.ipp | 78 +++++++++++ 6 files changed, 381 insertions(+), 143 deletions(-) create mode 100644 boost/network/message/wrappers/headers.ipp create mode 100644 boost/network/message_base.hpp create mode 100644 boost/network/protocol/http/policies/async_resolver.ipp create mode 100644 boost/network/protocol/http/request.ipp diff --git a/boost/network/message/directives/header.hpp b/boost/network/message/directives/header.hpp index 182d643d3..af3fcf91f 100644 --- a/boost/network/message/directives/header.hpp +++ b/boost/network/message/directives/header.hpp @@ -1,82 +1,44 @@ - -// Copyright Dean Michael Berris 2007-2010. -// 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 __NETWORK_MESSAGE_DIRECTIVES_HEADER_HPP__ #define __NETWORK_MESSAGE_DIRECTIVES_HEADER_HPP__ -#include -#include -#include -#include -#include -#include - -namespace boost { namespace network { - - namespace impl { +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) - template - struct header_directive { +#include - explicit header_directive(KeyType const & header_name, - ValueType const & header_value) : - _header_name(header_name), - _header_value(header_value) - { }; +namespace boost { namespace network { - template - struct pod_directive { - template - static void eval(Message const & message, T1 const & key, T2 const & value) { - typedef typename Message::headers_container_type::value_type value_type; - value_type value_ = { key, value }; - message.headers.insert(message.headers.end(), value_); - } - }; +namespace impl { - template - struct normal_directive { - template - static void eval(Message const & message, T1 const & key, T2 const & value) { - typedef typename Message::headers_container_type::value_type value_type; - message.add_header(value_type(key, value)); - } - }; +template +struct header_directive { - template - struct directive_impl : - mpl::if_< - is_base_of< - tags::pod, - typename Message::tag - >, - pod_directive, - normal_directive - >::type - {}; + explicit header_directive(KeyType const & header_name, + ValueType const & header_value) : + _header_name(header_name), + _header_value(header_value) + { }; - template - void operator() (Message const & msg) const { - typedef typename Message::headers_container_type::value_type value_type; - directive_impl::eval(msg, _header_name, _header_value); - } + void operator() (message_base & msg) const { + msg.append_header(_header_name, _header_value); + } - private: + private: - KeyType const & _header_name; - ValueType const & _header_value; - }; + KeyType const & _header_name; + ValueType const & _header_value; +}; - } // namespace impl +} // namespace impl - template - inline impl::header_directive - header(T1 const & header_name, T2 const & header_value) { - return impl::header_directive(header_name, header_value); - } +template +inline impl::header_directive +header(T1 const & header_name, T2 const & header_value) { + return impl::header_directive(header_name, header_value); +} } // namespace network } // namespace boost diff --git a/boost/network/message/wrappers/headers.hpp b/boost/network/message/wrappers/headers.hpp index ce2e0bf25..93f3ba68a 100644 --- a/boost/network/message/wrappers/headers.hpp +++ b/boost/network/message/wrappers/headers.hpp @@ -13,87 +13,53 @@ namespace boost { namespace network { - /// Template metaprogram to get the range type for a message - template - struct headers_range { - typedef typename headers_container::type headers_container_type; - typedef typename - boost::iterator_range - type; - }; - - template - struct basic_message; - - /** headers wrapper for messages. - * - * This exposes an interface similar to a map, indexable - * using operator[] taking a string as the index and returns - * a range of iterators (std::pair) - * whose keys are all equal to the index string. - * - * This type is also convertible to a - * headers_range >::type - * Which allows for full range support. - * - * The type is also convertible to a - * headers_container::type - * Which copies the headers from the wrapped message. - * - */ - namespace impl { - template - struct headers_wrapper : public detail::wrapper_base_const > { - typedef Tag tag; - typedef basic_message message_type; - typedef typename string::type string_type; - typedef typename headers_range::type range_type; - typedef typename headers_container::type headers_container_type; - typedef typename headers_container_type::const_iterator const_iterator; - typedef typename headers_container_type::iterator iterator; - typedef detail::wrapper_base_const > wrapper_base; - - explicit headers_wrapper(basic_message const & message_) - : wrapper_base(message_) - { }; - - range_type operator[] (string_type const & key) const { - return headers_wrapper::_message.headers().equal_range(key); - }; - - typename message_type::headers_container_type::size_type count(string_type const & key) const { - return headers_wrapper::_message.headers().count(key); - }; - - const_iterator begin() const { - return headers_wrapper::_message.headers().begin(); - }; - - const_iterator end() const { - return headers_wrapper::_message.headers().end(); - }; - - operator range_type () { - return make_iterator_range(headers_wrapper::_message.headers().begin(), headers_wrapper::_message.headers().end()); - }; - - operator headers_container_type () { - return headers_wrapper::_message.headers(); - } - - }; - } // namespace impl - - /// Factory method to create the right wrapper object - template - inline impl::headers_wrapper - headers(basic_message const & message_) { - return impl::headers_wrapper(message_); - } +namespace impl { + +/** headers wrapper for messages. + * + * This exposes an interface similar to a map, indexable + * using operator[] taking a string as the index and returns + * a range of iterators (std::pair) + * whose keys are all equal to the index string. + * + * This type is also convertible to a + * headers_range >::type + * Which allows for full range support. + * + * The type is also convertible to a + * headers_container::type + * Which copies the headers from the wrapped message. + * + */ +struct headers_wrapper { + typedef std::multimap container_type; + typedef shared_container_iterator iterator; + typedef iterator_range > + range_type; + + explicit headers_wrapper(message_base & message); + range_type operator[] (std::string const & key) const; + container_type::size_type count() const; + private: + void init_cache_all(); + mutable shared_ptr cache_; +}; + +} // namespace impl + +/// Factory method to create the right wrapper object +inline impl::headers_wrapper +headers(message_base & message_) { + return impl::headers_wrapper(message_); +} } // namespace network } // namespace boost +#ifdef BOOST_NETWORK_NO_LIB +#include +#endif + #endif // __NETWORK_MESSAGE_WRAPPERS_HEADERS_HPP__ diff --git a/boost/network/message/wrappers/headers.ipp b/boost/network/message/wrappers/headers.ipp new file mode 100644 index 000000000..b2afc7751 --- /dev/null +++ b/boost/network/message/wrappers/headers.ipp @@ -0,0 +1,69 @@ +#ifndef BOOST_NETWORK_MESSAGE_WRAPPERS_HEADERS_IPP_20110911 +#define BOOST_NETWORK_MESSAGE_WRAPPERS_HEADERS_IPP_20110911 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include + +namespace boost { namespace network { + +headers_wrapper::headers_wrapper(message_base & message) +: message_(message) +{} + +range_type headers_wrapper::operator[] (std::string const & key) const { + cache_.reset(new (std::nothrow) container_type); + if (!cache_.get()) + BOOST_THROW_EXCEPTION(std::runtime_error( + "Cannot allocate cache multimap for headers wrapper.")); + message_.get_headers( + key, + std::inserter(*cache_, cache_->end())); + return make_shared_container_range(cache_); +} + +headers_wrapper::container_type::size_type +headers_wrapper::count(string_type const & key) const { + this->init_cache_all(); + return cache_->size(); +} + +headers_wrapper::iterator headers_wrapper::begin() const { + this->init_cache_all(); + return make_shared_container_iterator(cache_->begin()); +} + +headers_wrapper::iterator headers_wrapper::end() const { + this->init_cache_all(); + return make_shared_container_iterator(cache_->end()); +}; + +headers_wrapper::operator headers_wrapper::range_type () { + this->init_cache_all(); + return make_shared_container_range(cache_); +}; + +headers_wrapper::operator headers_wrapper::container_type () { + this->init_cache_all(); + return *cache_; +} + +void headers_wrapper::init_cache_all() { + if (!cache_.get()) { + cache_.reset(new (std::nothrow) container_type); + if (!cache_.get()) + BOOST_THROW_EXCEPTION(std::runtime_error( + "Cannot allocate cache multimap for headers wrapper.")); + message_.get_headers(std::inserter(*cache_, cache_->end())); + } +} + +} /* network */ + +} /* boost */ + +#endif /* BOOST_NETWORK_MESSAGE_WRAPPERS_HEADERS_IPP_20110911 */ diff --git a/boost/network/message_base.hpp b/boost/network/message_base.hpp new file mode 100644 index 000000000..3dff437e5 --- /dev/null +++ b/boost/network/message_base.hpp @@ -0,0 +1,39 @@ +#ifndef BOOST_NETWORK_MESSAGE_BASE_HPP_20110910 +#define BOOST_NETWORK_MESSAGE_BASE_HPP_20110910 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +namespace boost { namespace network { + +struct message_base { + // Mutators + virtual void set_destination(std::string const & destination) = 0; + virtual void set_source(std::string const & source) = 0; + virtual void append_header(std::string const & name, + std::string const & value) = 0; + virtual void remove_headers(std::string const & name) = 0; + virtual void set_body(std::string const & body) = 0; + virtual void append_body(std::string const & data) = 0; + + // Retrievers + virtual void get_destination(std::string & destination) = 0; + virtual void get_source(std::string & source) = 0; + virtual void get_headers(function inserter) = 0; + virtual void get_headers(std::string const & name, function inserter) = 0; + virtual void get_headers(function predicate, function inserter) = 0; + virtual void get_body(std::string const & body) = 0; + virtual void get_body(function)> chunk_reader, size_t size) = 0; + + // Destructor + virtual ~message_base() = 0; // pure virtual +}; + +} /* network */ + +} /* boost */ + +#endif /* BOOST_NETWORK_MESSAGE_BASE_HPP_20110910 */ diff --git a/boost/network/protocol/http/policies/async_resolver.ipp b/boost/network/protocol/http/policies/async_resolver.ipp new file mode 100644 index 000000000..d7082efad --- /dev/null +++ b/boost/network/protocol/http/policies/async_resolver.ipp @@ -0,0 +1,124 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_POLICIES_ASYNC_RESOLVER_IPP_20110910 +#define BOOST_NETWORK_PROTOCOL_HTTP_POLICIES_ASYNC_RESOLVER_IPP_20110910 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace network { namespace http { + +async_resolver::async_resolver(asio::io_service & service) +: pimpl(new (std::nothrow) async_resolver_pimpl(service)) +{} + +void async_resolver::resolve(std::string const & host, + uint16_t port, + resolve_completion_function once_resolved) { + BOOST_ASSERT(pimpl.get() && "Uninitialized pimpl, probably ran out of memory."); + pimpl->resolve(host, port, once_resolved); +} + +void async_resolver::clear_resolved_cache() { + BOOST_ASSERT(pimpl.get() && "Uninitialized pimpl, probably ran out of memory."); + pimpl->clear_resolved_cache(); +} + +async_resolver::~async_resolver() { + // Do nothing +} + +struct async_resolver_pimpl : enable_shared_from_this { + explicit async_resolver_pimpl(asio::io_service & service); + void resolve(std::string const & host, + uint16_t port, + resolve_completion_function once_resolved); + void clear_resolved_cache(); + private: + asio::ip::udp::resolver resolver_; + bool cache_resolved_; + typedef asio::ip::udp::resolver::iterator + resolver_iterator; + typedef unordered_map > + endpoint_cache; + endpoint_cache endpoint_cache_; + scoped_ptr resolver_strand_; +}; + +async_resolver_pimpl::async_resolver_pimpl(asio::io_service & service) + : resolver_(service), + cache_resolved(cache_resolved), + endpoint_cache_(), + resolver_strand_(new(std::nothrow) asio::io_service::strand(service)) +{ + // Do nothing +} + +void async_resolver_pimpl::resolve(std::string const & host, + boost::uint16_t port, + resolve_completion_function once_resolved) { + if (!resolver_strand_.get()) + BOOST_THROW_EXCEPTION(std::runtime_error( + "Uninitialized resolver strand, ran out of memory.")); + + if (cache_resolved_) { + endpoint_cache::iterator iter = + endpoint_cache_.find(boost::to_lower_copy(host)); + if (iter != endpoint_cache_.end()) { + boost::system::error_code ignored; + once_resolved(ignored, iter->second); + return; + } + } + + std::string port_str = lexical_cast(port); + asio::ip::udp::resolver::query query(host, port_str); + resolver_.async_resolve( + query, + resolver_strand_->wrap( + boost::bind( + &async_resolver_pimpl::handle_resolve, + async_resolver_pimpl::shared_from_this(), + boost::to_lower_copy(host), + once_resolved, + boost::asio::placeholders::error, + boost::asio::placeholders::iterator))); +} + +void handle_resolve(std::string const & host, + resolve_completion_function once_resolved, + boost::system::error_code const & ec, + resolver_iterator endpoint_iterator) { + endpoint_cache::iterator iter; + bool inserted = false; + if (!ec && cache_resolved_) { + boost::fusion::tie(iter, inserted) = + endpoint_cache_.insert( + std::make_pair(host, + std::make_pair(endpoint_iterator, + resolver_iterator()))); + once_resolved(ec, iter->second); + } else { + once_resolved(ec, std::make_pair(endpoint_iterator,resolver_iterator())); + } +} + +} /* http */ + +} /* network */ + +} /* boost */ + + +#endif /* BOOST_NETWORK_PROTOCOL_HTTP_POLICIES_ASYNC_RESOLVER_IPP_20110910 */ diff --git a/boost/network/protocol/http/request.ipp b/boost/network/protocol/http/request.ipp new file mode 100644 index 000000000..55e2d9fca --- /dev/null +++ b/boost/network/protocol/http/request.ipp @@ -0,0 +1,78 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_IPP_20110910 +#define BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_IPP_20110910 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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 BOOST_NETWORK_BUFFER_CHUNK +#define BOOST_NETWORK_BUFFER_CHUNK 1024 // We want 1KiB worth of data at least. +#endif + +namespace boost { namespace network { namespace http { + +struct body_source : iostreams::source { + virtual std::streamsize read(char * buffer, std::streamsize size); + virtual ~body_source(); +}; + +struct request_storage_base { + typedef iostreams::stream body_stream; + protected: + // TODO Implement a segmented storage base which efficiently supports + // efficient memory usage that makes sense for HTTP payload. The idea is + // to expose the internal (segmented) storage to the client implementation + // so that raw buffers of formatted HTTP request data (which may or may not + // support delegated streams from user input -- i.e. for the body contents) + // can be efficiently sent out to the wire. This also implies that all + // thread-safety guarantees are handled by the storage base as well. + request_storage_base(size_t hint = BOOST_NETWORK_BUFFER_CHUNK); + virtual void set_status_line(std::string const &status_line); + virtual void append_header(std::string const &name, std::string const &value); +}; + +struct request_base : request_storage_base { + protected: + using request_storage_base::body_stream; + request_base(); + // Setters + virtual void set_method(std::string const & method); + virtual void set_status(std::string const & status); + virtual void set_status_message(std::string const & status_message); + virtual void append_header(std::string const &name, std::string const &value); + virtual void set_body_stream(shared_ptr stream); + + // Getters + virtual void get_method(std::string & method); + virtual void get_status(std::string & status); + virtual void get_status_message(std::string & status_message); + virtual void get_headers(function +struct basic_request : request_base { + basic_request(); + basic_request(basic_request const &); // valid copy constructor + // TODO implement a conditional move constructor + basic_request & operator=(basic_request); // valid assigment operator + String const method(); + void method(String const &); + + String const status(); + void status(String const &); + + std::multimap const & headers(); + + String const body(); + body_stream & body_stream(); +}; + + +#endif /* BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_IPP_20110910 */ From 7a009269d7a85ff50617d5de01c29d4163c4c500 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sun, 11 Sep 2011 01:14:58 +1000 Subject: [PATCH 005/196] WIP: Converted all modifiers and wrappers to use message_base interface. --- .../network/message/modifiers/add_header.hpp | 50 +------- boost/network/message/modifiers/body.hpp | 21 +--- .../message/modifiers/clear_headers.hpp | 51 +------- .../network/message/modifiers/destination.hpp | 26 +--- .../message/modifiers/remove_header.hpp | 70 +---------- boost/network/message/modifiers/source.hpp | 21 +--- boost/network/message/wrappers/body.hpp | 114 +++++------------- .../network/message/wrappers/destination.hpp | 53 ++++---- boost/network/message/wrappers/headers.hpp | 2 + boost/network/message/wrappers/source.hpp | 54 ++++----- boost/network/message_base.hpp | 4 + 11 files changed, 113 insertions(+), 353 deletions(-) diff --git a/boost/network/message/modifiers/add_header.hpp b/boost/network/message/modifiers/add_header.hpp index c93fe2edb..baeddb6d9 100644 --- a/boost/network/message/modifiers/add_header.hpp +++ b/boost/network/message/modifiers/add_header.hpp @@ -1,8 +1,8 @@ - #ifndef BOOST_NETWORK_MESSAGE_MODIFIER_ADD_HEADER_HPP_20100824 #define BOOST_NETWORK_MESSAGE_MODIFIER_ADD_HEADER_HPP_20100824 -// Copyright 2010 (c) Dean Michael Berris +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. // 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) @@ -13,48 +13,10 @@ namespace boost { namespace network { - namespace impl { - template - inline typename enable_if< - mpl::and_< - mpl::not_ > - , mpl::not_ > - > - , void - >::type - add_header(Message & message, KeyType const & key, ValueType const & value, Tag) { - message.headers().insert(std::make_pair(key, value)); - } - - template - inline typename enable_if< - mpl::and_< - mpl::not_ > - , is_async - > - , void - >::type - add_header(Message & message, KeyType const & key, ValueType const & value, Tag) { - typedef typename Message::header_type header_type; - message.add_header(header_type(key,value)); - } - - template - inline typename enable_if< - is_pod - , void - >::type - add_header(Message & message, KeyType const & key, ValueType const & value, Tag) { - typename Message::header_type header = { key, value }; - message.headers.insert(message.headers.end(), header); - } - - } - - template class Message, class KeyType, class ValueType> - inline void add_header(Message & message, KeyType const & key, ValueType const & value) { - impl::add_header(message, key, value, Tag()); - } +inline +void add_header(message_base & message, std::string const & key, std::string const & value) { + message.append_header(key, value); +} } // namespace network diff --git a/boost/network/message/modifiers/body.hpp b/boost/network/message/modifiers/body.hpp index f9b595818..fcd5b1422 100644 --- a/boost/network/message/modifiers/body.hpp +++ b/boost/network/message/modifiers/body.hpp @@ -6,24 +6,15 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include - namespace boost { namespace network { - template class Message, class ValueType> - inline void body_impl(Message & message, ValueType const & body, tags::pod) { - message.body = body; - } - - template class Message, class ValueType> - inline void body_impl(Message & message, ValueType const & body, tags::normal) { - message.body(body); - } +inline void body(message_base & message, std::string const & body_) { + message.set_body(body_); +} - template class Message, class ValueType> - inline void body(Message & message, ValueType const & body_) { - body_impl(message, body_, typename pod_or_normal::type()); - } +inline void append_body(message_base & message, std::string const & data) { + message.append_body(data); +} } // namespace network diff --git a/boost/network/message/modifiers/clear_headers.hpp b/boost/network/message/modifiers/clear_headers.hpp index a983b695a..077337e7c 100644 --- a/boost/network/message/modifiers/clear_headers.hpp +++ b/boost/network/message/modifiers/clear_headers.hpp @@ -1,58 +1,19 @@ #ifndef BOOST_NETWORK_MESSAGE_MODIFIER_CLEAR_HEADERS_HPP_20100824 #define BOOST_NETWORK_MESSAGE_MODIFIER_CLEAR_HEADERS_HPP_20100824 -// Copyright 2010 (c) Dean Michael Berris +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. // 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) -#include -#include -#include -#include +#include namespace boost { namespace network { - namespace impl { - template - inline typename enable_if< - mpl::and_< - mpl::not_ > - , mpl::not_ > - > - , void - >::type - clear_headers(Message const & message, Tag const &) { - (typename Message::headers_container_type()).swap(message.headers()); - } - - template - inline typename enable_if, void>::type - clear_headers(Message const & message, Tag const &) { - (typename Message::headers_container_type()).swap(message.headers); - } - - template - inline typename enable_if< - mpl::and_< - mpl::not_ > - , is_async - > - , void - >::type - clear_headers(Message const & message, Tag const &) { - boost::promise header_promise; - boost::shared_future headers_future(header_promise.get_future()); - message.headers(headers_future); - header_promise.set_value(typename Message::headers_container_type()); - } - - } // namespace impl - - template class Message> - inline void clear_headers(Message const & message) { - impl::clear_headers(message, Tag()); - } +inline void clear_headers(message_base & message) { + message.remove_headers(); +} } // namespace network diff --git a/boost/network/message/modifiers/destination.hpp b/boost/network/message/modifiers/destination.hpp index 8ff362e08..5704bd008 100644 --- a/boost/network/message/modifiers/destination.hpp +++ b/boost/network/message/modifiers/destination.hpp @@ -2,33 +2,17 @@ #ifndef BOOST_NETWORK_MESSAGE_MODIFIER_DESTINATION_HPP_20100824 #define BOOST_NETWORK_MESSAGE_MODIFIER_DESTINATION_HPP_20100824 -// Copyright 2010 (c) Dean Michael Berris +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. // 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) -#include - namespace boost { namespace network { - namespace impl { - - template - inline void destination(Message const & message, ValueType const & destination_, Tag const &, mpl::false_ const &){ - message.destination(destination_); - } - - template - inline void destination(Message const & message, ValueType const & destination_, Tag const &, mpl::true_ const &) { - message.destination(destination_); - } - - } - - template class Message, class ValueType> - inline void destination(Message const & message, ValueType const & destination_) { - impl::destination(message, destination_, Tag(), is_async()); - } +inline void destination(message_base & message, std::string const & destination_) { + message.set_destination(destination_); +} } // namespace network diff --git a/boost/network/message/modifiers/remove_header.hpp b/boost/network/message/modifiers/remove_header.hpp index e7b098875..fbbc12170 100644 --- a/boost/network/message/modifiers/remove_header.hpp +++ b/boost/network/message/modifiers/remove_header.hpp @@ -7,73 +7,15 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include -#include -#include +#include +#include namespace boost { namespace network { - namespace impl { - - template - inline typename enable_if< - mpl::and_< - mpl::not_ > - , mpl::not_ > - > - , void - >::type - remove_header(Message & message, KeyType const & key, Tag) { - message.headers().erase(key); - } - - template - inline typename enable_if< - mpl::and_< - mpl::not_ > - , is_async - > - , void - >::type - remove_header(Message & message, KeyType const & key, Tag) { - message.remove_header(key); - } - - template - struct iequals_pred { - KeyType const & key; - iequals_pred(KeyType const & key) - : key(key) {} - template - bool operator()(Header & other) const { - return boost::iequals(key, name(other)); - } - }; - - template - inline typename enable_if< - is_pod - , void - >::type - remove_header(Message & message, KeyType const & key, Tag) { - typedef typename Message::headers_container_type headers; - message.headers.erase( - boost::remove_if( - message.headers, - iequals_pred(key) - ) - , message.headers.end() - ); - } - - - } // namespace impl - - template class Message, class KeyType> - inline void remove_header(Message & message, KeyType const & key) { - impl::remove_header(message, key, Tag()); - } +inline +void remove_header(message_base & message, std::string const & key) { + message.remove_headers(key); +} } // namespace network diff --git a/boost/network/message/modifiers/source.hpp b/boost/network/message/modifiers/source.hpp index 11acb9071..f39131181 100644 --- a/boost/network/message/modifiers/source.hpp +++ b/boost/network/message/modifiers/source.hpp @@ -9,24 +9,9 @@ namespace boost { namespace network { - namespace impl { - - template - inline void source(Message const & message, ValueType const & source_, Tag const &, mpl::false_ const &) { - message.source(source_); - } - - template - inline void source(Message const & message, ValueType const & source_, Tag const &, mpl::true_ const &) { - message.source(source_); - } - - } // namespace impl - - template class Message, class ValueType> - inline void source(Message const & message, ValueType const & source_) { - impl::source(message, source_, Tag(), is_async()); - } +inline void source(message_base & message, std::string const & source_) { + message.set_source(source_); +} } // namespace network diff --git a/boost/network/message/wrappers/body.hpp b/boost/network/message/wrappers/body.hpp index b2199eca7..b5c89aa1a 100644 --- a/boost/network/message/wrappers/body.hpp +++ b/boost/network/message/wrappers/body.hpp @@ -7,105 +7,45 @@ #ifndef __NETWORK_MESSAGE_WRAPPERS_BODY_HPP__ #define __NETWORK_MESSAGE_WRAPPERS_BODY_HPP__ -#include #include +#include +#include namespace boost { namespace network { - template - struct body_range { - typedef typename boost::iterator_range type; - }; +namespace impl { - namespace impl { - template - struct body_wrapper : public detail::wrapper_base > { - typedef basic_message message_type; - typedef typename string::type string_type; - typedef detail::wrapper_base > wrapper_base; - - explicit body_wrapper(basic_message & message_) - : wrapper_base(message_) - { }; +struct body_wrapper { + explicit body_wrapper(message_base & message_); + operator std::string () const; + std::size_t size() const; + operator iterator_range () const; + std::string::const_iterator begin() const; + std::string::const_iterator end() const; + private: + message_base & message_; + mutable optional cache_; +}; - operator string_type () const { - return string_type(wrapper_base::_message.body()); - }; +inline std::ostream & operator<<(std::ostream & os, body_wrapper const & body) { + os << static_cast(body); + return os; +} - std::size_t size() const { - return wrapper_base::_message.body().size(); - } +} // namespace impl - operator boost::iterator_range< - typename boost::range_iterator::type - > () const { - return boost::make_iterator_range(wrapper_base::_message.body()); - } - - typename string_type::const_iterator - begin() const { - return wrapper_base::_message.body().begin(); - } - - typename string_type::const_iterator - end() const { - return wrapper_base::_message.body().end(); - } - - }; - - template - struct body_wrapper_const : public detail::wrapper_base_const > { - typedef basic_message message_type; - typedef typename string::type string_type; - typedef detail::wrapper_base_const > wrapper_base; - - explicit body_wrapper_const(basic_message const & message_) - : wrapper_base(message_) - {}; - - operator string_type () const { - return string_type(wrapper_base::_message.body()); - } - - std::size_t size() const { - return wrapper_base::_message.body().size(); - } - - operator boost::range_iterator () const { - return boost::make_iterator_range(wrapper_base::_message.body()); - } - }; - - template - inline std::ostream & operator<<(std::ostream & os, body_wrapper const & body) { - os << static_cast::string_type>(body); - return os; - } - - template - inline std::ostream & operator<<(std::ostream & os, body_wrapper_const const & body) { - os << static_cast::string_type>(body); - return os; - } - - } // namespace impl - - template - inline impl::body_wrapper const - body(basic_message & message_) { - return impl::body_wrapper(message_); - } - - template - inline impl::body_wrapper_const const - body(basic_message const & message_) { - return impl::body_wrapper_const(message_); - } +inline impl::body_wrapper const +body(message_base & message_) { + return impl::body_wrapper(message_); +} } // namespace network } // namespace boost +#ifdef BOOST_NETWORK_NO_LIB +#include +#endif + #endif // __NETWORK_MESSAGE_WRAPPERS_BODY_HPP__ diff --git a/boost/network/message/wrappers/destination.hpp b/boost/network/message/wrappers/destination.hpp index f1c485269..f4e94764e 100644 --- a/boost/network/message/wrappers/destination.hpp +++ b/boost/network/message/wrappers/destination.hpp @@ -1,42 +1,37 @@ - -// Copyright Dean Michael Berris 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 __NETWORK_MESSAGE_WRAPPERS_DESTINATION_HPP__ #define __NETWORK_MESSAGE_WRAPPERS_DESTINATION_HPP__ +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include namespace boost { namespace network { - namespace impl { - template - struct destination_wrapper : public detail::wrapper_base > { - typedef Tag tag; - typedef basic_message message_type; - typedef typename string::type string_type; - typedef detail::wrapper_base > wrapper_base; - - explicit destination_wrapper(message_type & message_) - : wrapper_base(message_) - { }; - - operator string_type () const { - return string_type(wrapper_base::_message.destination()); - }; - }; - } // namespace impl - - template - inline typename string::type - destination(basic_message & message_) { - return impl::destination_wrapper(message_); - } +namespace impl { + +struct destination_wrapper { + explicit destination_wrapper(message_base & message_); + operator std::string () const; +}; + +} // namespace impl + +inline std::string const +destination(message_base & message_) { + return impl::destination_wrapper(message_); +} } // namespace network } // namespace boost +#ifdef BOOST_NETWORK_NO_LIB +#include +#endif + #endif // __NETWORK_MESSAGE_WRAPPERS_DESTINATION_HPP__ diff --git a/boost/network/message/wrappers/headers.hpp b/boost/network/message/wrappers/headers.hpp index 93f3ba68a..5c217ddca 100644 --- a/boost/network/message/wrappers/headers.hpp +++ b/boost/network/message/wrappers/headers.hpp @@ -7,6 +7,8 @@ #ifndef __NETWORK_MESSAGE_WRAPPERS_HEADERS_HPP__ #define __NETWORK_MESSAGE_WRAPPERS_HEADERS_HPP__ +#include +#include #include #include #include diff --git a/boost/network/message/wrappers/source.hpp b/boost/network/message/wrappers/source.hpp index 378e80628..8a139de17 100644 --- a/boost/network/message/wrappers/source.hpp +++ b/boost/network/message/wrappers/source.hpp @@ -1,42 +1,36 @@ +#ifndef __NETWORK_MESSAGE_WRAPPERS_SOURCE_HPP__ +#define __NETWORK_MESSAGE_WRAPPERS_SOURCE_HPP__ -// Copyright Dean Michael Berris 2007. +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) -#ifndef __NETWORK_MESSAGE_WRAPPERS_SOURCE_HPP__ -#define __NETWORK_MESSAGE_WRAPPERS_SOURCE_HPP__ +#include namespace boost { namespace network { - namespace impl { - template - struct source_wrapper : public detail::wrapper_base > { - typedef Tag tag; - typedef basic_message message_type; - typedef typename string::type string_type; - typedef detail::wrapper_base > wrapper_base; - - explicit source_wrapper(basic_message & message_) - : wrapper_base(message_) - { }; - - operator string_type () const { - return string_type(wrapper_base::_message.source()); - }; - }; - } // namespace impl - - template - inline typename string::type - source(basic_message & message_) { - return impl::source_wrapper(message_); - } +namespace impl { + +struct source_wrapper { + explicit source_wrapper(message_base & message_); + operator std::string () const; +}; + +} // namespace impl + +inline std::string const +source(message_base & message_) { + return impl::source_wrapper(message_); +} } // namespace network } // namespace boost -#endif // __NETWORK_MESSAGE_WRAPPERS_SOURCE_HPP__ - +#ifdef BOOST_NETWORK_NO_LIB +#include +#endif +#endif // __NETWORK_MESSAGE_WRAPPERS_SOURCE_HPP__ diff --git a/boost/network/message_base.hpp b/boost/network/message_base.hpp index 3dff437e5..c96a666bc 100644 --- a/boost/network/message_base.hpp +++ b/boost/network/message_base.hpp @@ -7,6 +7,9 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#include +#include + namespace boost { namespace network { struct message_base { @@ -16,6 +19,7 @@ struct message_base { virtual void append_header(std::string const & name, std::string const & value) = 0; virtual void remove_headers(std::string const & name) = 0; + virtual void remove_headers() = 0; virtual void set_body(std::string const & body) = 0; virtual void append_body(std::string const & data) = 0; From 6c3696feb856309eca59263ac2906a09dd5a9f3f Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sun, 11 Sep 2011 09:39:47 -0700 Subject: [PATCH 006/196] More Gutting. The direction this commit takes is to have the message type more expansive and transition the interface to a more object-oriented design that still adheres to the generic programming interfaces. Note, the builds still aren't complete. This is a WIP commit. --- boost/network/message.hpp | 84 ++++++------- boost/network/message/basic_message.hpp | 52 ++++++++ boost/network/message/basic_message.ipp | 112 ++++++++++++++++++ boost/network/message/message_concept.hpp | 16 +-- boost/network/message/traits/body.hpp | 46 ------- boost/network/message/traits/destination.hpp | 45 ------- boost/network/message/traits/headers.hpp | 62 ---------- boost/network/message/traits/source.hpp | 45 ------- .../protocol/http/message/traits/status.hpp | 38 ------ .../http/message/traits/status_message.hpp | 40 ------- .../protocol/http/message/traits/version.hpp | 51 -------- boost/network/protocol/http/response.hpp | 2 - .../protocol/http/response_concept.hpp | 3 - 13 files changed, 205 insertions(+), 391 deletions(-) create mode 100644 boost/network/message/basic_message.hpp create mode 100644 boost/network/message/basic_message.ipp delete mode 100644 boost/network/message/traits/body.hpp delete mode 100644 boost/network/message/traits/destination.hpp delete mode 100644 boost/network/message/traits/headers.hpp delete mode 100644 boost/network/message/traits/source.hpp delete mode 100644 boost/network/protocol/http/message/traits/status.hpp delete mode 100644 boost/network/protocol/http/message/traits/status_message.hpp delete mode 100644 boost/network/protocol/http/message/traits/version.hpp diff --git a/boost/network/message.hpp b/boost/network/message.hpp index fcddc7e1b..e46a2707c 100644 --- a/boost/network/message.hpp +++ b/boost/network/message.hpp @@ -20,7 +20,11 @@ #include #include +#ifdef BOOST_NETWORK_DEBUG #include +#endif + +#include /** message.hpp * @@ -34,114 +38,98 @@ namespace boost { namespace network { /** The common message type. */ - template - struct basic_message { - public: - - typedef Tag tag; - - typedef typename headers_container::type headers_container_type; - typedef typename headers_container_type::value_type header_type; - typedef typename string::type string_type; + template + struct basic_message : basic_storage_base { + typedef std::pair header_type; + typedef std::multimap headers_container_type; + typedef String string_type; basic_message() - : _headers(), _body(), _source(), _destination() - { } + : basic_storage_base() + {} basic_message(const basic_message & other) - : _headers(other._headers), _body(other._body), _source(other._source), _destination(other._destination) - { } + : basic_storage_base(other) + {} - basic_message & operator=(basic_message rhs) { + basic_message & operator=(basic_message rhs) { rhs.swap(*this); return *this; } - void swap(basic_message & other) { - std::swap(other._headers, _headers); - std::swap(other._body, _body); - std::swap(other._source, _source); - std::swap(other._destination, _destination); + void swap(basic_message & other) { + basic_storage_base & this_ = *this, + & other_ = other; + swap(this_, other_); } headers_container_type & headers() { - return _headers; + return pimpl->headers_; } void headers(headers_container_type const & headers_) const { - _headers = headers_; + pimpl->headers_ = headers_; } void add_header(typename headers_container_type::value_type const & pair_) const { - _headers.insert(pair_); + this->append_header(pair_.first, pair_.second); } void remove_header(typename headers_container_type::key_type const & key) const { - _headers.erase(key); + this->remove_headers(key); } headers_container_type const & headers() const { - return _headers; + return pimpl->headers_; } string_type & body() { - return _body; + return pimpl->body_; } void body(string_type const & body_) const { - _body = body_; + this->set_body(body_); } string_type const & body() const { - return _body; + return pimpl->body_; } string_type & source() { - return _source; + return pimpl->source_; } void source(string_type const & source_) const { - _source = source_; + this->set_source(source_); } string_type const & source() const { - return _source; + return pimpl->source_; } string_type & destination() { - return _destination; + return pimpl->destination_; } void destination(string_type const & destination_) const { - _destination = destination_; + this->set_destination(destination_); } string_type const & destination() const { - return _destination; + return pimpl->destination_; } - - private: - - friend struct detail::directive_base ; - friend struct detail::wrapper_base > ; - - mutable headers_container_type _headers; - mutable string_type _body; - mutable string_type _source; - mutable string_type _destination; }; - template - inline void swap(basic_message & left, basic_message & right) { - // swap for ADL + template + inline void swap(basic_message & left, basic_message & right) { left.swap(right); } // Commenting this out as we don't need to do this anymore. // BOOST_CONCEPT_ASSERT((Message >)); // BOOST_CONCEPT_ASSERT((Message >)); - typedef basic_message message; - typedef basic_message wmessage; + typedef basic_message message; + typedef basic_message wmessage; } // namespace network } // namespace boost diff --git a/boost/network/message/basic_message.hpp b/boost/network/message/basic_message.hpp new file mode 100644 index 000000000..3bf44db93 --- /dev/null +++ b/boost/network/message/basic_message.hpp @@ -0,0 +1,52 @@ +#ifndef BOOST_NETWORK_MESSAGE_BASIC_MESSAGE_HPP_20110911 +#define BOOST_NETWORK_MESSAGE_BASIC_MESSAGE_HPP_20110911 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include +#include + +namespace boost { namespace network { + +struct basic_storage_pimpl; + +struct basic_storage_base : message_base { + basic_storage_base(); + basic_storage_base(basic_storage_base const &); + virtual void set_destination(std::string const & destination); + virtual void set_source(std::string const & source); + virtual void append_header(std::string const & name, + std::string const & value); + virtual void remove_headers(std::string const & name); + virtual void remove_headers(); + virtual void set_body(std::string const & body); + virtual void append_body(std::string const & data); + + virtual void get_destination(std::string & destination); + virtual void get_source(std::string & source); + virtual void get_headers(function inserter); + virtual void get_headers(std::string const & name, function inserter); + virtual void get_body(std::string & body); + virtual void get_body(function)> chunk_reader, size_t size); + + void swap(basic_storage_base & other); + + virtual ~basic_storage_base(); + protected: + scoped_ptr pimpl; +}; + +void swap(basic_storage_base & l, basic_storage_base & r); + +} /* network */ +} /* boost */ + +#ifdef BOOST_NETWORK_NO_LIB +#include +#endif + +#endif /* BOOST_NETWORK_MESSAGE_BASIC_MESSAGE_HPP_20110911 */ diff --git a/boost/network/message/basic_message.ipp b/boost/network/message/basic_message.ipp new file mode 100644 index 000000000..bd9a94d92 --- /dev/null +++ b/boost/network/message/basic_message.ipp @@ -0,0 +1,112 @@ +#ifndef BOOST_NETWORK_MESSAGE_BASIC_MESSAGE_IPP_20110911 +#define BOOST_NETWORK_MESSAGE_BASIC_MESSAGE_IPP_20110911 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +namespace boost { namespace network { + +struct basic_storage_pimpl { + basic_storage_pimpl(); + basic_storage_pimpl(basic_storage_pimpl const &); + + virtual basic_storage_pimpl* clone(); + protected: + friend struct basic_storage_base; + std::string source_, destination_; + typedef std::multimap headers_container_type; + headers_container_type headers_; + std::string body_; +}; + +basic_storage_base::basic_storage_base() +: pimpl(new (std::nothrow) basic_storage_pimpl()) +{} + +basic_storage_base::basic_storage_base(basic_storage_base const & other) +: pimpl(other.clone()) +{} + +void basic_storage_base::set_destination(std::string const & destination) { + pimpl->destination_ = destination; +} + +void basic_storage_base::set_source(std::string const & source) { + pimpl->source_ = source; +} + +void basic_storage_base::append_header(std::string const & name, + std::string const & value) { + pimpl->headers_.insert(std::make_pair(name, value)); +} + +void basic_storage_base::remove_headers(std::string const & name) { + pimpl->headers_.erase(name); +} + +void basic_storage_base::remove_headers() { + basic_storage_pimpl::headers_container_type().swap(pimpl->headers_); +} + +void basic_storage_base::set_body(std::string const & body) { + pimpl->body = body; +} + +void basic_storage_base::append_body(std::string const & data) { + pimpl->body.append(data); +} + +void basic_storage_base::get_destination(std::string & destination) { + destination = pimpl->destination; +} + +void basic_storage_base::get_source(std::string & source) { + source = pimpl->source; +} + +void basic_storage_base::get_headers(function inserter) { + copy(pimpl->headers_, inserter); +} + +void basic_storage_base::get_headers(std::string const & name, function inserter) { + basic_storage_pimpl::headers_container_type::const_iterator + it = pimpl->headers_.find(name), + pe = pimpl->headers_.end(); + for (; it != pe; ++it) + inserter(it->first, it->second); +} + +void basic_storage_base::get_body(std::string & body) { + // TODO use iostreams! + body = pimpl_->body; +} + +void basic_storage_base::get_body(function)> chunk_reader, size_t size) { + // TODO use iostreams! + std::string::const_iterator it = pimpl->body.begin(), + pe = pimpl->body.end(); + std::advance(it, size); + chunk_reader(make_iterator_range(it, pe)); + pimpl->body.assign(it, pe); +} + +basic_storage_base::~basic_storage_base() { + pimpl->reset(); +} + +void basic_storage_base::swap(basic_storage_base & other) { + std::swap(pimpl, other.pimpl); +} + +void swap(basic_storage_base & l, basic_storage_base & r) { + l.swap(r); +} + +} /* network */ + +} /* boost */ + +#endif /* BOOST_NETWORK_MESSAGE_BASIC_MESSAGE_IPP_20110911 */ diff --git a/boost/network/message/message_concept.hpp b/boost/network/message/message_concept.hpp index 91ac07960..2016c806f 100644 --- a/boost/network/message/message_concept.hpp +++ b/boost/network/message/message_concept.hpp @@ -10,10 +10,6 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include -#include -#include -#include #include #include #include @@ -29,13 +25,11 @@ namespace boost { namespace network { BOOST_CONCEPT_USAGE(Message) { M message_; swap(message, message_); - - typedef typename traits::body::type body_type; - typedef typename traits::source::type source_type; - typedef typename traits::destination::type destination_type; - - typedef typename traits::header_key::type header_key_type; - typedef typename traits::header_value::type header_value_type; + typedef std::string source_type; + typedef std::string destination_type; + typedef std::string body_type; + typedef std::string header_key_type; + typedef std::string header_value_type; headers_container_type headers_ = headers(message); string_type body_ = body(message); diff --git a/boost/network/message/traits/body.hpp b/boost/network/message/traits/body.hpp deleted file mode 100644 index 5d539d7f4..000000000 --- a/boost/network/message/traits/body.hpp +++ /dev/null @@ -1,46 +0,0 @@ - -#ifndef BOOST_NETWORK_MESSAGE_TRAITS_BODY_HPP_20100903 -#define BOOST_NETWORK_MESSAGE_TRAITS_BODY_HPP_20100903 - -// Copyright Dean Michael Berris 2010. -// 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) - -#include -#include -#include -#include - -namespace boost { namespace network { - - namespace traits { - - template - struct unsupported_tag; - - template - struct body : - mpl::if_< - is_async, - boost::shared_future::type>, - typename mpl::if_< - mpl::or_< - is_sync, - is_same, - is_same - >, - typename string::type, - unsupported_tag - >::type - > - {}; - - } // namespace traits - -} /* network */ - -} /* boost */ - -#endif // BOOST_NETWORK_MESSAGE_TRAITS_BODY_HPP_20100903 - diff --git a/boost/network/message/traits/destination.hpp b/boost/network/message/traits/destination.hpp deleted file mode 100644 index 39da83de9..000000000 --- a/boost/network/message/traits/destination.hpp +++ /dev/null @@ -1,45 +0,0 @@ - -#ifndef BOOST_NETWORK_MESSAGE_TRAITS_DESTINATION_HPP_20100903 -#define BOOST_NETWORK_MESSAGE_TRAITS_DESTINATION_HPP_20100903 - -// Copyright Dean Michael Berris 2010. -// 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) - -#include -#include -#include - -namespace boost { namespace network { - - namespace traits { - - template - struct unsupported_tag; - - template - struct destination : - mpl::if_< - is_async, - boost::shared_future::type>, - typename mpl::if_< - mpl::or_< - is_sync, - is_same, - is_same - >, - typename string::type, - unsupported_tag - >::type - > - {}; - - } // namespace traits - -} /* network */ - -} /* boost */ - -#endif // BOOST_NETWORK_MESSAGE_TRAITS_DESTINATION_HPP_20100903 - diff --git a/boost/network/message/traits/headers.hpp b/boost/network/message/traits/headers.hpp deleted file mode 100644 index a51023675..000000000 --- a/boost/network/message/traits/headers.hpp +++ /dev/null @@ -1,62 +0,0 @@ - -#ifndef BOOST_NETWORK_MESSAGE_TRAITS_HEADERS_HPP_20100903 -#define BOOST_NETWORK_MESSAGE_TRAITS_HEADERS_HPP_20100903 - -// Copyright Dean Michael Berris 2010. -// 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) - -#include -#include -#include - -namespace boost { namespace network { - - namespace traits { - - template - struct unsupported_tag; - - template - struct header_key : - mpl::if_< - is_async, - boost::shared_future::type>, - typename mpl::if_< - mpl::or_< - is_sync, - is_same, - is_same - >, - typename string::type, - unsupported_tag - >::type - > - {}; - - template - struct header_value : - mpl::if_< - is_async, - boost::shared_future::type>, - typename mpl::if_< - mpl::or_< - is_sync, - is_same, - is_same - >, - typename string::type, - unsupported_tag - >::type - > - {}; - - } // namespace traits - -} /* network */ - -} /* boost */ - -#endif // BOOST_NETWORK_MESSAGE_TRAITS_HEADERS_HPP_20100903 - diff --git a/boost/network/message/traits/source.hpp b/boost/network/message/traits/source.hpp deleted file mode 100644 index 9d2237e1e..000000000 --- a/boost/network/message/traits/source.hpp +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef BOOST_NETWORK_MESSAGE_TRAITS_SOURCE_HPP_20100903 -#define BOOST_NETWORK_MESSAGE_TRAITS_SOURCE_HPP_20100903 - -// Copyright Dean Michael Berris 2010. -// 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) - -#include -#include -#include - -namespace boost { namespace network { - - namespace traits { - - template - struct unsupported_tag; - - template - struct source : - mpl::if_< - is_async, - boost::shared_future::type>, - typename mpl::if_< - mpl::or_< - is_sync, - is_same, - is_same - >, - typename string::type, - unsupported_tag - >::type - > - {}; - - } // namespace traits - -} /* network */ - -} /* boost */ - -#endif // BOOST_NETWORK_MESSAGE_TRAITS_SOURCE_HPP_20100903 - - diff --git a/boost/network/protocol/http/message/traits/status.hpp b/boost/network/protocol/http/message/traits/status.hpp deleted file mode 100644 index 2ff22dcae..000000000 --- a/boost/network/protocol/http/message/traits/status.hpp +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_STATUS_HPP_20100903 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_STATUS_HPP_20100903 - -// Copyright Dean Michael Berris 2010. -// 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) - -#include - -namespace boost { namespace network { namespace http { - - namespace traits { - - template - struct unsupported_tag; - - template - struct status - : mpl::if_< - is_async, - boost::shared_future, - typename mpl::if_< - is_sync, - boost::uint16_t, - unsupported_tag - >::type - > - {}; - - } /* traits */ - -} /* http */ -} /* network */ -} /* boost */ - -#endif - diff --git a/boost/network/protocol/http/message/traits/status_message.hpp b/boost/network/protocol/http/message/traits/status_message.hpp deleted file mode 100644 index 9b0a47ccf..000000000 --- a/boost/network/protocol/http/message/traits/status_message.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_STATUS_MESSAGE_HPP_20100903 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_STATUS_MESSAGE_HPP_20100903 - -// Copyright Dean Michael Berris 2010. -// 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) - -namespace boost { namespace network { namespace http { - - namespace traits { - - template - struct unsupported_tag; - - template - struct status_message - : mpl::if_< - is_async, - boost::shared_future::type>, - typename mpl::if_< - mpl::or_< - is_sync, - is_same, - is_same - >, - typename string::type, - unsupported_tag - >::type - > - {}; - - } /* traits */ - -} /* http */ -} /* network */ -} /* boost */ - -#endif - diff --git a/boost/network/protocol/http/message/traits/version.hpp b/boost/network/protocol/http/message/traits/version.hpp deleted file mode 100644 index 748bb71c6..000000000 --- a/boost/network/protocol/http/message/traits/version.hpp +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_VERSION_HPP_20100903 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_VERSION_HPP_20100903 - -// Copyright Dean Michael Berris 2010. -// 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) - -#include -#include - -namespace boost { namespace network { namespace http { - - namespace traits { - - template - struct unsupported_tag; - - template - struct version - { - typedef unsupported_tag type; - }; - - template - struct version >::type> - { - typedef boost::shared_future::type> type; - }; - - template - struct version, - is_default_string, - is_default_wstring - > - >::type - > - { - typedef typename string::type type; - }; - - } /* traits */ - -} /* http */ -} /* network */ -} /* boost */ - -#endif diff --git a/boost/network/protocol/http/response.hpp b/boost/network/protocol/http/response.hpp index 459f938b8..bf9a00005 100644 --- a/boost/network/protocol/http/response.hpp +++ b/boost/network/protocol/http/response.hpp @@ -9,8 +9,6 @@ #include -#include - #include #include #include diff --git a/boost/network/protocol/http/response_concept.hpp b/boost/network/protocol/http/response_concept.hpp index ef6bf0f62..9d067532d 100644 --- a/boost/network/protocol/http/response_concept.hpp +++ b/boost/network/protocol/http/response_concept.hpp @@ -9,9 +9,6 @@ #include #include -#include -#include -#include #include namespace boost { namespace network { namespace http { From 0e521d02e2b1f667278a46b86d3b7ea2dd1f381c Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Fri, 30 Sep 2011 16:44:19 +1000 Subject: [PATCH 007/196] WIP: Gutting the message implementation. --- boost/network/message.hpp | 55 +++++++++++--- .../http/message/directives/status.hpp | 72 +++++-------------- boost/network/protocol/http/request.ipp | 2 +- 3 files changed, 65 insertions(+), 64 deletions(-) diff --git a/boost/network/message.hpp b/boost/network/message.hpp index e46a2707c..32b3f68f0 100644 --- a/boost/network/message.hpp +++ b/boost/network/message.hpp @@ -64,11 +64,15 @@ namespace boost { namespace network { } headers_container_type & headers() { - return pimpl->headers_; + if (!headers_) { + headers_ = headers_container_type(); + this->get_headers(*headers_); + } + return *headers_; } void headers(headers_container_type const & headers_) const { - pimpl->headers_ = headers_; + this->set_headers(headers_); } void add_header(typename headers_container_type::value_type const & pair_) const { @@ -80,11 +84,19 @@ namespace boost { namespace network { } headers_container_type const & headers() const { - return pimpl->headers_; + if (!headers_) { + headers_ = headers_container_type(); + this->get_headers(*headers_); + } + return *headers_; } string_type & body() { - return pimpl->body_; + if (!body_) { + body_ = String(); + this->get_body(*body_); + } + return *body_; } void body(string_type const & body_) const { @@ -92,11 +104,19 @@ namespace boost { namespace network { } string_type const & body() const { - return pimpl->body_; + if (!body_) { + body_ = String(); + this->get_body(*body_); + } + return *body_; } string_type & source() { - return pimpl->source_; + if (!source_) { + source_ = String(); + this->get_source(*source_); + } + return *source_; } void source(string_type const & source_) const { @@ -104,11 +124,19 @@ namespace boost { namespace network { } string_type const & source() const { - return pimpl->source_; + if (!source_) { + source_ = String(); + this->get_source(*source_); + } + return *source_; } string_type & destination() { - return pimpl->destination_; + if (!destination_) { + destination_ = String(); + this->get_destination(*destination_); + } + return *destination_; } void destination(string_type const & destination_) const { @@ -116,8 +144,17 @@ namespace boost { namespace network { } string_type const & destination() const { - return pimpl->destination_; + if (!destination_) { + destination_ = String(); + this->get_destination(*destination_); + } + return *destination_; } + + protected: + optional source_, destination_; + optional headers_; + optional body_; }; template diff --git a/boost/network/protocol/http/message/directives/status.hpp b/boost/network/protocol/http/message/directives/status.hpp index bfd68354c..6595658b7 100644 --- a/boost/network/protocol/http/message/directives/status.hpp +++ b/boost/network/protocol/http/message/directives/status.hpp @@ -1,76 +1,40 @@ #ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_STATUS_HPP_20100603 #define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_STATUS_HPP_20100603 -// Copyright 2010 (c) Dean Michael Berris // Copyright 2010 (c) Sinefunc, Inc. +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. // 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) #include #include -#include -#include -#include #include namespace boost { namespace network { namespace http { - template - struct basic_response; - - struct status_directive { +template +struct status_directive { - boost::variant< - boost::uint16_t, - boost::shared_future - > status_; + status_directive(String const & s) + : status_(s) + {} - explicit status_directive(boost::uint16_t status) - : status_(status) {} + void operator()(response_base & response) { + response.set_status(status_); + } - explicit status_directive(boost::shared_future const & status) - : status_(status) {} + protected: + + String status_; - status_directive(status_directive const & other) - : status_(other.status_) {} +}; - template - struct value - : mpl::if_< - is_async, - boost::shared_future, - boost::uint16_t - > - {}; - - template - struct status_visitor : boost::static_visitor<> { - basic_response const & response; - status_visitor(basic_response const & response) - : response(response) {} - - void operator()(typename value::type const & status_) const { - response.status(status_); - } - - template - void operator()(T const &) const { - // FIXME fail here! - } - }; - - template basic_response const & operator() (basic_response const & response) const { - apply_visitor(status_visitor(response), status_); - return response; - } - - }; - - template - inline status_directive const status(T const & status_) { - return status_directive(status_); - } +template +inline status_directive status(String const & response) { + return status_directive(response); +} } // namespace http diff --git a/boost/network/protocol/http/request.ipp b/boost/network/protocol/http/request.ipp index 55e2d9fca..cace3fccb 100644 --- a/boost/network/protocol/http/request.ipp +++ b/boost/network/protocol/http/request.ipp @@ -33,7 +33,7 @@ struct request_storage_base { virtual void append_header(std::string const &name, std::string const &value); }; -struct request_base : request_storage_base { +struct request_base : message_base, request_storage_base { protected: using request_storage_base::body_stream; request_base(); From ddbfba25cd76189bae46bc73ada7b444d8c37c78 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Fri, 30 Sep 2011 17:36:47 +1000 Subject: [PATCH 008/196] WIP: Gutting the message implementation... --- boost/network/message/wrappers/body.hpp | 7 +- boost/network/message/wrappers/source.hpp | 2 + boost/network/protocol/http/impl/response.ipp | 570 +++++++++--------- .../http/message/directives/status.hpp | 1 + .../network/protocol/http/message/header.hpp | 79 +-- .../protocol/http/message/message_base.hpp | 33 - .../protocol/http/message/modifiers/body.hpp | 74 --- .../http/message/modifiers/destination.hpp | 90 --- .../http/message/modifiers/headers.hpp | 57 -- .../http/message/modifiers/source.hpp | 82 --- .../http/message/modifiers/status.hpp | 26 +- .../http/message/modifiers/status_message.hpp | 26 +- .../http/message/modifiers/version.hpp | 27 +- .../http/message/wrappers/destination.hpp | 33 - .../protocol/http/message/wrappers/source.hpp | 27 - .../protocol/http/message/wrappers/status.hpp | 49 +- .../http/message/wrappers/status_message.hpp | 47 +- .../protocol/http/message/wrappers/uri.hpp | 42 +- .../http/message/wrappers/version.hpp | 53 +- boost/network/protocol/http/request.hpp | 6 - boost/network/protocol/http/response.hpp | 47 +- .../protocol/http/response_concept.hpp | 6 +- .../protocol/http/server/impl/parsers.ipp | 2 +- 23 files changed, 387 insertions(+), 999 deletions(-) delete mode 100644 boost/network/protocol/http/message/message_base.hpp delete mode 100644 boost/network/protocol/http/message/modifiers/body.hpp delete mode 100644 boost/network/protocol/http/message/modifiers/destination.hpp delete mode 100644 boost/network/protocol/http/message/modifiers/headers.hpp delete mode 100644 boost/network/protocol/http/message/modifiers/source.hpp delete mode 100644 boost/network/protocol/http/message/wrappers/destination.hpp delete mode 100644 boost/network/protocol/http/message/wrappers/source.hpp diff --git a/boost/network/message/wrappers/body.hpp b/boost/network/message/wrappers/body.hpp index b5c89aa1a..ce19f8d0b 100644 --- a/boost/network/message/wrappers/body.hpp +++ b/boost/network/message/wrappers/body.hpp @@ -1,11 +1,12 @@ -// Copyright Dean Michael Berris 2007. +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. // 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 __NETWORK_MESSAGE_WRAPPERS_BODY_HPP__ -#define __NETWORK_MESSAGE_WRAPPERS_BODY_HPP__ +#ifndef BOOST_NETWORK_MESSAGE_WRAPPERS_BODY_HPP_20110930 +#define BOOST_NETWORK_MESSAGE_WRAPPERS_BODY_HPP_20110930 #include #include diff --git a/boost/network/message/wrappers/source.hpp b/boost/network/message/wrappers/source.hpp index 8a139de17..7485f6b73 100644 --- a/boost/network/message/wrappers/source.hpp +++ b/boost/network/message/wrappers/source.hpp @@ -16,6 +16,8 @@ namespace impl { struct source_wrapper { explicit source_wrapper(message_base & message_); operator std::string () const; + private: + message_base & message_; }; } // namespace impl diff --git a/boost/network/protocol/http/impl/response.ipp b/boost/network/protocol/http/impl/response.ipp index 0708575e8..5780ef24e 100644 --- a/boost/network/protocol/http/impl/response.ipp +++ b/boost/network/protocol/http/impl/response.ipp @@ -20,305 +20,299 @@ namespace boost { namespace network { namespace http { - /// A reply to be sent to a client. - template <> - struct basic_response { - typedef tags::http_server tag; - typedef response_header::type header_type; +/// A reply to be sent to a client. +template class Vector = std::vector> +struct basic_response : response_base { - /// The status of the reply. - enum status_type { - ok = 200, - created = 201, - accepted = 202, - no_content = 204, - multiple_choices = 300, - moved_permanently = 301, - moved_temporarily = 302, - not_modified = 304, - bad_request = 400, - unauthorized = 401, - forbidden = 403, - not_found = 404, - not_supported = 405, - not_acceptable = 406, - internal_server_error = 500, - not_implemented = 501, - bad_gateway = 502, - service_unavailable = 503 - } status; - - /// The headers to be included in the reply. - typedef vector::apply::type headers_vector; - headers_vector headers; - - /// The content to be sent in the reply. - typedef string::type string_type; - string_type content; + /// The status of the reply. + enum status_type { + ok = 200, + created = 201, + accepted = 202, + no_content = 204, + multiple_choices = 300, + moved_permanently = 301, + moved_temporarily = 302, + not_modified = 304, + bad_request = 400, + unauthorized = 401, + forbidden = 403, + not_found = 404, + not_supported = 405, + not_acceptable = 406, + internal_server_error = 500, + not_implemented = 501, + bad_gateway = 502, + service_unavailable = 503 + } status; + + /// The headers to be included in the reply. + typedef Vector > headers_vector; + headers_vector headers; - /// Convert the reply into a vector of buffers. The buffers do not own the - /// underlying memory blocks, therefore the reply object must remain valid and - /// not be changed until the write operation has completed. - std::vector to_buffers() { - using boost::asio::const_buffer; - using boost::asio::buffer; - static const char name_value_separator[] = { ':', ' ' }; - static const char crlf[] = { '\r', '\n' }; - std::vector buffers; - buffers.push_back(to_buffer(status)); - for (std::size_t i = 0; i < headers.size(); ++i) { - header_type & h = headers[i]; - buffers.push_back(buffer(h.name)); - buffers.push_back(buffer(name_value_separator)); - buffers.push_back(buffer(h.value)); - buffers.push_back(buffer(crlf)); - } + /// Convert the reply into a vector of buffers. The buffers do not own the + /// underlying memory blocks, therefore the reply object must remain valid and + /// not be changed until the write operation has completed. + std::vector to_buffers() { + // FIXME: Rethink this and do this asynchronously. + using boost::asio::const_buffer; + using boost::asio::buffer; + static const char name_value_separator[] = { ':', ' ' }; + static const char crlf[] = { '\r', '\n' }; + std::vector buffers; + buffers.push_back(to_buffer(status)); + for (std::size_t i = 0; i < headers.size(); ++i) { + response_header & h = headers[i]; + buffers.push_back(buffer(h.name)); + buffers.push_back(buffer(name_value_separator)); + buffers.push_back(buffer(h.value)); buffers.push_back(buffer(crlf)); - buffers.push_back(buffer(content)); - return buffers; } + buffers.push_back(buffer(crlf)); + return buffers; + } - /// Get a stock reply. - static basic_response stock_reply(status_type status) { - return stock_reply(status, to_string(status)); - } + /// Get a stock reply. + static basic_response stock_reply(status_type status) { + return stock_reply(status, to_string(status)); + } - /// Get a stock reply with custom plain text data. - static basic_response stock_reply(status_type status, string_type content) { - using boost::lexical_cast; - basic_response rep; - rep.status = status; - rep.content = content; - rep.headers.resize(2); - rep.headers[0].name = "Content-Length"; - rep.headers[0].value = lexical_cast(rep.content.size()); - rep.headers[1].name = "Content-Type"; - rep.headers[1].value = "text/html"; - return rep; - } + /// Get a stock reply with custom plain text data. + static basic_response stock_reply(status_type status, String const & content) { + using boost::lexical_cast; + basic_response rep; + rep.status = status; + rep.content = content; + rep.headers.resize(2); + rep.headers[0].name = "Content-Length"; + rep.headers[0].value = lexical_cast(rep.content.size()); + rep.headers[1].name = "Content-Type"; + rep.headers[1].value = "text/html"; + return rep; + } - /// Swap response objects - void swap(basic_response &r) { - using std::swap; - swap(headers, r.headers); - swap(content, r.content); - } + /// Swap response objects + void swap(basic_response &r) { + using std::swap; + swap(headers, r.headers); + // swap(content, r.content); + } - private: - - static string_type to_string(status_type status) { - static const char ok[] = ""; - static const char created[] = - "" - "Created" - "

201 Created

" - ""; - static const char accepted[] = - "" - "Accepted" - "

202 Accepted

" - ""; - static const char no_content[] = - "" - "No Content" - "

204 Content

" - ""; - static const char multiple_choices[] = - "" - "Multiple Choices" - "

300 Multiple Choices

" - ""; - static const char moved_permanently[] = - "" - "Moved Permanently" - "

301 Moved Permanently

" - ""; - static const char moved_temporarily[] = - "" - "Moved Temporarily" - "

302 Moved Temporarily

" - ""; - static const char not_modified[] = - "" - "Not Modified" - "

304 Not Modified

" - ""; - static const char bad_request[] = - "" - "Bad Request" - "

400 Bad Request

" - ""; - static const char unauthorized[] = - "" - "Unauthorized" - "

401 Unauthorized

" - ""; - static const char forbidden[] = - "" - "Forbidden" - "

403 Forbidden

" - ""; - static const char not_found[] = - "" - "Not Found" - "

404 Not Found

" - ""; - static const char not_supported[] = - "" - "Method Not Supported" - "

Method Not Supported

" - ""; - static const char not_acceptable[] = - "" - "Request Not Acceptable" - "

Request Not Acceptable

" - ""; - static const char internal_server_error[] = - "" - "Internal Server Error" - "

500 Internal Server Error

" - ""; - static const char not_implemented[] = - "" - "Not Implemented" - "

501 Not Implemented

" - ""; - static const char bad_gateway[] = - "" - "Bad Gateway" - "

502 Bad Gateway

" - ""; - static const char service_unavailable[] = - "" - "Service Unavailable" - "

503 Service Unavailable

" - ""; + private: - switch (status) - { - case basic_response::ok: - return ok; - case basic_response::created: - return created; - case basic_response::accepted: - return accepted; - case basic_response::no_content: - return no_content; - case basic_response::multiple_choices: - return multiple_choices; - case basic_response::moved_permanently: - return moved_permanently; - case basic_response::moved_temporarily: - return moved_temporarily; - case basic_response::not_modified: - return not_modified; - case basic_response::bad_request: - return bad_request; - case basic_response::unauthorized: - return unauthorized; - case basic_response::forbidden: - return forbidden; - case basic_response::not_found: - return not_found; - case basic_response::not_supported: - return not_supported; - case basic_response::not_acceptable: - return not_acceptable; - case basic_response::internal_server_error: - return internal_server_error; - case basic_response::not_implemented: - return not_implemented; - case basic_response::bad_gateway: - return bad_gateway; - case basic_response::service_unavailable: - return service_unavailable; - default: - return internal_server_error; - } + static String to_string(status_type status) { + static const char ok[] = ""; + static const char created[] = + "" + "Created" + "

201 Created

" + ""; + static const char accepted[] = + "" + "Accepted" + "

202 Accepted

" + ""; + static const char no_content[] = + "" + "No Content" + "

204 Content

" + ""; + static const char multiple_choices[] = + "" + "Multiple Choices" + "

300 Multiple Choices

" + ""; + static const char moved_permanently[] = + "" + "Moved Permanently" + "

301 Moved Permanently

" + ""; + static const char moved_temporarily[] = + "" + "Moved Temporarily" + "

302 Moved Temporarily

" + ""; + static const char not_modified[] = + "" + "Not Modified" + "

304 Not Modified

" + ""; + static const char bad_request[] = + "" + "Bad Request" + "

400 Bad Request

" + ""; + static const char unauthorized[] = + "" + "Unauthorized" + "

401 Unauthorized

" + ""; + static const char forbidden[] = + "" + "Forbidden" + "

403 Forbidden

" + ""; + static const char not_found[] = + "" + "Not Found" + "

404 Not Found

" + ""; + static const char not_supported[] = + "" + "Method Not Supported" + "

Method Not Supported

" + ""; + static const char not_acceptable[] = + "" + "Request Not Acceptable" + "

Request Not Acceptable

" + ""; + static const char internal_server_error[] = + "" + "Internal Server Error" + "

500 Internal Server Error

" + ""; + static const char not_implemented[] = + "" + "Not Implemented" + "

501 Not Implemented

" + ""; + static const char bad_gateway[] = + "" + "Bad Gateway" + "

502 Bad Gateway

" + ""; + static const char service_unavailable[] = + "" + "Service Unavailable" + "

503 Service Unavailable

" + ""; + + switch (status) + { + case basic_response::ok: + return ok; + case basic_response::created: + return created; + case basic_response::accepted: + return accepted; + case basic_response::no_content: + return no_content; + case basic_response::multiple_choices: + return multiple_choices; + case basic_response::moved_permanently: + return moved_permanently; + case basic_response::moved_temporarily: + return moved_temporarily; + case basic_response::not_modified: + return not_modified; + case basic_response::bad_request: + return bad_request; + case basic_response::unauthorized: + return unauthorized; + case basic_response::forbidden: + return forbidden; + case basic_response::not_found: + return not_found; + case basic_response::not_supported: + return not_supported; + case basic_response::not_acceptable: + return not_acceptable; + case basic_response::internal_server_error: + return internal_server_error; + case basic_response::not_implemented: + return not_implemented; + case basic_response::bad_gateway: + return bad_gateway; + case basic_response::service_unavailable: + return service_unavailable; + default: + return internal_server_error; + } + } + + boost::asio::const_buffer to_buffer(status_type status) { + using boost::asio::buffer; + static const String ok = + "HTTP/1.0 200 OK\r\n"; + static const String created = + "HTTP/1.0 201 Created\r\n"; + static const String accepted = + "HTTP/1.0 202 Accepted\r\n"; + static const String no_content = + "HTTP/1.0 204 No Content\r\n"; + static const String multiple_choices = + "HTTP/1.0 300 Multiple Choices\r\n"; + static const String moved_permanently = + "HTTP/1.0 301 Moved Permanently\r\n"; + static const String moved_temporarily = + "HTTP/1.0 302 Moved Temporarily\r\n"; + static const String not_modified = + "HTTP/1.0 304 Not Modified\r\n"; + static const String bad_request = + "HTTP/1.0 400 Bad Request\r\n"; + static const String unauthorized = + "HTTP/1.0 401 Unauthorized\r\n"; + static const String forbidden = + "HTTP/1.0 403 Forbidden\r\n"; + static const String not_found = + "HTTP/1.0 404 Not Found\r\n"; + static const String not_supported = + "HTTP/1.0 405 Method Not Supported\r\n"; + static const String not_acceptable = + "HTTP/1.0 406 Method Not Acceptable\r\n"; + static const String internal_server_error = + "HTTP/1.0 500 Internal Server Error\r\n"; + static const String not_implemented = + "HTTP/1.0 501 Not Implemented\r\n"; + static const String bad_gateway = + "HTTP/1.0 502 Bad Gateway\r\n"; + static const String service_unavailable = + "HTTP/1.0 503 Service Unavailable\r\n"; + + switch (status) { + case basic_response::ok: + return buffer(ok); + case basic_response::created: + return buffer(created); + case basic_response::accepted: + return buffer(accepted); + case basic_response::no_content: + return buffer(no_content); + case basic_response::multiple_choices: + return buffer(multiple_choices); + case basic_response::moved_permanently: + return buffer(moved_permanently); + case basic_response::moved_temporarily: + return buffer(moved_temporarily); + case basic_response::not_modified: + return buffer(not_modified); + case basic_response::bad_request: + return buffer(bad_request); + case basic_response::unauthorized: + return buffer(unauthorized); + case basic_response::forbidden: + return buffer(forbidden); + case basic_response::not_found: + return buffer(not_found); + case basic_response::not_supported: + return buffer(not_supported); + case basic_response::not_acceptable: + return buffer(not_acceptable); + case basic_response::internal_server_error: + return buffer(internal_server_error); + case basic_response::not_implemented: + return buffer(not_implemented); + case basic_response::bad_gateway: + return buffer(bad_gateway); + case basic_response::service_unavailable: + return buffer(service_unavailable); + default: + return buffer(internal_server_error); } + } - boost::asio::const_buffer to_buffer(status_type status) { - using boost::asio::buffer; - static const string_type ok = - "HTTP/1.0 200 OK\r\n"; - static const string_type created = - "HTTP/1.0 201 Created\r\n"; - static const string_type accepted = - "HTTP/1.0 202 Accepted\r\n"; - static const string_type no_content = - "HTTP/1.0 204 No Content\r\n"; - static const string_type multiple_choices = - "HTTP/1.0 300 Multiple Choices\r\n"; - static const string_type moved_permanently = - "HTTP/1.0 301 Moved Permanently\r\n"; - static const string_type moved_temporarily = - "HTTP/1.0 302 Moved Temporarily\r\n"; - static const string_type not_modified = - "HTTP/1.0 304 Not Modified\r\n"; - static const string_type bad_request = - "HTTP/1.0 400 Bad Request\r\n"; - static const string_type unauthorized = - "HTTP/1.0 401 Unauthorized\r\n"; - static const string_type forbidden = - "HTTP/1.0 403 Forbidden\r\n"; - static const string_type not_found = - "HTTP/1.0 404 Not Found\r\n"; - static const string_type not_supported = - "HTTP/1.0 405 Method Not Supported\r\n"; - static const string_type not_acceptable = - "HTTP/1.0 406 Method Not Acceptable\r\n"; - static const string_type internal_server_error = - "HTTP/1.0 500 Internal Server Error\r\n"; - static const string_type not_implemented = - "HTTP/1.0 501 Not Implemented\r\n"; - static const string_type bad_gateway = - "HTTP/1.0 502 Bad Gateway\r\n"; - static const string_type service_unavailable = - "HTTP/1.0 503 Service Unavailable\r\n"; - - switch (status) { - case basic_response::ok: - return buffer(ok); - case basic_response::created: - return buffer(created); - case basic_response::accepted: - return buffer(accepted); - case basic_response::no_content: - return buffer(no_content); - case basic_response::multiple_choices: - return buffer(multiple_choices); - case basic_response::moved_permanently: - return buffer(moved_permanently); - case basic_response::moved_temporarily: - return buffer(moved_temporarily); - case basic_response::not_modified: - return buffer(not_modified); - case basic_response::bad_request: - return buffer(bad_request); - case basic_response::unauthorized: - return buffer(unauthorized); - case basic_response::forbidden: - return buffer(forbidden); - case basic_response::not_found: - return buffer(not_found); - case basic_response::not_supported: - return buffer(not_supported); - case basic_response::not_acceptable: - return buffer(not_acceptable); - case basic_response::internal_server_error: - return buffer(internal_server_error); - case basic_response::not_implemented: - return buffer(not_implemented); - case basic_response::bad_gateway: - return buffer(bad_gateway); - case basic_response::service_unavailable: - return buffer(service_unavailable); - default: - return buffer(internal_server_error); - } - } - - }; +}; } // namespace http diff --git a/boost/network/protocol/http/message/directives/status.hpp b/boost/network/protocol/http/message/directives/status.hpp index 6595658b7..2b910d595 100644 --- a/boost/network/protocol/http/message/directives/status.hpp +++ b/boost/network/protocol/http/message/directives/status.hpp @@ -11,6 +11,7 @@ #include #include #include +#include namespace boost { namespace network { namespace http { diff --git a/boost/network/protocol/http/message/header.hpp b/boost/network/protocol/http/message/header.hpp index 052ece94b..e842ebd45 100644 --- a/boost/network/protocol/http/message/header.hpp +++ b/boost/network/protocol/http/message/header.hpp @@ -21,79 +21,24 @@ namespace boost { namespace network { namespace http { - template - struct unsupported_string; - - struct request_header_narrow { - typedef std::string string_type; - std::string name, value; - }; - - struct request_header_wide { - typedef std::wstring string_type; - std::wstring name, value; - }; - - template struct request_header { - typedef unsupported_string type; - }; - - template - struct request_header >::type> { - typedef request_header_narrow type; - }; - - template - struct request_header >::type> { - typedef request_header_wide type; + std::string name, value; }; - inline void swap(request_header_narrow & l, request_header_narrow & r) { - swap(l.name, r.name); - swap(l.value, r.value); - } - - inline void swap(request_header_wide & l, request_header_wide & r) { + inline void swap(request_header & l, request_header & r) { swap(l.name, r.name); swap(l.value, r.value); } - struct response_header_narrow { - typedef std::string string_type; - std::string name, value; - }; - - struct response_header_wide { - typedef std::wstring string_type; - std::wstring name, value; - }; - - template struct response_header { - typedef unsupported_string type; - }; - - template - struct response_header >::type> { - typedef response_header_wide type; - }; - - template - struct response_header >::type> { - typedef response_header_narrow type; + std::string name, value; }; - inline void swap(response_header_narrow & l, response_header_narrow & r) { + inline void swap(response_header & l, response_header & r) { std::swap(l.name, r.name); std::swap(l.value, r.value); } - inline void swap(response_header_wide & l, response_header_wide & r) { - std::swap(l.name, r.name); - std::swap(l.value, r.value); - } - } // namespace http } // namespace network @@ -101,27 +46,15 @@ namespace boost { namespace network { namespace http { } // namespace boost BOOST_FUSION_ADAPT_STRUCT( - boost::network::http::request_header_narrow, + boost::network::http::request_header, (std::string, name) (std::string, value) ) BOOST_FUSION_ADAPT_STRUCT( - boost::network::http::request_header_wide, - (std::wstring, name) - (std::wstring, value) - ) - -BOOST_FUSION_ADAPT_STRUCT( - boost::network::http::response_header_narrow, + boost::network::http::response_header, (std::string, name) (std::string, value) ) -BOOST_FUSION_ADAPT_STRUCT( - boost::network::http::response_header_wide, - (std::wstring, name) - (std::wstring, value) - ) - #endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_HPP_20101122 diff --git a/boost/network/protocol/http/message/message_base.hpp b/boost/network/protocol/http/message/message_base.hpp deleted file mode 100644 index bc27bd03c..000000000 --- a/boost/network/protocol/http/message/message_base.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_BASE_HPP_20100603 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_BASE_HPP_20100603 - -// Copyright 2010 (c) Dean Michael Berris -// Copyright 2010 (c) Sinefunc, Inc. -// 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) - -namespace boost { namespace network { namespace http { - - template - struct async_message; - - template - struct message_impl; - - template - struct message_base - : mpl::if_< - is_async, - async_message, - message_impl - > - {}; - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_BASE_HPP_20100603 diff --git a/boost/network/protocol/http/message/modifiers/body.hpp b/boost/network/protocol/http/message/modifiers/body.hpp deleted file mode 100644 index 40523b4ea..000000000 --- a/boost/network/protocol/http/message/modifiers/body.hpp +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIER_BODY_HPP_20100624 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIER_BODY_HPP_20100624 - -// Copyright 2010 (C) Dean Michael Berris -// 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) - -#include -#include -#include - -namespace boost { namespace network { namespace http { - - template - struct basic_response; - - template - struct basic_request; - - namespace impl { - - template - void body(basic_response & response, T const & value, mpl::false_ const &) { - response << ::boost::network::body(value); - } - - template - void body(basic_response & response, T const & future, mpl::true_ const &) { - response.body(future); - } - - } - - template - inline void - body(basic_response & response, T const & value) { - impl::body(response, value, is_async()); - } - - template - inline void - body_impl(basic_request & request, T const & value, tags::server) { - request.body = value; - } - - template - inline void - body_impl(basic_request & request, T const & value, tags::client) { - request << ::boost::network::body(value); - } - - template - inline void - body(basic_request & request, T const & value) { - body_impl(request, value, typename client_or_server::type()); - } - -} // namespace http - - namespace impl { - - template - inline void body(Message const & message, ValueType const & body_, http::tags::http_server, Async) { - message.body = body_; - } - - } /* impl */ - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIER_BODY_HPP_20100624 diff --git a/boost/network/protocol/http/message/modifiers/destination.hpp b/boost/network/protocol/http/message/modifiers/destination.hpp deleted file mode 100644 index d67958653..000000000 --- a/boost/network/protocol/http/message/modifiers/destination.hpp +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIER_DESTINATION_HPP_20100624 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIER_DESTINATION_HPP_20100624 - -// Copyright 2010 (C) Dean Michael Berris -// 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) - -#include -#include - -namespace boost { namespace network { namespace http { - - template - struct basic_response; - - template - struct basic_request; - - namespace impl { - - template - void destination(basic_response & response, T const & value, mpl::false_ const &) { - response << ::boost::network::destination(value); - } - - template - void destination(basic_response & response, T const & future, mpl::true_ const &) { - response.destination(future); - } - - } - - template - inline void - destination(basic_response & response, T const & value) { - impl::destination(response, value, is_async()); - } - - template - struct ServerRequest; - - template - inline void - destination_impl(basic_request & request, T const & value, tags::server) { - request.destination = value; - } - - template - inline void - destination_impl(basic_request & request, T const & value, tags::pod) { - request.destination = value; - } - - template - inline void - destination_impl(basic_request & request, T const & value, tags::normal) { - request.destination(value); - } - - template - inline void - destination_impl(basic_request & request, T const & value, tags::client) { - destination_impl(request, value, typename pod_or_normal::type()); - } - - template - inline void - destination(basic_request & request, T const & value) { - destination_impl(request, value, typename client_or_server::type()); - } - -} // namespace http - - namespace impl { - - template - inline void destination(Message const & message, ValueType const & destination_, http::tags::http_server, Async) { - message.destination = destination_; - } - - } /* impl */ - -} // namespace network - -} // namespace boost - -#include - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIER_DESTINATION_HPP_20100624 diff --git a/boost/network/protocol/http/message/modifiers/headers.hpp b/boost/network/protocol/http/message/modifiers/headers.hpp deleted file mode 100644 index 9bfcec4fc..000000000 --- a/boost/network/protocol/http/message/modifiers/headers.hpp +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIER_HEADERS_HPP_20100624 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIER_HEADERS_HPP_20100624 - -// Copyright 2010 (C) Dean Michael Berris -// 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) - -#include -#include - -namespace boost { namespace network { namespace http { - - template - struct basic_response; - - template - struct basic_request; - - namespace impl { - - template - void headers(basic_response & response, T const & value, mpl::false_ const &) { - response << headers(value); - } - - template - void headers(basic_response & response, T const & future, mpl::true_ const &) { - response.headers(future); - } - - template - void headers(basic_request & request, T const & value, tags::server const &) { - request.headers = value; - } - - } - - template - inline void - headers(basic_response & response, T const & value) { - impl::headers(response, value, is_async()); - } - - template - inline void - headers(basic_request & request, T const & value) { - impl::headers(request, value, Tag()); - } - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIER_HEADERS_HPP_20100624 diff --git a/boost/network/protocol/http/message/modifiers/source.hpp b/boost/network/protocol/http/message/modifiers/source.hpp deleted file mode 100644 index 4fa537b6a..000000000 --- a/boost/network/protocol/http/message/modifiers/source.hpp +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIER_SOURCE_HPP_20100624 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIER_SOURCE_HPP_20100624 - -// Copyright 2010 (C) Dean Michael Berris -// 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) - -#include -#include -#include - -namespace boost { namespace network { namespace http { - - template - struct basic_response; - - namespace impl { - - template - void source(basic_response & response, T const & value, mpl::false_ const &) { - response << ::boost::network::source(value); - } - - template - void source(basic_response & response, T const & future, mpl::true_ const &) { - response.source(future); - } - - template - void source(basic_request & request, T const & value, tags::server const &) { - request.source = value; - } - - template - void source(basic_request & request, T const & value, tags::client const &) { - request << ::boost::network::source(value); - } - - } - - template - inline void - source(basic_response & response, T const & value) { - impl::source(response, value, is_async()); - } - - template - inline void - source_impl(basic_request & request, T const & value, tags::server) { - impl::source(request, value, Tag()); - } - - template - inline void - source_impl(basic_request & request, T const & value, tags::client) { - impl::source(request, value, Tag()); - } - - template - inline void - source(basic_request & request, T const & value) { - source_impl(request, value, typename client_or_server::type()); - } - -} // namespace http - - namespace impl { - - template - inline void source(Message const & message, ValueType const & source_, http::tags::http_server const &, Async const &) { - message.source = source_; - } - - } /* impl */ - -} // namespace network - -} // namespace boost - -#include -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIER_SOURCE_HPP_20100624 diff --git a/boost/network/protocol/http/message/modifiers/status.hpp b/boost/network/protocol/http/message/modifiers/status.hpp index dfcd305e8..ca6024e09 100644 --- a/boost/network/protocol/http/message/modifiers/status.hpp +++ b/boost/network/protocol/http/message/modifiers/status.hpp @@ -7,31 +7,13 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { - template - struct basic_response; - - namespace impl { - - template - void status(basic_response & response, T const & value, mpl::false_ const &) { - response << boost::network::http::status(value); - } - - template - void status(basic_response & response, T const & future, mpl::true_ const &) { - response.status(future); - } - - } // namespace impl - - template - void status(basic_response & response, T const & value) { - impl::status(response, value, is_async()); - } +inline void status(response_base & response, std::string const & value) { + response.set_status(value); +} } // namespace http diff --git a/boost/network/protocol/http/message/modifiers/status_message.hpp b/boost/network/protocol/http/message/modifiers/status_message.hpp index bcd92bcb8..3d24601cc 100644 --- a/boost/network/protocol/http/message/modifiers/status_message.hpp +++ b/boost/network/protocol/http/message/modifiers/status_message.hpp @@ -7,31 +7,13 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { - template - struct basic_response; - - namespace impl { - - template - void status_message(basic_response & response, T const & value, mpl::false_ const &) { - response << boost::network::http::status_message(value); - } - - template - void status_message(basic_response & response, T const & future, mpl::true_ const &) { - response.status_message(future); - } - - } // namespace impl - - template - void status_message(basic_response & response, T const & value) { - impl::status_message(response, value, is_async()); - } +inline void status_message(response_base & response, std::string const & value) { + response.set_status_message(value); +} } // namespace http diff --git a/boost/network/protocol/http/message/modifiers/version.hpp b/boost/network/protocol/http/message/modifiers/version.hpp index 0077ca4f6..ee668fc07 100644 --- a/boost/network/protocol/http/message/modifiers/version.hpp +++ b/boost/network/protocol/http/message/modifiers/version.hpp @@ -7,32 +7,13 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include +#include namespace boost { namespace network { namespace http { - template - struct basic_response; - - namespace impl { - - template - void version(basic_response & response, T const & value, mpl::false_ const &) { - response << boost::network::http::version(value); - } - - template - void version(basic_response & response, T const & future, mpl::true_ const &) { - response.version(future); - } - - } // namespace impl - - template - void version(basic_response & response, T const & value) { - impl::version(response, value, is_async()); - } +inline void version(response_base & response, std::string const & value) { + response.set_version(value); +} } // namespace http diff --git a/boost/network/protocol/http/message/wrappers/destination.hpp b/boost/network/protocol/http/message/wrappers/destination.hpp deleted file mode 100644 index bf851aac7..000000000 --- a/boost/network/protocol/http/message/wrappers/destination.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DESTINATION_HPP_20100624 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DESTINATION_HPP_20100624 - -// Copyright 2010 (c) Dean Michael Berris. -// 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) - -#include - -namespace boost { namespace network { namespace http { - - template - struct basic_response; - - template - struct basic_request; - - template - struct Request; - - template - struct Response; - - BOOST_NETWORK_DEFINE_HTTP_WRAPPER(destination, destination, destination); - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DESTINATION_HPP_20100624 diff --git a/boost/network/protocol/http/message/wrappers/source.hpp b/boost/network/protocol/http/message/wrappers/source.hpp deleted file mode 100644 index be5f67ea9..000000000 --- a/boost/network/protocol/http/message/wrappers/source.hpp +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_SOURCE_HPP_20100622 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_SOURCE_HPP_20100622 - -// Copyright 2010 (c) Dean Michael Berris -// 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) - -#include - -namespace boost { namespace network { namespace http { - - template - struct basic_response; - - template - struct basic_request; - - BOOST_NETWORK_DEFINE_HTTP_WRAPPER(source, source, source); - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_SOURCE_HPP_20100622 diff --git a/boost/network/protocol/http/message/wrappers/status.hpp b/boost/network/protocol/http/message/wrappers/status.hpp index 2fc860a94..4c06a6eab 100644 --- a/boost/network/protocol/http/message/wrappers/status.hpp +++ b/boost/network/protocol/http/message/wrappers/status.hpp @@ -11,39 +11,22 @@ namespace boost { namespace network { namespace http { - template - struct basic_response; - - namespace impl { - - template - struct status_wrapper { - - basic_response const & response_; - - explicit status_wrapper(basic_response const & response) - : response_(response) {} - - status_wrapper(status_wrapper const & other) - : response_(other.response_) {} - - operator boost::uint16_t () { - return response_.status(); - } - - }; - - } // namespace impl - - template - struct Response; - - template - inline - impl::status_wrapper - status(basic_response const & response) { - return impl::status_wrapper(response); - } +namespace impl { + +struct status_wrapper { + explicit status_wrapper(response_base & response_); + operator std::string () const; + private: + response_base & response_; +}; + +} // namespace impl + +inline +impl::status_wrapper +status(response_base & response) { + return impl::status_wrapper(response); +} } // namespace http diff --git a/boost/network/protocol/http/message/wrappers/status_message.hpp b/boost/network/protocol/http/message/wrappers/status_message.hpp index 99f29658d..a7c19165c 100644 --- a/boost/network/protocol/http/message/wrappers/status_message.hpp +++ b/boost/network/protocol/http/message/wrappers/status_message.hpp @@ -7,40 +7,31 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -namespace boost { namespace network { namespace http { - - template - struct basic_response; - - namespace impl { - - template - struct status_message_wrapper { +#include - typedef typename string::type string_type; - - basic_response const & response_; - - explicit status_message_wrapper(basic_response const & response) - : response_(response) {} +namespace boost { namespace network { namespace http { - status_message_wrapper(status_message_wrapper const & other) - : response_(other.response_) {} +namespace impl { - operator string_type () { - return response_.status_message(); - } +struct status_message_wrapper { + explicit status_message_wrapper(response_base & response_); + operator std::string () const; + private: + response_base & response_; + mutable optional cache_; +}; - }; +inline std::ostream & operator<<(std::ostream & os, status_message_wrapper const & status_message) { + return os << static_cast(status_message); +} - } // namespace impl +} // namespace impl - template - inline - impl::status_message_wrapper - status_message(basic_response const & response) { - return impl::status_message_wrapper(response); - } +inline +impl::status_message_wrapper +status_message(response_base & response) { + return impl::status_message_wrapper(response); +} } // namespace http diff --git a/boost/network/protocol/http/message/wrappers/uri.hpp b/boost/network/protocol/http/message/wrappers/uri.hpp index 622d53a4a..222f24e09 100644 --- a/boost/network/protocol/http/message/wrappers/uri.hpp +++ b/boost/network/protocol/http/message/wrappers/uri.hpp @@ -8,33 +8,27 @@ // http://www.boost.org/LICENSE_1_0.txt) #include +#include namespace boost { namespace network { namespace http { - template - struct basic_request; - - namespace impl { - template - struct uri_wrapper { - basic_request const & message_; - uri_wrapper(basic_request const & message) - : message_(message) {} - typedef typename basic_request::string_type string_type; - operator string_type() { - return message_.uri().raw(); - } - operator boost::network::uri::basic_uri::type> () { - return message_.uri(); - } - }; - } - - template inline - impl::uri_wrapper - uri(basic_request const & request) { - return impl::uri_wrapper(request); - } +namespace impl { + +struct uri_wrapper { + explicit uri_wrapper(request_base & request_); + operator std::string() const; + operator boost::network::uri::uri() const; + private: + request_base & request_; +}; + +} // namespace impl + +inline +impl::uri_wrapper +uri(request_base & request) { + return impl::uri_wrapper(request); +} } // namespace http diff --git a/boost/network/protocol/http/message/wrappers/version.hpp b/boost/network/protocol/http/message/wrappers/version.hpp index b3e16d2fc..6b8f0b7d3 100644 --- a/boost/network/protocol/http/message/wrappers/version.hpp +++ b/boost/network/protocol/http/message/wrappers/version.hpp @@ -9,38 +9,27 @@ namespace boost { namespace network { namespace http { - template - struct basic_response; - - namespace impl { - - template - struct version_wrapper { - - typedef typename string::type string_type; - - basic_response const & response_; - - explicit version_wrapper(basic_response const & response) - : response_(response) {} - - version_wrapper(version_wrapper const & other) - : response_(other.response_) {} - - operator string_type () { - return response_.version(); - } - - }; - - } // namespace impl - - template - inline - impl::version_wrapper - version(basic_response const & response) { - return impl::version_wrapper(response); - } +namespace impl { + +struct version_wrapper { + explicit version_wrapper(response_base & response_); + operator std::string() const; + private: + response_base & response_; + mutable optional cache_; +}; + +inline std::ostream & operator<< (std::ostream & os, version_wrapper const & version) { + return os << static_cast(version); +} + +} // namespace impl + +inline +impl::version_wrapper +version(response_base & response) { + return impl::version_wrapper(response); +} } // namespace http diff --git a/boost/network/protocol/http/request.hpp b/boost/network/protocol/http/request.hpp index ef5927ba5..7b10f5586 100644 --- a/boost/network/protocol/http/request.hpp +++ b/boost/network/protocol/http/request.hpp @@ -29,15 +29,9 @@ #include #include #include -#include -#include -#include -#include #include #include #include -#include -#include #include #include diff --git a/boost/network/protocol/http/response.hpp b/boost/network/protocol/http/response.hpp index bf9a00005..080ba77f8 100644 --- a/boost/network/protocol/http/response.hpp +++ b/boost/network/protocol/http/response.hpp @@ -9,6 +9,8 @@ #include +struct response_base; + #include #include #include @@ -18,61 +20,16 @@ #include #include #include -#include -#include -#include -#include #include #include #include -#include -#include #include -#include -#include #include namespace boost { namespace network { namespace http { - template - struct basic_response : public message_base::type { - - typedef typename string::type string_type; - - private: - typedef typename message_base::type base_type; - - public: - - typedef Tag tag; - - basic_response() - : base_type() - {} - - basic_response(basic_response const & other) - : base_type(other) - {} - - basic_response & operator=(basic_response rhs) { - rhs.swap(*this); - return *this; - }; - - void swap(basic_response & other) { - base_type & base_ref(other), - & this_ref(*this); - std::swap(this_ref, base_ref); - }; - }; - - template - inline void swap(basic_response & lhs, basic_response & rhs) { - lhs.swap(rhs); - } - } // namespace http } // namespace network diff --git a/boost/network/protocol/http/response_concept.hpp b/boost/network/protocol/http/response_concept.hpp index 9d067532d..25094ca40 100644 --- a/boost/network/protocol/http/response_concept.hpp +++ b/boost/network/protocol/http/response_concept.hpp @@ -23,9 +23,9 @@ namespace boost { namespace network { namespace http { R response_; swap(response, response_); // swappable via ADL - typedef typename traits::version::type version_type; - typedef typename traits::status::type status_type; - typedef typename traits::status_message::type status_message_type; + typedef std::string version_type; + typedef std::string status_type; + typedef std::string status_message_type; response << version(version_type()) // version directive << status(status_type()) // status directive diff --git a/boost/network/protocol/http/server/impl/parsers.ipp b/boost/network/protocol/http/server/impl/parsers.ipp index e39c7b26d..848b0fc4d 100644 --- a/boost/network/protocol/http/server/impl/parsers.ipp +++ b/boost/network/protocol/http/server/impl/parsers.ipp @@ -35,7 +35,7 @@ namespace boost { namespace network { namespace http { , version_pair); } - BOOST_NETWORK_INLINE void parse_headers(std::string const & input, std::vector & container) { + BOOST_NETWORK_INLINE void parse_headers(std::string const & input, std::vector & container) { using namespace boost::spirit::qi; parse( input.begin(), input.end(), From d0ad12298162c69240a38c3796a1cebdea85a076 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Fri, 30 Sep 2011 17:37:11 +1000 Subject: [PATCH 009/196] Minimal interface required for responses. --- boost/network/protocol/http/response_base.hpp | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 boost/network/protocol/http/response_base.hpp diff --git a/boost/network/protocol/http/response_base.hpp b/boost/network/protocol/http/response_base.hpp new file mode 100644 index 000000000..284ca7a3f --- /dev/null +++ b/boost/network/protocol/http/response_base.hpp @@ -0,0 +1,27 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_BASE_HPP_20110930 +#define BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_BASE_HPP_20110930 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +namespace boost { namespace network { namespace http { + +struct response_base : message_base { + virtual void set_status(std::string const & new_status) = 0; + virtual void set_status_message(std::string const & new_status_message) = 0; + virtual void set_version(std::string const & new_version) = 0; + virtual ~response_base() = 0; +}; + +response_base::~response_base() {} + +} /* http */ + +} /* network */ + +} /* boost */ + +#endif /* BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_BASE_HPP_20110930 */ From b1cfe58bc65ab11043f199a2ebf86fcb1a3ba185 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sat, 8 Oct 2011 16:19:13 +1100 Subject: [PATCH 010/196] WIP: Ongoing refactoring... --- boost/network/constants.hpp | 169 +++--------------- boost/network/constants.ipp | 126 +++++++++++++ boost/network/protocol/http/client.hpp | 10 +- .../protocol/http/client/async_impl.hpp | 94 ---------- boost/network/protocol/http/client/base.hpp | 48 +++++ boost/network/protocol/http/client/base.ipp | 112 ++++++++++++ .../http/client/connection_manager.hpp | 10 +- boost/network/protocol/http/client/facade.hpp | 40 ++--- .../http/message/modifiers/clear_headers.hpp | 46 ----- .../http/message/modifiers/method.hpp | 13 +- .../protocol/http/message/wrappers/body.hpp | 71 -------- .../http/message/wrappers/headers.hpp | 126 ------------- .../protocol/http/message/wrappers/method.hpp | 36 ++-- boost/network/protocol/http/request.hpp | 68 +++++-- boost/network/protocol/http/request.ipp | 68 +------ boost/network/protocol/http/request_base.hpp | 67 +++++++ boost/network/protocol/http/response.hpp | 39 +++- 17 files changed, 506 insertions(+), 637 deletions(-) create mode 100644 boost/network/constants.ipp delete mode 100644 boost/network/protocol/http/client/async_impl.hpp create mode 100644 boost/network/protocol/http/client/base.hpp create mode 100644 boost/network/protocol/http/client/base.ipp delete mode 100644 boost/network/protocol/http/message/modifiers/clear_headers.hpp delete mode 100644 boost/network/protocol/http/message/wrappers/body.hpp delete mode 100644 boost/network/protocol/http/message/wrappers/headers.hpp create mode 100644 boost/network/protocol/http/request_base.hpp diff --git a/boost/network/constants.hpp b/boost/network/constants.hpp index 3f03d6d6c..12d7e33b3 100644 --- a/boost/network/constants.hpp +++ b/boost/network/constants.hpp @@ -6,149 +6,36 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include - namespace boost { namespace network { - namespace impl { - template - struct constants_narrow { - - static char const * crlf() { - static char crlf_[] = { '\r', '\n', 0 }; - return crlf_; - } - - static char const * dot() { - static char dot_[] = { '.', 0 }; - return dot_; - } - - static char dot_char() { return '.'; } - - static char const * http_slash() { - static char http_slash_[] = { 'H', 'T', 'T', 'P', '/', 0 }; - return http_slash_; - } - - static char const * space() { - static char space_[] = {' ', 0}; - return space_; - } - - static char space_char() { return ' '; } - - static char const * slash() { - static char slash_[] = {'/', 0}; - return slash_; - } - - static char slash_char() { return '/'; } - - static char const * host() { - static char host_[] = {'H', 'o', 's', 't', 0}; - return host_; - } - - static char const * colon() { - static char colon_[] = {':', 0}; - return colon_; - } - - static char colon_char() { return ':'; } - - static char const * accept() { - static char accept_[] = {'A', 'c', 'c', 'e', 'p', 't', 0}; - return accept_; - } - - static char const * default_accept_mime() { - static char mime_[] = { - '*', '/', '*', 0 - }; - return mime_; - } - - static char const * accept_encoding() { - static char accept_encoding_[] = { - 'A','c','c','e','p','t','-','E','n','c','o','d','i','n','g',0 - }; - return accept_encoding_; - } - - static char const * default_accept_encoding() { - static char default_accept_encoding_[] = { - 'i','d','e','n','t','i','t','y',';','q','=','1','.','0',',',' ','*',';','q','=','0',0 - }; - return default_accept_encoding_; - } - - static char const * user_agent() { - static char user_agent_[] = { - 'U','s','e','r','-','A','g','e','n','t',0 - }; - return user_agent_; - } - - static char const * cpp_netlib_slash() { - static char cpp_netlib_slash_[] = { - 'c','p','p','-','n','e','t','l','i','b','/',0 - }; - return cpp_netlib_slash_; - } - - static char question_mark_char() { - return '?'; - } - - static char hash_char() { - return '#'; - } - - static char const * connection() { - static char connection_[] = { - 'C','o','n','n','e','c','t','i','o','n',0 - }; - return connection_; - } - - static char const * close() { - static char close_[] = { - 'C','l','o','s','e', 0 - }; - return close_; - } - - static char const * https() { - static char https_[] = "https"; - return https_; - } - - }; - - template - struct constants_wide { - - static wchar_t const * https() { - static wchar_t https_[] = L"https"; - return https_; - } - - }; - } - - template - struct constants : - mpl::if_< - is_default_string, - impl::constants_narrow, - typename mpl::if_< - is_default_wstring, - impl::constants_wide, - unsupported_tag - >::type - >::type - {}; +struct constants { + static char const * crlf(); + static char const * dot(); + static char dot_char(); + static char const * http_slash(); + static char const * space(); + static char space_char(); + static char const * slash(); + static char slash_char(); + static char const * host(); + static char const * colon(); + static char colon_char(); + static char const * accept(); + static char const * default_accept_mime(); + static char const * accept_encoding(); + static char const * default_accept_encoding(); + static char const * user_agent(); + static char const * cpp_netlib_slash(); + static char question_mark_char(); + static char hash_char(); + static char const * connection(); + static char const * close(); + static char const * https(); +}; + +#ifdef BOOST_NETWORK_NO_LIB +#include +#endif } // namespace network diff --git a/boost/network/constants.ipp b/boost/network/constants.ipp new file mode 100644 index 000000000..86ac0ffc8 --- /dev/null +++ b/boost/network/constants.ipp @@ -0,0 +1,126 @@ +#ifndef BOOST_NETWORK_CONSTANTS_HPP_20111008 +#define BOOST_NETWORK_CONSTANTS_HPP_20111008 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +namespace boost { namespace network { + +char const * constants::crlf() { + static char crlf_[] = { '\r', '\n', 0 }; + return crlf_; +} + +char const * constants::dot() { + static char dot_[] = { '.', 0 }; + return dot_; +} + +char constants::dot_char() { return '.'; } + +char const * constants::http_slash() { + static char http_slash_[] = { 'H', 'T', 'T', 'P', '/', 0 }; + return http_slash_; +} + +char const * constants::space() { + static char space_[] = {' ', 0}; + return space_; +} + +char constants::space_char() { return ' '; } + +char const * constants::slash() { + static char slash_[] = {'/', 0}; + return slash_; +} + +char constants::slash_char() { return '/'; } + +char const * constants::host() { + static char host_[] = {'H', 'o', 's', 't', 0}; + return host_; +} + +char const * constants::colon() { + static char colon_[] = {':', 0}; + return colon_; +} + +char constants::colon_char() { return ':'; } + +char const * constants::accept() { + static char accept_[] = {'A', 'c', 'c', 'e', 'p', 't', 0}; + return accept_; +} + +char const * constants::default_accept_mime() { + static char mime_[] = { + '*', '/', '*', 0 + }; + return mime_; +} + +char const * constants::accept_encoding() { + static char accept_encoding_[] = { + 'A','c','c','e','p','t','-','E','n','c','o','d','i','n','g',0 + }; + return accept_encoding_; +} + +char const * constants::default_accept_encoding() { + static char default_accept_encoding_[] = { + 'i','d','e','n','t','i','t','y',';','q','=','1','.','0',',',' ','*',';','q','=','0',0 + }; + return default_accept_encoding_; +} + +char const * constants::user_agent() { + static char user_agent_[] = { + 'U','s','e','r','-','A','g','e','n','t',0 + }; + return user_agent_; +} + +char const * constants::cpp_netlib_slash() { + static char cpp_netlib_slash_[] = { + 'c','p','p','-','n','e','t','l','i','b','/',0 + }; + return cpp_netlib_slash_; +} + +char constants::question_mark_char() { + return '?'; +} + +char constants::hash_char() { + return '#'; +} + +char const * constants::connection() { + static char connection_[] = { + 'C','o','n','n','e','c','t','i','o','n',0 + }; + return connection_; +} + +char const * constants::close() { + static char close_[] = { + 'C','l','o','s','e', 0 + }; + return close_; +} + +char const * constants::https() { + static char https_[] = "https"; + return https_; +} + +} /* network */ + +} /* boost */ + +#endif /* BOOST_NETWORK_CONSTANTS_HPP_20111008 */ diff --git a/boost/network/protocol/http/client.hpp b/boost/network/protocol/http/client.hpp index 2d45ff2df..85c3bb583 100644 --- a/boost/network/protocol/http/client.hpp +++ b/boost/network/protocol/http/client.hpp @@ -12,18 +12,18 @@ #include #include #include +#include +#include namespace boost { namespace network { namespace http { -template -struct basic_client : basic_client_facade { +struct client : basic_client_facade { private: typedef basic_client_facade base_facade_type; public: - typedef basic_request request; - typedef basic_response response; - typedef String string_type; + typedef ::boost::network::http::request request; + typedef ::boost::network::http::response response; // Constructor // ================================================================= diff --git a/boost/network/protocol/http/client/async_impl.hpp b/boost/network/protocol/http/client/async_impl.hpp deleted file mode 100644 index 2fbd5d488..000000000 --- a/boost/network/protocol/http/client/async_impl.hpp +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_ASYNC_IMPL_HPP_20100623 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_ASYNC_IMPL_HPP_20100623 - -// Copyright Dean Michael Berris 2010. -// Copyright 2011 Dean Michael Berris (dberris@google.com). -// Copyright 2011 Google, Inc. -// 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) - -#include -#include -#include -#include - -namespace boost { namespace network { namespace http { - - template - struct basic_client_impl; - - namespace impl { - template - struct async_client - { - typedef - typename string::type - string_type; - - typedef - function const &, system::error_code const &)> - body_callback_function_type; - - async_client(shared_ptr connection_manager) - : service_ptr(new boost::asio::io_service), - service_(*service_ptr), - sentinel_(new boost::asio::io_service::work(service_)), - connection_manager_(connection_manager) - { - lifetime_thread_.reset(new boost::thread( - boost::bind( - &boost::asio::io_service::run, - &service_ - ))); - } - - async_client(boost::asio::io_service & service, - shared_ptr connection_manager) - : service_ptr(0), - service_(service), - sentinel_(new boost::asio::io_service::work(service_)), - connection_manager_(connection_manager) - { - } - - ~async_client() throw () - { - sentinel_.reset(); - connection_manager_->reset(); - if (lifetime_thread_.get()) { - lifetime_thread_->join(); - lifetime_thread_.reset(); - } - delete service_ptr; - } - - basic_response const request_skeleton( - basic_request const & request_, - string_type const & method, - bool get_body, - body_callback_function_type callback - ) - { - shared_ptr connection_; - connection_ = connection_manager_->get_connection(service_, request_); - shared_ptr response = connection_->send_request( - method, request_, get_body, callback); - return *response; - } - - boost::asio::io_service * service_ptr; - boost::asio::io_service & service_; - boost::shared_ptr sentinel_; - boost::shared_ptr lifetime_thread_; - shared_ptr connection_manager_; - }; - } // namespace impl - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_ASYNC_IMPL_HPP_20100623 diff --git a/boost/network/protocol/http/client/base.hpp b/boost/network/protocol/http/client/base.hpp new file mode 100644 index 000000000..7e3eff5bc --- /dev/null +++ b/boost/network/protocol/http/client/base.hpp @@ -0,0 +1,48 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_BASE_HPP_20111008 +#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_BASE_HPP_20111008 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include +#include +#include +#include +#include +#include + +namespace boost { namespace network { namespace http { + +struct client_base_pimpl; + +struct client_base { + typedef + function const &, system::error_code const &)> + body_callback_function_type; + + client_base(shared_ptr connection_manager_); + client_base(asio::io_service & service, + shared_ptr connection_manager_); + ~client_base(); + response const request_skeleton(request_base const & request_, + std::string const & method, + bool get_body, + body_callback_function_type callback); + private: + client_base_pimpl * pimpl; +}; + +} /* http */ + +} /* network */ + +} /* boost */ + +#ifdef BOOST_NETWORK_NO_LIB +#include +#endif + +#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_BASE_HPP_20111008 */ diff --git a/boost/network/protocol/http/client/base.ipp b/boost/network/protocol/http/client/base.ipp new file mode 100644 index 000000000..8140f67e4 --- /dev/null +++ b/boost/network/protocol/http/client/base.ipp @@ -0,0 +1,112 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_ASYNC_IMPL_HPP_20100623 +#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_ASYNC_IMPL_HPP_20100623 + +// Copyright 2011 Dean Michael Berris (dberris@google.com). +// Copyright 2011 Google, Inc. +// 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) + +#include +#include +#include +#include +#include + +namespace boost { namespace network { namespace http { + +struct client_base_pimpl { + typedef + function const &, system::error_code const &)> + body_callback_function_type; + client_base_pimpl(shared_ptr connection_manager_); + client_base_pimpl(io_service & service, shared_ptr connection_manager_); + response const request_skeleton(request const & request_, + std::string const & method, + bool get_body, + body_callback_function_type callback); + ~client_base_pimpl(); + private: + boost::asio::io_service * service_ptr; + boost::asio::io_service & service_; + boost::shared_ptr sentinel_; + boost::shared_ptr lifetime_thread_; + shared_ptr connection_manager_; +}; + +client_base::client_base(shared_ptr connection_manager_) +: pimpl(new (std::nothrow) client_base_pimpl(connection_manager_)) +{} + +client_base::client_base(asio::io_service & service, + shared_ptr connection_manager_) +: pimpl(new (std::nothrow) client_base_pimpl(service, connection_manager_)) +{} + +response const client_base::request_skeleton(request_base const & request_, + std::string const & method, + bool get_body, + body_callback_function_type callback) { + return pimpl->request_skeleton(request_, method, get_body, callback); +} + +client_base::~client_base() { + delete pimpl; +} + +client_base_pimpl::client_base_pimpl(shared_ptr connection_manager) + : service_ptr(new (std::nothrow) boost::asio::io_service), + service_(*service_ptr), + sentinel_(new (std::nothrow) boost::asio::io_service::work(service_)), + connection_manager_(connection_manager) +{ + lifetime_thread_.reset(new (std::nothrow) boost::thread( + boost::bind( + &boost::asio::io_service::run, + &service_ + ))); + if (!lifetime_thread_.get()) + BOOST_THROW_EXCEPTION(std::runtime_error("Cannot allocate client lifetime thread; not enough memory.")); +} + +client_base_pimpl::client_base_pimpl(boost::asio::io_service & service, + shared_ptr connection_manager) + : service_ptr(0), + service_(service), + sentinel_(new (std::nothrow) boost::asio::io_service::work(service_)), + connection_manager_(connection_manager) +{ + if (!sentinel_.get()) + BOOST_THROW_EXCEPTION(std::runtime_error("Cannot allocate sentinel; not enough memory.")); +} + +~client_base_pimpl::client_base_pimpl() +{ + sentinel_.reset(); + connection_manager_->reset(); + if (lifetime_thread_.get()) { + lifetime_thread_->join(); + lifetime_thread_.reset(); + } + delete service_ptr; +} + +response const client_base_pimpl::request_skeleton( + request const & request_, + std::string const & method, + bool get_body, + body_callback_function_type callback + ) +{ + shared_ptr connection_; + connection_ = connection_manager_->get_connection(service_, request_); + return connection_->send_request(method, request_, get_body, callback); +} + +} // namespace http + +} // namespace network + +} // namespace boost + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_ASYNC_IMPL_HPP_20100623 diff --git a/boost/network/protocol/http/client/connection_manager.hpp b/boost/network/protocol/http/client/connection_manager.hpp index aca063ee8..ee5dd7eb2 100644 --- a/boost/network/protocol/http/client/connection_manager.hpp +++ b/boost/network/protocol/http/client/connection_manager.hpp @@ -11,16 +11,16 @@ namespace boost { namespace network { namespace http { struct request_base; -struct response_base; +struct response; struct client_connection { typedef function const &, system::error_code const &)> callback_type; - virtual shared_ptr send_request(std::string const & method, - request_base const & request, - bool get_body, - callback_type callback) = 0; + virtual response send_request(std::string const & method, + request_base const & request, + bool get_body, + callback_type callback) = 0; virtual void reset() = 0; virtual ~client_connection() = 0; }; diff --git a/boost/network/protocol/http/client/facade.hpp b/boost/network/protocol/http/client/facade.hpp index a47f78c7b..6faae3497 100644 --- a/boost/network/protocol/http/client/facade.hpp +++ b/boost/network/protocol/http/client/facade.hpp @@ -8,29 +8,17 @@ #include #include -#include +#include #include namespace boost { namespace network { namespace http { -template -struct basic_request; - -template -struct basic_response; - -template struct basic_client_facade { - - typedef typename string::type string_type; - typedef basic_request request; - typedef basic_response response; - typedef basic_client_impl pimpl_type; - typedef function const &,system::error_code const &)> body_callback_function_type; + typedef client_base::body_callback_function_type body_callback_function_type; template basic_client_facade(ArgPack const & args) { - init_pimpl(args, + init_base(args, typename mpl::if_< is_same< typename parameter::value_type::type, @@ -42,7 +30,7 @@ struct basic_client_facade { } BOOST_PARAMETER_MEMBER_FUNCTION((response const), head, tag, (required (request,(request const &)))) { - return pimpl->request_skeleton(request, "HEAD", false, body_callback_function_type()); + return base->request_skeleton(request, "HEAD", false, body_callback_function_type()); } BOOST_PARAMETER_MEMBER_FUNCTION((response const), get , tag, @@ -52,7 +40,7 @@ struct basic_client_facade { (optional (body_handler,(body_callback_function_type),body_callback_function_type()) )) { - return pimpl->request_skeleton(request, "GET", true, body_handler); + return base->request_skeleton(request, "GET", true, body_handler); } BOOST_PARAMETER_MEMBER_FUNCTION((response const), post, tag, @@ -83,7 +71,7 @@ struct basic_client_facade { request << header("Content-Type", content_type); } } - return pimpl->request_skeleton(request, "POST", true, body_handler); + return base->request_skeleton(request, "POST", true, body_handler); } BOOST_PARAMETER_MEMBER_FUNCTION((response const), put , tag, @@ -114,7 +102,7 @@ struct basic_client_facade { request << header("Content-Type", content_type); } } - return pimpl->request_skeleton(request, "PUT", true, body_handler); + return base->request_skeleton(request, "PUT", true, body_handler); } BOOST_PARAMETER_MEMBER_FUNCTION((response const), delete_, tag, @@ -124,11 +112,11 @@ struct basic_client_facade { (optional (body_handler,(body_callback_function_type),body_callback_function_type()) )) { - return pimpl->request_skeleton(request, "DELETE", true, body_handler); + return base->request_skeleton(request, "DELETE", true, body_handler); } void clear_resolved_cache() { - pimpl->clear_resolved_cache(); + base->clear_resolved_cache(); } protected: @@ -136,16 +124,16 @@ struct basic_client_facade { struct no_io_service {}; struct has_io_service {}; - boost::scoped_ptr pimpl; + boost::scoped_ptr base; template - void init_pimpl(ArgPack const & args, no_io_service) { - pimpl.reset(new pimpl_type(this->get_connection_manager(args))); + void init_base(ArgPack const & args, no_io_service) { + base.reset(new base_type(this->get_connection_manager(args))); } template - void init_pimpl(ArgPack const & args, has_io_service) { - pimpl.reset(new pimpl_type(args[_io_service], this->get_connection_manager(args))); + void init_base(ArgPack const & args, has_io_service) { + base.reset(new base_type(args[_io_service], this->get_connection_manager(args))); } private: diff --git a/boost/network/protocol/http/message/modifiers/clear_headers.hpp b/boost/network/protocol/http/message/modifiers/clear_headers.hpp deleted file mode 100644 index 8cf2806aa..000000000 --- a/boost/network/protocol/http/message/modifiers/clear_headers.hpp +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_CLEAR_HEADER_HPP_20101128 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_CLEAR_HEADER_HPP_20101128 - -// Copyright 2010 Dean Michael Berris. -// 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) - -#include - -namespace boost { namespace network { namespace http { - - template - inline void clear_headers_impl(basic_request & request, tags::pod) { - typedef typename basic_request::headers_container_type headers_container; - headers_container().swap(request.headers); - } - - template - inline void clear_headers_impl(basic_request & request, tags::normal) { - request.headers(typename basic_request::headers_container_type()); - } - - template - inline void clear_headers_impl(basic_request & request, tags::client) { - clear_headers_impl(request, typename pod_or_normal::type()); - } - - template - inline void clear_headers_impl(basic_request & request, tags::server) { - typedef typename basic_request::headers_container_type headers_container; - headers_container().swap(request.headers); - } - - template - inline void clear_headers(basic_request & request) { - clear_headers_impl(request, typename client_or_server::type()); - } - -} /* http */ - -} /* network */ - -} /* boost */ - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_CLEAR_HEADER_HPP_20101128 */ diff --git a/boost/network/protocol/http/message/modifiers/method.hpp b/boost/network/protocol/http/message/modifiers/method.hpp index bc23dc78d..f2101479a 100644 --- a/boost/network/protocol/http/message/modifiers/method.hpp +++ b/boost/network/protocol/http/message/modifiers/method.hpp @@ -6,18 +6,13 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { - template - struct basic_request; - - template - inline typename enable_if, void>::type - method(basic_request & request, typename string::type const & method_) { - request.method = method_; - } +inline void method(request_base & request, std::string const & method_) { + request.set_method(method_); +} } /* http */ diff --git a/boost/network/protocol/http/message/wrappers/body.hpp b/boost/network/protocol/http/message/wrappers/body.hpp deleted file mode 100644 index 068ab38a9..000000000 --- a/boost/network/protocol/http/message/wrappers/body.hpp +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_BODY_HPP_20100622 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_BODY_HPP_20100622 - -// Copyright 2010 (c) Dean Michael Berris -// 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) - -namespace boost { namespace network { namespace http { - - template - struct basic_response; - - template - struct basic_request; - - namespace impl { - - template - struct body_wrapper { - typedef typename string::type string_type; - Message const & message_; - explicit body_wrapper(Message const & message) - : message_(message) {} - body_wrapper(body_wrapper const & other) - : message_(other.message_) {} - - operator string_type () const { - return message_.body(); - } - - size_t size() const { - return message_.body().size(); - } - - boost::iterator_range - range() const - { - return boost::make_iterator_range(message_.body()); - } - }; - - template - inline std::ostream & operator<<(std::ostream & os, body_wrapper const & body) { - os << static_cast::string_type>(body); - return os; - } - - } // namespace impl - - template - inline - typename impl::body_wrapper > - body(basic_response const & message) { - return impl::body_wrapper >(message); - } - - template - inline - typename impl::body_wrapper > - body(basic_request const & message) { - return impl::body_wrapper >(message); - } - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_BODY_HPP_20100622 diff --git a/boost/network/protocol/http/message/wrappers/headers.hpp b/boost/network/protocol/http/message/wrappers/headers.hpp deleted file mode 100644 index 0b9a13b13..000000000 --- a/boost/network/protocol/http/message/wrappers/headers.hpp +++ /dev/null @@ -1,126 +0,0 @@ - -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPER_HEADERS_HPP_20100811 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPER_HEADERS_HPP_20100811 - -// Copyright Dean Michael Berris 2010. -// 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) - -namespace boost { namespace network { namespace http { - - template - struct headers_range { - typedef typename headers_container::type headers_container_type; - typedef typename boost::iterator_range type; - }; - - template - struct basic_request; - - template - struct basic_response; - - namespace impl { - - template - struct request_headers_wrapper { - typedef typename string::type string_type; - typedef typename headers_range >::type range_type; - typedef typename headers_container::type headers_container_type; - typedef typename headers_container_type::const_iterator const_iterator; - typedef typename headers_container_type::iterator iterator; - - explicit request_headers_wrapper(basic_request const & message) - : message_(message) - {} - - range_type operator[] (string_type const & key) const { - return message_.headers().equal_range(key); - } - - typename headers_container_type::size_type count(string_type const & key) const { - return message_.headers().count(key); - } - - const_iterator begin() const { - return message_.headers().begin(); - } - - const_iterator end() const { - return message_.headers().end(); - } - - operator range_type () { - return make_iterator_range(message_.headers().begin(), message_.headers().end()); - } - - operator headers_container_type () { - return message_.headers(); - } - - private: - basic_request const & message_; - }; - - template - struct response_headers_wrapper { - typedef typename string::type string_type; - typedef typename headers_range >::type range_type; - typedef typename headers_container::type headers_container_type; - typedef typename headers_container_type::const_iterator const_iterator; - typedef typename headers_container_type::iterator iterator; - - explicit response_headers_wrapper(basic_response const & message) - : message_(message) - {} - - range_type operator[] (string_type const & key) const { - return message_.headers().equal_range(key); - } - - typename headers_container_type::size_type count(string_type const & key) const { - return message_.headers().count(key); - } - - const_iterator begin() const { - return message_.headers().begin(); - } - - const_iterator end() const { - return message_.headers().end(); - } - - operator range_type () { - return make_iterator_range(message_.headers().begin(), message_.headers().end()); - } - - operator headers_container_type () { - return message_.headers(); - } - - private: - basic_response const & message_; - }; - - } // namespace impl - - template - inline impl::request_headers_wrapper - headers(basic_request const & request_) { - return impl::request_headers_wrapper(request_); - } - - template - inline impl::response_headers_wrapper - headers(basic_response const & response_) { - return impl::response_headers_wrapper(response_); - } - -} // namepace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPER_HEADERS_HPP_20100811 diff --git a/boost/network/protocol/http/message/wrappers/method.hpp b/boost/network/protocol/http/message/wrappers/method.hpp index 8edb98692..a122a5b2b 100644 --- a/boost/network/protocol/http/message/wrappers/method.hpp +++ b/boost/network/protocol/http/message/wrappers/method.hpp @@ -6,33 +6,21 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include +#include namespace boost { namespace network { namespace http { - template - struct basic_request; - - template - struct method_wrapper { - explicit method_wrapper(basic_request const & message) - : message_(message) {} - - basic_request const & message_; - - typedef typename basic_request::string_type string_type; - - operator string_type() { - return message_.method; - } - }; - - template - inline typename enable_if, typename string::type >::type - method(basic_request const & message) { - return method_wrapper(message); - } +struct method_wrapper { + explicit method_wrapper(request_base & message); + operator std::string () const; + private: + request_base & message_; +}; + +inline method_wrapper const +method(request_base & message) { + return method_wrapper(message); +} } /* http */ diff --git a/boost/network/protocol/http/request.hpp b/boost/network/protocol/http/request.hpp index 7b10f5586..2a42d60a1 100644 --- a/boost/network/protocol/http/request.hpp +++ b/boost/network/protocol/http/request.hpp @@ -10,17 +10,16 @@ #include +#include #include #include #include #include -#include #include #include #include #include #include -#include #include #include #include @@ -29,30 +28,59 @@ #include #include #include -#include #include #include #include #include -// forward declarations namespace boost { namespace network { namespace http { -struct request_base; - -template -struct basic_request; - -} // namespace http - -} // namespace network - -} // namespace boost - -#include - -namespace boost { namespace network { namespace http { +struct request_pimpl; + +struct request : request_base { + // FIXME Implement all these! + + // From message_base... + // Mutators + virtual void set_destination(std::string const & destination); + virtual void set_source(std::string const & source); + virtual void append_header(std::string const & name, + std::string const & value); + virtual void remove_headers(std::string const & name); + virtual void remove_headers(); + virtual void set_body(std::string const & body); + virtual void append_body(std::string const & data); + + // Retrievers + virtual void get_destination(std::string & destination); + virtual void get_source(std::string & source); + virtual void get_headers(function inserter); + virtual void get_headers(std::string const & name, function inserter); + virtual void get_headers(function predicate, function inserter); + virtual void get_body(std::string const & body); + virtual void get_body(function)> chunk_reader, size_t size); + + // From request_base... + // Setters + virtual void set_method(std::string const & method); + virtual void set_status(std::string const & status); + virtual void set_status_message(std::string const & status_message); + virtual void set_uri(std::string const &uri); + virtual void set_uri(network::uri::uri const &uri); + + // Getters + virtual void get_uri(network::uri::uri &uri); + virtual void get_uri(std::string &uri); + virtual void get_method(std::string & method); + virtual void get_status(std::string & status); + virtual void get_status_message(std::string & status_message); + virtual void get_body_stream(body_stream & output_stream) = 0; + + virtual ~request(); + private: + request_pimpl * pimpl_; +}; template request_base & operator<< (request_base & request, @@ -67,6 +95,10 @@ request_base & operator<< (request_base & request, } // namespace boost +#ifdef BOOST_NETWORK_NO_LIB +#include +#endif + #include #endif // __NETWORK_PROTOCOL_HTTP_REQUEST_20070908-1_HPP__ diff --git a/boost/network/protocol/http/request.ipp b/boost/network/protocol/http/request.ipp index cace3fccb..d34cb7581 100644 --- a/boost/network/protocol/http/request.ipp +++ b/boost/network/protocol/http/request.ipp @@ -7,72 +7,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_NETWORK_BUFFER_CHUNK -#define BOOST_NETWORK_BUFFER_CHUNK 1024 // We want 1KiB worth of data at least. -#endif - -namespace boost { namespace network { namespace http { - -struct body_source : iostreams::source { - virtual std::streamsize read(char * buffer, std::streamsize size); - virtual ~body_source(); -}; - -struct request_storage_base { - typedef iostreams::stream body_stream; - protected: - // TODO Implement a segmented storage base which efficiently supports - // efficient memory usage that makes sense for HTTP payload. The idea is - // to expose the internal (segmented) storage to the client implementation - // so that raw buffers of formatted HTTP request data (which may or may not - // support delegated streams from user input -- i.e. for the body contents) - // can be efficiently sent out to the wire. This also implies that all - // thread-safety guarantees are handled by the storage base as well. - request_storage_base(size_t hint = BOOST_NETWORK_BUFFER_CHUNK); - virtual void set_status_line(std::string const &status_line); - virtual void append_header(std::string const &name, std::string const &value); -}; - -struct request_base : message_base, request_storage_base { - protected: - using request_storage_base::body_stream; - request_base(); - // Setters - virtual void set_method(std::string const & method); - virtual void set_status(std::string const & status); - virtual void set_status_message(std::string const & status_message); - virtual void append_header(std::string const &name, std::string const &value); - virtual void set_body_stream(shared_ptr stream); - - // Getters - virtual void get_method(std::string & method); - virtual void get_status(std::string & status); - virtual void get_status_message(std::string & status_message); - virtual void get_headers(function -struct basic_request : request_base { - basic_request(); - basic_request(basic_request const &); // valid copy constructor - // TODO implement a conditional move constructor - basic_request & operator=(basic_request); // valid assigment operator - String const method(); - void method(String const &); - - String const status(); - void status(String const &); - - std::multimap const & headers(); - - String const body(); - body_stream & body_stream(); -}; - +// TODO Implement the basic request proxy! #endif /* BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_IPP_20110910 */ diff --git a/boost/network/protocol/http/request_base.hpp b/boost/network/protocol/http/request_base.hpp new file mode 100644 index 000000000..2d532754a --- /dev/null +++ b/boost/network/protocol/http/request_base.hpp @@ -0,0 +1,67 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_BASE_HPP_20111008 +#define BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_BASE_HPP_20111008 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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 BOOST_NETWORK_BUFFER_CHUNK +#define BOOST_NETWORK_BUFFER_CHUNK 1024 // We want 1KiB worth of data at least. +#endif + +#include +#include +#include + +namespace boost { namespace network { namespace http { + +struct body_source : iostreams::source { + virtual std::streamsize read(char * buffer, std::streamsize size); + virtual ~body_source(); +}; + +struct request_storage_base { + typedef iostreams::stream body_stream; + protected: + // TODO Implement a segmented storage base which efficiently supports + // efficient memory usage that makes sense for HTTP payload. The idea is + // to expose the internal (segmented) storage to the client implementation + // so that raw buffers of formatted HTTP request data (which may or may not + // support delegated streams from user input -- i.e. for the body contents) + // can be efficiently sent out to the wire. This also implies that all + // thread-safety guarantees are handled by the storage base as well. + request_storage_base(size_t hint = BOOST_NETWORK_BUFFER_CHUNK); + virtual void set_status_line(std::string const &status_line); + virtual void append_header(std::string const &name, std::string const &value); + virtual ~request_storage_base(); +}; + +struct request_base : message_base, request_storage_base { + using request_storage_base::body_stream; + // Setters + virtual void set_method(std::string const & method) = 0; + virtual void set_status(std::string const & status) = 0; + virtual void set_status_message(std::string const & status_message) = 0; + virtual void set_body_stream(shared_ptr stream) = 0; + virtual void set_uri(std::string const &uri) = 0; + virtual void set_uri(network::uri::uri const &uri) = 0; + + // Getters + virtual void get_uri(network::uri::uri &uri) = 0; + virtual void get_uri(std::string &uri) = 0; + virtual void get_method(std::string & method) = 0; + virtual void get_status(std::string & status) = 0; + virtual void get_status_message(std::string & status_message) = 0; + virtual void get_body_stream(body_stream & output_stream) = 0; + virtual ~request_base() = 0; +}; + +} /* http */ + +} /* network */ + +} /* boost */ + +#endif /* BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_BASE_HPP_20111008 */ diff --git a/boost/network/protocol/http/response.hpp b/boost/network/protocol/http/response.hpp index 080ba77f8..4c7832102 100644 --- a/boost/network/protocol/http/response.hpp +++ b/boost/network/protocol/http/response.hpp @@ -9,8 +9,7 @@ #include -struct response_base; - +#include #include #include #include @@ -30,6 +29,36 @@ struct response_base; namespace boost { namespace network { namespace http { +struct response : response_base { + // FIXME implement all these! + + // From message_base... + // Mutators + virtual void set_destination(std::string const & destination); + virtual void set_source(std::string const & source); + virtual void append_header(std::string const & name, + std::string const & value); + virtual void remove_headers(std::string const & name); + virtual void remove_headers(); + virtual void set_body(std::string const & body); + virtual void append_body(std::string const & data); + + // Retrievers + virtual void get_destination(std::string & destination); + virtual void get_source(std::string & source); + virtual void get_headers(function inserter); + virtual void get_headers(std::string const & name, function inserter); + virtual void get_headers(function predicate, function inserter); + virtual void get_body(std::string const & body); + virtual void get_body(function)> chunk_reader, size_t size); + + // From response_base... + virtual void set_status(std::string const & new_status); + virtual void set_status_message(std::string const & new_status_message); + virtual void set_version(std::string const & new_version); + virtual ~response(); +}; + } // namespace http } // namespace network @@ -40,9 +69,9 @@ namespace boost { namespace network { namespace http { namespace boost { namespace network { namespace http { - template - basic_response & operator<<( - basic_response & message, + template + response & operator<<( + response & message, Directive const & directive ) { From bd41f3cff9a9f495cdd624e6862625e40ae0ed8f Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sun, 16 Oct 2011 23:57:49 +1100 Subject: [PATCH 011/196] Message Refactoring This commit gets the message tests to compile, but now the linker complains that the implementation of the stubbed out interfaces for the message implementation(s) are not available. This is a milestone which indicates that the work required to get the library into working shape would be clearer now. More work lies ahead. --- boost/network/message.hpp | 160 ++++------------ boost/network/message/directives.hpp | 13 +- .../directives/detail/string_directive.hpp | 25 +-- boost/network/message/directives/header.hpp | 16 +- .../message/directives/remove_header.hpp | 39 +--- boost/network/message/wrappers/headers.hpp | 5 +- .../protocol/http/algorithms/linearize.hpp | 25 +-- boost/network/protocol/http/client.hpp | 6 +- boost/network/protocol/http/client/base.hpp | 1 + .../http/client/connection/async_base.hpp | 1 - .../http/client/connection/async_normal.hpp | 5 - .../connection/async_protocol_handler.hpp | 74 ++++---- .../client/connection/connection_delegate.hpp | 3 + .../client/connection/resolver_delegate.hpp | 22 +++ boost/network/protocol/http/client/facade.hpp | 45 +++-- .../http/message/directives/method.hpp | 4 +- .../message/directives/status_message.hpp | 4 +- .../protocol/http/message/directives/uri.hpp | 2 +- .../http/message/directives/version.hpp | 2 +- .../protocol/http/message/header/name.hpp | 15 +- .../protocol/http/message/header/value.hpp | 25 +-- .../protocol/http/message/header_concept.hpp | 2 - .../protocol/http/parser/incremental.hpp | 2 - .../http/policies/async_connection.hpp | 20 +- boost/network/protocol/http/request.hpp | 3 +- libs/network/test/message_test.cpp | 174 ++++-------------- 26 files changed, 212 insertions(+), 481 deletions(-) create mode 100644 boost/network/protocol/http/client/connection/resolver_delegate.hpp diff --git a/boost/network/message.hpp b/boost/network/message.hpp index 32b3f68f0..d03393be4 100644 --- a/boost/network/message.hpp +++ b/boost/network/message.hpp @@ -24,8 +24,6 @@ #include #endif -#include - /** message.hpp * * This header file implements the common message type which @@ -38,136 +36,44 @@ namespace boost { namespace network { /** The common message type. */ - template - struct basic_message : basic_storage_base { - typedef std::pair header_type; - typedef std::multimap headers_container_type; - typedef String string_type; - - basic_message() - : basic_storage_base() - {} - - basic_message(const basic_message & other) - : basic_storage_base(other) - {} - - basic_message & operator=(basic_message rhs) { - rhs.swap(*this); - return *this; - } - - void swap(basic_message & other) { - basic_storage_base & this_ = *this, - & other_ = other; - swap(this_, other_); - } - - headers_container_type & headers() { - if (!headers_) { - headers_ = headers_container_type(); - this->get_headers(*headers_); - } - return *headers_; - } - - void headers(headers_container_type const & headers_) const { - this->set_headers(headers_); - } - - void add_header(typename headers_container_type::value_type const & pair_) const { - this->append_header(pair_.first, pair_.second); - } - - void remove_header(typename headers_container_type::key_type const & key) const { - this->remove_headers(key); - } - - headers_container_type const & headers() const { - if (!headers_) { - headers_ = headers_container_type(); - this->get_headers(*headers_); - } - return *headers_; - } - - string_type & body() { - if (!body_) { - body_ = String(); - this->get_body(*body_); - } - return *body_; - } - - void body(string_type const & body_) const { - this->set_body(body_); - } - - string_type const & body() const { - if (!body_) { - body_ = String(); - this->get_body(*body_); - } - return *body_; - } - - string_type & source() { - if (!source_) { - source_ = String(); - this->get_source(*source_); - } - return *source_; - } - - void source(string_type const & source_) const { - this->set_source(source_); - } - - string_type const & source() const { - if (!source_) { - source_ = String(); - this->get_source(*source_); - } - return *source_; - } - - string_type & destination() { - if (!destination_) { - destination_ = String(); - this->get_destination(*destination_); - } - return *destination_; - } - - void destination(string_type const & destination_) const { - this->set_destination(destination_); - } - - string_type const & destination() const { - if (!destination_) { - destination_ = String(); - this->get_destination(*destination_); - } - return *destination_; - } - - protected: - optional source_, destination_; - optional headers_; - optional body_; + struct message : message_base { + // Nested types + typedef iterator_range< + shared_container_iterator > > + headers_range; + + // Mutators + virtual void set_destination(std::string const & destination); + virtual void set_source(std::string const & source); + virtual void append_header(std::string const & name, + std::string const & value); + virtual void remove_headers(std::string const & name); + virtual void remove_headers(); + virtual void set_body(std::string const & body); + virtual void append_body(std::string const & data); + + // Retrievers + virtual void get_destination(std::string & destination); + virtual void get_source(std::string & source); + virtual void get_headers(function inserter); + virtual void get_headers(std::string const & name, function inserter); + virtual void get_headers(function predicate, function inserter); + virtual void get_body(std::string const & body); + virtual void get_body(function)> chunk_reader, size_t size); + void swap(message & other); + virtual ~message(); }; - template - inline void swap(basic_message & left, basic_message & right) { + inline void swap(message & left, message & right) { left.swap(right); } - - // Commenting this out as we don't need to do this anymore. - // BOOST_CONCEPT_ASSERT((Message >)); - // BOOST_CONCEPT_ASSERT((Message >)); - typedef basic_message message; - typedef basic_message wmessage; + template + message_base & operator<< (message_base & msg, Directive directive) { + directive(msg); + return msg; + } + } // namespace network } // namespace boost diff --git a/boost/network/message/directives.hpp b/boost/network/message/directives.hpp index 005a91e14..23be513f2 100644 --- a/boost/network/message/directives.hpp +++ b/boost/network/message/directives.hpp @@ -13,16 +13,9 @@ namespace boost { namespace network { - template - inline basic_message & - operator<< (basic_message & message_, Directive const & directive) { - directive(message_); - return message_; - } - - BOOST_NETWORK_STRING_DIRECTIVE(source, source_, message.source(source_), message.source=source_); - BOOST_NETWORK_STRING_DIRECTIVE(destination, destination_, message.destination(destination_), message.destination=destination_); - BOOST_NETWORK_STRING_DIRECTIVE(body, body_, message.body(body_), message.body=body_); + BOOST_NETWORK_STRING_DIRECTIVE(source); + BOOST_NETWORK_STRING_DIRECTIVE(destination); + BOOST_NETWORK_STRING_DIRECTIVE(body); } // namespace network diff --git a/boost/network/message/directives/detail/string_directive.hpp b/boost/network/message/directives/detail/string_directive.hpp index 885777da4..239b3bd44 100644 --- a/boost/network/message/directives/detail/string_directive.hpp +++ b/boost/network/message/directives/detail/string_directive.hpp @@ -29,29 +29,22 @@ */ #ifndef BOOST_NETWORK_STRING_DIRECTIVE -#define BOOST_NETWORK_STRING_DIRECTIVE(name, value, body, pod_body) \ - template \ +#define BOOST_NETWORK_STRING_DIRECTIVE(name) \ struct name##_directive { \ - ValueType const & value; \ - explicit name##_directive(ValueType const & value_) \ + std::string const & value; \ + explicit name##_directive(std::string const & value_) \ : value(value_) {} \ name##_directive(name##_directive const & other) \ : value(other.value) {} \ - template class Message> \ - typename enable_if, void>::type \ - operator()(Message & message) const { \ - pod_body; \ - } \ - template class Message> \ - typename enable_if >, void>::type \ - operator()(Message & message) const { \ - body; \ + template \ + void operator()(Message & message) const { \ + message.set_##name(value); \ } \ }; \ \ - template inline name##_directive \ - name (T const & input) { \ - return name##_directive(input); \ + inline name##_directive const \ + name (std::string const & input) { \ + return name##_directive(input); \ } #endif /* BOOST_NETWORK_STRING_DIRECTIVE */ diff --git a/boost/network/message/directives/header.hpp b/boost/network/message/directives/header.hpp index af3fcf91f..c223d721f 100644 --- a/boost/network/message/directives/header.hpp +++ b/boost/network/message/directives/header.hpp @@ -13,11 +13,10 @@ namespace boost { namespace network { namespace impl { -template struct header_directive { - explicit header_directive(KeyType const & header_name, - ValueType const & header_value) : + explicit header_directive(std::string const & header_name, + std::string const & header_value) : _header_name(header_name), _header_value(header_value) { }; @@ -28,16 +27,15 @@ struct header_directive { private: - KeyType const & _header_name; - ValueType const & _header_value; + std::string const & _header_name; + std::string const & _header_value; }; } // namespace impl -template -inline impl::header_directive -header(T1 const & header_name, T2 const & header_value) { - return impl::header_directive(header_name, header_value); +inline impl::header_directive +header(std::string const & header_name, std::string const & header_value) { + return impl::header_directive(header_name, header_value); } } // namespace network } // namespace boost diff --git a/boost/network/message/directives/remove_header.hpp b/boost/network/message/directives/remove_header.hpp index 16d863e15..1a1f4f63e 100644 --- a/boost/network/message/directives/remove_header.hpp +++ b/boost/network/message/directives/remove_header.hpp @@ -1,5 +1,6 @@ -// Copyright Dean Michael Berris 2008. +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. // 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) @@ -10,40 +11,20 @@ namespace boost { namespace network { - template - struct basic_message; - namespace impl { -template < - class T - > -struct remove_header_directive { - - explicit remove_header_directive(T header_name) : - header_name_(header_name) - { }; - - template - void operator() (basic_message & msg) const { - msg.headers().erase(header_name_); - } -private: - mutable T header_name_; +struct remove_header_directive { + explicit remove_header_directive(std::string const & header_name); + void operator() (message_base & msg) const; + private: + std::string const & header_name_; }; } // namespace impl -inline -impl::remove_header_directive -remove_header(std::string header_name) { - return impl::remove_header_directive(header_name); -} - -inline -impl::remove_header_directive -remove_header(std::wstring header_name) { - return impl::remove_header_directive(header_name); +inline impl::remove_header_directive const +remove_header(std::string const & header_name) { + return impl::remove_header_directive(header_name); } } // namespace network } // namespace boost diff --git a/boost/network/message/wrappers/headers.hpp b/boost/network/message/wrappers/headers.hpp index 5c217ddca..41f4daab4 100644 --- a/boost/network/message/wrappers/headers.hpp +++ b/boost/network/message/wrappers/headers.hpp @@ -35,13 +35,14 @@ namespace impl { */ struct headers_wrapper { typedef std::multimap container_type; - typedef shared_container_iterator iterator; typedef iterator_range > range_type; explicit headers_wrapper(message_base & message); range_type operator[] (std::string const & key) const; + operator range_type () const; container_type::size_type count() const; + container_type::size_type count(std::string const &key) const; private: void init_cache_all(); mutable shared_ptr cache_; @@ -50,7 +51,7 @@ struct headers_wrapper { } // namespace impl /// Factory method to create the right wrapper object -inline impl::headers_wrapper +inline impl::headers_wrapper const headers(message_base & message_) { return impl::headers_wrapper(message_); } diff --git a/boost/network/protocol/http/algorithms/linearize.hpp b/boost/network/protocol/http/algorithms/linearize.hpp index c53305ae2..0fd24f740 100644 --- a/boost/network/protocol/http/algorithms/linearize.hpp +++ b/boost/network/protocol/http/algorithms/linearize.hpp @@ -6,7 +6,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include #include #include #include @@ -18,9 +17,8 @@ namespace boost { namespace network { namespace http { - template struct linearize_header { - typedef typename string::type string_type; + typedef std::string string_type; template struct result; @@ -35,8 +33,8 @@ namespace boost { namespace network { namespace http { ((Header)), (string_type) ) operator()(ValueType & header) { - typedef typename ostringstream::type output_stream; - typedef constants consts; + typedef std::ostringstream output_stream; + typedef constants consts; output_stream header_line; header_line << name(header) << consts::colon() << consts::space() @@ -57,9 +55,8 @@ namespace boost { namespace network { namespace http { OutputIterator oi ) { - typedef typename Request::tag Tag; - typedef constants consts; - typedef typename string::type string_type; + typedef constants consts; + typedef std::string string_type; static string_type http_slash = consts::http_slash() , accept = consts::accept() @@ -115,7 +112,7 @@ namespace boost { namespace network { namespace http { boost::copy(default_accept_encoding, oi); boost::copy(crlf, oi); } - typedef typename headers_range::type headers_range; + typedef boost::iterator_range::const_iterator> headers_range; typedef typename range_iterator::type headers_iterator; headers_range request_headers = headers(request); headers_iterator iterator = boost::begin(request_headers), @@ -129,15 +126,9 @@ namespace boost { namespace network { namespace http { boost::copy(header_value, oi); boost::copy(crlf, oi); } - if (!connection_keepalive::value) { - boost::copy(connection, oi); - *oi = consts::colon_char(); - *oi = consts::space_char(); - boost::copy(close, oi); - boost::copy(crlf, oi); - } boost::copy(crlf, oi); - typename body_range::type body_data = body(request).range(); + boost::iterator_range body_data = + body(request); return boost::copy(body_data, oi); } diff --git a/boost/network/protocol/http/client.hpp b/boost/network/protocol/http/client.hpp index 85c3bb583..bd8203a5c 100644 --- a/boost/network/protocol/http/client.hpp +++ b/boost/network/protocol/http/client.hpp @@ -50,13 +50,13 @@ struct client : basic_client_facade { // this client. BOOST_PARAMETER_CONSTRUCTOR( - basic_client, (base_facade_type), tag, + client, (base_facade_type), tag, (optional (in_out(io_service), (boost::asio::io_service&)) (follow_redirects, (bool)) (cache_resolved, (bool)) - (openssl_certificate, (string_type)) - (openssl_verify_path, (string_type)) + (openssl_certificate, (std::string)) + (openssl_verify_path, (std::string)) (connection_manager, (shared_ptr)) )) diff --git a/boost/network/protocol/http/client/base.hpp b/boost/network/protocol/http/client/base.hpp index 7e3eff5bc..b5b381e49 100644 --- a/boost/network/protocol/http/client/base.hpp +++ b/boost/network/protocol/http/client/base.hpp @@ -31,6 +31,7 @@ struct client_base { std::string const & method, bool get_body, body_callback_function_type callback); + void clear_resolved_cache(); private: client_base_pimpl * pimpl; }; diff --git a/boost/network/protocol/http/client/connection/async_base.hpp b/boost/network/protocol/http/client/connection/async_base.hpp index 1cdf85486..2ada508c9 100644 --- a/boost/network/protocol/http/client/connection/async_base.hpp +++ b/boost/network/protocol/http/client/connection/async_base.hpp @@ -9,7 +9,6 @@ #include #include -#include #include namespace boost { namespace network { namespace http { namespace impl { diff --git a/boost/network/protocol/http/client/connection/async_normal.hpp b/boost/network/protocol/http/client/connection/async_normal.hpp index 0595d408c..fa23fd75b 100644 --- a/boost/network/protocol/http/client/connection/async_normal.hpp +++ b/boost/network/protocol/http/client/connection/async_normal.hpp @@ -17,8 +17,6 @@ #include #include #include -#include -#include #include #include #include @@ -29,8 +27,6 @@ #include #include -#include - namespace boost { namespace network { namespace http { namespace impl { template @@ -38,7 +34,6 @@ namespace boost { namespace network { namespace http { namespace impl { namespace placeholders = boost::asio::placeholders; - template struct http_async_connection : async_connection_base, protected http_async_protocol_handler, diff --git a/boost/network/protocol/http/client/connection/async_protocol_handler.hpp b/boost/network/protocol/http/client/connection/async_protocol_handler.hpp index f0368c0e1..6109c4ae2 100644 --- a/boost/network/protocol/http/client/connection/async_protocol_handler.hpp +++ b/boost/network/protocol/http/client/connection/async_protocol_handler.hpp @@ -17,18 +17,16 @@ namespace boost { namespace network { namespace http { namespace impl { struct http_async_protocol_handler { protected: - typedef typename string::type string_type; - #ifdef BOOST_NETWORK_DEBUG struct debug_escaper { - string_type & string; - explicit debug_escaper(string_type & string_) + std::string & string; + explicit debug_escaper(std::string & string_) : string(string_) {} debug_escaper(debug_escaper const & other) : string(other.string) {} - void operator()(typename string_type::value_type input) { + void operator()(typename std::string::value_type input) { if (!algorithm::is_print()(input)) { - typename ostringstream::type escaped_stream; + std::ostringstream escaped_stream; if (input == '\r') { string.append("\\r"); } else if (input == '\n') { @@ -46,36 +44,33 @@ namespace boost { namespace network { namespace http { namespace impl { template void init_response(ResponseType & response_, bool get_body) { - boost::shared_future source_future( + boost::shared_future source_future( source_promise.get_future()); source(response_, source_future); - boost::shared_future destination_future( + boost::shared_future destination_future( destination_promise.get_future()); destination(response_, destination_future); - boost::shared_future::type> + boost::shared_future > headers_future(headers_promise.get_future()); headers(response_, headers_future); - boost::shared_future body_future( + boost::shared_future body_future( body_promise.get_future()); body(response_, body_future); - boost::shared_future version_future( + boost::shared_future version_future( version_promise.get_future()); version(response_, version_future); boost::shared_future status_future( status_promise.get_future()); status(response_, status_future); - boost::shared_future status_message_future( + boost::shared_future status_message_future( status_message_promise.get_future()); status_message(response_, status_message_future); } struct to_http_headers { - typedef typename string::type string_type; template - string_type const operator() (U const & pair) const { - typedef typename ostringstream::type ostringstream_type; - typedef constants constants; - ostringstream_type header_line; + std::string const operator() (U const & pair) const { + std::ostringstream header_line; header_line << pair.first << constants::colon() << constants::space() @@ -100,7 +95,7 @@ namespace boost { namespace network { namespace http { namespace impl { response_parser_type::http_version_done, input_range); if (parsed_ok == true) { - string_type version; + std::string version; std::swap(version, partial_parsed); version.append(boost::begin(result_range), boost::end(result_range)); @@ -109,7 +104,7 @@ namespace boost { namespace network { namespace http { namespace impl { part_begin = boost::end(result_range); } else if (parsed_ok == false) { #ifdef BOOST_NETWORK_DEBUG - string_type escaped; + std::string escaped; debug_escaper escaper(escaped); std::for_each(part_begin, part_end, escaper); BOOST_NETWORK_MESSAGE("[parser:" @@ -155,7 +150,7 @@ namespace boost { namespace network { namespace http { namespace impl { response_parser_type::http_status_done, input_range); if (parsed_ok == true) { - string_type status; + std::string status; std::swap(status, partial_parsed); status.append(boost::begin(result_range), boost::end(result_range)); @@ -166,7 +161,7 @@ namespace boost { namespace network { namespace http { namespace impl { part_begin = boost::end(result_range); } else if (parsed_ok == false) { #ifdef BOOST_NETWORK_DEBUG - string_type escaped; + std::string escaped; debug_escaper escaper(escaped); std::for_each(part_begin, part_end, escaper); BOOST_NETWORK_MESSAGE("[parser:" @@ -211,7 +206,7 @@ namespace boost { namespace network { namespace http { namespace impl { response_parser_type::http_status_message_done, input_range); if (parsed_ok == true) { - string_type status_message; + std::string status_message; std::swap(status_message, partial_parsed); status_message.append(boost::begin(result_range), boost::end(result_range)); @@ -220,7 +215,7 @@ namespace boost { namespace network { namespace http { namespace impl { part_begin = boost::end(result_range); } else if (parsed_ok == false) { #ifdef BOOST_NETWORK_DEBUG - string_type escaped; + std::string escaped; debug_escaper escaper(escaped); std::for_each(part_begin, part_end, escaper); BOOST_NETWORK_MESSAGE("[parser:" @@ -249,15 +244,15 @@ namespace boost { namespace network { namespace http { namespace impl { return parsed_ok; } - void parse_headers_real(string_type & headers_part) { - typename boost::iterator_range + void parse_headers_real(std::string & headers_part) { + typename boost::iterator_range input_range = boost::make_iterator_range(headers_part) , result_range; logic::tribool parsed_ok; response_parser_type headers_parser( response_parser_type::http_header_line_done); - typename headers_container::type headers; - std::pair header_pair; + std::multimap headers; + std::pair header_pair; while (!boost::empty(input_range)) { fusion::tie(parsed_ok, result_range) = headers_parser.parse_until( @@ -266,14 +261,14 @@ namespace boost { namespace network { namespace http { namespace impl { if (headers_parser.state() != response_parser_type::http_header_colon) break; - header_pair.first = string_type(boost::begin(result_range), + header_pair.first = std::string(boost::begin(result_range), boost::end(result_range)); input_range.advance_begin(boost::distance(result_range)); fusion::tie(parsed_ok, result_range) = headers_parser.parse_until( response_parser_type::http_header_line_done, input_range); - header_pair.second = string_type(boost::begin(result_range), + header_pair.second = std::string(boost::begin(result_range), boost::end(result_range)); input_range.advance_begin(boost::distance(result_range)); @@ -303,7 +298,7 @@ namespace boost { namespace network { namespace http { namespace impl { response_parser_type::http_headers_done, input_range); if (parsed_ok == true) { - string_type headers_string; + std::string headers_string; std::swap(headers_string, partial_parsed); headers_string.append(boost::begin(result_range), boost::end(result_range)); @@ -313,7 +308,7 @@ namespace boost { namespace network { namespace http { namespace impl { // We want to output the contents of the buffer that caused // the error in debug builds. #ifdef BOOST_NETWORK_DEBUG - string_type escaped; + std::string escaped; debug_escaper escaper(escaped); std::for_each(part_begin, part_end, escaper); BOOST_NETWORK_MESSAGE("[parser:" @@ -359,20 +354,19 @@ namespace boost { namespace network { namespace http { namespace impl { } typedef response_parser response_parser_type; - // TODO: make 1024 go away and become a configurable value. - typedef boost::array::type, 1024> buffer_type; + typedef boost::array buffer_type; response_parser_type response_parser_; - boost::promise version_promise; + boost::promise version_promise; boost::promise status_promise; - boost::promise status_message_promise; - boost::promise::type> headers_promise; - boost::promise source_promise; - boost::promise destination_promise; - boost::promise body_promise; + boost::promise status_message_promise; + boost::promise > headers_promise; + boost::promise source_promise; + boost::promise destination_promise; + boost::promise body_promise; buffer_type part; typename buffer_type::const_iterator part_begin; - string_type partial_parsed; + std::string partial_parsed; }; diff --git a/boost/network/protocol/http/client/connection/connection_delegate.hpp b/boost/network/protocol/http/client/connection/connection_delegate.hpp index 0e18b231c..7f4bc5b5b 100644 --- a/boost/network/protocol/http/client/connection/connection_delegate.hpp +++ b/boost/network/protocol/http/client/connection/connection_delegate.hpp @@ -7,6 +7,9 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#include +#include + namespace boost { namespace network { namespace http { namespace impl { struct connection_delegate { diff --git a/boost/network/protocol/http/client/connection/resolver_delegate.hpp b/boost/network/protocol/http/client/connection/resolver_delegate.hpp new file mode 100644 index 000000000..3acf2fd7b --- /dev/null +++ b/boost/network/protocol/http/client/connection/resolver_delegate.hpp @@ -0,0 +1,22 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_HPP_20111016 +#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_HPP_20111016 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +namespace boost { namespace network { namespace http { + +struct resolver_delegate { + virtual ~resolver_delegate() = 0; +}; + +} /* http */ + +} /* network */ + +} /* boost */ + +#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_HPP_20111016 */ diff --git a/boost/network/protocol/http/client/facade.hpp b/boost/network/protocol/http/client/facade.hpp index 6faae3497..f26282215 100644 --- a/boost/network/protocol/http/client/facade.hpp +++ b/boost/network/protocol/http/client/facade.hpp @@ -10,6 +10,7 @@ #include #include #include +#include namespace boost { namespace network { namespace http { @@ -48,26 +49,25 @@ struct basic_client_facade { (request,(request)) // yes sir, we make a copy of the original request. ) (optional - (body,(string_type const &),string_type()) - (content_type,(string_type const &),string_type()) + (body,(std::string const &),std::string()) + (content_type,(std::string const &),std::string()) (body_handler,(body_callback_function_type),body_callback_function_type()) )) { - if (body != string_type()) { + if (body.size()) { request << remove_header("Content-Length") - << header("Content-Length", boost::lexical_cast(body.size())) + << header("Content-Length", boost::lexical_cast(body.size())) << boost::network::body(body); } - typename headers_range >::type content_type_headers = + std::multimap content_type_headers = headers(request)["Content-Type"]; - if (content_type != string_type()) { + if (content_type.size()) { if (!boost::empty(content_type_headers)) request << remove_header("Content-Type"); request << header("Content-Type", content_type); } else { if (boost::empty(content_type_headers)) { - typedef typename char_::type char_type; - static char_type content_type[] = "x-application/octet-stream"; + static char content_type[] = "x-application/octet-stream"; request << header("Content-Type", content_type); } } @@ -79,26 +79,25 @@ struct basic_client_facade { (request,(request)) // yes sir, we make a copy of the original request. ) (optional - (body,(string_type const &),string_type()) - (content_type,(string_type const &),string_type()) + (body,(std::string const &),std::string()) + (content_type,(std::string const &),std::string()) (body_handler,(body_callback_function_type),body_callback_function_type()) )) { - if (body != string_type()) { + if (body != std::string()) { request << remove_header("Content-Length") - << header("Content-Length", boost::lexical_cast(body.size())) + << header("Content-Length", boost::lexical_cast(body.size())) << boost::network::body(body); } - typename headers_range >::type content_type_headers = + std::multimap content_type_headers = headers(request)["Content-Type"]; - if (content_type != string_type()) { + if (content_type.size()) { if (!boost::empty(content_type_headers)) request << remove_header("Content-Type"); request << header("Content-Type", content_type); } else { if (boost::empty(content_type_headers)) { - typedef typename char_::type char_type; - static char_type content_type[] = "x-application/octet-stream"; + static char content_type[] = "x-application/octet-stream"; request << header("Content-Type", content_type); } } @@ -128,29 +127,27 @@ struct basic_client_facade { template void init_base(ArgPack const & args, no_io_service) { - base.reset(new base_type(this->get_connection_manager(args))); + base.reset(new client_base(this->get_connection_manager(args))); } template void init_base(ArgPack const & args, has_io_service) { - base.reset(new base_type(args[_io_service], this->get_connection_manager(args))); + base.reset(new client_base(args[_io_service], this->get_connection_manager(args))); } private: template shared_ptr get_connection_manager(ArgPack const & args) { - shared_ptr connection_manager_ = ptr; + shared_ptr connection_manager_ = args[_connection_manager|shared_ptr()]; if (!connection_manager_.get()) { // Because there's no explicit connection manager, we use the default // implementation as provided by the tag. - typedef typename async_connection_policy::type - default_connection_manager_type; connection_manager_.reset( - new default_connection_manager_type(args[_cache_resolved|false], + new simple_async_connection_manager(args[_cache_resolved|false], args[_follow_redirects|false], - args[_openssl_certificate|optional()], - args[_openssl_verify_path|optional()])); + args[_openssl_certificate|optional()], + args[_openssl_verify_path|optional()])); } return connection_manager_; diff --git a/boost/network/protocol/http/message/directives/method.hpp b/boost/network/protocol/http/message/directives/method.hpp index 2f9aac3a4..a79718f54 100644 --- a/boost/network/protocol/http/message/directives/method.hpp +++ b/boost/network/protocol/http/message/directives/method.hpp @@ -8,9 +8,7 @@ namespace boost { namespace network { namespace http { - BOOST_NETWORK_STRING_DIRECTIVE(method, method_, - message.method(method_), - message.method=method_); + BOOST_NETWORK_STRING_DIRECTIVE(method); } /* http */ diff --git a/boost/network/protocol/http/message/directives/status_message.hpp b/boost/network/protocol/http/message/directives/status_message.hpp index 3ac16d06b..63c621b8f 100644 --- a/boost/network/protocol/http/message/directives/status_message.hpp +++ b/boost/network/protocol/http/message/directives/status_message.hpp @@ -11,9 +11,7 @@ namespace boost { namespace network { namespace http { - BOOST_NETWORK_STRING_DIRECTIVE(status_message, status_message_, - message.status_message(status_message_), - message.status_message=status_message_); + BOOST_NETWORK_STRING_DIRECTIVE(status_message); } // namespace http diff --git a/boost/network/protocol/http/message/directives/uri.hpp b/boost/network/protocol/http/message/directives/uri.hpp index 1ae91a53e..b7acb68c0 100644 --- a/boost/network/protocol/http/message/directives/uri.hpp +++ b/boost/network/protocol/http/message/directives/uri.hpp @@ -11,7 +11,7 @@ namespace boost { namespace network { namespace http { - BOOST_NETWORK_STRING_DIRECTIVE(uri, uri_, message.uri(uri_), message.uri=uri_); + BOOST_NETWORK_STRING_DIRECTIVE(uri); } // namespace http diff --git a/boost/network/protocol/http/message/directives/version.hpp b/boost/network/protocol/http/message/directives/version.hpp index 88f2d1c5a..2d4eec0fd 100644 --- a/boost/network/protocol/http/message/directives/version.hpp +++ b/boost/network/protocol/http/message/directives/version.hpp @@ -11,7 +11,7 @@ namespace boost { namespace network { namespace http { - BOOST_NETWORK_STRING_DIRECTIVE(version, version_, message.version(version_), message.version=version_); + BOOST_NETWORK_STRING_DIRECTIVE(version); } // namespace http diff --git a/boost/network/protocol/http/message/header/name.hpp b/boost/network/protocol/http/message/header/name.hpp index e7c26d17c..712ea312c 100644 --- a/boost/network/protocol/http/message/header/name.hpp +++ b/boost/network/protocol/http/message/header/name.hpp @@ -18,23 +18,12 @@ namespace boost { namespace network { namespace http { } inline std::string const & - name(request_header_narrow const & h) { + name(request_header const & h) { return h.name; } - inline std::wstring const & - name(request_header_wide const &h) { - return h.name; - } - - inline std::string const & - name(response_header_narrow const & h) { - return h.name; - } - - inline std::wstring const & - name(response_header_wide const &h) { + name(response_header const & h) { return h.name; } diff --git a/boost/network/protocol/http/message/header/value.hpp b/boost/network/protocol/http/message/header/value.hpp index 3769ec2ab..3be67c91e 100644 --- a/boost/network/protocol/http/message/header/value.hpp +++ b/boost/network/protocol/http/message/header/value.hpp @@ -7,39 +7,28 @@ // http://www.boost.org/LICENSE_1_0.txt) #include +#include namespace boost { namespace network { namespace http { - struct request_header_narrow; - struct request_header_wide; - struct response_header_narrow; - struct response_header_wide; + struct request_header; + struct response_header; template T1 & value(std::pair const & p) { return p.second; } - inline request_header_narrow::string_type const & - value(request_header_narrow const & h) { + inline std::string const & + value(request_header const & h) { return h.value; } - inline request_header_wide::string_type const & - value(request_header_wide const & h) { - return h.value; - } - - inline response_header_narrow::string_type const & - value(response_header_narrow const & h) { + inline std::string const & + value(response_header const & h) { return h.value; } - inline response_header_wide::string_type const & - value(response_header_wide const & h) { - return h.value; - } - } /* http */ } /* network */ diff --git a/boost/network/protocol/http/message/header_concept.hpp b/boost/network/protocol/http/message/header_concept.hpp index 9a14d47fd..538a3b067 100644 --- a/boost/network/protocol/http/message/header_concept.hpp +++ b/boost/network/protocol/http/message/header_concept.hpp @@ -6,8 +6,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include - namespace boost { namespace network { namespace http { template diff --git a/boost/network/protocol/http/parser/incremental.hpp b/boost/network/protocol/http/parser/incremental.hpp index 44c4c2a2e..58c16ca8c 100644 --- a/boost/network/protocol/http/parser/incremental.hpp +++ b/boost/network/protocol/http/parser/incremental.hpp @@ -8,10 +8,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include #include #include -#include #include #include #include diff --git a/boost/network/protocol/http/policies/async_connection.hpp b/boost/network/protocol/http/policies/async_connection.hpp index ace3d7137..a3651c18c 100644 --- a/boost/network/protocol/http/policies/async_connection.hpp +++ b/boost/network/protocol/http/policies/async_connection.hpp @@ -13,14 +13,13 @@ #include #include #include -#include -#include -#include #include #include #include #include #include +#include +#include namespace boost { namespace network { namespace http { @@ -60,22 +59,9 @@ struct http_1_1_async_connection_manager : connection_manager, enable_shared_fro bool cache_resolved, follow_redirects_; mutex shared_resolver_mutex; shared_ptr shared_resolver_delegate; - unordered_map > ready_connections; + boost::unordered_map > ready_connections; }; -template -struct async_connection_policy; - -template -struct async_connection_policy { // HTTP/1.0 - typedef simple_async_connection_manager type; -} - -template -struct async_connection_policy { // HTTP/1.1 - typedef http_1_1_connection_manager type; -} - } // namespace http } // namespace network diff --git a/boost/network/protocol/http/request.hpp b/boost/network/protocol/http/request.hpp index 2a42d60a1..c02644723 100644 --- a/boost/network/protocol/http/request.hpp +++ b/boost/network/protocol/http/request.hpp @@ -66,6 +66,7 @@ struct request : request_base { virtual void set_method(std::string const & method); virtual void set_status(std::string const & status); virtual void set_status_message(std::string const & status_message); + virtual void set_body_stream(shared_ptr stream); virtual void set_uri(std::string const &uri); virtual void set_uri(network::uri::uri const &uri); @@ -75,7 +76,7 @@ struct request : request_base { virtual void get_method(std::string & method); virtual void get_status(std::string & status); virtual void get_status_message(std::string & status_message); - virtual void get_body_stream(body_stream & output_stream) = 0; + virtual void get_body_stream(body_stream & output_stream); virtual ~request(); private: diff --git a/libs/network/test/message_test.cpp b/libs/network/test/message_test.cpp index a3d7d4b36..775ee8087 100644 --- a/libs/network/test/message_test.cpp +++ b/libs/network/test/message_test.cpp @@ -13,162 +13,62 @@ using namespace boost::network; -typedef boost::mpl::list< - http::tags::http_default_8bit_tcp_resolve, - http::tags::http_default_8bit_udp_resolve, - http::tags::http_keepalive_8bit_tcp_resolve, - http::tags::http_keepalive_8bit_udp_resolve, - tags::default_string, - tags::default_wstring -> tag_types; - -struct string_header_name { - static std::string string; -}; - -std::string string_header_name::string = "Header"; - -struct wstring_header_name { - static std::wstring string; -}; - -std::wstring wstring_header_name::string = L"Header"; - -struct string_header_value { - static std::string string; -}; - -std::string string_header_value::string = "Value"; - -struct wstring_header_value { - static std::wstring string; -}; - -std::wstring wstring_header_value::string = L"Value"; - -template -struct header_name : string_header_name {}; - -template <> -struct header_name : wstring_header_name {}; - -template -struct header_value : string_header_value {}; - -template <> -struct header_value : wstring_header_value {}; - -struct string_body_data { - static std::string string; -}; - -std::string string_body_data::string = "The quick brown fox jumps over the lazy dog."; - -struct wstring_body_data { - static std::wstring string; -}; - -std::wstring wstring_body_data::string = L"The quick brown fox jumps over the lazy dog."; - -template -struct body_data : string_body_data {}; - -template <> -struct body_data : wstring_body_data {}; - -struct string_source_data { - static std::string string; -}; - -std::string string_source_data::string = "Source"; - -struct wstring_source_data { - static std::wstring string; -}; - -std::wstring wstring_source_data::string = L"Source"; - -template -struct source_data : string_source_data {}; - -template <> -struct source_data : wstring_body_data {}; - -struct string_destination_data { - static std::string string; -}; - -std::string string_destination_data::string = "Destination"; - -struct wstring_destination_data { - static std::wstring string; -}; - -std::wstring wstring_destination_data::string = L"Destination"; - -template -struct destination_data : string_destination_data {}; - -template <> -struct destination_data : wstring_destination_data {}; - - /** * Defines a set of template functions that can be used to test * generic code. */ -BOOST_AUTO_TEST_CASE_TEMPLATE(copy_constructor_test, T, tag_types) { - basic_message instance; - instance << header(header_name::string, header_value::string); - basic_message copy(instance); - BOOST_CHECK_EQUAL(headers(copy).count(header_name::string), static_cast(1)); - typename headers_range >::type range = headers(copy)[header_name::string]; - BOOST_CHECK (boost::begin(range) != boost::end(range)); +BOOST_AUTO_TEST_CASE(copy_constructor_test) { + message instance; + instance << header("name", "value"); + message copy(instance); + BOOST_CHECK_EQUAL(headers(copy).count("name"), static_cast(1)); + message::headers_range range = headers(copy)["name"]; + BOOST_CHECK (!boost::empty(range)); } -BOOST_AUTO_TEST_CASE_TEMPLATE(swap_test, T, tag_types) { - basic_message instance; - instance << header(header_name::string, header_value::string); - basic_message other; +BOOST_AUTO_TEST_CASE(swap_test) { + message instance; + instance << header("name", "value"); + message other; swap(instance, other); - BOOST_CHECK_EQUAL (headers(instance).count(header_name::string), static_cast(0)); - BOOST_CHECK_EQUAL (headers(other).count(header_name::string), static_cast(1)); + BOOST_CHECK_EQUAL (headers(instance).count("name"), static_cast(0)); + BOOST_CHECK_EQUAL (headers(other).count("name"), static_cast(1)); } -BOOST_AUTO_TEST_CASE_TEMPLATE(headers_directive_test, T, tag_types) { - basic_message instance; - instance << header(header_name::string, header_value::string); - BOOST_CHECK_EQUAL ( headers(instance).count(header_name::string), static_cast(1) ); - typename headers_range >::type range = headers(instance)[header_name::string]; +BOOST_AUTO_TEST_CASE(headers_directive_test) { + message instance; + instance << header("name", "value"); + BOOST_CHECK_EQUAL ( headers(instance).count("name"), static_cast(1) ); + message::headers_range range = headers(instance)["name"]; BOOST_CHECK (boost::begin(range) != boost::end(range)); } -BOOST_AUTO_TEST_CASE_TEMPLATE(body_directive_test, T, tag_types) { - basic_message instance; - instance << ::boost::network::body(body_data::string); - typename string::type body_string = body(instance); - BOOST_CHECK ( body_string == body_data::string ); +BOOST_AUTO_TEST_CASE(body_directive_test) { + message instance; + instance << ::boost::network::body("body"); + std::string body_string = body(instance); + BOOST_CHECK ( body_string == "body" ); } -BOOST_AUTO_TEST_CASE_TEMPLATE(source_directive_test, T, tag_types) { - basic_message instance; - instance << ::boost::network::source(source_data::string); - typename string::type source_string = source(instance); - BOOST_CHECK ( source_string == source_data::string ); +BOOST_AUTO_TEST_CASE(source_directive_test) { + message instance; + instance << ::boost::network::source("source"); + std::string source_string = source(instance); + BOOST_CHECK ( source_string == "source" ); } -BOOST_AUTO_TEST_CASE_TEMPLATE(destination_directive_test, T, tag_types) { - basic_message instance; - instance << destination(destination_data::string); - BOOST_CHECK ( destination(instance) == destination_data::string ); +BOOST_AUTO_TEST_CASE(destination_directive_test) { + message instance; + instance << destination("destination"); + BOOST_CHECK ( destination(instance) == "destination" ); } -BOOST_AUTO_TEST_CASE_TEMPLATE(remove_header_directive_test, T, tag_types) { - basic_message instance; - instance << header(header_name::string, header_value::string) - << remove_header(header_name::string); - typename headers_range >::type range = headers(instance); +BOOST_AUTO_TEST_CASE(remove_header_directive_test) { + message instance; + instance << header("name", "value") + << remove_header("name"); + message::headers_range range = headers(instance); BOOST_CHECK ( boost::begin(range) == boost::end(range) ); } From 1221ce8609095057513b39386784f9d117332a36 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Thu, 20 Oct 2011 17:58:22 +1100 Subject: [PATCH 012/196] Initial implementation of boost::network::message. --- boost/network/message.hpp | 98 ++++++----- boost/network/message.ipp | 211 +++++++++++++++++++++++ boost/network/message_base.hpp | 2 +- boost/network/protocol/http/request.hpp | 5 +- boost/network/protocol/http/response.hpp | 2 +- boost/network/uri/uri.hpp | 5 +- libs/network/build/CMakeLists.txt | 2 +- libs/network/src/CMakeLists.txt | 3 + libs/network/src/message.cpp | 14 ++ libs/network/test/CMakeLists.txt | 4 +- 10 files changed, 295 insertions(+), 51 deletions(-) create mode 100644 boost/network/message.ipp create mode 100644 libs/network/src/message.cpp diff --git a/boost/network/message.hpp b/boost/network/message.hpp index d03393be4..32ebd22bc 100644 --- a/boost/network/message.hpp +++ b/boost/network/message.hpp @@ -34,48 +34,64 @@ */ namespace boost { namespace network { - /** The common message type. - */ - struct message : message_base { - // Nested types - typedef iterator_range< - shared_container_iterator > > - headers_range; - - // Mutators - virtual void set_destination(std::string const & destination); - virtual void set_source(std::string const & source); - virtual void append_header(std::string const & name, - std::string const & value); - virtual void remove_headers(std::string const & name); - virtual void remove_headers(); - virtual void set_body(std::string const & body); - virtual void append_body(std::string const & data); - - // Retrievers - virtual void get_destination(std::string & destination); - virtual void get_source(std::string & source); - virtual void get_headers(function inserter); - virtual void get_headers(std::string const & name, function inserter); - virtual void get_headers(function predicate, function inserter); - virtual void get_body(std::string const & body); - virtual void get_body(function)> chunk_reader, size_t size); - void swap(message & other); - virtual ~message(); - }; - - inline void swap(message & left, message & right) { - left.swap(right); - } - - template - message_base & operator<< (message_base & msg, Directive directive) { - directive(msg); - return msg; - } - + struct message_pimpl; + + /** The common message type. + */ + struct message : message_base { + // Nested types + typedef iterator_range< + shared_container_iterator > > + headers_range; + + // Constructors + message(); + message(message const & other); + + // Assignment + message & operator=(message other); + + // Mutators + virtual void set_destination(std::string const & destination); + virtual void set_source(std::string const & source); + virtual void append_header(std::string const & name, + std::string const & value); + virtual void remove_headers(std::string const & name); + virtual void remove_headers(); + virtual void set_body(std::string const & body); + virtual void append_body(std::string const & data); + + // Retrievers + virtual void get_destination(std::string & destination); + virtual void get_source(std::string & source); + virtual void get_headers(function inserter); + virtual void get_headers(std::string const & name, function inserter); + virtual void get_headers(function predicate, function inserter); + virtual void get_body(std::string & body); + virtual void get_body(function)> chunk_reader, size_t size); + void swap(message & other); + + // Destructor + virtual ~message(); + private: + message_pimpl * pimpl; + }; + + inline void swap(message & left, message & right) { + left.swap(right); + } + + template + message_base & operator<< (message_base & msg, Directive directive) { + directive(msg); + return msg; + } + } // namespace network } // namespace boost -#endif // __NETWORK_MESSAGE_HPP__ +#ifdef BOOST_NETWORK_NO_LIB +#include +#endif +#endif // __NETWORK_MESSAGE_HPP__ diff --git a/boost/network/message.ipp b/boost/network/message.ipp new file mode 100644 index 000000000..afd90a12d --- /dev/null +++ b/boost/network/message.ipp @@ -0,0 +1,211 @@ +#ifndef BOOST_NETWORK_MESSAGE_IPP_20111020 +#define BOOST_NETWORK_MESSAGE_IPP_20111020 + +// Copyright 2011 Dean Michael Berris (dberris@google.com). +// Copyright 2011 Google, Inc. +// 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) + +#include +#include +#include +#include + +namespace boost { namespace network { + +struct message_pimpl { + message_pimpl() : + destination_(), + source_(), + headers_(), + body_(), + body_read_pos(0) + {} + + void set_destination(std::string const & destination) { + destination_ = destination; + } + + void set_source(std::string const & source) { + source_ = source; + } + + void append_header(std::string const & name, + std::string const & value) { + headers_.insert(std::make_pair(name, value)); + } + + void remove_headers(std::string const & name) { + headers_.erase(name); + } + + void remove_headers() { + std::multimap().swap(headers_); + } + + void set_body(std::string const & body) { + body_ = body; + } + + void append_body(std::string const & data) { + body_.append(data); + } + + // Retrievers + void get_destination(std::string & destination) { + destination = destination_; + } + + void get_source(std::string & source) { + source = source_; + } + + void get_headers(function inserter) { + std::multimap::const_iterator it = headers_.begin(), + end = headers_.end(); + for (; it != end; ++it) inserter(it->first, it->second); + } + + void get_headers(std::string const & name, + function inserter) { + std::multimap::const_iterator it = headers_.find(name), + end= headers_.end(); + while (it != end) { + inserter(it->first, it->second); + ++it; + } + } + + void get_headers(function predicate, + function inserter) { + std::multimap::const_iterator it = headers_.begin(), + end = headers_.end(); + while (it != end) { + if (predicate(it->first, it->second)) + inserter(it->first, it->second); + ++it; + } + } + + void get_body(std::string & body) { + body = body_; + } + + void get_body(function)> chunk_reader, size_t size) { + static char const * nullptr_ = 0; + if (body_read_pos == body_.size()) + chunk_reader(boost::make_iterator_range(nullptr_, nullptr_)); + std::string::const_iterator it = body_.begin(), + end = body_.end(); + std::advance(it, body_read_pos); + size_t max_size = std::distance(it, end); + size_t max_read = std::min(max_size, size); + std::string::const_iterator start = it; + end = start; + std::advance(end, max_read); + body_read_pos += max_read; + chunk_reader(boost::make_iterator_range(&(*start), &(*end))); + } + + message_pimpl * clone() { + message_pimpl * other = new(std::nothrow) message_pimpl; + other->destination_ = this->destination_; + other->source_ = this->source_; + other->headers_ = this->headers_; + other->body_ = this->body_; + return other; + } + + private: + std::string destination_, source_; + std::multimap headers_; + // TODO: use Boost.IOStreams here later on. + std::string body_; + size_t body_read_pos; +}; + +message::message() + : pimpl(new (std::nothrow) message_pimpl) +{} + +message::message(message const & other) + : pimpl(other.pimpl->clone()) +{} + +message& message::operator=(message other) { + *pimpl = *other.pimpl; +} + +message::~message() { + delete pimpl; +} + +void message::set_destination(std::string const & destination) { + pimpl->set_destination(destination); +} + +void message::set_source(std::string const & source) { + pimpl->set_source(source); +} + +void message::append_header(std::string const & name, + std::string const & value) { + pimpl->append_header(name, value); +} + +void message::remove_headers(std::string const & name) { + pimpl->remove_headers(name); +} + +void message::remove_headers() { + pimpl->remove_headers(); +} + +void message::set_body(std::string const & body) { + pimpl->set_body(body); +} + +void message::append_body(std::string const & data) { + pimpl->append_body(data); +} + +void message::get_destination(std::string & destination) { + pimpl->get_destination(destination); +} + +void message::get_source(std::string & source) { + pimpl->get_source(source); +} + +void message::get_headers(function inserter) { + pimpl->get_headers(inserter); +} + +void message::get_headers(std::string const & name, + function inserter) { + pimpl->get_headers(name, inserter); +} + +void message::get_headers(function predicate, + function inserter) { + pimpl->get_headers(predicate, inserter); +} + +void message::get_body(std::string & body) { + pimpl->get_body(body); +} + +void message::get_body(function)> chunk_reader, size_t size) { + pimpl->get_body(chunk_reader, size); +} + +void message::swap(message & other) { + std::swap(this->pimpl, other.pimpl); +} + +} /* network */ + +} /* boost */ + +#endif /* BOOST_NETWORK_MESSAGE_IPP_20111020 */ diff --git a/boost/network/message_base.hpp b/boost/network/message_base.hpp index c96a666bc..ac2aaffad 100644 --- a/boost/network/message_base.hpp +++ b/boost/network/message_base.hpp @@ -29,7 +29,7 @@ struct message_base { virtual void get_headers(function inserter) = 0; virtual void get_headers(std::string const & name, function inserter) = 0; virtual void get_headers(function predicate, function inserter) = 0; - virtual void get_body(std::string const & body) = 0; + virtual void get_body(std::string & body) = 0; virtual void get_body(function)> chunk_reader, size_t size) = 0; // Destructor diff --git a/boost/network/protocol/http/request.hpp b/boost/network/protocol/http/request.hpp index c02644723..edb7b0406 100644 --- a/boost/network/protocol/http/request.hpp +++ b/boost/network/protocol/http/request.hpp @@ -58,9 +58,9 @@ struct request : request_base { virtual void get_headers(function inserter); virtual void get_headers(std::string const & name, function inserter); virtual void get_headers(function predicate, function inserter); - virtual void get_body(std::string const & body); + virtual void get_body(std::string & body); virtual void get_body(function)> chunk_reader, size_t size); - + // From request_base... // Setters virtual void set_method(std::string const & method); @@ -103,4 +103,3 @@ request_base & operator<< (request_base & request, #include #endif // __NETWORK_PROTOCOL_HTTP_REQUEST_20070908-1_HPP__ - diff --git a/boost/network/protocol/http/response.hpp b/boost/network/protocol/http/response.hpp index 4c7832102..f8e1aa094 100644 --- a/boost/network/protocol/http/response.hpp +++ b/boost/network/protocol/http/response.hpp @@ -49,7 +49,7 @@ struct response : response_base { virtual void get_headers(function inserter); virtual void get_headers(std::string const & name, function inserter); virtual void get_headers(function predicate, function inserter); - virtual void get_body(std::string const & body); + virtual void get_body(std::string & body); virtual void get_body(function)> chunk_reader, size_t size); // From response_base... diff --git a/boost/network/uri/uri.hpp b/boost/network/uri/uri.hpp index 99054559c..31aae7c95 100644 --- a/boost/network/uri/uri.hpp +++ b/boost/network/uri/uri.hpp @@ -300,8 +300,6 @@ inline bool operator == (const uri &lhs, const uri &rhs) { return std::equal(lhs.begin(), lhs.end(), rhs.begin()); } -} // namespace uri -} // namespace network inline network::uri::uri::iterator begin(network::uri::uri &uri_) { @@ -327,6 +325,9 @@ inline void swap(network::uri::uri &lhs, network::uri::uri &rhs) { lhs.swap(rhs); } + +} // namespace uri +} // namespace network } // namespace boost diff --git a/libs/network/build/CMakeLists.txt b/libs/network/build/CMakeLists.txt index 8111a37b7..e7dbee625 100644 --- a/libs/network/build/CMakeLists.txt +++ b/libs/network/build/CMakeLists.txt @@ -3,4 +3,4 @@ find_package( Boost 1.43.0 COMPONENTS unit_test_framework system regex thread fi add_library(cppnetlib-uri STATIC ${CPP-NETLIB_SOURCE_DIR}/libs/network/src/parse_uri_impl.cpp) add_library(cppnetlib-server-parsers STATIC ${CPP-NETLIB_SOURCE_DIR}/libs/network/src/server_request_parsers_impl.cpp) - +add_library(cppnetlib-message STATIC ${CPP-NETLIB_SOURCE_DIR}/libs/network/src/message.cpp) diff --git a/libs/network/src/CMakeLists.txt b/libs/network/src/CMakeLists.txt index 169a51bfd..9e38860f6 100644 --- a/libs/network/src/CMakeLists.txt +++ b/libs/network/src/CMakeLists.txt @@ -15,3 +15,6 @@ add_library(cppnetlib-server-parsers ${CPP-NETLIB_HTTP_SERVER_SRCS}) set(CPP-NETLIB_HTTP_CLIENT_SRCS client.cpp) add_library(cppnetlib-client-connections ${CPP-NETLIB_HTTP_CLIENT_SRCS}) + +set(CPP-NETLIB_MESSAGE_SRCS message.cpp) +add_library(cppnetlib-message ${CPP-NETLIB_MESSAGE_SRCS}) diff --git a/libs/network/src/message.cpp b/libs/network/src/message.cpp new file mode 100644 index 000000000..eb2f65a04 --- /dev/null +++ b/libs/network/src/message.cpp @@ -0,0 +1,14 @@ +// Copyright 2011 Dean Michael Berris (dberris@google.com). +// Copyright 2011 Google, Inc. +// 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) + +// This is the conglomeration of all message-related implementation files. All +// we're doing is including all the .ipp files that are relevant. + +#ifdef BOOST_NETWORK_NO_LIB +#undef BOOST_NETWORK_NO_LIB +#endif + +#include diff --git a/libs/network/test/CMakeLists.txt b/libs/network/test/CMakeLists.txt index 343cf5697..7e3b7a531 100644 --- a/libs/network/test/CMakeLists.txt +++ b/libs/network/test/CMakeLists.txt @@ -22,11 +22,11 @@ if (Boost_FOUND) set_source_files_properties(${test}.cpp PROPERTIES COMPILE_FLAGS "-Wall") add_executable(cpp-netlib-${test} ${test}.cpp) - add_dependencies(cpp-netlib-${test} cppnetlib-uri) + add_dependencies(cpp-netlib-${test} cppnetlib-uri cppnetlib-message) # add_dependencies(cpp-netlib-${test} cppnetlib-uri) # target_link_libraries(cpp-netlib-${test} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri) - target_link_libraries(cpp-netlib-${test} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri) + target_link_libraries(cpp-netlib-${test} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri cppnetlib-message) if (OPENSSL_FOUND) target_link_libraries(cpp-netlib-${test} ${OPENSSL_LIBRARIES}) endif() From f74775fae5b3d75e4b540b3cbf12ff5313e45304 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Thu, 20 Oct 2011 18:03:05 +1100 Subject: [PATCH 013/196] Expanding ignored files. --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 0a0b40a64..22066753e 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ Testing *.gch libs/mime/test/mime-roundtrip *.a +bin/ +tests/ +example/ From c066d2e02d42ca68402a92fcb560b4f311b02c65 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Thu, 20 Oct 2011 19:23:10 +1100 Subject: [PATCH 014/196] Default implementation of pure virtual destructor for message_base. --- boost/network/message_base.hpp | 4 ++++ boost/network/message_base.ipp | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 boost/network/message_base.ipp diff --git a/boost/network/message_base.hpp b/boost/network/message_base.hpp index ac2aaffad..43b2307bc 100644 --- a/boost/network/message_base.hpp +++ b/boost/network/message_base.hpp @@ -40,4 +40,8 @@ struct message_base { } /* boost */ +#ifdef BOOST_NETWORK_NO_LIB +#include +#endif + #endif /* BOOST_NETWORK_MESSAGE_BASE_HPP_20110910 */ diff --git a/boost/network/message_base.ipp b/boost/network/message_base.ipp new file mode 100644 index 000000000..061d2a6f6 --- /dev/null +++ b/boost/network/message_base.ipp @@ -0,0 +1,23 @@ +#ifndef BOOST_NETWORK_MESSAGE_BASE_IPP_20111020 +#define BOOST_NETWORK_MESSAGE_BASE_IPP_20111020 + +// Copyright 2011 Dean Michael Berris (dberris@google.com). +// Copyright 2011 Google, Inc. +// 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) + +#include + +namespace boost { namespace network { + +message_base::~message_base() { + // This is never used, but is required even though message_base's destructor + // is a pure virtual one. +} + +} /* network */ + +} /* boost */ + +#endif /* BOOST_NETWORK_MESSAGE_BASE_IPP_20111020 */ From 47776015a5a519a857f3f1c5e7168eaac79c9f89 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Fri, 21 Oct 2011 14:39:05 +1100 Subject: [PATCH 015/196] Moving headers around for better organization. --- boost/network/message.hpp | 88 +++---------------- boost/network/message/directives/header.hpp | 3 +- boost/network/message/message.hpp | 86 ++++++++++++++++++ boost/network/{ => message}/message.ipp | 2 +- boost/network/{ => message}/message_base.hpp | 0 boost/network/{ => message}/message_base.ipp | 0 .../message/modifiers/clear_headers.hpp | 2 +- .../message/modifiers/remove_header.hpp | 3 +- boost/network/message/wrappers/body.hpp | 3 +- .../network/message/wrappers/destination.hpp | 3 +- boost/network/message/wrappers/source.hpp | 2 +- .../http/message/directives/status.hpp | 2 +- .../http/message/modifiers/method.hpp | 2 +- .../http/message/modifiers/status.hpp | 2 +- .../http/message/modifiers/status_message.hpp | 2 +- .../http/message/modifiers/version.hpp | 2 +- .../protocol/http/message/wrappers/method.hpp | 2 +- .../http/message/wrappers/status_message.hpp | 2 +- .../protocol/http/message/wrappers/uri.hpp | 2 +- boost/network/protocol/http/request.hpp | 79 ++--------------- .../network/protocol/http/request/request.hpp | 79 +++++++++++++++++ .../protocol/http/{ => request}/request.ipp | 0 .../http/{ => request}/request_base.hpp | 2 +- .../http/{ => request}/request_concept.hpp | 0 boost/network/protocol/http/response.hpp | 63 +------------ .../protocol/http/response/response.hpp | 65 ++++++++++++++ .../http/{ => response}/response_base.hpp | 0 .../http/{ => response}/response_concept.hpp | 0 libs/network/src/message.cpp | 2 +- 29 files changed, 267 insertions(+), 231 deletions(-) create mode 100644 boost/network/message/message.hpp rename boost/network/{ => message}/message.ipp (99%) rename boost/network/{ => message}/message_base.hpp (100%) rename boost/network/{ => message}/message_base.ipp (100%) create mode 100644 boost/network/protocol/http/request/request.hpp rename boost/network/protocol/http/{ => request}/request.ipp (100%) rename boost/network/protocol/http/{ => request}/request_base.hpp (98%) rename boost/network/protocol/http/{ => request}/request_concept.hpp (100%) create mode 100644 boost/network/protocol/http/response/response.hpp rename boost/network/protocol/http/{ => response}/response_base.hpp (100%) rename boost/network/protocol/http/{ => response}/response_concept.hpp (100%) diff --git a/boost/network/message.hpp b/boost/network/message.hpp index 32ebd22bc..e1b266384 100644 --- a/boost/network/message.hpp +++ b/boost/network/message.hpp @@ -1,10 +1,12 @@ -// Copyright Dean Michael Berris 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 BOOST_NETWORK_MESSAGE_HPP_20111021 +#define BOOST_NETWORK_MESSAGE_HPP_20111021 -#ifndef __NETWORK_MESSAGE_HPP__ -#define __NETWORK_MESSAGE_HPP__ +// Copyright Dean Michael Berris 2007. +// Copyright 2011 Dean Michael Berris (dberris@google.com). +// Copyright 2011 Google, Inc. +// 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) #include #include @@ -20,78 +22,10 @@ #include #include +#include + #ifdef BOOST_NETWORK_DEBUG #include #endif -/** message.hpp - * - * This header file implements the common message type which - * all networking implementations under the boost::network - * namespace. The common message type allows for easy message - * construction and manipulation suited for networked - * application development. - */ -namespace boost { namespace network { - - struct message_pimpl; - - /** The common message type. - */ - struct message : message_base { - // Nested types - typedef iterator_range< - shared_container_iterator > > - headers_range; - - // Constructors - message(); - message(message const & other); - - // Assignment - message & operator=(message other); - - // Mutators - virtual void set_destination(std::string const & destination); - virtual void set_source(std::string const & source); - virtual void append_header(std::string const & name, - std::string const & value); - virtual void remove_headers(std::string const & name); - virtual void remove_headers(); - virtual void set_body(std::string const & body); - virtual void append_body(std::string const & data); - - // Retrievers - virtual void get_destination(std::string & destination); - virtual void get_source(std::string & source); - virtual void get_headers(function inserter); - virtual void get_headers(std::string const & name, function inserter); - virtual void get_headers(function predicate, function inserter); - virtual void get_body(std::string & body); - virtual void get_body(function)> chunk_reader, size_t size); - void swap(message & other); - - // Destructor - virtual ~message(); - private: - message_pimpl * pimpl; - }; - - inline void swap(message & left, message & right) { - left.swap(right); - } - - template - message_base & operator<< (message_base & msg, Directive directive) { - directive(msg); - return msg; - } - -} // namespace network -} // namespace boost - -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif - -#endif // __NETWORK_MESSAGE_HPP__ +#endif // BOOST_NETWORK_MESSAGE_HPP_20111021 diff --git a/boost/network/message/directives/header.hpp b/boost/network/message/directives/header.hpp index c223d721f..23c849508 100644 --- a/boost/network/message/directives/header.hpp +++ b/boost/network/message/directives/header.hpp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { @@ -41,4 +41,3 @@ header(std::string const & header_name, std::string const & header_value) { } // namespace boost #endif // __NETWORK_MESSAGE_DIRECTIVES_HEADER_HPP__ - diff --git a/boost/network/message/message.hpp b/boost/network/message/message.hpp new file mode 100644 index 000000000..5684b721a --- /dev/null +++ b/boost/network/message/message.hpp @@ -0,0 +1,86 @@ +#ifndef BOOST_NETWORK_MESSAGE_MESSAGE_HPP_20111021 +#define BOOST_NETWORK_MESSAGE_MESSAGE_HPP_20111021 + +// Copyright 2011 Dean Michael Berris (dberris@google.com). +// Copyright 2011 Google, Inc. +// 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) + +#include +#include +#include +#include +#include + +namespace boost { namespace network { + +struct message_pimpl; + +/** The common message type. + */ +struct message : message_base { + // Nested types + typedef iterator_range< + shared_container_iterator > > + headers_range; + + // Constructors + message(); + message(message const & other); + + // Assignment + message & operator=(message other); + + // Mutators + virtual void set_destination(std::string const & destination); + virtual void set_source(std::string const & source); + virtual void append_header(std::string const & name, + std::string const & value); + virtual void remove_headers(std::string const & name); + virtual void remove_headers(); + virtual void set_body(std::string const & body); + virtual void append_body(std::string const & data); + + // Retrievers + virtual void get_destination(std::string & destination); + virtual void get_source(std::string & source); + virtual void get_headers( + function inserter); + virtual void get_headers( + std::string const & name, + function inserter); + virtual void get_headers( + function predicate, + function inserter); + virtual void get_body(std::string & body); + virtual void get_body( + function)> chunk_reader, + size_t size); + void swap(message & other); + + // Destructor + virtual ~message(); + private: + message_pimpl * pimpl; +}; + +inline void swap(message & left, message & right) { + left.swap(right); +} + +template +message_base & operator<< (message_base & msg, Directive directive) { + directive(msg); + return msg; +} + +} /* network */ + +} /* boost */ + +#ifdef BOOST_NETWORK_NO_LIB +#include +#endif + +#endif /* BOOST_NETWORK_MESSAGE_MESSAGE_HPP_20111021 */ diff --git a/boost/network/message.ipp b/boost/network/message/message.ipp similarity index 99% rename from boost/network/message.ipp rename to boost/network/message/message.ipp index afd90a12d..370cdbe2e 100644 --- a/boost/network/message.ipp +++ b/boost/network/message/message.ipp @@ -10,7 +10,7 @@ #include #include #include -#include +#include namespace boost { namespace network { diff --git a/boost/network/message_base.hpp b/boost/network/message/message_base.hpp similarity index 100% rename from boost/network/message_base.hpp rename to boost/network/message/message_base.hpp diff --git a/boost/network/message_base.ipp b/boost/network/message/message_base.ipp similarity index 100% rename from boost/network/message_base.ipp rename to boost/network/message/message_base.ipp diff --git a/boost/network/message/modifiers/clear_headers.hpp b/boost/network/message/modifiers/clear_headers.hpp index 077337e7c..671cf0b7d 100644 --- a/boost/network/message/modifiers/clear_headers.hpp +++ b/boost/network/message/modifiers/clear_headers.hpp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { diff --git a/boost/network/message/modifiers/remove_header.hpp b/boost/network/message/modifiers/remove_header.hpp index fbbc12170..d14146a41 100644 --- a/boost/network/message/modifiers/remove_header.hpp +++ b/boost/network/message/modifiers/remove_header.hpp @@ -8,7 +8,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include +#include namespace boost { namespace network { @@ -22,4 +22,3 @@ void remove_header(message_base & message, std::string const & key) { } // namespace boost #endif // BOOST_NETWORK_MESSAGE_MODIFIER_REMOVE_HEADER_HPP_20100824 - diff --git a/boost/network/message/wrappers/body.hpp b/boost/network/message/wrappers/body.hpp index ce19f8d0b..093334fb2 100644 --- a/boost/network/message/wrappers/body.hpp +++ b/boost/network/message/wrappers/body.hpp @@ -10,7 +10,7 @@ #include #include -#include +#include namespace boost { namespace network { @@ -49,4 +49,3 @@ body(message_base & message_) { #endif #endif // __NETWORK_MESSAGE_WRAPPERS_BODY_HPP__ - diff --git a/boost/network/message/wrappers/destination.hpp b/boost/network/message/wrappers/destination.hpp index f4e94764e..4330f115b 100644 --- a/boost/network/message/wrappers/destination.hpp +++ b/boost/network/message/wrappers/destination.hpp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { @@ -34,4 +34,3 @@ destination(message_base & message_) { #endif #endif // __NETWORK_MESSAGE_WRAPPERS_DESTINATION_HPP__ - diff --git a/boost/network/message/wrappers/source.hpp b/boost/network/message/wrappers/source.hpp index 7485f6b73..788ec90a5 100644 --- a/boost/network/message/wrappers/source.hpp +++ b/boost/network/message/wrappers/source.hpp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { diff --git a/boost/network/protocol/http/message/directives/status.hpp b/boost/network/protocol/http/message/directives/status.hpp index 2b910d595..6560607ab 100644 --- a/boost/network/protocol/http/message/directives/status.hpp +++ b/boost/network/protocol/http/message/directives/status.hpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include namespace boost { namespace network { namespace http { diff --git a/boost/network/protocol/http/message/modifiers/method.hpp b/boost/network/protocol/http/message/modifiers/method.hpp index f2101479a..98a747f0b 100644 --- a/boost/network/protocol/http/message/modifiers/method.hpp +++ b/boost/network/protocol/http/message/modifiers/method.hpp @@ -6,7 +6,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/boost/network/protocol/http/message/modifiers/status.hpp b/boost/network/protocol/http/message/modifiers/status.hpp index ca6024e09..66675fa8e 100644 --- a/boost/network/protocol/http/message/modifiers/status.hpp +++ b/boost/network/protocol/http/message/modifiers/status.hpp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/boost/network/protocol/http/message/modifiers/status_message.hpp b/boost/network/protocol/http/message/modifiers/status_message.hpp index 3d24601cc..ad12bf637 100644 --- a/boost/network/protocol/http/message/modifiers/status_message.hpp +++ b/boost/network/protocol/http/message/modifiers/status_message.hpp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/boost/network/protocol/http/message/modifiers/version.hpp b/boost/network/protocol/http/message/modifiers/version.hpp index ee668fc07..1af1ac567 100644 --- a/boost/network/protocol/http/message/modifiers/version.hpp +++ b/boost/network/protocol/http/message/modifiers/version.hpp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/boost/network/protocol/http/message/wrappers/method.hpp b/boost/network/protocol/http/message/wrappers/method.hpp index a122a5b2b..0219d69b5 100644 --- a/boost/network/protocol/http/message/wrappers/method.hpp +++ b/boost/network/protocol/http/message/wrappers/method.hpp @@ -6,7 +6,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/boost/network/protocol/http/message/wrappers/status_message.hpp b/boost/network/protocol/http/message/wrappers/status_message.hpp index a7c19165c..40c5306a3 100644 --- a/boost/network/protocol/http/message/wrappers/status_message.hpp +++ b/boost/network/protocol/http/message/wrappers/status_message.hpp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/boost/network/protocol/http/message/wrappers/uri.hpp b/boost/network/protocol/http/message/wrappers/uri.hpp index 222f24e09..505ebc078 100644 --- a/boost/network/protocol/http/message/wrappers/uri.hpp +++ b/boost/network/protocol/http/message/wrappers/uri.hpp @@ -8,7 +8,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include +#include namespace boost { namespace network { namespace http { diff --git a/boost/network/protocol/http/request.hpp b/boost/network/protocol/http/request.hpp index edb7b0406..ae0098a6b 100644 --- a/boost/network/protocol/http/request.hpp +++ b/boost/network/protocol/http/request.hpp @@ -1,16 +1,15 @@ -#ifndef __NETWORK_PROTOCOL_HTTP_REQUEST_20070908_1_HPP__ -#define __NETWORK_PROTOCOL_HTTP_REQUEST_20070908_1_HPP__ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_HPP_20111021 +#define BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_HPP_20111021 // Copyright Dean Michael Berris 2007. // Copyright 2011 Dean Michael Berris . -// Copyright 2011 Google, Inc. +// Copyright 2011 Google, Inc. // 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) #include -#include #include #include #include @@ -33,73 +32,7 @@ #include #include +#include +#include -namespace boost { namespace network { namespace http { - -struct request_pimpl; - -struct request : request_base { - // FIXME Implement all these! - - // From message_base... - // Mutators - virtual void set_destination(std::string const & destination); - virtual void set_source(std::string const & source); - virtual void append_header(std::string const & name, - std::string const & value); - virtual void remove_headers(std::string const & name); - virtual void remove_headers(); - virtual void set_body(std::string const & body); - virtual void append_body(std::string const & data); - - // Retrievers - virtual void get_destination(std::string & destination); - virtual void get_source(std::string & source); - virtual void get_headers(function inserter); - virtual void get_headers(std::string const & name, function inserter); - virtual void get_headers(function predicate, function inserter); - virtual void get_body(std::string & body); - virtual void get_body(function)> chunk_reader, size_t size); - - // From request_base... - // Setters - virtual void set_method(std::string const & method); - virtual void set_status(std::string const & status); - virtual void set_status_message(std::string const & status_message); - virtual void set_body_stream(shared_ptr stream); - virtual void set_uri(std::string const &uri); - virtual void set_uri(network::uri::uri const &uri); - - // Getters - virtual void get_uri(network::uri::uri &uri); - virtual void get_uri(std::string &uri); - virtual void get_method(std::string & method); - virtual void get_status(std::string & status); - virtual void get_status_message(std::string & status_message); - virtual void get_body_stream(body_stream & output_stream); - - virtual ~request(); - private: - request_pimpl * pimpl_; -}; - -template -request_base & operator<< (request_base & request, - Directive const & directive) { - directive(request); - return request; -} - -} // namespace http - -} // namespace network - -} // namespace boost - -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif - -#include - -#endif // __NETWORK_PROTOCOL_HTTP_REQUEST_20070908-1_HPP__ +#endif // BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_HPP_20111021 diff --git a/boost/network/protocol/http/request/request.hpp b/boost/network/protocol/http/request/request.hpp new file mode 100644 index 000000000..eab2164d2 --- /dev/null +++ b/boost/network/protocol/http/request/request.hpp @@ -0,0 +1,79 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_REQUEST_HPP_20111021 +#define BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_REQUEST_HPP_20111021 + +// Copyright 2011 Dean Michael Berris (dberris@google.com). +// Copyright 2011 Google, Inc. +// 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) + +#include + +namespace boost { namespace network { namespace http { + +struct request_pimpl; + +struct request : request_base { + // FIXME Implement all these! + + // From message_base... + // Mutators + virtual void set_destination(std::string const & destination); + virtual void set_source(std::string const & source); + virtual void append_header(std::string const & name, + std::string const & value); + virtual void remove_headers(std::string const & name); + virtual void remove_headers(); + virtual void set_body(std::string const & body); + virtual void append_body(std::string const & data); + + // Retrievers + virtual void get_destination(std::string & destination); + virtual void get_source(std::string & source); + virtual void get_headers(function inserter); + virtual void get_headers(std::string const & name, function inserter); + virtual void get_headers(function predicate, function inserter); + virtual void get_body(std::string & body); + virtual void get_body(function)> chunk_reader, size_t size); + + // From request_base... + // Setters + virtual void set_method(std::string const & method); + virtual void set_status(std::string const & status); + virtual void set_status_message(std::string const & status_message); + virtual void set_body_stream(shared_ptr stream); + virtual void set_uri(std::string const &uri); + virtual void set_uri(network::uri::uri const &uri); + + // Getters + virtual void get_uri(network::uri::uri &uri); + virtual void get_uri(std::string &uri); + virtual void get_method(std::string & method); + virtual void get_status(std::string & status); + virtual void get_status_message(std::string & status_message); + virtual void get_body_stream(body_stream & output_stream); + + virtual ~request(); + private: + request_pimpl * pimpl_; +}; + +template +request_base & operator<< (request_base & request, + Directive const & directive) { + directive(request); + return request; +} + +} // namespace http + +} // namespace network + +} // namespace boost + +#ifdef BOOST_NETWORK_NO_LIB +#include +#endif + + +#endif /* BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_REQUEST_HPP_20111021 */ diff --git a/boost/network/protocol/http/request.ipp b/boost/network/protocol/http/request/request.ipp similarity index 100% rename from boost/network/protocol/http/request.ipp rename to boost/network/protocol/http/request/request.ipp diff --git a/boost/network/protocol/http/request_base.hpp b/boost/network/protocol/http/request/request_base.hpp similarity index 98% rename from boost/network/protocol/http/request_base.hpp rename to boost/network/protocol/http/request/request_base.hpp index 2d532754a..d8369cdff 100644 --- a/boost/network/protocol/http/request_base.hpp +++ b/boost/network/protocol/http/request/request_base.hpp @@ -11,7 +11,7 @@ #define BOOST_NETWORK_BUFFER_CHUNK 1024 // We want 1KiB worth of data at least. #endif -#include +#include #include #include diff --git a/boost/network/protocol/http/request_concept.hpp b/boost/network/protocol/http/request/request_concept.hpp similarity index 100% rename from boost/network/protocol/http/request_concept.hpp rename to boost/network/protocol/http/request/request_concept.hpp diff --git a/boost/network/protocol/http/response.hpp b/boost/network/protocol/http/response.hpp index f8e1aa094..70a9f0521 100644 --- a/boost/network/protocol/http/response.hpp +++ b/boost/network/protocol/http/response.hpp @@ -9,7 +9,7 @@ #include -#include +#include #include #include #include @@ -25,64 +25,7 @@ #include #include -#include - -namespace boost { namespace network { namespace http { - -struct response : response_base { - // FIXME implement all these! - - // From message_base... - // Mutators - virtual void set_destination(std::string const & destination); - virtual void set_source(std::string const & source); - virtual void append_header(std::string const & name, - std::string const & value); - virtual void remove_headers(std::string const & name); - virtual void remove_headers(); - virtual void set_body(std::string const & body); - virtual void append_body(std::string const & data); - - // Retrievers - virtual void get_destination(std::string & destination); - virtual void get_source(std::string & source); - virtual void get_headers(function inserter); - virtual void get_headers(std::string const & name, function inserter); - virtual void get_headers(function predicate, function inserter); - virtual void get_body(std::string & body); - virtual void get_body(function)> chunk_reader, size_t size); - - // From response_base... - virtual void set_status(std::string const & new_status); - virtual void set_status_message(std::string const & new_status_message); - virtual void set_version(std::string const & new_version); - virtual ~response(); -}; - -} // namespace http - -} // namespace network - -} // namespace boost - -#include - -namespace boost { namespace network { namespace http { - - template - response & operator<<( - response & message, - Directive const & directive - ) - { - directive(message); - return message; - } - -} // namespace http - -} // namespace network - -} // namespace boost +#include +#include #endif // BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_HPP diff --git a/boost/network/protocol/http/response/response.hpp b/boost/network/protocol/http/response/response.hpp new file mode 100644 index 000000000..7b22c0cac --- /dev/null +++ b/boost/network/protocol/http/response/response.hpp @@ -0,0 +1,65 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_RESPONSE_HPP_20111021 +#define BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_RESPONSE_HPP_20111021 + +// Copyright 2011 Dean Michael Berris (dberris@google.com). +// Copyright 2011 Google, Inc. +// 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) + +namespace boost { namespace network { namespace http { + +struct response : response_base { + // FIXME implement all these! + + // From message_base... + // Mutators + virtual void set_destination(std::string const & destination); + virtual void set_source(std::string const & source); + virtual void append_header(std::string const & name, + std::string const & value); + virtual void remove_headers(std::string const & name); + virtual void remove_headers(); + virtual void set_body(std::string const & body); + virtual void append_body(std::string const & data); + + // Retrievers + virtual void get_destination(std::string & destination); + virtual void get_source(std::string & source); + virtual void get_headers( + function inserter); + virtual void get_headers( + std::string const & name, + function inserter); + virtual void get_headers( + function predicate, + function inserter); + virtual void get_body(std::string & body); + virtual void get_body( + function)> chunk_reader, + size_t size); + + // From response_base... + virtual void set_status(std::string const & new_status); + virtual void set_status_message(std::string const & new_status_message); + virtual void set_version(std::string const & new_version); + virtual ~response(); +}; + +template +response & operator<<( + response & message, + Directive const & directive + ) +{ + directive(message); + return message; +} + +} // namespace http + +} // namespace network + +} // namespace boost + +#endif /* BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_RESPONSE_HPP_20111021 */ diff --git a/boost/network/protocol/http/response_base.hpp b/boost/network/protocol/http/response/response_base.hpp similarity index 100% rename from boost/network/protocol/http/response_base.hpp rename to boost/network/protocol/http/response/response_base.hpp diff --git a/boost/network/protocol/http/response_concept.hpp b/boost/network/protocol/http/response/response_concept.hpp similarity index 100% rename from boost/network/protocol/http/response_concept.hpp rename to boost/network/protocol/http/response/response_concept.hpp diff --git a/libs/network/src/message.cpp b/libs/network/src/message.cpp index eb2f65a04..bc54a74e7 100644 --- a/libs/network/src/message.cpp +++ b/libs/network/src/message.cpp @@ -11,4 +11,4 @@ #undef BOOST_NETWORK_NO_LIB #endif -#include +#include From 3a68cff37ab86f92f794cc3aa687fd7b6599d5f3 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Fri, 21 Oct 2011 16:27:15 +1100 Subject: [PATCH 016/196] Fleshing out more implementations. --- boost/network/message/directives/header.hpp | 23 +++--- boost/network/message/directives/header.ipp | 28 ++++++++ .../message/directives/remove_header.hpp | 20 +++--- .../message/directives/remove_header.ipp | 27 +++++++ boost/network/message/message_base.ipp | 2 +- boost/network/message/wrappers/body.hpp | 11 ++- boost/network/message/wrappers/body.ipp | 71 +++++++++++++++++++ .../network/message/wrappers/destination.hpp | 9 ++- .../network/message/wrappers/destination.ipp | 33 +++++++++ boost/network/message/wrappers/headers.hpp | 19 ++--- boost/network/message/wrappers/headers.ipp | 50 ++++++++----- boost/network/message/wrappers/source.hpp | 9 +-- boost/network/message/wrappers/source.ipp | 33 +++++++++ libs/network/build/CMakeLists.txt | 11 ++- libs/network/src/CMakeLists.txt | 11 ++- libs/network/src/message/directives.cpp | 15 ++++ libs/network/src/{ => message}/message.cpp | 1 + libs/network/src/message/wrappers.cpp | 13 ++++ libs/network/test/CMakeLists.txt | 16 +++-- libs/network/test/message_test.cpp | 5 +- 20 files changed, 330 insertions(+), 77 deletions(-) create mode 100644 boost/network/message/directives/header.ipp create mode 100644 boost/network/message/directives/remove_header.ipp create mode 100644 boost/network/message/wrappers/body.ipp create mode 100644 boost/network/message/wrappers/destination.ipp create mode 100644 boost/network/message/wrappers/source.ipp create mode 100644 libs/network/src/message/directives.cpp rename libs/network/src/{ => message}/message.cpp (90%) create mode 100644 libs/network/src/message/wrappers.cpp diff --git a/boost/network/message/directives/header.hpp b/boost/network/message/directives/header.hpp index 23c849508..9edc7e0b0 100644 --- a/boost/network/message/directives/header.hpp +++ b/boost/network/message/directives/header.hpp @@ -14,21 +14,12 @@ namespace boost { namespace network { namespace impl { struct header_directive { - - explicit header_directive(std::string const & header_name, - std::string const & header_value) : - _header_name(header_name), - _header_value(header_value) - { }; - - void operator() (message_base & msg) const { - msg.append_header(_header_name, _header_value); - } - + explicit header_directive(std::string const & name, + std::string const & value); + void operator() (message_base & msg) const; private: - - std::string const & _header_name; - std::string const & _header_value; + std::string const & name_; + std::string const & value_; }; } // namespace impl @@ -40,4 +31,8 @@ header(std::string const & header_name, std::string const & header_value) { } // namespace network } // namespace boost +#ifdef BOOST_NETWORK_NO_LIB +#include +#endif + #endif // __NETWORK_MESSAGE_DIRECTIVES_HEADER_HPP__ diff --git a/boost/network/message/directives/header.ipp b/boost/network/message/directives/header.ipp new file mode 100644 index 000000000..5c5401a1f --- /dev/null +++ b/boost/network/message/directives/header.ipp @@ -0,0 +1,28 @@ +#ifndef BOOST_NETWORK_MESSAGE_DIRECTIVES_IPP_20111021 +#define BOOST_NETWORK_MESSAGE_DIRECTIVES_IPP_20111021 + +// Copyright 2011 Dean Michael Berris (dberris@google.com). +// Copyright 2011 Google, Inc. +// 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) + +#include +#include + +namespace boost { namespace network { namespace impl { + +header_directive::header_directive(std::string const & name, + std::string const & value): + name_(name), + value_(value) {} + +void header_directive::operator() (message_base & msg) const { + msg.append_header(name_, value_); +} + +} /* impl */ +} /* network */ +} /* boost */ + +#endif /* BOOST_NETWORK_MESSAGE_DIRECTIVES_IPP_20111021 */ diff --git a/boost/network/message/directives/remove_header.hpp b/boost/network/message/directives/remove_header.hpp index 1a1f4f63e..958434b46 100644 --- a/boost/network/message/directives/remove_header.hpp +++ b/boost/network/message/directives/remove_header.hpp @@ -1,13 +1,11 @@ +#ifndef BOOST_NETWORK_MESSAGE_DIRECTIVES_REMOVE_HEADER_HPP_20111021 +#define BOOST_NETWORK_MESSAGE_DIRECTIVES_REMOVE_HEADER_HPP_20111021 // Copyright 2011 Dean Michael Berris . -// Copyright 2011 Google, Inc. +// Copyright 2011 Google, Inc. // 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 NETWORK_MESSAGE_DIRECTIVES_REMOVE_HEADER_HPP -#define NETWORK_MESSAGE_DIRECTIVES_REMOVE_HEADER_HPP - +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) namespace boost { namespace network { @@ -15,7 +13,7 @@ namespace impl { struct remove_header_directive { explicit remove_header_directive(std::string const & header_name); - void operator() (message_base & msg) const; + void operator() (message_base & msg) const; private: std::string const & header_name_; }; @@ -29,6 +27,8 @@ remove_header(std::string const & header_name) { } // namespace network } // namespace boost +#ifdef BOOST_NETWORK_NO_LIB +#undef BOOST_NETWORK_NO_LIB +#endif -#endif // NETWORK_MESSAGE_DIRECTIVES_REMOVE_HEADER_HPP - +#endif // BOOST_NETWORK_MESSAGE_DIRECTIVES_REMOVE_HEADER_HPP_20111021 diff --git a/boost/network/message/directives/remove_header.ipp b/boost/network/message/directives/remove_header.ipp new file mode 100644 index 000000000..b732983e6 --- /dev/null +++ b/boost/network/message/directives/remove_header.ipp @@ -0,0 +1,27 @@ +#ifndef BOOST_NETWORK_MESSAGE_DIRECTIVES_REMOVE_HEADER_IPP_20111021 +#define BOOST_NETWORK_MESSAGE_DIRECTIVES_REMOVE_HEADER_IPP_20111021 + +// Copyright 2011 Dean Michael Berris (dberris@google.com). +// Copyright 2011 Google, Inc. +// 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) + +#include + +namespace boost { namespace network { namespace impl { + +remove_header_directive::remove_header_directive(std::string const & header_name): + header_name_(header_name) {} + +void remove_header_directive::operator() (message_base & msg) const { + msg.remove_headers(header_name_); +} + +} /* impl */ + +} /* network */ + +} /* boost */ + +#endif /* BOOST_NETWORK_MESSAGE_DIRECTIVES_REMOVE_HEADER_IPP_20111021 */ diff --git a/boost/network/message/message_base.ipp b/boost/network/message/message_base.ipp index 061d2a6f6..0ef383e9b 100644 --- a/boost/network/message/message_base.ipp +++ b/boost/network/message/message_base.ipp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { diff --git a/boost/network/message/wrappers/body.hpp b/boost/network/message/wrappers/body.hpp index 093334fb2..cf0b37d78 100644 --- a/boost/network/message/wrappers/body.hpp +++ b/boost/network/message/wrappers/body.hpp @@ -1,12 +1,11 @@ +#ifndef BOOST_NETWORK_MESSAGE_WRAPPERS_BODY_HPP_20110930 +#define BOOST_NETWORK_MESSAGE_WRAPPERS_BODY_HPP_20110930 // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 BOOST_NETWORK_MESSAGE_WRAPPERS_BODY_HPP_20110930 -#define BOOST_NETWORK_MESSAGE_WRAPPERS_BODY_HPP_20110930 +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) #include #include @@ -17,7 +16,7 @@ namespace boost { namespace network { namespace impl { struct body_wrapper { - explicit body_wrapper(message_base & message_); + explicit body_wrapper(message_base & message); operator std::string () const; std::size_t size() const; operator iterator_range () const; diff --git a/boost/network/message/wrappers/body.ipp b/boost/network/message/wrappers/body.ipp new file mode 100644 index 000000000..0c24f67bc --- /dev/null +++ b/boost/network/message/wrappers/body.ipp @@ -0,0 +1,71 @@ +#ifndef BOOST_NETWORK_MESSAGE_WRAPPERS_BODY_IPP_20111021 +#define BOOST_NETWORK_MESSAGE_WRAPPERS_BODY_IPP_20111021 + +// Copyright 2011 Dean Michael Berris (dberris@google.com). +// Copyright 2011 Google, Inc. +// 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) + +#include + +namespace boost { namespace network { namespace impl { + +body_wrapper::body_wrapper(message_base & message): + message_(message) {} + +body_wrapper::operator std::string () const { + if (cache_) { + return *cache_; + } + std::string tmp; + message_.get_body(tmp); + cache_ = tmp; + return *cache_; +} + +std::size_t body_wrapper::size() const { + if (cache_) { + return cache_->size(); + } + std::string tmp; + message_.get_body(tmp); + cache_ = tmp; + return cache_->size(); +} + +body_wrapper::operator boost::iterator_range () const { + if (cache_) { + return boost::make_iterator_range(*cache_); + } + std::string tmp; + message_.get_body(tmp); + cache_ = tmp; + return boost::make_iterator_range(*cache_); +} + +std::string::const_iterator body_wrapper::begin() const { + if (cache_) { + return cache_->begin(); + } + std::string tmp; + message_.get_body(tmp); + cache_ = tmp; + return cache_->begin(); +} + +std::string::const_iterator body_wrapper::end() const { + if (cache_) { + return cache_->end(); + } + std::string tmp; + message_.get_body(tmp); + cache_ = tmp; + return cache_->end(); +} + +} /* impl */ +} /* network */ +} /* boost */ + +#endif /* BOOST_NETWORK_MESSAGE_WRAPPERS_BODY_IPP_20111021 */ diff --git a/boost/network/message/wrappers/destination.hpp b/boost/network/message/wrappers/destination.hpp index 4330f115b..a6d9e355c 100644 --- a/boost/network/message/wrappers/destination.hpp +++ b/boost/network/message/wrappers/destination.hpp @@ -2,7 +2,7 @@ #define __NETWORK_MESSAGE_WRAPPERS_DESTINATION_HPP__ // Copyright 2011 Dean Michael Berris . -// Copyright 2011 Google, Inc. +// Copyright 2011 Google, Inc. // 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) @@ -14,8 +14,11 @@ namespace boost { namespace network { namespace impl { struct destination_wrapper { - explicit destination_wrapper(message_base & message_); - operator std::string () const; + explicit destination_wrapper(message_base & message); + operator std::string () const; + private: + message_base & message_; + mutable optional cache_; }; } // namespace impl diff --git a/boost/network/message/wrappers/destination.ipp b/boost/network/message/wrappers/destination.ipp new file mode 100644 index 000000000..cb99e62f5 --- /dev/null +++ b/boost/network/message/wrappers/destination.ipp @@ -0,0 +1,33 @@ +#ifndef BOOST_NETWORK_MESSAGE_WRAPPERS_DESTINATION_IPP_20111021 +#define BOOST_NETWORK_MESSAGE_WRAPPERS_DESTINATION_IPP_20111021 + +// Copyright 2011 Dean Michael Berris (dberris@google.com). +// Copyright 2011 Google, Inc. +// 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) + +#include + +namespace boost { namespace network { namespace impl { + +destination_wrapper::destination_wrapper(message_base & message): + message_(message) {} + +destination_wrapper::operator std::string () const { + if (cache_) { + return *cache_; + } + std::string tmp; + message_.get_destination(tmp); + cache_ = tmp; + return *cache_; +} + +} /* impl */ + +} /* network */ + +} /* boost */ + +#endif /* BOOST_NETWORK_MESSAGE_WRAPPERS_DESTINATION_IPP_20111021 */ diff --git a/boost/network/message/wrappers/headers.hpp b/boost/network/message/wrappers/headers.hpp index 41f4daab4..71a5e1907 100644 --- a/boost/network/message/wrappers/headers.hpp +++ b/boost/network/message/wrappers/headers.hpp @@ -24,27 +24,23 @@ namespace impl { * a range of iterators (std::pair) * whose keys are all equal to the index string. * - * This type is also convertible to a - * headers_range >::type - * Which allows for full range support. - * - * The type is also convertible to a - * headers_container::type - * Which copies the headers from the wrapped message. - * */ struct headers_wrapper { typedef std::multimap container_type; - typedef iterator_range > - range_type; + typedef shared_container_iterator iterator; + typedef iterator_range range_type; explicit headers_wrapper(message_base & message); range_type operator[] (std::string const & key) const; operator range_type () const; + operator container_type () const; container_type::size_type count() const; container_type::size_type count(std::string const &key) const; + iterator begin() const; + iterator end() const; private: - void init_cache_all(); + void init_cache_all() const; + message_base & message_; mutable shared_ptr cache_; }; @@ -65,4 +61,3 @@ headers(message_base & message_) { #endif #endif // __NETWORK_MESSAGE_WRAPPERS_HEADERS_HPP__ - diff --git a/boost/network/message/wrappers/headers.ipp b/boost/network/message/wrappers/headers.ipp index b2afc7751..80825fd23 100644 --- a/boost/network/message/wrappers/headers.ipp +++ b/boost/network/message/wrappers/headers.ipp @@ -8,60 +8,76 @@ // http://www.boost.org/LICENSE_1_0.txt) #include +#include -namespace boost { namespace network { +namespace boost { namespace network { namespace impl { headers_wrapper::headers_wrapper(message_base & message) : message_(message) {} -range_type headers_wrapper::operator[] (std::string const & key) const { - cache_.reset(new (std::nothrow) container_type); - if (!cache_.get()) - BOOST_THROW_EXCEPTION(std::runtime_error( - "Cannot allocate cache multimap for headers wrapper.")); - message_.get_headers( - key, - std::inserter(*cache_, cache_->end())); - return make_shared_container_range(cache_); +headers_wrapper::range_type headers_wrapper::operator[] (std::string const & key) const { + this->init_cache_all(); + std::pair p = + cache_->equal_range(key); + return boost::make_iterator_range( + boost::make_shared_container_iterator( + p.first, cache_), + boost::make_shared_container_iterator( + p.second, cache_)); } headers_wrapper::container_type::size_type -headers_wrapper::count(string_type const & key) const { +headers_wrapper::count(std::string const & key) const { this->init_cache_all(); return cache_->size(); } headers_wrapper::iterator headers_wrapper::begin() const { this->init_cache_all(); - return make_shared_container_iterator(cache_->begin()); + container_type::iterator begin = cache_->begin(); + return make_shared_container_iterator(begin, cache_); } headers_wrapper::iterator headers_wrapper::end() const { this->init_cache_all(); - return make_shared_container_iterator(cache_->end()); + container_type::iterator end = cache_->end(); + return make_shared_container_iterator(end, cache_); }; -headers_wrapper::operator headers_wrapper::range_type () { +headers_wrapper::operator headers_wrapper::range_type () const { this->init_cache_all(); return make_shared_container_range(cache_); }; -headers_wrapper::operator headers_wrapper::container_type () { +headers_wrapper::operator headers_wrapper::container_type () const { this->init_cache_all(); return *cache_; } -void headers_wrapper::init_cache_all() { +template +struct kv_inserter { + kv_inserter(Map & m) + : m_(m) {} + void operator() (std::string const & k, std::string const & v) const { + m_.insert(std::make_pair(k, v)); + } + private: + Map & m_; +}; + +void headers_wrapper::init_cache_all() const { if (!cache_.get()) { cache_.reset(new (std::nothrow) container_type); if (!cache_.get()) BOOST_THROW_EXCEPTION(std::runtime_error( "Cannot allocate cache multimap for headers wrapper.")); - message_.get_headers(std::inserter(*cache_, cache_->end())); + message_.get_headers(kv_inserter(*cache_)); } } +} /* impl */ + } /* network */ } /* boost */ diff --git a/boost/network/message/wrappers/source.hpp b/boost/network/message/wrappers/source.hpp index 788ec90a5..84c7f6fe8 100644 --- a/boost/network/message/wrappers/source.hpp +++ b/boost/network/message/wrappers/source.hpp @@ -1,5 +1,5 @@ -#ifndef __NETWORK_MESSAGE_WRAPPERS_SOURCE_HPP__ -#define __NETWORK_MESSAGE_WRAPPERS_SOURCE_HPP__ +#ifndef BOOST_NETWORK_MESSAGE_WRAPPERS_SOURCE_HPP_20111021 +#define BOOST_NETWORK_MESSAGE_WRAPPERS_SOURCE_HPP_20111021 // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. @@ -14,10 +14,11 @@ namespace boost { namespace network { namespace impl { struct source_wrapper { - explicit source_wrapper(message_base & message_); + explicit source_wrapper(message_base & message); operator std::string () const; private: message_base & message_; + mutable boost::optional cache_; }; } // namespace impl @@ -35,4 +36,4 @@ source(message_base & message_) { #include #endif -#endif // __NETWORK_MESSAGE_WRAPPERS_SOURCE_HPP__ +#endif // BOOST_NETWORK_MESSAGE_WRAPPERS_SOURCE_HPP_20111021 diff --git a/boost/network/message/wrappers/source.ipp b/boost/network/message/wrappers/source.ipp new file mode 100644 index 000000000..829d3876f --- /dev/null +++ b/boost/network/message/wrappers/source.ipp @@ -0,0 +1,33 @@ +#ifndef BOOST_NETWORK_MESSAGE_WRAPPERS_SOURCE_IPP_20111021 +#define BOOST_NETWORK_MESSAGE_WRAPPERS_SOURCE_IPP_20111021 + +// Copyright 2011 Dean Michael Berris (dberris@google.com). +// Copyright 2011 Google, Inc. +// 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) + +#include + +namespace boost { namespace network { namespace impl { + +source_wrapper::source_wrapper(message_base & message): + message_(message) {} + +source_wrapper::operator std::string () const { + if (cache_) { + return *cache_; + } + std::string tmp; + message_.get_source(tmp); + cache_ = tmp; + return *cache_; +} + +} /* impl */ + +} /* network */ + +} /* boost */ + +#endif /* BOOST_NETWORK_MESSAGE_WRAPPERS_SOURCE_IPP_20111021 */ diff --git a/libs/network/build/CMakeLists.txt b/libs/network/build/CMakeLists.txt index e7dbee625..305bb82ce 100644 --- a/libs/network/build/CMakeLists.txt +++ b/libs/network/build/CMakeLists.txt @@ -3,4 +3,13 @@ find_package( Boost 1.43.0 COMPONENTS unit_test_framework system regex thread fi add_library(cppnetlib-uri STATIC ${CPP-NETLIB_SOURCE_DIR}/libs/network/src/parse_uri_impl.cpp) add_library(cppnetlib-server-parsers STATIC ${CPP-NETLIB_SOURCE_DIR}/libs/network/src/server_request_parsers_impl.cpp) -add_library(cppnetlib-message STATIC ${CPP-NETLIB_SOURCE_DIR}/libs/network/src/message.cpp) +add_library(cppnetlib-message + STATIC + ${CPP-NETLIB_SOURCE_DIR}/libs/network/src/message/message.cpp) +add_library(cppnetlib-message-directives + STATIC + ${CPP-NETLIB_SOURCE_DIR}/libs/network/src/message/directives.cpp) +add_library(cppnetlib-http-message + STATIC + ${CPP-NETLIB_SOURCE_DIR}/libs/network/src/http/request.cpp + ${CPP-NETLIB_SOURCE_DIR}/libs/network/src/http/response.cpp) diff --git a/libs/network/src/CMakeLists.txt b/libs/network/src/CMakeLists.txt index 9e38860f6..6680dbd89 100644 --- a/libs/network/src/CMakeLists.txt +++ b/libs/network/src/CMakeLists.txt @@ -16,5 +16,14 @@ add_library(cppnetlib-server-parsers ${CPP-NETLIB_HTTP_SERVER_SRCS}) set(CPP-NETLIB_HTTP_CLIENT_SRCS client.cpp) add_library(cppnetlib-client-connections ${CPP-NETLIB_HTTP_CLIENT_SRCS}) -set(CPP-NETLIB_MESSAGE_SRCS message.cpp) +set(CPP-NETLIB_MESSAGE_SRCS message/message.cpp) add_library(cppnetlib-message ${CPP-NETLIB_MESSAGE_SRCS}) + +set(CPP-NETLIB_MESSAGE_DIRECTIVES_SRCS message/directives.cpp) +add_library(cppnetlib-message-directives ${CPP-NETLIB_MESSAGE_DIRECTIVES_SRCS}) + +set(CPP-NETLIB_MESSAGE_WRAPPERS_SRCS message/wrappers.cpp) +add_library(cppnetlib-message-wrappers ${CPP-NETLIB_MESSAGE_WRAPPERS_SRCS}) + +set(CPP-NETLIB_HTTP_MESSAGE_SRCS http/request.cpp http/response.cpp) +add_library(cppnetlib-http-message ${CPP-NETLIB_HTTP_MESSAGE_SRCS}) diff --git a/libs/network/src/message/directives.cpp b/libs/network/src/message/directives.cpp new file mode 100644 index 000000000..960ce80d9 --- /dev/null +++ b/libs/network/src/message/directives.cpp @@ -0,0 +1,15 @@ +// Copyright 2011 Dean Michael Berris (dberris@google.com). +// Copyright 2011 Google, Inc. +// 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) + +// This is the directives file where all standard directives on messages are +// pulled in and compiled into a library. + +#ifdef BOOST_NETWORK_NO_LIB +#undef BOOST_NETWORK_NO_LIB +#endif + +#include +#include diff --git a/libs/network/src/message.cpp b/libs/network/src/message/message.cpp similarity index 90% rename from libs/network/src/message.cpp rename to libs/network/src/message/message.cpp index bc54a74e7..d92958017 100644 --- a/libs/network/src/message.cpp +++ b/libs/network/src/message/message.cpp @@ -12,3 +12,4 @@ #endif #include +#include diff --git a/libs/network/src/message/wrappers.cpp b/libs/network/src/message/wrappers.cpp new file mode 100644 index 000000000..95374e599 --- /dev/null +++ b/libs/network/src/message/wrappers.cpp @@ -0,0 +1,13 @@ +// Copyright 2011 Dean Michael Berris (dberris@google.com). +// Copyright 2011 Google, Inc. +// 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) + +// This file conglomerates all the standard wrappers that come with cpp-netlib. +// It just includes all the implementation files that get turned into a library. + +#include +#include +#include +#include diff --git a/libs/network/test/CMakeLists.txt b/libs/network/test/CMakeLists.txt index 7e3b7a531..48bc6a707 100644 --- a/libs/network/test/CMakeLists.txt +++ b/libs/network/test/CMakeLists.txt @@ -22,11 +22,19 @@ if (Boost_FOUND) set_source_files_properties(${test}.cpp PROPERTIES COMPILE_FLAGS "-Wall") add_executable(cpp-netlib-${test} ${test}.cpp) - add_dependencies(cpp-netlib-${test} cppnetlib-uri cppnetlib-message) + add_dependencies(cpp-netlib-${test} + cppnetlib-uri + cppnetlib-message + cppnetlib-message-directives + cppnetlib-message-wrappers) - # add_dependencies(cpp-netlib-${test} cppnetlib-uri) - # target_link_libraries(cpp-netlib-${test} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri) - target_link_libraries(cpp-netlib-${test} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri cppnetlib-message) + target_link_libraries(cpp-netlib-${test} + ${Boost_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} + cppnetlib-uri + cppnetlib-message + cppnetlib-message-directives + cppnetlib-message-wrappers) if (OPENSSL_FOUND) target_link_libraries(cpp-netlib-${test} ${OPENSSL_LIBRARIES}) endif() diff --git a/libs/network/test/message_test.cpp b/libs/network/test/message_test.cpp index 775ee8087..ae61973d8 100644 --- a/libs/network/test/message_test.cpp +++ b/libs/network/test/message_test.cpp @@ -7,9 +7,8 @@ #define BOOST_TEST_MODULE message test #include #include -#include +#include #include -#include using namespace boost::network; @@ -71,5 +70,3 @@ BOOST_AUTO_TEST_CASE(remove_header_directive_test) { message::headers_range range = headers(instance); BOOST_CHECK ( boost::begin(range) == boost::end(range) ); } - - From fcc93d7870021e7deb67c9b393812eeb965f640e Mon Sep 17 00:00:00 2001 From: Glyn Matthews Date: Sat, 22 Oct 2011 08:22:22 +0200 Subject: [PATCH 017/196] Some minor fixes to make sure that the tests could build on MSVC. --- boost/network/message/message.ipp | 1 + libs/network/src/CMakeLists.txt | 4 ++-- libs/network/test/message_test.cpp | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/boost/network/message/message.ipp b/boost/network/message/message.ipp index 370cdbe2e..88f17ba9e 100644 --- a/boost/network/message/message.ipp +++ b/boost/network/message/message.ipp @@ -135,6 +135,7 @@ message::message(message const & other) message& message::operator=(message other) { *pimpl = *other.pimpl; + return *this; } message::~message() { diff --git a/libs/network/src/CMakeLists.txt b/libs/network/src/CMakeLists.txt index 6680dbd89..1e87917b5 100644 --- a/libs/network/src/CMakeLists.txt +++ b/libs/network/src/CMakeLists.txt @@ -25,5 +25,5 @@ add_library(cppnetlib-message-directives ${CPP-NETLIB_MESSAGE_DIRECTIVES_SRCS}) set(CPP-NETLIB_MESSAGE_WRAPPERS_SRCS message/wrappers.cpp) add_library(cppnetlib-message-wrappers ${CPP-NETLIB_MESSAGE_WRAPPERS_SRCS}) -set(CPP-NETLIB_HTTP_MESSAGE_SRCS http/request.cpp http/response.cpp) -add_library(cppnetlib-http-message ${CPP-NETLIB_HTTP_MESSAGE_SRCS}) +#set(CPP-NETLIB_HTTP_MESSAGE_SRCS http/request.cpp http/response.cpp) +#add_library(cppnetlib-http-message ${CPP-NETLIB_HTTP_MESSAGE_SRCS}) diff --git a/libs/network/test/message_test.cpp b/libs/network/test/message_test.cpp index ae61973d8..92a6b9103 100644 --- a/libs/network/test/message_test.cpp +++ b/libs/network/test/message_test.cpp @@ -67,6 +67,6 @@ BOOST_AUTO_TEST_CASE(remove_header_directive_test) { message instance; instance << header("name", "value") << remove_header("name"); - message::headers_range range = headers(instance); + message::headers_range range = headers(instance)["name"]; BOOST_CHECK ( boost::begin(range) == boost::end(range) ); } From f867bdb9e8a229e50a5174c4554938e87f9e1564 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Fri, 28 Oct 2011 13:48:27 +1100 Subject: [PATCH 018/196] Adding missing HTTP implementations. --- libs/network/src/http/request.cpp | 0 libs/network/src/http/response.cpp | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 libs/network/src/http/request.cpp create mode 100644 libs/network/src/http/response.cpp diff --git a/libs/network/src/http/request.cpp b/libs/network/src/http/request.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/libs/network/src/http/response.cpp b/libs/network/src/http/response.cpp new file mode 100644 index 000000000..e69de29bb From 144f21d519c356d07ffae41872243be860ce6d09 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Fri, 28 Oct 2011 13:58:14 +1100 Subject: [PATCH 019/196] Fixes to transformer and thread pool libs. --- boost/network/include/message.hpp | 1 - .../network/message/transformers/to_lower.hpp | 113 +++++++++--------- .../network/message/transformers/to_upper.hpp | 86 ++++++------- boost/network/utils/thread_pool.hpp | 109 ++++------------- libs/network/src/CMakeLists.txt | 3 + libs/network/test/CMakeLists.txt | 14 ++- 6 files changed, 140 insertions(+), 186 deletions(-) diff --git a/boost/network/include/message.hpp b/boost/network/include/message.hpp index 539292673..2f7d00897 100644 --- a/boost/network/include/message.hpp +++ b/boost/network/include/message.hpp @@ -8,7 +8,6 @@ // // This is the modular include file for using the basic message type -#include #include #endif // BOOST_NETWORK_INCLUDE_MESSAGE_HPP_ diff --git a/boost/network/message/transformers/to_lower.hpp b/boost/network/message/transformers/to_lower.hpp index 75ed3a67b..aa2227c6e 100644 --- a/boost/network/message/transformers/to_lower.hpp +++ b/boost/network/message/transformers/to_lower.hpp @@ -8,6 +8,7 @@ #define __NETWORK_MESSAGE_TRANSFORMERS_TO_LOWER_HPP__ #include +#include /** to_lower.hpp * @@ -18,61 +19,63 @@ * This defines a type, to be applied using template * metaprogramming on the selected string target. */ -namespace boost { namespace network { - - namespace impl { - - template - struct to_lower_transformer { }; - - template <> - struct to_lower_transformer { - template - void operator() (basic_message & message_) const { - boost::to_lower(message_.source()); - } - - protected: - ~to_lower_transformer() { } - }; - - template <> - struct to_lower_transformer { - template - void operator() (basic_message & message_) const { - boost::to_lower(message_.destination()); - } - - protected: - ~to_lower_transformer() { }; - }; - - } // namespace impl - - namespace detail { - struct to_lower_placeholder_helper; - } - - detail::to_lower_placeholder_helper to_lower_(detail::to_lower_placeholder_helper); - - namespace detail { - - struct to_lower_placeholder_helper { - template - struct type : public impl::to_lower_transformer { }; - private: - to_lower_placeholder_helper() {} - to_lower_placeholder_helper(to_lower_placeholder_helper const &) {} - friend to_lower_placeholder_helper boost::network::to_lower_(to_lower_placeholder_helper); - }; - - } - - typedef detail::to_lower_placeholder_helper (*to_lower_placeholder)(detail::to_lower_placeholder_helper); - - inline detail::to_lower_placeholder_helper to_lower_(detail::to_lower_placeholder_helper) { - return detail::to_lower_placeholder_helper(); - } +namespace boost { namespace network { namespace impl { + +template +struct to_lower_transformer { }; + +template <> +struct to_lower_transformer { + void operator() (message_base & message_) const { + std::string source_; + message_.get_source(source_); + boost::to_lower(source_); + message_.set_source(source_); + } + + protected: + ~to_lower_transformer() { } +}; + +template <> +struct to_lower_transformer { + void operator() (message_base & message_) const { + std::string destination_; + message_.get_destination(destination_); + boost::to_lower(destination_); + message_.set_destination(destination_); + } + + protected: + ~to_lower_transformer() { }; +}; + +} // namespace impl + +namespace detail { + struct to_lower_placeholder_helper; +} + +detail::to_lower_placeholder_helper to_lower_(detail::to_lower_placeholder_helper); + +namespace detail { + +struct to_lower_placeholder_helper { + template + struct type : public impl::to_lower_transformer { }; + private: + to_lower_placeholder_helper() {} + to_lower_placeholder_helper(to_lower_placeholder_helper const &) {} + friend to_lower_placeholder_helper boost::network::to_lower_(to_lower_placeholder_helper); +}; + +} + +typedef detail::to_lower_placeholder_helper (*to_lower_placeholder)(detail::to_lower_placeholder_helper); + +inline detail::to_lower_placeholder_helper to_lower_(detail::to_lower_placeholder_helper) { + return detail::to_lower_placeholder_helper(); +} } // namespace network diff --git a/boost/network/message/transformers/to_upper.hpp b/boost/network/message/transformers/to_upper.hpp index 8ad11c09e..f8c684c16 100644 --- a/boost/network/message/transformers/to_upper.hpp +++ b/boost/network/message/transformers/to_upper.hpp @@ -8,6 +8,7 @@ #define __NETWORK_MESSAGE_TRANSFORMERS_TO_UPPER_HPP__ #include +#include /** to_upper.hpp * @@ -18,61 +19,64 @@ * This defines a type, to be applied using template * metaprogramming on the selected string target. */ -namespace boost { namespace network { +namespace boost { namespace network { namespace impl { - namespace impl { +template +struct to_upper_transformer { }; - template - struct to_upper_transformer { }; +template <> +struct to_upper_transformer { + void operator() (message_base & message_) const { + std::string source_; + message_.get_source(source_); + boost::to_upper(source_); + message_.set_source(source_); + } - template <> - struct to_upper_transformer { - template - void operator() (basic_message & message_) const { - boost::to_upper(message_.source()); - } + protected: + ~to_upper_transformer() { }; +}; - protected: - ~to_upper_transformer() { }; - }; +template <> +struct to_upper_transformer { + void operator() (message_base & message_) const { + std::string destination_; + message_.get_destination(destination_); + boost::to_upper(destination_); + message_.set_destination(destination_); + } - template <> - struct to_upper_transformer { - template - void operator() (basic_message & message_) const { - boost::to_upper(message_.destination()); - } + protected: + ~to_upper_transformer() { }; +}; - protected: - ~to_upper_transformer() { }; - }; +} // namespace impl - } // namespace impl +namespace detail { + struct to_upper_placeholder_helper; +} - namespace detail { - struct to_upper_placeholder_helper; - } +detail::to_upper_placeholder_helper to_upper_(detail::to_upper_placeholder_helper); - detail::to_upper_placeholder_helper to_upper_(detail::to_upper_placeholder_helper); +namespace detail { - namespace detail { +struct to_upper_placeholder_helper { + template + struct type : public impl::to_upper_transformer { }; - struct to_upper_placeholder_helper { - template - struct type : public impl::to_upper_transformer { }; - private: - to_upper_placeholder_helper() {} - to_upper_placeholder_helper(to_upper_placeholder_helper const &) {} - friend to_upper_placeholder_helper boost::network::to_upper_(to_upper_placeholder_helper); - }; + private: + to_upper_placeholder_helper() {} + to_upper_placeholder_helper(to_upper_placeholder_helper const &) {} + friend to_upper_placeholder_helper boost::network::to_upper_(to_upper_placeholder_helper); +}; - } +} - typedef detail::to_upper_placeholder_helper (*to_upper_placeholder)(detail::to_upper_placeholder_helper); +typedef detail::to_upper_placeholder_helper (*to_upper_placeholder)(detail::to_upper_placeholder_helper); - inline detail::to_upper_placeholder_helper to_upper_(detail::to_upper_placeholder_helper) { - return detail::to_upper_placeholder_helper(); - } +inline detail::to_upper_placeholder_helper to_upper_(detail::to_upper_placeholder_helper) { + return detail::to_upper_placeholder_helper(); +} } // namespace network diff --git a/boost/network/utils/thread_pool.hpp b/boost/network/utils/thread_pool.hpp index 1938f6d81..18c91ce3e 100644 --- a/boost/network/utils/thread_pool.hpp +++ b/boost/network/utils/thread_pool.hpp @@ -7,7 +7,6 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include #include #include #include @@ -16,98 +15,32 @@ namespace boost { namespace network { namespace utils { - typedef boost::shared_ptr io_service_ptr; - typedef boost::shared_ptr worker_threads_ptr; - typedef boost::shared_ptr sentinel_ptr; - - template - struct basic_thread_pool { - basic_thread_pool( - std::size_t threads = 1, - io_service_ptr io_service = io_service_ptr(), - worker_threads_ptr worker_threads = worker_threads_ptr() - ) - : threads_(threads) - , io_service_(io_service) - , worker_threads_(worker_threads) - , sentinel_() - { - bool commit = false; - BOOST_SCOPE_EXIT_TPL((&commit)(&io_service_)(&worker_threads_)(&sentinel_)) { - if (!commit) { - sentinel_.reset(); - io_service_.reset(); - if (worker_threads_.get()) { - worker_threads_->interrupt_all(); - worker_threads_->join_all(); - } - worker_threads_.reset(); - } - } BOOST_SCOPE_EXIT_END +typedef boost::shared_ptr io_service_ptr; +typedef boost::shared_ptr worker_threads_ptr; +typedef boost::shared_ptr sentinel_ptr; - if (!io_service_.get()) { - io_service_.reset(new boost::asio::io_service); - } +struct thread_pool_pimpl; - if (!worker_threads_.get()) { - worker_threads_.reset(new boost::thread_group); - } +struct thread_pool { + thread_pool(std::size_t threads = 1, + io_service_ptr io_service = io_service_ptr(), + worker_threads_ptr worker_threads = worker_threads_ptr()); + std::size_t const thread_count() const; + void post(function f); + ~thread_pool(); + void swap(thread_pool & other); + protected: + thread_pool_pimpl * pimpl; +}; - if (!sentinel_.get()) { - sentinel_.reset(new boost::asio::io_service::work(*io_service_)); - } +inline void swap(thread_pool & l, thread_pool & r) { + l.swap(r); +} - for (std::size_t counter = 0; counter < threads_; ++counter) - worker_threads_->create_thread( - boost::bind( - &boost::asio::io_service::run, - io_service_ - ) - ); +} // utils - commit = true; - } +} // network - std::size_t const thread_count() const { - return threads_; - } - - void post(boost::function f) { - io_service_->post(f); - } - - ~basic_thread_pool() throw () { - sentinel_.reset(); - try { - worker_threads_->join_all(); - } catch (...) { - BOOST_ASSERT(false && "A handler was not supposed to throw, but one did."); - } - } - - void swap(basic_thread_pool & other) { - std::swap(other.threads_, threads_); - std::swap(other.io_service_, io_service_); - std::swap(other.worker_threads_, worker_threads_); - std::swap(other.sentinel_, sentinel_); - } - protected: - std::size_t threads_; - io_service_ptr io_service_; - worker_threads_ptr worker_threads_; - sentinel_ptr sentinel_; - - private: - basic_thread_pool(basic_thread_pool const &); // no copies please - basic_thread_pool & operator=(basic_thread_pool); // no assignment please - }; - - typedef basic_thread_pool thread_pool; - -} /* utils */ - -} /* network */ - -} /* boost */ +} // boost #endif /* BOOST_NETWORK_UTILS_THREAD_POOL_HPP_20101020 */ diff --git a/libs/network/src/CMakeLists.txt b/libs/network/src/CMakeLists.txt index 6680dbd89..75b77264e 100644 --- a/libs/network/src/CMakeLists.txt +++ b/libs/network/src/CMakeLists.txt @@ -27,3 +27,6 @@ add_library(cppnetlib-message-wrappers ${CPP-NETLIB_MESSAGE_WRAPPERS_SRCS}) set(CPP-NETLIB_HTTP_MESSAGE_SRCS http/request.cpp http/response.cpp) add_library(cppnetlib-http-message ${CPP-NETLIB_HTTP_MESSAGE_SRCS}) + +set(CPP-NETLIB_UTILS_THREAD_POOL_SRCS utils/thread_pool.cpp) +add_library(cppnetlib-utils-thread_pool ${CPP-NETLIB_UTILS_THREAD_POOL_SRCS}) diff --git a/libs/network/test/CMakeLists.txt b/libs/network/test/CMakeLists.txt index 48bc6a707..beb55f287 100644 --- a/libs/network/test/CMakeLists.txt +++ b/libs/network/test/CMakeLists.txt @@ -16,7 +16,6 @@ if (Boost_FOUND) TESTS message_test message_transform_test - utils_thread_pool ) foreach (test ${TESTS}) set_source_files_properties(${test}.cpp @@ -43,5 +42,18 @@ if (Boost_FOUND) add_test(cpp-netlib-${test} ${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-${test}) endforeach (test) + set_source_files_properties(utils_thread_pool.cpp + PROPERTIES COMPILE_FLAGS "-Wall") + add_executable(cpp-netlib-utils_thread_pool utils_thread_pool.cpp) + add_dependencies(cpp-netlib-utils_thread_pool + cppnetlib-utils-thread_pool) + target_link_libraries(cpp-netlib-utils_thread_pool + ${Boost_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} + cppnetlib-utils-thread_pool) + set_target_properties(cpp-netlib-utils_thread_pool + PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests) + add_test(cpp-netlib-utils_thread_pool ${CPP-NETLIB_BRINARY_DIR}/tests/cpp-netlib-utils_thread_pool) + endif() From f255c4c8007f8382376f78f6b03fb48bbb906d3f Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Fri, 28 Oct 2011 14:00:35 +1100 Subject: [PATCH 020/196] Adding missing files. --- boost/network/utils/thread_pool.ipp | 124 +++++++++++++++++++++++++ libs/network/src/http/request.cpp | 0 libs/network/src/http/response.cpp | 0 libs/network/src/utils/thread_pool.cpp | 7 ++ 4 files changed, 131 insertions(+) create mode 100644 boost/network/utils/thread_pool.ipp create mode 100644 libs/network/src/http/request.cpp create mode 100644 libs/network/src/http/response.cpp create mode 100644 libs/network/src/utils/thread_pool.cpp diff --git a/boost/network/utils/thread_pool.ipp b/boost/network/utils/thread_pool.ipp new file mode 100644 index 000000000..582739368 --- /dev/null +++ b/boost/network/utils/thread_pool.ipp @@ -0,0 +1,124 @@ +#ifndef BOOST_NETWORK_UTILS_THREAD_POOL_IPP_20111021 +#define BOOST_NETWORK_UTILS_THREAD_POOL_IPP_20111021 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include + +namespace boost { namespace network { namespace utils { + +struct thread_pool_pimpl { + thread_pool_pimpl( + std::size_t threads = 1, + io_service_ptr io_service = io_service_ptr(), + worker_threads_ptr worker_threads = worker_threads_ptr() + ) + : threads_(threads) + , io_service_(io_service) + , worker_threads_(worker_threads) + , sentinel_() + { + bool commit = false; + BOOST_SCOPE_EXIT((&commit)(&io_service_)(&worker_threads_)(&sentinel_)) { + if (!commit) { + sentinel_.reset(); + io_service_.reset(); + if (worker_threads_.get()) { + worker_threads_->interrupt_all(); + worker_threads_->join_all(); + } + worker_threads_.reset(); + } + } BOOST_SCOPE_EXIT_END + + if (!io_service_.get()) { + io_service_.reset(new boost::asio::io_service); + } + + if (!worker_threads_.get()) { + worker_threads_.reset(new boost::thread_group); + } + + if (!sentinel_.get()) { + sentinel_.reset(new boost::asio::io_service::work(*io_service_)); + } + + for (std::size_t counter = 0; counter < threads_; ++counter) + worker_threads_->create_thread( + boost::bind( + &boost::asio::io_service::run, + io_service_ + ) + ); + + commit = true; + } + + std::size_t const thread_count() const { + return threads_; + } + + void post(boost::function f) { + io_service_->post(f); + } + + ~thread_pool_pimpl() { + sentinel_.reset(); + try { + worker_threads_->join_all(); + } catch (...) { + BOOST_ASSERT(false && "A handler was not supposed to throw, but one did."); + std::abort(); + } + } + + void swap(thread_pool_pimpl & other) { + std::swap(other.threads_, threads_); + std::swap(other.io_service_, io_service_); + std::swap(other.worker_threads_, worker_threads_); + std::swap(other.sentinel_, sentinel_); + } +protected: + std::size_t threads_; + io_service_ptr io_service_; + worker_threads_ptr worker_threads_; + sentinel_ptr sentinel_; + +private: + thread_pool_pimpl(thread_pool_pimpl const &); // no copies please + thread_pool_pimpl & operator=(thread_pool_pimpl); // no assignment please +}; + +thread_pool::thread_pool(std::size_t threads, + io_service_ptr io_service, + worker_threads_ptr worker_threads) +: pimpl(new (std::nothrow) thread_pool_pimpl(threads, io_service, worker_threads)) +{} + +std::size_t const thread_pool::thread_count() const { + return pimpl->thread_count(); +} + +void thread_pool::post(function f) { + pimpl->post(f); +} + +void thread_pool::swap(thread_pool & other) { + std::swap(other.pimpl, this->pimpl); +} + +thread_pool::~thread_pool() { + delete pimpl; +} + +} /* utils */ + +} /* network */ + +} /* boost */ + +#endif /* BOOST_NETWORK_UTILS_THREAD_POOL_IPP_20111021 */ diff --git a/libs/network/src/http/request.cpp b/libs/network/src/http/request.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/libs/network/src/http/response.cpp b/libs/network/src/http/response.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/libs/network/src/utils/thread_pool.cpp b/libs/network/src/utils/thread_pool.cpp new file mode 100644 index 000000000..4254f43d4 --- /dev/null +++ b/libs/network/src/utils/thread_pool.cpp @@ -0,0 +1,7 @@ +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include From 5cf5a25341fe5c0fbe55c334871e0fbd8175811c Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Fri, 28 Oct 2011 14:06:55 +1100 Subject: [PATCH 021/196] Order of linking issue. --- libs/network/test/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/network/test/CMakeLists.txt b/libs/network/test/CMakeLists.txt index beb55f287..652ae3e10 100644 --- a/libs/network/test/CMakeLists.txt +++ b/libs/network/test/CMakeLists.txt @@ -48,9 +48,9 @@ if (Boost_FOUND) add_dependencies(cpp-netlib-utils_thread_pool cppnetlib-utils-thread_pool) target_link_libraries(cpp-netlib-utils_thread_pool + cppnetlib-utils-thread_pool ${Boost_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} - cppnetlib-utils-thread_pool) + ${CMAKE_THREAD_LIBS_INIT}) set_target_properties(cpp-netlib-utils_thread_pool PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests) add_test(cpp-netlib-utils_thread_pool ${CPP-NETLIB_BRINARY_DIR}/tests/cpp-netlib-utils_thread_pool) From 3654e3fd93ecb7f70cb9e2f78e91d1b6f628959a Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Tue, 1 Nov 2011 23:17:47 +1100 Subject: [PATCH 022/196] Removing unnecessary tag include. --- libs/network/test/uri/url_builder_test.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/libs/network/test/uri/url_builder_test.cpp b/libs/network/test/uri/url_builder_test.cpp index fb55e96ad..089f4ea5c 100644 --- a/libs/network/test/uri/url_builder_test.cpp +++ b/libs/network/test/uri/url_builder_test.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include From d9c30d7cfd6091fa870805e1b1f1153e928dbd30 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Wed, 2 Nov 2011 00:21:19 +1100 Subject: [PATCH 023/196] Getting the client_constructor_test to compile! --- boost/network/message/transformers.hpp | 29 ++++---- boost/network/message/wrappers/headers.hpp | 2 +- .../http/message/wrappers/version.hpp | 2 + .../http/policies/async_connection.hpp | 8 +++ .../test/http/client_constructor_test.cpp | 17 +++-- libs/network/test/http/client_types.hpp | 68 ------------------- libs/network/test/http/tag_types.hpp | 24 ------- 7 files changed, 33 insertions(+), 117 deletions(-) delete mode 100644 libs/network/test/http/client_types.hpp delete mode 100644 libs/network/test/http/tag_types.hpp diff --git a/boost/network/message/transformers.hpp b/boost/network/message/transformers.hpp index baea48f4b..68ad230ed 100644 --- a/boost/network/message/transformers.hpp +++ b/boost/network/message/transformers.hpp @@ -14,7 +14,7 @@ #include #include #include - +#include #include namespace boost { namespace network { @@ -37,23 +37,22 @@ namespace boost { namespace network { }; template - struct transform_impl : public get_real_algorithm::type { }; + struct transform_impl : public get_real_algorithm::type { }; } // namspace impl template - inline impl::transform_impl - transform(Algorithm, Selector) { - return impl::transform_impl(); - } - - template - inline basic_message & - operator<< (basic_message & msg_, - impl::transform_impl - const & transformer) { - transformer(msg_); - return msg_; - } + inline impl::transform_impl + transform(Algorithm, Selector) { + return impl::transform_impl(); + } + + template + message_base & operator<< ( + message_base & msg_, + impl::transform_impl const & transformer) { + transformer(msg_); + return msg_; + } } // namespace network diff --git a/boost/network/message/wrappers/headers.hpp b/boost/network/message/wrappers/headers.hpp index 71a5e1907..ba71860eb 100644 --- a/boost/network/message/wrappers/headers.hpp +++ b/boost/network/message/wrappers/headers.hpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include namespace boost { namespace network { diff --git a/boost/network/protocol/http/message/wrappers/version.hpp b/boost/network/protocol/http/message/wrappers/version.hpp index 6b8f0b7d3..28e35988b 100644 --- a/boost/network/protocol/http/message/wrappers/version.hpp +++ b/boost/network/protocol/http/message/wrappers/version.hpp @@ -7,6 +7,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#include + namespace boost { namespace network { namespace http { namespace impl { diff --git a/boost/network/protocol/http/policies/async_connection.hpp b/boost/network/protocol/http/policies/async_connection.hpp index a3651c18c..3793fba43 100644 --- a/boost/network/protocol/http/policies/async_connection.hpp +++ b/boost/network/protocol/http/policies/async_connection.hpp @@ -28,6 +28,10 @@ struct simple_async_connection_manager : connection_manager { bool follow_redirects, optional openssl_certificate, optional openssl_verify_path); + simple_async_connection_manager(bool cache_resolved, + bool follow_redirects, + std::string const & openssl_certificate, + std::string const & openssl_verify_path); virtual shared_ptr get_connection( asio::io_service & service, request_base const & request); // override @@ -46,6 +50,10 @@ struct http_1_1_async_connection_manager : connection_manager, enable_shared_fro bool follow_redirects, optional openssl_certificate, optional openssl_verify_path); + http_1_1_async_connection_manager(bool cache_resolved, + bool follow_redirects, + std::string const & openssl_certificate, + std::string const & openssl_verify_path); virtual shared_ptr get_connection( asio::io_service & service, request_base const & request); // override diff --git a/libs/network/test/http/client_constructor_test.cpp b/libs/network/test/http/client_constructor_test.cpp index 9fa0b15b2..0f764271a 100644 --- a/libs/network/test/http/client_constructor_test.cpp +++ b/libs/network/test/http/client_constructor_test.cpp @@ -7,29 +7,28 @@ #define BOOST_TEST_MODULE HTTP 1.0 Client Constructor Test #include #include -#include "client_types.hpp" namespace http = boost::network::http; -BOOST_AUTO_TEST_CASE_TEMPLATE(http_client_constructor_test, client, client_types) { - client instance; +BOOST_AUTO_TEST_CASE(http_client_constructor_test) { + http::client instance; boost::asio::io_service io_service; - client instance2(io_service); - client instance3(http::_io_service=io_service); + http::client instance2(io_service); + http::client instance3(http::_io_service=io_service); } -BOOST_AUTO_TEST_CASE_TEMPLATE(http_cient_constructor_params_test, client, client_types) { - client instance( +BOOST_AUTO_TEST_CASE(http_cient_constructor_params_test) { + http::client instance( http::_follow_redirects=true, http::_cache_resolved=true ); boost::asio::io_service io_service; - client instance2( + http::client instance2( http::_follow_redirects=true, http::_io_service=io_service, http::_cache_resolved=true ); - client instance3( + http::client instance3( http::_openssl_certificate="foo", http::_openssl_verify_path="bar" ); diff --git a/libs/network/test/http/client_types.hpp b/libs/network/test/http/client_types.hpp deleted file mode 100644 index 3bed03afe..000000000 --- a/libs/network/test/http/client_types.hpp +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef CLIENT_TYPES_ROOWQCLE -#define CLIENT_TYPES_ROOWQCLE - -// Copyright 2010 Dean Michael Berris. -// 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) - -#include "tag_types.hpp" -#include -#include -#include -#include -#include -#include - -namespace mpl = boost::mpl ; - -template -struct client_adapter { - template - struct apply { - typedef boost::network::http::basic_client type; - }; -}; - -typedef - mpl::transform< - tag_types, - client_adapter<1,0> - >::type - client_1_0; - -typedef - mpl::transform< - tag_types, - client_adapter<1,1> - >::type - client_1_1; - -typedef mpl::joint_view< - client_1_0 - , client_1_1 ->::type client_types; - -typedef - mpl::joint_view< - mpl::transform< - mpl::remove_if< - tag_types, - boost::network::is_sync< - boost::mpl::_ - > - >::type, - client_adapter<1,0> - >::type, - mpl::transform< - mpl::remove_if< - tag_types, - boost::network::is_sync< - boost::mpl::_ - > - >::type, - client_adapter<1,1> - >::type - >::type async_only_client_types; - -#endif /* CLIENT_TYPES_ROOWQCLE */ diff --git a/libs/network/test/http/tag_types.hpp b/libs/network/test/http/tag_types.hpp deleted file mode 100644 index 219ae9303..000000000 --- a/libs/network/test/http/tag_types.hpp +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef TAG_TYPES_4NNM8B5T -#define TAG_TYPES_4NNM8B5T - -// Copyright 2010 Dean Michael Berris. -// 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) - -#include -#include - -namespace http = boost::network::http; - -typedef boost::mpl::vector< - http::tags::http_default_8bit_tcp_resolve - , http::tags::http_default_8bit_udp_resolve - , http::tags::http_keepalive_8bit_tcp_resolve - , http::tags::http_keepalive_8bit_udp_resolve - , http::tags::http_async_8bit_udp_resolve - , http::tags::http_async_8bit_tcp_resolve -> tag_types; - - -#endif /* TAG_TYPES_4NNM8B5T */ From 31a8807b70b85be14287c758de089578f4f1311c Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Wed, 2 Nov 2011 23:33:10 +1100 Subject: [PATCH 024/196] Adding missing default destructor implementations for request/response bases. --- .../protocol/http/request/request_base.hpp | 4 ++++ .../protocol/http/request/request_base.ipp | 24 +++++++++++++++++++ .../protocol/http/response/response_base.hpp | 8 +++++-- .../protocol/http/response/response_base.ipp | 23 ++++++++++++++++++ libs/network/src/http/request.cpp | 11 +++++++++ libs/network/src/http/response.cpp | 11 +++++++++ libs/network/test/http/CMakeLists.txt | 14 +++++++++-- libs/network/test/uri/CMakeLists.txt | 5 +++- 8 files changed, 95 insertions(+), 5 deletions(-) create mode 100644 boost/network/protocol/http/request/request_base.ipp create mode 100644 boost/network/protocol/http/response/response_base.ipp diff --git a/boost/network/protocol/http/request/request_base.hpp b/boost/network/protocol/http/request/request_base.hpp index d8369cdff..add874829 100644 --- a/boost/network/protocol/http/request/request_base.hpp +++ b/boost/network/protocol/http/request/request_base.hpp @@ -64,4 +64,8 @@ struct request_base : message_base, request_storage_base { } /* boost */ +#ifdef BOOST_NETWORK_NO_LIB +#include +#endif + #endif /* BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_BASE_HPP_20111008 */ diff --git a/boost/network/protocol/http/request/request_base.ipp b/boost/network/protocol/http/request/request_base.ipp new file mode 100644 index 000000000..5209ffacf --- /dev/null +++ b/boost/network/protocol/http/request/request_base.ipp @@ -0,0 +1,24 @@ +#ifndef BOOST_NETWORK_RPTOCOL_HTTP_REQUEST_BASE_IPP_20111102 +#define BOOST_NETWORK_RPTOCOL_HTTP_REQUEST_BASE_IPP_20111102 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include + +namespace boost { namespace network { namespace http { + +request_base::~request_base() { + // default implementation, only required for linking. +} + +} /* http */ + +} /* network */ + +} /* boost */ + +#endif /* BOOST_NETWORK_RPTOCOL_HTTP_REQUEST_BASE_IPP_20111102 */ diff --git a/boost/network/protocol/http/response/response_base.hpp b/boost/network/protocol/http/response/response_base.hpp index 284ca7a3f..e6c4597a9 100644 --- a/boost/network/protocol/http/response/response_base.hpp +++ b/boost/network/protocol/http/response/response_base.hpp @@ -7,6 +7,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#include + namespace boost { namespace network { namespace http { struct response_base : message_base { @@ -16,12 +18,14 @@ struct response_base : message_base { virtual ~response_base() = 0; }; -response_base::~response_base() {} - } /* http */ } /* network */ } /* boost */ +#ifdef BOOST_NETWORK_NO_LIB +#include +#endif + #endif /* BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_BASE_HPP_20110930 */ diff --git a/boost/network/protocol/http/response/response_base.ipp b/boost/network/protocol/http/response/response_base.ipp new file mode 100644 index 000000000..6ff547217 --- /dev/null +++ b/boost/network/protocol/http/response/response_base.ipp @@ -0,0 +1,23 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_RESPONSE_BASE_IPP_20111102 +#define BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_RESPONSE_BASE_IPP_20111102 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include + +namespace boost { namespace network { namespace http { + +response_base::~response_base() { + // default implementation, required only for linking. +} + +} /* http */ +} /* network */ + +} /* boost */ + +#endif /* BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_RESPONSE_BASE_IPP_20111102 */ diff --git a/libs/network/src/http/request.cpp b/libs/network/src/http/request.cpp index e69de29bb..983880dc4 100644 --- a/libs/network/src/http/request.cpp +++ b/libs/network/src/http/request.cpp @@ -0,0 +1,11 @@ +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#ifdef BOOST_NETWORK_NO_LIB +#undef BOOST_NETWORK_NO_LIB +#endif + +#include diff --git a/libs/network/src/http/response.cpp b/libs/network/src/http/response.cpp index e69de29bb..0989e5f70 100644 --- a/libs/network/src/http/response.cpp +++ b/libs/network/src/http/response.cpp @@ -0,0 +1,11 @@ +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#ifdef BOOST_NETWORK_NO_LIB +#undef BOOST_NETWORK_NO_LIB +#endif + +#include diff --git a/libs/network/test/http/CMakeLists.txt b/libs/network/test/http/CMakeLists.txt index dcc3749cb..5b04d0026 100644 --- a/libs/network/test/http/CMakeLists.txt +++ b/libs/network/test/http/CMakeLists.txt @@ -31,8 +31,18 @@ if (Boost_FOUND) PROPERTIES COMPILE_FLAGS "-Wall") endif() add_executable(cpp-netlib-http-${test} ${test}.cpp) - add_dependencies(cpp-netlib-http-${test} cppnetlib-uri) - target_link_libraries(cpp-netlib-http-${test} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri cppnetlib-client-connections) + add_dependencies(cpp-netlib-http-${test} + cppnetlib-uri + cppnetlib-message + cppnetlib-http-message + cppnetlib-client-connections) + target_link_libraries(cpp-netlib-http-${test} + ${Boost_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} + cppnetlib-uri + cppnetlib-message + cppnetlib-http-message + cppnetlib-client-connections) if (OPENSSL_FOUND) target_link_libraries(cpp-netlib-http-${test} ${OPENSSL_LIBRARIES}) endif() diff --git a/libs/network/test/uri/CMakeLists.txt b/libs/network/test/uri/CMakeLists.txt index ab2f012a8..84ccb9a6f 100644 --- a/libs/network/test/uri/CMakeLists.txt +++ b/libs/network/test/uri/CMakeLists.txt @@ -22,7 +22,10 @@ if (Boost_FOUND) PROPERTIES COMPILE_FLAGS "-Wall") add_executable(cpp-netlib-${test} ${test}.cpp) add_dependencies(cpp-netlib-${test} cppnetlib-uri) - target_link_libraries(cpp-netlib-${test} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri) + target_link_libraries(cpp-netlib-${test} + ${Boost_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} + cppnetlib-uri) if (OPENSSL_FOUND) target_link_libraries(cpp-netlib-${test} ${OPENSSL_LIBRARIES}) endif() From 80a073ad99d43838119c96adfcefafc5b4dfba3e Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Thu, 3 Nov 2011 22:46:58 +1100 Subject: [PATCH 025/196] Initial implementation of default destructors for client connections. --- .../http/client/client_connection.hpp | 40 +++++++++++++++++++ .../http/client/client_connection.ipp | 25 ++++++++++++ .../http/client/connection_manager.hpp | 27 +++++-------- .../http/client/connection_manager.ipp | 22 ++++++++++ libs/network/src/CMakeLists.txt | 3 ++ libs/network/src/http/client_connections.cpp | 12 ++++++ 6 files changed, 113 insertions(+), 16 deletions(-) create mode 100644 boost/network/protocol/http/client/client_connection.hpp create mode 100644 boost/network/protocol/http/client/client_connection.ipp create mode 100644 boost/network/protocol/http/client/connection_manager.ipp create mode 100644 libs/network/src/http/client_connections.cpp diff --git a/boost/network/protocol/http/client/client_connection.hpp b/boost/network/protocol/http/client/client_connection.hpp new file mode 100644 index 000000000..10556d14d --- /dev/null +++ b/boost/network/protocol/http/client/client_connection.hpp @@ -0,0 +1,40 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CLIENT_CONNECTION_HPP_20111103 +#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CLIENT_CONNECTION_HPP_20111103 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include +#include +#include +#include +#include + +namespace boost { namespace network { namespace http { + +struct client_connection { + typedef function const &, + system::error_code const &)> + callback_type; + virtual response send_request(std::string const & method, + request_base const & request, + bool get_body, + callback_type callback) = 0; + virtual void reset() = 0; + virtual ~client_connection() = 0; +}; + +} /* http */ + +} /* network */ + +} /* boost */ + +#ifdef BOOST_NETWORK_NO_LIB +#include +#endif + +#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CLIENT_CONNECTION_HPP_20111103 */ diff --git a/boost/network/protocol/http/client/client_connection.ipp b/boost/network/protocol/http/client/client_connection.ipp new file mode 100644 index 000000000..989ad213b --- /dev/null +++ b/boost/network/protocol/http/client/client_connection.ipp @@ -0,0 +1,25 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CLIENT_CONNECTION_IPP_20111103 +#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CLIENT_CONNECTION_IPP_20111103 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include + +namespace boost { namespace network { namespace http { + +client_connection::~client_connection() { + // default implementation, for linkage only. +} + + +} /* http */ + +} /* network */ + +} /* boost */ + +#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CLIENT_CONNECTION_IPP_20111103 */ diff --git a/boost/network/protocol/http/client/connection_manager.hpp b/boost/network/protocol/http/client/connection_manager.hpp index ee5dd7eb2..e28ce5dee 100644 --- a/boost/network/protocol/http/client/connection_manager.hpp +++ b/boost/network/protocol/http/client/connection_manager.hpp @@ -7,23 +7,12 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -namespace boost { namespace network { namespace http { - -struct request_base; - -struct response; +#include +#include +#include +#include -struct client_connection { - typedef function const &, - system::error_code const &)> - callback_type; - virtual response send_request(std::string const & method, - request_base const & request, - bool get_body, - callback_type callback) = 0; - virtual void reset() = 0; - virtual ~client_connection() = 0; -}; +namespace boost { namespace network { namespace http { struct connection_manager { virtual shared_ptr get_connection( @@ -34,7 +23,13 @@ struct connection_manager { }; } /* http */ + } /* network */ + } /* boost */ +#ifdef BOOST_NETWORK_NO_LIB +#include +#endif + #endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_MANAGER_HPP_20110930 */ diff --git a/boost/network/protocol/http/client/connection_manager.ipp b/boost/network/protocol/http/client/connection_manager.ipp new file mode 100644 index 000000000..fc1b45978 --- /dev/null +++ b/boost/network/protocol/http/client/connection_manager.ipp @@ -0,0 +1,22 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_MANAGER_IPP_20111103 +#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_MANAGER_IPP_20111103 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include + +namespace boost { namespace network { namespace http { + +connection_manager::~connection_manager() { + // default implementation, for linkage only. +} + +} /* http */ +} /* network */ +} /* boost */ + +#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_MANAGER_IPP_20111103 */ diff --git a/libs/network/src/CMakeLists.txt b/libs/network/src/CMakeLists.txt index 75b77264e..c3101a62d 100644 --- a/libs/network/src/CMakeLists.txt +++ b/libs/network/src/CMakeLists.txt @@ -28,5 +28,8 @@ add_library(cppnetlib-message-wrappers ${CPP-NETLIB_MESSAGE_WRAPPERS_SRCS}) set(CPP-NETLIB_HTTP_MESSAGE_SRCS http/request.cpp http/response.cpp) add_library(cppnetlib-http-message ${CPP-NETLIB_HTTP_MESSAGE_SRCS}) +set(CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS http/client_connections.cpp) +add_library(cppnetlib-http-client-connections ${CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS}) + set(CPP-NETLIB_UTILS_THREAD_POOL_SRCS utils/thread_pool.cpp) add_library(cppnetlib-utils-thread_pool ${CPP-NETLIB_UTILS_THREAD_POOL_SRCS}) diff --git a/libs/network/src/http/client_connections.cpp b/libs/network/src/http/client_connections.cpp new file mode 100644 index 000000000..06cb0df22 --- /dev/null +++ b/libs/network/src/http/client_connections.cpp @@ -0,0 +1,12 @@ +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#ifdef BOOST_NETWORK_NO_LIB +#undef BOOST_NETWORK_NO_LIB +#endif + +#include +#include From 24e49cbcd0758d21463b49d1dc5b977e1fcca96d Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Wed, 23 Nov 2011 23:53:31 +1100 Subject: [PATCH 026/196] Major Surgery, aligning APIs. So this set of changes moves forward the APIs of the internals of the client implementation. This is going to be more in flux until the request and response implementations get filled out. For the moment the "simplification" continues. WARNING: There's a lot of legacy code here still, most of which will not be kept. After this refactoring process is completed, the layout of the library will also change to better reflect the structure. --- boost/network/message/message.hpp | 15 +- boost/network/message/message.ipp | 28 +- boost/network/message/message_base.hpp | 14 +- .../network/message/wrappers/destination.hpp | 6 +- .../network/message/wrappers/destination.ipp | 2 +- .../protocol/http/algorithms/linearize.hpp | 2 +- boost/network/protocol/http/client.hpp | 1 + .../http/client/connection/async_normal.hpp | 443 ++---------------- .../http/client/connection/async_normal.ipp | 395 ++++++++++++++++ .../client/connection/connection_delegate.hpp | 5 +- .../connection_delegate_factory.hpp | 46 +- .../connection_delegate_factory.ipp | 48 ++ .../client/connection/connection_factory.hpp | 36 ++ .../client/connection/normal_delegate.hpp | 4 +- .../client/connection/normal_delegate.ipp | 10 +- .../connection/resolver_delegate_factory.hpp | 19 +- .../connection/simple_connection_factory.hpp | 48 ++ .../connection/simple_connection_factory.ipp | 82 ++++ .../http/client/connection/ssl_delegate.hpp | 4 +- .../http/client/connection/ssl_delegate.ipp | 16 +- boost/network/protocol/http/client/facade.hpp | 37 +- .../protocol/http/client/parameters.hpp | 1 + .../http/client/simple_connection_manager.hpp | 119 +++++ .../http/client/simple_connection_manager.ipp | 99 ++++ .../network/protocol/http/request/request.hpp | 26 +- .../protocol/http/request/request_base.hpp | 12 +- .../protocol/http/response/response.hpp | 14 +- libs/network/src/CMakeLists.txt | 6 +- .../src/http/connection_delegate_factory.cpp | 11 + .../src/http/simple_connection_factory.cpp | 11 + .../src/http/simple_connection_manager.cpp | 11 + 31 files changed, 1025 insertions(+), 546 deletions(-) create mode 100644 boost/network/protocol/http/client/connection/async_normal.ipp create mode 100644 boost/network/protocol/http/client/connection/connection_delegate_factory.ipp create mode 100644 boost/network/protocol/http/client/connection/connection_factory.hpp create mode 100644 boost/network/protocol/http/client/connection/simple_connection_factory.hpp create mode 100644 boost/network/protocol/http/client/connection/simple_connection_factory.ipp create mode 100644 boost/network/protocol/http/client/simple_connection_manager.hpp create mode 100644 boost/network/protocol/http/client/simple_connection_manager.ipp create mode 100644 libs/network/src/http/connection_delegate_factory.cpp create mode 100644 libs/network/src/http/simple_connection_factory.cpp create mode 100644 libs/network/src/http/simple_connection_manager.cpp diff --git a/boost/network/message/message.hpp b/boost/network/message/message.hpp index 5684b721a..2d570a506 100644 --- a/boost/network/message/message.hpp +++ b/boost/network/message/message.hpp @@ -43,20 +43,21 @@ struct message : message_base { virtual void append_body(std::string const & data); // Retrievers - virtual void get_destination(std::string & destination); - virtual void get_source(std::string & source); + virtual void get_destination(std::string & destination) const; + virtual void get_source(std::string & source) const; virtual void get_headers( - function inserter); + function inserter) const; virtual void get_headers( std::string const & name, - function inserter); + function inserter) const; virtual void get_headers( function predicate, - function inserter); - virtual void get_body(std::string & body); + function inserter) const; + virtual void get_body(std::string & body) const; virtual void get_body( function)> chunk_reader, - size_t size); + size_t size) const; + void swap(message & other); // Destructor diff --git a/boost/network/message/message.ipp b/boost/network/message/message.ipp index 88f17ba9e..fa0e14601 100644 --- a/boost/network/message/message.ipp +++ b/boost/network/message/message.ipp @@ -53,22 +53,22 @@ struct message_pimpl { } // Retrievers - void get_destination(std::string & destination) { + void get_destination(std::string & destination) const { destination = destination_; } - void get_source(std::string & source) { + void get_source(std::string & source) const { source = source_; } - void get_headers(function inserter) { + void get_headers(function inserter) const { std::multimap::const_iterator it = headers_.begin(), end = headers_.end(); for (; it != end; ++it) inserter(it->first, it->second); } void get_headers(std::string const & name, - function inserter) { + function inserter) const { std::multimap::const_iterator it = headers_.find(name), end= headers_.end(); while (it != end) { @@ -78,7 +78,7 @@ struct message_pimpl { } void get_headers(function predicate, - function inserter) { + function inserter) const { std::multimap::const_iterator it = headers_.begin(), end = headers_.end(); while (it != end) { @@ -92,7 +92,7 @@ struct message_pimpl { body = body_; } - void get_body(function)> chunk_reader, size_t size) { + void get_body(function)> chunk_reader, size_t size) const { static char const * nullptr_ = 0; if (body_read_pos == body_.size()) chunk_reader(boost::make_iterator_range(nullptr_, nullptr_)); @@ -122,7 +122,7 @@ struct message_pimpl { std::multimap headers_; // TODO: use Boost.IOStreams here later on. std::string body_; - size_t body_read_pos; + mutable size_t body_read_pos; }; message::message() @@ -171,33 +171,33 @@ void message::append_body(std::string const & data) { pimpl->append_body(data); } -void message::get_destination(std::string & destination) { +void message::get_destination(std::string & destination) const { pimpl->get_destination(destination); } -void message::get_source(std::string & source) { +void message::get_source(std::string & source) const { pimpl->get_source(source); } -void message::get_headers(function inserter) { +void message::get_headers(function inserter) const { pimpl->get_headers(inserter); } void message::get_headers(std::string const & name, - function inserter) { + function inserter) const { pimpl->get_headers(name, inserter); } void message::get_headers(function predicate, - function inserter) { + function inserter) const { pimpl->get_headers(predicate, inserter); } -void message::get_body(std::string & body) { +void message::get_body(std::string & body) const { pimpl->get_body(body); } -void message::get_body(function)> chunk_reader, size_t size) { +void message::get_body(function)> chunk_reader, size_t size) const { pimpl->get_body(chunk_reader, size); } diff --git a/boost/network/message/message_base.hpp b/boost/network/message/message_base.hpp index 43b2307bc..5f3681e5a 100644 --- a/boost/network/message/message_base.hpp +++ b/boost/network/message/message_base.hpp @@ -24,13 +24,13 @@ struct message_base { virtual void append_body(std::string const & data) = 0; // Retrievers - virtual void get_destination(std::string & destination) = 0; - virtual void get_source(std::string & source) = 0; - virtual void get_headers(function inserter) = 0; - virtual void get_headers(std::string const & name, function inserter) = 0; - virtual void get_headers(function predicate, function inserter) = 0; - virtual void get_body(std::string & body) = 0; - virtual void get_body(function)> chunk_reader, size_t size) = 0; + virtual void get_destination(std::string & destination) const = 0; + virtual void get_source(std::string & source) const = 0; + virtual void get_headers(function inserter) const = 0; + virtual void get_headers(std::string const & name, function inserter) const = 0; + virtual void get_headers(function predicate, function inserter) const = 0; + virtual void get_body(std::string & body) const = 0; + virtual void get_body(function)> chunk_reader, size_t size) const = 0; // Destructor virtual ~message_base() = 0; // pure virtual diff --git a/boost/network/message/wrappers/destination.hpp b/boost/network/message/wrappers/destination.hpp index a6d9e355c..1f3f44330 100644 --- a/boost/network/message/wrappers/destination.hpp +++ b/boost/network/message/wrappers/destination.hpp @@ -14,17 +14,17 @@ namespace boost { namespace network { namespace impl { struct destination_wrapper { - explicit destination_wrapper(message_base & message); + explicit destination_wrapper(message_base const & message); operator std::string () const; private: - message_base & message_; + message_base const & message_; mutable optional cache_; }; } // namespace impl inline std::string const -destination(message_base & message_) { +destination(message_base const & message_) { return impl::destination_wrapper(message_); } diff --git a/boost/network/message/wrappers/destination.ipp b/boost/network/message/wrappers/destination.ipp index cb99e62f5..99c1d73ff 100644 --- a/boost/network/message/wrappers/destination.ipp +++ b/boost/network/message/wrappers/destination.ipp @@ -11,7 +11,7 @@ namespace boost { namespace network { namespace impl { -destination_wrapper::destination_wrapper(message_base & message): +destination_wrapper::destination_wrapper(message_base const & message): message_(message) {} destination_wrapper::operator std::string () const { diff --git a/boost/network/protocol/http/algorithms/linearize.hpp b/boost/network/protocol/http/algorithms/linearize.hpp index 0fd24f740..f109640b2 100644 --- a/boost/network/protocol/http/algorithms/linearize.hpp +++ b/boost/network/protocol/http/algorithms/linearize.hpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/boost/network/protocol/http/client.hpp b/boost/network/protocol/http/client.hpp index bd8203a5c..41ae22bc7 100644 --- a/boost/network/protocol/http/client.hpp +++ b/boost/network/protocol/http/client.hpp @@ -58,6 +58,7 @@ struct client : basic_client_facade { (openssl_certificate, (std::string)) (openssl_verify_path, (std::string)) (connection_manager, (shared_ptr)) + (connection_factory, (shared_ptr)) )) // diff --git a/boost/network/protocol/http/client/connection/async_normal.hpp b/boost/network/protocol/http/client/connection/async_normal.hpp index fa23fd75b..51abe10a1 100644 --- a/boost/network/protocol/http/client/connection/async_normal.hpp +++ b/boost/network/protocol/http/client/connection/async_normal.hpp @@ -1,426 +1,41 @@ #ifndef BOOST_NETWORK_PROTOCOL_HTTP_IMPL_HTTP_ASYNC_CONNECTION_HPP_20100601 #define BOOST_NETWORK_PROTOCOL_HTTP_IMPL_HTTP_ASYNC_CONNECTION_HPP_20100601 -// Copyright 2010 (C) Dean Michael Berris -// Copyright 2010 (C) Sinefunc, Inc. // Copyright 2011 Dean Michael Berris (dberris@google.com). // Copyright 2011 Google,Inc. // 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) -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace network { namespace http { namespace impl { - - template - struct async_connection_base; - - namespace placeholders = boost::asio::placeholders; - - struct http_async_connection - : async_connection_base, - protected http_async_protocol_handler, - boost::enable_shared_from_this > - { - typedef async_connection_base base; - typedef http_async_protocol_handler protocol_base; - typedef typename base::resolver_type resolver_type; - typedef typename base::resolver_base::resolver_iterator resolver_iterator; - typedef typename base::resolver_base::resolver_iterator_pair resolver_iterator_pair; - typedef typename base::response response; - typedef typename base::string_type string_type; - typedef typename base::request request; - typedef typename base::resolver_base::resolve_function resolve_function; - typedef typename base::body_callback_function_type body_callback_function_type; - typedef http_async_connection this_type; - typedef typename delegate_factory::type delegate_factory_type; - typedef typename delegate_factory_type::connection_delegate_ptr - connection_delegate_ptr; - - http_async_connection(resolver_delegate_ptr resolver_delegate, - asio::io_service & io_service, - bool follow_redirect, - connection_delegate_ptr delegate) - : - follow_redirect_(follow_redirect), - request_strand_(io_service), - resolver_delegate_(resolver_delegate), - delegate_(delegate) {} - - // This is the main entry point for the connection/request pipeline. We're - // overriding async_connection_base<...>::start(...) here which is called - // by the client. - virtual response start(request const & request, - string_type const & method, - bool get_body, - body_callback_function_type callback) { - response response_; - this->init_response(response_, get_body); - linearize(request, method, version_major, version_minor, - std::ostreambuf_iterator::type>(&command_streambuf)); - this->method = method; - boost::uint16_t port_ = port(request); - resolver_delegate_->resolve(host(request), - port_, - request_strand_.wrap( - boost::bind( - &this_type::handle_resolved, - this_type::shared_from_this(), - port_, - get_body, - callback, - _1, - _2))); - return response_; - } - - private: - - http_async_connection(http_async_connection const &); // = delete - - void set_errors(boost::system::error_code const & ec) { - boost::system::system_error error(ec); - this->version_promise.set_exception(boost::copy_exception(error)); - this->status_promise.set_exception(boost::copy_exception(error)); - this->status_message_promise.set_exception(boost::copy_exception(error)); - this->headers_promise.set_exception(boost::copy_exception(error)); - this->source_promise.set_exception(boost::copy_exception(error)); - this->destination_promise.set_exception(boost::copy_exception(error)); - this->body_promise.set_exception(boost::copy_exception(error)); - } - - void handle_resolved(boost::uint16_t port, - bool get_body, - body_callback_function_type callback, - boost::system::error_code const & ec, - resolver_iterator_pair endpoint_range) { - if (!ec && !boost::empty(endpoint_range)) { - // Here we deal with the case that there was an error encountered and - // that there's still more endpoints to try connecting to. - resolver_iterator iter = boost::begin(endpoint_range); - asio::ip::tcp::endpoint endpoint(iter->endpoint().address(), port); - delegate_->connect(endpoint, - request_strand_.wrap( - boost::bind( - &this_type::handle_connected, - this_type::shared_from_this(), - port, - get_body, - callback, - std::make_pair(++iter, - resolver_iterator()), - placeholders::error))); - } else { - set_errors(ec ? ec : boost::asio::error::host_not_found); - } - } - - void handle_connected(boost::uint16_t port, - bool get_body, - body_callback_function_type callback, - resolver_iterator_pair endpoint_range, - boost::system::error_code const & ec) { - if (!ec) { - BOOST_ASSERT(delegate_.get() != 0); - delegate_->write(command_streambuf, - request_strand_.wrap( - boost::bind( - &this_type::handle_sent_request, - this_type::shared_from_this(), - get_body, - callback, - placeholders::error, - placeholders::bytes_transferred))); - } else { - if (!boost::empty(endpoint_range)) { - resolver_iterator iter = boost::begin(endpoint_range); - asio::ip::tcp::endpoint endpoint(iter->endpoint().address(), port); - delegate_->connect(endpoint, - request_strand_.wrap( - boost::bind( - &this_type::handle_connected, - this_type::shared_from_this(), - port, - get_body, - callback, - std::make_pair(++iter, - resolver_iterator()), - placeholders::error))); - } else { - set_errors(ec ? ec : boost::asio::error::host_not_found); - } - } - } - - enum state_t { - version, status, status_message, headers, body - }; - - void handle_sent_request(bool get_body, - body_callback_function_type callback, - boost::system::error_code const & ec, - std::size_t bytes_transferred) { - if (!ec) { - delegate_->read_some( - boost::asio::mutable_buffers_1(this->part.c_array(), - this->part.size()), - request_strand_.wrap( - boost::bind(&this_type::handle_received_data, - this_type::shared_from_this(), - version, get_body, callback, - placeholders::error, - placeholders::bytes_transferred))); - } else { - set_errors(ec); - } - } - - void handle_received_data(state_t state, bool get_body, body_callback_function_type callback, boost::system::error_code const & ec, std::size_t bytes_transferred) { - if (!ec || ec == boost::asio::error::eof) { - logic::tribool parsed_ok; - size_t remainder; - switch(state) { - case version: - parsed_ok = - this->parse_version(delegate_, - request_strand_.wrap( - boost::bind( - &this_type::handle_received_data, - this_type::shared_from_this(), - version, get_body, callback, - placeholders::error, - placeholders::bytes_transferred)), - bytes_transferred); - if (!parsed_ok || indeterminate(parsed_ok)) return; - case status: - parsed_ok = - this->parse_status(delegate_, - request_strand_.wrap( - boost::bind( - &this_type::handle_received_data, - this_type::shared_from_this(), - status, get_body, callback, - placeholders::error, - placeholders::bytes_transferred)), - bytes_transferred); - if (!parsed_ok || indeterminate(parsed_ok)) return; - case status_message: - parsed_ok = - this->parse_status_message(delegate_, - request_strand_.wrap( - boost::bind( - &this_type::handle_received_data, - this_type::shared_from_this(), - status_message, get_body, callback, - placeholders::error, placeholders::bytes_transferred - ) - ), - bytes_transferred - ); - if (!parsed_ok || indeterminate(parsed_ok)) return; - case headers: - // In the following, remainder is the number of bytes that remain - // in the buffer. We need this in the body processing to make sure - // that the data remaining in the buffer is dealt with before - // another call to get more data for the body is scheduled. - fusion::tie(parsed_ok, remainder) = - this->parse_headers(delegate_, - request_strand_.wrap( - boost::bind( - &this_type::handle_received_data, - this_type::shared_from_this(), - headers, get_body, callback, - placeholders::error, placeholders::bytes_transferred - ) - ), - bytes_transferred - ); - - if (!parsed_ok || indeterminate(parsed_ok)) return; - - if (!get_body) { - // We short-circuit here because the user does not - // want to get the body (in the case of a HEAD - // request). - this->body_promise.set_value(""); - this->destination_promise.set_value(""); - this->source_promise.set_value(""); - this->part.assign('\0'); - this->response_parser_.reset(); - return; - } - - if (callback) { - // Here we deal with the spill-over data from the - // headers processing. This means the headers data - // has already been parsed appropriately and we're - // looking to treat everything that remains in the - // buffer. - typename protocol_base::buffer_type::const_iterator begin = this->part_begin; - typename protocol_base::buffer_type::const_iterator end = begin; - std::advance(end, remainder); - - // We're setting the body promise here to an empty string because - // this can be used as a signaling mechanism for the user to - // determine that the body is now ready for processing, even - // though the callback is already provided. - this->body_promise.set_value(""); - - // The invocation of the callback is synchronous to allow us to - // wait before scheduling another read. - callback(make_iterator_range(begin, end), ec); - - delegate_->read_some( - boost::asio::mutable_buffers_1(this->part.c_array(), - this->part.size()), - request_strand_.wrap( - boost::bind(&this_type::handle_received_data, - this_type::shared_from_this(), - body, - get_body, - callback, - placeholders::error, - placeholders::bytes_transferred))); - } else { - // Here we handle the body data ourself and append to an - // ever-growing string buffer. - this->parse_body( - delegate_, - request_strand_.wrap( - boost::bind( - &this_type::handle_received_data, - this_type::shared_from_this(), - body, get_body, callback, - placeholders::error, placeholders::bytes_transferred - ) - ), - remainder); - } - return; - case body: - if (ec == boost::asio::error::eof) { - // Here we're handling the case when the connection has been - // closed from the server side, or at least that the end of file - // has been reached while reading the socket. This signals the end - // of the body processing chain. - if (callback) { - typename protocol_base::buffer_type::const_iterator begin = - this->part.begin(), - end = begin; - std::advance(end, bytes_transferred); - - // We call the callback function synchronously passing the error - // condition (in this case, end of file) so that it can handle - // it appropriately. - callback(make_iterator_range(begin, end), ec); - } else { - string_type body_string; - std::swap(body_string, this->partial_parsed); - body_string.append( - this->part.begin() - , bytes_transferred - ); - this->body_promise.set_value(body_string); - } - // TODO set the destination value somewhere! - this->destination_promise.set_value(""); - this->source_promise.set_value(""); - this->part.assign('\0'); - this->response_parser_.reset(); - } else { - // This means the connection has not been closed yet and we want to get more - // data. - if (callback) { - // Here we have a body_handler callback. Let's invoke the - // callback from here and make sure we're getting more data - // right after. - typename protocol_base::buffer_type::const_iterator begin = this->part.begin(); - typename protocol_base::buffer_type::const_iterator end = begin; - std::advance(end, bytes_transferred); - callback(make_iterator_range(begin, end), ec); - delegate_->read_some( - boost::asio::mutable_buffers_1( - this->part.c_array(), - this->part.size()), - request_strand_.wrap( - boost::bind( - &this_type::handle_received_data, - this_type::shared_from_this(), - body, - get_body, - callback, - placeholders::error, - placeholders::bytes_transferred))); - } else { - // Here we don't have a body callback. Let's - // make sure that we deal with the remainder - // from the headers part in case we do have data - // that's still in the buffer. - this->parse_body(delegate_, - request_strand_.wrap( - boost::bind( - &this_type::handle_received_data, - this_type::shared_from_this(), - body, - get_body, - callback, - placeholders::error, - placeholders::bytes_transferred)), - bytes_transferred); - } - } - return; - default: - BOOST_ASSERT(false && "Bug, report this to the developers!"); - } - } else { - boost::system::system_error error(ec); - this->source_promise.set_exception(boost::copy_exception(error)); - this->destination_promise.set_exception(boost::copy_exception(error)); - switch (state) { - case version: - this->version_promise.set_exception(boost::copy_exception(error)); - case status: - this->status_promise.set_exception(boost::copy_exception(error)); - case status_message: - this->status_message_promise.set_exception(boost::copy_exception(error)); - case headers: - this->headers_promise.set_exception(boost::copy_exception(error)); - case body: - this->body_promise.set_exception(boost::copy_exception(error)); - break; - default: - BOOST_ASSERT(false && "Bug, report this to the developers!"); - } - } - } - - bool follow_redirect_; - boost::asio::io_service::strand request_strand_; - resolver_delegate_ptr resolver_delegate_; - connection_delegate_ptr delegate_; - boost::asio::streambuf command_streambuf; - string_type method; - }; - -} // namespace impl +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace network { namespace http { + +struct http_async_connection_pimpl; + +struct http_async_connection +: client_connection +, enable_shared_from_this { + using client_connection::callback_type; + http_async_connection(shared_ptr resolver_delegate, + shared_ptr connection_delegate, + asio::io_service & io_service, + bool follow_redirects); + virtual response send_request(std::string const & method, + request_base const & request, + bool get_body, + callback_type callback); // override + virtual void reset(); // override + virtual ~http_async_connection(); + private: + scoped_ptr pimpl; +}; } // namespace http diff --git a/boost/network/protocol/http/client/connection/async_normal.ipp b/boost/network/protocol/http/client/connection/async_normal.ipp new file mode 100644 index 000000000..405e644c4 --- /dev/null +++ b/boost/network/protocol/http/client/connection/async_normal.ipp @@ -0,0 +1,395 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_NORMAL_IPP_20111123 +#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_NORMAL_IPP_20111123 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include +#include + +namespace boost { namespace network { namespace http { + +namespace placeholders = boost::asio::placeholders; + +struct http_async_connection +: client_connection +, boost::enable_shared_from_this +{ + + http_async_connection(resolver_delegate_ptr resolver_delegate, + asio::io_service & io_service, + bool follow_redirect, + connection_delegate_ptr delegate) + : + follow_redirect_(follow_redirect), + request_strand_(io_service), + resolver_delegate_(resolver_delegate), + delegate_(delegate) {} + + // This is the main entry point for the connection/request pipeline. We're + // overriding async_connection_base<...>::start(...) here which is called + // by the client. + virtual response start(request const & request, + string_type const & method, + bool get_body, + body_callback_function_type callback) { + response response_; + this->init_response(response_, get_body); + linearize(request, method, version_major, version_minor, + std::ostreambuf_iterator::type>(&command_streambuf)); + this->method = method; + boost::uint16_t port_ = port(request); + resolver_delegate_->resolve(host(request), + port_, + request_strand_.wrap( + boost::bind( + &this_type::handle_resolved, + this_type::shared_from_this(), + port_, + get_body, + callback, + _1, + _2))); + return response_; + } + +private: + + http_async_connection(http_async_connection const &); // = delete + + void set_errors(boost::system::error_code const & ec) { + boost::system::system_error error(ec); + this->version_promise.set_exception(boost::copy_exception(error)); + this->status_promise.set_exception(boost::copy_exception(error)); + this->status_message_promise.set_exception(boost::copy_exception(error)); + this->headers_promise.set_exception(boost::copy_exception(error)); + this->source_promise.set_exception(boost::copy_exception(error)); + this->destination_promise.set_exception(boost::copy_exception(error)); + this->body_promise.set_exception(boost::copy_exception(error)); + } + + void handle_resolved(boost::uint16_t port, + bool get_body, + body_callback_function_type callback, + boost::system::error_code const & ec, + resolver_iterator_pair endpoint_range) { + if (!ec && !boost::empty(endpoint_range)) { + // Here we deal with the case that there was an error encountered and + // that there's still more endpoints to try connecting to. + resolver_iterator iter = boost::begin(endpoint_range); + asio::ip::tcp::endpoint endpoint(iter->endpoint().address(), port); + delegate_->connect(endpoint, + request_strand_.wrap( + boost::bind( + &this_type::handle_connected, + this_type::shared_from_this(), + port, + get_body, + callback, + std::make_pair(++iter, + resolver_iterator()), + placeholders::error))); + } else { + set_errors(ec ? ec : boost::asio::error::host_not_found); + } + } + + void handle_connected(boost::uint16_t port, + bool get_body, + body_callback_function_type callback, + resolver_iterator_pair endpoint_range, + boost::system::error_code const & ec) { + if (!ec) { + BOOST_ASSERT(delegate_.get() != 0); + delegate_->write(command_streambuf, + request_strand_.wrap( + boost::bind( + &this_type::handle_sent_request, + this_type::shared_from_this(), + get_body, + callback, + placeholders::error, + placeholders::bytes_transferred))); + } else { + if (!boost::empty(endpoint_range)) { + resolver_iterator iter = boost::begin(endpoint_range); + asio::ip::tcp::endpoint endpoint(iter->endpoint().address(), port); + delegate_->connect(endpoint, + request_strand_.wrap( + boost::bind( + &this_type::handle_connected, + this_type::shared_from_this(), + port, + get_body, + callback, + std::make_pair(++iter, + resolver_iterator()), + placeholders::error))); + } else { + set_errors(ec ? ec : boost::asio::error::host_not_found); + } + } + } + + enum state_t { + version, status, status_message, headers, body + }; + + void handle_sent_request(bool get_body, + body_callback_function_type callback, + boost::system::error_code const & ec, + std::size_t bytes_transferred) { + if (!ec) { + delegate_->read_some( + boost::asio::mutable_buffers_1(this->part.c_array(), + this->part.size()), + request_strand_.wrap( + boost::bind(&this_type::handle_received_data, + this_type::shared_from_this(), + version, get_body, callback, + placeholders::error, + placeholders::bytes_transferred))); + } else { + set_errors(ec); + } + } + + void handle_received_data(state_t state, bool get_body, body_callback_function_type callback, boost::system::error_code const & ec, std::size_t bytes_transferred) { + if (!ec || ec == boost::asio::error::eof) { + logic::tribool parsed_ok; + size_t remainder; + switch(state) { + case version: + parsed_ok = + this->parse_version(delegate_, + request_strand_.wrap( + boost::bind( + &this_type::handle_received_data, + this_type::shared_from_this(), + version, get_body, callback, + placeholders::error, + placeholders::bytes_transferred)), + bytes_transferred); + if (!parsed_ok || indeterminate(parsed_ok)) return; + case status: + parsed_ok = + this->parse_status(delegate_, + request_strand_.wrap( + boost::bind( + &this_type::handle_received_data, + this_type::shared_from_this(), + status, get_body, callback, + placeholders::error, + placeholders::bytes_transferred)), + bytes_transferred); + if (!parsed_ok || indeterminate(parsed_ok)) return; + case status_message: + parsed_ok = + this->parse_status_message(delegate_, + request_strand_.wrap( + boost::bind( + &this_type::handle_received_data, + this_type::shared_from_this(), + status_message, get_body, callback, + placeholders::error, placeholders::bytes_transferred + ) + ), + bytes_transferred + ); + if (!parsed_ok || indeterminate(parsed_ok)) return; + case headers: + // In the following, remainder is the number of bytes that remain + // in the buffer. We need this in the body processing to make sure + // that the data remaining in the buffer is dealt with before + // another call to get more data for the body is scheduled. + fusion::tie(parsed_ok, remainder) = + this->parse_headers(delegate_, + request_strand_.wrap( + boost::bind( + &this_type::handle_received_data, + this_type::shared_from_this(), + headers, get_body, callback, + placeholders::error, placeholders::bytes_transferred + ) + ), + bytes_transferred + ); + + if (!parsed_ok || indeterminate(parsed_ok)) return; + + if (!get_body) { + // We short-circuit here because the user does not + // want to get the body (in the case of a HEAD + // request). + this->body_promise.set_value(""); + this->destination_promise.set_value(""); + this->source_promise.set_value(""); + this->part.assign('\0'); + this->response_parser_.reset(); + return; + } + + if (callback) { + // Here we deal with the spill-over data from the + // headers processing. This means the headers data + // has already been parsed appropriately and we're + // looking to treat everything that remains in the + // buffer. + typename protocol_base::buffer_type::const_iterator begin = this->part_begin; + typename protocol_base::buffer_type::const_iterator end = begin; + std::advance(end, remainder); + + // We're setting the body promise here to an empty string because + // this can be used as a signaling mechanism for the user to + // determine that the body is now ready for processing, even + // though the callback is already provided. + this->body_promise.set_value(""); + + // The invocation of the callback is synchronous to allow us to + // wait before scheduling another read. + callback(make_iterator_range(begin, end), ec); + + delegate_->read_some( + boost::asio::mutable_buffers_1(this->part.c_array(), + this->part.size()), + request_strand_.wrap( + boost::bind(&this_type::handle_received_data, + this_type::shared_from_this(), + body, + get_body, + callback, + placeholders::error, + placeholders::bytes_transferred))); + } else { + // Here we handle the body data ourself and append to an + // ever-growing string buffer. + this->parse_body( + delegate_, + request_strand_.wrap( + boost::bind( + &this_type::handle_received_data, + this_type::shared_from_this(), + body, get_body, callback, + placeholders::error, placeholders::bytes_transferred + ) + ), + remainder); + } + return; + case body: + if (ec == boost::asio::error::eof) { + // Here we're handling the case when the connection has been + // closed from the server side, or at least that the end of file + // has been reached while reading the socket. This signals the end + // of the body processing chain. + if (callback) { + typename protocol_base::buffer_type::const_iterator begin = + this->part.begin(), + end = begin; + std::advance(end, bytes_transferred); + + // We call the callback function synchronously passing the error + // condition (in this case, end of file) so that it can handle + // it appropriately. + callback(make_iterator_range(begin, end), ec); + } else { + string_type body_string; + std::swap(body_string, this->partial_parsed); + body_string.append( + this->part.begin() + , bytes_transferred + ); + this->body_promise.set_value(body_string); + } + // TODO set the destination value somewhere! + this->destination_promise.set_value(""); + this->source_promise.set_value(""); + this->part.assign('\0'); + this->response_parser_.reset(); + } else { + // This means the connection has not been closed yet and we want to get more + // data. + if (callback) { + // Here we have a body_handler callback. Let's invoke the + // callback from here and make sure we're getting more data + // right after. + typename protocol_base::buffer_type::const_iterator begin = this->part.begin(); + typename protocol_base::buffer_type::const_iterator end = begin; + std::advance(end, bytes_transferred); + callback(make_iterator_range(begin, end), ec); + delegate_->read_some( + boost::asio::mutable_buffers_1( + this->part.c_array(), + this->part.size()), + request_strand_.wrap( + boost::bind( + &this_type::handle_received_data, + this_type::shared_from_this(), + body, + get_body, + callback, + placeholders::error, + placeholders::bytes_transferred))); + } else { + // Here we don't have a body callback. Let's + // make sure that we deal with the remainder + // from the headers part in case we do have data + // that's still in the buffer. + this->parse_body(delegate_, + request_strand_.wrap( + boost::bind( + &this_type::handle_received_data, + this_type::shared_from_this(), + body, + get_body, + callback, + placeholders::error, + placeholders::bytes_transferred)), + bytes_transferred); + } + } + return; + default: + BOOST_ASSERT(false && "Bug, report this to the developers!"); + } + } else { + boost::system::system_error error(ec); + this->source_promise.set_exception(boost::copy_exception(error)); + this->destination_promise.set_exception(boost::copy_exception(error)); + switch (state) { + case version: + this->version_promise.set_exception(boost::copy_exception(error)); + case status: + this->status_promise.set_exception(boost::copy_exception(error)); + case status_message: + this->status_message_promise.set_exception(boost::copy_exception(error)); + case headers: + this->headers_promise.set_exception(boost::copy_exception(error)); + case body: + this->body_promise.set_exception(boost::copy_exception(error)); + break; + default: + BOOST_ASSERT(false && "Bug, report this to the developers!"); + } + } + } + + bool follow_redirect_; + boost::asio::io_service::strand request_strand_; + resolver_delegate_ptr resolver_delegate_; + connection_delegate_ptr delegate_; + boost::asio::streambuf command_streambuf; + string_type method; +}; + + +} /* http */ + +} /* network */ + +} /* boost */ + +#endbooif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_NORMAL_IPP_20111123 */ diff --git a/boost/network/protocol/http/client/connection/connection_delegate.hpp b/boost/network/protocol/http/client/connection/connection_delegate.hpp index 7f4bc5b5b..6d1d4e3ce 100644 --- a/boost/network/protocol/http/client/connection/connection_delegate.hpp +++ b/boost/network/protocol/http/client/connection/connection_delegate.hpp @@ -9,8 +9,9 @@ #include #include +#include -namespace boost { namespace network { namespace http { namespace impl { +namespace boost { namespace network { namespace http { struct connection_delegate { virtual void connect(asio::ip::tcp::endpoint & endpoint, @@ -22,8 +23,6 @@ struct connection_delegate { virtual ~connection_delegate() {} }; -} /* impl */ - } /* http */ } /* network */ diff --git a/boost/network/protocol/http/client/connection/connection_delegate_factory.hpp b/boost/network/protocol/http/client/connection/connection_delegate_factory.hpp index 05991c6d4..d467615b4 100644 --- a/boost/network/protocol/http/client/connection/connection_delegate_factory.hpp +++ b/boost/network/protocol/http/client/connection/connection_delegate_factory.hpp @@ -9,53 +9,35 @@ #include #include -#include -#ifdef BOOST_NETWORK_ENABLE_HTTPS -#include -#endif /* BOOST_NETWORK_ENABLE_HTTPS */ -namespace boost { namespace network { namespace http { namespace impl { - -struct ssl_delegate; - -struct normal_delegate; +namespace boost { namespace network { namespace http { struct connection_delegate_factory { typedef shared_ptr connection_delegate_ptr; + connection_delegate_factory(); + // This is the factory method that actually returns the delegate instance. // TODO Support passing in proxy settings when crafting connections. - static connection_delegate_ptr new_connection_delegate( + virtual connection_delegate_ptr create_connection_delegate( asio::io_service & service, bool https, optional certificate_filename, optional verify_path); + + virtual ~connection_delegate_factory(); + + private: + connection_delegate_factory(connection_delegate_factory const &); // = delete + connection_delegate_factory& operator=(connection_delegate_factory); // = delete }; -connection_delegate_factory::connection_delegate_ptr -connection_delegate_factory::new_connection_delegate( - asio::io_service & service, - bool https, - optional certificate_filename, - optional verify_path) { - connection_delegate_ptr delegate; - if (https) { -#ifdef BOOST_NETWORK_ENABLE_HTTPS - delegate.reset(new ssl_delegate(service, - certificate_filename, - verify_path)); -#else - BOOST_THROW_EXCEPTION(std::runtime_error("HTTPS not supported.")); -#endif /* BOOST_NETWORK_ENABLE_HTTPS */ - } else { - delegate.reset(new normal_delegate(service)); - } - return delegate; -} - -} /* impl */ } /* http */ } /* network */ } /* boost */ +#ifdef BOOST_NETWORK_NO_LIB +#include +#endif + #endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_DELEGATE_FACTORY_HPP_20110819 */ diff --git a/boost/network/protocol/http/client/connection/connection_delegate_factory.ipp b/boost/network/protocol/http/client/connection/connection_delegate_factory.ipp new file mode 100644 index 000000000..4ac901457 --- /dev/null +++ b/boost/network/protocol/http/client/connection/connection_delegate_factory.ipp @@ -0,0 +1,48 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_DELEGATE_FACTORY_IPP_20111123 +#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_DELEGATE_FACTORY_IPP_20111123 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include +#ifdef BOOST_NETWORK_ENABLE_HTTPS +#include +#endif /* BOOST_NETWORK_ENABLE_HTTPS */ + +#include + +namespace boost { namespace network { namespace http { + +connection_delegate_factory::connection_delegate_factory() {} + +connection_delegate_factory::connection_delegate_ptr +connection_delegate_factory::create_connection_delegate( + asio::io_service & service, + bool https, + optional certificate_filename, + optional verify_path) { + connection_delegate_ptr delegate; + if (https) { +#ifdef BOOST_NETWORK_ENABLE_HTTPS + delegate.reset(new ssl_delegate(service, + certificate_filename, + verify_path)); +#else + BOOST_THROW_EXCEPTION(std::runtime_error("HTTPS not supported.")); +#endif /* BOOST_NETWORK_ENABLE_HTTPS */ + } else { + delegate.reset(new normal_delegate(service)); + } + return delegate; +} + +} /* http */ + +} /* network */ + +} /* boost */ + +#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_DELEGATE_FACTORY_IPP_20111123 */ diff --git a/boost/network/protocol/http/client/connection/connection_factory.hpp b/boost/network/protocol/http/client/connection/connection_factory.hpp new file mode 100644 index 000000000..c2dad0852 --- /dev/null +++ b/boost/network/protocol/http/client/connection/connection_factory.hpp @@ -0,0 +1,36 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_FACTORY_HPP_20111112 +#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_FACTORY_HPP_20111112 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include +#include +#include + +namespace boost { namespace network { namespace http { + +struct connection_factory { + virtual shared_ptr create_connection(asio::io_service & service, + request_base const & request, + bool cache_resolved, + bool follow_redirects, + optional openssl_certificate, + optional openssl_verify_path) = 0; + virtual ~connection_factory() = 0; // pure virtual, interface only. +}; + +} /* http */ + +} /* network */ + +} /* boost */ + +#ifdef BOOST_NETWORK_NO_LIB +#include +#endif + +#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_FACTORY_HPP_20111112 */ diff --git a/boost/network/protocol/http/client/connection/normal_delegate.hpp b/boost/network/protocol/http/client/connection/normal_delegate.hpp index d18f1461a..8817aa235 100644 --- a/boost/network/protocol/http/client/connection/normal_delegate.hpp +++ b/boost/network/protocol/http/client/connection/normal_delegate.hpp @@ -11,7 +11,7 @@ #include #include -namespace boost { namespace network { namespace http { namespace impl { +namespace boost { namespace network { namespace http { struct normal_delegate : connection_delegate { normal_delegate(asio::io_service & service); @@ -32,8 +32,6 @@ struct normal_delegate : connection_delegate { normal_delegate& operator=(normal_delegate); // = delete }; -} /* impl */ - } /* http */ } /* network */ diff --git a/boost/network/protocol/http/client/connection/normal_delegate.ipp b/boost/network/protocol/http/client/connection/normal_delegate.ipp index f084dc163..f05263cdf 100644 --- a/boost/network/protocol/http/client/connection/normal_delegate.ipp +++ b/boost/network/protocol/http/client/connection/normal_delegate.ipp @@ -14,29 +14,29 @@ #include #include -boost::network::http::impl::normal_delegate::normal_delegate(asio::io_service & service) +boost::network::http::normal_delegate::normal_delegate(asio::io_service & service) : service_(service) {} -void boost::network::http::impl::normal_delegate::connect( +void boost::network::http::normal_delegate::connect( asio::ip::tcp::endpoint & endpoint, function handler) { socket_.reset(new asio::ip::tcp::socket(service_)); socket_->async_connect(endpoint, handler); } -void boost::network::http::impl::normal_delegate::write( +void boost::network::http::normal_delegate::write( asio::streambuf & command_streambuf, function handler) { asio::async_write(*socket_, command_streambuf, handler); } -void boost::network::http::impl::normal_delegate::read_some( +void boost::network::http::normal_delegate::read_some( asio::mutable_buffers_1 const & read_buffer, function handler) { socket_->async_read_some(read_buffer, handler); } -boost::network::http::impl::normal_delegate::~normal_delegate() {} +boost::network::http::normal_delegate::~normal_delegate() {} #endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_NORMAL_DELEGATE_IPP_20110819 */ diff --git a/boost/network/protocol/http/client/connection/resolver_delegate_factory.hpp b/boost/network/protocol/http/client/connection/resolver_delegate_factory.hpp index e754473f6..cb55bdb8e 100644 --- a/boost/network/protocol/http/client/connection/resolver_delegate_factory.hpp +++ b/boost/network/protocol/http/client/connection/resolver_delegate_factory.hpp @@ -9,21 +9,20 @@ #include -namespace boost { namespace network { namespace http { namespace impl { +namespace boost { namespace network { namespace http { struct resolver_base; -template -struct resolver_delegate_factory; - -template -struct resolver_delegate_factory >::type> { - typedef shared_ptr resolver_delegate_ptr; - // TODO Implement this! - resolver_delegate_ptr new_resolver_delegate(...); +struct resolver_delegate_factory { + resolver_delegate_factory(); + virtual shared_ptr create_resolver_delegate( + asio::io_service & service, + request_base const & request); + private: + resolver_delegate_factory(resolver_delegate_factory const &); // = delete + resolver_delegate_factory& operator=(resolver_delegate_factory); // = delete }; -} /* impl */ } /* http */ } /* network */ } /* boost */ diff --git a/boost/network/protocol/http/client/connection/simple_connection_factory.hpp b/boost/network/protocol/http/client/connection/simple_connection_factory.hpp new file mode 100644 index 000000000..c2d3759b7 --- /dev/null +++ b/boost/network/protocol/http/client/connection/simple_connection_factory.hpp @@ -0,0 +1,48 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SIMPLE_CONNECTION_FACTORY_20111112 +#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SIMPLE_CONNECTION_FACTORY_20111112 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include +#include +#include +#include +#include + +namespace boost { namespace network { namespace http { + +struct simple_connection_factory_pimpl; + +struct simple_connection_factory : connection_factory { + simple_connection_factory(); + simple_connection_factory(shared_ptr conn_delegate_factory, + shared_ptr res_delegate_factory); + virtual shared_ptr create_connection(asio::io_service & service, + request_base const & request, + bool cache_resolved, + bool follow_redirects, + optional openssl_certificate, + optional openssl_verify_path); // override + virtual ~simple_connection_factory(); + private: + scoped_ptr pimpl; + simple_connection_factory(simple_connection_factory const &); // = delete + simple_connection_factory& operator=(simple_connection_factory); // = delete +}; + +} /* http */ + +} /* network */ + +} /* boost */ + +#ifdef BOOST_NETWORK_NO_LIB +#include +#endif + +#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SIMPLE_CONNECTION_FACTORY_20111112 */ + diff --git a/boost/network/protocol/http/client/connection/simple_connection_factory.ipp b/boost/network/protocol/http/client/connection/simple_connection_factory.ipp new file mode 100644 index 000000000..17fcced83 --- /dev/null +++ b/boost/network/protocol/http/client/connection/simple_connection_factory.ipp @@ -0,0 +1,82 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SIMPLE_CONNECTION_FACTORY_20111120 +#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SIMPLE_CONNECTION_FACTORY_20111120 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include +#include +#include +#include + +namespace boost { namespace network { namespace http { + +struct simple_connection_factory_pimpl { + simple_connection_factory_pimpl(shared_ptr conn_delegate_factory, + shared_ptr res_delegate_factory) + : conn_delegate_factory_(conn_delegate_factory) + , res_delegate_factory_(res_delegate_factory) + {} + + shared_ptr create_connection( + asio::io_service & service, + request_base const & request, + bool cache_resolved, + bool follow_redirects, + optional openssl_certificate, + optional openssl_verify_path) { + ::boost::network::uri::uri uri_(destination(request)); + bool https = to_lower_copy(scheme(uri_)) == "https"; + shared_ptr conn_; + conn_.reset(new (std::nothrow) http_async_connection( + res_delegate_factory_->create_resolver_delegate(service, request), + conn_delegate_factory_->create_connection_delegate( + service, https, openssl_certificate, openssl_verify_path), + service, + follow_redirects)); + } + + private: + shared_ptr conn_delegate_factory_; + shared_ptr res_delegate_factory_; +}; + +simple_connection_factory::simple_connection_factory() { + shared_ptr connection_delegate_factory_; + connection_delegate_factory_.reset(new (std::nothrow) connection_delegate_factory()); + shared_ptr resolver_delegate_factory_; + resolver_delegate_factory_.reset(new (std::nothrow) resolver_delegate_factory()); + pimpl.reset(new (std::nothrow) simple_connection_factory_pimpl( + connection_delegate_factory_, resolver_delegate_factory_)); +} + +simple_connection_factory::simple_connection_factory(shared_ptr conn_delegate_factory, + shared_ptr res_delegate_factory) +: pimpl(new (std::nothrow) simple_connection_factory_pimpl(conn_delegate_factory, res_delegate_factory)) +{} + +shared_ptr +simple_connection_factory::create_connection(asio::io_service & service, + request_base const & request, + bool cache_resolved, + bool follow_redirects, + optional openssl_certificate, + optional openssl_verify_path) { + return pimpl->create_connection(service, request, cache_resolved, follow_redirects, + openssl_certificate, openssl_verify_path); +} + +simple_connection_factory::~simple_connection_factory() { + // do nothing +} + +} /* http */ + +} /* network */ + +} /* boost */ + +#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SIMPLE_CONNECTION_FACTORY_20111120 */ diff --git a/boost/network/protocol/http/client/connection/ssl_delegate.hpp b/boost/network/protocol/http/client/connection/ssl_delegate.hpp index d07281df7..41cb284b0 100644 --- a/boost/network/protocol/http/client/connection/ssl_delegate.hpp +++ b/boost/network/protocol/http/client/connection/ssl_delegate.hpp @@ -13,7 +13,7 @@ #include #include -namespace boost { namespace network { namespace http { namespace impl { +namespace boost { namespace network { namespace http { struct ssl_delegate : connection_delegate, enable_shared_from_this { ssl_delegate(asio::io_service & service, @@ -41,8 +41,6 @@ struct ssl_delegate : connection_delegate, enable_shared_from_this function handler); }; -} /* impl */ - } /* http */ } /* network */ diff --git a/boost/network/protocol/http/client/connection/ssl_delegate.ipp b/boost/network/protocol/http/client/connection/ssl_delegate.ipp index c7ee5e573..65a8f541e 100644 --- a/boost/network/protocol/http/client/connection/ssl_delegate.ipp +++ b/boost/network/protocol/http/client/connection/ssl_delegate.ipp @@ -10,14 +10,14 @@ #include #include -boost::network::http::impl::ssl_delegate::ssl_delegate(asio::io_service & service, +boost::network::http::ssl_delegate::ssl_delegate(asio::io_service & service, optional certificate_filename, optional verify_path) : service_(service), certificate_filename_(certificate_filename), verify_path_(verify_path) {} -void boost::network::http::impl::ssl_delegate::connect( +void boost::network::http::ssl_delegate::connect( asio::ip::tcp::endpoint & endpoint, function handler) { context_.reset(new asio::ssl::context( @@ -33,13 +33,13 @@ void boost::network::http::impl::ssl_delegate::connect( socket_.reset(new asio::ssl::stream(service_, *context_)); socket_->lowest_layer().async_connect( endpoint, - bind(&boost::network::http::impl::ssl_delegate::handle_connected, - boost::network::http::impl::ssl_delegate::shared_from_this(), + bind(&boost::network::http::ssl_delegate::handle_connected, + boost::network::http::ssl_delegate::shared_from_this(), asio::placeholders::error, handler)); } -void boost::network::http::impl::ssl_delegate::handle_connected(system::error_code const & ec, +void boost::network::http::ssl_delegate::handle_connected(system::error_code const & ec, function handler) { if (!ec) { socket_->async_handshake(asio::ssl::stream_base::client, handler); @@ -48,18 +48,18 @@ void boost::network::http::impl::ssl_delegate::handle_connected(system::error_co } } -void boost::network::http::impl::ssl_delegate::write( +void boost::network::http::ssl_delegate::write( asio::streambuf & command_streambuf, function handler) { asio::async_write(*socket_, command_streambuf, handler); } -void boost::network::http::impl::ssl_delegate::read_some( +void boost::network::http::ssl_delegate::read_some( asio::mutable_buffers_1 const & read_buffer, function handler) { socket_->async_read_some(read_buffer, handler); } -boost::network::http::impl::ssl_delegate::~ssl_delegate() {} +boost::network::http::ssl_delegate::~ssl_delegate() {} #endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SSL_DELEGATE_IPP_20110819 */ diff --git a/boost/network/protocol/http/client/facade.hpp b/boost/network/protocol/http/client/facade.hpp index f26282215..ee6113222 100644 --- a/boost/network/protocol/http/client/facade.hpp +++ b/boost/network/protocol/http/client/facade.hpp @@ -10,7 +10,8 @@ #include #include #include -#include +#include +#include namespace boost { namespace network { namespace http { @@ -127,12 +128,16 @@ struct basic_client_facade { template void init_base(ArgPack const & args, no_io_service) { - base.reset(new client_base(this->get_connection_manager(args))); + base.reset(new client_base( + this->get_connection_manager(args))); } template void init_base(ArgPack const & args, has_io_service) { - base.reset(new client_base(args[_io_service], this->get_connection_manager(args))); + base.reset( + new client_base( + args[_io_service], + this->get_connection_manager(args))); } private: @@ -142,16 +147,32 @@ struct basic_client_facade { shared_ptr connection_manager_ = args[_connection_manager|shared_ptr()]; if (!connection_manager_.get()) { // Because there's no explicit connection manager, we use the default - // implementation as provided by the tag. + // implementation. connection_manager_.reset( - new simple_async_connection_manager(args[_cache_resolved|false], - args[_follow_redirects|false], - args[_openssl_certificate|optional()], - args[_openssl_verify_path|optional()])); + new (std::nothrow) simple_connection_manager( + args[_cache_resolved|false], + args[_follow_redirects|false], + args[_openssl_certificate|optional()], + args[_openssl_verify_path|optional()], + this->get_connection_factory(args))); } return connection_manager_; } + + template + shared_ptr get_connection_factory(ArgPack const & args) { + shared_ptr connection_factory_ = args[_connection_factory|shared_ptr()]; + if (!connection_factory_.get()) { + // Because there's no explicit connection factory, we use the default + // implementation. + connection_factory_.reset( + new (std::nothrow) simple_connection_factory()); + } + + return connection_factory_; + } + }; } // namespace http diff --git a/boost/network/protocol/http/client/parameters.hpp b/boost/network/protocol/http/client/parameters.hpp index 19c213fe1..340e9506e 100644 --- a/boost/network/protocol/http/client/parameters.hpp +++ b/boost/network/protocol/http/client/parameters.hpp @@ -21,6 +21,7 @@ namespace boost { namespace network { namespace http { BOOST_PARAMETER_NAME(body_handler) BOOST_PARAMETER_NAME(connection_manager) + BOOST_PARAMETER_NAME(connection_factory) } /* http */ } /* network */ diff --git a/boost/network/protocol/http/client/simple_connection_manager.hpp b/boost/network/protocol/http/client/simple_connection_manager.hpp new file mode 100644 index 000000000..173135164 --- /dev/null +++ b/boost/network/protocol/http/client/simple_connection_manager.hpp @@ -0,0 +1,119 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_SIMPLE_CONNECTION_MANAGER_HPP_20111105 +#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_SIMPLE_CONNECTION_MANAGER_HPP_20111105 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include +#include +#include + +namespace boost { namespace network { namespace http { + +/// Forward declaration of simple_connection_manager_pimpl. +struct simple_connection_manager_pimpl; + +/** simple_connection_manager + * + * This connection manager implementation doesn't do any connection tracking + * and mostly delegates the connection creation from a connection factory. + */ +struct simple_connection_manager : connection_manager { + /** Constructor + * + * Args: + * bool cache_resolved: Indicate whether to cache resolved endpoints. + * bool follow_redirects: Indicate whether to follow HTTP 301/302/304 + * redirections. + * optional openssl_certificate: The filename for the + * OpenSSL certificate to use. + * optional openssl_verify_path: The directory from which + * OpenSSL certificates are + * searched for when + * verification is requested. + * shared_ptr: The connection factory that actually + * creates the appropriate client + * connection object. + */ + simple_connection_manager(bool cache_resolved, + bool follow_redirects, + optional openssl_certificate, + optional openssl_verify_path, + shared_ptr connection_factory); + + /** Constructor + * + * Args: + * bool cache_resolved: Indicate whether to cache resolved endpoints. + * bool follow_redirects: Indicate whether to follow HTTP 301/302/304 + * redirections. + * std::string const & openssl_certificate: The filename for the + * OpenSSL certificate to use. + * std::string const & openssl_verify_path: The directory from which + * OpenSSL certificates are + * searched for when + * verification is requested. + * shared_ptr: The connection factory that actually + * creates the appropriate client + * connection object. + */ + simple_connection_manager(bool cache_resolved, + bool follow_redirects, + std::string const & openssl_certificate, + std::string const & openssl_verify_path, + shared_ptr connection_factory); + + /** get_connection + * + * Args: + * asio::io_service & service: The io_service instance to which the + * connection should be bound to (for newly + * created objects, ignored for already + * created objects). + * request_base const & request: The request object that includes the + * information required by the connection. + * + * Returns: + * shared_ptr -- either an already-generated object + * or a newly constructed connection configured to perform the request. + */ + virtual shared_ptr get_connection( + asio::io_service & service, + request_base const & request); // override + + /** reset + * + * This function resets the internal caches and intermediary data structures + * used by the connection manager to perform its functions. In the case of + * this simple_connection_manager, the call to reset will not do anything. + */ + virtual void reset(); // override + + /** Destructor. + */ + virtual ~simple_connection_manager(); // override + + protected: + scoped_ptr pimpl; + + private: + /// Disabled copy constructor. + simple_connection_manager(simple_connection_manager const &); // = delete + /// Disabled assignment operator. + simple_connection_manager & operator=(simple_connection_manager); // = delete +}; + +} /* http */ + +} /* network */ + +} /* boost */ + +#ifdef BOOST_NETWORK_NO_LIB +#include +#endif + +#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_SIMPLE_CONNECTION_MANAGER_HPP_20111105 */ diff --git a/boost/network/protocol/http/client/simple_connection_manager.ipp b/boost/network/protocol/http/client/simple_connection_manager.ipp new file mode 100644 index 000000000..ff049ac92 --- /dev/null +++ b/boost/network/protocol/http/client/simple_connection_manager.ipp @@ -0,0 +1,99 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_SIMPLE_CONNECTION_MANAGER_IPP_20111112 +#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_SIMPLE_CONNECTION_MANAGER_IPP_20111112 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include + +namespace boost { namespace network { namespace http { + +struct simple_connection_manager_pimpl { + simple_connection_manager_pimpl(bool cache_resolved, + bool follow_redirects, + optional openssl_certificate, + optional openssl_verify_path, + shared_ptr connection_factory) + : cache_resolved_(cache_resolved_) + , follow_redirects_(follow_redirects) + , openssl_certificate_(openssl_certificate) + , openssl_verify_path_(openssl_verify_path) + , connection_factory_(connection_factory) + {} + + simple_connection_manager_pimpl(bool cache_resolved, + bool follow_redirects, + std::string const & openssl_certificate, + std::string const & openssl_verify_path, + shared_ptr connection_factory) + : cache_resolved_(cache_resolved_) + , follow_redirects_(follow_redirects) + , openssl_certificate_(openssl_certificate) + , openssl_verify_path_(openssl_verify_path) + , connection_factory_(connection_factory) + {} + + shared_ptr get_connection(asio::io_service & service, + request_base const & request) { + return connection_factory_->create_connection( + service, request, cache_resolved_, follow_redirects_, + openssl_certificate_, openssl_verify_path_); + } + + void reset() { + // do nothing here. + } + + ~simple_connection_manager_pimpl() { + // do nothing here. + } + + private: + bool cache_resolved_, follow_redirects_; + optional openssl_certificate_, openssl_verify_path_; + shared_ptr connection_factory_; + +}; + +simple_connection_manager::simple_connection_manager(bool cache_resolved, + bool follow_redirects, + optional openssl_certificate, + optional openssl_verify_path, + shared_ptr connection_factory) +: pimpl(new (std::nothrow) simple_connection_manager_pimpl( + cache_resolved, follow_redirects, openssl_certificate, openssl_verify_path, connection_factory)) +{} + +simple_connection_manager::simple_connection_manager(bool cache_resolved, + bool follow_redirects, + std::string const & openssl_certificate, + std::string const & openssl_verify_path, + shared_ptr connection_factory) +: pimpl(new (std::nothrow) simple_connection_manager_pimpl( + cache_resolved, follow_redirects, openssl_certificate, openssl_verify_path, connection_factory)) +{} + +shared_ptr simple_connection_manager::get_connection( + asio::io_service & service, + request_base const & request) { + return pimpl->get_connection(service, request); +} + +void simple_connection_manager::reset() { + pimpl->reset(); +} + +simple_connection_manager::~simple_connection_manager() { + // do nothing here. +} + +} /* http */ + +} /* network */ + +} /* boost */ + +#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_SIMPLE_CONNECTION_MANAGER_IPP_20111112 */ diff --git a/boost/network/protocol/http/request/request.hpp b/boost/network/protocol/http/request/request.hpp index eab2164d2..eb01a25d9 100644 --- a/boost/network/protocol/http/request/request.hpp +++ b/boost/network/protocol/http/request/request.hpp @@ -28,13 +28,13 @@ struct request : request_base { virtual void append_body(std::string const & data); // Retrievers - virtual void get_destination(std::string & destination); - virtual void get_source(std::string & source); - virtual void get_headers(function inserter); - virtual void get_headers(std::string const & name, function inserter); - virtual void get_headers(function predicate, function inserter); - virtual void get_body(std::string & body); - virtual void get_body(function)> chunk_reader, size_t size); + virtual void get_destination(std::string & destination) const; + virtual void get_source(std::string & source) const; + virtual void get_headers(function inserter) const; + virtual void get_headers(std::string const & name, function inserter) const; + virtual void get_headers(function predicate, function inserter) const; + virtual void get_body(std::string & body) const; + virtual void get_body(function)> chunk_reader, size_t size) const; // From request_base... // Setters @@ -46,12 +46,12 @@ struct request : request_base { virtual void set_uri(network::uri::uri const &uri); // Getters - virtual void get_uri(network::uri::uri &uri); - virtual void get_uri(std::string &uri); - virtual void get_method(std::string & method); - virtual void get_status(std::string & status); - virtual void get_status_message(std::string & status_message); - virtual void get_body_stream(body_stream & output_stream); + virtual void get_uri(network::uri::uri &uri) const; + virtual void get_uri(std::string &uri) const; + virtual void get_method(std::string & method) const; + virtual void get_status(std::string & status) const; + virtual void get_status_message(std::string & status_message) const; + virtual void get_body_stream(body_stream & output_stream) const; virtual ~request(); private: diff --git a/boost/network/protocol/http/request/request_base.hpp b/boost/network/protocol/http/request/request_base.hpp index add874829..79ccbbe85 100644 --- a/boost/network/protocol/http/request/request_base.hpp +++ b/boost/network/protocol/http/request/request_base.hpp @@ -49,12 +49,12 @@ struct request_base : message_base, request_storage_base { virtual void set_uri(network::uri::uri const &uri) = 0; // Getters - virtual void get_uri(network::uri::uri &uri) = 0; - virtual void get_uri(std::string &uri) = 0; - virtual void get_method(std::string & method) = 0; - virtual void get_status(std::string & status) = 0; - virtual void get_status_message(std::string & status_message) = 0; - virtual void get_body_stream(body_stream & output_stream) = 0; + virtual void get_uri(network::uri::uri &uri) const = 0; + virtual void get_uri(std::string &uri) const = 0; + virtual void get_method(std::string & method) const = 0; + virtual void get_status(std::string & status) const = 0; + virtual void get_status_message(std::string & status_message) const = 0; + virtual void get_body_stream(body_stream & output_stream) const = 0; virtual ~request_base() = 0; }; diff --git a/boost/network/protocol/http/response/response.hpp b/boost/network/protocol/http/response/response.hpp index 7b22c0cac..412dfe3c3 100644 --- a/boost/network/protocol/http/response/response.hpp +++ b/boost/network/protocol/http/response/response.hpp @@ -24,20 +24,20 @@ struct response : response_base { virtual void append_body(std::string const & data); // Retrievers - virtual void get_destination(std::string & destination); - virtual void get_source(std::string & source); + virtual void get_destination(std::string & destination) const; + virtual void get_source(std::string & source) const; virtual void get_headers( - function inserter); + function inserter) const; virtual void get_headers( std::string const & name, - function inserter); + function inserter) const; virtual void get_headers( function predicate, - function inserter); - virtual void get_body(std::string & body); + function inserter) const; + virtual void get_body(std::string & body) const; virtual void get_body( function)> chunk_reader, - size_t size); + size_t size) const; // From response_base... virtual void set_status(std::string const & new_status); diff --git a/libs/network/src/CMakeLists.txt b/libs/network/src/CMakeLists.txt index c3101a62d..6b2599d9b 100644 --- a/libs/network/src/CMakeLists.txt +++ b/libs/network/src/CMakeLists.txt @@ -28,7 +28,11 @@ add_library(cppnetlib-message-wrappers ${CPP-NETLIB_MESSAGE_WRAPPERS_SRCS}) set(CPP-NETLIB_HTTP_MESSAGE_SRCS http/request.cpp http/response.cpp) add_library(cppnetlib-http-message ${CPP-NETLIB_HTTP_MESSAGE_SRCS}) -set(CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS http/client_connections.cpp) +set(CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS + http/client_connections.cpp + http/simple_connection_manager.cpp + http/simple_connection_factory.cpp + http/connection_delegate_factory.cpp) add_library(cppnetlib-http-client-connections ${CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS}) set(CPP-NETLIB_UTILS_THREAD_POOL_SRCS utils/thread_pool.cpp) diff --git a/libs/network/src/http/connection_delegate_factory.cpp b/libs/network/src/http/connection_delegate_factory.cpp new file mode 100644 index 000000000..9c9cf31ee --- /dev/null +++ b/libs/network/src/http/connection_delegate_factory.cpp @@ -0,0 +1,11 @@ +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#ifdef BOOST_NETWORK_NO_LIB +#undef BOOST_NETWORK_NO_LIB +#endif + +#include diff --git a/libs/network/src/http/simple_connection_factory.cpp b/libs/network/src/http/simple_connection_factory.cpp new file mode 100644 index 000000000..dc0bd6847 --- /dev/null +++ b/libs/network/src/http/simple_connection_factory.cpp @@ -0,0 +1,11 @@ +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#ifdef BOOST_NETWORK_NO_LIB +#undef BOOST_NETWORK_NO_LIB +#endif + +#include diff --git a/libs/network/src/http/simple_connection_manager.cpp b/libs/network/src/http/simple_connection_manager.cpp new file mode 100644 index 000000000..d446ae037 --- /dev/null +++ b/libs/network/src/http/simple_connection_manager.cpp @@ -0,0 +1,11 @@ +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#ifdef BOOST_NETWORK_NO_LIB +#undef BOOST_NETWORK_NO_LIB +#endif + +#include From ed4d247d67243399aa2a9197e77f6e613e738217 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sat, 26 Nov 2011 23:48:16 +1100 Subject: [PATCH 027/196] Progress on build of some tests. This resolves some dependency issues on the cppnetlib-http-client-connections lib. From here on out I'm moving on to the development of the meat of the client implementation, as well as the functionality. It looks like (at least optimistically) the event horizon is at least visible from this black hole. --- .../protocol/http/client/simple_connection_manager.ipp | 1 - boost/network/uri/accessors.hpp | 5 +++++ boost/network/uri/uri.hpp | 1 + libs/network/build/CMakeLists.txt | 9 +++++++++ libs/network/src/CMakeLists.txt | 4 ++++ libs/network/test/http/CMakeLists.txt | 6 ++++-- 6 files changed, 23 insertions(+), 3 deletions(-) diff --git a/boost/network/protocol/http/client/simple_connection_manager.ipp b/boost/network/protocol/http/client/simple_connection_manager.ipp index ff049ac92..e8042c374 100644 --- a/boost/network/protocol/http/client/simple_connection_manager.ipp +++ b/boost/network/protocol/http/client/simple_connection_manager.ipp @@ -55,7 +55,6 @@ struct simple_connection_manager_pimpl { bool cache_resolved_, follow_redirects_; optional openssl_certificate_, openssl_verify_path_; shared_ptr connection_factory_; - }; simple_connection_manager::simple_connection_manager(bool cache_resolved, diff --git a/boost/network/uri/accessors.hpp b/boost/network/uri/accessors.hpp index 7b71862b3..242caf218 100644 --- a/boost/network/uri/accessors.hpp +++ b/boost/network/uri/accessors.hpp @@ -51,6 +51,7 @@ Map &query_map(const uri &uri_, Map &map) { return map; } +inline std::string username(const uri &uri_) { uri::const_range_type user_info_range = uri_.user_info_range(); uri::const_iterator it(boost::begin(user_info_range)), end(boost::end(user_info_range)); @@ -62,6 +63,7 @@ std::string username(const uri &uri_) { return std::string(boost::begin(user_info_range), it); } +inline std::string password(const uri &uri_) { uri::const_range_type user_info_range = uri_.user_info_range(); uri::const_iterator it(boost::begin(user_info_range)), end(boost::end(user_info_range)); @@ -74,6 +76,7 @@ std::string password(const uri &uri_) { return std::string(it, boost::end(user_info_range)); } +inline std::string decoded_path(const uri &uri_) { uri::const_range_type path_range = uri_.path_range(); std::string decoded_path; @@ -81,6 +84,7 @@ std::string decoded_path(const uri &uri_) { return decoded_path; } +inline std::string decoded_query(const uri &uri_) { uri::const_range_type query_range = uri_.query_range(); std::string decoded_query; @@ -88,6 +92,7 @@ std::string decoded_query(const uri &uri_) { return decoded_query; } +inline std::string decoded_fragment(const uri &uri_) { uri::const_range_type fragment_range = uri_.fragment_range(); std::string decoded_fragment; diff --git a/boost/network/uri/uri.hpp b/boost/network/uri/uri.hpp index 31aae7c95..8fa4e07ad 100644 --- a/boost/network/uri/uri.hpp +++ b/boost/network/uri/uri.hpp @@ -292,6 +292,7 @@ bool is_hierarchical(const uri &uri_) { return false; } +inline bool is_opaque(const uri &uri_) { return false; } diff --git a/libs/network/build/CMakeLists.txt b/libs/network/build/CMakeLists.txt index 305bb82ce..931ab14de 100644 --- a/libs/network/build/CMakeLists.txt +++ b/libs/network/build/CMakeLists.txt @@ -13,3 +13,12 @@ add_library(cppnetlib-http-message STATIC ${CPP-NETLIB_SOURCE_DIR}/libs/network/src/http/request.cpp ${CPP-NETLIB_SOURCE_DIR}/libs/network/src/http/response.cpp) +add_library(cppnetlib-http-client-connections + STATIC + ${CPP-NETLIB_SOURCE_DIR}/libs/network/src/http/client_connections.cpp + ${CPP-NETLIB_SOURCE_DIR}/libs/network/src/http/simple_connection_manager.cpp + ${CPP-NETLIB_SOURCE_DIR}/libs/network/src/http/simple_connection_factory.cpp + ${CPP-NETLIB_SOURCE_DIR}/libs/network/src/http/connection_delegate_factory.cpp) +add_library(cppnetlib-http-client + STATIC + ${CPP-NETLIB_SOURCE_DIR}/libs/network/src/http/client.cpp) diff --git a/libs/network/src/CMakeLists.txt b/libs/network/src/CMakeLists.txt index 6b2599d9b..81e471882 100644 --- a/libs/network/src/CMakeLists.txt +++ b/libs/network/src/CMakeLists.txt @@ -35,5 +35,9 @@ set(CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS http/connection_delegate_factory.cpp) add_library(cppnetlib-http-client-connections ${CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS}) +set(CPP-NETLIB_HTTP_CLIENT_SRCS + http/client.cpp) +add_library(cppnetlib-http-client ${CPP-NETLIB_HTTP_CLIENT_SRCS}) + set(CPP-NETLIB_UTILS_THREAD_POOL_SRCS utils/thread_pool.cpp) add_library(cppnetlib-utils-thread_pool ${CPP-NETLIB_UTILS_THREAD_POOL_SRCS}) diff --git a/libs/network/test/http/CMakeLists.txt b/libs/network/test/http/CMakeLists.txt index 5b04d0026..e71b8333f 100644 --- a/libs/network/test/http/CMakeLists.txt +++ b/libs/network/test/http/CMakeLists.txt @@ -35,14 +35,16 @@ if (Boost_FOUND) cppnetlib-uri cppnetlib-message cppnetlib-http-message - cppnetlib-client-connections) + cppnetlib-http-client + cppnetlib-http-client-connections) target_link_libraries(cpp-netlib-http-${test} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri cppnetlib-message cppnetlib-http-message - cppnetlib-client-connections) + cppnetlib-http-client + cppnetlib-http-client-connections) if (OPENSSL_FOUND) target_link_libraries(cpp-netlib-http-${test} ${OPENSSL_LIBRARIES}) endif() From bcdf43c7141f1e1ccdd306870b0fdeaa2170bf80 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sat, 26 Nov 2011 23:55:03 +1100 Subject: [PATCH 028/196] Step one: Client base compiles. This is the first step in filling out cppnetlib-http-client lib object files. --- boost/network/protocol/http/client/base.ipp | 10 ++++++---- libs/network/src/http/client.cpp | 11 +++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 libs/network/src/http/client.cpp diff --git a/boost/network/protocol/http/client/base.ipp b/boost/network/protocol/http/client/base.ipp index 8140f67e4..34732b6d3 100644 --- a/boost/network/protocol/http/client/base.ipp +++ b/boost/network/protocol/http/client/base.ipp @@ -7,11 +7,13 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#include #include #include #include #include #include +#include namespace boost { namespace network { namespace http { @@ -20,8 +22,8 @@ struct client_base_pimpl { function const &, system::error_code const &)> body_callback_function_type; client_base_pimpl(shared_ptr connection_manager_); - client_base_pimpl(io_service & service, shared_ptr connection_manager_); - response const request_skeleton(request const & request_, + client_base_pimpl(asio::io_service & service, shared_ptr connection_manager_); + response const request_skeleton(request_base const & request_, std::string const & method, bool get_body, body_callback_function_type callback); @@ -80,7 +82,7 @@ client_base_pimpl::client_base_pimpl(boost::asio::io_service & service, BOOST_THROW_EXCEPTION(std::runtime_error("Cannot allocate sentinel; not enough memory.")); } -~client_base_pimpl::client_base_pimpl() +client_base_pimpl::~client_base_pimpl() { sentinel_.reset(); connection_manager_->reset(); @@ -92,7 +94,7 @@ client_base_pimpl::client_base_pimpl(boost::asio::io_service & service, } response const client_base_pimpl::request_skeleton( - request const & request_, + request_base const & request_, std::string const & method, bool get_body, body_callback_function_type callback diff --git a/libs/network/src/http/client.cpp b/libs/network/src/http/client.cpp new file mode 100644 index 000000000..fe421c53d --- /dev/null +++ b/libs/network/src/http/client.cpp @@ -0,0 +1,11 @@ +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#ifdef BOOST_NETWORK_NO_LIB +#undef BOOST_NETWORK_NO_LIB +#endif + +#include From fab3b5f7844467f904e4ba6a54c61c83ed890fdb Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sun, 27 Nov 2011 00:34:53 +1100 Subject: [PATCH 029/196] Step two: implement the resolver delegate factory. This moves out the policies into the client/connection/ directory and adds the necessary parts that deal with the creation of the async_resolver implementation. We now have wired the async_resolver to derive from a resolver_delegate type that the connections will use to resolve IP addresses of hosts. --- .../http/client/connection/async_normal.hpp | 2 +- .../http/client/connection/async_resolver.hpp | 43 +++++++++++++++++ .../connection}/async_resolver.ipp | 8 ++-- .../client/connection/resolver_delegate.hpp | 17 +++++++ .../client/connection/resolver_delegate.ipp | 23 +++++++++ .../connection/resolver_delegate_factory.hpp | 11 +++-- .../connection/resolver_delegate_factory.ipp | 32 +++++++++++++ .../protocol/http/policies/async_resolver.hpp | 48 ------------------- libs/network/src/CMakeLists.txt | 3 +- .../http/client_resolver_delegate_factory.cpp | 11 +++++ 10 files changed, 142 insertions(+), 56 deletions(-) create mode 100644 boost/network/protocol/http/client/connection/async_resolver.hpp rename boost/network/protocol/http/{policies => client/connection}/async_resolver.ipp (92%) create mode 100644 boost/network/protocol/http/client/connection/resolver_delegate.ipp create mode 100644 boost/network/protocol/http/client/connection/resolver_delegate_factory.ipp delete mode 100644 boost/network/protocol/http/policies/async_resolver.hpp create mode 100644 libs/network/src/http/client_resolver_delegate_factory.cpp diff --git a/boost/network/protocol/http/client/connection/async_normal.hpp b/boost/network/protocol/http/client/connection/async_normal.hpp index 51abe10a1..c31edba68 100644 --- a/boost/network/protocol/http/client/connection/async_normal.hpp +++ b/boost/network/protocol/http/client/connection/async_normal.hpp @@ -23,7 +23,7 @@ struct http_async_connection : client_connection , enable_shared_from_this { using client_connection::callback_type; - http_async_connection(shared_ptr resolver_delegate, + http_async_connection(shared_ptr resolver_delegate, shared_ptr connection_delegate, asio::io_service & io_service, bool follow_redirects); diff --git a/boost/network/protocol/http/client/connection/async_resolver.hpp b/boost/network/protocol/http/client/connection/async_resolver.hpp new file mode 100644 index 000000000..abc39a403 --- /dev/null +++ b/boost/network/protocol/http/client/connection/async_resolver.hpp @@ -0,0 +1,43 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_RESOLVER_20111126 +#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_RESOLVER_20111126 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include +#include + +namespace boost { namespace network { namespace http { + +struct async_resolver_pimpl; + +struct async_resolver : resolver_delegate { + using resolver_delegate::resolve_completion_function; + + explicit async_resolver(asio::io_service & service); + virtual void resolve(std::string const & host, + uint16_t port, + resolve_completion_function once_resolved); // override + virtual void clear_resolved_cache(); // override + virtual ~async_resolver(); + + protected: + // We need a shared_ptr because the pimpl may live on long after the resolver + // delegate (instances of this type) is actually destroyed. + shared_ptr pimpl; +}; + +} // namespace http + +} // namespace network + +} // namespace boost + +#ifdef BOOST_NETWORK_NO_LIB +#include +#endif + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_RESOLVER_20111126 diff --git a/boost/network/protocol/http/policies/async_resolver.ipp b/boost/network/protocol/http/client/connection/async_resolver.ipp similarity index 92% rename from boost/network/protocol/http/policies/async_resolver.ipp rename to boost/network/protocol/http/client/connection/async_resolver.ipp index d7082efad..0a1ac390c 100644 --- a/boost/network/protocol/http/policies/async_resolver.ipp +++ b/boost/network/protocol/http/client/connection/async_resolver.ipp @@ -1,5 +1,5 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_POLICIES_ASYNC_RESOLVER_IPP_20110910 -#define BOOST_NETWORK_PROTOCOL_HTTP_POLICIES_ASYNC_RESOLVER_IPP_20110910 +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_RESOLVER_IPP_20110911 +#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_RESOLVER_IPP_20111126 // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. @@ -39,6 +39,8 @@ async_resolver::~async_resolver() { // Do nothing } +// Define the actual implementation in a private implementation class. + struct async_resolver_pimpl : enable_shared_from_this { explicit async_resolver_pimpl(asio::io_service & service); void resolve(std::string const & host, @@ -121,4 +123,4 @@ void handle_resolve(std::string const & host, } /* boost */ -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_POLICIES_ASYNC_RESOLVER_IPP_20110910 */ +#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_RESOLVER_IPP_20111126 */ diff --git a/boost/network/protocol/http/client/connection/resolver_delegate.hpp b/boost/network/protocol/http/client/connection/resolver_delegate.hpp index 3acf2fd7b..dd2492db0 100644 --- a/boost/network/protocol/http/client/connection/resolver_delegate.hpp +++ b/boost/network/protocol/http/client/connection/resolver_delegate.hpp @@ -7,9 +7,22 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#include +#include +#include + namespace boost { namespace network { namespace http { struct resolver_delegate { + typedef asio::ip::udp::resolver::iterator resolver_iterator; + typedef std::pair + iterator_pair; + typedef function + resolve_completion_function; + virtual void resolve(std::string const & host, + uint16_t port, + resolve_completion_function once_resolved) = 0; + virtual void clear_resolved_cache() = 0; virtual ~resolver_delegate() = 0; }; @@ -19,4 +32,8 @@ struct resolver_delegate { } /* boost */ +#ifdef BOOST_NETWORK_NO_LIB +#include +#endif + #endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_HPP_20111016 */ diff --git a/boost/network/protocol/http/client/connection/resolver_delegate.ipp b/boost/network/protocol/http/client/connection/resolver_delegate.ipp new file mode 100644 index 000000000..4a9c06a2d --- /dev/null +++ b/boost/network/protocol/http/client/connection/resolver_delegate.ipp @@ -0,0 +1,23 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_IPP_20111126 +#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_IPP_20111126 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include +#include + +namespace boost { namespace network { namespace http { + +resolver_delegate::~resolver_delegate() {} + +} // namespace http + +} // namespace network + +} // namespace boost + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_IPP_20111126 diff --git a/boost/network/protocol/http/client/connection/resolver_delegate_factory.hpp b/boost/network/protocol/http/client/connection/resolver_delegate_factory.hpp index cb55bdb8e..4d8597819 100644 --- a/boost/network/protocol/http/client/connection/resolver_delegate_factory.hpp +++ b/boost/network/protocol/http/client/connection/resolver_delegate_factory.hpp @@ -8,16 +8,17 @@ // http://www.boost.org/LICENSE_1_0.txt) #include +#include +#include namespace boost { namespace network { namespace http { -struct resolver_base; - struct resolver_delegate_factory { resolver_delegate_factory(); - virtual shared_ptr create_resolver_delegate( + virtual shared_ptr create_resolver_delegate( asio::io_service & service, request_base const & request); + virtual ~resolver_delegate_factory(); private: resolver_delegate_factory(resolver_delegate_factory const &); // = delete resolver_delegate_factory& operator=(resolver_delegate_factory); // = delete @@ -27,4 +28,8 @@ struct resolver_delegate_factory { } /* network */ } /* boost */ +#ifdef BOOST_NETWORK_NO_LIB +#include +#endif + #endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_FACTORY_HPP_20110930 */ diff --git a/boost/network/protocol/http/client/connection/resolver_delegate_factory.ipp b/boost/network/protocol/http/client/connection/resolver_delegate_factory.ipp new file mode 100644 index 000000000..c74377258 --- /dev/null +++ b/boost/network/protocol/http/client/connection/resolver_delegate_factory.ipp @@ -0,0 +1,32 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_FACTORY_IPP_20111126 +#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_FACTORY_IPP_20111126 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include +#include + +namespace boost { namespace network { namespace http { + +resolver_delegate_factory::resolver_delegate_factory() {} + +shared_ptr +resolver_delegate_factory::create_resolver_delegate(asio::io_service & service, + request_base const & request) { + shared_ptr resolver_(new (std::nothrow) async_resolver(service)); + return resolver_; +} + +resolver_delegate_factory::~resolver_delegate_factory() {} + +} // namespace http + +} // namespace network + +} // namespace boost + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_FACTORY_IPP_20111126 diff --git a/boost/network/protocol/http/policies/async_resolver.hpp b/boost/network/protocol/http/policies/async_resolver.hpp deleted file mode 100644 index c7cacfbdf..000000000 --- a/boost/network/protocol/http/policies/async_resolver.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_POLICIES_ASYNC_RESOLVER_20100622 -#define BOOST_NETWORK_PROTOCOL_HTTP_POLICIES_ASYNC_RESOLVER_20100622 - -// Copyright 2011 Dean Michael Berris . -// Copyright 2011 Google, Inc. -// 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) - -#include -#include -#include - -namespace boost { namespace network { namespace http { namespace policies { - -struct async_resolver_pimpl; - -struct async_resolver { - typedef asio::ip::udp::resolver::iterator resolver_iterator; - typedef std::pair - iterator_pair; - typedef function - resolve_completion_function; - - explicit async_resolver(asio::io_service & service); - void resolve(std::string const & host, - uint16_t port, - resolve_completion_function once_resolved); - void clear_resolved_cache(); - ~async_resolver(); - - protected: - shared_ptr pimpl; -}; - -} // namespace policies - -} // namespace http - -} // namespace network - -} // namespace boost - -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_POLICIES_ASYNC_RESOLVER_20100622 diff --git a/libs/network/src/CMakeLists.txt b/libs/network/src/CMakeLists.txt index 81e471882..71a8ae918 100644 --- a/libs/network/src/CMakeLists.txt +++ b/libs/network/src/CMakeLists.txt @@ -32,7 +32,8 @@ set(CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS http/client_connections.cpp http/simple_connection_manager.cpp http/simple_connection_factory.cpp - http/connection_delegate_factory.cpp) + http/connection_delegate_factory.cpp + http/client_resolver_delegate_factory.cpp) add_library(cppnetlib-http-client-connections ${CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS}) set(CPP-NETLIB_HTTP_CLIENT_SRCS diff --git a/libs/network/src/http/client_resolver_delegate_factory.cpp b/libs/network/src/http/client_resolver_delegate_factory.cpp new file mode 100644 index 000000000..06c82f2a8 --- /dev/null +++ b/libs/network/src/http/client_resolver_delegate_factory.cpp @@ -0,0 +1,11 @@ +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#ifdef BOOST_NETWORK_NO_LIB +#undef BOOST_NETWORK_NO_LIB +#endif + +#include From 9ad624aefb5a5b794a351b5394caba5ae9a5cb4f Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sun, 27 Nov 2011 01:05:29 +1100 Subject: [PATCH 030/196] Getting the ducks in a neat row... First, we get the asynchronous resolver delegate into a cpp file that gets built and linked into the cppnetlib-client-connections lib. We then write it up in the connection factory and resolver delegate factory implementation so that we can create instances of these properly. Then lastly we have the default implementation of the pure virtual destructors for the pure interface types we use. --- .../http/client/connection/async_resolver.hpp | 2 +- .../http/client/connection/async_resolver.ipp | 77 +++++++++++-------- .../connection_delegate_factory.ipp | 2 + .../client/connection/connection_factory.ipp | 22 ++++++ .../connection/resolver_delegate_factory.hpp | 2 +- .../connection/resolver_delegate_factory.ipp | 5 +- .../connection/simple_connection_factory.ipp | 2 +- libs/network/src/CMakeLists.txt | 6 +- .../src/http/client_async_resolver.cpp | 11 +++ .../src/http/client_connection_delegates.cpp | 14 ++++ .../src/http/client_connection_factory.cpp | 11 +++ .../src/http/client_resolver_delegate.cpp | 11 +++ 12 files changed, 127 insertions(+), 38 deletions(-) create mode 100644 boost/network/protocol/http/client/connection/connection_factory.ipp create mode 100644 libs/network/src/http/client_async_resolver.cpp create mode 100644 libs/network/src/http/client_connection_delegates.cpp create mode 100644 libs/network/src/http/client_connection_factory.cpp create mode 100644 libs/network/src/http/client_resolver_delegate.cpp diff --git a/boost/network/protocol/http/client/connection/async_resolver.hpp b/boost/network/protocol/http/client/connection/async_resolver.hpp index abc39a403..dc6dfd151 100644 --- a/boost/network/protocol/http/client/connection/async_resolver.hpp +++ b/boost/network/protocol/http/client/connection/async_resolver.hpp @@ -17,7 +17,7 @@ struct async_resolver_pimpl; struct async_resolver : resolver_delegate { using resolver_delegate::resolve_completion_function; - explicit async_resolver(asio::io_service & service); + async_resolver(asio::io_service & service, bool cache_resolved); virtual void resolve(std::string const & host, uint16_t port, resolve_completion_function once_resolved); // override diff --git a/boost/network/protocol/http/client/connection/async_resolver.ipp b/boost/network/protocol/http/client/connection/async_resolver.ipp index 0a1ac390c..90d980ed6 100644 --- a/boost/network/protocol/http/client/connection/async_resolver.ipp +++ b/boost/network/protocol/http/client/connection/async_resolver.ipp @@ -16,33 +16,16 @@ #include #include #include +#include +#include +#include +#include +#include namespace boost { namespace network { namespace http { - -async_resolver::async_resolver(asio::io_service & service) -: pimpl(new (std::nothrow) async_resolver_pimpl(service)) -{} - -void async_resolver::resolve(std::string const & host, - uint16_t port, - resolve_completion_function once_resolved) { - BOOST_ASSERT(pimpl.get() && "Uninitialized pimpl, probably ran out of memory."); - pimpl->resolve(host, port, once_resolved); -} - -void async_resolver::clear_resolved_cache() { - BOOST_ASSERT(pimpl.get() && "Uninitialized pimpl, probably ran out of memory."); - pimpl->clear_resolved_cache(); -} - -async_resolver::~async_resolver() { - // Do nothing -} - -// Define the actual implementation in a private implementation class. - struct async_resolver_pimpl : enable_shared_from_this { - explicit async_resolver_pimpl(asio::io_service & service); + typedef resolver_delegate::resolve_completion_function resolve_completion_function; + async_resolver_pimpl(asio::io_service & service, bool cache_resolved); void resolve(std::string const & host, uint16_t port, resolve_completion_function once_resolved); @@ -56,20 +39,30 @@ struct async_resolver_pimpl : enable_shared_from_this { endpoint_cache; endpoint_cache endpoint_cache_; scoped_ptr resolver_strand_; + + void handle_resolve(std::string const & host, + resolve_completion_function once_resolved, + system::error_code const & ec, + resolver_iterator endpoint_iterator); }; -async_resolver_pimpl::async_resolver_pimpl(asio::io_service & service) +async_resolver_pimpl::async_resolver_pimpl(asio::io_service & service, bool cache_resolved) : resolver_(service), - cache_resolved(cache_resolved), + cache_resolved_(cache_resolved), endpoint_cache_(), resolver_strand_(new(std::nothrow) asio::io_service::strand(service)) { // Do nothing } +void async_resolver_pimpl::clear_resolved_cache() { + if (cache_resolved_) + endpoint_cache().swap(endpoint_cache_); +} + void async_resolver_pimpl::resolve(std::string const & host, - boost::uint16_t port, - resolve_completion_function once_resolved) { + boost::uint16_t port, + resolve_completion_function once_resolved) { if (!resolver_strand_.get()) BOOST_THROW_EXCEPTION(std::runtime_error( "Uninitialized resolver strand, ran out of memory.")); @@ -98,10 +91,10 @@ void async_resolver_pimpl::resolve(std::string const & host, boost::asio::placeholders::iterator))); } -void handle_resolve(std::string const & host, - resolve_completion_function once_resolved, - boost::system::error_code const & ec, - resolver_iterator endpoint_iterator) { +void async_resolver_pimpl::handle_resolve(std::string const & host, + resolve_completion_function once_resolved, + boost::system::error_code const & ec, + resolver_iterator endpoint_iterator) { endpoint_cache::iterator iter; bool inserted = false; if (!ec && cache_resolved_) { @@ -116,6 +109,26 @@ void handle_resolve(std::string const & host, } } +async_resolver::async_resolver(asio::io_service & service, bool cache_resolved) +: pimpl(new (std::nothrow) async_resolver_pimpl(service, cache_resolved)) +{} + +void async_resolver::resolve(std::string const & host, + uint16_t port, + resolve_completion_function once_resolved) { + BOOST_ASSERT(pimpl.get() && "Uninitialized pimpl, probably ran out of memory."); + pimpl->resolve(host, port, once_resolved); +} + +void async_resolver::clear_resolved_cache() { + BOOST_ASSERT(pimpl.get() && "Uninitialized pimpl, probably ran out of memory."); + pimpl->clear_resolved_cache(); +} + +async_resolver::~async_resolver() { + // Do nothing +} + } /* http */ } /* network */ diff --git a/boost/network/protocol/http/client/connection/connection_delegate_factory.ipp b/boost/network/protocol/http/client/connection/connection_delegate_factory.ipp index 4ac901457..64133e001 100644 --- a/boost/network/protocol/http/client/connection/connection_delegate_factory.ipp +++ b/boost/network/protocol/http/client/connection/connection_delegate_factory.ipp @@ -39,6 +39,8 @@ connection_delegate_factory::create_connection_delegate( return delegate; } +connection_delegate_factory::~connection_delegate_factory() {} + } /* http */ } /* network */ diff --git a/boost/network/protocol/http/client/connection/connection_factory.ipp b/boost/network/protocol/http/client/connection/connection_factory.ipp new file mode 100644 index 000000000..fb8004dcd --- /dev/null +++ b/boost/network/protocol/http/client/connection/connection_factory.ipp @@ -0,0 +1,22 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_FACTORY_IPP_20111126 +#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_FACTORY_IPP_20111126 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include + +namespace boost { namespace network { namespace http { + +connection_factory::~connection_factory() {} + +} // namespace http + +} // namespace network + +} // namespace boost + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_FACTORY_IPP_20111126 diff --git a/boost/network/protocol/http/client/connection/resolver_delegate_factory.hpp b/boost/network/protocol/http/client/connection/resolver_delegate_factory.hpp index 4d8597819..3c21fa8d2 100644 --- a/boost/network/protocol/http/client/connection/resolver_delegate_factory.hpp +++ b/boost/network/protocol/http/client/connection/resolver_delegate_factory.hpp @@ -17,7 +17,7 @@ struct resolver_delegate_factory { resolver_delegate_factory(); virtual shared_ptr create_resolver_delegate( asio::io_service & service, - request_base const & request); + bool cache_resolved); virtual ~resolver_delegate_factory(); private: resolver_delegate_factory(resolver_delegate_factory const &); // = delete diff --git a/boost/network/protocol/http/client/connection/resolver_delegate_factory.ipp b/boost/network/protocol/http/client/connection/resolver_delegate_factory.ipp index c74377258..ee3df204f 100644 --- a/boost/network/protocol/http/client/connection/resolver_delegate_factory.ipp +++ b/boost/network/protocol/http/client/connection/resolver_delegate_factory.ipp @@ -16,8 +16,9 @@ resolver_delegate_factory::resolver_delegate_factory() {} shared_ptr resolver_delegate_factory::create_resolver_delegate(asio::io_service & service, - request_base const & request) { - shared_ptr resolver_(new (std::nothrow) async_resolver(service)); + bool cache_resolved) { + shared_ptr resolver_( + new (std::nothrow) async_resolver(service, cache_resolved)); return resolver_; } diff --git a/boost/network/protocol/http/client/connection/simple_connection_factory.ipp b/boost/network/protocol/http/client/connection/simple_connection_factory.ipp index 17fcced83..41eeea9ba 100644 --- a/boost/network/protocol/http/client/connection/simple_connection_factory.ipp +++ b/boost/network/protocol/http/client/connection/simple_connection_factory.ipp @@ -32,7 +32,7 @@ struct simple_connection_factory_pimpl { bool https = to_lower_copy(scheme(uri_)) == "https"; shared_ptr conn_; conn_.reset(new (std::nothrow) http_async_connection( - res_delegate_factory_->create_resolver_delegate(service, request), + res_delegate_factory_->create_resolver_delegate(service, cache_resolved), conn_delegate_factory_->create_connection_delegate( service, https, openssl_certificate, openssl_verify_path), service, diff --git a/libs/network/src/CMakeLists.txt b/libs/network/src/CMakeLists.txt index 71a8ae918..293fa90d8 100644 --- a/libs/network/src/CMakeLists.txt +++ b/libs/network/src/CMakeLists.txt @@ -33,7 +33,11 @@ set(CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS http/simple_connection_manager.cpp http/simple_connection_factory.cpp http/connection_delegate_factory.cpp - http/client_resolver_delegate_factory.cpp) + http/client_resolver_delegate.cpp + http/client_resolver_delegate_factory.cpp + http/client_connection_delegates.cpp + http/client_connection_factory.cpp + http/client_async_resolver.cpp) add_library(cppnetlib-http-client-connections ${CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS}) set(CPP-NETLIB_HTTP_CLIENT_SRCS diff --git a/libs/network/src/http/client_async_resolver.cpp b/libs/network/src/http/client_async_resolver.cpp new file mode 100644 index 000000000..19ee682cd --- /dev/null +++ b/libs/network/src/http/client_async_resolver.cpp @@ -0,0 +1,11 @@ +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#ifdef BOOST_NETWORK_NO_LIB +#undef BOOST_NETWORK_NO_LIB +#endif + +#include diff --git a/libs/network/src/http/client_connection_delegates.cpp b/libs/network/src/http/client_connection_delegates.cpp new file mode 100644 index 000000000..f596f841f --- /dev/null +++ b/libs/network/src/http/client_connection_delegates.cpp @@ -0,0 +1,14 @@ +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#ifdef BOOST_NETWORK_NO_LIB +#undef BOOST_NETWORK_NO_LIB +#endif + +#include +#ifdef BOOST_NETWORK_ENABLE_HTTPS +#include +#endif diff --git a/libs/network/src/http/client_connection_factory.cpp b/libs/network/src/http/client_connection_factory.cpp new file mode 100644 index 000000000..63f23e681 --- /dev/null +++ b/libs/network/src/http/client_connection_factory.cpp @@ -0,0 +1,11 @@ +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#ifdef BOOST_NETWORK_NO_LIB +#undef BOOST_NETWORK_NO_LIB +#endif + +#include diff --git a/libs/network/src/http/client_resolver_delegate.cpp b/libs/network/src/http/client_resolver_delegate.cpp new file mode 100644 index 000000000..04b0bdd08 --- /dev/null +++ b/libs/network/src/http/client_resolver_delegate.cpp @@ -0,0 +1,11 @@ +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#ifdef BOOST_NETWORK_NO_LIB +#undef BOOST_NETWORK_NO_LIB +#endif + +#include From 7d932bfd0d81d4cac072245d8ced0053c1e1a7b4 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Mon, 28 Nov 2011 23:19:14 +1100 Subject: [PATCH 031/196] Updating client connection interfaces; some refactoring. --- .../http/client/client_connection.hpp | 1 + .../http/client/client_connection.ipp | 9 +- .../http/client/connection/async_normal.hpp | 8 +- .../http/client/connection/async_normal.ipp | 94 +++++++++++-------- 4 files changed, 66 insertions(+), 46 deletions(-) diff --git a/boost/network/protocol/http/client/client_connection.hpp b/boost/network/protocol/http/client/client_connection.hpp index 10556d14d..a6302ad4d 100644 --- a/boost/network/protocol/http/client/client_connection.hpp +++ b/boost/network/protocol/http/client/client_connection.hpp @@ -23,6 +23,7 @@ struct client_connection { request_base const & request, bool get_body, callback_type callback) = 0; + virtual client_connection * clone() const = 0; virtual void reset() = 0; virtual ~client_connection() = 0; }; diff --git a/boost/network/protocol/http/client/client_connection.ipp b/boost/network/protocol/http/client/client_connection.ipp index 989ad213b..ef0e147d2 100644 --- a/boost/network/protocol/http/client/client_connection.ipp +++ b/boost/network/protocol/http/client/client_connection.ipp @@ -8,11 +8,18 @@ // http://www.boost.org/LICENSE_1_0.txt) #include +#include namespace boost { namespace network { namespace http { client_connection::~client_connection() { - // default implementation, for linkage only. + // For exposition only. + BOOST_ASSERT(false && "This should not ever be called."); +} + +client_connection * client_connection::clone() const { + // For exposition only. + BOOST_ASSERT(false && "This should not ever be called."); } diff --git a/boost/network/protocol/http/client/connection/async_normal.hpp b/boost/network/protocol/http/client/connection/async_normal.hpp index c31edba68..53e06bd81 100644 --- a/boost/network/protocol/http/client/connection/async_normal.hpp +++ b/boost/network/protocol/http/client/connection/async_normal.hpp @@ -19,14 +19,14 @@ namespace boost { namespace network { namespace http { struct http_async_connection_pimpl; -struct http_async_connection -: client_connection -, enable_shared_from_this { +struct http_async_connection : client_connection + , enable_shared_from_this { using client_connection::callback_type; http_async_connection(shared_ptr resolver_delegate, shared_ptr connection_delegate, asio::io_service & io_service, bool follow_redirects); + http_async_connection * clone() const; virtual response send_request(std::string const & method, request_base const & request, bool get_body, @@ -34,7 +34,7 @@ struct http_async_connection virtual void reset(); // override virtual ~http_async_connection(); private: - scoped_ptr pimpl; + shared_ptr pimpl; }; } // namespace http diff --git a/boost/network/protocol/http/client/connection/async_normal.ipp b/boost/network/protocol/http/client/connection/async_normal.ipp index 405e644c4..4d0408f5b 100644 --- a/boost/network/protocol/http/client/connection/async_normal.ipp +++ b/boost/network/protocol/http/client/connection/async_normal.ipp @@ -14,51 +14,50 @@ namespace boost { namespace network { namespace http { namespace placeholders = boost::asio::placeholders; -struct http_async_connection -: client_connection -, boost::enable_shared_from_this +struct http_async_connection_pimpl : boost::enable_shared_from_this { + http_async_connection_pimpl( + resolver_delegate_ptr resolver_delegate, + asio::io_service & io_service, + bool follow_redirect, + connection_delegate_ptr delegate) + : + follow_redirect_(follow_redirect), + request_strand_(io_service), + resolver_delegate_(resolver_delegate), + delegate_(delegate) {} - http_async_connection(resolver_delegate_ptr resolver_delegate, - asio::io_service & io_service, - bool follow_redirect, - connection_delegate_ptr delegate) - : - follow_redirect_(follow_redirect), - request_strand_(io_service), - resolver_delegate_(resolver_delegate), - delegate_(delegate) {} - - // This is the main entry point for the connection/request pipeline. We're - // overriding async_connection_base<...>::start(...) here which is called - // by the client. - virtual response start(request const & request, - string_type const & method, - bool get_body, - body_callback_function_type callback) { - response response_; - this->init_response(response_, get_body); - linearize(request, method, version_major, version_minor, - std::ostreambuf_iterator::type>(&command_streambuf)); - this->method = method; - boost::uint16_t port_ = port(request); - resolver_delegate_->resolve(host(request), - port_, - request_strand_.wrap( - boost::bind( - &this_type::handle_resolved, - this_type::shared_from_this(), - port_, - get_body, - callback, - _1, - _2))); - return response_; - } + // This is the main entry point for the connection/request pipeline. We're + // overriding async_connection_base<...>::start(...) here which is called + // by the client. + response start(request const & request, + string_type const & method, + bool get_body, + body_callback_function_type callback) { + response response_; + this->init_response(response_, get_body); + linearize(request, method, version_major, version_minor, + std::ostreambuf_iterator::type>(&command_streambuf)); + this->method = method; + boost::uint16_t port_ = port(request); + resolver_delegate_->resolve( + host(request), + port_, + request_strand_.wrap( + boost::bind( + &this_type::handle_resolved, + this_type::shared_from_this(), + port_, + get_body, + callback, + _1, + _2))); + return response_; + } -private: + private: - http_async_connection(http_async_connection const &); // = delete + http_async_connection_pimpl(http_async_connection_pimpl const &); // = delete void set_errors(boost::system::error_code const & ec) { boost::system::system_error error(ec); @@ -385,6 +384,19 @@ private: string_type method; }; +// END OF PIMPL DEFINITION + +http_async_connection::http_async_connection(shared_ptr resolver_delegate, + shared_ptr connection_delegate, + asio::io_service & io_service, + bool follow_redirects) +: pimpl(new (std::nothrow) http_async_connection_pimpl(resolver_delegate, + connection_delegate, + io_service, + follow_redirects)) +{} + +http_async_connection::http } /* http */ From 6a6875ab271e91ec99496c10cc10bdaec91a997b Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Mon, 28 Nov 2011 23:39:43 +1100 Subject: [PATCH 032/196] Mine Tripped: http::request and http::response. The thing I've been delaying for a long time already is something I now have to face. The good part about this is that there are concept requirements that I can use to keep the interface and semantics from changing. Unfortunately this also means that I need to come up with a working http::request and http::response implementation that *does the right thing* now that it's necessary. The http::http_async_normal_connection is undergoing a lot of changes especially now that the details of how the message stores the data has been abstracted out of the client. It used to be that the wiring of the promise objects and the future objects were evident in the http_async_connection implementation and the http::response objects. That was bad design and now we're going all good OOP with this implementation, which means we're going to have to hide these in the http::response implementation. This is yet another black hole I'm going to disappear in as I wire in an efficient non-std::string storage mechanism for efficient small and large payload processing in the http::response objects. The same goes for supporting streams in the http::request objects. Hang on tight, from here on out there will be a lot of changes that will pertain to the http::request and http::response implementations that may not be for the faint at heart. Cheers --- .../http/client/connection/async_normal.hpp | 1 + .../http/client/connection/async_normal.ipp | 82 ++++++++++--------- libs/network/src/CMakeLists.txt | 3 +- .../src/http/client_connection_normal.cpp | 11 +++ 4 files changed, 58 insertions(+), 39 deletions(-) create mode 100644 libs/network/src/http/client_connection_normal.cpp diff --git a/boost/network/protocol/http/client/connection/async_normal.hpp b/boost/network/protocol/http/client/connection/async_normal.hpp index 53e06bd81..c4fc08e86 100644 --- a/boost/network/protocol/http/client/connection/async_normal.hpp +++ b/boost/network/protocol/http/client/connection/async_normal.hpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include diff --git a/boost/network/protocol/http/client/connection/async_normal.ipp b/boost/network/protocol/http/client/connection/async_normal.ipp index 4d0408f5b..5f5ad5077 100644 --- a/boost/network/protocol/http/client/connection/async_normal.ipp +++ b/boost/network/protocol/http/client/connection/async_normal.ipp @@ -9,6 +9,8 @@ #include #include +#include +#include namespace boost { namespace network { namespace http { @@ -16,28 +18,31 @@ namespace placeholders = boost::asio::placeholders; struct http_async_connection_pimpl : boost::enable_shared_from_this { + typedef http_async_connection::callback_type body_callback_function_type; + typedef resolver_delegate::resolver_iterator resolver_iterator; + typedef resolver_delegate::iterator_pair resolver_iterator_pair; + http_async_connection_pimpl( - resolver_delegate_ptr resolver_delegate, + shared_ptr resolver_delegate, + shared_ptr connection_delegate, asio::io_service & io_service, - bool follow_redirect, - connection_delegate_ptr delegate) + bool follow_redirect) : follow_redirect_(follow_redirect), request_strand_(io_service), resolver_delegate_(resolver_delegate), - delegate_(delegate) {} + connection_delegate_(connection_delegate) {} // This is the main entry point for the connection/request pipeline. We're // overriding async_connection_base<...>::start(...) here which is called // by the client. response start(request const & request, - string_type const & method, + std::string const & method, bool get_body, body_callback_function_type callback) { response response_; - this->init_response(response_, get_body); - linearize(request, method, version_major, version_minor, - std::ostreambuf_iterator::type>(&command_streambuf)); + linearize(request, method, 1, 1, + std::ostreambuf_iterator(&command_streambuf)); this->method = method; boost::uint16_t port_ = port(request); resolver_delegate_->resolve( @@ -61,13 +66,14 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisversion_promise.set_exception(boost::copy_exception(error)); - this->status_promise.set_exception(boost::copy_exception(error)); - this->status_message_promise.set_exception(boost::copy_exception(error)); - this->headers_promise.set_exception(boost::copy_exception(error)); - this->source_promise.set_exception(boost::copy_exception(error)); - this->destination_promise.set_exception(boost::copy_exception(error)); - this->body_promise.set_exception(boost::copy_exception(error)); + // FIXME: Wire up the response object for errors. +// this->version_promise.set_exception(boost::copy_exception(error)); +// this->status_promise.set_exception(boost::copy_exception(error)); +// this->status_message_promise.set_exception(boost::copy_exception(error)); +// this->headers_promise.set_exception(boost::copy_exception(error)); +// this->source_promise.set_exception(boost::copy_exception(error)); +// this->destination_promise.set_exception(boost::copy_exception(error)); +// this->body_promise.set_exception(boost::copy_exception(error)); } void handle_resolved(boost::uint16_t port, @@ -80,7 +86,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisendpoint().address(), port); - delegate_->connect(endpoint, + connection_delegate_->connect(endpoint, request_strand_.wrap( boost::bind( &this_type::handle_connected, @@ -102,8 +108,8 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thiswrite(command_streambuf, + BOOST_ASSERT(connection_delegate_.get() != 0); + connection_delegate_->write(command_streambuf, request_strand_.wrap( boost::bind( &this_type::handle_sent_request, @@ -116,7 +122,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisendpoint().address(), port); - delegate_->connect(endpoint, + connection_delegate_->connect(endpoint, request_strand_.wrap( boost::bind( &this_type::handle_connected, @@ -142,7 +148,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisread_some( + connection_delegate_->read_some( boost::asio::mutable_buffers_1(this->part.c_array(), this->part.size()), request_strand_.wrap( @@ -163,7 +169,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisparse_version(delegate_, + this->parse_version(connection_delegate_, request_strand_.wrap( boost::bind( &this_type::handle_received_data, @@ -175,7 +181,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisparse_status(delegate_, + this->parse_status(connection_delegate_, request_strand_.wrap( boost::bind( &this_type::handle_received_data, @@ -187,7 +193,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisparse_status_message(delegate_, + this->parse_status_message(connection_delegate_, request_strand_.wrap( boost::bind( &this_type::handle_received_data, @@ -205,7 +211,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisparse_headers(delegate_, + this->parse_headers(connection_delegate_, request_strand_.wrap( boost::bind( &this_type::handle_received_data, @@ -251,7 +257,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisread_some( + connection_delegate_->read_some( boost::asio::mutable_buffers_1(this->part.c_array(), this->part.size()), request_strand_.wrap( @@ -266,7 +272,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisparse_body( - delegate_, + connection_delegate_, request_strand_.wrap( boost::bind( &this_type::handle_received_data, @@ -295,7 +301,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thispartial_parsed); body_string.append( this->part.begin() @@ -319,7 +325,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisread_some( + connection_delegate_->read_some( boost::asio::mutable_buffers_1( this->part.c_array(), this->part.size()), @@ -337,7 +343,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisparse_body(delegate_, + this->parse_body(connection_delegate_, request_strand_.wrap( boost::bind( &this_type::handle_received_data, @@ -360,16 +366,16 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisdestination_promise.set_exception(boost::copy_exception(error)); switch (state) { case version: - this->version_promise.set_exception(boost::copy_exception(error)); +// this->version_promise.set_exception(boost::copy_exception(error)); case status: - this->status_promise.set_exception(boost::copy_exception(error)); +// this->status_promise.set_exception(boost::copy_exception(error)); case status_message: - this->status_message_promise.set_exception(boost::copy_exception(error)); +// this->status_message_promise.set_exception(boost::copy_exception(error)); case headers: - this->headers_promise.set_exception(boost::copy_exception(error)); +// this->headers_promise.set_exception(boost::copy_exception(error)); case body: - this->body_promise.set_exception(boost::copy_exception(error)); - break; +// this->body_promise.set_exception(boost::copy_exception(error)); +// break; default: BOOST_ASSERT(false && "Bug, report this to the developers!"); } @@ -378,10 +384,10 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this resolver_delegate_; + shared_ptr connection_delegate_; boost::asio::streambuf command_streambuf; - string_type method; + std::string method; }; // END OF PIMPL DEFINITION diff --git a/libs/network/src/CMakeLists.txt b/libs/network/src/CMakeLists.txt index 293fa90d8..a231213e9 100644 --- a/libs/network/src/CMakeLists.txt +++ b/libs/network/src/CMakeLists.txt @@ -37,7 +37,8 @@ set(CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS http/client_resolver_delegate_factory.cpp http/client_connection_delegates.cpp http/client_connection_factory.cpp - http/client_async_resolver.cpp) + http/client_async_resolver.cpp + http/client_connection_normal.cpp) add_library(cppnetlib-http-client-connections ${CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS}) set(CPP-NETLIB_HTTP_CLIENT_SRCS diff --git a/libs/network/src/http/client_connection_normal.cpp b/libs/network/src/http/client_connection_normal.cpp new file mode 100644 index 000000000..48b8ac7c4 --- /dev/null +++ b/libs/network/src/http/client_connection_normal.cpp @@ -0,0 +1,11 @@ +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#ifdef BOOST_NETWORK_NO_LIB +#undef BOOST_NETWORK_NO_LIB +#endif + +#include From a573a4cc9491083045debe8b54ef853fe391b218 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Thu, 1 Dec 2011 17:37:43 +1100 Subject: [PATCH 033/196] Updating the Concepts. Due to the changes in the interfaces and removal for the requirement of static tag-based dispatch, the concepts had to be updated to reflect the now minimal requirements. This applies to the Message concept and the ClientRequest and ServerRequest concepts. For the same reason the modifiers for HTTP messages had to be updated to reflect the interface. Same goes for the wrappers that deal specifically with HTTP request objects. The steps taken here will allow for more forward progress in making the library more modular. Extension at a later time may require membership in the hierarchy but this should make it more familiar using OOP techniques. If it proves useful the wrappers, modifiers, and directives can be written in a generic approach -- the meat though of the message types would benefit from having a dynamic implementation for preserving binary compatibility. --- boost/network/message/message_concept.hpp | 17 ++++--- boost/network/message/modifiers.hpp | 17 +++++++ .../http/client/connection/async_resolver.ipp | 1 + .../connection/simple_connection_factory.ipp | 1 + .../http/client/simple_connection_manager.ipp | 4 +- .../protocol/http/message/directives.hpp | 16 +++++++ .../protocol/http/message/modifiers.hpp | 16 +++++++ .../protocol/http/message/modifiers/uri.hpp | 15 ++++--- .../protocol/http/message/wrappers.hpp | 24 ++++++++++ .../protocol/http/message/wrappers/anchor.hpp | 35 ++++++--------- .../protocol/http/message/wrappers/host.hpp | 41 ++++++----------- .../protocol/http/message/wrappers/path.hpp | 41 ++++++----------- .../protocol/http/message/wrappers/port.hpp | 45 ++++++------------- .../http/message/wrappers/protocol.hpp | 35 ++++++--------- .../protocol/http/message/wrappers/query.hpp | 42 ++++++----------- .../protocol/http/message/wrappers/uri.hpp | 12 ++--- .../network/protocol/http/request/request.hpp | 24 ++++++++++ .../protocol/http/request/request_concept.hpp | 39 +++++++--------- 18 files changed, 222 insertions(+), 203 deletions(-) create mode 100644 boost/network/message/modifiers.hpp create mode 100644 boost/network/protocol/http/message/directives.hpp create mode 100644 boost/network/protocol/http/message/modifiers.hpp create mode 100644 boost/network/protocol/http/message/wrappers.hpp diff --git a/boost/network/message/message_concept.hpp b/boost/network/message/message_concept.hpp index 2016c806f..d3731f3e1 100644 --- a/boost/network/message/message_concept.hpp +++ b/boost/network/message/message_concept.hpp @@ -13,14 +13,13 @@ #include #include #include +#include namespace boost { namespace network { template struct Message : DefaultConstructible, CopyConstructible, Assignable { - typedef typename M::string_type string_type; - typedef typename M::headers_container_type headers_container_type; BOOST_CONCEPT_USAGE(Message) { M message_; @@ -31,18 +30,18 @@ namespace boost { namespace network { typedef std::string header_key_type; typedef std::string header_value_type; - headers_container_type headers_ = headers(message); - string_type body_ = body(message); - string_type source_ = source(message); - string_type destination_ = destination(message); + std::multimap headers_ = headers(message); + std::string body_ = body(message); + std::string source_ = source(message); + std::string destination_ = destination(message); message << source(source_type()) << destination(destination_type()) - << header(string_type(), string_type()) + << header(std::string(), std::string()) << body(body_type()); - add_header(message, string_type(), string_type()); - remove_header(message, string_type()); + add_header(message, std::string(), std::string()); + remove_header(message, std::string()); clear_headers(message); source(message, source_type()); destination(message, destination_type()); diff --git a/boost/network/message/modifiers.hpp b/boost/network/message/modifiers.hpp new file mode 100644 index 000000000..95e998044 --- /dev/null +++ b/boost/network/message/modifiers.hpp @@ -0,0 +1,17 @@ +#ifndef BOOST_NETWORK_MESSAGE_MODIFIERS_HPP_20111201 +#define BOOST_NETWORK_MESSAGE_MODIFIERS_HPP_20111201 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include +#include +#include +#include +#include +#include + +#endif // BOOST_NETWORK_MESSAGE_MODIFIERS_HPP_20111201 diff --git a/boost/network/protocol/http/client/connection/async_resolver.ipp b/boost/network/protocol/http/client/connection/async_resolver.ipp index 90d980ed6..e5dad6151 100644 --- a/boost/network/protocol/http/client/connection/async_resolver.ipp +++ b/boost/network/protocol/http/client/connection/async_resolver.ipp @@ -20,6 +20,7 @@ #include #include #include +#include #include namespace boost { namespace network { namespace http { diff --git a/boost/network/protocol/http/client/connection/simple_connection_factory.ipp b/boost/network/protocol/http/client/connection/simple_connection_factory.ipp index 41eeea9ba..f271e6e1b 100644 --- a/boost/network/protocol/http/client/connection/simple_connection_factory.ipp +++ b/boost/network/protocol/http/client/connection/simple_connection_factory.ipp @@ -37,6 +37,7 @@ struct simple_connection_factory_pimpl { service, https, openssl_certificate, openssl_verify_path), service, follow_redirects)); + return conn_; } private: diff --git a/boost/network/protocol/http/client/simple_connection_manager.ipp b/boost/network/protocol/http/client/simple_connection_manager.ipp index e8042c374..8f65b215d 100644 --- a/boost/network/protocol/http/client/simple_connection_manager.ipp +++ b/boost/network/protocol/http/client/simple_connection_manager.ipp @@ -17,7 +17,7 @@ struct simple_connection_manager_pimpl { optional openssl_certificate, optional openssl_verify_path, shared_ptr connection_factory) - : cache_resolved_(cache_resolved_) + : cache_resolved_(cache_resolved) , follow_redirects_(follow_redirects) , openssl_certificate_(openssl_certificate) , openssl_verify_path_(openssl_verify_path) @@ -29,7 +29,7 @@ struct simple_connection_manager_pimpl { std::string const & openssl_certificate, std::string const & openssl_verify_path, shared_ptr connection_factory) - : cache_resolved_(cache_resolved_) + : cache_resolved_(cache_resolved) , follow_redirects_(follow_redirects) , openssl_certificate_(openssl_certificate) , openssl_verify_path_(openssl_verify_path) diff --git a/boost/network/protocol/http/message/directives.hpp b/boost/network/protocol/http/message/directives.hpp new file mode 100644 index 000000000..a923e716f --- /dev/null +++ b/boost/network/protocol/http/message/directives.hpp @@ -0,0 +1,16 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_HPP_20111201 +#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_HPP_20111201 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include +#include +#include +#include +#include + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_HPP_20111201 diff --git a/boost/network/protocol/http/message/modifiers.hpp b/boost/network/protocol/http/message/modifiers.hpp new file mode 100644 index 000000000..e14a3ff0a --- /dev/null +++ b/boost/network/protocol/http/message/modifiers.hpp @@ -0,0 +1,16 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_HPP_20111201 +#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_HPP_20111201 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include +#include +#include +#include +#include + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_HPP_20111201 diff --git a/boost/network/protocol/http/message/modifiers/uri.hpp b/boost/network/protocol/http/message/modifiers/uri.hpp index e96525df5..298ffb4fa 100644 --- a/boost/network/protocol/http/message/modifiers/uri.hpp +++ b/boost/network/protocol/http/message/modifiers/uri.hpp @@ -3,21 +3,22 @@ // Copyright 2010 (c) Dean Michael Berris // Copyright 2010 (c) Sinefunc, Inc. +// Copyright 2011 Google, Inc. // 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) -#include +#include namespace boost { namespace network { namespace http { - template - struct basic_request; +inline void uri(request_base & request, std::string const & value) { + request.set_uri(value); +} - template - void uri(basic_request & request, T const & value) { - request.uri(value); - } +inline void uri(request_base & request, uri::uri const & value) { + request.set_uri(value); +} } // namespace http diff --git a/boost/network/protocol/http/message/wrappers.hpp b/boost/network/protocol/http/message/wrappers.hpp new file mode 100644 index 000000000..cc75c9e32 --- /dev/null +++ b/boost/network/protocol/http/message/wrappers.hpp @@ -0,0 +1,24 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_HPP_20111201 +#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_HPP_20111201 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_HPP_20111201 diff --git a/boost/network/protocol/http/message/wrappers/anchor.hpp b/boost/network/protocol/http/message/wrappers/anchor.hpp index 4a6e85f15..7a23b74c5 100644 --- a/boost/network/protocol/http/message/wrappers/anchor.hpp +++ b/boost/network/protocol/http/message/wrappers/anchor.hpp @@ -3,33 +3,26 @@ // Copyright 2010 (c) Dean Michael Berris. // Copyright 2010 (c) Sinefunc, Inc. +// Copyright 2011 Google, Inc. // 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) +#include + namespace boost { namespace network { namespace http { - template - struct basic_request; - - namespace impl { - template - struct anchor_wrapper { - basic_request const & message_; - anchor_wrapper(basic_request const & message) - : message_(message) {} - typedef typename basic_request::string_type string_type; - operator string_type() { - return message_.anchor(); - } - }; - } - - template inline - impl::anchor_wrapper - anchor(basic_request const & request) { - return impl::anchor_wrapper(request); - } +struct anchor_wrapper { + explicit anchor_wrapper(request_base const & request); + operator std::string () const; + private: + request_base const & request_; +}; + +inline anchor_wrapper const +anchor(request_base const & request) { + return anchor_wrapper(request); +} } // namespace http diff --git a/boost/network/protocol/http/message/wrappers/host.hpp b/boost/network/protocol/http/message/wrappers/host.hpp index 876beb352..0b33511d4 100644 --- a/boost/network/protocol/http/message/wrappers/host.hpp +++ b/boost/network/protocol/http/message/wrappers/host.hpp @@ -3,39 +3,26 @@ // Copyright 2010 (c) Dean Michael Berris. // Copyright 2010 (c) Sinefunc, Inc. +// Copyright 2011 Google, Inc. // 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) -namespace boost { namespace network { namespace http { - - template - struct basic_request; - - namespace impl { - - template - struct host_wrapper { - basic_request const & message_; +#include - host_wrapper(basic_request const & message) - : message_(message) {} - - typedef typename basic_request::string_type string_type; - - operator string_type() { - return message_.host(); - } - }; - - } +namespace boost { namespace network { namespace http { - template - inline - impl::host_wrapper - host(basic_request const & request) { - return impl::host_wrapper(request); - } +struct host_wrapper { + explicit host_wrapper(request_base const & request); + operator std::string () const; + private: + request_base const & request_; +}; + +inline host_wrapper const +host(request_base const & request) { + return host_wrapper(request); +} } // namespace http diff --git a/boost/network/protocol/http/message/wrappers/path.hpp b/boost/network/protocol/http/message/wrappers/path.hpp index 818b55c2f..8adfe608d 100644 --- a/boost/network/protocol/http/message/wrappers/path.hpp +++ b/boost/network/protocol/http/message/wrappers/path.hpp @@ -3,39 +3,26 @@ // Copyright 2010 (c) Dean Michael Berris. // Copyright 2010 (c) Sinefunc, Inc. +// Copyright 2011 Google, Inc. // 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) -namespace boost { namespace network { namespace http { - - template - struct basic_request; - - namespace impl { - - template - struct path_wrapper { - basic_request const & message_; +#include - path_wrapper(basic_request const & message) - : message_(message) {} - - typedef typename basic_request::string_type string_type; - - operator string_type() { - return message_.path(); - } - }; - - } +namespace boost { namespace network { namespace http { - template - inline - impl::path_wrapper - path(basic_request const & request) { - return impl::path_wrapper(request); - } +struct path_wrapper { + explicit path_wrapper(request_base const & request); + operator std::string () const; + private: + request_base const & request_; +}; + +inline path_wrapper const +path(request_base const & request) { + return path_wrapper(request); +} } // namespace http diff --git a/boost/network/protocol/http/message/wrappers/port.hpp b/boost/network/protocol/http/message/wrappers/port.hpp index 786ce1e98..b74204da7 100644 --- a/boost/network/protocol/http/message/wrappers/port.hpp +++ b/boost/network/protocol/http/message/wrappers/port.hpp @@ -3,45 +3,28 @@ // Copyright 2010 (c) Dean Michael Berris. // Copyright 2010 (c) Sinefunc, Inc. +// Copyright 2011 Google, Inc. // 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) +#include #include namespace boost { namespace network { namespace http { - template - struct basic_request; - - namespace impl { - - template - struct port_wrapper { - basic_request const & message_; - - port_wrapper(basic_request const & message) - : message_(message) {} - - typedef typename basic_request::port_type port_type; - - operator port_type() { - return message_.port(); - } - - operator boost::optional () { - return uri::port_us(message_.uri()); - } - }; - - } // namespace impl - - template - inline - impl::port_wrapper - port(basic_request const & request) { - return impl::port_wrapper(request); - } +struct port_wrapper { + port_wrapper(request_base const & request); + operator boost::uint16_t () const; + operator boost::optional () const; + private: + request_base const & message_; +}; + +inline port_wrapper const +port(request_base const & request) { + return port_wrapper(request); +} } // namespace http diff --git a/boost/network/protocol/http/message/wrappers/protocol.hpp b/boost/network/protocol/http/message/wrappers/protocol.hpp index bca206c68..0a069fe4a 100644 --- a/boost/network/protocol/http/message/wrappers/protocol.hpp +++ b/boost/network/protocol/http/message/wrappers/protocol.hpp @@ -3,33 +3,26 @@ // Copyright 2010 (c) Dean Michael Berris. // Copyright 2010 (c) Sinefunc, Inc. +// Copyright 2011 Google, Inc. // 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) +#include + namespace boost { namespace network { namespace http { - template - struct basic_request; - - namespace impl { - template - struct protocol_wrapper { - basic_request const & message_; - protocol_wrapper(basic_request const & message) - : message_(message) {} - typedef typename basic_request::string_type string_type; - operator string_type() { - return message_.protocol(); - } - }; - } - - template inline - impl::protocol_wrapper - protocol(basic_request const & request) { - return impl::protocol_wrapper(request); - } +struct protocol_wrapper { + explicit protocol_wrapper(request_base const & request); + operator std::string () const; + private: + request_base const & request_; +}; + +inline protocol_wrapper const +protocol(request_base const & request) { + return protocol_wrapper(request); +} } // namespace http diff --git a/boost/network/protocol/http/message/wrappers/query.hpp b/boost/network/protocol/http/message/wrappers/query.hpp index 594e6720f..d3f04e157 100644 --- a/boost/network/protocol/http/message/wrappers/query.hpp +++ b/boost/network/protocol/http/message/wrappers/query.hpp @@ -3,40 +3,26 @@ // Copyright 2010 (c) Dean Michael Berris. // Copyright 2010 (c) Sinefunc, Inc. +// Copyright 2011 Google, Inc. // 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) -namespace boost { namespace network { namespace http { - - template - struct basic_request; - - namespace impl { - - template - struct query_wrapper { - basic_request const & message_; +#include - query_wrapper(basic_request const & message) - : message_(message) {} - - typedef typename basic_request::string_type string_type; - - operator string_type () { - return message_.query(); - } - - }; - - } // namespace impl +namespace boost { namespace network { namespace http { - template - inline - impl::query_wrapper - query(basic_request const & request) { - return impl::query_wrapper(request); - } +struct query_wrapper { + explicit query_wrapper(request_base const & request); + operator std::string () const; + private: + request_base const & request_; +}; + +inline query_wrapper const +query(request_base const & request) { + return query_wrapper(request); +} } // namespace http diff --git a/boost/network/protocol/http/message/wrappers/uri.hpp b/boost/network/protocol/http/message/wrappers/uri.hpp index 505ebc078..191bbf9af 100644 --- a/boost/network/protocol/http/message/wrappers/uri.hpp +++ b/boost/network/protocol/http/message/wrappers/uri.hpp @@ -12,22 +12,18 @@ namespace boost { namespace network { namespace http { -namespace impl { - struct uri_wrapper { - explicit uri_wrapper(request_base & request_); + explicit uri_wrapper(request_base const & request_); operator std::string() const; operator boost::network::uri::uri() const; private: request_base & request_; }; -} // namespace impl - inline -impl::uri_wrapper -uri(request_base & request) { - return impl::uri_wrapper(request); +uri_wrapper const +uri(request_base const & request) { + return uri_wrapper(request); } } // namespace http diff --git a/boost/network/protocol/http/request/request.hpp b/boost/network/protocol/http/request/request.hpp index eb01a25d9..549aefeca 100644 --- a/boost/network/protocol/http/request/request.hpp +++ b/boost/network/protocol/http/request/request.hpp @@ -8,6 +8,8 @@ // http://www.boost.org/LICENSE_1_0.txt) #include +#include +#include namespace boost { namespace network { namespace http { @@ -16,6 +18,14 @@ struct request_pimpl; struct request : request_base { // FIXME Implement all these! + // We support full value semantics. + request(); + explicit request(std::string url); + explicit request(uri::uri url); + request(request const &); + request& operator=(request); + void swap(request & other); + // From message_base... // Mutators virtual void set_destination(std::string const & destination); @@ -65,6 +75,10 @@ request_base & operator<< (request_base & request, return request; } +inline void swap(request &l, request &r) { + l.swap(r); +} + } // namespace http } // namespace network @@ -75,5 +89,15 @@ request_base & operator<< (request_base & request, #include #endif +#include +#include +#include +#include +#include +#include + +#ifdef BOOST_NETWORK_DEBUG +BOOST_CONCEPT_ASSERT((boost::network::http::ClientRequest)); +#endif #endif /* BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_REQUEST_HPP_20111021 */ diff --git a/boost/network/protocol/http/request/request_concept.hpp b/boost/network/protocol/http/request/request_concept.hpp index 5b0ee99eb..e868b3a31 100644 --- a/boost/network/protocol/http/request/request_concept.hpp +++ b/boost/network/protocol/http/request/request_concept.hpp @@ -12,21 +12,19 @@ #include #include #include +#include +#include namespace boost { namespace network { namespace http { template struct ServerRequest { - typedef typename R::string_type string_type; - typedef typename R::tag tag; - typedef typename R::headers_container_type headers_container_type; - BOOST_CONCEPT_USAGE(ServerRequest) { - string_type source_, method_, destination_; + std::string source_, method_, destination_; boost::uint8_t major_version_, minor_version_; - headers_container_type headers_; - string_type body_; + std::multimap headers_; + std::string body_; source_ = source(request); method_ = method(request); @@ -42,12 +40,12 @@ namespace boost { namespace network { namespace http { major_version(request, major_version_); minor_version(request, minor_version_); headers(request, headers_); - add_header(request, string_type(), string_type()); - remove_header(request, string_type()); + add_header(request, std::string(), std::string()); + remove_header(request, std::string()); clear_headers(request); body(request, body_); - string_type name, value; + std::string name, value; request << ::boost::network::source(source_) << ::boost::network::destination(destination_) @@ -70,24 +68,21 @@ namespace boost { namespace network { namespace http { struct ClientRequest : boost::network::Message { - typedef typename R::string_type string_type; - typedef typename R::port_type port_type; - BOOST_CONCEPT_USAGE(ClientRequest) { - string_type tmp; + std::string tmp; R request_(tmp); swap(request, request_); // swappable via ADL - string_type host_ = host(request); - port_type port_ = port(request); - string_type path_ = path(request); - string_type query_ = query(request); - string_type anchor_ = anchor(request); - string_type protocol_ = protocol(request); + std::string host_ = host(request); + boost::uint16_t port_ = port(request); + std::string path_ = path(request); + std::string query_ = query(request); + std::string anchor_ = anchor(request); + std::string protocol_ = protocol(request); - request << uri(string_type()); + request << uri(std::string()); - boost::network::http::uri(request, string_type()); + boost::network::http::uri(request, std::string()); (void)host_; (void)port_; From 891c29fd70353095c5e7a920fe8616800571167b Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sat, 3 Dec 2011 01:09:39 +1100 Subject: [PATCH 034/196] HTTP Connections Building. After a few changes to the core body and headers wrappers in the message implementation and the request linearization algorithm (to fix a bug that makes the implementation not rely on the concept constraints) the asynchronous HTTP connection implementation now compiles! The bad news here is that the async_normal implementation still needs to be cleaned up as much of the work here involved moving the protocol_handler implementation into the actual connection implementation. There's still a lot to do here to make the code more readable which may mean just more documentation -- which I will be very happy with as soon as things settle down. This commit also limits the accessibility of the response field setting interface that deals with futures and promises. Along with it is the fix for the incremental parser's mis-handling of the edge case where the range passed to the parse_until function is actually empty. --- boost/network/message/wrappers/body.hpp | 6 +- boost/network/message/wrappers/headers.hpp | 14 +- .../protocol/http/algorithms/linearize.hpp | 42 +- .../http/client/connection/async_normal.ipp | 380 ++++++++++++- .../connection/async_protocol_handler.hpp | 50 +- boost/network/protocol/http/impl/access.hpp | 40 ++ boost/network/protocol/http/impl/access.ipp | 45 ++ .../protocol/http/parser/incremental.hpp | 498 +++++++++--------- .../protocol/http/response/response.hpp | 23 + 9 files changed, 770 insertions(+), 328 deletions(-) create mode 100644 boost/network/protocol/http/impl/access.hpp create mode 100644 boost/network/protocol/http/impl/access.ipp diff --git a/boost/network/message/wrappers/body.hpp b/boost/network/message/wrappers/body.hpp index cf0b37d78..2a76497f9 100644 --- a/boost/network/message/wrappers/body.hpp +++ b/boost/network/message/wrappers/body.hpp @@ -16,14 +16,14 @@ namespace boost { namespace network { namespace impl { struct body_wrapper { - explicit body_wrapper(message_base & message); + explicit body_wrapper(message_base const & message); operator std::string () const; std::size_t size() const; operator iterator_range () const; std::string::const_iterator begin() const; std::string::const_iterator end() const; private: - message_base & message_; + message_base const & message_; mutable optional cache_; }; @@ -35,7 +35,7 @@ inline std::ostream & operator<<(std::ostream & os, body_wrapper const & body) { } // namespace impl inline impl::body_wrapper const -body(message_base & message_) { +body(message_base const & message_) { return impl::body_wrapper(message_); } diff --git a/boost/network/message/wrappers/headers.hpp b/boost/network/message/wrappers/headers.hpp index ba71860eb..a7a44aeae 100644 --- a/boost/network/message/wrappers/headers.hpp +++ b/boost/network/message/wrappers/headers.hpp @@ -15,8 +15,6 @@ namespace boost { namespace network { -namespace impl { - /** headers wrapper for messages. * * This exposes an interface similar to a map, indexable @@ -30,7 +28,7 @@ struct headers_wrapper { typedef shared_container_iterator iterator; typedef iterator_range range_type; - explicit headers_wrapper(message_base & message); + explicit headers_wrapper(message_base const & message); range_type operator[] (std::string const & key) const; operator range_type () const; operator container_type () const; @@ -40,16 +38,14 @@ struct headers_wrapper { iterator end() const; private: void init_cache_all() const; - message_base & message_; + message_base const & message_; mutable shared_ptr cache_; }; -} // namespace impl - /// Factory method to create the right wrapper object -inline impl::headers_wrapper const -headers(message_base & message_) { - return impl::headers_wrapper(message_); +inline headers_wrapper const +headers(message_base const & message_) { + return headers_wrapper(message_); } } // namespace network diff --git a/boost/network/protocol/http/algorithms/linearize.hpp b/boost/network/protocol/http/algorithms/linearize.hpp index f109640b2..6c2a66b66 100644 --- a/boost/network/protocol/http/algorithms/linearize.hpp +++ b/boost/network/protocol/http/algorithms/linearize.hpp @@ -49,7 +49,7 @@ namespace boost { namespace network { namespace http { (OutputIterator) ) linearize( Request const & request, - typename Request::string_type const & method, + std::string const & method, unsigned version_major, unsigned version_minor, OutputIterator oi @@ -64,22 +64,31 @@ namespace boost { namespace network { namespace http { , accept_encoding = consts::accept_encoding() , default_accept_encoding = consts::default_accept_encoding() , crlf = consts::crlf() - , host = consts::host() + , host_const = consts::host() , connection = consts::connection() , close = consts::close() ; boost::copy(method, oi); *oi = consts::space_char(); - if (request.path().empty() || request.path()[0] != consts::slash_char()) - *oi = consts::slash_char(); - boost::copy(request.path(), oi); - if (!request.query().empty()) { - *oi = consts::question_mark_char(); - boost::copy(request.query(), oi); + { + std::string path_ = path(request); + if (path_.empty() || path_[0] != consts::slash_char()) + *oi = consts::slash_char(); + boost::copy(path_, oi); } - if (!request.anchor().empty()) { + { + std::string query_ = query(request); + if (!query_.empty()) { + *oi = consts::question_mark_char(); + boost::copy(query_, oi); + } + } + { + std::string anchor_ = anchor(request); + if (!anchor_.empty()) { *oi = consts::hash_char(); - boost::copy(request.anchor(), oi); + boost::copy(anchor_, oi); + } } *oi = consts::space_char(); boost::copy(http_slash, oi); @@ -89,10 +98,13 @@ namespace boost { namespace network { namespace http { *oi = consts::dot_char(); boost::copy(version_minor_str, oi); boost::copy(crlf, oi); - boost::copy(host, oi); + boost::copy(host_const, oi); *oi = consts::colon_char(); *oi = consts::space_char(); - boost::copy(request.host(), oi); + { + std::string host_ = host(request); + boost::copy(host_, oi); + } boost::optional port_ = port(request); if (port_) { string_type port_str = boost::lexical_cast(*port_); @@ -112,9 +124,9 @@ namespace boost { namespace network { namespace http { boost::copy(default_accept_encoding, oi); boost::copy(crlf, oi); } - typedef boost::iterator_range::const_iterator> headers_range; + typedef headers_wrapper::range_type headers_range; typedef typename range_iterator::type headers_iterator; - headers_range request_headers = headers(request); + headers_range request_headers = boost::network::headers(request); headers_iterator iterator = boost::begin(request_headers), end = boost::end(request_headers); for (; iterator != end; ++iterator) { @@ -128,7 +140,7 @@ namespace boost { namespace network { namespace http { } boost::copy(crlf, oi); boost::iterator_range body_data = - body(request); + boost::network::body(request); return boost::copy(body_data, oi); } diff --git a/boost/network/protocol/http/client/connection/async_normal.ipp b/boost/network/protocol/http/client/connection/async_normal.ipp index 5f5ad5077..e57e8b016 100644 --- a/boost/network/protocol/http/client/connection/async_normal.ipp +++ b/boost/network/protocol/http/client/connection/async_normal.ipp @@ -9,8 +9,11 @@ #include #include +#include #include +#include #include +#include namespace boost { namespace network { namespace http { @@ -21,6 +24,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this resolver_delegate, @@ -41,6 +45,10 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisinit_response(response_); + // Use HTTP/1.1 -- at some point we might want to implement a different + // connection type just for HTTP/1.0. + // TODO: Implement a different connection type and factory for HTTP/1.0. linearize(request, method, 1, 1, std::ostreambuf_iterator(&command_streambuf)); this->method = method; @@ -64,16 +72,26 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thissource_promise = accessor.get_source_promise(r); + this->destination_promise = accessor.get_destination_promise(r); + this->headers_promise = accessor.get_headers_promise(r); + this->body_promise = accessor.get_body_promise(r); + this->version_promise = accessor.get_version_promise(r); + this->status_promise = accessor.get_status_promise(r); + this->status_message_promise = accessor.get_status_message_promise(r); + } + void set_errors(boost::system::error_code const & ec) { boost::system::system_error error(ec); - // FIXME: Wire up the response object for errors. -// this->version_promise.set_exception(boost::copy_exception(error)); -// this->status_promise.set_exception(boost::copy_exception(error)); -// this->status_message_promise.set_exception(boost::copy_exception(error)); -// this->headers_promise.set_exception(boost::copy_exception(error)); -// this->source_promise.set_exception(boost::copy_exception(error)); -// this->destination_promise.set_exception(boost::copy_exception(error)); -// this->body_promise.set_exception(boost::copy_exception(error)); + this->version_promise.set_exception(boost::copy_exception(error)); + this->status_promise.set_exception(boost::copy_exception(error)); + this->status_message_promise.set_exception(boost::copy_exception(error)); + this->headers_promise.set_exception(boost::copy_exception(error)); + this->source_promise.set_exception(boost::copy_exception(error)); + this->destination_promise.set_exception(boost::copy_exception(error)); + this->body_promise.set_exception(boost::copy_exception(error)); } void handle_resolved(boost::uint16_t port, @@ -169,8 +187,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisparse_version(connection_delegate_, - request_strand_.wrap( + this->parse_version(request_strand_.wrap( boost::bind( &this_type::handle_received_data, this_type::shared_from_this(), @@ -181,8 +198,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisparse_status(connection_delegate_, - request_strand_.wrap( + this->parse_status(request_strand_.wrap( boost::bind( &this_type::handle_received_data, this_type::shared_from_this(), @@ -193,7 +209,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisparse_status_message(connection_delegate_, + this->parse_status_message( request_strand_.wrap( boost::bind( &this_type::handle_received_data, @@ -211,7 +227,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisparse_headers(connection_delegate_, + this->parse_headers( request_strand_.wrap( boost::bind( &this_type::handle_received_data, @@ -243,8 +259,8 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thispart_begin; - typename protocol_base::buffer_type::const_iterator end = begin; + buffer_type::const_iterator begin = this->part_begin; + buffer_type::const_iterator end = begin; std::advance(end, remainder); // We're setting the body promise here to an empty string because @@ -272,7 +288,6 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisparse_body( - connection_delegate_, request_strand_.wrap( boost::bind( &this_type::handle_received_data, @@ -291,7 +306,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thispart.begin(), end = begin; std::advance(end, bytes_transferred); @@ -321,8 +336,8 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thispart.begin(); - typename protocol_base::buffer_type::const_iterator end = begin; + buffer_type::const_iterator begin = this->part.begin(); + buffer_type::const_iterator end = begin; std::advance(end, bytes_transferred); callback(make_iterator_range(begin, end), ec); connection_delegate_->read_some( @@ -343,8 +358,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisparse_body(connection_delegate_, - request_strand_.wrap( + this->parse_body(request_strand_.wrap( boost::bind( &this_type::handle_received_data, this_type::shared_from_this(), @@ -382,12 +396,330 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this(input); + string.append(escaped_stream.str()); + } + } else { + string.push_back(input); + } + } + }; +#endif + + struct to_http_headers { + template + std::string const operator() (U const & pair) const { + std::ostringstream header_line; + header_line << pair.first + << constants::colon() + << constants::space() + << pair.second + << constants::crlf(); + return header_line.str(); + } + }; + + logic::tribool parse_version( + function callback, + size_t bytes) { + logic::tribool parsed_ok; + part_begin = part.begin(); + buffer_type::const_iterator part_end = part.begin(); + std::advance(part_end, bytes); + boost::iterator_range + result_range, + input_range = boost::make_iterator_range(part_begin, part_end); + fusion::tie(parsed_ok, result_range) = response_parser_.parse_until( + response_parser::http_version_done, + input_range); + if (parsed_ok == true) { + std::string version; + std::swap(version, partial_parsed); + version.append(boost::begin(result_range), + boost::end(result_range)); + algorithm::trim(version); + version_promise.set_value(version); + part_begin = boost::end(result_range); + } else if (parsed_ok == false) { +#ifdef BOOST_NETWORK_DEBUG + std::string escaped; + debug_escaper escaper(escaped); + std::for_each(part_begin, part_end, escaper); + BOOST_NETWORK_MESSAGE("[parser:" + << response_parser_.state() + << "] buffer contents: \"" + << escaped + << "\""); +#endif + std::runtime_error error("Invalid Version Part."); + version_promise.set_exception(boost::copy_exception(error)); + status_promise.set_exception(boost::copy_exception(error)); + status_message_promise.set_exception( + boost::copy_exception(error)); + headers_promise.set_exception(boost::copy_exception(error)); + source_promise.set_exception(boost::copy_exception(error)); + destination_promise.set_exception(boost::copy_exception(error)); + body_promise.set_exception(boost::copy_exception(error)); + } else { + partial_parsed.append( + boost::begin(result_range), + boost::end(result_range) + ); + part_begin = part.begin(); + connection_delegate_->read_some( + boost::asio::mutable_buffers_1(part.c_array(), part.size()), + callback + ); + } + return parsed_ok; + } + + logic::tribool parse_status( + function callback, + size_t bytes) { + logic::tribool parsed_ok; + buffer_type::const_iterator part_end = part.begin(); + std::advance(part_end, bytes); + boost::iterator_range< buffer_type::const_iterator> + result_range, + input_range = boost::make_iterator_range(part_begin, part_end); + fusion::tie(parsed_ok, result_range) = response_parser_.parse_until( + response_parser::http_status_done, + input_range); + if (parsed_ok == true) { + std::string status; + std::swap(status, partial_parsed); + status.append(boost::begin(result_range), + boost::end(result_range)); + trim(status); + boost::uint16_t status_int = + lexical_cast(status); + status_promise.set_value(status_int); + part_begin = boost::end(result_range); + } else if (parsed_ok == false) { +#ifdef BOOST_NETWORK_DEBUG + std::string escaped; + debug_escaper escaper(escaped); + std::for_each(part_begin, part_end, escaper); + BOOST_NETWORK_MESSAGE("[parser:" + << response_parser_.state() + << "] buffer contents: \"" + << escaped + << "\""); +#endif + std::runtime_error error("Invalid status part."); + status_promise.set_exception(boost::copy_exception(error)); + status_message_promise.set_exception( + boost::copy_exception(error)); + headers_promise.set_exception(boost::copy_exception(error)); + source_promise.set_exception(boost::copy_exception(error)); + destination_promise.set_exception(boost::copy_exception(error)); + body_promise.set_exception(boost::copy_exception(error)); + } else { + partial_parsed.append( + boost::begin(result_range), + boost::end(result_range) + ); + part_begin = part.begin(); + connection_delegate_->read_some( + boost::asio::mutable_buffers_1(part.c_array(), part.size()), + callback + ); + } + return parsed_ok; + } + + logic::tribool parse_status_message( + function callback, + size_t bytes) { + logic::tribool parsed_ok; + buffer_type::const_iterator part_end = part.begin(); + std::advance(part_end, bytes); + boost::iterator_range< buffer_type::const_iterator> + result_range, + input_range = boost::make_iterator_range(part_begin, part_end); + fusion::tie(parsed_ok, result_range) = response_parser_.parse_until( + response_parser::http_status_message_done, + input_range); + if (parsed_ok == true) { + std::string status_message; + std::swap(status_message, partial_parsed); + status_message.append(boost::begin(result_range), + boost::end(result_range)); + algorithm::trim(status_message); + status_message_promise.set_value(status_message); + part_begin = boost::end(result_range); + } else if (parsed_ok == false) { +#ifdef BOOST_NETWORK_DEBUG + std::string escaped; + debug_escaper escaper(escaped); + std::for_each(part_begin, part_end, escaper); + BOOST_NETWORK_MESSAGE("[parser:" + << response_parser_.state() + << "] buffer contents: \"" + << escaped + << "\""); +#endif + std::runtime_error error("Invalid status message part."); + status_message_promise.set_exception( + boost::copy_exception(error)); + headers_promise.set_exception(boost::copy_exception(error)); + source_promise.set_exception(boost::copy_exception(error)); + destination_promise.set_exception(boost::copy_exception(error)); + body_promise.set_exception(boost::copy_exception(error)); + } else { + partial_parsed.append( + boost::begin(result_range), + boost::end(result_range)); + part_begin = part.begin(); + connection_delegate_->read_some( + boost::asio::mutable_buffers_1(part.c_array(), part.size()), + callback + ); + } + return parsed_ok; + } + + void parse_headers_real(std::string & headers_part) { + boost::iterator_range< std::string::const_iterator> + input_range = boost::make_iterator_range(headers_part) + , result_range; + logic::tribool parsed_ok; + response_parser headers_parser( + response_parser::http_header_line_done); + std::multimap headers; + std::pair header_pair; + while (!boost::empty(input_range)) { + fusion::tie(parsed_ok, result_range) = + headers_parser.parse_until( + response_parser::http_header_colon, + input_range); + if (headers_parser.state() + != response_parser::http_header_colon) + break; + header_pair.first = std::string(boost::begin(result_range), + boost::end(result_range)); + input_range.advance_begin(boost::distance(result_range)); + fusion::tie(parsed_ok, result_range) = + headers_parser.parse_until( + response_parser::http_header_line_done, + input_range); + header_pair.second = std::string(boost::begin(result_range), + boost::end(result_range)); + input_range.advance_begin(boost::distance(result_range)); + + trim(header_pair.first); + if (header_pair.first.size() > 1) { + header_pair.first.erase( + header_pair.first.size() - 1 + ); + } + trim(header_pair.second); + headers.insert(header_pair); + } + headers_promise.set_value(headers); + } + + fusion::tuple parse_headers( + function callback, + size_t bytes) { + logic::tribool parsed_ok; + buffer_type::const_iterator part_end = part.begin(); + std::advance(part_end, bytes); + boost::iterator_range + result_range, + input_range = boost::make_iterator_range(part_begin, part_end); + fusion::tie(parsed_ok, result_range) = response_parser_.parse_until( + response_parser::http_headers_done, + input_range); + if (parsed_ok == true) { + std::string headers_string; + std::swap(headers_string, partial_parsed); + headers_string.append(boost::begin(result_range), + boost::end(result_range)); + part_begin = boost::end(result_range); + this->parse_headers_real(headers_string); + } else if (parsed_ok == false) { + // We want to output the contents of the buffer that caused + // the error in debug builds. +#ifdef BOOST_NETWORK_DEBUG + std::string escaped; + debug_escaper escaper(escaped); + std::for_each(part_begin, part_end, escaper); + BOOST_NETWORK_MESSAGE("[parser:" + << response_parser_.state() + << "] buffer contents: \"" + << escaped + << "\" consumed length: " + << boost::distance(result_range)); +#endif + std::runtime_error error("Invalid header part."); + headers_promise.set_exception(boost::copy_exception(error)); + body_promise.set_exception(boost::copy_exception(error)); + source_promise.set_exception(boost::copy_exception(error)); + destination_promise.set_exception(boost::copy_exception(error)); + } else { + partial_parsed.append(boost::begin(result_range), + boost::end(result_range)); + part_begin = part.begin(); + connection_delegate_->read_some( + boost::asio::mutable_buffers_1(part.c_array(), part.size()), + callback + ); + } + return fusion::make_tuple( + parsed_ok, + std::distance( + boost::end(result_range) + , part_end + ) + ); + } + + void parse_body(function callback, size_t bytes) { + // TODO: we should really not use a string for the partial body + // buffer. + partial_parsed.append(part_begin, bytes); + part_begin = part.begin(); + connection_delegate_->read_some( + boost::asio::mutable_buffers_1(part.c_array(), part.size()), + callback + ); + } + bool follow_redirect_; boost::asio::io_service::strand request_strand_; shared_ptr resolver_delegate_; shared_ptr connection_delegate_; boost::asio::streambuf command_streambuf; std::string method; + response_parser response_parser_; + boost::promise version_promise; + boost::promise status_promise; + boost::promise status_message_promise; + boost::promise > headers_promise; + boost::promise source_promise; + boost::promise destination_promise; + boost::promise body_promise; + typedef boost::array buffer_type; + buffer_type part; + buffer_type::const_iterator part_begin; + std::string partial_parsed; }; // END OF PIMPL DEFINITION @@ -402,12 +734,10 @@ http_async_connection::http_async_connection(shared_ptr resol follow_redirects)) {} -http_async_connection::http - } /* http */ } /* network */ } /* boost */ -#endbooif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_NORMAL_IPP_20111123 */ +#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_NORMAL_IPP_20111123 */ diff --git a/boost/network/protocol/http/client/connection/async_protocol_handler.hpp b/boost/network/protocol/http/client/connection/async_protocol_handler.hpp index 6109c4ae2..9f706635b 100644 --- a/boost/network/protocol/http/client/connection/async_protocol_handler.hpp +++ b/boost/network/protocol/http/client/connection/async_protocol_handler.hpp @@ -13,7 +13,6 @@ namespace boost { namespace network { namespace http { namespace impl { - template struct http_async_protocol_handler { protected: @@ -24,7 +23,7 @@ namespace boost { namespace network { namespace http { namespace impl { : string(string_) {} debug_escaper(debug_escaper const & other) : string(other.string) {} - void operator()(typename std::string::value_type input) { + void operator()( std::string::value_type input) { if (!algorithm::is_print()(input)) { std::ostringstream escaped_stream; if (input == '\r') { @@ -42,8 +41,7 @@ namespace boost { namespace network { namespace http { namespace impl { }; #endif - template - void init_response(ResponseType & response_, bool get_body) { + void init_response(response & response_) { boost::shared_future source_future( source_promise.get_future()); source(response_, source_future); @@ -86,13 +84,13 @@ namespace boost { namespace network { namespace http { namespace impl { size_t bytes) { logic::tribool parsed_ok; part_begin = part.begin(); - typename buffer_type::const_iterator part_end = part.begin(); + buffer_type::const_iterator part_end = part.begin(); std::advance(part_end, bytes); - typename boost::iterator_range + boost::iterator_range< buffer_type::const_iterator> result_range, input_range = boost::make_iterator_range(part_begin, part_end); fusion::tie(parsed_ok, result_range) = response_parser_.parse_until( - response_parser_type::http_version_done, + response_parser::http_version_done, input_range); if (parsed_ok == true) { std::string version; @@ -141,13 +139,13 @@ namespace boost { namespace network { namespace http { namespace impl { Callback callback, size_t bytes) { logic::tribool parsed_ok; - typename buffer_type::const_iterator part_end = part.begin(); + buffer_type::const_iterator part_end = part.begin(); std::advance(part_end, bytes); - typename boost::iterator_range + boost::iterator_range< buffer_type::const_iterator> result_range, input_range = boost::make_iterator_range(part_begin, part_end); fusion::tie(parsed_ok, result_range) = response_parser_.parse_until( - response_parser_type::http_status_done, + response_parser::http_status_done, input_range); if (parsed_ok == true) { std::string status; @@ -197,13 +195,13 @@ namespace boost { namespace network { namespace http { namespace impl { Callback callback, size_t bytes) { logic::tribool parsed_ok; - typename buffer_type::const_iterator part_end = part.begin(); + buffer_type::const_iterator part_end = part.begin(); std::advance(part_end, bytes); - typename boost::iterator_range + boost::iterator_range< buffer_type::const_iterator> result_range, input_range = boost::make_iterator_range(part_begin, part_end); fusion::tie(parsed_ok, result_range) = response_parser_.parse_until( - response_parser_type::http_status_message_done, + response_parser::http_status_message_done, input_range); if (parsed_ok == true) { std::string status_message; @@ -245,28 +243,28 @@ namespace boost { namespace network { namespace http { namespace impl { } void parse_headers_real(std::string & headers_part) { - typename boost::iterator_range + boost::iterator_range< std::string::const_iterator> input_range = boost::make_iterator_range(headers_part) , result_range; logic::tribool parsed_ok; - response_parser_type headers_parser( - response_parser_type::http_header_line_done); + response_parser headers_parser( + response_parser::http_header_line_done); std::multimap headers; std::pair header_pair; while (!boost::empty(input_range)) { fusion::tie(parsed_ok, result_range) = headers_parser.parse_until( - response_parser_type::http_header_colon, + response_parser::http_header_colon, input_range); if (headers_parser.state() - != response_parser_type::http_header_colon) + != response_parser::http_header_colon) break; header_pair.first = std::string(boost::begin(result_range), boost::end(result_range)); input_range.advance_begin(boost::distance(result_range)); fusion::tie(parsed_ok, result_range) = headers_parser.parse_until( - response_parser_type::http_header_line_done, + response_parser::http_header_line_done, input_range); header_pair.second = std::string(boost::begin(result_range), boost::end(result_range)); @@ -289,13 +287,13 @@ namespace boost { namespace network { namespace http { namespace impl { Callback callback, size_t bytes) { logic::tribool parsed_ok; - typename buffer_type::const_iterator part_end = part.begin(); + buffer_type::const_iterator part_end = part.begin(); std::advance(part_end, bytes); - typename boost::iterator_range + boost::iterator_range< buffer_type::const_iterator> result_range, input_range = boost::make_iterator_range(part_begin, part_end); fusion::tie(parsed_ok, result_range) = response_parser_.parse_until( - response_parser_type::http_headers_done, + response_parser::http_headers_done, input_range); if (parsed_ok == true) { std::string headers_string; @@ -353,10 +351,7 @@ namespace boost { namespace network { namespace http { namespace impl { ); } - typedef response_parser response_parser_type; - typedef boost::array buffer_type; - - response_parser_type response_parser_; + response_parser response_parser_; boost::promise version_promise; boost::promise status_promise; boost::promise status_message_promise; @@ -364,8 +359,9 @@ namespace boost { namespace network { namespace http { namespace impl { boost::promise source_promise; boost::promise destination_promise; boost::promise body_promise; + typedef boost::array buffer_type; buffer_type part; - typename buffer_type::const_iterator part_begin; + buffer_type::const_iterator part_begin; std::string partial_parsed; }; diff --git a/boost/network/protocol/http/impl/access.hpp b/boost/network/protocol/http/impl/access.hpp new file mode 100644 index 000000000..f32bfd661 --- /dev/null +++ b/boost/network/protocol/http/impl/access.hpp @@ -0,0 +1,40 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_IMPL_ACCESS_HPP_20111202 +#define BOOST_NETWORK_PROTOCOL_HTTP_IMPL_ACCESS_HPP_20111202 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include + +namespace boost { namespace network { namespace http { + +struct response; + +namespace impl { + +struct setter_access { + promise get_version_promise(response &r); + promise get_status_promise(response &r); + promise get_status_message_promise(response &r); + promise > get_headers_promise(response &r); + promise get_source_promise(response &r); + promise get_destination_promise(response &r); + promise get_body_promise(response &r); +}; + +} // namespace impl + +} // namespace http + +} // namespace network + +} // namespace boost + +#ifdef BOOST_NETWORK_NO_LIB +#include +#endif + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_IMPL_ACCESS_HPP_20111202 diff --git a/boost/network/protocol/http/impl/access.ipp b/boost/network/protocol/http/impl/access.ipp new file mode 100644 index 000000000..944d4d2b7 --- /dev/null +++ b/boost/network/protocol/http/impl/access.ipp @@ -0,0 +1,45 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_IMPL_ACCESS_IPP_20111202 +#define BOOST_NETWORK_PROTOCOL_HTTP_IMPL_ACCESS_IPP_20111202 + +#include + +namespace boost { namespace network { namespace http { namespace impl { + +promise setter_access::get_version_promise(response &r) { + return r.get_version_promise(); +} + +promise setter_access::get_status_promise(response &r) { + return r.get_status_promise(); +} + +promise setter_access::get_status_message_promise(response &r) { + return r.get_status_message_promise(); +} + +promise > +setter_access::get_headers_promise(response &r) { + return r.get_headers_promise(); +} + +promise setter_access::get_source_promise(response &r) { + return r.get_source_promise(); +} + +promise setter_access::get_destination_promise(response &r) { + return r.get_destination_promise(); +} + +promise setter_access::get_body_promise(response &r) { + return r.get_body_promise(); +} + +} // namespace impl + +} // namespace http + +} // namespace network + +} // namespace boost + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_IMPL_ACCESS_IPP_20111202 diff --git a/boost/network/protocol/http/parser/incremental.hpp b/boost/network/protocol/http/parser/incremental.hpp index 58c16ca8c..ca07db0b7 100644 --- a/boost/network/protocol/http/parser/incremental.hpp +++ b/boost/network/protocol/http/parser/incremental.hpp @@ -16,267 +16,267 @@ namespace boost { namespace network { namespace http { - template - struct response_parser { +struct response_parser { - enum state_t { - http_response_begin, - http_version_h, - http_version_t1, - http_version_t2, - http_version_p, - http_version_slash, - http_version_major, - http_version_dot, - http_version_minor, - http_version_done, - http_status_digit, - http_status_done, - http_status_message_char, - http_status_message_cr, - http_status_message_done, - http_header_name_char, - http_header_colon, - http_header_value_char, - http_header_line_cr, - http_header_line_done, - http_headers_end_cr, - http_headers_done - }; + enum state_t { + http_response_begin, + http_version_h, + http_version_t1, + http_version_t2, + http_version_p, + http_version_slash, + http_version_major, + http_version_dot, + http_version_minor, + http_version_done, + http_status_digit, + http_status_done, + http_status_message_char, + http_status_message_cr, + http_status_message_done, + http_header_name_char, + http_header_colon, + http_header_value_char, + http_header_line_cr, + http_header_line_done, + http_headers_end_cr, + http_headers_done + }; - explicit response_parser (state_t state=http_response_begin) - : state_(state) {} + explicit response_parser (state_t state=http_response_begin) + : state_(state) {} - response_parser (response_parser const & other) - : state_(other.state_) {} + response_parser (response_parser const & other) + : state_(other.state_) {} - ~response_parser () {} + ~response_parser () {} - void swap(response_parser & other) { - std::swap(other.state_, this->state_); - } - - response_parser & operator=(response_parser rhs) { - rhs.swap(*this); - return *this; - } + void swap(response_parser & other) { + std::swap(other.state_, this->state_); + } - template - fusion::tuple > parse_until(state_t stop_state, Range & range_) { - logic::tribool parsed_ok(logic::indeterminate); - typename Range::const_iterator start = boost::begin(range_), - current = start, - end = boost::end(range_); - boost::iterator_range - local_range = boost::make_iterator_range(start, end); - while (!boost::empty(local_range) && indeterminate(parsed_ok)) { - current = boost::begin(local_range); - if (state_ == stop_state) { - parsed_ok = true; - } else { - switch(state_) { - case http_response_begin: - if (*current == ' ' || *current == '\r' || *current == '\n') { - // skip valid leading whitespace - ++start; - ++current; - } else if (*current == 'H') { - state_ = http_version_h; - start = current; - ++current; - } else { - parsed_ok = false; - } - break; - case http_version_h: - if (*current == 'T') { - state_ = http_version_t1; - ++current; - } else { - parsed_ok = false; - } - break; - case http_version_t1: - if (*current == 'T') { - state_ = http_version_t2; - ++current; - } else { - parsed_ok = false; - } - break; - case http_version_t2: - if (*current == 'P') { - state_ = http_version_p; - ++current; - } else { - parsed_ok = false; - } - break; - case http_version_p: - if (*current == '/') { - state_ = http_version_slash; - ++current; - } else { - parsed_ok = false; - } - break; - case http_version_slash: - if (algorithm::is_digit()(*current)) { - state_ = http_version_major; - ++current; - } else { - parsed_ok = false; - } - break; - case http_version_major: - if (*current == '.') { - state_ = http_version_dot; - ++current; - } else { - parsed_ok = false; - } - break; - case http_version_dot: - if (algorithm::is_digit()(*current)) { - state_ = http_version_minor; - ++current; - } else { - parsed_ok = false; - } - break; - case http_version_minor: - if (*current == ' ') { - state_ = http_version_done; - ++current; - } else { - parsed_ok = false; - } - break; - case http_version_done: - if (algorithm::is_digit()(*current)) { - state_ = http_status_digit; - ++current; - } else { - parsed_ok = false; - } - break; - case http_status_digit: - if (algorithm::is_digit()(*current)) { - ++current; - } else if (*current == ' ') { - state_ = http_status_done; - ++current; - } else { - parsed_ok = false; - } - break; - case http_status_done: - if (algorithm::is_alnum()(*current)) { - state_ = http_status_message_char; - ++current; - } else { - parsed_ok = false; - } - break; - case http_status_message_char: - if (algorithm::is_alnum()(*current) || algorithm::is_punct()(*current) || (*current == ' ')) { - ++current; - } else if (*current == '\r') { - state_ = http_status_message_cr; - ++current; - } else { - parsed_ok = false; - } - break; - case http_status_message_cr: - if (*current == '\n') { - state_ = http_status_message_done; - ++current; - } else { - parsed_ok = false; - } - break; - case http_status_message_done: - case http_header_line_done: - if (algorithm::is_alnum()(*current)) { - state_ = http_header_name_char; - ++current; - } else if (*current == '\r') { - state_ = http_headers_end_cr; - ++current; - } else { - parsed_ok = false; - } - break; - case http_header_name_char: - if (*current == ':') { - state_ = http_header_colon; - ++current; - } else if (algorithm::is_alnum()(*current) || algorithm::is_space()(*current) || algorithm::is_punct()(*current)) { - ++current; - } else { - parsed_ok = false; - } - break; - case http_header_colon: - if (algorithm::is_space()(*current)) { - ++current; - } else if (algorithm::is_alnum()(*current) || algorithm::is_punct()(*current)) { - state_ = http_header_value_char; - ++current; - } else { - parsed_ok = false; - } - break; - case http_header_value_char: - if (*current == '\r') { - state_ = http_header_line_cr; - ++current; - } else if (algorithm::is_cntrl()(*current)) { - parsed_ok = false; - } else { - ++current; - } - break; - case http_header_line_cr: - if (*current == '\n') { - state_ = http_header_line_done; - ++current; - } else { - parsed_ok = false; - } - break; - case http_headers_end_cr: - if (*current == '\n') { - state_ = http_headers_done; - ++current; - } else { - parsed_ok = false; - } - break; - default: - parsed_ok = false; - } - } + response_parser & operator=(response_parser rhs) { + rhs.swap(*this); + return *this; + } - local_range = boost::make_iterator_range(current, end); - } - if (state_ == stop_state) parsed_ok = true; - return fusion::make_tuple(parsed_ok,boost::make_iterator_range(start, current)); + template + fusion::tuple > parse_until(state_t stop_state, Range & range_) { + logic::tribool parsed_ok(logic::indeterminate); + typename Range::const_iterator start = boost::begin(range_), + current = start, + end = boost::end(range_); + boost::iterator_range + local_range = boost::make_iterator_range(start, end); + if (boost::empty(local_range)) parsed_ok = false; + while (!boost::empty(local_range) && indeterminate(parsed_ok)) { + current = boost::begin(local_range); + if (state_ == stop_state) { + parsed_ok = true; + } else { + switch(state_) { + case http_response_begin: + if (*current == ' ' || *current == '\r' || *current == '\n') { + // skip valid leading whitespace + ++start; + ++current; + } else if (*current == 'H') { + state_ = http_version_h; + start = current; + ++current; + } else { + parsed_ok = false; + } + break; + case http_version_h: + if (*current == 'T') { + state_ = http_version_t1; + ++current; + } else { + parsed_ok = false; + } + break; + case http_version_t1: + if (*current == 'T') { + state_ = http_version_t2; + ++current; + } else { + parsed_ok = false; + } + break; + case http_version_t2: + if (*current == 'P') { + state_ = http_version_p; + ++current; + } else { + parsed_ok = false; + } + break; + case http_version_p: + if (*current == '/') { + state_ = http_version_slash; + ++current; + } else { + parsed_ok = false; + } + break; + case http_version_slash: + if (algorithm::is_digit()(*current)) { + state_ = http_version_major; + ++current; + } else { + parsed_ok = false; + } + break; + case http_version_major: + if (*current == '.') { + state_ = http_version_dot; + ++current; + } else { + parsed_ok = false; + } + break; + case http_version_dot: + if (algorithm::is_digit()(*current)) { + state_ = http_version_minor; + ++current; + } else { + parsed_ok = false; + } + break; + case http_version_minor: + if (*current == ' ') { + state_ = http_version_done; + ++current; + } else { + parsed_ok = false; + } + break; + case http_version_done: + if (algorithm::is_digit()(*current)) { + state_ = http_status_digit; + ++current; + } else { + parsed_ok = false; + } + break; + case http_status_digit: + if (algorithm::is_digit()(*current)) { + ++current; + } else if (*current == ' ') { + state_ = http_status_done; + ++current; + } else { + parsed_ok = false; + } + break; + case http_status_done: + if (algorithm::is_alnum()(*current)) { + state_ = http_status_message_char; + ++current; + } else { + parsed_ok = false; + } + break; + case http_status_message_char: + if (algorithm::is_alnum()(*current) || algorithm::is_punct()(*current) || (*current == ' ')) { + ++current; + } else if (*current == '\r') { + state_ = http_status_message_cr; + ++current; + } else { + parsed_ok = false; + } + break; + case http_status_message_cr: + if (*current == '\n') { + state_ = http_status_message_done; + ++current; + } else { + parsed_ok = false; + } + break; + case http_status_message_done: + case http_header_line_done: + if (algorithm::is_alnum()(*current)) { + state_ = http_header_name_char; + ++current; + } else if (*current == '\r') { + state_ = http_headers_end_cr; + ++current; + } else { + parsed_ok = false; + } + break; + case http_header_name_char: + if (*current == ':') { + state_ = http_header_colon; + ++current; + } else if (algorithm::is_alnum()(*current) || algorithm::is_space()(*current) || algorithm::is_punct()(*current)) { + ++current; + } else { + parsed_ok = false; + } + break; + case http_header_colon: + if (algorithm::is_space()(*current)) { + ++current; + } else if (algorithm::is_alnum()(*current) || algorithm::is_punct()(*current)) { + state_ = http_header_value_char; + ++current; + } else { + parsed_ok = false; + } + break; + case http_header_value_char: + if (*current == '\r') { + state_ = http_header_line_cr; + ++current; + } else if (algorithm::is_cntrl()(*current)) { + parsed_ok = false; + } else { + ++current; + } + break; + case http_header_line_cr: + if (*current == '\n') { + state_ = http_header_line_done; + ++current; + } else { + parsed_ok = false; + } + break; + case http_headers_end_cr: + if (*current == '\n') { + state_ = http_headers_done; + ++current; + } else { + parsed_ok = false; + } + break; + default: + parsed_ok = false; } + } - state_t state() { - return state_; - } + local_range = boost::make_iterator_range(current, end); + } + if (state_ == stop_state) parsed_ok = true; + return fusion::make_tuple(parsed_ok,boost::make_iterator_range(start, current)); + } - void reset(state_t new_state = http_response_begin) { - state_ = new_state; - } + state_t state() { + return state_; + } + + void reset(state_t new_state = http_response_begin) { + state_ = new_state; + } - private: - state_t state_; + private: + state_t state_; - }; +}; } /* http */ diff --git a/boost/network/protocol/http/response/response.hpp b/boost/network/protocol/http/response/response.hpp index 412dfe3c3..c184759c5 100644 --- a/boost/network/protocol/http/response/response.hpp +++ b/boost/network/protocol/http/response/response.hpp @@ -7,10 +7,17 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#include +#include + namespace boost { namespace network { namespace http { struct response : response_base { // FIXME implement all these! + response(); + response(response const &); + response& operator=(response); + void swap(response &); // From message_base... // Mutators @@ -44,8 +51,24 @@ struct response : response_base { virtual void set_status_message(std::string const & new_status_message); virtual void set_version(std::string const & new_version); virtual ~response(); + + private: + friend class impl::setter_access; // Hide access through accessor class. + // These methods are unique to the response type which will allow for creating + // promises that can be set appropriately. + promise get_version_promise(); + promise get_status_promise(); + promise get_status_message_promise(); + promise > get_headers_promise(); + promise get_source_promise(); + promise get_destination_promise(); + promise get_body_promise(); }; +inline void swap(response &l, response &r) { + l.swap(r); +} + template response & operator<<( response & message, From cfccb144f6a3d2bd7bbf9525a1b2d327e4ccc69f Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sat, 3 Dec 2011 23:57:55 +1100 Subject: [PATCH 035/196] HTTP Client Connections now Build! More changes in the message wrapper implementations but this is mostly for consistency. This means though that it breaks backwards compatibility for usage of these wrappers. Ultimately this commit gets the asynchronous connection implementation to a state where it actually builds and links. Next steps involve the actual chore of making the request and result implementations work as expected. --- boost/network/message/wrappers/body.hpp | 8 ++--- boost/network/message/wrappers/body.ipp | 5 ++- .../network/message/wrappers/destination.hpp | 12 +++---- .../network/message/wrappers/destination.ipp | 4 +-- boost/network/message/wrappers/headers.ipp | 6 ++-- boost/network/message/wrappers/source.hpp | 12 +++---- boost/network/message/wrappers/source.ipp | 4 +-- boost/network/protocol/http/client/base.hpp | 2 +- boost/network/protocol/http/client/base.ipp | 8 ++--- .../http/client/client_connection.hpp | 4 +-- .../http/client/connection/async_normal.hpp | 3 +- .../http/client/connection/async_normal.ipp | 36 +++++++++++++++++-- libs/network/test/http/CMakeLists.txt | 2 ++ libs/network/test/message_test.cpp | 3 +- libs/network/test/message_transform_test.cpp | 24 ++++++++----- 15 files changed, 83 insertions(+), 50 deletions(-) diff --git a/boost/network/message/wrappers/body.hpp b/boost/network/message/wrappers/body.hpp index 2a76497f9..fffe9277d 100644 --- a/boost/network/message/wrappers/body.hpp +++ b/boost/network/message/wrappers/body.hpp @@ -13,8 +13,6 @@ namespace boost { namespace network { -namespace impl { - struct body_wrapper { explicit body_wrapper(message_base const & message); operator std::string () const; @@ -32,11 +30,9 @@ inline std::ostream & operator<<(std::ostream & os, body_wrapper const & body) { return os; } -} // namespace impl - -inline impl::body_wrapper const +inline body_wrapper const body(message_base const & message_) { - return impl::body_wrapper(message_); + return body_wrapper(message_); } } // namespace network diff --git a/boost/network/message/wrappers/body.ipp b/boost/network/message/wrappers/body.ipp index 0c24f67bc..6cda77129 100644 --- a/boost/network/message/wrappers/body.ipp +++ b/boost/network/message/wrappers/body.ipp @@ -9,9 +9,9 @@ #include -namespace boost { namespace network { namespace impl { +namespace boost { namespace network { -body_wrapper::body_wrapper(message_base & message): +body_wrapper::body_wrapper(message_base const & message): message_(message) {} body_wrapper::operator std::string () const { @@ -64,7 +64,6 @@ std::string::const_iterator body_wrapper::end() const { return cache_->end(); } -} /* impl */ } /* network */ } /* boost */ diff --git a/boost/network/message/wrappers/destination.hpp b/boost/network/message/wrappers/destination.hpp index 1f3f44330..3b269a489 100644 --- a/boost/network/message/wrappers/destination.hpp +++ b/boost/network/message/wrappers/destination.hpp @@ -11,8 +11,6 @@ namespace boost { namespace network { -namespace impl { - struct destination_wrapper { explicit destination_wrapper(message_base const & message); operator std::string () const; @@ -21,11 +19,13 @@ struct destination_wrapper { mutable optional cache_; }; -} // namespace impl - -inline std::string const +inline destination_wrapper const destination(message_base const & message_) { - return impl::destination_wrapper(message_); + return destination_wrapper(message_); +} + +inline std::ostream & operator<< (std::ostream &os, destination_wrapper const &d) { + return os << static_cast(d); } } // namespace network diff --git a/boost/network/message/wrappers/destination.ipp b/boost/network/message/wrappers/destination.ipp index 99c1d73ff..8c25cc1d4 100644 --- a/boost/network/message/wrappers/destination.ipp +++ b/boost/network/message/wrappers/destination.ipp @@ -9,7 +9,7 @@ #include -namespace boost { namespace network { namespace impl { +namespace boost { namespace network { destination_wrapper::destination_wrapper(message_base const & message): message_(message) {} @@ -24,8 +24,6 @@ destination_wrapper::operator std::string () const { return *cache_; } -} /* impl */ - } /* network */ } /* boost */ diff --git a/boost/network/message/wrappers/headers.ipp b/boost/network/message/wrappers/headers.ipp index 80825fd23..38d917189 100644 --- a/boost/network/message/wrappers/headers.ipp +++ b/boost/network/message/wrappers/headers.ipp @@ -10,9 +10,9 @@ #include #include -namespace boost { namespace network { namespace impl { +namespace boost { namespace network { -headers_wrapper::headers_wrapper(message_base & message) +headers_wrapper::headers_wrapper(message_base const & message) : message_(message) {} @@ -76,8 +76,6 @@ void headers_wrapper::init_cache_all() const { } } -} /* impl */ - } /* network */ } /* boost */ diff --git a/boost/network/message/wrappers/source.hpp b/boost/network/message/wrappers/source.hpp index 84c7f6fe8..05dfac024 100644 --- a/boost/network/message/wrappers/source.hpp +++ b/boost/network/message/wrappers/source.hpp @@ -11,8 +11,6 @@ namespace boost { namespace network { -namespace impl { - struct source_wrapper { explicit source_wrapper(message_base & message); operator std::string () const; @@ -21,11 +19,13 @@ struct source_wrapper { mutable boost::optional cache_; }; -} // namespace impl - -inline std::string const +inline source_wrapper const source(message_base & message_) { - return impl::source_wrapper(message_); + return source_wrapper(message_); +} + +inline std::ostream & operator<<(std::ostream &os, source_wrapper const &s) { + return os << static_cast(s); } } // namespace network diff --git a/boost/network/message/wrappers/source.ipp b/boost/network/message/wrappers/source.ipp index 829d3876f..d6219b876 100644 --- a/boost/network/message/wrappers/source.ipp +++ b/boost/network/message/wrappers/source.ipp @@ -9,7 +9,7 @@ #include -namespace boost { namespace network { namespace impl { +namespace boost { namespace network { source_wrapper::source_wrapper(message_base & message): message_(message) {} @@ -24,8 +24,6 @@ source_wrapper::operator std::string () const { return *cache_; } -} /* impl */ - } /* network */ } /* boost */ diff --git a/boost/network/protocol/http/client/base.hpp b/boost/network/protocol/http/client/base.hpp index b5b381e49..a75823069 100644 --- a/boost/network/protocol/http/client/base.hpp +++ b/boost/network/protocol/http/client/base.hpp @@ -27,7 +27,7 @@ struct client_base { client_base(asio::io_service & service, shared_ptr connection_manager_); ~client_base(); - response const request_skeleton(request_base const & request_, + response const request_skeleton(request const & request_, std::string const & method, bool get_body, body_callback_function_type callback); diff --git a/boost/network/protocol/http/client/base.ipp b/boost/network/protocol/http/client/base.ipp index 34732b6d3..730bf1c7f 100644 --- a/boost/network/protocol/http/client/base.ipp +++ b/boost/network/protocol/http/client/base.ipp @@ -13,7 +13,7 @@ #include #include #include -#include +#include namespace boost { namespace network { namespace http { @@ -23,7 +23,7 @@ struct client_base_pimpl { body_callback_function_type; client_base_pimpl(shared_ptr connection_manager_); client_base_pimpl(asio::io_service & service, shared_ptr connection_manager_); - response const request_skeleton(request_base const & request_, + response const request_skeleton(request const & request_, std::string const & method, bool get_body, body_callback_function_type callback); @@ -45,7 +45,7 @@ client_base::client_base(asio::io_service & service, : pimpl(new (std::nothrow) client_base_pimpl(service, connection_manager_)) {} -response const client_base::request_skeleton(request_base const & request_, +response const client_base::request_skeleton(request const & request_, std::string const & method, bool get_body, body_callback_function_type callback) { @@ -94,7 +94,7 @@ client_base_pimpl::~client_base_pimpl() } response const client_base_pimpl::request_skeleton( - request_base const & request_, + request const & request_, std::string const & method, bool get_body, body_callback_function_type callback diff --git a/boost/network/protocol/http/client/client_connection.hpp b/boost/network/protocol/http/client/client_connection.hpp index a6302ad4d..e161c93c2 100644 --- a/boost/network/protocol/http/client/client_connection.hpp +++ b/boost/network/protocol/http/client/client_connection.hpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include namespace boost { namespace network { namespace http { @@ -20,7 +20,7 @@ struct client_connection { system::error_code const &)> callback_type; virtual response send_request(std::string const & method, - request_base const & request, + request const & request, bool get_body, callback_type callback) = 0; virtual client_connection * clone() const = 0; diff --git a/boost/network/protocol/http/client/connection/async_normal.hpp b/boost/network/protocol/http/client/connection/async_normal.hpp index c4fc08e86..3e44600d3 100644 --- a/boost/network/protocol/http/client/connection/async_normal.hpp +++ b/boost/network/protocol/http/client/connection/async_normal.hpp @@ -29,12 +29,13 @@ struct http_async_connection : client_connection bool follow_redirects); http_async_connection * clone() const; virtual response send_request(std::string const & method, - request_base const & request, + request const & request, bool get_body, callback_type callback); // override virtual void reset(); // override virtual ~http_async_connection(); private: + explicit http_async_connection(shared_ptr); shared_ptr pimpl; }; diff --git a/boost/network/protocol/http/client/connection/async_normal.ipp b/boost/network/protocol/http/client/connection/async_normal.ipp index e57e8b016..285d742f0 100644 --- a/boost/network/protocol/http/client/connection/async_normal.ipp +++ b/boost/network/protocol/http/client/connection/async_normal.ipp @@ -68,6 +68,18 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisresolver_delegate_, + this->connection_delegate_, + request_strand_.get_io_service(), + follow_redirect_); + } + + void reset() { + // FIXME Perform the actual re-set of the internal state and pending stuff. + } + private: http_async_connection_pimpl(http_async_connection_pimpl const &); // = delete @@ -731,8 +743,28 @@ http_async_connection::http_async_connection(shared_ptr resol : pimpl(new (std::nothrow) http_async_connection_pimpl(resolver_delegate, connection_delegate, io_service, - follow_redirects)) -{} + follow_redirects)) {} + +http_async_connection::http_async_connection(shared_ptr new_pimpl) +: pimpl(new_pimpl) {} + +http_async_connection::~http_async_connection() {} + +http_async_connection * http_async_connection::clone() const { + shared_ptr new_pimpl(pimpl->clone()); + return new (std::nothrow) http_async_connection(new_pimpl); +} + +response http_async_connection::send_request(std::string const & method, + request const & request, + bool get_body, + callback_type callback) { + return pimpl->start(request, method, get_body, callback); +} + +void http_async_connection::reset() { + pimpl->reset(); // NOTE: We're not resetting the pimpl, just the internal state. +} } /* http */ diff --git a/libs/network/test/http/CMakeLists.txt b/libs/network/test/http/CMakeLists.txt index e71b8333f..01a4bfdad 100644 --- a/libs/network/test/http/CMakeLists.txt +++ b/libs/network/test/http/CMakeLists.txt @@ -34,6 +34,7 @@ if (Boost_FOUND) add_dependencies(cpp-netlib-http-${test} cppnetlib-uri cppnetlib-message + cppnetlib-message-wrappers cppnetlib-http-message cppnetlib-http-client cppnetlib-http-client-connections) @@ -42,6 +43,7 @@ if (Boost_FOUND) ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri cppnetlib-message + cppnetlib-message-wrappers cppnetlib-http-message cppnetlib-http-client cppnetlib-http-client-connections) diff --git a/libs/network/test/message_test.cpp b/libs/network/test/message_test.cpp index 92a6b9103..d5f50fbf9 100644 --- a/libs/network/test/message_test.cpp +++ b/libs/network/test/message_test.cpp @@ -60,7 +60,8 @@ BOOST_AUTO_TEST_CASE(source_directive_test) { BOOST_AUTO_TEST_CASE(destination_directive_test) { message instance; instance << destination("destination"); - BOOST_CHECK ( destination(instance) == "destination" ); + std::string const & destination_ = destination(instance); + BOOST_CHECK ( destination_ == "destination" ); } BOOST_AUTO_TEST_CASE(remove_header_directive_test) { diff --git a/libs/network/test/message_transform_test.cpp b/libs/network/test/message_transform_test.cpp index c1be57148..9f77d014c 100644 --- a/libs/network/test/message_transform_test.cpp +++ b/libs/network/test/message_transform_test.cpp @@ -15,13 +15,17 @@ BOOST_AUTO_TEST_CASE ( message_transform_toupper ) { message msg; msg << source("me"); - BOOST_CHECK_EQUAL ( source(msg), "me" ); + std::string const & source_orig = source(msg); + BOOST_CHECK_EQUAL ( source_orig, "me" ); msg << transform(to_upper_, source_); - BOOST_CHECK_EQUAL ( source(msg), "ME" ); + std::string const & source_upper = source(msg); + BOOST_CHECK_EQUAL ( source_upper, "ME" ); msg << destination("you"); - BOOST_CHECK_EQUAL ( destination(msg), "you"); + std::string const & destination_orig = destination(msg); + BOOST_CHECK_EQUAL ( destination_orig, "you"); msg << transform(to_upper_, destination_); - BOOST_CHECK_EQUAL ( destination(msg), "YOU"); + std::string const & destination_upper = destination(msg); + BOOST_CHECK_EQUAL ( destination_upper, "YOU"); } BOOST_AUTO_TEST_CASE ( message_transform_tolower ) { @@ -29,12 +33,16 @@ BOOST_AUTO_TEST_CASE ( message_transform_tolower ) { message msg; msg << source("ME"); - BOOST_CHECK_EQUAL ( source(msg), "ME" ); + std::string const & source_orig = source(msg); + BOOST_CHECK_EQUAL ( source_orig, "ME" ); msg << transform(to_lower_, source_); - BOOST_CHECK_EQUAL ( source(msg), "me" ); + std::string const & source_lower = source(msg); + BOOST_CHECK_EQUAL ( source_lower, "me" ); msg << destination("YOU"); - BOOST_CHECK_EQUAL ( destination(msg), "YOU" ); + std::string const & destination_orig = destination(msg); + BOOST_CHECK_EQUAL ( destination_orig, "YOU" ); msg << transform(to_lower_, destination_); - BOOST_CHECK_EQUAL ( destination(msg), "you" ); + std::string const & destination_lower = destination(msg); + BOOST_CHECK_EQUAL ( destination_lower, "you" ); } From eeb590cd99c01b7972892deb302de08a1848a358 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sun, 4 Dec 2011 21:30:18 +1100 Subject: [PATCH 036/196] More Wrapper Implementations. Here are a few more implementations of the wrappers required to get the necessary bits of the implementation out of the way. This clears up some fo the linker errors for the easier things that need to be dealt with. We also introduce a new lib for the constants used throughout the library. At some point later we're going to have to consolidate these constants not only from the HTTP implementation but also the URI implementation. --- boost/network/constants.ipp | 2 + .../protocol/http/message/wrappers/anchor.ipp | 30 +++++++++++++++ .../protocol/http/message/wrappers/host.ipp | 30 +++++++++++++++ .../protocol/http/message/wrappers/path.ipp | 30 +++++++++++++++ .../protocol/http/message/wrappers/port.hpp | 2 +- .../protocol/http/message/wrappers/port.ipp | 37 +++++++++++++++++++ .../protocol/http/message/wrappers/query.ipp | 30 +++++++++++++++ libs/network/src/CMakeLists.txt | 3 ++ libs/network/src/constants.cpp | 11 ++++++ libs/network/src/http/client_connections.cpp | 1 + libs/network/src/http/request.cpp | 5 +++ libs/network/test/http/CMakeLists.txt | 2 + 12 files changed, 182 insertions(+), 1 deletion(-) create mode 100644 boost/network/protocol/http/message/wrappers/anchor.ipp create mode 100644 boost/network/protocol/http/message/wrappers/host.ipp create mode 100644 boost/network/protocol/http/message/wrappers/path.ipp create mode 100644 boost/network/protocol/http/message/wrappers/port.ipp create mode 100644 boost/network/protocol/http/message/wrappers/query.ipp create mode 100644 libs/network/src/constants.cpp diff --git a/boost/network/constants.ipp b/boost/network/constants.ipp index 86ac0ffc8..e6e10cd4d 100644 --- a/boost/network/constants.ipp +++ b/boost/network/constants.ipp @@ -7,6 +7,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#include + namespace boost { namespace network { char const * constants::crlf() { diff --git a/boost/network/protocol/http/message/wrappers/anchor.ipp b/boost/network/protocol/http/message/wrappers/anchor.ipp new file mode 100644 index 000000000..b439b9c58 --- /dev/null +++ b/boost/network/protocol/http/message/wrappers/anchor.ipp @@ -0,0 +1,30 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_ANCHOR_IPP_20111204 +#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_ANCHOR_IPP_20111204 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Googl,Inc. +// 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) + +#include +#include + +namespace boost { namespace network { namespace http { + +anchor_wrapper::anchor_wrapper(request_base const & request) +: request_(request) {} + +anchor_wrapper::operator std::string () const { + uri::uri uri_; + request_.get_uri(uri_); + return fragment(uri_); +} + +} // namespace http + +} // namespace network + +} // namespace boost + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_ANCHOR_IPP_20111204 diff --git a/boost/network/protocol/http/message/wrappers/host.ipp b/boost/network/protocol/http/message/wrappers/host.ipp new file mode 100644 index 000000000..db047655b --- /dev/null +++ b/boost/network/protocol/http/message/wrappers/host.ipp @@ -0,0 +1,30 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_IPP_20111204 +#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_IPP_20111204 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include +#include + +namespace boost { namespace network { namespace http { + +host_wrapper::host_wrapper(request_base const & request) +: request_(request) {} + +host_wrapper::operator std::string () const { + uri::uri uri_; + request_.get_uri(uri_); + return host(uri_); +} + +} // namespace http + +} // namespace network + +} // namespace boost + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_IPP_20111204 diff --git a/boost/network/protocol/http/message/wrappers/path.ipp b/boost/network/protocol/http/message/wrappers/path.ipp new file mode 100644 index 000000000..5427fa2a8 --- /dev/null +++ b/boost/network/protocol/http/message/wrappers/path.ipp @@ -0,0 +1,30 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PATH_IPP_20111204 +#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PATH_IPP_20111204 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include +#include + +namespace boost { namespace network { namespace http { + +path_wrapper::path_wrapper(request_base const & request) +: request_(request) {} + +path_wrapper::operator std::string () const { + uri::uri uri_; + request_.get_uri(uri_); + return path(uri_); +} + +} // namespace http + +} // namespace network + +} // namespace boost + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PATH_IPP_20111204 diff --git a/boost/network/protocol/http/message/wrappers/port.hpp b/boost/network/protocol/http/message/wrappers/port.hpp index b74204da7..62a3e45ba 100644 --- a/boost/network/protocol/http/message/wrappers/port.hpp +++ b/boost/network/protocol/http/message/wrappers/port.hpp @@ -18,7 +18,7 @@ struct port_wrapper { operator boost::uint16_t () const; operator boost::optional () const; private: - request_base const & message_; + request_base const & request_; }; inline port_wrapper const diff --git a/boost/network/protocol/http/message/wrappers/port.ipp b/boost/network/protocol/http/message/wrappers/port.ipp new file mode 100644 index 000000000..6a4472fa5 --- /dev/null +++ b/boost/network/protocol/http/message/wrappers/port.ipp @@ -0,0 +1,37 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PORT_IPP_20111204 +#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PORT_IPP_20111204 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include +#include + +namespace boost { namespace network { namespace http { + +port_wrapper::port_wrapper(request_base const & request) +: request_(request) {} + +port_wrapper::operator boost::uint16_t () const { + uri::uri uri_; + request_.get_uri(uri_); + optional optional_port = port_us(uri_); + return optional_port ? *optional_port : 80u; +} + +port_wrapper::operator optional () const { + uri::uri uri_; + request_.get_uri(uri_); + return port_us(uri_); +} + +} // namespace http + +} // namespace network + +} // namespace boost + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PORT_IPP_20111204 diff --git a/boost/network/protocol/http/message/wrappers/query.ipp b/boost/network/protocol/http/message/wrappers/query.ipp new file mode 100644 index 000000000..806f0314d --- /dev/null +++ b/boost/network/protocol/http/message/wrappers/query.ipp @@ -0,0 +1,30 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_QUERY_IPP_20111204 +#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_QUERY_IPP_20111204 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include +#include + +namespace boost { namespace network { namespace http { + +query_wrapper::query_wrapper(request_base const & request) +: request_(request) {} + +query_wrapper::operator std::string () const { + uri::uri uri_; + request_.get_uri(uri_); + return query(uri_); +} + +} // namespace http + +} // namespace network + +} // namespace boost + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_QUERY_IPP_20111204 diff --git a/libs/network/src/CMakeLists.txt b/libs/network/src/CMakeLists.txt index a231213e9..81b19d561 100644 --- a/libs/network/src/CMakeLists.txt +++ b/libs/network/src/CMakeLists.txt @@ -47,3 +47,6 @@ add_library(cppnetlib-http-client ${CPP-NETLIB_HTTP_CLIENT_SRCS}) set(CPP-NETLIB_UTILS_THREAD_POOL_SRCS utils/thread_pool.cpp) add_library(cppnetlib-utils-thread_pool ${CPP-NETLIB_UTILS_THREAD_POOL_SRCS}) + +set(CPP-NETLIB_CONSTANTS_SRCS constants.cpp) +add_library(cppnetlib-constants ${CPP-NETLIB_CONSTANTS_SRCS}) diff --git a/libs/network/src/constants.cpp b/libs/network/src/constants.cpp new file mode 100644 index 000000000..f8674a076 --- /dev/null +++ b/libs/network/src/constants.cpp @@ -0,0 +1,11 @@ +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#ifdef BOOST_NETWORK_NO_LIB +#undef BOOST_NETWORK_NO_LIB +#endif + +#include diff --git a/libs/network/src/http/client_connections.cpp b/libs/network/src/http/client_connections.cpp index 06cb0df22..0ad39c4a8 100644 --- a/libs/network/src/http/client_connections.cpp +++ b/libs/network/src/http/client_connections.cpp @@ -10,3 +10,4 @@ #include #include +#include diff --git a/libs/network/src/http/request.cpp b/libs/network/src/http/request.cpp index 983880dc4..a1f1ff481 100644 --- a/libs/network/src/http/request.cpp +++ b/libs/network/src/http/request.cpp @@ -9,3 +9,8 @@ #endif #include +#include +#include +#include +#include +#include diff --git a/libs/network/test/http/CMakeLists.txt b/libs/network/test/http/CMakeLists.txt index 01a4bfdad..d5bc63cd5 100644 --- a/libs/network/test/http/CMakeLists.txt +++ b/libs/network/test/http/CMakeLists.txt @@ -32,6 +32,7 @@ if (Boost_FOUND) endif() add_executable(cpp-netlib-http-${test} ${test}.cpp) add_dependencies(cpp-netlib-http-${test} + cppnetlib-constants cppnetlib-uri cppnetlib-message cppnetlib-message-wrappers @@ -41,6 +42,7 @@ if (Boost_FOUND) target_link_libraries(cpp-netlib-http-${test} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} + cppnetlib-constants cppnetlib-uri cppnetlib-message cppnetlib-message-wrappers From dfdcaa82362424e8d410ab2350ad8ca0a43cb5d3 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Wed, 7 Dec 2011 01:54:03 +1100 Subject: [PATCH 037/196] Attempt at linking happiness. But no dice. I'm running into the issue of not being able to properly move/return lvalue promises. I might have to change the API of this but I'm committing things now just for recording forward progress. I should really get some sleep now. --- .../http/message/modifiers/status.hpp | 2 +- .../protocol/http/response/response.hpp | 10 +- .../protocol/http/response/response.ipp | 344 ++++++++++++++++++ .../protocol/http/response/response_base.hpp | 5 +- libs/network/src/http/response.cpp | 1 + 5 files changed, 358 insertions(+), 4 deletions(-) create mode 100644 boost/network/protocol/http/response/response.ipp diff --git a/boost/network/protocol/http/message/modifiers/status.hpp b/boost/network/protocol/http/message/modifiers/status.hpp index 66675fa8e..cb33820bd 100644 --- a/boost/network/protocol/http/message/modifiers/status.hpp +++ b/boost/network/protocol/http/message/modifiers/status.hpp @@ -11,7 +11,7 @@ namespace boost { namespace network { namespace http { -inline void status(response_base & response, std::string const & value) { +inline void status(response_base & response, boost::uint16_t value) { response.set_status(value); } diff --git a/boost/network/protocol/http/response/response.hpp b/boost/network/protocol/http/response/response.hpp index c184759c5..8855122d1 100644 --- a/boost/network/protocol/http/response/response.hpp +++ b/boost/network/protocol/http/response/response.hpp @@ -12,8 +12,9 @@ namespace boost { namespace network { namespace http { +struct response_pimpl; + struct response : response_base { - // FIXME implement all these! response(); response(response const &); response& operator=(response); @@ -47,9 +48,12 @@ struct response : response_base { size_t size) const; // From response_base... - virtual void set_status(std::string const & new_status); + virtual void set_status(boost::uint16_t new_status); virtual void set_status_message(std::string const & new_status_message); virtual void set_version(std::string const & new_version); + virtual void get_status(boost::uint16_t &status) const; + virtual void get_status_message(std::string &status_message) const; + virtual void get_version(std::string &version) const; virtual ~response(); private: @@ -63,6 +67,8 @@ struct response : response_base { promise get_source_promise(); promise get_destination_promise(); promise get_body_promise(); + + scoped_ptr pimpl_; }; inline void swap(response &l, response &r) { diff --git a/boost/network/protocol/http/response/response.ipp b/boost/network/protocol/http/response/response.ipp new file mode 100644 index 000000000..62db26844 --- /dev/null +++ b/boost/network/protocol/http/response/response.ipp @@ -0,0 +1,344 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_RESPONSE_IPP_20111206 +#define BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_RESPONSE_IPP_20111206 + +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) + +#include +#include +#include + +namespace boost { namespace network { namespace http { + +struct response_pimpl { + response_pimpl() {} + response_pimpl * clone() { + response_pimpl * new_pimpl = new (std::nothrow) response_pimpl; + new_pimpl->source_future_ = source_future_; + new_pimpl->destination_future_ = destination_future_; + new_pimpl->headers_future_ = headers_future_; + new_pimpl->status_future_ = status_future_; + new_pimpl->status_message_future_ = status_message_future_; + new_pimpl->version_future_ = version_future_; + new_pimpl->body_future_ = body_future_; + return new_pimpl; + } + + void set_destination(std::string const &destination) { + promise destination_promise; + unique_future tmp_future = destination_promise.get_future(); + destination_future_ = move(tmp_future); + destination_promise.set_value(destination); + } + + void get_destination(std::string &destination) { + if (!destination_future_) { + destination = ""; + } else { + destination = destination_future_->get(); + } + } + + void set_source(std::string const &source) { + promise source_promise; + unique_future tmp_future = source_promise.get_future(); + source_future_ = move(tmp_future); + source_promise.set_value(source); + } + + void get_source(std::string &source) { + if (!source_future_) { + source = ""; + } else { + source = source_future_->get(); + } + } + + void append_header(std::string const & name, + std::string const & value) { + // FIXME do something! + } + + void remove_headers(std::string const &name) { + // FIXME do something! + } + + void remove_headers() { + // FIXME do something! + } + + void get_headers( + function inserter) { /* FIXME: Do something! */ } + void get_headers( + std::string const & name, + function inserter) { /* FIXME: Do something! */ } + void get_headers( + function predicate, + function inserter) { /* FIXME: Do something! */ } + + void set_body(std::string const &body) { + promise body_promise; + unique_future tmp_future = body_promise.get_future(); + body_future_ = move(tmp_future); + body_promise.set_value(body); + } + + void append_body(std::string const & data) { /* FIXME: Do something! */ } + + void get_body(std::string &body) { + if (!body_future_) { + body = ""; + } else { + body = body_future_->get(); + } + } + + void get_body( + function)> chunk_reader, + size_t size) { /* FIXME: Do something! */ } + + void set_status(boost::uint16_t status) { + promise status_promise; + unique_future tmp_future = status_promise.get_future(); + status_future_ = move(tmp_future); + status_promise.set_value(status); + } + + void get_status(boost::uint16_t &status) { + if (!status_future_) { + status = 0u; + } else { + status = status_future_->get(); + } + } + + void set_status_message(std::string const &status_message) { + promise status_message_promise_; + unique_future tmp_future = status_message_promise_.get_future(); + status_message_future_ = move(tmp_future); + status_message_promise_.set_value(status_message); + } + + void get_status_message(std::string &status_message) { + if (!status_message_future_) { + status_message = ""; + } else { + status_message = status_message_future_->get(); + } + } + + void set_version(std::string const &version) { + promise version_promise; + unique_future tmp_future = version_promise.get_future(); + version_future_ = move(tmp_future); + version_promise.set_value(version); + } + + void get_version(std::string &version) { + if (!version_future_) { + version = ""; + } else { + version = version_future_->get(); + } + } + + promise get_source_promise() { + promise promise_; + unique_future tmp_future = promise_.get_future(); + source_future_ = move(tmp_future); + return move(promise_); + } + + promise get_destination_promise() { + promise promise_; + unique_future tmp_future = promise_.get_future(); + destination_future_ = move(tmp_future); + return move(promise_); + } + + promise > get_headers_promise() { + promise > promise_; + unique_future > tmp_future = promise_.get_future(); + headers_future_ = move(tmp_future); + return promise_; + } + + promise get_status_promise() { + promise promise_; + unique_future tmp_future = promise_.get_future(); + status_future_ = move(tmp_future); + return promise_; + } + + promise get_status_message_promise() { + promise promise_; + unique_future tmp_future = promise_.get_future(); + status_message_future_ = move(tmp_future); + return promise_; + } + + promise get_version_promise() { + promise promise_; + unique_future tmp_future = promise_.get_future(); + version_future_ = move(tmp_future); + return promise_; + } + + promise get_body_promise() { + promise promise_; + unique_future tmp_future = promise_.get_future(); + body_future_ = move(tmp_future); + return promise_; + } + + private: + optional > source_future_; + optional > destination_future_; + optional > > + headers_future_; + optional > status_future_; + optional > status_message_future_; + optional > version_future_; + optional > body_future_; +}; + +response::response() +: pimpl_(new (std::nothrow) response_pimpl) +{} + +response::response(response const & other) +: pimpl_(other.pimpl_->clone()) +{} + +response& response::operator=(response rhs) { + rhs.swap(*this); + return *this; +} + +void response::swap(response &other) { + other.pimpl_.swap(pimpl_); +} + +void response::set_destination(std::string const &destination) { + pimpl_->set_destination(destination); +} + +void response::set_source(std::string const &source) { + pimpl_->set_source(source); +} + +void response::append_header(std::string const &name, + std::string const &value) { + pimpl_->append_header(name, value); +} + +void response::remove_headers(std::string const &name) { + pimpl_->remove_headers(name); +} + +void response::remove_headers() { + pimpl_->remove_headers(); +} + +void response::set_body(std::string const &body) { + pimpl_->set_body(body); +} + +void response::append_body(std::string const &data) { + pimpl_->append_body(data); +} + +void response::get_destination(std::string &destination) const { + pimpl_->get_destination(destination); +} + +void response::get_source(std::string &source) const { + pimpl_->get_source(source); +} + +void response::get_headers(function inserter) const { + pimpl_->get_headers(inserter); +} + +void response::get_headers(std::string const &name, + function inserter) const { + pimpl_->get_headers(name, inserter); +} + +void response::get_headers(function predicate, + function inserter) const { + pimpl_->get_headers(predicate, inserter); +} + +void response::get_body(std::string &body) const { + pimpl_->get_body(body); +} + +void response::get_body(function)> chunk_reader, size_t size) const { + pimpl_->get_body(chunk_reader, size); +} + +void response::set_status(boost::uint16_t new_status) { + pimpl_->set_status(new_status); +} + +void response::set_status_message(std::string const &new_status_message) { + pimpl_->set_status_message(new_status_message); +} + +void response::set_version(std::string const &new_version) { + pimpl_->set_version(new_version); +} + +void response::get_status(boost::uint16_t &status) const { + pimpl_->get_status(status); +} + +void response::get_status_message(std::string &status_message) const { + pimpl_->get_status_message(status_message); +} + +void response::get_version(std::string &version) const { + pimpl_->get_version(version); +} + +response::~response() {} + +promise response::get_version_promise() { + return pimpl_->get_version_promise(); +} + +promise response::get_status_promise() { + return pimpl_->get_status_promise(); +} + +promise response::get_status_message_promise() { + return pimpl_->get_status_message_promise(); +} + +promise > response::get_headers_promise() { + return pimpl_->get_headers_promise(); +} + +promise response::get_source_promise() { + return pimpl_->get_source_promise(); +} + +promise response::get_destination_promise() { + return pimpl_->get_destination_promise(); +} + +promise response::get_body_promise() { + return pimpl_->get_body_promise(); +} + +} // namespace http + +} // namespace network + +} // namespace boost + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_RESPONSE_IPP_20111206 diff --git a/boost/network/protocol/http/response/response_base.hpp b/boost/network/protocol/http/response/response_base.hpp index e6c4597a9..5d865b5b2 100644 --- a/boost/network/protocol/http/response/response_base.hpp +++ b/boost/network/protocol/http/response/response_base.hpp @@ -12,9 +12,12 @@ namespace boost { namespace network { namespace http { struct response_base : message_base { - virtual void set_status(std::string const & new_status) = 0; + virtual void set_status(boost::uint16_t new_status) = 0; virtual void set_status_message(std::string const & new_status_message) = 0; virtual void set_version(std::string const & new_version) = 0; + virtual void get_status(boost::uint16_t &status) const = 0; + virtual void get_status_message(std::string &status_message) const = 0; + virtual void get_version(std::string &version) const = 0; virtual ~response_base() = 0; }; diff --git a/libs/network/src/http/response.cpp b/libs/network/src/http/response.cpp index 0989e5f70..5fcd7c347 100644 --- a/libs/network/src/http/response.cpp +++ b/libs/network/src/http/response.cpp @@ -9,3 +9,4 @@ #endif #include +#include From b59dcc54bec12b1595f65777b9a008fb6f22e0d0 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Thu, 8 Dec 2011 23:51:25 +1100 Subject: [PATCH 038/196] Progress: Client Constructor Test now Builds! After some re-modeling of the internal implementation of the response object as well as the interface used for initializing the promises, now the client constructor test finally builds! This means most (not all) of the request and response methods required just to instantiate an HTTP client instance is ready for the linking. Much more work to be done to: 1) Re-work and simplify the other tests. 2) Mock the delegates and remove reliance on actual external testing that needs a network connection. 3) Make the request and response objects actually work. This is a tall order just because of the sheer amount of code required to make this happen. 4) Make the request and response objects more efficient in its use of memory and synchronization primitives. I have doubts on the efficiency and effectiveness of using futures for the data but this seems to be the most straight-forward approach for the meantime. Sounds like a lot of work to do but hopefully it's not as hard as it reads. --- .../http/client/connection/async_normal.ipp | 25 ++++----- boost/network/protocol/http/impl/access.hpp | 14 ++--- boost/network/protocol/http/impl/access.ipp | 30 +++++----- .../protocol/http/request/request_base.ipp | 4 ++ .../protocol/http/response/response.hpp | 14 ++--- .../protocol/http/response/response.ipp | 56 +++++++------------ 6 files changed, 66 insertions(+), 77 deletions(-) diff --git a/boost/network/protocol/http/client/connection/async_normal.ipp b/boost/network/protocol/http/client/connection/async_normal.ipp index 285d742f0..73d01e85b 100644 --- a/boost/network/protocol/http/client/connection/async_normal.ipp +++ b/boost/network/protocol/http/client/connection/async_normal.ipp @@ -86,13 +86,12 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thissource_promise = accessor.get_source_promise(r); - this->destination_promise = accessor.get_destination_promise(r); - this->headers_promise = accessor.get_headers_promise(r); - this->body_promise = accessor.get_body_promise(r); - this->version_promise = accessor.get_version_promise(r); - this->status_promise = accessor.get_status_promise(r); - this->status_message_promise = accessor.get_status_message_promise(r); + accessor.set_source_promise(r, this->source_promise); + accessor.set_destination_promise(r, this->destination_promise); + accessor.set_headers_promise(r, this->headers_promise); + accessor.set_body_promise(r, this->body_promise); + accessor.set_version_promise(r, this->version_promise); + accessor.set_status_message_promise(r, this->status_message_promise); } void set_errors(boost::system::error_code const & ec) { @@ -392,16 +391,16 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisdestination_promise.set_exception(boost::copy_exception(error)); switch (state) { case version: -// this->version_promise.set_exception(boost::copy_exception(error)); + this->version_promise.set_exception(boost::copy_exception(error)); case status: -// this->status_promise.set_exception(boost::copy_exception(error)); + this->status_promise.set_exception(boost::copy_exception(error)); case status_message: -// this->status_message_promise.set_exception(boost::copy_exception(error)); + this->status_message_promise.set_exception(boost::copy_exception(error)); case headers: -// this->headers_promise.set_exception(boost::copy_exception(error)); + this->headers_promise.set_exception(boost::copy_exception(error)); case body: -// this->body_promise.set_exception(boost::copy_exception(error)); -// break; + this->body_promise.set_exception(boost::copy_exception(error)); + break; default: BOOST_ASSERT(false && "Bug, report this to the developers!"); } diff --git a/boost/network/protocol/http/impl/access.hpp b/boost/network/protocol/http/impl/access.hpp index f32bfd661..ea38f56f6 100644 --- a/boost/network/protocol/http/impl/access.hpp +++ b/boost/network/protocol/http/impl/access.hpp @@ -16,13 +16,13 @@ struct response; namespace impl { struct setter_access { - promise get_version_promise(response &r); - promise get_status_promise(response &r); - promise get_status_message_promise(response &r); - promise > get_headers_promise(response &r); - promise get_source_promise(response &r); - promise get_destination_promise(response &r); - promise get_body_promise(response &r); + void set_version_promise(response &r, promise &p); + void set_status_promise(response &r, promise &p); + void set_status_message_promise(response &r, promise&p); + void set_headers_promise(response &r, promise > &p); + void set_source_promise(response &r, promise &p); + void set_destination_promise(response &r, promise &p); + void set_body_promise(response &r, promise &p); }; } // namespace impl diff --git a/boost/network/protocol/http/impl/access.ipp b/boost/network/protocol/http/impl/access.ipp index 944d4d2b7..752f48d8f 100644 --- a/boost/network/protocol/http/impl/access.ipp +++ b/boost/network/protocol/http/impl/access.ipp @@ -5,33 +5,33 @@ namespace boost { namespace network { namespace http { namespace impl { -promise setter_access::get_version_promise(response &r) { - return r.get_version_promise(); +void setter_access::set_version_promise(response &r, promise &p) { + return r.set_version_promise(p); } -promise setter_access::get_status_promise(response &r) { - return r.get_status_promise(); +void setter_access::set_status_promise(response &r, promise &p) { + return r.set_status_promise(p); } -promise setter_access::get_status_message_promise(response &r) { - return r.get_status_message_promise(); +void setter_access::set_status_message_promise(response &r, promise &p) { + return r.set_status_message_promise(p); } -promise > -setter_access::get_headers_promise(response &r) { - return r.get_headers_promise(); +void +setter_access::set_headers_promise(response &r, promise > &p) { + return r.set_headers_promise(p); } -promise setter_access::get_source_promise(response &r) { - return r.get_source_promise(); +void setter_access::set_source_promise(response &r, promise &p) { + return r.set_source_promise(p); } -promise setter_access::get_destination_promise(response &r) { - return r.get_destination_promise(); +void setter_access::set_destination_promise(response &r, promise &p) { + return r.set_destination_promise(p); } -promise setter_access::get_body_promise(response &r) { - return r.get_body_promise(); +void setter_access::set_body_promise(response &r, promise &p) { + return r.set_body_promise(p); } } // namespace impl diff --git a/boost/network/protocol/http/request/request_base.ipp b/boost/network/protocol/http/request/request_base.ipp index 5209ffacf..b556b7583 100644 --- a/boost/network/protocol/http/request/request_base.ipp +++ b/boost/network/protocol/http/request/request_base.ipp @@ -14,6 +14,10 @@ namespace boost { namespace network { namespace http { request_base::~request_base() { // default implementation, only required for linking. } + +request_storage_base::~request_storage_base() { + // default implementation, only required for linking. +} } /* http */ diff --git a/boost/network/protocol/http/response/response.hpp b/boost/network/protocol/http/response/response.hpp index 8855122d1..f5c78fbef 100644 --- a/boost/network/protocol/http/response/response.hpp +++ b/boost/network/protocol/http/response/response.hpp @@ -60,13 +60,13 @@ struct response : response_base { friend class impl::setter_access; // Hide access through accessor class. // These methods are unique to the response type which will allow for creating // promises that can be set appropriately. - promise get_version_promise(); - promise get_status_promise(); - promise get_status_message_promise(); - promise > get_headers_promise(); - promise get_source_promise(); - promise get_destination_promise(); - promise get_body_promise(); + void set_version_promise(promise&); + void set_status_promise(promise&); + void set_status_message_promise(promise&); + void set_headers_promise(promise >&); + void set_source_promise(promise&); + void set_destination_promise(promise&); + void set_body_promise(promise&); scoped_ptr pimpl_; }; diff --git a/boost/network/protocol/http/response/response.ipp b/boost/network/protocol/http/response/response.ipp index 62db26844..570d33f09 100644 --- a/boost/network/protocol/http/response/response.ipp +++ b/boost/network/protocol/http/response/response.ipp @@ -145,53 +145,39 @@ struct response_pimpl { } } - promise get_source_promise() { - promise promise_; + void set_source_promise(promise &promise_) { unique_future tmp_future = promise_.get_future(); source_future_ = move(tmp_future); - return move(promise_); } - promise get_destination_promise() { - promise promise_; + void set_destination_promise(promise &promise_) { unique_future tmp_future = promise_.get_future(); destination_future_ = move(tmp_future); - return move(promise_); } - promise > get_headers_promise() { - promise > promise_; + void set_headers_promise(promise > &promise_) { unique_future > tmp_future = promise_.get_future(); headers_future_ = move(tmp_future); - return promise_; } - promise get_status_promise() { - promise promise_; + void set_status_promise(promise &promise_) { unique_future tmp_future = promise_.get_future(); status_future_ = move(tmp_future); - return promise_; } - promise get_status_message_promise() { - promise promise_; + void set_status_message_promise(promise &promise_) { unique_future tmp_future = promise_.get_future(); status_message_future_ = move(tmp_future); - return promise_; } - promise get_version_promise() { - promise promise_; + void set_version_promise(promise &promise_) { unique_future tmp_future = promise_.get_future(); version_future_ = move(tmp_future); - return promise_; } - promise get_body_promise() { - promise promise_; + void set_body_promise(promise &promise_) { unique_future tmp_future = promise_.get_future(); body_future_ = move(tmp_future); - return promise_; } private: @@ -307,32 +293,32 @@ void response::get_version(std::string &version) const { response::~response() {} -promise response::get_version_promise() { - return pimpl_->get_version_promise(); +void response::set_version_promise(promise &promise) { + return pimpl_->set_version_promise(promise); } -promise response::get_status_promise() { - return pimpl_->get_status_promise(); +void response::set_status_promise(promise &promise) { + return pimpl_->set_status_promise(promise); } -promise response::get_status_message_promise() { - return pimpl_->get_status_message_promise(); +void response::set_status_message_promise(promise &promise) { + return pimpl_->set_status_message_promise(promise); } -promise > response::get_headers_promise() { - return pimpl_->get_headers_promise(); +void response::set_headers_promise(promise > &promise) { + return pimpl_->set_headers_promise(promise); } -promise response::get_source_promise() { - return pimpl_->get_source_promise(); +void response::set_source_promise(promise &promise) { + return pimpl_->set_source_promise(promise); } -promise response::get_destination_promise() { - return pimpl_->get_destination_promise(); +void response::set_destination_promise(promise &promise) { + return pimpl_->set_destination_promise(promise); } -promise response::get_body_promise() { - return pimpl_->get_body_promise(); +void response::set_body_promise(promise &promise) { + return pimpl_->set_body_promise(promise); } } // namespace http From df8eb44a2ced74b09021bdce7e96c1ad85f95321 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Wed, 14 Dec 2011 23:56:05 +1100 Subject: [PATCH 039/196] Baby steps: request implementation. In order to move on to getting the other tests to build, the request implementation needs to get to a point where it's building as well. --- .../http/message/directives/major_version.hpp | 27 ++++++------------ .../network/protocol/http/request/request.hpp | 14 ++++------ .../network/protocol/http/request/request.ipp | 28 ++++++++++++++++++- libs/network/src/http/request.cpp | 1 + .../http/client_get_different_port_test.cpp | 19 ++++++------- 5 files changed, 51 insertions(+), 38 deletions(-) diff --git a/boost/network/protocol/http/message/directives/major_version.hpp b/boost/network/protocol/http/message/directives/major_version.hpp index dc83f46ba..55abe29bd 100644 --- a/boost/network/protocol/http/message/directives/major_version.hpp +++ b/boost/network/protocol/http/message/directives/major_version.hpp @@ -6,29 +6,20 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include #include namespace boost { namespace network { namespace http { - template - struct basic_request; +struct major_version_directive { + boost::uint8_t major_version; + explicit major_version_directive(boost::uint8_t major_version); + void operator()(request_base &request) const; +}; - struct major_version_directive { - boost::uint8_t major_version; - explicit major_version_directive(boost::uint8_t major_version) - : major_version(major_version) {} - template - void operator()(basic_request & request) const { - request.http_version_major = major_version; - } - }; - - inline major_version_directive - major_version(boost::uint8_t major_version_) { - return major_version_directive(major_version_); - } +inline major_version_directive +major_version(boost::uint8_t major_version_) { + return major_version_directive(major_version_); +} } /* http */ diff --git a/boost/network/protocol/http/request/request.hpp b/boost/network/protocol/http/request/request.hpp index 549aefeca..7861882b5 100644 --- a/boost/network/protocol/http/request/request.hpp +++ b/boost/network/protocol/http/request/request.hpp @@ -8,8 +8,10 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include #include +#include +#include +#include namespace boost { namespace network { namespace http { @@ -20,8 +22,8 @@ struct request : request_base { // We support full value semantics. request(); - explicit request(std::string url); - explicit request(uri::uri url); + explicit request(std::string const & url); + explicit request(uri::uri const & url); request(request const &); request& operator=(request); void swap(request & other); @@ -65,7 +67,7 @@ struct request : request_base { virtual ~request(); private: - request_pimpl * pimpl_; + scoped_ptr pimpl_; }; template @@ -96,8 +98,4 @@ inline void swap(request &l, request &r) { #include #include -#ifdef BOOST_NETWORK_DEBUG -BOOST_CONCEPT_ASSERT((boost::network::http::ClientRequest)); -#endif - #endif /* BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_REQUEST_HPP_20111021 */ diff --git a/boost/network/protocol/http/request/request.ipp b/boost/network/protocol/http/request/request.ipp index d34cb7581..1b4be0263 100644 --- a/boost/network/protocol/http/request/request.ipp +++ b/boost/network/protocol/http/request/request.ipp @@ -7,6 +7,32 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// TODO Implement the basic request proxy! +#include +#include + +#ifdef BOOST_NETWORK_DEBUG +BOOST_CONCEPT_ASSERT((boost::network::http::ClientRequest)); +#endif + +namespace boost { namespace network { namespace http { + +struct request_pimpl { + explicit request_pimpl(std::string const & url) {} +}; + +request::~request() { + // Do nothing here. +} + +request::request(std::string const & url) +: pimpl_(new request_pimpl(url)) +{} + + +} // namespace http + +} // namespace network + +} // namespace boost #endif /* BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_IPP_20110910 */ diff --git a/libs/network/src/http/request.cpp b/libs/network/src/http/request.cpp index a1f1ff481..4a22cc2de 100644 --- a/libs/network/src/http/request.cpp +++ b/libs/network/src/http/request.cpp @@ -8,6 +8,7 @@ #undef BOOST_NETWORK_NO_LIB #endif +#include #include #include #include diff --git a/libs/network/test/http/client_get_different_port_test.cpp b/libs/network/test/http/client_get_different_port_test.cpp index 9feee918f..81bcb4716 100644 --- a/libs/network/test/http/client_get_different_port_test.cpp +++ b/libs/network/test/http/client_get_different_port_test.cpp @@ -7,17 +7,14 @@ #define BOOST_TEST_MODULE HTTP Client Get Different Port Test #include #include -#include "client_types.hpp" -namespace net = boost::network; -namespace http = boost::network::http; - -BOOST_AUTO_TEST_CASE_TEMPLATE(http_get_test_different_port, client, client_types) { - typename client::request request("http://www.boost.org/"); - client client_; - typename client::response response_ = client_.get(request); - typename net::headers_range::type range = headers(response_)["Content-Type"]; - BOOST_CHECK ( boost::begin(range) != boost::end(range) ); - BOOST_CHECK ( body(response_).size() != 0 ); +BOOST_AUTO_TEST_CASE(http_get_test_different_port) { + using namespace boost::network::http; + request request_("http://www.boost.org/"); + client client_; + response response_ = client_.get(request_); + boost::network::headers_wrapper::range_type headers_ = headers(response_)["Content-Type"]; + BOOST_CHECK( boost::begin(headers_) != boost::end(headers_) ); + BOOST_CHECK( body(response_).size() > 0 ); } From 19f108ebc853d3e882103fcf0a238694fb8cdf5b Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sun, 4 Mar 2012 14:48:33 +1100 Subject: [PATCH 040/196] WIP: Removing dependency on Boost.Parameter. --- boost/network/protocol/http/client.hpp | 48 ++--- .../http/client/connection/ssl_delegate.ipp | 4 +- boost/network/protocol/http/client/facade.hpp | 175 +++--------------- boost/network/protocol/http/client/facade.ipp | 93 ++++++++++ .../network/protocol/http/client/options.hpp | 147 +++++++++++++++ .../network/protocol/http/client/options.ipp | 157 ++++++++++++++++ .../protocol/http/response/response.hpp | 2 +- libs/network/src/http/client.cpp | 2 + .../test/http/client_constructor_test.cpp | 35 ++-- libs/network/test/http/client_get_test.cpp | 47 +++-- .../test/http/client_get_timeout_test.cpp | 11 +- 11 files changed, 483 insertions(+), 238 deletions(-) create mode 100644 boost/network/protocol/http/client/facade.ipp create mode 100644 boost/network/protocol/http/client/options.hpp create mode 100644 boost/network/protocol/http/client/options.ipp diff --git a/boost/network/protocol/http/client.hpp b/boost/network/protocol/http/client.hpp index 41ae22bc7..38f975349 100644 --- a/boost/network/protocol/http/client.hpp +++ b/boost/network/protocol/http/client.hpp @@ -1,12 +1,14 @@ #ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_20091215 #define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_20091215 -// Copyright Dean Michael Berris 2007-2010. +// Copyright 2012 Dean Michael Berris . +// Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) #include +#include #include #include @@ -27,43 +29,15 @@ struct client : basic_client_facade { // Constructor // ================================================================= - // This is a Boost.Parameter-based constructor forwarder, whose - // implementation is actually forwarded to the base type. + // A client can be default constructed. + client(); + // This is a simplified constructor that takes a reference to a const + // client_options instance. To find out what the supported options are + // see the boost/network/protocol/http/client/options.hpp file. // - // The supported parameters are: - // _follow_redirects : bool -- whether to follow HTTP redirect - // responses (default: false) - // _cache_resolved : bool -- whether to cache the resolved - // endpoints (default: false) - // _io_service : boost::asio::io_service & - // -- supply an io_service to the - // client - // _openssl_certificate : string - // -- the name of the certificate file - // to use - // _openssl_verify_path : string - // -- the name of the directory from - // which the certificate authority - // files can be found - // _connection_manager : shared_ptr - // -- The connection manager to use for - // this client. - - BOOST_PARAMETER_CONSTRUCTOR( - client, (base_facade_type), tag, - (optional - (in_out(io_service), (boost::asio::io_service&)) - (follow_redirects, (bool)) - (cache_resolved, (bool)) - (openssl_certificate, (std::string)) - (openssl_verify_path, (std::string)) - (connection_manager, (shared_ptr)) - (connection_factory, (shared_ptr)) - )) - + explicit client(client_options const &options); // // ================================================================= - }; } // namespace http diff --git a/boost/network/protocol/http/client/connection/ssl_delegate.ipp b/boost/network/protocol/http/client/connection/ssl_delegate.ipp index 0aa39db67..bdf53d7c4 100755 --- a/boost/network/protocol/http/client/connection/ssl_delegate.ipp +++ b/boost/network/protocol/http/client/connection/ssl_delegate.ipp @@ -33,8 +33,8 @@ void boost::network::http::ssl_delegate::connect( socket_.reset(new asio::ssl::stream(service_, *context_)); socket_->lowest_layer().async_connect( endpoint, - ::boost::bind(&boost::network::http::impl::ssl_delegate::handle_connected, - boost::network::http::impl::ssl_delegate::shared_from_this(), + ::boost::bind(&boost::network::http::ssl_delegate::handle_connected, + boost::network::http::ssl_delegate::shared_from_this(), asio::placeholders::error, handler)); } diff --git a/boost/network/protocol/http/client/facade.hpp b/boost/network/protocol/http/client/facade.hpp index ee6113222..5a555ebe3 100644 --- a/boost/network/protocol/http/client/facade.hpp +++ b/boost/network/protocol/http/client/facade.hpp @@ -9,170 +9,37 @@ #include #include #include -#include -#include -#include +#include namespace boost { namespace network { namespace http { struct basic_client_facade { typedef client_base::body_callback_function_type body_callback_function_type; - template - basic_client_facade(ArgPack const & args) { - init_base(args, - typename mpl::if_< - is_same< - typename parameter::value_type::type, - void - >, - no_io_service, - has_io_service - >::type()); - } + basic_client_facade(client_options const &options); + + response const head(request const &request, request_options const&options=request_options()); + response const get(request const &request, + body_callback_function_type body_handler = body_callback_function_type(), + request_options const &options=request_options()); + response const post(request request, + optional body = optional(), + optional content_type = optional(), + body_callback_function_type body_handler = body_callback_function_type(), + request_options const&options = request_options()); + response const put(request request, + optional body = optional(), + optional content_type = optional(), + body_callback_function_type body_handler = body_callback_function_type(), + request_options const & options = request_options()); + response const delete_(request const & request, + body_callback_function_type body_handler = body_callback_function_type(), + request_options const & options = request_options()); + void clear_resolved_cache(); - BOOST_PARAMETER_MEMBER_FUNCTION((response const), head, tag, (required (request,(request const &)))) { - return base->request_skeleton(request, "HEAD", false, body_callback_function_type()); - } - - BOOST_PARAMETER_MEMBER_FUNCTION((response const), get , tag, - (required - (request,(request const &)) - ) - (optional - (body_handler,(body_callback_function_type),body_callback_function_type()) - )) { - return base->request_skeleton(request, "GET", true, body_handler); - } - - BOOST_PARAMETER_MEMBER_FUNCTION((response const), post, tag, - (required - (request,(request)) // yes sir, we make a copy of the original request. - ) - (optional - (body,(std::string const &),std::string()) - (content_type,(std::string const &),std::string()) - (body_handler,(body_callback_function_type),body_callback_function_type()) - )) { - if (body.size()) { - request << remove_header("Content-Length") - << header("Content-Length", boost::lexical_cast(body.size())) - << boost::network::body(body); - } - - std::multimap content_type_headers = - headers(request)["Content-Type"]; - if (content_type.size()) { - if (!boost::empty(content_type_headers)) - request << remove_header("Content-Type"); - request << header("Content-Type", content_type); - } else { - if (boost::empty(content_type_headers)) { - static char content_type[] = "x-application/octet-stream"; - request << header("Content-Type", content_type); - } - } - return base->request_skeleton(request, "POST", true, body_handler); - } - - BOOST_PARAMETER_MEMBER_FUNCTION((response const), put , tag, - (required - (request,(request)) // yes sir, we make a copy of the original request. - ) - (optional - (body,(std::string const &),std::string()) - (content_type,(std::string const &),std::string()) - (body_handler,(body_callback_function_type),body_callback_function_type()) - )) { - if (body != std::string()) { - request << remove_header("Content-Length") - << header("Content-Length", boost::lexical_cast(body.size())) - << boost::network::body(body); - } - - std::multimap content_type_headers = - headers(request)["Content-Type"]; - if (content_type.size()) { - if (!boost::empty(content_type_headers)) - request << remove_header("Content-Type"); - request << header("Content-Type", content_type); - } else { - if (boost::empty(content_type_headers)) { - static char content_type[] = "x-application/octet-stream"; - request << header("Content-Type", content_type); - } - } - return base->request_skeleton(request, "PUT", true, body_handler); - } - - BOOST_PARAMETER_MEMBER_FUNCTION((response const), delete_, tag, - (required - (request,(request const &)) - ) - (optional - (body_handler,(body_callback_function_type),body_callback_function_type()) - )) { - return base->request_skeleton(request, "DELETE", true, body_handler); - } - - void clear_resolved_cache() { - base->clear_resolved_cache(); - } protected: - - struct no_io_service {}; - struct has_io_service {}; - boost::scoped_ptr base; - - template - void init_base(ArgPack const & args, no_io_service) { - base.reset(new client_base( - this->get_connection_manager(args))); - } - - template - void init_base(ArgPack const & args, has_io_service) { - base.reset( - new client_base( - args[_io_service], - this->get_connection_manager(args))); - } - - private: - - template - shared_ptr get_connection_manager(ArgPack const & args) { - shared_ptr connection_manager_ = args[_connection_manager|shared_ptr()]; - if (!connection_manager_.get()) { - // Because there's no explicit connection manager, we use the default - // implementation. - connection_manager_.reset( - new (std::nothrow) simple_connection_manager( - args[_cache_resolved|false], - args[_follow_redirects|false], - args[_openssl_certificate|optional()], - args[_openssl_verify_path|optional()], - this->get_connection_factory(args))); - } - - return connection_manager_; - } - - template - shared_ptr get_connection_factory(ArgPack const & args) { - shared_ptr connection_factory_ = args[_connection_factory|shared_ptr()]; - if (!connection_factory_.get()) { - // Because there's no explicit connection factory, we use the default - // implementation. - connection_factory_.reset( - new (std::nothrow) simple_connection_factory()); - } - - return connection_factory_; - } - }; } // namespace http diff --git a/boost/network/protocol/http/client/facade.ipp b/boost/network/protocol/http/client/facade.ipp new file mode 100644 index 000000000..7475a8ab7 --- /dev/null +++ b/boost/network/protocol/http/client/facade.ipp @@ -0,0 +1,93 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_FACADE_IPP_20120303 +#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_FACADE_IPP_20120303 + +#include + +namespace boost { namespace network { namespace http { + +response const basic_client_facade::head(request const &request, + request_options const&options) { + return base->request_skeleton(request, + "HEAD", + false, + body_callback_function_type(), + options); +} + +response const basic_client_facade::get(request const &request, + body_callback_function_type body_handler, + request_options const &options) { + return base->request_skeleton(request, "GET", true, body_handler, options); +} + +response const basic_client_facade::post(request request, + optional body, + optional content_type, + body_callback_function_type body_handler, + request_options const &options) { + if (body) { + request << remove_header("Content-Length") + << header("Content-Length", boost::lexical_cast(body->size())) + << boost::network::body(*body); + } + + std::multimap content_type_headers = + headers(request)["Content-Type"]; + if (content_type) { + if (!boost::empty(content_type_headers)) + request << remove_header("Content-Type"); + request << header("Content-Type", *content_type); + } else { + if (boost::empty(content_type_headers)) { + static char default_content_type[] = "x-application/octet-stream"; + request << header("Content-Type", default_content_type); + } + } + return base->request_skeleton(request, "POST", true, body_handler, options); +} + +response const basic_client_facade::put(request request, + optional body, + optional content_type, + body_callback_function_type body_handler, + request_options const & options) { + if (body) { + request << remove_header("Content-Length") + << header("Content-Length", boost::lexical_cast(body->size())) + << boost::network::body(*body); + } + + std::multimap content_type_headers = + headers(request)["Content-Type"]; + if (content_type) { + if (!boost::empty(content_type_headers)) + request << remove_header("Content-Type"); + request << header("Content-Type", *content_type); + } else { + if (boost::empty(content_type_headers)) { + static char default_content_type[] = "x-application/octet-stream"; + request << header("Content-Type", default_content_type); + } + } + return base->request_skeleton(request, "PUT", true, body_handler); +} + +response const basic_client_facade::delete_(request const & request, + body_callback_function_type body_handler, + request_options const & options) { + return base->request_skeleton(request, "DELETE", true, body_handler); +} + +void basic_client_facade::clear_resolved_cache() { + base->clear_resolved_cache(); +} + +} // namespace http + +} // namespace network + +} // namespace boost + + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_FACADE_IPP_20120303 + diff --git a/boost/network/protocol/http/client/options.hpp b/boost/network/protocol/http/client/options.hpp new file mode 100644 index 000000000..4450f8a8c --- /dev/null +++ b/boost/network/protocol/http/client/options.hpp @@ -0,0 +1,147 @@ +// Copyright Dean Michael Berris 2012. +// Copyright Google, Inc. 2012. +// 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 BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_OPTIONS_HPP +#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_OPTIONS_HPP + +#include +#include +#include +#include +#include +#include + +namespace boost { namespace network { namespace http { + + // Forward-declare the pimpl. + class client_options_pimpl; + + // This file defines all the options supported by the HTTP client + // implementation. + class client_options { + public: + client_options(); + client_options(client_options const &other); // Copy constructible. + client_options& operator=(client_options rhs); // Assignable. + void swap(client_options &other); // Swappable. + ~client_options(); // Non-virtual destructor by design. + + // When adding more supported options, follow the pattern: + // + // client_options& name_of_option(type variable); + // type name_of_option() const; + // + // These names have to be self-documenting but should still be documented + // to signify their intent and reason for being an option. The reason for + // returning a client_options& (usually *this) is so that it the operations + // can be chained properly. An example of usage would be: + // + // client_options options; + // options.io_service(&my_io_service) + // .follow_redirects() + // .cache_resolved(); + // client client_(options); + + // These are the setter and getter for the Boost.Asio io_service to use. + // The default setting when un-set is nullptr, meaning it signals the client + // implementation that the user doesn't want to use his own io_service + // instance. + client_options& io_service(asio::io_service *io_service); + asio::io_service* io_service() const; + + // The following option determines whether the client should follow + // HTTP redirects when the implementation encounters them. The default + // behavior is to return false. + client_options& follow_redirects(bool setting=false); + bool follow_redirects() const; + + // The following options determines whether the client should cache + // resolved endpoints. The default behavior is to not cache resolved + // endpoints. + client_options& cache_resolved(bool setting=true); + bool cache_resolved() const; + + // The following options provide the OpenSSL certificate paths to use. + // Setting these options without OpenSSL support is valid, but the client + // may throw an exception when attempting to make SSL connections. The + // default implementation doesn't define certificate paths. + client_options& add_openssl_certificate_path(std::string const &path); + std::list const & openssl_certificate_paths() const; + + // The following options provide the OpenSSL certificate authority paths + // where the certificates can be found. Setting these options without OpenSSL + // support is valid, but the client may throw an exception when attempting + // to make SSL connections. The default implementation doesn't define + // certificate authority paths. + client_options& add_openssl_verify_path(std::string const &path); + std::list const & openssl_verify_paths() const; + + // The following options provide the connection manager shared pointer that + // is what the client will use to manage connections. + client_options& connection_manager(shared_ptr manager); + shared_ptr connection_manager() const; + + // The following supports providing the connection factory instance responsible + // for creating the correct instances of the appropriate connection. + client_options& connection_factory(shared_ptr factory); + shared_ptr connection_factory() const; + + // More options go here... + + private: + // We hide the options in a pimpl, so that when new options get added + // we can keep backward binary compatibility and re-link to the new + // supported options without having to break those + client_options_pimpl *pimpl; + }; + + // Forward declare the request_options pimpl. + class request_options_pimpl; + + // This is the per-request options we allow users to provide. These allow + // for defining operational options that control a request's flow. + class request_options { + public: + request_options(); // Default constructor. + request_options(request_options const &other); // Copy constructible. + request_options& operator=(request_options rhs); // Assignable. + void swap(request_options &other); // Swappable. + ~request_options(); // Non-virtual destructor by design. + + // We follow the same pattern as the client_options class and use the + // chaining call pattern to set the options. When adding new options + // to support, they should look roughly like so: + // + // request_options& name_of_option(type_of_option variable=default_value); + // type_of_option name_of_option() const; + // + // See client_options above for a usage example in the same vein. + + // These determine the timeout when performing requests. The default timeout + // is 30,000 milliseconds (30 seconds). + request_options& timeout(uint64_t milliseconds = 30 * 1000); + uint64_t timeout() const; + + // These determine the maximum number of redirects to follow. The default + // implementation uses 10 as the maximum. A negative value means to keep + // following redirects until they no longer redirect. + request_options& max_redirects(int redirects=10); + int max_redirects() const; + + // More options go here... + + private: + // For the same reason as the client_options being a pimpl, we do this for + // minimizing the need to break ABI compatibility when adding new supported + // options. + request_options_pimpl *pimpl; + }; + +} // namespace http +} // namespace network +} // namespace boost + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_OPTIONS_HPP diff --git a/boost/network/protocol/http/client/options.ipp b/boost/network/protocol/http/client/options.ipp new file mode 100644 index 000000000..83a691c5d --- /dev/null +++ b/boost/network/protocol/http/client/options.ipp @@ -0,0 +1,157 @@ +// Copyright Dean Michael Berris 2012. +// Copyright Google, Inc. 2012. +// 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 BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_OPTIONS_IPP +#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_OPTIONS_IPP + +#include + +namespace boost { namespace network { namespace http { + +class client_options_pimpl { +public: + client_options_pimpl() + : io_service_(0) + , follow_redirects_(false) + , cache_resolved_(false) + , openssl_certificate_paths_() + , openssl_verify_paths_() + {} + + client_options_pimpl *clone() const { + return new (std::nothrow) client_options_pimpl(*this); + } + + void io_service(asio::io_service *io_service) { + io_service_ = io_service_; + } + + asio::io_service* io_service() const { + return io_service_; + } + + void follow_redirects(bool setting) { + follow_redirects_ = setting; + } + + bool follow_redirects() const { + return follow_redirects_; + } + + void cache_resolved(bool setting) { + cache_resolved_ = setting; + } + + bool cache_resolved() const { + return cache_resolved_; + } + + void add_openssl_certificate_path(std::string const &path) { + openssl_certificate_paths_.push_back(path); + } + + std::list const & openssl_certificate_paths() const { + return openssl_certificate_paths_; + } + + void add_openssl_verify_path(std::string const &path) { + openssl_verify_paths_.push_back(path); + } + + std::list const & openssl_verify_paths() const { + return openssl_verify_paths_; + } + +private: + client_options_pimpl(client_options_pimpl const &other) + : io_service_(other.io_service_) + , follow_redirects_(other.follow_redirects_) + , cache_resolved_(other.cache_resolved_) + , openssl_certificate_paths_(other.openssl_certificate_paths_) + , openssl_verify_paths_(other.openssl_verify_paths_) + {} + + client_options_pimpl& operator=(client_options_pimpl); // cannot assign + + // Here's the list of members. + asio::io_service *io_service_; + bool follow_redirects_, cache_resolved_; + std::list openssl_certificate_paths_, openssl_verify_paths_; +}; + +client_options::client_options() +: pimpl(new (std::nothrow) client_options_pimpl()) +{} + +client_options::client_options(client_options const &other) +: pimpl(other.pimpl->clone()) +{} + +client_options& client_options::operator=(client_options rhs) { + rhs.swap(*this); + return *this; +} + +void client_options::swap(client_options &other) { + std::swap(other.pimpl, this->pimpl); +} + +client_options::~client_options() { + delete pimpl; + pimpl = 0; +} + +client_options& client_options::io_service(asio::io_service *io_service) { + pimpl->io_service(io_service); + return *this; +} + +asio::io_service* client_options::io_service() const { + return pimpl->io_service(); +} + +client_options& client_options::follow_redirects(bool follow_redirects) { + pimpl->follow_redirects(follow_redirects); + return *this; +} + +bool client_options::follow_redirects() const { + return pimpl->follow_redirects(); +} + +client_options& client_options::cache_resolved(bool cache_resolved) { + pimpl->cache_resolved(cache_resolved); + return *this; +} + +bool client_options::cache_resolved() const { + return pimpl->cache_resolved(); +} + +client_options& client_options::add_openssl_certificate_path(std::string const &path) { + pimpl->add_openssl_certificate_path(path); + return *this; +} + +std::list const & client_options::openssl_certificate_paths() const { + return pimpl->openssl_certificate_paths(); +} + +client_options& client_options::add_openssl_verify_path(std::string const &path) { + pimpl->add_openssl_verify_path(path); + return *this; +} + +std::list const & client_options::openssl_verify_paths() const { + return pimpl->openssl_verify_paths(); +} + +} // namespace http +} // namespace network +} // namespace boost + + +#endif diff --git a/boost/network/protocol/http/response/response.hpp b/boost/network/protocol/http/response/response.hpp index f5c78fbef..102fea908 100644 --- a/boost/network/protocol/http/response/response.hpp +++ b/boost/network/protocol/http/response/response.hpp @@ -57,7 +57,7 @@ struct response : response_base { virtual ~response(); private: - friend class impl::setter_access; // Hide access through accessor class. + friend struct impl::setter_access; // Hide access through accessor class. // These methods are unique to the response type which will allow for creating // promises that can be set appropriately. void set_version_promise(promise&); diff --git a/libs/network/src/http/client.cpp b/libs/network/src/http/client.cpp index fe421c53d..ee271614b 100644 --- a/libs/network/src/http/client.cpp +++ b/libs/network/src/http/client.cpp @@ -9,3 +9,5 @@ #endif #include +#include +#include diff --git a/libs/network/test/http/client_constructor_test.cpp b/libs/network/test/http/client_constructor_test.cpp index 0f764271a..71099a846 100644 --- a/libs/network/test/http/client_constructor_test.cpp +++ b/libs/network/test/http/client_constructor_test.cpp @@ -11,25 +11,18 @@ namespace http = boost::network::http; BOOST_AUTO_TEST_CASE(http_client_constructor_test) { - http::client instance; - boost::asio::io_service io_service; - http::client instance2(io_service); - http::client instance3(http::_io_service=io_service); -} - -BOOST_AUTO_TEST_CASE(http_cient_constructor_params_test) { - http::client instance( - http::_follow_redirects=true, - http::_cache_resolved=true - ); - boost::asio::io_service io_service; - http::client instance2( - http::_follow_redirects=true, - http::_io_service=io_service, - http::_cache_resolved=true - ); - http::client instance3( - http::_openssl_certificate="foo", - http::_openssl_verify_path="bar" - ); + // Here's the simplest way to construct a client. + http::client instance; + + // The next way we're supporting is actually to construct an options object + // that allows you to set options. This class replaces the Boost.Parameter + // based approach to a much simpler model that scales better. + http::client_options options; + boost::asio::io_service io_service; + options.io_service(&io_service) + .follow_redirects() + .cache_resolved() + .add_openssl_certificate_path("/dev/zero") + .add_openssl_verify_path("/dev/null"); + http::client instance2(options); } diff --git a/libs/network/test/http/client_get_test.cpp b/libs/network/test/http/client_get_test.cpp index 1a2b558b1..27723d056 100644 --- a/libs/network/test/http/client_get_test.cpp +++ b/libs/network/test/http/client_get_test.cpp @@ -6,33 +6,46 @@ #define BOOST_TEST_MODULE HTTP 1.0 Get Test #include #include -#include "client_types.hpp" namespace net = boost::network; namespace http = boost::network::http; -BOOST_AUTO_TEST_CASE_TEMPLATE(http_client_get_test, client, client_types) { - typename client::request request("http://www.boost.org/"); - client client_; - typename client::response response; +BOOST_AUTO_TEST_CASE(http_client_get_test) { + http::client::request request("http://www.boost.org/"); + http::client client_; + http::client::response response; BOOST_REQUIRE_NO_THROW ( response = client_.get(request) ); - typename net::headers_range::type range = headers(response)["Content-Type"]; - BOOST_CHECK ( !boost::empty(range) ); + std::multimap headers_ = net::headers(response); + BOOST_CHECK ( !boost::empty(headers_) ); BOOST_REQUIRE_NO_THROW ( BOOST_CHECK ( body(response).size() != 0 ) ); - BOOST_CHECK_EQUAL ( response.version().substr(0,7), std::string("HTTP/1.") ); - BOOST_CHECK_EQUAL ( response.status(), 200u ); - BOOST_CHECK_EQUAL ( response.status_message(), std::string("OK") ); + std::string version_, status_message_; + response.get_version(version_); + uint16_t status_; + response.get_status(status_); + response.get_status_message(status_message_); + BOOST_CHECK_EQUAL ( version_.substr(0,7), "HTTP/1."); + BOOST_CHECK_EQUAL ( status_, 200u ); + BOOST_CHECK_EQUAL ( status_message_, std::string("OK") ); } #ifdef BOOST_NETWORK_ENABLE_HTTPS -BOOST_AUTO_TEST_CASE_TEMPLATE(https_client_get_test, client, client_types) { - typename client::request request("https://www.google.com/"); - client client_; - typename client::response response_ = client_.get(request); - typename net::headers_range::type range = headers(response_)["Content-Type"]; - BOOST_CHECK ( boost::begin(range) != boost::end(range) ); - BOOST_CHECK( body(response_).size() != 0 ); +BOOST_AUTO_TEST_CASE(https_client_get_test) { + http::client::request request("https://www.google.com/"); + http::client client_; + http::client::response response; + BOOST_REQUIRE_NO_THROW ( response = client_.get(request) ); + std::multimap headers_ = net::headers(response); + BOOST_CHECK ( !boost::empty(headers_) ); + BOOST_REQUIRE_NO_THROW ( BOOST_CHECK ( body(response).size() != 0 ) ); + std::string version_, status_message_; + response.get_version(version_); + uint16_t status_; + response.get_status(status_); + response.get_status_message(status_message_); + BOOST_CHECK_EQUAL ( version_.substr(0,7), "HTTP/1."); + BOOST_CHECK_EQUAL ( status_, 200u ); + BOOST_CHECK_EQUAL ( status_message_, std::string("OK") ); } #endif diff --git a/libs/network/test/http/client_get_timeout_test.cpp b/libs/network/test/http/client_get_timeout_test.cpp index 4f8aa5e1b..d17c4813b 100644 --- a/libs/network/test/http/client_get_timeout_test.cpp +++ b/libs/network/test/http/client_get_timeout_test.cpp @@ -7,16 +7,15 @@ #define BOOST_TEST_MODULE HTTP Client Get Timeout Test #include #include -#include "client_types.hpp" namespace http = boost::network::http; -BOOST_AUTO_TEST_CASE_TEMPLATE(http_get_test_timeout_1_0, client, client_types) { - typename client::request request("http://localhost:12121/"); - typename client::response response_; - client client_; +BOOST_AUTO_TEST_CASE(http_get_test_timeout_1_0) { + http::client::request request("http://localhost:12121/"); + http::client::response response_; + http::client client_; boost::uint16_t port_ = port(request); - typename client::response::string_type temp; + std::string temp; BOOST_CHECK_EQUAL ( 12121, port_ ); BOOST_CHECK_THROW ( response_ = client_.get(request); temp = body(response_); , std::exception ); } From 9d492c3b865239b3f5e06b5e691e03a334bb360c Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sun, 4 Mar 2012 20:40:41 +1100 Subject: [PATCH 041/196] Introducing client_options and request_options. This commit makes changes to the API that moves the options setting to a different type to keep the client API relatively stable even across version releases supporting newer options. The intention is to keep the ABI stable as well as we add more supported features in the form of options in two levels: the client, and the request. The client_options type is meant to define options that affect the behavior of the constructed client and the connections it creates internally. The request_options on the other hand define per-request options pertaining to the HTTP implementation. This paves the way for supporting more optional modes and extensions that can and will be easily testable and turned on/off in a programmatic manner. --- boost/network/protocol/http/client/base.hpp | 12 ++-- boost/network/protocol/http/client/base.ipp | 53 ++++++---------- .../http/client/client_connection.hpp | 5 +- .../http/client/connection/async_normal.hpp | 3 +- .../http/client/connection/async_normal.ipp | 8 ++- .../connection_delegate_factory.hpp | 6 +- .../connection_delegate_factory.ipp | 7 +-- .../client/connection/connection_factory.hpp | 11 ++-- .../connection/simple_connection_factory.hpp | 5 +- .../connection/simple_connection_factory.ipp | 21 +++---- .../http/client/connection/ssl_delegate.hpp | 6 +- .../http/client/connection/ssl_delegate.ipp | 29 ++++++--- .../http/client/connection_manager.hpp | 5 +- boost/network/protocol/http/client/facade.ipp | 8 +-- .../network/protocol/http/client/options.hpp | 1 + .../http/client/simple_connection_manager.hpp | 49 +++------------ .../http/client/simple_connection_manager.ipp | 61 +++++-------------- 17 files changed, 112 insertions(+), 178 deletions(-) diff --git a/boost/network/protocol/http/client/base.hpp b/boost/network/protocol/http/client/base.hpp index a75823069..8344ecea6 100644 --- a/boost/network/protocol/http/client/base.hpp +++ b/boost/network/protocol/http/client/base.hpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include @@ -18,19 +17,22 @@ namespace boost { namespace network { namespace http { struct client_base_pimpl; +class request_options; + +class client_options; + struct client_base { typedef function const &, system::error_code const &)> body_callback_function_type; - client_base(shared_ptr connection_manager_); - client_base(asio::io_service & service, - shared_ptr connection_manager_); + explicit client_base(client_options const &options); ~client_base(); response const request_skeleton(request const & request_, std::string const & method, bool get_body, - body_callback_function_type callback); + body_callback_function_type callback, + request_options const &options); void clear_resolved_cache(); private: client_base_pimpl * pimpl; diff --git a/boost/network/protocol/http/client/base.ipp b/boost/network/protocol/http/client/base.ipp index 730bf1c7f..58aaa3bda 100644 --- a/boost/network/protocol/http/client/base.ipp +++ b/boost/network/protocol/http/client/base.ipp @@ -8,6 +8,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include +#include #include #include #include @@ -21,67 +22,52 @@ struct client_base_pimpl { typedef function const &, system::error_code const &)> body_callback_function_type; - client_base_pimpl(shared_ptr connection_manager_); - client_base_pimpl(asio::io_service & service, shared_ptr connection_manager_); + client_base_pimpl(client_options const &options); response const request_skeleton(request const & request_, std::string const & method, bool get_body, - body_callback_function_type callback); + body_callback_function_type callback, + request_options const &options); ~client_base_pimpl(); private: + client_options options_; boost::asio::io_service * service_ptr; - boost::asio::io_service & service_; boost::shared_ptr sentinel_; boost::shared_ptr lifetime_thread_; shared_ptr connection_manager_; }; -client_base::client_base(shared_ptr connection_manager_) -: pimpl(new (std::nothrow) client_base_pimpl(connection_manager_)) -{} - -client_base::client_base(asio::io_service & service, - shared_ptr connection_manager_) -: pimpl(new (std::nothrow) client_base_pimpl(service, connection_manager_)) +client_base::client_base(client_options const &options) +: pimpl(new (std::nothrow) client_base_pimpl(options)) {} response const client_base::request_skeleton(request const & request_, std::string const & method, bool get_body, - body_callback_function_type callback) { - return pimpl->request_skeleton(request_, method, get_body, callback); + body_callback_function_type callback, + request_options const &options) { + return pimpl->request_skeleton(request_, method, get_body, callback, options); } client_base::~client_base() { delete pimpl; } -client_base_pimpl::client_base_pimpl(shared_ptr connection_manager) - : service_ptr(new (std::nothrow) boost::asio::io_service), - service_(*service_ptr), - sentinel_(new (std::nothrow) boost::asio::io_service::work(service_)), - connection_manager_(connection_manager) +client_base_pimpl::client_base_pimpl(client_options const &options) + : options_(options), + service_ptr(options.io_service()), + sentinel_(new (std::nothrow) boost::asio::io_service::work(*service_ptr)), + connection_manager_(options.connection_manager()) { lifetime_thread_.reset(new (std::nothrow) boost::thread( boost::bind( &boost::asio::io_service::run, - &service_ + service_ptr ))); if (!lifetime_thread_.get()) BOOST_THROW_EXCEPTION(std::runtime_error("Cannot allocate client lifetime thread; not enough memory.")); } -client_base_pimpl::client_base_pimpl(boost::asio::io_service & service, - shared_ptr connection_manager) - : service_ptr(0), - service_(service), - sentinel_(new (std::nothrow) boost::asio::io_service::work(service_)), - connection_manager_(connection_manager) -{ - if (!sentinel_.get()) - BOOST_THROW_EXCEPTION(std::runtime_error("Cannot allocate sentinel; not enough memory.")); -} - client_base_pimpl::~client_base_pimpl() { sentinel_.reset(); @@ -97,12 +83,13 @@ response const client_base_pimpl::request_skeleton( request const & request_, std::string const & method, bool get_body, - body_callback_function_type callback + body_callback_function_type callback, + request_options const &options ) { shared_ptr connection_; - connection_ = connection_manager_->get_connection(service_, request_); - return connection_->send_request(method, request_, get_body, callback); + connection_ = connection_manager_->get_connection(*service_ptr, request_, options_); + return connection_->send_request(method, request_, get_body, callback, options); } } // namespace http diff --git a/boost/network/protocol/http/client/client_connection.hpp b/boost/network/protocol/http/client/client_connection.hpp index e161c93c2..d302fb5ec 100644 --- a/boost/network/protocol/http/client/client_connection.hpp +++ b/boost/network/protocol/http/client/client_connection.hpp @@ -15,6 +15,8 @@ namespace boost { namespace network { namespace http { +class request_options; + struct client_connection { typedef function const &, system::error_code const &)> @@ -22,7 +24,8 @@ struct client_connection { virtual response send_request(std::string const & method, request const & request, bool get_body, - callback_type callback) = 0; + callback_type callback, + request_options const &options) = 0; virtual client_connection * clone() const = 0; virtual void reset() = 0; virtual ~client_connection() = 0; diff --git a/boost/network/protocol/http/client/connection/async_normal.hpp b/boost/network/protocol/http/client/connection/async_normal.hpp index 3e44600d3..dd7459c5f 100644 --- a/boost/network/protocol/http/client/connection/async_normal.hpp +++ b/boost/network/protocol/http/client/connection/async_normal.hpp @@ -31,7 +31,8 @@ struct http_async_connection : client_connection virtual response send_request(std::string const & method, request const & request, bool get_body, - callback_type callback); // override + callback_type callback, + request_options const &options); // override virtual void reset(); // override virtual ~http_async_connection(); private: diff --git a/boost/network/protocol/http/client/connection/async_normal.ipp b/boost/network/protocol/http/client/connection/async_normal.ipp index 73d01e85b..57dadcacc 100644 --- a/boost/network/protocol/http/client/connection/async_normal.ipp +++ b/boost/network/protocol/http/client/connection/async_normal.ipp @@ -43,7 +43,8 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisinit_response(response_); // Use HTTP/1.1 -- at some point we might want to implement a different @@ -757,8 +758,9 @@ http_async_connection * http_async_connection::clone() const { response http_async_connection::send_request(std::string const & method, request const & request, bool get_body, - callback_type callback) { - return pimpl->start(request, method, get_body, callback); + callback_type callback, + request_options const &options) { + return pimpl->start(request, method, get_body, callback, options); } void http_async_connection::reset() { diff --git a/boost/network/protocol/http/client/connection/connection_delegate_factory.hpp b/boost/network/protocol/http/client/connection/connection_delegate_factory.hpp index d467615b4..47adc8190 100644 --- a/boost/network/protocol/http/client/connection/connection_delegate_factory.hpp +++ b/boost/network/protocol/http/client/connection/connection_delegate_factory.hpp @@ -12,18 +12,18 @@ namespace boost { namespace network { namespace http { +class client_options; + struct connection_delegate_factory { typedef shared_ptr connection_delegate_ptr; connection_delegate_factory(); // This is the factory method that actually returns the delegate instance. - // TODO Support passing in proxy settings when crafting connections. virtual connection_delegate_ptr create_connection_delegate( asio::io_service & service, bool https, - optional certificate_filename, - optional verify_path); + client_options const &options); virtual ~connection_delegate_factory(); diff --git a/boost/network/protocol/http/client/connection/connection_delegate_factory.ipp b/boost/network/protocol/http/client/connection/connection_delegate_factory.ipp index 64133e001..44869b373 100644 --- a/boost/network/protocol/http/client/connection/connection_delegate_factory.ipp +++ b/boost/network/protocol/http/client/connection/connection_delegate_factory.ipp @@ -13,6 +13,7 @@ #endif /* BOOST_NETWORK_ENABLE_HTTPS */ #include +#include namespace boost { namespace network { namespace http { @@ -22,14 +23,12 @@ connection_delegate_factory::connection_delegate_ptr connection_delegate_factory::create_connection_delegate( asio::io_service & service, bool https, - optional certificate_filename, - optional verify_path) { + client_options const &options) { connection_delegate_ptr delegate; if (https) { #ifdef BOOST_NETWORK_ENABLE_HTTPS delegate.reset(new ssl_delegate(service, - certificate_filename, - verify_path)); + options)); #else BOOST_THROW_EXCEPTION(std::runtime_error("HTTPS not supported.")); #endif /* BOOST_NETWORK_ENABLE_HTTPS */ diff --git a/boost/network/protocol/http/client/connection/connection_factory.hpp b/boost/network/protocol/http/client/connection/connection_factory.hpp index c2dad0852..aa77ca302 100644 --- a/boost/network/protocol/http/client/connection/connection_factory.hpp +++ b/boost/network/protocol/http/client/connection/connection_factory.hpp @@ -13,13 +13,14 @@ namespace boost { namespace network { namespace http { +class client_options; + +struct client_connection; + struct connection_factory { - virtual shared_ptr create_connection(asio::io_service & service, + virtual shared_ptr create_connection(asio::io_service &service, request_base const & request, - bool cache_resolved, - bool follow_redirects, - optional openssl_certificate, - optional openssl_verify_path) = 0; + client_options const &options) = 0; virtual ~connection_factory() = 0; // pure virtual, interface only. }; diff --git a/boost/network/protocol/http/client/connection/simple_connection_factory.hpp b/boost/network/protocol/http/client/connection/simple_connection_factory.hpp index c2d3759b7..b83696d59 100644 --- a/boost/network/protocol/http/client/connection/simple_connection_factory.hpp +++ b/boost/network/protocol/http/client/connection/simple_connection_factory.hpp @@ -23,10 +23,7 @@ struct simple_connection_factory : connection_factory { shared_ptr res_delegate_factory); virtual shared_ptr create_connection(asio::io_service & service, request_base const & request, - bool cache_resolved, - bool follow_redirects, - optional openssl_certificate, - optional openssl_verify_path); // override + client_options const & options); // override virtual ~simple_connection_factory(); private: scoped_ptr pimpl; diff --git a/boost/network/protocol/http/client/connection/simple_connection_factory.ipp b/boost/network/protocol/http/client/connection/simple_connection_factory.ipp index f271e6e1b..5c6a19e62 100644 --- a/boost/network/protocol/http/client/connection/simple_connection_factory.ipp +++ b/boost/network/protocol/http/client/connection/simple_connection_factory.ipp @@ -11,6 +11,7 @@ #include #include #include +#include namespace boost { namespace network { namespace http { @@ -24,19 +25,15 @@ struct simple_connection_factory_pimpl { shared_ptr create_connection( asio::io_service & service, request_base const & request, - bool cache_resolved, - bool follow_redirects, - optional openssl_certificate, - optional openssl_verify_path) { + client_options const & options) { ::boost::network::uri::uri uri_(destination(request)); bool https = to_lower_copy(scheme(uri_)) == "https"; shared_ptr conn_; conn_.reset(new (std::nothrow) http_async_connection( - res_delegate_factory_->create_resolver_delegate(service, cache_resolved), - conn_delegate_factory_->create_connection_delegate( - service, https, openssl_certificate, openssl_verify_path), + res_delegate_factory_->create_resolver_delegate(service, options.cache_resolved()), + conn_delegate_factory_->create_connection_delegate(service, https, options), service, - follow_redirects)); + options.follow_redirects())); return conn_; } @@ -62,12 +59,8 @@ simple_connection_factory::simple_connection_factory(shared_ptr simple_connection_factory::create_connection(asio::io_service & service, request_base const & request, - bool cache_resolved, - bool follow_redirects, - optional openssl_certificate, - optional openssl_verify_path) { - return pimpl->create_connection(service, request, cache_resolved, follow_redirects, - openssl_certificate, openssl_verify_path); + client_options const &options) { + return pimpl->create_connection(service, request, options); } simple_connection_factory::~simple_connection_factory() { diff --git a/boost/network/protocol/http/client/connection/ssl_delegate.hpp b/boost/network/protocol/http/client/connection/ssl_delegate.hpp index 41cb284b0..a159b4d93 100644 --- a/boost/network/protocol/http/client/connection/ssl_delegate.hpp +++ b/boost/network/protocol/http/client/connection/ssl_delegate.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -17,8 +18,7 @@ namespace boost { namespace network { namespace http { struct ssl_delegate : connection_delegate, enable_shared_from_this { ssl_delegate(asio::io_service & service, - optional certificate_filename, - optional verify_path); + client_options const &options); virtual void connect(asio::ip::tcp::endpoint & endpoint, function handler); @@ -30,7 +30,7 @@ struct ssl_delegate : connection_delegate, enable_shared_from_this private: asio::io_service & service_; - optional certificate_filename_, verify_path_; + client_options options_; scoped_ptr context_; scoped_ptr > socket_; diff --git a/boost/network/protocol/http/client/connection/ssl_delegate.ipp b/boost/network/protocol/http/client/connection/ssl_delegate.ipp index bdf53d7c4..00ed507b6 100755 --- a/boost/network/protocol/http/client/connection/ssl_delegate.ipp +++ b/boost/network/protocol/http/client/connection/ssl_delegate.ipp @@ -7,15 +7,14 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#include #include #include boost::network::http::ssl_delegate::ssl_delegate(asio::io_service & service, - optional certificate_filename, - optional verify_path) : + client_options const &options) : service_(service), - certificate_filename_(certificate_filename), - verify_path_(verify_path) {} + options_(options) {} void boost::network::http::ssl_delegate::connect( asio::ip::tcp::endpoint & endpoint, @@ -23,13 +22,23 @@ void boost::network::http::ssl_delegate::connect( context_.reset(new asio::ssl::context( service_, asio::ssl::context::sslv23_client)); - if (certificate_filename_ || verify_path_) { - context_->set_verify_mode(asio::ssl::context::verify_peer); - if (certificate_filename_) context_->load_verify_file(*certificate_filename_); - if (verify_path_) context_->add_verify_path(*verify_path_); - } else { - context_->set_verify_mode(asio::ssl::context::verify_none); + std::list const & certificate_paths = + options_.openssl_certificate_paths(); + std::list const & verifier_paths = + options_.openssl_verify_paths(); + bool verify_peer = false; + for (std::list::const_iterator it = certificate_paths.begin(); + it != certificate_paths.end(); ++it) { + context_->load_verify_file(*it); + verify_peer = true; + } + for (std::list::const_iterator it = verifier_paths.begin(); + it != verifier_paths.begin(); ++it) { + context_->add_verify_path(*it); + verify_peer = true; } + if (verify_peer) context_->set_verify_mode(asio::ssl::context::verify_peer); + else context_->set_verify_mode(asio::ssl::context::verify_none); socket_.reset(new asio::ssl::stream(service_, *context_)); socket_->lowest_layer().async_connect( endpoint, diff --git a/boost/network/protocol/http/client/connection_manager.hpp b/boost/network/protocol/http/client/connection_manager.hpp index e28ce5dee..6c69dee5f 100644 --- a/boost/network/protocol/http/client/connection_manager.hpp +++ b/boost/network/protocol/http/client/connection_manager.hpp @@ -14,10 +14,13 @@ namespace boost { namespace network { namespace http { +class client_options; + struct connection_manager { virtual shared_ptr get_connection( asio::io_service & service, - request_base const & request) = 0; + request_base const & request, + client_options const & options) = 0; virtual void reset() = 0; virtual ~connection_manager() = 0; }; diff --git a/boost/network/protocol/http/client/facade.ipp b/boost/network/protocol/http/client/facade.ipp index 7475a8ab7..c288eff2f 100644 --- a/boost/network/protocol/http/client/facade.ipp +++ b/boost/network/protocol/http/client/facade.ipp @@ -31,7 +31,7 @@ response const basic_client_facade::post(request request, << boost::network::body(*body); } - std::multimap content_type_headers = + headers_wrapper::range_type content_type_headers = headers(request)["Content-Type"]; if (content_type) { if (!boost::empty(content_type_headers)) @@ -57,7 +57,7 @@ response const basic_client_facade::put(request request, << boost::network::body(*body); } - std::multimap content_type_headers = + headers_wrapper::range_type content_type_headers = headers(request)["Content-Type"]; if (content_type) { if (!boost::empty(content_type_headers)) @@ -69,13 +69,13 @@ response const basic_client_facade::put(request request, request << header("Content-Type", default_content_type); } } - return base->request_skeleton(request, "PUT", true, body_handler); + return base->request_skeleton(request, "PUT", true, body_handler, options); } response const basic_client_facade::delete_(request const & request, body_callback_function_type body_handler, request_options const & options) { - return base->request_skeleton(request, "DELETE", true, body_handler); + return base->request_skeleton(request, "DELETE", true, body_handler, options); } void basic_client_facade::clear_resolved_cache() { diff --git a/boost/network/protocol/http/client/options.hpp b/boost/network/protocol/http/client/options.hpp index 4450f8a8c..21efc74b2 100644 --- a/boost/network/protocol/http/client/options.hpp +++ b/boost/network/protocol/http/client/options.hpp @@ -13,6 +13,7 @@ #include #include #include +#include namespace boost { namespace network { namespace http { diff --git a/boost/network/protocol/http/client/simple_connection_manager.hpp b/boost/network/protocol/http/client/simple_connection_manager.hpp index 173135164..2e277c213 100644 --- a/boost/network/protocol/http/client/simple_connection_manager.hpp +++ b/boost/network/protocol/http/client/simple_connection_manager.hpp @@ -16,6 +16,9 @@ namespace boost { namespace network { namespace http { /// Forward declaration of simple_connection_manager_pimpl. struct simple_connection_manager_pimpl; +/// Forward declaration of the client_options class. +class client_options; + /** simple_connection_manager * * This connection manager implementation doesn't do any connection tracking @@ -25,46 +28,9 @@ struct simple_connection_manager : connection_manager { /** Constructor * * Args: - * bool cache_resolved: Indicate whether to cache resolved endpoints. - * bool follow_redirects: Indicate whether to follow HTTP 301/302/304 - * redirections. - * optional openssl_certificate: The filename for the - * OpenSSL certificate to use. - * optional openssl_verify_path: The directory from which - * OpenSSL certificates are - * searched for when - * verification is requested. - * shared_ptr: The connection factory that actually - * creates the appropriate client - * connection object. - */ - simple_connection_manager(bool cache_resolved, - bool follow_redirects, - optional openssl_certificate, - optional openssl_verify_path, - shared_ptr connection_factory); - - /** Constructor - * - * Args: - * bool cache_resolved: Indicate whether to cache resolved endpoints. - * bool follow_redirects: Indicate whether to follow HTTP 301/302/304 - * redirections. - * std::string const & openssl_certificate: The filename for the - * OpenSSL certificate to use. - * std::string const & openssl_verify_path: The directory from which - * OpenSSL certificates are - * searched for when - * verification is requested. - * shared_ptr: The connection factory that actually - * creates the appropriate client - * connection object. + * options: A properly construction client_options instance. */ - simple_connection_manager(bool cache_resolved, - bool follow_redirects, - std::string const & openssl_certificate, - std::string const & openssl_verify_path, - shared_ptr connection_factory); + explicit simple_connection_manager(client_options const &options); /** get_connection * @@ -75,6 +41,8 @@ struct simple_connection_manager : connection_manager { * created objects). * request_base const & request: The request object that includes the * information required by the connection. + * client_options const & options: The options relating to the client + * options. * * Returns: * shared_ptr -- either an already-generated object @@ -82,7 +50,8 @@ struct simple_connection_manager : connection_manager { */ virtual shared_ptr get_connection( asio::io_service & service, - request_base const & request); // override + request_base const & request, + client_options const & options); // override /** reset * diff --git a/boost/network/protocol/http/client/simple_connection_manager.ipp b/boost/network/protocol/http/client/simple_connection_manager.ipp index 8f65b215d..73f47cf50 100644 --- a/boost/network/protocol/http/client/simple_connection_manager.ipp +++ b/boost/network/protocol/http/client/simple_connection_manager.ipp @@ -8,39 +8,20 @@ // http://www.boost.org/LICENSE_1_0.txt) #include +#include namespace boost { namespace network { namespace http { struct simple_connection_manager_pimpl { - simple_connection_manager_pimpl(bool cache_resolved, - bool follow_redirects, - optional openssl_certificate, - optional openssl_verify_path, - shared_ptr connection_factory) - : cache_resolved_(cache_resolved) - , follow_redirects_(follow_redirects) - , openssl_certificate_(openssl_certificate) - , openssl_verify_path_(openssl_verify_path) - , connection_factory_(connection_factory) - {} - - simple_connection_manager_pimpl(bool cache_resolved, - bool follow_redirects, - std::string const & openssl_certificate, - std::string const & openssl_verify_path, - shared_ptr connection_factory) - : cache_resolved_(cache_resolved) - , follow_redirects_(follow_redirects) - , openssl_certificate_(openssl_certificate) - , openssl_verify_path_(openssl_verify_path) - , connection_factory_(connection_factory) + simple_connection_manager_pimpl(client_options const &options) + : options_(options) + , connection_factory_(options.connection_factory()) {} shared_ptr get_connection(asio::io_service & service, - request_base const & request) { - return connection_factory_->create_connection( - service, request, cache_resolved_, follow_redirects_, - openssl_certificate_, openssl_verify_path_); + request_base const & request, + client_options const &options) { + return connection_factory_->create_connection(service, request, options_); } void reset() { @@ -51,34 +32,20 @@ struct simple_connection_manager_pimpl { // do nothing here. } - private: - bool cache_resolved_, follow_redirects_; - optional openssl_certificate_, openssl_verify_path_; +private: + client_options options_; shared_ptr connection_factory_; }; -simple_connection_manager::simple_connection_manager(bool cache_resolved, - bool follow_redirects, - optional openssl_certificate, - optional openssl_verify_path, - shared_ptr connection_factory) -: pimpl(new (std::nothrow) simple_connection_manager_pimpl( - cache_resolved, follow_redirects, openssl_certificate, openssl_verify_path, connection_factory)) -{} - -simple_connection_manager::simple_connection_manager(bool cache_resolved, - bool follow_redirects, - std::string const & openssl_certificate, - std::string const & openssl_verify_path, - shared_ptr connection_factory) -: pimpl(new (std::nothrow) simple_connection_manager_pimpl( - cache_resolved, follow_redirects, openssl_certificate, openssl_verify_path, connection_factory)) +simple_connection_manager::simple_connection_manager(client_options const &options) +: pimpl(new (std::nothrow) simple_connection_manager_pimpl(options)) {} shared_ptr simple_connection_manager::get_connection( asio::io_service & service, - request_base const & request) { - return pimpl->get_connection(service, request); + request_base const & request, + client_options const &options) { + return pimpl->get_connection(service, request, options); } void simple_connection_manager::reset() { From a495a5bdaaa5474bf35df82474e5935987d48193 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sun, 4 Mar 2012 21:39:53 +1100 Subject: [PATCH 042/196] Simplifying logic for whether to verify peers. --- .../protocol/http/client/connection/ssl_delegate.ipp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/boost/network/protocol/http/client/connection/ssl_delegate.ipp b/boost/network/protocol/http/client/connection/ssl_delegate.ipp index 00ed507b6..f8290178d 100755 --- a/boost/network/protocol/http/client/connection/ssl_delegate.ipp +++ b/boost/network/protocol/http/client/connection/ssl_delegate.ipp @@ -26,19 +26,17 @@ void boost::network::http::ssl_delegate::connect( options_.openssl_certificate_paths(); std::list const & verifier_paths = options_.openssl_verify_paths(); - bool verify_peer = false; + bool verify_peer = !certificate_paths.empty() || !verifier_paths.empty(); + if (verify_peer) context_->set_verify_mode(asio::ssl::context::verify_peer); + else context_->set_verify_mode(asio::ssl::context::verify_none); for (std::list::const_iterator it = certificate_paths.begin(); it != certificate_paths.end(); ++it) { context_->load_verify_file(*it); - verify_peer = true; } for (std::list::const_iterator it = verifier_paths.begin(); it != verifier_paths.begin(); ++it) { context_->add_verify_path(*it); - verify_peer = true; } - if (verify_peer) context_->set_verify_mode(asio::ssl::context::verify_peer); - else context_->set_verify_mode(asio::ssl::context::verify_none); socket_.reset(new asio::ssl::stream(service_, *context_)); socket_->lowest_layer().async_connect( endpoint, From 94fde6ce482c94ecd59c1507a00667007c631891 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Tue, 6 Mar 2012 22:38:51 +1100 Subject: [PATCH 043/196] Incremental Progress on API. This change basically brings the client type closer to full API parity only simpler than how it used to be. The next change completely removes the reliance on Boost.Parameter as that's largely unnecessary now with a more scalable way of providing options and evolving the implementation going forward. --- boost/network/protocol/http/client.hpp | 4 +++ boost/network/protocol/http/client.ipp | 27 +++++++++++++++++++ boost/network/protocol/http/client/base.hpp | 1 + boost/network/protocol/http/client/base.ipp | 13 +++++++++ .../http/client/connection_manager.hpp | 1 + boost/network/protocol/http/client/facade.hpp | 3 ++- .../http/client/simple_connection_manager.hpp | 6 +++++ .../http/client/simple_connection_manager.ipp | 8 ++++++ libs/network/src/http/client.cpp | 2 ++ 9 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 boost/network/protocol/http/client.ipp diff --git a/boost/network/protocol/http/client.hpp b/boost/network/protocol/http/client.hpp index 38f975349..130ca00f2 100644 --- a/boost/network/protocol/http/client.hpp +++ b/boost/network/protocol/http/client.hpp @@ -46,4 +46,8 @@ struct client : basic_client_facade { } // namespace boost +#ifdef BOOST_NETWORK_NO_LIB +#include +#endif + #endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_20091215 diff --git a/boost/network/protocol/http/client.ipp b/boost/network/protocol/http/client.ipp new file mode 100644 index 000000000..c1989cf42 --- /dev/null +++ b/boost/network/protocol/http/client.ipp @@ -0,0 +1,27 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_IPP_20120306 +#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_IPP_20120306 + +// Copyright 2012 Dean Michael Berris . +// Copyright 2012 Google, Inc. +// 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) + +#include +#include + +namespace boost { namespace network { namespace http { + +client::client() +: base_facade_type() +{} + +client::client(client_options const &options) +: base_facade_type(options) +{} + +} // namespace http +} // namespace network +} // namespace boost + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_IPP_20120306 diff --git a/boost/network/protocol/http/client/base.hpp b/boost/network/protocol/http/client/base.hpp index 8344ecea6..46c61759c 100644 --- a/boost/network/protocol/http/client/base.hpp +++ b/boost/network/protocol/http/client/base.hpp @@ -26,6 +26,7 @@ struct client_base { function const &, system::error_code const &)> body_callback_function_type; + client_base(); explicit client_base(client_options const &options); ~client_base(); response const request_skeleton(request const & request_, diff --git a/boost/network/protocol/http/client/base.ipp b/boost/network/protocol/http/client/base.ipp index 58aaa3bda..baf9d262d 100644 --- a/boost/network/protocol/http/client/base.ipp +++ b/boost/network/protocol/http/client/base.ipp @@ -28,6 +28,7 @@ struct client_base_pimpl { bool get_body, body_callback_function_type callback, request_options const &options); + void clear_resolved_cache(); ~client_base_pimpl(); private: client_options options_; @@ -37,10 +38,18 @@ struct client_base_pimpl { shared_ptr connection_manager_; }; +client_base::client_base() +: pimpl(new (std::nothrow) client_base_pimpl(client_options())) +{} + client_base::client_base(client_options const &options) : pimpl(new (std::nothrow) client_base_pimpl(options)) {} +void client_base::clear_resolved_cache() { + pimpl->clear_resolved_cache(); +} + response const client_base::request_skeleton(request const & request_, std::string const & method, bool get_body, @@ -92,6 +101,10 @@ response const client_base_pimpl::request_skeleton( return connection_->send_request(method, request_, get_body, callback, options); } +void client_base_pimpl::clear_resolved_cache() { + connection_manager_->clear_resolved_cache(); +} + } // namespace http } // namespace network diff --git a/boost/network/protocol/http/client/connection_manager.hpp b/boost/network/protocol/http/client/connection_manager.hpp index 6c69dee5f..b9ed8f05a 100644 --- a/boost/network/protocol/http/client/connection_manager.hpp +++ b/boost/network/protocol/http/client/connection_manager.hpp @@ -21,6 +21,7 @@ struct connection_manager { asio::io_service & service, request_base const & request, client_options const & options) = 0; + virtual void clear_resolved_cache() = 0; virtual void reset() = 0; virtual ~connection_manager() = 0; }; diff --git a/boost/network/protocol/http/client/facade.hpp b/boost/network/protocol/http/client/facade.hpp index 5a555ebe3..e10d1fbf2 100644 --- a/boost/network/protocol/http/client/facade.hpp +++ b/boost/network/protocol/http/client/facade.hpp @@ -16,7 +16,8 @@ namespace boost { namespace network { namespace http { struct basic_client_facade { typedef client_base::body_callback_function_type body_callback_function_type; - basic_client_facade(client_options const &options); + basic_client_facade(); + explicit basic_client_facade(client_options const &options); response const head(request const &request, request_options const&options=request_options()); response const get(request const &request, diff --git a/boost/network/protocol/http/client/simple_connection_manager.hpp b/boost/network/protocol/http/client/simple_connection_manager.hpp index 2e277c213..81c10c765 100644 --- a/boost/network/protocol/http/client/simple_connection_manager.hpp +++ b/boost/network/protocol/http/client/simple_connection_manager.hpp @@ -61,6 +61,12 @@ struct simple_connection_manager : connection_manager { */ virtual void reset(); // override + /** clear_resolved_cache + * + * This function resets all the resolved endpoints that have been cached. + */ + virtual void clear_resolved_cache(); + /** Destructor. */ virtual ~simple_connection_manager(); // override diff --git a/boost/network/protocol/http/client/simple_connection_manager.ipp b/boost/network/protocol/http/client/simple_connection_manager.ipp index 73f47cf50..17f61a732 100644 --- a/boost/network/protocol/http/client/simple_connection_manager.ipp +++ b/boost/network/protocol/http/client/simple_connection_manager.ipp @@ -28,6 +28,10 @@ struct simple_connection_manager_pimpl { // do nothing here. } + void clear_resolved_cache() { + // TODO(deanberris): Make this happen! + } + ~simple_connection_manager_pimpl() { // do nothing here. } @@ -52,6 +56,10 @@ void simple_connection_manager::reset() { pimpl->reset(); } +void simple_connection_manager::clear_resolved_cache() { + pimpl->clear_resolved_cache(); +} + simple_connection_manager::~simple_connection_manager() { // do nothing here. } diff --git a/libs/network/src/http/client.cpp b/libs/network/src/http/client.cpp index ee271614b..f17bb7dcd 100644 --- a/libs/network/src/http/client.cpp +++ b/libs/network/src/http/client.cpp @@ -8,6 +8,8 @@ #undef BOOST_NETWORK_NO_LIB #endif +#include #include #include #include + From 4bca1ae79e0d1e63b75251072fdcfcb7df703b7b Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Tue, 6 Mar 2012 22:47:33 +1100 Subject: [PATCH 044/196] Removing Boost.Parameter from dependencies. --- boost/network/protocol/http/client.hpp | 1 - boost/network/protocol/http/parameters.hpp | 24 ---------------------- 2 files changed, 25 deletions(-) delete mode 100644 boost/network/protocol/http/parameters.hpp diff --git a/boost/network/protocol/http/client.hpp b/boost/network/protocol/http/client.hpp index 130ca00f2..7662e7cbf 100644 --- a/boost/network/protocol/http/client.hpp +++ b/boost/network/protocol/http/client.hpp @@ -12,7 +12,6 @@ #include #include -#include #include #include #include diff --git a/boost/network/protocol/http/parameters.hpp b/boost/network/protocol/http/parameters.hpp deleted file mode 100644 index 9bf0ae97e..000000000 --- a/boost/network/protocol/http/parameters.hpp +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_PARAMETERS_HPP_20101210 -#define BOOST_NETWORK_PROTOCOL_HTTP_PARAMETERS_HPP_20101210 - -// Copyright 2010 Dean Michael Berris. -// 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) - -#if !defined(BOOST_PARAMETER_MAX_ARITY) - #define BOOST_PARAMETER_MAX_ARITY 16 -#endif -#include - -namespace boost { namespace network { namespace http { - - BOOST_PARAMETER_NAME(io_service) - -} /* http */ - -} /* network */ - -} /* boost */ - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_PARAMETERS_HPP_20101210 */ From 788117960e096748bf70a93afc5624892460746f Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Thu, 8 Mar 2012 22:46:28 +1100 Subject: [PATCH 045/196] Finishing client_options implementation. --- boost/network/protocol/http/client/facade.ipp | 8 ++++ .../network/protocol/http/client/options.ipp | 45 ++++++++++++++++++- libs/network/build/CMakeLists.txt | 24 +--------- libs/network/test/http/CMakeLists.txt | 2 + 4 files changed, 55 insertions(+), 24 deletions(-) diff --git a/boost/network/protocol/http/client/facade.ipp b/boost/network/protocol/http/client/facade.ipp index c288eff2f..a58882b09 100644 --- a/boost/network/protocol/http/client/facade.ipp +++ b/boost/network/protocol/http/client/facade.ipp @@ -5,6 +5,14 @@ namespace boost { namespace network { namespace http { +basic_client_facade::basic_client_facade() +: base(new (std::nothrow) client_base()) +{} + +basic_client_facade::basic_client_facade(client_options const &options) +: base(new (std::nothrow) client_base(options)) +{} + response const basic_client_facade::head(request const &request, request_options const&options) { return base->request_skeleton(request, diff --git a/boost/network/protocol/http/client/options.ipp b/boost/network/protocol/http/client/options.ipp index 83a691c5d..d4024ad5a 100644 --- a/boost/network/protocol/http/client/options.ipp +++ b/boost/network/protocol/http/client/options.ipp @@ -8,6 +8,8 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_OPTIONS_IPP #include +#include +#include namespace boost { namespace network { namespace http { @@ -19,7 +21,10 @@ public: , cache_resolved_(false) , openssl_certificate_paths_() , openssl_verify_paths_() - {} + , connection_manager_() + , connection_factory_() + { + } client_options_pimpl *clone() const { return new (std::nothrow) client_options_pimpl(*this); @@ -65,6 +70,22 @@ public: return openssl_verify_paths_; } + void connection_manager(shared_ptr manager) { + connection_manager_ = manager; + } + + shared_ptr connection_manager() const { + return connection_manager_; + } + + void connection_factory(shared_ptr factory) { + connection_factory_ = factory; + } + + shared_ptr connection_factory() const { + return connection_factory_; + } + private: client_options_pimpl(client_options_pimpl const &other) : io_service_(other.io_service_) @@ -72,6 +93,8 @@ private: , cache_resolved_(other.cache_resolved_) , openssl_certificate_paths_(other.openssl_certificate_paths_) , openssl_verify_paths_(other.openssl_verify_paths_) + , connection_manager_(other.connection_manager_) + , connection_factory_(other.connection_factory_) {} client_options_pimpl& operator=(client_options_pimpl); // cannot assign @@ -80,6 +103,8 @@ private: asio::io_service *io_service_; bool follow_redirects_, cache_resolved_; std::list openssl_certificate_paths_, openssl_verify_paths_; + shared_ptr connection_manager_; + shared_ptr connection_factory_; }; client_options::client_options() @@ -149,6 +174,24 @@ std::list const & client_options::openssl_verify_paths() const { return pimpl->openssl_verify_paths(); } +client_options& client_options::connection_manager(shared_ptr manager) { + pimpl->connection_manager(manager); + return *this; +} + +shared_ptr client_options::connection_manager() const { + return pimpl->connection_manager(); +} + +client_options& client_options::connection_factory(shared_ptr factory) { + pimpl->connection_factory(factory); + return *this; +} + +shared_ptr client_options::connection_factory() const { + return pimpl->connection_factory(); +} + } // namespace http } // namespace network } // namespace boost diff --git a/libs/network/build/CMakeLists.txt b/libs/network/build/CMakeLists.txt index 6e7c74f74..85cd0dc8d 100644 --- a/libs/network/build/CMakeLists.txt +++ b/libs/network/build/CMakeLists.txt @@ -1,24 +1,2 @@ include_directories(${CPP-NETLIB_SOURCE_DIR}) -find_package( Boost 1.45.0 COMPONENTS unit_test_framework system regex thread filesystem ) - -add_library(cppnetlib-uri STATIC ${CPP-NETLIB_SOURCE_DIR}/libs/network/src/parse_uri_impl.cpp) -add_library(cppnetlib-server-parsers STATIC ${CPP-NETLIB_SOURCE_DIR}/libs/network/src/server_request_parsers_impl.cpp) -add_library(cppnetlib-message - STATIC - ${CPP-NETLIB_SOURCE_DIR}/libs/network/src/message/message.cpp) -add_library(cppnetlib-message-directives - STATIC - ${CPP-NETLIB_SOURCE_DIR}/libs/network/src/message/directives.cpp) -add_library(cppnetlib-http-message - STATIC - ${CPP-NETLIB_SOURCE_DIR}/libs/network/src/http/request.cpp - ${CPP-NETLIB_SOURCE_DIR}/libs/network/src/http/response.cpp) -add_library(cppnetlib-http-client-connections - STATIC - ${CPP-NETLIB_SOURCE_DIR}/libs/network/src/http/client_connections.cpp - ${CPP-NETLIB_SOURCE_DIR}/libs/network/src/http/simple_connection_manager.cpp - ${CPP-NETLIB_SOURCE_DIR}/libs/network/src/http/simple_connection_factory.cpp - ${CPP-NETLIB_SOURCE_DIR}/libs/network/src/http/connection_delegate_factory.cpp) -add_library(cppnetlib-http-client - STATIC - ${CPP-NETLIB_SOURCE_DIR}/libs/network/src/http/client.cpp) +add_subdirectory(../src) diff --git a/libs/network/test/http/CMakeLists.txt b/libs/network/test/http/CMakeLists.txt index 8ace2e090..4b2e3052e 100644 --- a/libs/network/test/http/CMakeLists.txt +++ b/libs/network/test/http/CMakeLists.txt @@ -30,6 +30,7 @@ if (Boost_FOUND) cppnetlib-uri cppnetlib-message cppnetlib-message-wrappers + cppnetlib-message-directives cppnetlib-http-message cppnetlib-http-client cppnetlib-http-client-connections) @@ -40,6 +41,7 @@ if (Boost_FOUND) cppnetlib-uri cppnetlib-message cppnetlib-message-wrappers + cppnetlib-message-directives cppnetlib-http-message cppnetlib-http-client cppnetlib-http-client-connections) From 4578dfdd881d4bc819713d9bcd54e435e89ed5b3 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Thu, 8 Mar 2012 23:18:31 +1100 Subject: [PATCH 046/196] Finishing requestion_options implementation. --- .../network/protocol/http/client/options.ipp | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/boost/network/protocol/http/client/options.ipp b/boost/network/protocol/http/client/options.ipp index d4024ad5a..3df7151e9 100644 --- a/boost/network/protocol/http/client/options.ipp +++ b/boost/network/protocol/http/client/options.ipp @@ -192,6 +192,86 @@ shared_ptr client_options::connection_factory() const return pimpl->connection_factory(); } +// End of client_options. + +class request_options_pimpl { +public: + request_options_pimpl() + : timeout_ms_(30 * 1000) + , max_redirects_(10) + {} + + request_options_pimpl *clone() const { + return new (std::nothrow) request_options_pimpl(*this); + } + + void timeout(uint64_t milliseconds) { + timeout_ms_ = milliseconds; + } + + uint64_t timeout() const { + return timeout_ms_; + } + + void max_redirects(int redirects) { + max_redirects_ = redirects; + } + + int max_redirects() const { + return max_redirects_; + } + +private: + uint64_t timeout_ms_; + int max_redirects_; + + request_options_pimpl(request_options_pimpl const &other) + : timeout_ms_(other.timeout_ms_) + , max_redirects_(other.max_redirects_) + {} + + request_options_pimpl& operator=(request_options_pimpl); // cannot be assigned. +}; + +request_options::request_options() +: pimpl(new (std::nothrow) request_options_pimpl) +{} + +request_options::request_options(request_options const &other) +: pimpl(other.pimpl->clone()) +{} + +request_options& request_options::operator=(request_options rhs) { + rhs.swap(*this); + return *this; +} + +void request_options::swap(request_options &other) { + std::swap(other.pimpl, this->pimpl); +} + +request_options::~request_options() { + delete pimpl; +} + +request_options& request_options::timeout(uint64_t milliseconds) { + pimpl->timeout(milliseconds); + return *this; +} + +uint64_t request_options::timeout() const { + return pimpl->timeout(); +} + +request_options& request_options::max_redirects(int redirects) { + pimpl->max_redirects(redirects); + return *this; +} + +int request_options::max_redirects() const { + return pimpl->max_redirects(); +} + } // namespace http } // namespace network } // namespace boost From 29ec3037a5417a9f58855e5e1fe3e935cece16d3 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sat, 10 Mar 2012 20:18:15 +1100 Subject: [PATCH 047/196] Implement request_storage_base. This commit implements an untested (but contains a building test) request_storage_base that aims to hide the details of a segmented data structure used to hold the request data. The intention is that the storage base will be used if large amounts of data will be stored in an efficient manner in memory. This design also allows the request implementation to ignore the fact that there's an underlying storage implementation and just use a provided body chunk writer. This allows people to add a function that pulls the data from whatever source and adds it to the request only when necessary. This is an evolutionary step forward moving from the inside out. The intention is that we're able to build higher level logic to be able to not rely on using the storage base in special circumstances. --- .../network/protocol/http/request/request.hpp | 5 +- .../network/protocol/http/request/request.ipp | 2 +- .../protocol/http/request/request_base.hpp | 28 ++--- .../protocol/http/request/request_base.ipp | 111 +++++++++++++++++- libs/network/test/http/CMakeLists.txt | 18 +-- libs/network/test/http/request_base_test.cpp | 49 ++++++++ 6 files changed, 184 insertions(+), 29 deletions(-) create mode 100644 libs/network/test/http/request_base_test.cpp diff --git a/boost/network/protocol/http/request/request.hpp b/boost/network/protocol/http/request/request.hpp index 7861882b5..457587513 100644 --- a/boost/network/protocol/http/request/request.hpp +++ b/boost/network/protocol/http/request/request.hpp @@ -53,7 +53,7 @@ struct request : request_base { virtual void set_method(std::string const & method); virtual void set_status(std::string const & status); virtual void set_status_message(std::string const & status_message); - virtual void set_body_stream(shared_ptr stream); + virtual void set_body_writer(function writer); virtual void set_uri(std::string const &uri); virtual void set_uri(network::uri::uri const &uri); @@ -63,7 +63,8 @@ struct request : request_base { virtual void get_method(std::string & method) const; virtual void get_status(std::string & status) const; virtual void get_status_message(std::string & status_message) const; - virtual void get_body_stream(body_stream & output_stream) const; + virtual void get_body(function chunk_reader) const; + virtual void get_body(std::string const & body) const; virtual ~request(); private: diff --git a/boost/network/protocol/http/request/request.ipp b/boost/network/protocol/http/request/request.ipp index 1b4be0263..0b0d3fc24 100644 --- a/boost/network/protocol/http/request/request.ipp +++ b/boost/network/protocol/http/request/request.ipp @@ -21,7 +21,7 @@ struct request_pimpl { }; request::~request() { - // Do nothing here. + // do nothing here } request::request(std::string const & url) diff --git a/boost/network/protocol/http/request/request_base.hpp b/boost/network/protocol/http/request/request_base.hpp index 79ccbbe85..0e257c7c5 100644 --- a/boost/network/protocol/http/request/request_base.hpp +++ b/boost/network/protocol/http/request/request_base.hpp @@ -13,7 +13,6 @@ #include #include -#include namespace boost { namespace network { namespace http { @@ -22,29 +21,27 @@ struct body_source : iostreams::source { virtual ~body_source(); }; +struct request_storage_base_pimpl; + struct request_storage_base { - typedef iostreams::stream body_stream; protected: - // TODO Implement a segmented storage base which efficiently supports - // efficient memory usage that makes sense for HTTP payload. The idea is - // to expose the internal (segmented) storage to the client implementation - // so that raw buffers of formatted HTTP request data (which may or may not - // support delegated streams from user input -- i.e. for the body contents) - // can be efficiently sent out to the wire. This also implies that all - // thread-safety guarantees are handled by the storage base as well. - request_storage_base(size_t hint = BOOST_NETWORK_BUFFER_CHUNK); - virtual void set_status_line(std::string const &status_line); - virtual void append_header(std::string const &name, std::string const &value); + request_storage_base(size_t chunk_size = BOOST_NETWORK_BUFFER_CHUNK); + virtual void append(char const *data, size_t size); + virtual size_t read(char *destination, size_t offset, size_t size); + virtual void flatten(std::string &destination); + virtual void clear(); virtual ~request_storage_base(); + + private: + request_storage_base_pimpl *pimpl_; }; struct request_base : message_base, request_storage_base { - using request_storage_base::body_stream; // Setters virtual void set_method(std::string const & method) = 0; virtual void set_status(std::string const & status) = 0; virtual void set_status_message(std::string const & status_message) = 0; - virtual void set_body_stream(shared_ptr stream) = 0; + virtual void set_body_writer(function writer) = 0; virtual void set_uri(std::string const &uri) = 0; virtual void set_uri(network::uri::uri const &uri) = 0; @@ -54,7 +51,8 @@ struct request_base : message_base, request_storage_base { virtual void get_method(std::string & method) const = 0; virtual void get_status(std::string & status) const = 0; virtual void get_status_message(std::string & status_message) const = 0; - virtual void get_body_stream(body_stream & output_stream) const = 0; + virtual void get_body(function chunk_reader) const = 0; + virtual void get_body(std::string const & body) const = 0; virtual ~request_base() = 0; }; diff --git a/boost/network/protocol/http/request/request_base.ipp b/boost/network/protocol/http/request/request_base.ipp index b556b7583..7643af5ba 100644 --- a/boost/network/protocol/http/request/request_base.ipp +++ b/boost/network/protocol/http/request/request_base.ipp @@ -8,6 +8,8 @@ // http://www.boost.org/LICENSE_1_0.txt) #include +#include +#include namespace boost { namespace network { namespace http { @@ -15,10 +17,115 @@ request_base::~request_base() { // default implementation, only required for linking. } +struct request_storage_base_pimpl { + request_storage_base_pimpl(size_t chunk_size); + void append(char const *data, size_t size); + size_t read(char *destination, size_t offset, size_t size); + void flatten(std::string &destination); + void clear(); + request_storage_base_pimpl clone() const; + ~request_storage_base_pimpl(); + + private: + size_t chunk_size_; + typedef std::vector > chunks_vector; + chunks_vector chunks_; + mutex chunk_mutex; +}; + +request_storage_base::request_storage_base(size_t chunk_size) +: pimpl_(new (std::nothrow) request_storage_base_pimpl(chunk_size)) +{} + request_storage_base::~request_storage_base() { - // default implementation, only required for linking. + delete pimpl_; +} + +void request_storage_base::append(char const *data, size_t size) { + pimpl_->append(data, size); +} + +size_t request_storage_base::read(char *destination, size_t offset, size_t size) { + return pimpl_->read(destination, offset, size); +} + +void request_storage_base::flatten(std::string &destination) { + pimpl_->flatten(destination); +} + +void request_storage_base::clear() { + pimpl_->clear(); +} + +request_storage_base_pimpl::request_storage_base_pimpl(size_t chunk_size) +: chunk_size_(chunk_size) +, chunks_() +{ + // do nothing here. +} + +void request_storage_base_pimpl::append(char const *data, size_t size) { + if (chunks_.empty()) { + chunks_.push_back(std::make_pair( + new (std::nothrow) char[chunk_size_], 0)); + } + std::pair *chunk = &chunks_.back(); + size_t remaining = chunk_size_ - chunk->second; + while (remaining < size) { + std::memcpy(chunk->first + chunk->second, data, size - remaining); + chunk->second += size - remaining; + data += remaining; + size -= remaining; + chunks_.push_back(std::make_pair( + new (std::nothrow) char[chunk_size_], 0)); + chunk = &chunks_.back(); + remaining = chunk_size_ - chunk->second; + } + if (size > 0) { + std::memcpy(chunk->first + chunk->second, data, size); + chunk->second += size; + } } - + +size_t request_storage_base_pimpl::read(char *destination, size_t offset, size_t size) { + if (chunks_.empty()) return 0; + // First we find which chunk we're going to read from using the provided + // offset and some arithmetic to determine the correct one. + size_t chunk_index = offset / chunk_size_; + + // Then we start copying up to size data either until we've reached the end + // or we're + size_t chunks_count = chunks_.size(); + size_t read_count = 0; + while (size > 0 && chunk_index < chunks_.size()) { + size_t bytes_to_read = std::min(chunks_[chunk_index].second, size); + std::memcpy(destination + read_count, chunks_[chunk_index].first, bytes_to_read); + read_count += bytes_to_read; + size -= bytes_to_read; + ++chunk_index; + } + return read_count; +} + +void request_storage_base_pimpl::flatten(std::string &destination) { + chunks_vector::const_iterator chunk_iterator = chunks_.begin(); + for (; chunk_iterator != chunks_.end(); ++chunk_iterator) { + destination.append(chunk_iterator->first, chunk_iterator->second); + } +} + +void request_storage_base_pimpl::clear() { + chunks_vector::const_iterator chunk_iterator = chunks_.begin(); + for (; chunk_iterator != chunks_.end(); ++chunk_iterator) { + delete [] chunk_iterator->first; + } + chunks_vector().swap(chunks_); +} + +request_storage_base_pimpl::~request_storage_base_pimpl() { + clear(); +} + } /* http */ } /* network */ diff --git a/libs/network/test/http/CMakeLists.txt b/libs/network/test/http/CMakeLists.txt index 4b2e3052e..f15ea61f0 100644 --- a/libs/network/test/http/CMakeLists.txt +++ b/libs/network/test/http/CMakeLists.txt @@ -12,6 +12,15 @@ if (OPENSSL_FOUND) endif() if (Boost_FOUND) + # These are the internal (simple) tests. + add_executable(cpp-netlib-http-request_base_test request_base_test.cpp) + target_link_libraries(cpp-netlib-http-request_base_test + ${Boost_LIBRARIES} + cppnetlib-message + cppnetlib-http-message) + add_test(cpp-netlib-http-request_base_test + ${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-http-request_base_test) + set ( TESTS client_constructor_test client_get_test @@ -25,15 +34,6 @@ if (Boost_FOUND) PROPERTIES COMPILE_FLAGS "-Wall") endif() add_executable(cpp-netlib-http-${test} ${test}.cpp) - add_dependencies(cpp-netlib-http-${test} - cppnetlib-constants - cppnetlib-uri - cppnetlib-message - cppnetlib-message-wrappers - cppnetlib-message-directives - cppnetlib-http-message - cppnetlib-http-client - cppnetlib-http-client-connections) target_link_libraries(cpp-netlib-http-${test} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} diff --git a/libs/network/test/http/request_base_test.cpp b/libs/network/test/http/request_base_test.cpp new file mode 100644 index 000000000..f91ffd445 --- /dev/null +++ b/libs/network/test/http/request_base_test.cpp @@ -0,0 +1,49 @@ +// Copyright 2012 Dean Michael Berris . +// Copyright 2012 Google, Inc. +// 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) + +#define BOOST_TEST_MODULE HTTP Request Storage Base Test +#include +#include + +namespace http = boost::network::http; + +// In this test we make sure that the implementation of the default request +// storage base actually doesn't have bugs and works as advertised. Although we +// don't intend to expose this interface to users, we use the test as a sanity +// check on the internals of the implementation. +struct request_test : http::request_storage_base { + typedef http::request_storage_base base_type; + + // Expose the protected functions so that we can test them. + using base_type::append; + using base_type::read; + using base_type::flatten; + using base_type::clear; + + request_test(size_t chunk_size) + : base_type(chunk_size) + {} + + ~request_test() { + // do nothing here. + } +}; + +BOOST_AUTO_TEST_CASE(request_storage_flow) { + // Use a few byte chunks just to make it manageable. + request_test simple(64); + static char data[] = + "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vitae ante sed nunc dapibus convallis in at neque. Vestibulum sed congue nunc. Sed tempus lorem non dui ultrices porttitor porta ligula venenatis. Sed a orci gravida tellus condimentum laoreet. Vivamus pulvinar, tortor eu adipiscing tempus, dolor urna tincidunt enim, id pretium eros ante quis dui. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In hac habitasse platea dictumst. Maecenas mattis metus."; + simple.append(data, sizeof(data)); + char output[sizeof(data)]; + size_t bytes_read = simple.read(output, 0, sizeof(data)); + BOOST_CHECK_EQUAL(bytes_read, sizeof(data)); + std::string flattened; + simple.flatten(flattened); + BOOST_CHECK_EQUAL(flattened, std::string(output, sizeof(data))); + BOOST_CHECK_EQUAL(std::string(data, sizeof(data)), std::string(output, sizeof(data))); + simple.clear(); +} From a1bbacea98de4bf2ea1a3a361199c28d28ac38ba Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sun, 11 Mar 2012 00:30:15 +1100 Subject: [PATCH 048/196] WIP: Make the request type build. This commit makes the request.ipp/cpp files build without having to do anything. The innards of the implementation are yet to be defined. --- .../network/protocol/http/request/request.hpp | 2 +- .../network/protocol/http/request/request.ipp | 56 +++++++++++++++++++ libs/network/src/CMakeLists.txt | 3 - 3 files changed, 57 insertions(+), 4 deletions(-) diff --git a/boost/network/protocol/http/request/request.hpp b/boost/network/protocol/http/request/request.hpp index 457587513..a860c8d92 100644 --- a/boost/network/protocol/http/request/request.hpp +++ b/boost/network/protocol/http/request/request.hpp @@ -68,7 +68,7 @@ struct request : request_base { virtual ~request(); private: - scoped_ptr pimpl_; + request_pimpl* pimpl_; }; template diff --git a/boost/network/protocol/http/request/request.ipp b/boost/network/protocol/http/request/request.ipp index 0b0d3fc24..add2e14d9 100644 --- a/boost/network/protocol/http/request/request.ipp +++ b/boost/network/protocol/http/request/request.ipp @@ -18,6 +18,13 @@ namespace boost { namespace network { namespace http { struct request_pimpl { explicit request_pimpl(std::string const & url) {} + request_pimpl* clone() { + return new (std::nothrow) request_pimpl(*this); + } + + private: + request_pimpl(request_pimpl const &other) + {} }; request::~request() { @@ -28,6 +35,55 @@ request::request(std::string const & url) : pimpl_(new request_pimpl(url)) {} +request::request(request const &other) +: pimpl_(other.pimpl_->clone()) +{} + +request& request::operator=(request rhs) { + rhs.swap(*this); +} + +void request::swap(request & other) { + std::swap(this->pimpl_, other.pimpl_); +} + +// From message_base... +// Mutators +void request::set_destination(std::string const & destination){} +void request::set_source(std::string const & source){} +void request::append_header(std::string const & name, + std::string const & value){} +void request::remove_headers(std::string const & name){} +void request::remove_headers(){} +void request::set_body(std::string const & body){} +void request::append_body(std::string const & data){} + +// Retrievers +void request::get_destination(std::string & destination) const{} +void request::get_source(std::string & source) const{} +void request::get_headers(function inserter) const{} +void request::get_headers(std::string const & name, function inserter) const{} +void request::get_headers(function predicate, function inserter) const{} +void request::get_body(std::string & body) const{} +void request::get_body(function)> chunk_reader, size_t size) const{} + +// From request_base... +// Setters +void request::set_method(std::string const & method){} +void request::set_status(std::string const & status){} +void request::set_status_message(std::string const & status_message){} +void request::set_body_writer(function writer){} +void request::set_uri(std::string const &uri){} +void request::set_uri(network::uri::uri const &uri){} + +// Getters +void request::get_uri(network::uri::uri &uri) const{} +void request::get_uri(std::string &uri) const{} +void request::get_method(std::string & method) const{} +void request::get_status(std::string & status) const{} +void request::get_status_message(std::string & status_message) const{} +void request::get_body(function chunk_reader) const{} +void request::get_body(std::string const & body) const{} } // namespace http diff --git a/libs/network/src/CMakeLists.txt b/libs/network/src/CMakeLists.txt index 41a79bd92..8c8e8b9c5 100644 --- a/libs/network/src/CMakeLists.txt +++ b/libs/network/src/CMakeLists.txt @@ -14,9 +14,6 @@ add_library(cppnetlib-uri ${CPP-NETLIB_URI_SRCS}) set(CPP-NETLIB_HTTP_SERVER_SRCS server_request_parsers_impl.cpp) add_library(cppnetlib-server-parsers ${CPP-NETLIB_HTTP_SERVER_SRCS}) -set(CPP-NETLIB_HTTP_CLIENT_SRCS client.cpp) -add_library(cppnetlib-client-connections ${CPP-NETLIB_HTTP_CLIENT_SRCS}) - set(CPP-NETLIB_MESSAGE_SRCS message/message.cpp) add_library(cppnetlib-message ${CPP-NETLIB_MESSAGE_SRCS}) From 8e8b14e73d0cd9e7c4316d45e505deaeb1f64f95 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sun, 11 Mar 2012 01:04:54 +1100 Subject: [PATCH 049/196] Implementing append and read correctly. --- .../protocol/http/request/request_base.ipp | 19 +++++++++++++------ libs/network/test/http/CMakeLists.txt | 2 ++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/boost/network/protocol/http/request/request_base.ipp b/boost/network/protocol/http/request/request_base.ipp index 7643af5ba..aaf052821 100644 --- a/boost/network/protocol/http/request/request_base.ipp +++ b/boost/network/protocol/http/request/request_base.ipp @@ -70,16 +70,19 @@ void request_storage_base_pimpl::append(char const *data, size_t size) { new (std::nothrow) char[chunk_size_], 0)); } std::pair *chunk = &chunks_.back(); + BOOST_ASSERT(chunk_size_ >= chunk->second); size_t remaining = chunk_size_ - chunk->second; while (remaining < size) { - std::memcpy(chunk->first + chunk->second, data, size - remaining); - chunk->second += size - remaining; - data += remaining; - size -= remaining; + size_t bytes_to_write = std::min(size - remaining, chunk_size_); + std::memcpy(chunk->first + chunk->second, data, bytes_to_write); + chunk->second += bytes_to_write; + BOOST_ASSERT(chunk->second <= chunk_size_); + data += bytes_to_write; + size -= bytes_to_write; chunks_.push_back(std::make_pair( new (std::nothrow) char[chunk_size_], 0)); chunk = &chunks_.back(); - remaining = chunk_size_ - chunk->second; + remaining = chunk_size_; } if (size > 0) { std::memcpy(chunk->first + chunk->second, data, size); @@ -92,6 +95,7 @@ size_t request_storage_base_pimpl::read(char *destination, size_t offset, size_t // First we find which chunk we're going to read from using the provided // offset and some arithmetic to determine the correct one. size_t chunk_index = offset / chunk_size_; + offset = offset % chunk_size_; // Then we start copying up to size data either until we've reached the end // or we're @@ -99,9 +103,12 @@ size_t request_storage_base_pimpl::read(char *destination, size_t offset, size_t size_t read_count = 0; while (size > 0 && chunk_index < chunks_.size()) { size_t bytes_to_read = std::min(chunks_[chunk_index].second, size); - std::memcpy(destination + read_count, chunks_[chunk_index].first, bytes_to_read); + std::memcpy(destination + read_count, + chunks_[chunk_index].first + offset, + bytes_to_read); read_count += bytes_to_read; size -= bytes_to_read; + offset = 0; ++chunk_index; } return read_count; diff --git a/libs/network/test/http/CMakeLists.txt b/libs/network/test/http/CMakeLists.txt index f15ea61f0..4f30d8f9a 100644 --- a/libs/network/test/http/CMakeLists.txt +++ b/libs/network/test/http/CMakeLists.txt @@ -18,6 +18,8 @@ if (Boost_FOUND) ${Boost_LIBRARIES} cppnetlib-message cppnetlib-http-message) + set_target_properties(cpp-netlib-http-request_base_test + PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests) add_test(cpp-netlib-http-request_base_test ${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-http-request_base_test) From 82bba850f57c69838d49f1718ebbeb40c92a770c Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sun, 11 Mar 2012 20:59:53 +1100 Subject: [PATCH 050/196] Making client_get_streaming_test.cpp build. --- .../http/message/directives/status.hpp | 20 +++------ .../protocol/http/message/wrappers/status.hpp | 1 + .../test/http/client_get_streaming_test.cpp | 42 ++++++++++--------- 3 files changed, 29 insertions(+), 34 deletions(-) diff --git a/boost/network/protocol/http/message/directives/status.hpp b/boost/network/protocol/http/message/directives/status.hpp index 6560607ab..ff1afea43 100644 --- a/boost/network/protocol/http/message/directives/status.hpp +++ b/boost/network/protocol/http/message/directives/status.hpp @@ -15,26 +15,16 @@ namespace boost { namespace network { namespace http { -template struct status_directive { - - status_directive(String const & s) - : status_(s) - {} - - void operator()(response_base & response) { - response.set_status(status_); - } + explicit status_directive(std::string const & s); + void operator()(response_base & response) const; protected: - - String status_; - + std::string status_; }; -template -inline status_directive status(String const & response) { - return status_directive(response); +inline status_directive status(std::string const & response) { + return status_directive(response); } } // namespace http diff --git a/boost/network/protocol/http/message/wrappers/status.hpp b/boost/network/protocol/http/message/wrappers/status.hpp index 4c06a6eab..cba2f8618 100644 --- a/boost/network/protocol/http/message/wrappers/status.hpp +++ b/boost/network/protocol/http/message/wrappers/status.hpp @@ -16,6 +16,7 @@ namespace impl { struct status_wrapper { explicit status_wrapper(response_base & response_); operator std::string () const; + operator uint16_t () const; private: response_base & response_; }; diff --git a/libs/network/test/http/client_get_streaming_test.cpp b/libs/network/test/http/client_get_streaming_test.cpp index aa1bdd902..680d05504 100644 --- a/libs/network/test/http/client_get_streaming_test.cpp +++ b/libs/network/test/http/client_get_streaming_test.cpp @@ -7,7 +7,6 @@ #include #include #include -#include "client_types.hpp" namespace net = boost::network; namespace http = boost::network::http; @@ -26,23 +25,28 @@ struct body_handler { }; -BOOST_AUTO_TEST_CASE_TEMPLATE(http_client_get_streaming_test, client, async_only_client_types) { - typename client::request request("http://www.boost.org/"); - typename client::response response; - typename client::string_type body_string; - typename client::string_type dummy_body; - body_handler handler_instance(body_string); - { - client client_; - BOOST_CHECK_NO_THROW( response = client_.get(request, http::_body_handler=handler_instance) ); - typename net::headers_range::type range = headers(response)["Content-Type"]; - BOOST_CHECK ( !boost::empty(range) ); - BOOST_CHECK_EQUAL ( body(response).size(), 0u ); - BOOST_CHECK_EQUAL ( response.version().substr(0, 7), std::string("HTTP/1.") ); - BOOST_CHECK_EQUAL ( response.status(), 200u ); - BOOST_CHECK_EQUAL ( response.status_message(), std::string("OK") ); - dummy_body = body(response); - } - BOOST_CHECK ( dummy_body == typename client::string_type() ); +BOOST_AUTO_TEST_CASE(http_client_get_streaming_test) { + http::client::request request("http://www.boost.org/"); + http::client::response response; + std::string body_string; + std::string dummy_body; + body_handler handler_instance(body_string); + { + http::client client_; + BOOST_CHECK_NO_THROW( response = client_.get(request, handler_instance) ); + net::headers_wrapper::range_type range = headers(response)["Content-Type"]; + BOOST_CHECK ( !boost::empty(range) ); + BOOST_CHECK_EQUAL ( body(response).size(), 0u ); + std::string version_, status_message_; + boost::uint16_t status_; + version_ = version(response); + status_ = status(response); + status_message_ = status_message(response); + BOOST_CHECK_EQUAL ( version_.substr(0, 7), std::string("HTTP/1.") ); + BOOST_CHECK_EQUAL ( status_, 200u ); + BOOST_CHECK_EQUAL ( status_message_, std::string("OK") ); + dummy_body = body(response); + } + BOOST_CHECK ( dummy_body == std::string() ); } From b542d50bcaedf75acb739626b61fb4946e8c4837 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sun, 11 Mar 2012 22:13:19 +1100 Subject: [PATCH 051/196] Incremental Progress on HTTP Message This time I've gotten all the tests to start building and linking. Now it's the long road ahead to getting all the tests passing. There's a number of API changes that need to be documented too. The tests are now using opaque types and the virtual interfaces are clear delineations for extension. At some point implementations of different kinds of connection managers, connection delegates, connections (websocket, spdy, proxied http, etc.), and other things would be nice to have. The next step probably is to get some sort of mocking around the connections so that the HTTP parsing/handling logic can be handled properly. Fake implementations of the connections now that they're properly virtualized are going to be the other main focus going forward. --- .../protocol/http/message/wrappers/status.hpp | 11 ++----- .../protocol/http/message/wrappers/status.ipp | 30 +++++++++++++++++ .../http/message/wrappers/status_message.hpp | 10 ++---- .../http/message/wrappers/status_message.ipp | 32 +++++++++++++++++++ .../http/message/wrappers/version.hpp | 11 +++---- .../http/message/wrappers/version.ipp | 32 +++++++++++++++++++ libs/network/src/http/response.cpp | 4 +++ 7 files changed, 108 insertions(+), 22 deletions(-) create mode 100644 boost/network/protocol/http/message/wrappers/status.ipp create mode 100644 boost/network/protocol/http/message/wrappers/status_message.ipp create mode 100644 boost/network/protocol/http/message/wrappers/version.ipp diff --git a/boost/network/protocol/http/message/wrappers/status.hpp b/boost/network/protocol/http/message/wrappers/status.hpp index cba2f8618..cb902ca54 100644 --- a/boost/network/protocol/http/message/wrappers/status.hpp +++ b/boost/network/protocol/http/message/wrappers/status.hpp @@ -11,22 +11,17 @@ namespace boost { namespace network { namespace http { -namespace impl { - struct status_wrapper { - explicit status_wrapper(response_base & response_); - operator std::string () const; + explicit status_wrapper(response_base & response); operator uint16_t () const; private: response_base & response_; }; -} // namespace impl - inline -impl::status_wrapper +status_wrapper const status(response_base & response) { - return impl::status_wrapper(response); + return status_wrapper(response); } } // namespace http diff --git a/boost/network/protocol/http/message/wrappers/status.ipp b/boost/network/protocol/http/message/wrappers/status.ipp new file mode 100644 index 000000000..70480ac8d --- /dev/null +++ b/boost/network/protocol/http/message/wrappers/status.ipp @@ -0,0 +1,30 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_IPP_20120311 +#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_IPP_20120311 + +// Copyright 2012 Dean Michael Berris . +// Copyright 2012 Google, Inc. +// 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) + +#include + +namespace boost { namespace network { namespace http { + +status_wrapper::status_wrapper(response_base &response) +: response_(response_) +{} + +status_wrapper::operator uint16_t () const { + uint16_t status; + response_.get_status(status); + return status; +} + +} // namespace http + +} // namespace network + +} // namespace boost + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_IPP_20120311 diff --git a/boost/network/protocol/http/message/wrappers/status_message.hpp b/boost/network/protocol/http/message/wrappers/status_message.hpp index 40c5306a3..a9258026c 100644 --- a/boost/network/protocol/http/message/wrappers/status_message.hpp +++ b/boost/network/protocol/http/message/wrappers/status_message.hpp @@ -11,10 +11,8 @@ namespace boost { namespace network { namespace http { -namespace impl { - struct status_message_wrapper { - explicit status_message_wrapper(response_base & response_); + explicit status_message_wrapper(response_base & response); operator std::string () const; private: response_base & response_; @@ -25,12 +23,10 @@ inline std::ostream & operator<<(std::ostream & os, status_message_wrapper const return os << static_cast(status_message); } -} // namespace impl - inline -impl::status_message_wrapper +status_message_wrapper status_message(response_base & response) { - return impl::status_message_wrapper(response); + return status_message_wrapper(response); } } // namespace http diff --git a/boost/network/protocol/http/message/wrappers/status_message.ipp b/boost/network/protocol/http/message/wrappers/status_message.ipp new file mode 100644 index 000000000..da76cb7ba --- /dev/null +++ b/boost/network/protocol/http/message/wrappers/status_message.ipp @@ -0,0 +1,32 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_MESSAGE_IPP_20120311 +#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_MESSAGE_IPP_20120311 + +// Copyright 2012 Dean Michael Berris . +// Copyright 2012 Google, Inc. +// 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) + +#include + +namespace boost { namespace network { namespace http { + +status_message_wrapper::status_message_wrapper(response_base &response) +: response_(response) +{} + +status_message_wrapper::operator std::string () const { + if (cache_) return *cache_; + std::string tmp; + response_.get_status_message(tmp); + cache_ = tmp; + return *cache_; +} + +} // namespace http + +} // namespace network + +} // namespace boost + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_MESSAGE_IPP_20120311 diff --git a/boost/network/protocol/http/message/wrappers/version.hpp b/boost/network/protocol/http/message/wrappers/version.hpp index 28e35988b..b166758b6 100644 --- a/boost/network/protocol/http/message/wrappers/version.hpp +++ b/boost/network/protocol/http/message/wrappers/version.hpp @@ -1,8 +1,9 @@ #ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_VERSION_HPP_20100603 #define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_VERSION_HPP_20100603 -// Copyright 2010 (c) Dean Michael Berris +// Copyright 2010-2012 (c) Dean Michael Berris // Copyright 2010 (c) Sinefunc, Inc. +// Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -11,8 +12,6 @@ namespace boost { namespace network { namespace http { -namespace impl { - struct version_wrapper { explicit version_wrapper(response_base & response_); operator std::string() const; @@ -25,12 +24,10 @@ inline std::ostream & operator<< (std::ostream & os, version_wrapper const & ver return os << static_cast(version); } -} // namespace impl - inline -impl::version_wrapper +version_wrapper version(response_base & response) { - return impl::version_wrapper(response); + return version_wrapper(response); } } // namespace http diff --git a/boost/network/protocol/http/message/wrappers/version.ipp b/boost/network/protocol/http/message/wrappers/version.ipp new file mode 100644 index 000000000..9620b01b0 --- /dev/null +++ b/boost/network/protocol/http/message/wrappers/version.ipp @@ -0,0 +1,32 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_VERSION_IPP_20120311 +#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_VERSION_IPP_20120311 + +// Copyright 2012 Dean Michael Berris . +// Copyright 2012 Google, Inc. +// 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) + +#include + +namespace boost { namespace network { namespace http { + +version_wrapper::version_wrapper(response_base & response) +: response_(response) +{} + +version_wrapper::operator std::string() const { + if (cache_) return *cache_; + std::string tmp; + response_.get_version(tmp); + cache_ = tmp; + return *cache_; +} + +} // namespace http + +} // namespace network + +} // namespace boost + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_VERSION_IPP_20120311 diff --git a/libs/network/src/http/response.cpp b/libs/network/src/http/response.cpp index 5fcd7c347..d3413fe14 100644 --- a/libs/network/src/http/response.cpp +++ b/libs/network/src/http/response.cpp @@ -10,3 +10,7 @@ #include #include + +#include +#include +#include From 1df741587c46ef67680033d662a394dc61d2cb48 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Mon, 12 Mar 2012 17:41:12 +1100 Subject: [PATCH 052/196] Address initialization errors. --- boost/network/protocol/http/client/base.ipp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/boost/network/protocol/http/client/base.ipp b/boost/network/protocol/http/client/base.ipp index baf9d262d..8c127bf18 100644 --- a/boost/network/protocol/http/client/base.ipp +++ b/boost/network/protocol/http/client/base.ipp @@ -14,6 +14,7 @@ #include #include #include +#include #include namespace boost { namespace network { namespace http { @@ -65,9 +66,14 @@ client_base::~client_base() { client_base_pimpl::client_base_pimpl(client_options const &options) : options_(options), service_ptr(options.io_service()), - sentinel_(new (std::nothrow) boost::asio::io_service::work(*service_ptr)), + sentinel_(), connection_manager_(options.connection_manager()) { + if (service_ptr == 0) service_ptr = new(std::nothrow) asio::io_service; + if (!connection_manager_.get()) + connection_manager_.reset( + new (std::nothrow) simple_connection_manager(options)); + sentinel_.reset(new (std::nothrow) boost::asio::io_service::work(*service_ptr)); lifetime_thread_.reset(new (std::nothrow) boost::thread( boost::bind( &boost::asio::io_service::run, From 2c69f64ec20a37e2900b8a6482f44d3c256a381e Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Tue, 13 Mar 2012 15:00:29 +1100 Subject: [PATCH 053/196] Long road to functional http::request. One of the larger casualties of this refactor is http::request which has been turned into a pimpl'ed value type. The implementation still has a heavy-weight copy but at some point we can actually go ahead and do some "copy-on-write" behavior if we really want to. For now we're going to cover all the supported public APIs for the http::request object. Once we're done with that we can then continue to debugging, testing, and mocking out certain parts for the HTTP client objects. I have a sneaking suspicion that if we get done with the http::request and http::response objects then the HTTP clients might "just work". --- .../http/client/client_connection.ipp | 3 +- .../http/client/simple_connection_manager.ipp | 7 +++- .../network/protocol/http/request/request.ipp | 33 ++++++++++++++++--- libs/network/test/http/CMakeLists.txt | 29 +++++++++++----- libs/network/test/http/request_test.cpp | 27 +++++++++++++++ 5 files changed, 83 insertions(+), 16 deletions(-) create mode 100644 libs/network/test/http/request_test.cpp diff --git a/boost/network/protocol/http/client/client_connection.ipp b/boost/network/protocol/http/client/client_connection.ipp index ef0e147d2..8995442a1 100644 --- a/boost/network/protocol/http/client/client_connection.ipp +++ b/boost/network/protocol/http/client/client_connection.ipp @@ -13,8 +13,7 @@ namespace boost { namespace network { namespace http { client_connection::~client_connection() { - // For exposition only. - BOOST_ASSERT(false && "This should not ever be called."); + // Do nothing here. } client_connection * client_connection::clone() const { diff --git a/boost/network/protocol/http/client/simple_connection_manager.ipp b/boost/network/protocol/http/client/simple_connection_manager.ipp index 17f61a732..a5aa72d7f 100644 --- a/boost/network/protocol/http/client/simple_connection_manager.ipp +++ b/boost/network/protocol/http/client/simple_connection_manager.ipp @@ -8,6 +8,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include +#include #include namespace boost { namespace network { namespace http { @@ -16,7 +17,11 @@ struct simple_connection_manager_pimpl { simple_connection_manager_pimpl(client_options const &options) : options_(options) , connection_factory_(options.connection_factory()) - {} + { + if (!connection_factory_.get()) + connection_factory_.reset( + new (std::nothrow) simple_connection_factory()); + } shared_ptr get_connection(asio::io_service & service, request_base const & request, diff --git a/boost/network/protocol/http/request/request.ipp b/boost/network/protocol/http/request/request.ipp index add2e14d9..6febaa3e6 100644 --- a/boost/network/protocol/http/request/request.ipp +++ b/boost/network/protocol/http/request/request.ipp @@ -17,13 +17,28 @@ BOOST_CONCEPT_ASSERT((boost::network::http::ClientRequest writer){} -void request::set_uri(std::string const &uri){} +void request::set_uri(std::string const &uri) { + pimpl_->set_uri(uri); +} void request::set_uri(network::uri::uri const &uri){} // Getters void request::get_uri(network::uri::uri &uri) const{} -void request::get_uri(std::string &uri) const{} + +void request::get_uri(std::string &uri) const { + pimpl_->get_uri(uri); +} + void request::get_method(std::string & method) const{} void request::get_status(std::string & status) const{} void request::get_status_message(std::string & status_message) const{} diff --git a/libs/network/test/http/CMakeLists.txt b/libs/network/test/http/CMakeLists.txt index 4f30d8f9a..3de77f4fc 100644 --- a/libs/network/test/http/CMakeLists.txt +++ b/libs/network/test/http/CMakeLists.txt @@ -13,15 +13,26 @@ endif() if (Boost_FOUND) # These are the internal (simple) tests. - add_executable(cpp-netlib-http-request_base_test request_base_test.cpp) - target_link_libraries(cpp-netlib-http-request_base_test - ${Boost_LIBRARIES} - cppnetlib-message - cppnetlib-http-message) - set_target_properties(cpp-netlib-http-request_base_test - PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests) - add_test(cpp-netlib-http-request_base_test - ${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-http-request_base_test) + set ( MESSAGE_TESTS + request_base_test + request_test + ) + foreach ( test ${MESSAGE_TESTS} ) + if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) + set_source_files_properties(${test}.cpp + PROPERTIES COMPILE_FLAGS "-Wall") + endif() + add_executable(cpp-netlib-http-${test} ${test}.cpp) + target_link_libraries(cpp-netlib-http-${test} + ${Boost_LIBRARIES} + cppnetlib-message + cppnetlib-uri + cppnetlib-http-message) + set_target_properties(cpp-netlib-http-${test} + PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests) + add_test(cpp-netlib-http-${test} + ${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-http-${test}) + endforeach(test) set ( TESTS client_constructor_test diff --git a/libs/network/test/http/request_test.cpp b/libs/network/test/http/request_test.cpp new file mode 100644 index 000000000..4c35453ad --- /dev/null +++ b/libs/network/test/http/request_test.cpp @@ -0,0 +1,27 @@ +// Copyright 2012 Dean Michael Berris . +// Copyright 2012 Google, Inc. +// 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) + +#define BOOST_TEST_MODULE HTTP Request Test +#include +#include + +namespace http = boost::network::http; + +BOOST_AUTO_TEST_CASE(request_construction) { + http::request request; + http::request other(request); +} + +BOOST_AUTO_TEST_CASE(request_uri_test) { + http::request request; + request.set_uri("http://www.google.com/"); + http::request other(request); + std::string original, copied; + request.get_uri(original); + other.get_uri(copied); + BOOST_CHECK_EQUAL(std::string("http://www.google.com/"), original); + BOOST_CHECK_EQUAL(original, copied); +} From 43f56f318a67784c777c81dc9da06b927e069834 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Tue, 13 Mar 2012 21:29:34 +1100 Subject: [PATCH 054/196] Additional cases for request_test. This is just an incremental test case that uses a little of the mix between the pimpl held in the request and the native storage that is part of the request_storage_base from which the request derives from. This is the default implementation and it's possible to implement a different request type that uses different internal storage (probably a better idea for mmap-io backed storage, etc.). --- .../network/protocol/http/request/request.ipp | 184 +++++++++++++++--- .../protocol/http/request/request_base.hpp | 4 +- .../protocol/http/request/request_base.ipp | 12 +- libs/network/test/http/CMakeLists.txt | 1 + libs/network/test/http/request_test.cpp | 26 +++ 5 files changed, 194 insertions(+), 33 deletions(-) diff --git a/boost/network/protocol/http/request/request.ipp b/boost/network/protocol/http/request/request.ipp index 6febaa3e6..fe5e04ad8 100644 --- a/boost/network/protocol/http/request/request.ipp +++ b/boost/network/protocol/http/request/request.ipp @@ -9,6 +9,7 @@ #include #include +#include #ifdef BOOST_NETWORK_DEBUG BOOST_CONCEPT_ASSERT((boost::network::http::ClientRequest)); @@ -21,6 +22,9 @@ struct request_pimpl { explicit request_pimpl(std::string const & url) : uri_(url) + , read_offset_(0) + , source_() + , headers_() {} request_pimpl* clone() { @@ -31,14 +35,78 @@ struct request_pimpl { uri_ = uri; } + void set_uri(uri::uri const & uri) { + uri_ = uri; + } + void get_uri(std::string &uri) { uri = uri_.string(); } + void get_uri(uri::uri &uri) { + uri = uri_; + } + + void append_header(std::string const & name, std::string const & value) { + headers_.insert(std::make_pair(name, value)); + } + + void get_headers(function predicate, + function inserter) const { + headers_type::const_iterator it = headers_.begin(); + for (; it != headers_.end(); ++it) { + if (predicate(it->first, it->second)) { + inserter(it->first, it->second); + } + } + } + + void get_headers(function inserter) const { + headers_type::const_iterator it = headers_.begin(); + for (; it != headers_.end(); ++it) { + inserter(it->first, it->second); + } + } + + void get_headers(std::string const &name, + function inserter) const { + headers_type::const_iterator it = headers_.begin(); + for (; it != headers_.end(); ++it) { + if (it->first == name) { + inserter(it->first, it->second); + } + } + } + + void set_source(std::string const &source) { + source_ = source; + } + + void get_source(std::string &source) const { + source = source_; + } + + size_t read_offset() const { + return read_offset_; + } + + void advance_read_offset(size_t bytes) { + read_offset_ += bytes; + } + private: + typedef std::multimap headers_type; + uri::uri uri_; + size_t read_offset_; + std::string source_; + headers_type headers_; + request_pimpl(request_pimpl const &other) : uri_(other.uri_) + , read_offset_(other.read_offset_) + , source_(other.source_) + , headers_(other.headers_) {} }; @@ -68,47 +136,113 @@ void request::swap(request & other) { // From message_base... // Mutators -void request::set_destination(std::string const & destination){} -void request::set_source(std::string const & source){} +void request::set_destination(std::string const & destination) { +} + +void request::set_source(std::string const & source) { + pimpl_->set_source(source); +} + void request::append_header(std::string const & name, - std::string const & value){} -void request::remove_headers(std::string const & name){} -void request::remove_headers(){} -void request::set_body(std::string const & body){} -void request::append_body(std::string const & data){} + std::string const & value) { + pimpl_->append_header(name, value); +} + +void request::remove_headers(std::string const & name) { +} + +void request::remove_headers() { +} + +void request::set_body(std::string const & body) { + this->clear(); + this->append(body.data(), body.size()); +} + +void request::append_body(std::string const & data) { + this->append(data.data(), data.size()); +} // Retrievers -void request::get_destination(std::string & destination) const{} -void request::get_source(std::string & source) const{} -void request::get_headers(function inserter) const{} -void request::get_headers(std::string const & name, function inserter) const{} -void request::get_headers(function predicate, function inserter) const{} -void request::get_body(std::string & body) const{} -void request::get_body(function)> chunk_reader, size_t size) const{} +void request::get_destination(std::string & destination) const { +} + +void request::get_source(std::string & source) const { + pimpl_->get_source(source); +} + +void request::get_headers(function inserter) const { + pimpl_->get_headers(inserter); +} + +void request::get_headers(std::string const & name, function inserter) const { + pimpl_->get_headers(name, inserter); +} + +void request::get_headers(function predicate, function inserter) const { + pimpl_->get_headers(predicate, inserter); +} + +void request::get_body(std::string & body) const { + this->flatten(body); +} + +void request::get_body(function)> chunk_reader, size_t size) const { + scoped_array local_buffer(new (std::nothrow) char[size]); + size_t bytes_read = this->read(local_buffer.get(), + pimpl_->read_offset(), + size); + pimpl_->advance_read_offset(bytes_read); + char const * begin = local_buffer.get(); + char const * end = local_buffer.get() + bytes_read; + chunk_reader(make_iterator_range(begin, end)); +} // From request_base... // Setters -void request::set_method(std::string const & method){} -void request::set_status(std::string const & status){} -void request::set_status_message(std::string const & status_message){} -void request::set_body_writer(function writer){} +void request::set_method(std::string const & method) { +} + +void request::set_status(std::string const & status) { +} + +void request::set_status_message(std::string const & status_message) { +} + +void request::set_body_writer(function writer) { +} + void request::set_uri(std::string const &uri) { pimpl_->set_uri(uri); } -void request::set_uri(network::uri::uri const &uri){} + +void request::set_uri(network::uri::uri const &uri) { + pimpl_->set_uri(uri); +} // Getters -void request::get_uri(network::uri::uri &uri) const{} +void request::get_uri(network::uri::uri &uri) const { + pimpl_->get_uri(uri); +} void request::get_uri(std::string &uri) const { pimpl_->get_uri(uri); } -void request::get_method(std::string & method) const{} -void request::get_status(std::string & status) const{} -void request::get_status_message(std::string & status_message) const{} -void request::get_body(function chunk_reader) const{} -void request::get_body(std::string const & body) const{} +void request::get_method(std::string & method) const { +} + +void request::get_status(std::string & status) const { +} + +void request::get_status_message(std::string & status_message) const { +} + +void request::get_body(function chunk_reader) const { +} + +void request::get_body(std::string const & body) const { +} } // namespace http diff --git a/boost/network/protocol/http/request/request_base.hpp b/boost/network/protocol/http/request/request_base.hpp index 0e257c7c5..596453415 100644 --- a/boost/network/protocol/http/request/request_base.hpp +++ b/boost/network/protocol/http/request/request_base.hpp @@ -27,8 +27,8 @@ struct request_storage_base { protected: request_storage_base(size_t chunk_size = BOOST_NETWORK_BUFFER_CHUNK); virtual void append(char const *data, size_t size); - virtual size_t read(char *destination, size_t offset, size_t size); - virtual void flatten(std::string &destination); + virtual size_t read(char *destination, size_t offset, size_t size) const; + virtual void flatten(std::string &destination) const; virtual void clear(); virtual ~request_storage_base(); diff --git a/boost/network/protocol/http/request/request_base.ipp b/boost/network/protocol/http/request/request_base.ipp index aaf052821..eeed24c3d 100644 --- a/boost/network/protocol/http/request/request_base.ipp +++ b/boost/network/protocol/http/request/request_base.ipp @@ -20,8 +20,8 @@ request_base::~request_base() { struct request_storage_base_pimpl { request_storage_base_pimpl(size_t chunk_size); void append(char const *data, size_t size); - size_t read(char *destination, size_t offset, size_t size); - void flatten(std::string &destination); + size_t read(char *destination, size_t offset, size_t size) const; + void flatten(std::string &destination) const; void clear(); request_storage_base_pimpl clone() const; ~request_storage_base_pimpl(); @@ -45,11 +45,11 @@ void request_storage_base::append(char const *data, size_t size) { pimpl_->append(data, size); } -size_t request_storage_base::read(char *destination, size_t offset, size_t size) { +size_t request_storage_base::read(char *destination, size_t offset, size_t size) const { return pimpl_->read(destination, offset, size); } -void request_storage_base::flatten(std::string &destination) { +void request_storage_base::flatten(std::string &destination) const { pimpl_->flatten(destination); } @@ -90,7 +90,7 @@ void request_storage_base_pimpl::append(char const *data, size_t size) { } } -size_t request_storage_base_pimpl::read(char *destination, size_t offset, size_t size) { +size_t request_storage_base_pimpl::read(char *destination, size_t offset, size_t size) const { if (chunks_.empty()) return 0; // First we find which chunk we're going to read from using the provided // offset and some arithmetic to determine the correct one. @@ -114,7 +114,7 @@ size_t request_storage_base_pimpl::read(char *destination, size_t offset, size_t return read_count; } -void request_storage_base_pimpl::flatten(std::string &destination) { +void request_storage_base_pimpl::flatten(std::string &destination) const { chunks_vector::const_iterator chunk_iterator = chunks_.begin(); for (; chunk_iterator != chunks_.end(); ++chunk_iterator) { destination.append(chunk_iterator->first, chunk_iterator->second); diff --git a/libs/network/test/http/CMakeLists.txt b/libs/network/test/http/CMakeLists.txt index 3de77f4fc..7f1535e00 100644 --- a/libs/network/test/http/CMakeLists.txt +++ b/libs/network/test/http/CMakeLists.txt @@ -26,6 +26,7 @@ if (Boost_FOUND) target_link_libraries(cpp-netlib-http-${test} ${Boost_LIBRARIES} cppnetlib-message + cppnetlib-message-wrappers cppnetlib-uri cppnetlib-http-message) set_target_properties(cpp-netlib-http-${test} diff --git a/libs/network/test/http/request_test.cpp b/libs/network/test/http/request_test.cpp index 4c35453ad..225417f82 100644 --- a/libs/network/test/http/request_test.cpp +++ b/libs/network/test/http/request_test.cpp @@ -6,9 +6,12 @@ #define BOOST_TEST_MODULE HTTP Request Test #include +#include #include namespace http = boost::network::http; +namespace uri = boost::network::uri; +namespace net = boost::network; BOOST_AUTO_TEST_CASE(request_construction) { http::request request; @@ -25,3 +28,26 @@ BOOST_AUTO_TEST_CASE(request_uri_test) { BOOST_CHECK_EQUAL(std::string("http://www.google.com/"), original); BOOST_CHECK_EQUAL(original, copied); } + +BOOST_AUTO_TEST_CASE(request_basics_test) { + http::request request; + request.set_uri("http://www.google.com/"); + request.set_source("127.0.0.1"); + request.set_destination("http://www.google.com/"); + request.append_header("X-Referer", "http://cpp-netlib.github.com/"); + request.append_header("Connection", "close"); + request.append_body("The quick brown fox jumps over the lazy dog!"); + + uri::uri uri_; + std::string source_, destination_, body_; + net::headers_wrapper::range_type headers_range = headers(request); + request.get_uri(uri_); + request.get_source(source_); + request.get_destination(destination_); + request.get_body(body_); + + BOOST_CHECK_EQUAL(uri_.string(), std::string("http://www.google.com/")); + BOOST_CHECK_EQUAL(source_, std::string("127.0.0.1")); + BOOST_CHECK_EQUAL(body_, std::string("The quick brown fox jumps over the lazy dog!")); + BOOST_CHECK(!boost::empty(headers_range)); +} From ddf1765286e1aea71402f156c4b86bf17d4bda57 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Wed, 14 Mar 2012 14:24:06 +1100 Subject: [PATCH 055/196] Value Semantics for request_storage_base. Here we make sure that copies of types deriving from request_storage_base will properly copy the data (not copy-on-write) that is in the buffers of the original object. --- .../network/protocol/http/request/request.hpp | 4 --- .../protocol/http/request/request_base.hpp | 5 +--- .../protocol/http/request/request_base.ipp | 30 +++++++++++++++++-- libs/network/test/http/CMakeLists.txt | 1 - libs/network/test/http/request_base_test.cpp | 25 +++++++++++++++- 5 files changed, 53 insertions(+), 12 deletions(-) diff --git a/boost/network/protocol/http/request/request.hpp b/boost/network/protocol/http/request/request.hpp index a860c8d92..641324e53 100644 --- a/boost/network/protocol/http/request/request.hpp +++ b/boost/network/protocol/http/request/request.hpp @@ -88,10 +88,6 @@ inline void swap(request &l, request &r) { } // namespace boost -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif - #include #include #include diff --git a/boost/network/protocol/http/request/request_base.hpp b/boost/network/protocol/http/request/request_base.hpp index 596453415..c7e37f662 100644 --- a/boost/network/protocol/http/request/request_base.hpp +++ b/boost/network/protocol/http/request/request_base.hpp @@ -26,6 +26,7 @@ struct request_storage_base_pimpl; struct request_storage_base { protected: request_storage_base(size_t chunk_size = BOOST_NETWORK_BUFFER_CHUNK); + request_storage_base(request_storage_base const &other); virtual void append(char const *data, size_t size); virtual size_t read(char *destination, size_t offset, size_t size) const; virtual void flatten(std::string &destination) const; @@ -62,8 +63,4 @@ struct request_base : message_base, request_storage_base { } /* boost */ -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif - #endif /* BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_BASE_HPP_20111008 */ diff --git a/boost/network/protocol/http/request/request_base.ipp b/boost/network/protocol/http/request/request_base.ipp index eeed24c3d..409c9f49d 100644 --- a/boost/network/protocol/http/request/request_base.ipp +++ b/boost/network/protocol/http/request/request_base.ipp @@ -18,12 +18,12 @@ request_base::~request_base() { } struct request_storage_base_pimpl { - request_storage_base_pimpl(size_t chunk_size); + explicit request_storage_base_pimpl(size_t chunk_size); + request_storage_base_pimpl *clone() const; void append(char const *data, size_t size); size_t read(char *destination, size_t offset, size_t size) const; void flatten(std::string &destination) const; void clear(); - request_storage_base_pimpl clone() const; ~request_storage_base_pimpl(); private: @@ -31,12 +31,18 @@ struct request_storage_base_pimpl { typedef std::vector > chunks_vector; chunks_vector chunks_; mutex chunk_mutex; + + request_storage_base_pimpl(request_storage_base_pimpl const &other); }; request_storage_base::request_storage_base(size_t chunk_size) : pimpl_(new (std::nothrow) request_storage_base_pimpl(chunk_size)) {} +request_storage_base::request_storage_base(request_storage_base const &other) +: pimpl_(other.pimpl_->clone()) +{} + request_storage_base::~request_storage_base() { delete pimpl_; } @@ -64,6 +70,25 @@ request_storage_base_pimpl::request_storage_base_pimpl(size_t chunk_size) // do nothing here. } +request_storage_base_pimpl::request_storage_base_pimpl(request_storage_base_pimpl const &other) +: chunk_size_(other.chunk_size_) +, chunks_(0) { + chunks_.reserve(other.chunks_.size()); + chunks_vector::const_iterator it = other.chunks_.begin(); + for (; it != other.chunks_.end(); ++it) { + chunks_vector::value_type pair = + std::make_pair( + new (std::nothrow) char[other.chunk_size_], + it->second); + std::memcpy(pair.first, it->first, it->second); + chunks_.push_back(pair); + } +} + +request_storage_base_pimpl * request_storage_base_pimpl::clone() const { + return new(std::nothrow) request_storage_base_pimpl(*this); +} + void request_storage_base_pimpl::append(char const *data, size_t size) { if (chunks_.empty()) { chunks_.push_back(std::make_pair( @@ -133,6 +158,7 @@ request_storage_base_pimpl::~request_storage_base_pimpl() { clear(); } + } /* http */ } /* network */ diff --git a/libs/network/test/http/CMakeLists.txt b/libs/network/test/http/CMakeLists.txt index 7f1535e00..b9367381b 100644 --- a/libs/network/test/http/CMakeLists.txt +++ b/libs/network/test/http/CMakeLists.txt @@ -78,7 +78,6 @@ if (Boost_FOUND) PROPERTIES COMPILE_FLAGS "-Wall") endif() add_executable(cpp-netlib-http-${test} ${test}.cpp) - add_dependencies(cpp-netlib-http-${test} cppnetlib-server-parsers) target_link_libraries(cpp-netlib-http-${test} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-server-parsers) set_target_properties(cpp-netlib-http-${test} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests) diff --git a/libs/network/test/http/request_base_test.cpp b/libs/network/test/http/request_base_test.cpp index f91ffd445..a5fdaa8de 100644 --- a/libs/network/test/http/request_base_test.cpp +++ b/libs/network/test/http/request_base_test.cpp @@ -23,10 +23,14 @@ struct request_test : http::request_storage_base { using base_type::flatten; using base_type::clear; - request_test(size_t chunk_size) + explicit request_test(size_t chunk_size) : base_type(chunk_size) {} + request_test(request_test const &other) + : base_type(other) + {} + ~request_test() { // do nothing here. } @@ -47,3 +51,22 @@ BOOST_AUTO_TEST_CASE(request_storage_flow) { BOOST_CHECK_EQUAL(std::string(data, sizeof(data)), std::string(output, sizeof(data))); simple.clear(); } + +BOOST_AUTO_TEST_CASE(request_storage_copy) { + // Use a few byt chunks just to make it manageable. + request_test original(64); + static char quick_brown[] = "The quick brown fox jumps over the lazy dog."; + original.append(quick_brown, sizeof(quick_brown)); + char output[sizeof(quick_brown)]; + request_test copy(original); + size_t bytes_read = copy.read(output, 0, sizeof(quick_brown)); + BOOST_CHECK_EQUAL(bytes_read, sizeof(quick_brown)); + std::string flattened; + copy.flatten(flattened); + BOOST_CHECK_EQUAL(flattened, std::string(output, sizeof(quick_brown))); + BOOST_CHECK_EQUAL(std::string(quick_brown, sizeof(quick_brown)), std::string(output, sizeof(quick_brown))); + copy.clear(); + flattened.clear(); + original.flatten(flattened); + BOOST_CHECK_EQUAL(flattened, std::string(quick_brown, sizeof(quick_brown))); +} From 23a4c5f38217e167e4a8fb4d45ffa560e624e06b Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Wed, 14 Mar 2012 15:07:29 +1100 Subject: [PATCH 056/196] Fix bug with non-owned io_service deletion. This was a bug waiting to happen that I've plugged. In case a non-owned io_service was provided to the base, it will still delete it in the constructor. I've changed it so that it only deletes the io_service in case the base object owns the created io_service -- leaves it alone otherwise. --- boost/network/protocol/http/client/base.hpp | 4 ---- boost/network/protocol/http/client/base.ipp | 12 ++++++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/boost/network/protocol/http/client/base.hpp b/boost/network/protocol/http/client/base.hpp index 46c61759c..04a5916ea 100644 --- a/boost/network/protocol/http/client/base.hpp +++ b/boost/network/protocol/http/client/base.hpp @@ -45,8 +45,4 @@ struct client_base { } /* boost */ -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif - #endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_BASE_HPP_20111008 */ diff --git a/boost/network/protocol/http/client/base.ipp b/boost/network/protocol/http/client/base.ipp index 8c127bf18..f938bf8d5 100644 --- a/boost/network/protocol/http/client/base.ipp +++ b/boost/network/protocol/http/client/base.ipp @@ -37,6 +37,7 @@ struct client_base_pimpl { boost::shared_ptr sentinel_; boost::shared_ptr lifetime_thread_; shared_ptr connection_manager_; + bool owned_service_; }; client_base::client_base() @@ -67,9 +68,12 @@ client_base_pimpl::client_base_pimpl(client_options const &options) : options_(options), service_ptr(options.io_service()), sentinel_(), - connection_manager_(options.connection_manager()) -{ - if (service_ptr == 0) service_ptr = new(std::nothrow) asio::io_service; + connection_manager_(options.connection_manager()), + owned_service_(false) { + if (service_ptr == 0) { + service_ptr = new(std::nothrow) asio::io_service; + owned_service_ = true; + } if (!connection_manager_.get()) connection_manager_.reset( new (std::nothrow) simple_connection_manager(options)); @@ -91,7 +95,7 @@ client_base_pimpl::~client_base_pimpl() lifetime_thread_->join(); lifetime_thread_.reset(); } - delete service_ptr; + if (owned_service_) delete service_ptr; } response const client_base_pimpl::request_skeleton( From e7e7df6785c6d55512ec772c91dfde13d7ebc0da Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Wed, 14 Mar 2012 16:55:24 +1100 Subject: [PATCH 057/196] Fix bug with URI equality comparison. I found this bug mostly when I was implementing and supporting value semantics in the request object. Added a test to expose the bug. I suppose there's a better fix here but in the meantime I'm going with this one. --- boost/network/uri/uri.hpp | 5 ++++- libs/network/test/uri/url_test.cpp | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/boost/network/uri/uri.hpp b/boost/network/uri/uri.hpp index 4507691df..ee84de256 100644 --- a/boost/network/uri/uri.hpp +++ b/boost/network/uri/uri.hpp @@ -280,7 +280,10 @@ bool is_valid(const uri &uri_) { inline bool operator == (const uri &lhs, const uri &rhs) { - return std::equal(lhs.begin(), lhs.end(), rhs.begin()); + if (boost::empty(lhs) && boost::empty(rhs)) return true; + if ((boost::empty(lhs) && !boost::empty(rhs)) || + (boost::empty(rhs) && !boost::empty(lhs))) return false; + return std::equal(lhs.begin(), lhs.end(), rhs.begin()); } } // namespace uri diff --git a/libs/network/test/uri/url_test.cpp b/libs/network/test/uri/url_test.cpp index ab9d9eb09..a3eea3a91 100644 --- a/libs/network/test/uri/url_test.cpp +++ b/libs/network/test/uri/url_test.cpp @@ -27,6 +27,17 @@ BOOST_AUTO_TEST_CASE(basic_uri_test) { BOOST_CHECK_EQUAL(uri::fragment(instance), ""); } +BOOST_AUTO_TEST_CASE(basic_uri_value_semantics_test) { + uri::uri original; + uri::uri assigned; + assigned = original; + BOOST_CHECK(original == assigned); + assigned = "http://www.example.com/"; + BOOST_CHECK(original != assigned); + uri::uri copy(assigned); + BOOST_CHECK(copy == assigned); +} + BOOST_AUTO_TEST_CASE(basic_uri_range_test) { uri::uri instance("http://www.example.com/"); BOOST_REQUIRE(uri::valid(instance)); From 84e46e6711c0e9565a9ded8896315e4c516ed499 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Wed, 14 Mar 2012 17:05:17 +1100 Subject: [PATCH 058/196] Initial value semantics support for request. In this commit we implement some support for partial value semantics. This is important so that we can put the request objects into a container and compare two requests whether they are semantically equal value-wise. --- .../network/protocol/http/request/request.hpp | 11 +++++++-- .../network/protocol/http/request/request.ipp | 14 ++++++++++- .../protocol/http/request/request_base.hpp | 1 + .../protocol/http/request/request_base.ipp | 18 ++++++++++++++ libs/network/test/http/request_test.cpp | 24 +++++++++++++++++++ 5 files changed, 65 insertions(+), 3 deletions(-) diff --git a/boost/network/protocol/http/request/request.hpp b/boost/network/protocol/http/request/request.hpp index 641324e53..a506d63ab 100644 --- a/boost/network/protocol/http/request/request.hpp +++ b/boost/network/protocol/http/request/request.hpp @@ -18,8 +18,6 @@ namespace boost { namespace network { namespace http { struct request_pimpl; struct request : request_base { - // FIXME Implement all these! - // We support full value semantics. request(); explicit request(std::string const & url); @@ -27,6 +25,7 @@ struct request : request_base { request(request const &); request& operator=(request); void swap(request & other); + bool equals(request const &other) const; // From message_base... // Mutators @@ -82,6 +81,14 @@ inline void swap(request &l, request &r) { l.swap(r); } +inline bool operator==(request const &l, request const &r) { + return l.equals(r); +} + +inline bool operator!=(request const &l, request const &r) { + return !l.equals(r); +} + } // namespace http } // namespace network diff --git a/boost/network/protocol/http/request/request.ipp b/boost/network/protocol/http/request/request.ipp index fe5e04ad8..930e0a4f6 100644 --- a/boost/network/protocol/http/request/request.ipp +++ b/boost/network/protocol/http/request/request.ipp @@ -27,7 +27,7 @@ struct request_pimpl { , headers_() {} - request_pimpl* clone() { + request_pimpl* clone() const { return new (std::nothrow) request_pimpl(*this); } @@ -94,6 +94,13 @@ struct request_pimpl { read_offset_ += bytes; } + bool equals(request_pimpl const &other) const { + return uri_ == other.uri_ && + read_offset_ == other.read_offset_ && + source_ == other.source_ && + headers_ == other.headers_; + } + private: typedef std::multimap headers_type; @@ -130,6 +137,11 @@ request& request::operator=(request rhs) { rhs.swap(*this); } +bool request::equals(request const &other) const { + return pimpl_->equals(*other.pimpl_) && + request_storage_base::equals(other); +} + void request::swap(request & other) { std::swap(this->pimpl_, other.pimpl_); } diff --git a/boost/network/protocol/http/request/request_base.hpp b/boost/network/protocol/http/request/request_base.hpp index c7e37f662..4837dd1db 100644 --- a/boost/network/protocol/http/request/request_base.hpp +++ b/boost/network/protocol/http/request/request_base.hpp @@ -31,6 +31,7 @@ struct request_storage_base { virtual size_t read(char *destination, size_t offset, size_t size) const; virtual void flatten(std::string &destination) const; virtual void clear(); + virtual bool equals(request_storage_base const &other) const; virtual ~request_storage_base(); private: diff --git a/boost/network/protocol/http/request/request_base.ipp b/boost/network/protocol/http/request/request_base.ipp index 409c9f49d..ea702fb5a 100644 --- a/boost/network/protocol/http/request/request_base.ipp +++ b/boost/network/protocol/http/request/request_base.ipp @@ -24,6 +24,7 @@ struct request_storage_base_pimpl { size_t read(char *destination, size_t offset, size_t size) const; void flatten(std::string &destination) const; void clear(); + bool equals(request_storage_base_pimpl const &other) const; ~request_storage_base_pimpl(); private: @@ -63,6 +64,10 @@ void request_storage_base::clear() { pimpl_->clear(); } +bool request_storage_base::equals(request_storage_base const &other) const { + return pimpl_->equals(*other.pimpl_); +} + request_storage_base_pimpl::request_storage_base_pimpl(size_t chunk_size) : chunk_size_(chunk_size) , chunks_() @@ -154,6 +159,19 @@ void request_storage_base_pimpl::clear() { chunks_vector().swap(chunks_); } +bool request_storage_base_pimpl::equals(request_storage_base_pimpl const &other) const { + if (other.chunk_size_ != chunk_size_) return false; + if (other.chunks_.size() != chunks_.size()) return false; + chunks_vector::const_iterator chunk_iterator = chunks_.begin(); + chunks_vector::const_iterator other_iterator = other.chunks_.begin(); + for (; chunk_iterator != chunks_.begin() && other_iterator != other.chunks_.end(); + ++chunk_iterator, ++other_iterator) { + if (chunk_iterator->second != other_iterator->second) return false; + if (strncmp(chunk_iterator->first, other_iterator->first, chunk_iterator->second)) return false; + } + return true; +} + request_storage_base_pimpl::~request_storage_base_pimpl() { clear(); } diff --git a/libs/network/test/http/request_test.cpp b/libs/network/test/http/request_test.cpp index 225417f82..0d2e389a7 100644 --- a/libs/network/test/http/request_test.cpp +++ b/libs/network/test/http/request_test.cpp @@ -18,6 +18,30 @@ BOOST_AUTO_TEST_CASE(request_construction) { http::request other(request); } +BOOST_AUTO_TEST_CASE(request_value_semantics) { + // First let's default construct a request. + http::request original; + // Next let's copy the request. + http::request copy(original); + // Next let's compare the requests. + BOOST_CHECK(original == copy); + // Next let's assign the original to another request. + http::request assigned; + assigned = original; + // Next we modify the assigned object and make sure it's not the same as the + // original. + assigned.set_uri("http://www.google.com/"); + std::string original_uri, assigned_uri; + original.get_uri(original_uri); + assigned.get_uri(assigned_uri); + BOOST_CHECK_NE(original_uri, assigned_uri); + BOOST_CHECK(original != assigned); + // Next we swap the assigned and copy. + std::swap(assigned, copy); + BOOST_CHECK(copy != assigned); + BOOST_CHECK(assigned == original); +} + BOOST_AUTO_TEST_CASE(request_uri_test) { http::request request; request.set_uri("http://www.google.com/"); From 4c411e7a4222349f7e622034ce618b448a906cbb Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Wed, 14 Mar 2012 18:14:12 +1100 Subject: [PATCH 059/196] Swap support for request. --- .../network/protocol/http/request/request.ipp | 1 + .../protocol/http/request/request_base.hpp | 1 + .../protocol/http/request/request_base.ipp | 38 ++++++++++++++++--- libs/network/test/CMakeLists.txt | 2 - libs/network/test/http/request_test.cpp | 11 +++--- 5 files changed, 41 insertions(+), 12 deletions(-) diff --git a/boost/network/protocol/http/request/request.ipp b/boost/network/protocol/http/request/request.ipp index 930e0a4f6..392d34929 100644 --- a/boost/network/protocol/http/request/request.ipp +++ b/boost/network/protocol/http/request/request.ipp @@ -144,6 +144,7 @@ bool request::equals(request const &other) const { void request::swap(request & other) { std::swap(this->pimpl_, other.pimpl_); + request_storage_base::swap(other); } // From message_base... diff --git a/boost/network/protocol/http/request/request_base.hpp b/boost/network/protocol/http/request/request_base.hpp index 4837dd1db..fdb39d1cd 100644 --- a/boost/network/protocol/http/request/request_base.hpp +++ b/boost/network/protocol/http/request/request_base.hpp @@ -32,6 +32,7 @@ struct request_storage_base { virtual void flatten(std::string &destination) const; virtual void clear(); virtual bool equals(request_storage_base const &other) const; + virtual void swap(request_storage_base &other); virtual ~request_storage_base(); private: diff --git a/boost/network/protocol/http/request/request_base.ipp b/boost/network/protocol/http/request/request_base.ipp index ea702fb5a..5950d7daa 100644 --- a/boost/network/protocol/http/request/request_base.ipp +++ b/boost/network/protocol/http/request/request_base.ipp @@ -25,13 +25,14 @@ struct request_storage_base_pimpl { void flatten(std::string &destination) const; void clear(); bool equals(request_storage_base_pimpl const &other) const; + void swap(request_storage_base_pimpl &other); ~request_storage_base_pimpl(); private: size_t chunk_size_; typedef std::vector > chunks_vector; chunks_vector chunks_; - mutex chunk_mutex; + mutable mutex chunk_mutex_; request_storage_base_pimpl(request_storage_base_pimpl const &other); }; @@ -68,6 +69,10 @@ bool request_storage_base::equals(request_storage_base const &other) const { return pimpl_->equals(*other.pimpl_); } +void request_storage_base::swap(request_storage_base &other) { + return other.pimpl_->swap(*pimpl_); +} + request_storage_base_pimpl::request_storage_base_pimpl(size_t chunk_size) : chunk_size_(chunk_size) , chunks_() @@ -78,6 +83,7 @@ request_storage_base_pimpl::request_storage_base_pimpl(size_t chunk_size) request_storage_base_pimpl::request_storage_base_pimpl(request_storage_base_pimpl const &other) : chunk_size_(other.chunk_size_) , chunks_(0) { + lock_guard scoped_lock(other.chunk_mutex_); chunks_.reserve(other.chunks_.size()); chunks_vector::const_iterator it = other.chunks_.begin(); for (; it != other.chunks_.end(); ++it) { @@ -95,6 +101,7 @@ request_storage_base_pimpl * request_storage_base_pimpl::clone() const { } void request_storage_base_pimpl::append(char const *data, size_t size) { + lock_guard scoped_lock(chunk_mutex_); if (chunks_.empty()) { chunks_.push_back(std::make_pair( new (std::nothrow) char[chunk_size_], 0)); @@ -121,6 +128,7 @@ void request_storage_base_pimpl::append(char const *data, size_t size) { } size_t request_storage_base_pimpl::read(char *destination, size_t offset, size_t size) const { + lock_guard scoped_lock(chunk_mutex_); if (chunks_.empty()) return 0; // First we find which chunk we're going to read from using the provided // offset and some arithmetic to determine the correct one. @@ -145,6 +153,7 @@ size_t request_storage_base_pimpl::read(char *destination, size_t offset, size_t } void request_storage_base_pimpl::flatten(std::string &destination) const { + lock_guard scpoped_lock(chunk_mutex_); chunks_vector::const_iterator chunk_iterator = chunks_.begin(); for (; chunk_iterator != chunks_.end(); ++chunk_iterator) { destination.append(chunk_iterator->first, chunk_iterator->second); @@ -152,6 +161,7 @@ void request_storage_base_pimpl::flatten(std::string &destination) const { } void request_storage_base_pimpl::clear() { + lock_guard scoped_lock(chunk_mutex_); chunks_vector::const_iterator chunk_iterator = chunks_.begin(); for (; chunk_iterator != chunks_.end(); ++chunk_iterator) { delete [] chunk_iterator->first; @@ -160,18 +170,36 @@ void request_storage_base_pimpl::clear() { } bool request_storage_base_pimpl::equals(request_storage_base_pimpl const &other) const { - if (other.chunk_size_ != chunk_size_) return false; - if (other.chunks_.size() != chunks_.size()) return false; + lock(other.chunk_mutex_, this->chunk_mutex_); + if (other.chunk_size_ != chunk_size_ || other.chunks_.size() != chunks_.size()) { + other.chunk_mutex_.unlock(); + this->chunk_mutex_.unlock(); + return false; + } chunks_vector::const_iterator chunk_iterator = chunks_.begin(); chunks_vector::const_iterator other_iterator = other.chunks_.begin(); for (; chunk_iterator != chunks_.begin() && other_iterator != other.chunks_.end(); ++chunk_iterator, ++other_iterator) { - if (chunk_iterator->second != other_iterator->second) return false; - if (strncmp(chunk_iterator->first, other_iterator->first, chunk_iterator->second)) return false; + if (chunk_iterator->second != other_iterator->second || + strncmp(chunk_iterator->first, other_iterator->first, chunk_iterator->second)) { + other.chunk_mutex_.unlock(); + this->chunk_mutex_.unlock(); + return false; + } } + other.chunk_mutex_.unlock(); + this->chunk_mutex_.unlock(); return true; } +void request_storage_base_pimpl::swap(request_storage_base_pimpl &other) { + lock(other.chunk_mutex_, this->chunk_mutex_); + std::swap(chunk_size_, other.chunk_size_); + std::swap(chunks_, other.chunks_); + other.chunk_mutex_.unlock(); + this->chunk_mutex_.unlock(); +} + request_storage_base_pimpl::~request_storage_base_pimpl() { clear(); } diff --git a/libs/network/test/CMakeLists.txt b/libs/network/test/CMakeLists.txt index 63e3c759a..e459f8b98 100644 --- a/libs/network/test/CMakeLists.txt +++ b/libs/network/test/CMakeLists.txt @@ -45,8 +45,6 @@ if (Boost_FOUND) set_source_files_properties(utils_thread_pool.cpp PROPERTIES COMPILE_FLAGS "-Wall") add_executable(cpp-netlib-utils_thread_pool utils_thread_pool.cpp) - add_dependencies(cpp-netlib-utils_thread_pool - cppnetlib-utils-thread_pool) target_link_libraries(cpp-netlib-utils_thread_pool cppnetlib-utils-thread_pool ${Boost_LIBRARIES} diff --git a/libs/network/test/http/request_test.cpp b/libs/network/test/http/request_test.cpp index 0d2e389a7..961e00eb4 100644 --- a/libs/network/test/http/request_test.cpp +++ b/libs/network/test/http/request_test.cpp @@ -31,15 +31,16 @@ BOOST_AUTO_TEST_CASE(request_value_semantics) { // Next we modify the assigned object and make sure it's not the same as the // original. assigned.set_uri("http://www.google.com/"); - std::string original_uri, assigned_uri; - original.get_uri(original_uri); - assigned.get_uri(assigned_uri); - BOOST_CHECK_NE(original_uri, assigned_uri); + assigned.set_source("127.0.0.1"); + assigned.set_destination("http://www.google.com/"); + assigned.append_header("Connection", "close"); + assigned.set_body("Hello, world!"); BOOST_CHECK(original != assigned); // Next we swap the assigned and copy. std::swap(assigned, copy); BOOST_CHECK(copy != assigned); - BOOST_CHECK(assigned == original); + BOOST_CHECK(copy != original); + BOOST_CHECK(original == assigned); } BOOST_AUTO_TEST_CASE(request_uri_test) { From 8ae025d3d9f2b1351bf043b47d1f30081baf5d52 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Wed, 14 Mar 2012 18:25:34 +1100 Subject: [PATCH 060/196] Missed destination checking. --- boost/network/protocol/http/request/request.ipp | 15 ++++++++++++++- libs/network/test/http/request_test.cpp | 3 ++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/boost/network/protocol/http/request/request.ipp b/boost/network/protocol/http/request/request.ipp index 392d34929..44a650b97 100644 --- a/boost/network/protocol/http/request/request.ipp +++ b/boost/network/protocol/http/request/request.ipp @@ -24,6 +24,7 @@ struct request_pimpl { : uri_(url) , read_offset_(0) , source_() + , destination_() , headers_() {} @@ -86,6 +87,14 @@ struct request_pimpl { source = source_; } + void set_destination(std::string const &destination) { + destination_ = destination; + } + + void get_destination(std::string &destination) const { + destination = destination_; + } + size_t read_offset() const { return read_offset_; } @@ -98,6 +107,7 @@ struct request_pimpl { return uri_ == other.uri_ && read_offset_ == other.read_offset_ && source_ == other.source_ && + destination_ == other.destination_ && headers_ == other.headers_; } @@ -106,13 +116,14 @@ struct request_pimpl { uri::uri uri_; size_t read_offset_; - std::string source_; + std::string source_, destination_; headers_type headers_; request_pimpl(request_pimpl const &other) : uri_(other.uri_) , read_offset_(other.read_offset_) , source_(other.source_) + , destination_(other.destination_) , headers_(other.headers_) {} }; @@ -150,6 +161,7 @@ void request::swap(request & other) { // From message_base... // Mutators void request::set_destination(std::string const & destination) { + pimpl_->set_destination(destination); } void request::set_source(std::string const & source) { @@ -178,6 +190,7 @@ void request::append_body(std::string const & data) { // Retrievers void request::get_destination(std::string & destination) const { + pimpl_->get_destination(destination); } void request::get_source(std::string & source) const { diff --git a/libs/network/test/http/request_test.cpp b/libs/network/test/http/request_test.cpp index 961e00eb4..4ae1e91de 100644 --- a/libs/network/test/http/request_test.cpp +++ b/libs/network/test/http/request_test.cpp @@ -58,7 +58,7 @@ BOOST_AUTO_TEST_CASE(request_basics_test) { http::request request; request.set_uri("http://www.google.com/"); request.set_source("127.0.0.1"); - request.set_destination("http://www.google.com/"); + request.set_destination("destination!"); request.append_header("X-Referer", "http://cpp-netlib.github.com/"); request.append_header("Connection", "close"); request.append_body("The quick brown fox jumps over the lazy dog!"); @@ -73,6 +73,7 @@ BOOST_AUTO_TEST_CASE(request_basics_test) { BOOST_CHECK_EQUAL(uri_.string(), std::string("http://www.google.com/")); BOOST_CHECK_EQUAL(source_, std::string("127.0.0.1")); + BOOST_CHECK_EQUAL(destination_, std::string("destination!")); BOOST_CHECK_EQUAL(body_, std::string("The quick brown fox jumps over the lazy dog!")); BOOST_CHECK(!boost::empty(headers_range)); } From 4ea203496569ded3e8560be030dd0eb6ebe1e23b Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Thu, 15 Mar 2012 16:08:19 +1100 Subject: [PATCH 061/196] Partial implementation of http::response. After chasing down invalid memory access errors that shouldn't be there I've made sure that we're turning on -Wall and -Werror for most (if not all) the code in cpp-netlib built with CMAKE. If there's an easier way to do this, it should be done. My CMake-foo is not strong enough to make it happen except by doing copy-paste. In other news this is the beginnings of the http::response type that's supporting value semantics. There's still a number of stubbed out functions regarding headers, which hopefully once implemented will allow for moving forward to actually starting to debug the client implementation. --- .../network/protocol/http/request/request.ipp | 1 + .../protocol/http/request/request_base.ipp | 2 +- .../protocol/http/response/response.hpp | 11 +- .../protocol/http/response/response.ipp | 148 +++++++++++++----- libs/network/example/CMakeLists.txt | 24 +-- libs/network/src/CMakeLists.txt | 60 +++++++ libs/network/test/http/CMakeLists.txt | 33 ++-- libs/network/test/http/response_test.cpp | 31 ++++ 8 files changed, 244 insertions(+), 66 deletions(-) create mode 100644 libs/network/test/http/response_test.cpp diff --git a/boost/network/protocol/http/request/request.ipp b/boost/network/protocol/http/request/request.ipp index 44a650b97..e16ac99e3 100644 --- a/boost/network/protocol/http/request/request.ipp +++ b/boost/network/protocol/http/request/request.ipp @@ -146,6 +146,7 @@ request::request(request const &other) request& request::operator=(request rhs) { rhs.swap(*this); + return *this; } bool request::equals(request const &other) const { diff --git a/boost/network/protocol/http/request/request_base.ipp b/boost/network/protocol/http/request/request_base.ipp index 5950d7daa..712b5ca39 100644 --- a/boost/network/protocol/http/request/request_base.ipp +++ b/boost/network/protocol/http/request/request_base.ipp @@ -139,7 +139,7 @@ size_t request_storage_base_pimpl::read(char *destination, size_t offset, size_t // or we're size_t chunks_count = chunks_.size(); size_t read_count = 0; - while (size > 0 && chunk_index < chunks_.size()) { + while (size > 0 && chunk_index < chunks_count) { size_t bytes_to_read = std::min(chunks_[chunk_index].second, size); std::memcpy(destination + read_count, chunks_[chunk_index].first + offset, diff --git a/boost/network/protocol/http/response/response.hpp b/boost/network/protocol/http/response/response.hpp index 102fea908..915bddd8e 100644 --- a/boost/network/protocol/http/response/response.hpp +++ b/boost/network/protocol/http/response/response.hpp @@ -19,6 +19,7 @@ struct response : response_base { response(response const &); response& operator=(response); void swap(response &); + bool equals(response const &) const; // From message_base... // Mutators @@ -68,13 +69,21 @@ struct response : response_base { void set_destination_promise(promise&); void set_body_promise(promise&); - scoped_ptr pimpl_; + response_pimpl *pimpl_; }; inline void swap(response &l, response &r) { l.swap(r); } +inline bool operator==(response const &l, response const &r) { + return l.equals(r); +} + +inline bool operator!=(response const &l, response const &r) { + return !l.equals(r); +} + template response & operator<<( response & message, diff --git a/boost/network/protocol/http/response/response.ipp b/boost/network/protocol/http/response/response.ipp index 570d33f09..b6738338c 100644 --- a/boost/network/protocol/http/response/response.ipp +++ b/boost/network/protocol/http/response/response.ipp @@ -15,45 +15,38 @@ namespace boost { namespace network { namespace http { struct response_pimpl { response_pimpl() {} + response_pimpl * clone() { - response_pimpl * new_pimpl = new (std::nothrow) response_pimpl; - new_pimpl->source_future_ = source_future_; - new_pimpl->destination_future_ = destination_future_; - new_pimpl->headers_future_ = headers_future_; - new_pimpl->status_future_ = status_future_; - new_pimpl->status_message_future_ = status_message_future_; - new_pimpl->version_future_ = version_future_; - new_pimpl->body_future_ = body_future_; - return new_pimpl; + return new (std::nothrow) response_pimpl(*this); } void set_destination(std::string const &destination) { promise destination_promise; + destination_promise.set_value(destination); unique_future tmp_future = destination_promise.get_future(); destination_future_ = move(tmp_future); - destination_promise.set_value(destination); } void get_destination(std::string &destination) { - if (!destination_future_) { + if (destination_future_.get_state() == future_state::uninitialized) { destination = ""; } else { - destination = destination_future_->get(); + destination = destination_future_.get(); } } void set_source(std::string const &source) { promise source_promise; + source_promise.set_value(source); unique_future tmp_future = source_promise.get_future(); source_future_ = move(tmp_future); - source_promise.set_value(source); } void get_source(std::string &source) { - if (!source_future_) { + if (source_future_.get_state() == future_state::uninitialized) { source = ""; } else { - source = source_future_->get(); + source = source_future_.get(); } } @@ -81,18 +74,18 @@ struct response_pimpl { void set_body(std::string const &body) { promise body_promise; + body_promise.set_value(body); unique_future tmp_future = body_promise.get_future(); body_future_ = move(tmp_future); - body_promise.set_value(body); } void append_body(std::string const & data) { /* FIXME: Do something! */ } void get_body(std::string &body) { - if (!body_future_) { + if (body_future_.get_state() == future_state::uninitialized) { body = ""; } else { - body = body_future_->get(); + body = body_future_.get(); } } @@ -102,46 +95,46 @@ struct response_pimpl { void set_status(boost::uint16_t status) { promise status_promise; + status_promise.set_value(status); unique_future tmp_future = status_promise.get_future(); status_future_ = move(tmp_future); - status_promise.set_value(status); } void get_status(boost::uint16_t &status) { - if (!status_future_) { + if (status_future_.get_state() == future_state::uninitialized) { status = 0u; } else { - status = status_future_->get(); + status = status_future_.get(); } } void set_status_message(std::string const &status_message) { promise status_message_promise_; + status_message_promise_.set_value(status_message); unique_future tmp_future = status_message_promise_.get_future(); status_message_future_ = move(tmp_future); - status_message_promise_.set_value(status_message); } void get_status_message(std::string &status_message) { - if (!status_message_future_) { + if (status_message_future_.get_state() == future_state::uninitialized) { status_message = ""; } else { - status_message = status_message_future_->get(); + status_message = status_message_future_.get(); } } void set_version(std::string const &version) { promise version_promise; + version_promise.set_value(version); unique_future tmp_future = version_promise.get_future(); version_future_ = move(tmp_future); - version_promise.set_value(version); } void get_version(std::string &version) { - if (!version_future_) { + if (version_future_.get_state() == future_state::uninitialized) { version = ""; } else { - version = version_future_->get(); + version = version_future_.get(); } } @@ -180,15 +173,92 @@ struct response_pimpl { body_future_ = move(tmp_future); } + bool equals(response_pimpl const &other) { + if (source_future_.get_state() != future_state::uninitialized) { + if (other.source_future_.get_state() == future_state::uninitialized) + return false; + if (source_future_.get() != other.source_future_.get()) + return false; + } else { + if (other.source_future_.get_state() != future_state::uninitialized) + return false; + } + if (destination_future_.get_state() != future_state::uninitialized) { + if (other.destination_future_.get_state() == future_state::uninitialized) + return false; + if (destination_future_.get() != other.destination_future_.get()) + return false; + } else { + if (other.destination_future_.get_state() != future_state::uninitialized) + return false; + } + if (headers_future_.get_state() != future_state::uninitialized) { + if (other.headers_future_.get_state() == future_state::uninitialized) + return false; + if (headers_future_.get() != other.headers_future_.get()) + return false; + } else { + if (other.headers_future_.get_state() != future_state::uninitialized) + return false; + } + if (status_future_.get_state() != future_state::uninitialized) { + if (other.status_future_.get_state() == future_state::uninitialized) + return false; + if (status_future_.get() != other.status_future_.get()) + return false; + } else { + if (other.status_future_.get_state() != future_state::uninitialized) + return false; + } + if (status_message_future_.get_state() != future_state::uninitialized) { + if (other.status_message_future_.get_state() == future_state::uninitialized) + return false; + if (status_message_future_.get() != other.status_message_future_.get()) + return false; + } else { + if (other.status_message_future_.get_state() != future_state::uninitialized) + return false; + } + if (version_future_.get_state() != future_state::uninitialized) { + if (other.version_future_.get_state() == future_state::uninitialized) + return false; + if (version_future_.get() != other.version_future_.get()) + return false; + } else { + if (other.version_future_.get_state() != future_state::uninitialized) + return false; + } + if (body_future_.get_state() != future_state::uninitialized) { + if (other.body_future_.get_state() == future_state::uninitialized) + return false; + if (body_future_.get() != other.body_future_.get()) + return false; + } else { + if (other.body_future_.get_state() != future_state::uninitialized) + return false; + } + return true; + } + private: - optional > source_future_; - optional > destination_future_; - optional > > + mutable shared_future source_future_; + mutable shared_future destination_future_; + mutable shared_future > headers_future_; - optional > status_future_; - optional > status_message_future_; - optional > version_future_; - optional > body_future_; + mutable shared_future status_future_; + mutable shared_future status_message_future_; + mutable shared_future version_future_; + mutable shared_future body_future_; + + response_pimpl(response_pimpl const &other) + : source_future_(other.source_future_) + , destination_future_(other.destination_future_) + , headers_future_(other.headers_future_) + , status_future_(other.status_future_) + , status_message_future_(other.status_message_future_) + , version_future_(other.version_future_) + , body_future_(other.body_future_) + {} }; response::response() @@ -205,7 +275,11 @@ response& response::operator=(response rhs) { } void response::swap(response &other) { - other.pimpl_.swap(pimpl_); + std::swap(this->pimpl_, other.pimpl_); +} + +bool response::equals(response const &other) const { + return other.pimpl_->equals(*pimpl_); } void response::set_destination(std::string const &destination) { @@ -291,7 +365,9 @@ void response::get_version(std::string &version) const { pimpl_->get_version(version); } -response::~response() {} +response::~response() { + delete pimpl_; +} void response::set_version_promise(promise &promise) { return pimpl_->set_version_promise(promise); diff --git a/libs/network/example/CMakeLists.txt b/libs/network/example/CMakeLists.txt index 2a5efc740..7ae8699cd 100644 --- a/libs/network/example/CMakeLists.txt +++ b/libs/network/example/CMakeLists.txt @@ -19,12 +19,6 @@ if (UNIX) add_executable(fileserver http/fileserver.cpp) endif (UNIX) add_executable(uri uri.cpp) -add_dependencies(http_client cppnetlib-uri cppnetlib-client-connections) -add_dependencies(simple_wget cppnetlib-uri cppnetlib-client-connections) -add_dependencies(atom_reader cppnetlib-uri cppnetlib-client-connections) -add_dependencies(rss_reader cppnetlib-uri cppnetlib-client-connections) -add_dependencies(twitter_search cppnetlib-uri cppnetlib-client-connections) -add_dependencies(uri cppnetlib-uri) set(BOOST_CLIENT_LIBS ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_THREAD_LIBRARY} @@ -42,31 +36,37 @@ target_link_libraries(http_client ${BOOST_CLIENT_LIBS} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri - cppnetlib-client-connections) + cppnetlib-http-client-connections) target_link_libraries(simple_wget ${BOOST_CLIENT_LIBS} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri - cppnetlib-client-connections) + cppnetlib-http-client-connections) target_link_libraries(atom_reader ${BOOST_CLIENT_LIBS} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri - cppnetlib-client-connections) + cppnetlib-message + cppnetlib-message-directives + cppnetlib-message-wrappers + cppnetlib-http-message + cppnetlib-constants + cppnetlib-http-client + cppnetlib-http-client-connections) target_link_libraries(rss_reader ${BOOST_CLIENT_LIBS} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri - cppnetlib-client-connections) + cppnetlib-http-client-connections) target_link_libraries(twitter_search ${BOOST_CLIENT_LIBS} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri - cppnetlib-client-connections) + cppnetlib-http-client-connections) target_link_libraries(hello_world_server ${BOOST_SERVER_LIBS} @@ -76,7 +76,7 @@ target_link_libraries(hello_world_client ${BOOST_CLIENT_LIBS} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri - cppnetlib-client-connections) + cppnetlib-http-client-connections) if (OPENSSL_FOUND) target_link_libraries(http_client ${OPENSSL_LIBRARIES}) diff --git a/libs/network/src/CMakeLists.txt b/libs/network/src/CMakeLists.txt index 8c8e8b9c5..b224e3591 100644 --- a/libs/network/src/CMakeLists.txt +++ b/libs/network/src/CMakeLists.txt @@ -10,21 +10,57 @@ include_directories(${CPP-NETLIB_SOURCE_DIR}) set(CPP-NETLIB_URI_SRCS uri/parse.cpp) add_library(cppnetlib-uri ${CPP-NETLIB_URI_SRCS}) +foreach (src_file ${CPP-NETLIB_URI_SRCS}) +if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) + set_source_files_properties(${src_file} + PROPERTIES COMPILE_FLAGS "-Wall -Werror") +endif() +endforeach(src_file) set(CPP-NETLIB_HTTP_SERVER_SRCS server_request_parsers_impl.cpp) add_library(cppnetlib-server-parsers ${CPP-NETLIB_HTTP_SERVER_SRCS}) +foreach (src_file ${CPP-NETLIB_HTTP_SERVER_SRCS}) +if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) + set_source_files_properties(${src_file} + PROPERTIES COMPILE_FLAGS "-Wall -Werror") +endif() +endforeach(src_file) set(CPP-NETLIB_MESSAGE_SRCS message/message.cpp) add_library(cppnetlib-message ${CPP-NETLIB_MESSAGE_SRCS}) +foreach (src_file ${CPP-NETLIB_MESSAGE_SRCS}) +if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) + set_source_files_properties(${src_file} + PROPERTIES COMPILE_FLAGS "-Wall -Werror") +endif() +endforeach(src_file) set(CPP-NETLIB_MESSAGE_DIRECTIVES_SRCS message/directives.cpp) add_library(cppnetlib-message-directives ${CPP-NETLIB_MESSAGE_DIRECTIVES_SRCS}) +foreach (src_file ${CPP-NETLIB_MESSAGE_DIRECTIVES_SRCS}) +if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) + set_source_files_properties(${src_file} + PROPERTIES COMPILE_FLAGS "-Wall -Werror") +endif() +endforeach(src_file) set(CPP-NETLIB_MESSAGE_WRAPPERS_SRCS message/wrappers.cpp) add_library(cppnetlib-message-wrappers ${CPP-NETLIB_MESSAGE_WRAPPERS_SRCS}) +foreach (src_file ${CPP-NETLIB_MESSAGE_WRAPPERS_SRCS}) +if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) + set_source_files_properties(${src_file} + PROPERTIES COMPILE_FLAGS "-Wall -Werror") +endif() +endforeach(src_file) set(CPP-NETLIB_HTTP_MESSAGE_SRCS http/request.cpp http/response.cpp) add_library(cppnetlib-http-message ${CPP-NETLIB_HTTP_MESSAGE_SRCS}) +foreach (src_file ${CPP-NETLIB_HTTP_MESSAGE_SRCS}) +if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) + set_source_files_properties(${src_file} + PROPERTIES COMPILE_FLAGS "-Wall -Werror") +endif() +endforeach(src_file) set(CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS http/client_connections.cpp @@ -38,13 +74,37 @@ set(CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS http/client_async_resolver.cpp http/client_connection_normal.cpp) add_library(cppnetlib-http-client-connections ${CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS}) +foreach (src_file ${CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS}) +if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) + set_source_files_properties(${src_file} + PROPERTIES COMPILE_FLAGS "-Wall -Werror") +endif() +endforeach(src_file) set(CPP-NETLIB_HTTP_CLIENT_SRCS http/client.cpp) add_library(cppnetlib-http-client ${CPP-NETLIB_HTTP_CLIENT_SRCS}) +foreach (src_file ${CPP-NETLIB_HTTP_CLIENT_SRCS}) +if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) + set_source_files_properties(${src_file} + PROPERTIES COMPILE_FLAGS "-Wall -Werror") +endif() +endforeach(src_file) set(CPP-NETLIB_UTILS_THREAD_POOL_SRCS utils/thread_pool.cpp) add_library(cppnetlib-utils-thread_pool ${CPP-NETLIB_UTILS_THREAD_POOL_SRCS}) +foreach (src_file ${CPP-NETLIB_UTILS_THREAD_POOL_SRCS}) +if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) + set_source_files_properties(${src_file} + PROPERTIES COMPILE_FLAGS "-Wall -Werror") +endif() +endforeach(src_file) set(CPP-NETLIB_CONSTANTS_SRCS constants.cpp) add_library(cppnetlib-constants ${CPP-NETLIB_CONSTANTS_SRCS}) +foreach (src_file ${CPP-NETLIB_CONSTANTS_SRCS}) +if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) + set_source_files_properties(${src_file} + PROPERTIES COMPILE_FLAGS "-Wall -Werror") +endif() +endforeach(src_file) diff --git a/libs/network/test/http/CMakeLists.txt b/libs/network/test/http/CMakeLists.txt index b9367381b..3b4945eb0 100644 --- a/libs/network/test/http/CMakeLists.txt +++ b/libs/network/test/http/CMakeLists.txt @@ -16,6 +16,7 @@ if (Boost_FOUND) set ( MESSAGE_TESTS request_base_test request_test + response_test ) foreach ( test ${MESSAGE_TESTS} ) if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) @@ -68,21 +69,21 @@ if (Boost_FOUND) ${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-http-${test}) endforeach (test) - set ( SERVER_API_TESTS - server_constructor_test - server_async_run_stop_concurrency - ) - foreach ( test ${SERVER_API_TESTS} ) - if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) - set_source_files_properties(${test}.cpp - PROPERTIES COMPILE_FLAGS "-Wall") - endif() - add_executable(cpp-netlib-http-${test} ${test}.cpp) - target_link_libraries(cpp-netlib-http-${test} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-server-parsers) - set_target_properties(cpp-netlib-http-${test} - PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests) - add_test(cpp-netlib-http-${test} - ${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-http-${test}) - endforeach (test) +# set ( SERVER_API_TESTS +# server_constructor_test +# server_async_run_stop_concurrency +# ) +# foreach ( test ${SERVER_API_TESTS} ) +# if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) +# set_source_files_properties(${test}.cpp +# PROPERTIES COMPILE_FLAGS "-Wall") +# endif() +# add_executable(cpp-netlib-http-${test} ${test}.cpp) +# target_link_libraries(cpp-netlib-http-${test} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-server-parsers) +# set_target_properties(cpp-netlib-http-${test} +# PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests) +# add_test(cpp-netlib-http-${test} +# ${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-http-${test}) +# endforeach (test) endif() diff --git a/libs/network/test/http/response_test.cpp b/libs/network/test/http/response_test.cpp new file mode 100644 index 000000000..b6b018cdb --- /dev/null +++ b/libs/network/test/http/response_test.cpp @@ -0,0 +1,31 @@ +// Copyright 2012 Dean Michael Berris . +// Copyright 2012 Google, Inc. +// 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) + +#define BOOST_TEST_MODULE HTTP Client Response Test +#include +#include + +namespace http = boost::network::http; + +BOOST_AUTO_TEST_CASE(response_constructor_test) { + http::response created; +} + +BOOST_AUTO_TEST_CASE(response_value_semantics_test) { + http::response original; + http::response copy(original); + http::response assigned; + assigned = original; + BOOST_CHECK(original == assigned); + assigned.set_source("http://www.google.com/"); + BOOST_CHECK(original != assigned); + std::swap(assigned, copy); + BOOST_CHECK(assigned == original); + BOOST_CHECK(copy != original); + BOOST_CHECK(assigned != copy); + original = copy; + BOOST_CHECK(original == copy); +} From fcf488899eb7f387f1e5b916245c97b12b05fd88 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Thu, 15 Mar 2012 18:43:34 +1100 Subject: [PATCH 062/196] More complete response functionality. In this commit we add rudimentary header processing. The equality check is not exactly correct as it's completely plausible that two different response instances have different merged headers, but for the meantime we're banking on internal equality rather than semantic equality. What needs to happen to fix this is to add a little bit of caching/merging logic to make sure that we're able to actually merge the actual headers waiting in the future with the added headers manually along with the removed headers, and compare those instead. Unfortunately that's too much work for now and it's not really necessary at this time. --- .../protocol/http/response/response.ipp | 43 ++++++++++++++++--- libs/network/test/http/response_test.cpp | 40 +++++++++++++++++ 2 files changed, 77 insertions(+), 6 deletions(-) diff --git a/boost/network/protocol/http/response/response.ipp b/boost/network/protocol/http/response/response.ipp index b6738338c..36f7d8066 100644 --- a/boost/network/protocol/http/response/response.ipp +++ b/boost/network/protocol/http/response/response.ipp @@ -8,8 +8,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include -#include +#include namespace boost { namespace network { namespace http { @@ -52,19 +51,44 @@ struct response_pimpl { void append_header(std::string const & name, std::string const & value) { - // FIXME do something! + added_headers_.insert(std::make_pair(name, value)); } void remove_headers(std::string const &name) { - // FIXME do something! + removed_headers_.insert(name); } void remove_headers() { - // FIXME do something! + if (headers_future_.get_state() == future_state::uninitialized) { + promise > headers_promise; + headers_promise.set_value(std::multimap()); + unique_future > tmp = + headers_promise.get_future(); + std::multimap().swap(added_headers_); + std::set().swap(removed_headers_); + headers_future_ = move(tmp); + } } void get_headers( - function inserter) { /* FIXME: Do something! */ } + function inserter) { + std::multimap::const_iterator it; + if (headers_future_.get_state() == future_state::uninitialized) { + it = added_headers_.begin(); + for (;it != added_headers_.end(); ++it) { + if (removed_headers_.find(it->first) == removed_headers_.end()) { + inserter(it->first, it->second); + } + } + } else { + it = headers_future_.get().begin(); + for (;it != headers_future_.get().end(); ++it) { + if (removed_headers_.find(it->first) == removed_headers_.end()) { + inserter(it->first, it->second); + } + } + } + } void get_headers( std::string const & name, function inserter) { /* FIXME: Do something! */ } @@ -237,6 +261,8 @@ struct response_pimpl { if (other.body_future_.get_state() != future_state::uninitialized) return false; } + if (other.added_headers_ != added_headers_ || other.removed_headers_ != removed_headers_) + return false; return true; } @@ -249,6 +275,9 @@ struct response_pimpl { mutable shared_future status_message_future_; mutable shared_future version_future_; mutable shared_future body_future_; + // TODO: use unordered_map and unordered_set here. + std::multimap added_headers_; + std::set removed_headers_; response_pimpl(response_pimpl const &other) : source_future_(other.source_future_) @@ -258,6 +287,8 @@ struct response_pimpl { , status_message_future_(other.status_message_future_) , version_future_(other.version_future_) , body_future_(other.body_future_) + , added_headers_(other.added_headers_) + , removed_headers_(other.removed_headers_) {} }; diff --git a/libs/network/test/http/response_test.cpp b/libs/network/test/http/response_test.cpp index b6b018cdb..75a8be0d9 100644 --- a/libs/network/test/http/response_test.cpp +++ b/libs/network/test/http/response_test.cpp @@ -29,3 +29,43 @@ BOOST_AUTO_TEST_CASE(response_value_semantics_test) { original = copy; BOOST_CHECK(original == copy); } + +struct multimap_inserter { + void operator()(std::string const &name, std::string const &value) const { + multimap_.insert(std::make_pair(name, value)); + } + explicit multimap_inserter(std::multimap &multimap) + : multimap_(multimap) + {} + std::multimap & multimap_; +}; + +BOOST_AUTO_TEST_CASE(response_setters_and_getters_test) { + http::response response; + response.set_source("http://www.google.com/"); + response.set_destination("127.0.0.1"); + response.append_header("Connection", "close"); + response.append_header("Content-Type", "text/plain"); + response.set_body("Hello, World!"); + response.set_status(200u); + response.set_status_message("OK"); + response.set_version("HTTP/1.1"); + std::string source, destination, body, status_message, version; + std::multimap headers, expected_headers; + expected_headers.insert(std::make_pair("Connection", "close")); + expected_headers.insert(std::make_pair("Content-Type", "text/plain")); + boost::uint16_t status; + response.get_source(source); + response.get_destination(destination); + response.get_body(body); + response.get_status_message(status_message); + response.get_version(version); + response.get_headers(multimap_inserter(headers)); + response.get_status(status); + BOOST_CHECK_EQUAL(source, std::string("http://www.google.com/")); + BOOST_CHECK_EQUAL(destination, std::string("127.0.0.1")); + BOOST_CHECK_EQUAL(body, std::string("Hello, World!")); + BOOST_CHECK_EQUAL(status, 200u); + BOOST_CHECK_EQUAL(version, std::string("HTTP/1.1")); + BOOST_CHECK(expected_headers == headers); +} From 335dd84992beaf04de4b4b8185ab31470697aeb9 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Thu, 15 Mar 2012 23:26:33 +1100 Subject: [PATCH 063/196] WIP: Tons of logging, improving build times. I've reorganized a few things trying to hunt down why certain things aren't happening as expected. I'm committing so that I can try and merge from cpp-netlib/cpp-netlib:master to catch what Glyn has pushed with the URI implementation. There's a few issues with trying to get the host and other parts of the message through the wrappers and I'm trying a merge to figure out if this has been fixed. --- boost/network/include/http/client.hpp | 6 +++ boost/network/protocol/http/client.ipp | 10 +++-- boost/network/protocol/http/client/base.ipp | 22 ++++++++--- .../http/client/client_connection.hpp | 5 ++- .../http/client/client_connection.ipp | 3 ++ .../http/client/connection/async_normal.ipp | 32 ++++++++++++++-- .../connection_delegate_factory.hpp | 4 -- .../connection_delegate_factory.ipp | 13 ++++++- .../client/connection/connection_factory.hpp | 16 ++++---- .../client/connection/normal_delegate.hpp | 4 -- .../client/connection/resolver_delegate.hpp | 4 -- .../connection/resolver_delegate_factory.hpp | 4 -- .../connection/resolver_delegate_factory.ipp | 10 ++++- .../connection/simple_connection_factory.hpp | 4 -- .../connection/simple_connection_factory.ipp | 22 +++++++++-- .../http/client/connection/ssl_delegate.hpp | 4 -- .../http/client/connection/ssl_delegate.ipp | 15 +++++++- .../http/client/connection_manager.hpp | 15 ++++++-- .../http/client/connection_manager.ipp | 2 + boost/network/protocol/http/client/facade.ipp | 23 +++++++++-- .../http/client/simple_connection_manager.hpp | 4 -- .../http/client/simple_connection_manager.ipp | 19 +++++++++- .../protocol/http/message/wrappers/uri.hpp | 2 +- .../protocol/http/message/wrappers/uri.ipp | 38 +++++++++++++++++++ boost/network/protocol/http/request.hpp | 25 ------------ .../network/protocol/http/request/request.ipp | 8 +++- libs/network/src/CMakeLists.txt | 9 +++++ libs/network/src/http/client_connections.cpp | 3 ++ libs/network/src/http/message/wrappers.cpp | 12 ++++++ libs/network/src/http/request.cpp | 5 --- libs/network/test/http/CMakeLists.txt | 7 +++- .../test/http/request_linearize_test.cpp | 18 ++------- libs/network/test/http/request_test.cpp | 16 ++++++++ 33 files changed, 270 insertions(+), 114 deletions(-) create mode 100644 boost/network/protocol/http/message/wrappers/uri.ipp create mode 100644 libs/network/src/http/message/wrappers.cpp diff --git a/boost/network/include/http/client.hpp b/boost/network/include/http/client.hpp index f9b27d188..4ca545f9e 100644 --- a/boost/network/include/http/client.hpp +++ b/boost/network/include/http/client.hpp @@ -9,6 +9,12 @@ // This is the modular include file for using the HTTP Client #include +#include +#include +#include +#include +#include +#include #endif // BOOST_NETWORK_INCLUDE_HTTP_CLIENT_HPP_ diff --git a/boost/network/protocol/http/client.ipp b/boost/network/protocol/http/client.ipp index c1989cf42..9b6d3d004 100644 --- a/boost/network/protocol/http/client.ipp +++ b/boost/network/protocol/http/client.ipp @@ -9,16 +9,20 @@ #include #include +#include namespace boost { namespace network { namespace http { client::client() -: base_facade_type() -{} +: base_facade_type() { + BOOST_NETWORK_MESSAGE("client::client()"); +} client::client(client_options const &options) : base_facade_type(options) -{} +{ + BOOST_NETWORK_MESSAGE("client::client(client_options const &)"); +} } // namespace http } // namespace network diff --git a/boost/network/protocol/http/client/base.ipp b/boost/network/protocol/http/client/base.ipp index f938bf8d5..dadc3a3da 100644 --- a/boost/network/protocol/http/client/base.ipp +++ b/boost/network/protocol/http/client/base.ipp @@ -16,6 +16,7 @@ #include #include #include +#include namespace boost { namespace network { namespace http { @@ -41,12 +42,14 @@ struct client_base_pimpl { }; client_base::client_base() -: pimpl(new (std::nothrow) client_base_pimpl(client_options())) -{} +: pimpl(new (std::nothrow) client_base_pimpl(client_options())) { + BOOST_NETWORK_MESSAGE("client_base::client_base()"); +} client_base::client_base(client_options const &options) -: pimpl(new (std::nothrow) client_base_pimpl(options)) -{} +: pimpl(new (std::nothrow) client_base_pimpl(options)) { + BOOST_NETWORK_MESSAGE("client_base::client_base(client_options const &)"); +} void client_base::clear_resolved_cache() { pimpl->clear_resolved_cache(); @@ -57,10 +60,12 @@ response const client_base::request_skeleton(request const & request_, bool get_body, body_callback_function_type callback, request_options const &options) { + BOOST_NETWORK_MESSAGE("client_base::request_skeleton(...)"); return pimpl->request_skeleton(request_, method, get_body, callback, options); } client_base::~client_base() { + BOOST_NETWORK_MESSAGE("client_base::~client_base()"); delete pimpl; } @@ -70,13 +75,17 @@ client_base_pimpl::client_base_pimpl(client_options const &options) sentinel_(), connection_manager_(options.connection_manager()), owned_service_(false) { + BOOST_NETWORK_MESSAGE("client_base_pimpl::client_base_pimpl(client_options const &)"); if (service_ptr == 0) { + BOOST_NETWORK_MESSAGE("creating owned io_service."); service_ptr = new(std::nothrow) asio::io_service; owned_service_ = true; } - if (!connection_manager_.get()) + if (!connection_manager_.get()) { + BOOST_NETWORK_MESSAGE("creating owned simple_connection_manager"); connection_manager_.reset( new (std::nothrow) simple_connection_manager(options)); + } sentinel_.reset(new (std::nothrow) boost::asio::io_service::work(*service_ptr)); lifetime_thread_.reset(new (std::nothrow) boost::thread( boost::bind( @@ -89,6 +98,7 @@ client_base_pimpl::client_base_pimpl(client_options const &options) client_base_pimpl::~client_base_pimpl() { + BOOST_NETWORK_MESSAGE("client_base_pimpl::~client_base_pimpl()"); sentinel_.reset(); connection_manager_->reset(); if (lifetime_thread_.get()) { @@ -106,12 +116,14 @@ response const client_base_pimpl::request_skeleton( request_options const &options ) { + BOOST_NETWORK_MESSAGE("client_base_pimpl::request_skeleton(...)"); shared_ptr connection_; connection_ = connection_manager_->get_connection(*service_ptr, request_, options_); return connection_->send_request(method, request_, get_body, callback, options); } void client_base_pimpl::clear_resolved_cache() { + BOOST_NETWORK_MESSAGE("client_base_pimpl::clear_resolved_cache()"); connection_manager_->clear_resolved_cache(); } diff --git a/boost/network/protocol/http/client/client_connection.hpp b/boost/network/protocol/http/client/client_connection.hpp index d302fb5ec..89bd0b4e8 100644 --- a/boost/network/protocol/http/client/client_connection.hpp +++ b/boost/network/protocol/http/client/client_connection.hpp @@ -10,11 +10,12 @@ #include #include #include -#include -#include namespace boost { namespace network { namespace http { +struct request; +struct response; + class request_options; struct client_connection { diff --git a/boost/network/protocol/http/client/client_connection.ipp b/boost/network/protocol/http/client/client_connection.ipp index 8995442a1..bb4ac9eff 100644 --- a/boost/network/protocol/http/client/client_connection.ipp +++ b/boost/network/protocol/http/client/client_connection.ipp @@ -9,14 +9,17 @@ #include #include +#include namespace boost { namespace network { namespace http { client_connection::~client_connection() { + BOOST_NETWORK_MESSAGE("client_connection::~client_connection()"); // Do nothing here. } client_connection * client_connection::clone() const { + BOOST_NETWORK_MESSAGE("client_connection::clone()"); // For exposition only. BOOST_ASSERT(false && "This should not ever be called."); } diff --git a/boost/network/protocol/http/client/connection/async_normal.ipp b/boost/network/protocol/http/client/connection/async_normal.ipp index 57dadcacc..955eac80b 100644 --- a/boost/network/protocol/http/client/connection/async_normal.ipp +++ b/boost/network/protocol/http/client/connection/async_normal.ipp @@ -35,7 +35,9 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this::start(...) here which is called @@ -45,6 +47,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisinit_response(response_); // Use HTTP/1.1 -- at some point we might want to implement a different @@ -52,8 +55,17 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this(&command_streambuf)); +#ifdef BOOST_NETWORK_DEBUG + { + std::ostringstream linearized; + linearized << &command_streambuf; + BOOST_NETWORK_MESSAGE("linearized request: ['" << linearized.str() << "']"); + } +#endif this->method = method; + BOOST_NETWORK_MESSAGE("method: " << this->method); boost::uint16_t port_ = port(request); + BOOST_NETWORK_MESSAGE("port: " << port_); resolver_delegate_->resolve( host(request), port_, @@ -70,6 +82,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisresolver_delegate_, this->connection_delegate_, @@ -86,6 +99,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thissource_promise); accessor.set_destination_promise(r, this->destination_promise); @@ -93,9 +107,12 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisbody_promise); accessor.set_version_promise(r, this->version_promise); accessor.set_status_message_promise(r, this->status_message_promise); + BOOST_NETWORK_MESSAGE("futures and promises lined up."); } void set_errors(boost::system::error_code const & ec) { + BOOST_NETWORK_MESSAGE("http_async_connection_pimpl::set_errors(...)"); + BOOST_NETWORK_MESSAGE("error: " << ec); boost::system::system_error error(ec); this->version_promise.set_exception(boost::copy_exception(error)); this->status_promise.set_exception(boost::copy_exception(error)); @@ -104,6 +121,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thissource_promise.set_exception(boost::copy_exception(error)); this->destination_promise.set_exception(boost::copy_exception(error)); this->body_promise.set_exception(boost::copy_exception(error)); + BOOST_NETWORK_MESSAGE("promise+future exceptions set."); } void handle_resolved(boost::uint16_t port, @@ -111,10 +129,13 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisendpoint().address() << ":" << port); asio::ip::tcp::endpoint endpoint(iter->endpoint().address(), port); connection_delegate_->connect(endpoint, request_strand_.wrap( @@ -128,6 +149,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thiswrite(command_streambuf, request_strand_.wrap( @@ -149,8 +173,10 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisendpoint().address() << ":" << port); asio::ip::tcp::endpoint endpoint(iter->endpoint().address(), port); connection_delegate_->connect(endpoint, request_strand_.wrap( diff --git a/boost/network/protocol/http/client/connection/connection_delegate_factory.hpp b/boost/network/protocol/http/client/connection/connection_delegate_factory.hpp index 47adc8190..4a9923ad2 100644 --- a/boost/network/protocol/http/client/connection/connection_delegate_factory.hpp +++ b/boost/network/protocol/http/client/connection/connection_delegate_factory.hpp @@ -36,8 +36,4 @@ struct connection_delegate_factory { } /* network */ } /* boost */ -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif - #endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_DELEGATE_FACTORY_HPP_20110819 */ diff --git a/boost/network/protocol/http/client/connection/connection_delegate_factory.ipp b/boost/network/protocol/http/client/connection/connection_delegate_factory.ipp index 44869b373..d807f6f4c 100644 --- a/boost/network/protocol/http/client/connection/connection_delegate_factory.ipp +++ b/boost/network/protocol/http/client/connection/connection_delegate_factory.ipp @@ -14,31 +14,40 @@ #include #include +#include namespace boost { namespace network { namespace http { -connection_delegate_factory::connection_delegate_factory() {} +connection_delegate_factory::connection_delegate_factory() { + BOOST_NETWORK_MESSAGE("connection_delegate_factory::connection_delegate_factory()"); +} connection_delegate_factory::connection_delegate_ptr connection_delegate_factory::create_connection_delegate( asio::io_service & service, bool https, client_options const &options) { + BOOST_NETWORK_MESSAGE("connection_delegate_factory::create_connection_delegate(...)"); connection_delegate_ptr delegate; if (https) { #ifdef BOOST_NETWORK_ENABLE_HTTPS + BOOST_NETWORK_MESSAGE("creating an SSL delegate"); delegate.reset(new ssl_delegate(service, options)); #else + BOOST_NETWORK_MESSAGE("creating an SSL delegate, but not supported"); BOOST_THROW_EXCEPTION(std::runtime_error("HTTPS not supported.")); #endif /* BOOST_NETWORK_ENABLE_HTTPS */ } else { + BOOST_NETWORK_MESSAGE("creating a normal delegate"); delegate.reset(new normal_delegate(service)); } return delegate; } -connection_delegate_factory::~connection_delegate_factory() {} +connection_delegate_factory::~connection_delegate_factory() { + BOOST_NETWORK_MESSAGE("connection_delegate_factory::~connection_delegate_factory()"); +} } /* http */ diff --git a/boost/network/protocol/http/client/connection/connection_factory.hpp b/boost/network/protocol/http/client/connection/connection_factory.hpp index aa77ca302..aa7dc8388 100644 --- a/boost/network/protocol/http/client/connection/connection_factory.hpp +++ b/boost/network/protocol/http/client/connection/connection_factory.hpp @@ -8,14 +8,20 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include -#include + +namespace boost { namespace asio { + +class io_service; + +} // namespace asio + +} // namespace boost namespace boost { namespace network { namespace http { class client_options; - struct client_connection; +struct request_base; struct connection_factory { virtual shared_ptr create_connection(asio::io_service &service, @@ -30,8 +36,4 @@ struct connection_factory { } /* boost */ -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif - #endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_FACTORY_HPP_20111112 */ diff --git a/boost/network/protocol/http/client/connection/normal_delegate.hpp b/boost/network/protocol/http/client/connection/normal_delegate.hpp index 8817aa235..15c44c595 100644 --- a/boost/network/protocol/http/client/connection/normal_delegate.hpp +++ b/boost/network/protocol/http/client/connection/normal_delegate.hpp @@ -38,8 +38,4 @@ struct normal_delegate : connection_delegate { } /* boost */ -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif /* BOOST_NETWORK_NO_LIB */ - #endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_NORMAL_DELEGATE_20110819 */ diff --git a/boost/network/protocol/http/client/connection/resolver_delegate.hpp b/boost/network/protocol/http/client/connection/resolver_delegate.hpp index dd2492db0..1804cd7c5 100644 --- a/boost/network/protocol/http/client/connection/resolver_delegate.hpp +++ b/boost/network/protocol/http/client/connection/resolver_delegate.hpp @@ -32,8 +32,4 @@ struct resolver_delegate { } /* boost */ -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif - #endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_HPP_20111016 */ diff --git a/boost/network/protocol/http/client/connection/resolver_delegate_factory.hpp b/boost/network/protocol/http/client/connection/resolver_delegate_factory.hpp index 3c21fa8d2..48628eac4 100644 --- a/boost/network/protocol/http/client/connection/resolver_delegate_factory.hpp +++ b/boost/network/protocol/http/client/connection/resolver_delegate_factory.hpp @@ -28,8 +28,4 @@ struct resolver_delegate_factory { } /* network */ } /* boost */ -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif - #endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_FACTORY_HPP_20110930 */ diff --git a/boost/network/protocol/http/client/connection/resolver_delegate_factory.ipp b/boost/network/protocol/http/client/connection/resolver_delegate_factory.ipp index ee3df204f..16d37de66 100644 --- a/boost/network/protocol/http/client/connection/resolver_delegate_factory.ipp +++ b/boost/network/protocol/http/client/connection/resolver_delegate_factory.ipp @@ -9,20 +9,26 @@ #include #include +#include namespace boost { namespace network { namespace http { -resolver_delegate_factory::resolver_delegate_factory() {} +resolver_delegate_factory::resolver_delegate_factory() { + BOOST_NETWORK_MESSAGE("resolver_delegate_factory::resolver_delegate_factory()"); +} shared_ptr resolver_delegate_factory::create_resolver_delegate(asio::io_service & service, bool cache_resolved) { + BOOST_NETWORK_MESSAGE("resolver_delegate_factory::create_resolver_delegate(...)"); shared_ptr resolver_( new (std::nothrow) async_resolver(service, cache_resolved)); return resolver_; } -resolver_delegate_factory::~resolver_delegate_factory() {} +resolver_delegate_factory::~resolver_delegate_factory() { + BOOST_NETWORK_MESSAGE("resolver_delegate_factory::~resolver_delegate_factory()"); +} } // namespace http diff --git a/boost/network/protocol/http/client/connection/simple_connection_factory.hpp b/boost/network/protocol/http/client/connection/simple_connection_factory.hpp index b83696d59..00a2c2ab6 100644 --- a/boost/network/protocol/http/client/connection/simple_connection_factory.hpp +++ b/boost/network/protocol/http/client/connection/simple_connection_factory.hpp @@ -37,9 +37,5 @@ struct simple_connection_factory : connection_factory { } /* boost */ -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif - #endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SIMPLE_CONNECTION_FACTORY_20111112 */ diff --git a/boost/network/protocol/http/client/connection/simple_connection_factory.ipp b/boost/network/protocol/http/client/connection/simple_connection_factory.ipp index 5c6a19e62..14573daa3 100644 --- a/boost/network/protocol/http/client/connection/simple_connection_factory.ipp +++ b/boost/network/protocol/http/client/connection/simple_connection_factory.ipp @@ -12,6 +12,12 @@ #include #include #include +#include +#ifdef BOOST_NETWORK_DEBUG +#include +#endif + +#include namespace boost { namespace network { namespace http { @@ -19,14 +25,17 @@ struct simple_connection_factory_pimpl { simple_connection_factory_pimpl(shared_ptr conn_delegate_factory, shared_ptr res_delegate_factory) : conn_delegate_factory_(conn_delegate_factory) - , res_delegate_factory_(res_delegate_factory) - {} + , res_delegate_factory_(res_delegate_factory) { + BOOST_NETWORK_MESSAGE("simple_connection_factory_pimpl::simple_connection_factory_pimpl(...)"); + } shared_ptr create_connection( asio::io_service & service, request_base const & request, client_options const & options) { - ::boost::network::uri::uri uri_(destination(request)); + BOOST_NETWORK_MESSAGE("simple_connection_factory_pimpl::create_connection(...)"); + uri::uri uri_ = http::uri(request); + BOOST_NETWORK_MESSAGE("destination: " << uri_); bool https = to_lower_copy(scheme(uri_)) == "https"; shared_ptr conn_; conn_.reset(new (std::nothrow) http_async_connection( @@ -43,6 +52,7 @@ struct simple_connection_factory_pimpl { }; simple_connection_factory::simple_connection_factory() { + BOOST_NETWORK_MESSAGE("simple_connection_factory::simple_connection_factory()"); shared_ptr connection_delegate_factory_; connection_delegate_factory_.reset(new (std::nothrow) connection_delegate_factory()); shared_ptr resolver_delegate_factory_; @@ -54,16 +64,20 @@ simple_connection_factory::simple_connection_factory() { simple_connection_factory::simple_connection_factory(shared_ptr conn_delegate_factory, shared_ptr res_delegate_factory) : pimpl(new (std::nothrow) simple_connection_factory_pimpl(conn_delegate_factory, res_delegate_factory)) -{} +{ + BOOST_NETWORK_MESSAGE("simple_connection_factory::simple_connection_factory(...)"); +} shared_ptr simple_connection_factory::create_connection(asio::io_service & service, request_base const & request, client_options const &options) { + BOOST_NETWORK_MESSAGE("simple_connection_factory::create_connection(...)"); return pimpl->create_connection(service, request, options); } simple_connection_factory::~simple_connection_factory() { + BOOST_NETWORK_MESSAGE("simple_connection_factory::~simple_connection_factory()"); // do nothing } diff --git a/boost/network/protocol/http/client/connection/ssl_delegate.hpp b/boost/network/protocol/http/client/connection/ssl_delegate.hpp index a159b4d93..47e1c960c 100644 --- a/boost/network/protocol/http/client/connection/ssl_delegate.hpp +++ b/boost/network/protocol/http/client/connection/ssl_delegate.hpp @@ -47,8 +47,4 @@ struct ssl_delegate : connection_delegate, enable_shared_from_this } /* boost */ -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif /* BOOST_NETWORK_NO_LIB */ - #endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SSL_DELEGATE_20110819 */ diff --git a/boost/network/protocol/http/client/connection/ssl_delegate.ipp b/boost/network/protocol/http/client/connection/ssl_delegate.ipp index f8290178d..302fa180a 100755 --- a/boost/network/protocol/http/client/connection/ssl_delegate.ipp +++ b/boost/network/protocol/http/client/connection/ssl_delegate.ipp @@ -10,6 +10,7 @@ #include #include #include +#include boost::network::http::ssl_delegate::ssl_delegate(asio::io_service & service, client_options const &options) : @@ -19,6 +20,7 @@ boost::network::http::ssl_delegate::ssl_delegate(asio::io_service & service, void boost::network::http::ssl_delegate::connect( asio::ip::tcp::endpoint & endpoint, function handler) { + BOOST_NETWORK_MESSAGE("ssl_delegate::connect(...)"); context_.reset(new asio::ssl::context( service_, asio::ssl::context::sslv23_client)); @@ -27,6 +29,7 @@ void boost::network::http::ssl_delegate::connect( std::list const & verifier_paths = options_.openssl_verify_paths(); bool verify_peer = !certificate_paths.empty() || !verifier_paths.empty(); + BOOST_NETWORK_MESSAGE("verify peer setting is: " << verify_peer); if (verify_peer) context_->set_verify_mode(asio::ssl::context::verify_peer); else context_->set_verify_mode(asio::ssl::context::verify_none); for (std::list::const_iterator it = certificate_paths.begin(); @@ -38,6 +41,7 @@ void boost::network::http::ssl_delegate::connect( context_->add_verify_path(*it); } socket_.reset(new asio::ssl::stream(service_, *context_)); + BOOST_NETWORK_MESSAGE("scheduling asynchronous connection..."); socket_->lowest_layer().async_connect( endpoint, ::boost::bind(&boost::network::http::ssl_delegate::handle_connected, @@ -48,9 +52,12 @@ void boost::network::http::ssl_delegate::connect( void boost::network::http::ssl_delegate::handle_connected(system::error_code const & ec, function handler) { + BOOST_NETWORK_MESSAGE("ssl_delegate::handle_connected(...)"); if (!ec) { + BOOST_NETWORK_MESSAGE("connected to endpoint."); socket_->async_handshake(asio::ssl::stream_base::client, handler); } else { + BOOST_NETWORK_MESSAGE("encountered error: " << ec); handler(ec); } } @@ -58,15 +65,21 @@ void boost::network::http::ssl_delegate::handle_connected(system::error_code con void boost::network::http::ssl_delegate::write( asio::streambuf & command_streambuf, function handler) { + BOOST_NETWORK_MESSAGE("ssl_delegate::write(...)"); + BOOST_NETWORK_MESSAGE("scheduling asynchronous write..."); asio::async_write(*socket_, command_streambuf, handler); } void boost::network::http::ssl_delegate::read_some( asio::mutable_buffers_1 const & read_buffer, function handler) { + BOOST_NETWORK_MESSAGE("ssl_delegate::read_some(...)"); + BOOST_NETWORK_MESSAGE("scheduling asynchronous read_some..."); socket_->async_read_some(read_buffer, handler); } -boost::network::http::ssl_delegate::~ssl_delegate() {} +boost::network::http::ssl_delegate::~ssl_delegate() { + BOOST_NETWORK_MESSAGE("ssl_delegate::~ssl_delegate()"); +} #endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SSL_DELEGATE_IPP_20110819 */ diff --git a/boost/network/protocol/http/client/connection_manager.hpp b/boost/network/protocol/http/client/connection_manager.hpp index b9ed8f05a..062b7d742 100644 --- a/boost/network/protocol/http/client/connection_manager.hpp +++ b/boost/network/protocol/http/client/connection_manager.hpp @@ -7,13 +7,20 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include -#include -#include +#include + +namespace boost { namespace asio { + +class io_service; + +} // namespace asio + +} // namespace boost namespace boost { namespace network { namespace http { +struct client_connection; +struct request_base; class client_options; struct connection_manager { diff --git a/boost/network/protocol/http/client/connection_manager.ipp b/boost/network/protocol/http/client/connection_manager.ipp index fc1b45978..44539a806 100644 --- a/boost/network/protocol/http/client/connection_manager.ipp +++ b/boost/network/protocol/http/client/connection_manager.ipp @@ -8,10 +8,12 @@ // http://www.boost.org/LICENSE_1_0.txt) #include +#include namespace boost { namespace network { namespace http { connection_manager::~connection_manager() { + BOOST_NETWORK_MESSAGE("connection_manager::~connection_manager()"); // default implementation, for linkage only. } diff --git a/boost/network/protocol/http/client/facade.ipp b/boost/network/protocol/http/client/facade.ipp index a58882b09..28e7e1313 100644 --- a/boost/network/protocol/http/client/facade.ipp +++ b/boost/network/protocol/http/client/facade.ipp @@ -2,19 +2,23 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_FACADE_IPP_20120303 #include +#include namespace boost { namespace network { namespace http { basic_client_facade::basic_client_facade() -: base(new (std::nothrow) client_base()) -{} +: base(new (std::nothrow) client_base()) { + BOOST_NETWORK_MESSAGE("basic_client_facade::basic_client_facade()"); +} basic_client_facade::basic_client_facade(client_options const &options) -: base(new (std::nothrow) client_base(options)) -{} +: base(new (std::nothrow) client_base(options)) { + BOOST_NETWORK_MESSAGE("basic_client_facade::basic_client_facade(client_options const &)"); +} response const basic_client_facade::head(request const &request, request_options const&options) { + BOOST_NETWORK_MESSAGE("basic_client_facade::head(...)"); return base->request_skeleton(request, "HEAD", false, @@ -25,6 +29,7 @@ response const basic_client_facade::head(request const &request, response const basic_client_facade::get(request const &request, body_callback_function_type body_handler, request_options const &options) { + BOOST_NETWORK_MESSAGE("basic_client_facade::get(...)"); return base->request_skeleton(request, "GET", true, body_handler, options); } @@ -33,7 +38,9 @@ response const basic_client_facade::post(request request, optional content_type, body_callback_function_type body_handler, request_options const &options) { + BOOST_NETWORK_MESSAGE("basic_client_facade::post(...)"); if (body) { + BOOST_NETWORK_MESSAGE("using body provided."); request << remove_header("Content-Length") << header("Content-Length", boost::lexical_cast(body->size())) << boost::network::body(*body); @@ -42,10 +49,12 @@ response const basic_client_facade::post(request request, headers_wrapper::range_type content_type_headers = headers(request)["Content-Type"]; if (content_type) { + BOOST_NETWORK_MESSAGE("using provided content type."); if (!boost::empty(content_type_headers)) request << remove_header("Content-Type"); request << header("Content-Type", *content_type); } else { + BOOST_NETWORK_MESSAGE("using default content type."); if (boost::empty(content_type_headers)) { static char default_content_type[] = "x-application/octet-stream"; request << header("Content-Type", default_content_type); @@ -59,7 +68,9 @@ response const basic_client_facade::put(request request, optional content_type, body_callback_function_type body_handler, request_options const & options) { + BOOST_NETWORK_MESSAGE("basic_client_facade::put(...)"); if (body) { + BOOST_NETWORK_MESSAGE("using body provided."); request << remove_header("Content-Length") << header("Content-Length", boost::lexical_cast(body->size())) << boost::network::body(*body); @@ -68,10 +79,12 @@ response const basic_client_facade::put(request request, headers_wrapper::range_type content_type_headers = headers(request)["Content-Type"]; if (content_type) { + BOOST_NETWORK_MESSAGE("using provided content type."); if (!boost::empty(content_type_headers)) request << remove_header("Content-Type"); request << header("Content-Type", *content_type); } else { + BOOST_NETWORK_MESSAGE("using default content type."); if (boost::empty(content_type_headers)) { static char default_content_type[] = "x-application/octet-stream"; request << header("Content-Type", default_content_type); @@ -83,10 +96,12 @@ response const basic_client_facade::put(request request, response const basic_client_facade::delete_(request const & request, body_callback_function_type body_handler, request_options const & options) { + BOOST_NETWORK_MESSAGE("basic_client_facade::delete_(...)"); return base->request_skeleton(request, "DELETE", true, body_handler, options); } void basic_client_facade::clear_resolved_cache() { + BOOST_NETWORK_MESSAGE("basic_client_facade::clear_resolved_cache()"); base->clear_resolved_cache(); } diff --git a/boost/network/protocol/http/client/simple_connection_manager.hpp b/boost/network/protocol/http/client/simple_connection_manager.hpp index 81c10c765..ec0382df3 100644 --- a/boost/network/protocol/http/client/simple_connection_manager.hpp +++ b/boost/network/protocol/http/client/simple_connection_manager.hpp @@ -87,8 +87,4 @@ struct simple_connection_manager : connection_manager { } /* boost */ -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif - #endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_SIMPLE_CONNECTION_MANAGER_HPP_20111105 */ diff --git a/boost/network/protocol/http/client/simple_connection_manager.ipp b/boost/network/protocol/http/client/simple_connection_manager.ipp index a5aa72d7f..0b0bd0a11 100644 --- a/boost/network/protocol/http/client/simple_connection_manager.ipp +++ b/boost/network/protocol/http/client/simple_connection_manager.ipp @@ -10,6 +10,7 @@ #include #include #include +#include namespace boost { namespace network { namespace http { @@ -18,14 +19,20 @@ struct simple_connection_manager_pimpl { : options_(options) , connection_factory_(options.connection_factory()) { - if (!connection_factory_.get()) + BOOST_NETWORK_MESSAGE( + "simple_connection_manager_pimpl::simple_connection_manager_pimpl(" + "client_options const &)"); + if (!connection_factory_.get()) { + BOOST_NETWORK_MESSAGE("creating simple connection factory"); connection_factory_.reset( new (std::nothrow) simple_connection_factory()); + } } shared_ptr get_connection(asio::io_service & service, request_base const & request, client_options const &options) { + BOOST_NETWORK_MESSAGE("simple_connection_manager_pimpl::get_connection(...)"); return connection_factory_->create_connection(service, request, options_); } @@ -38,6 +45,7 @@ struct simple_connection_manager_pimpl { } ~simple_connection_manager_pimpl() { + BOOST_NETWORK_MESSAGE("simple_connection_manager_pimpl::~simple_connection_manager_pimpl()"); // do nothing here. } @@ -48,24 +56,31 @@ private: simple_connection_manager::simple_connection_manager(client_options const &options) : pimpl(new (std::nothrow) simple_connection_manager_pimpl(options)) -{} +{ + BOOST_NETWORK_MESSAGE("simple_connection_manager::simple_connection_manager(" + "client_options const &)"); +} shared_ptr simple_connection_manager::get_connection( asio::io_service & service, request_base const & request, client_options const &options) { + BOOST_NETWORK_MESSAGE("simple_connection_manager::get_connection(...)"); return pimpl->get_connection(service, request, options); } void simple_connection_manager::reset() { + BOOST_NETWORK_MESSAGE("simple_connection_manager::reset()"); pimpl->reset(); } void simple_connection_manager::clear_resolved_cache() { + BOOST_NETWORK_MESSAGE("simple_connection_manager::clear_resolved_cache()"); pimpl->clear_resolved_cache(); } simple_connection_manager::~simple_connection_manager() { + BOOST_NETWORK_MESSAGE("simple_connection_manager::~simple_connection_manager()"); // do nothing here. } diff --git a/boost/network/protocol/http/message/wrappers/uri.hpp b/boost/network/protocol/http/message/wrappers/uri.hpp index 191bbf9af..7db8ce961 100644 --- a/boost/network/protocol/http/message/wrappers/uri.hpp +++ b/boost/network/protocol/http/message/wrappers/uri.hpp @@ -17,7 +17,7 @@ struct uri_wrapper { operator std::string() const; operator boost::network::uri::uri() const; private: - request_base & request_; + request_base const & request_; }; inline diff --git a/boost/network/protocol/http/message/wrappers/uri.ipp b/boost/network/protocol/http/message/wrappers/uri.ipp new file mode 100644 index 000000000..8034d387d --- /dev/null +++ b/boost/network/protocol/http/message/wrappers/uri.ipp @@ -0,0 +1,38 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_URI_IPP_20120315 +#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_URI_IPP_20120315 + +// Copyright 2012 Dean Michael Berris . +// Copyright 2012 Google, Inc. +// 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) + +#include + +namespace boost { namespace network { namespace http { + +uri_wrapper::uri_wrapper(request_base const & request_) +: request_(request_) { + // do nothing here +} + +uri_wrapper::operator std::string() const { + std::string uri; + request_.get_uri(uri); + return uri; +} + +uri_wrapper::operator boost::network::uri::uri() const { + boost::network::uri::uri uri; + request_.get_uri(uri); + return uri; +} + +} // namespace http + +} // namespace network + +} // namespace boost + + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_URI_IPP_20120315 diff --git a/boost/network/protocol/http/request.hpp b/boost/network/protocol/http/request.hpp index ae0098a6b..e0ceaff0a 100644 --- a/boost/network/protocol/http/request.hpp +++ b/boost/network/protocol/http/request.hpp @@ -8,31 +8,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include #include -#include #endif // BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_HPP_20111021 diff --git a/boost/network/protocol/http/request/request.ipp b/boost/network/protocol/http/request/request.ipp index e16ac99e3..2fbc6fb9a 100644 --- a/boost/network/protocol/http/request/request.ipp +++ b/boost/network/protocol/http/request/request.ipp @@ -18,7 +18,13 @@ BOOST_CONCEPT_ASSERT((boost::network::http::ClientRequest +#include +#include #include #include #include diff --git a/libs/network/src/http/message/wrappers.cpp b/libs/network/src/http/message/wrappers.cpp new file mode 100644 index 000000000..0fafbfc42 --- /dev/null +++ b/libs/network/src/http/message/wrappers.cpp @@ -0,0 +1,12 @@ +// Copyright 2012 Dean Michael Berris . +// Copyright 2012 Google, Inc. +// 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) + +#include +#include +#include +#include +#include +#include diff --git a/libs/network/src/http/request.cpp b/libs/network/src/http/request.cpp index 4a22cc2de..658ef67de 100644 --- a/libs/network/src/http/request.cpp +++ b/libs/network/src/http/request.cpp @@ -10,8 +10,3 @@ #include #include -#include -#include -#include -#include -#include diff --git a/libs/network/test/http/CMakeLists.txt b/libs/network/test/http/CMakeLists.txt index 3b4945eb0..dedbe384e 100644 --- a/libs/network/test/http/CMakeLists.txt +++ b/libs/network/test/http/CMakeLists.txt @@ -16,6 +16,7 @@ if (Boost_FOUND) set ( MESSAGE_TESTS request_base_test request_test + request_linearize_test response_test ) foreach ( test ${MESSAGE_TESTS} ) @@ -28,8 +29,11 @@ if (Boost_FOUND) ${Boost_LIBRARIES} cppnetlib-message cppnetlib-message-wrappers + cppnetlib-http-message + cppnetlib-http-message-wrappers cppnetlib-uri - cppnetlib-http-message) + cppnetlib-constants + ) set_target_properties(cpp-netlib-http-${test} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests) add_test(cpp-netlib-http-${test} @@ -58,6 +62,7 @@ if (Boost_FOUND) cppnetlib-message-wrappers cppnetlib-message-directives cppnetlib-http-message + cppnetlib-http-message-wrappers cppnetlib-http-client cppnetlib-http-client-connections) if (OPENSSL_FOUND) diff --git a/libs/network/test/http/request_linearize_test.cpp b/libs/network/test/http/request_linearize_test.cpp index c2151a054..e799b75b9 100644 --- a/libs/network/test/http/request_linearize_test.cpp +++ b/libs/network/test/http/request_linearize_test.cpp @@ -8,24 +8,14 @@ #include #include #include -#include #include namespace http = boost::network::http; -namespace tags = boost::network::http::tags; -namespace mpl = boost::mpl; namespace net = boost::network; -typedef mpl::list< - tags::http_default_8bit_tcp_resolve - , tags::http_default_8bit_udp_resolve - , tags::http_async_8bit_tcp_resolve - , tags::http_async_8bit_udp_resolve - > tag_types; - -BOOST_AUTO_TEST_CASE_TEMPLATE(linearize_request, T, tag_types) { - http::basic_request request("http://www.boost.org/"); - linearize(request, "GET", 1, 0, std::ostream_iterator::type>(std::cout)); - linearize(request, "GET", 1, 1, std::ostream_iterator::type>(std::cout)); +BOOST_AUTO_TEST_CASE(linearize_request) { + http::request request("http://www.boost.org/"); + linearize(request, "GET", 1, 0, std::ostream_iterator(std::cout)); + linearize(request, "GET", 1, 1, std::ostream_iterator(std::cout)); } diff --git a/libs/network/test/http/request_test.cpp b/libs/network/test/http/request_test.cpp index 4ae1e91de..147b5700a 100644 --- a/libs/network/test/http/request_test.cpp +++ b/libs/network/test/http/request_test.cpp @@ -6,8 +6,10 @@ #define BOOST_TEST_MODULE HTTP Request Test #include +#include #include #include +#include namespace http = boost::network::http; namespace uri = boost::network::uri; @@ -54,6 +56,20 @@ BOOST_AUTO_TEST_CASE(request_uri_test) { BOOST_CHECK_EQUAL(original, copied); } +BOOST_AUTO_TEST_CASE(request_url_constructor_test) { + http::request request("http://www.google.com/"); + http::request other; + other.set_uri("http://www.google.com/"); + uri::uri original, other_uri; + request.get_uri(original); + other.get_uri(other_uri); + BOOST_CHECK_EQUAL(original, other_uri); + + // Now test the directives.. + uri::uri directive_original = http::uri(request); + BOOST_CHECK_EQUAL(original, directive_original); +} + BOOST_AUTO_TEST_CASE(request_basics_test) { http::request request; request.set_uri("http://www.google.com/"); From 64f4ef94df953d7a8104076bafb32f9470601d1d Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Fri, 16 Mar 2012 00:09:32 +1100 Subject: [PATCH 064/196] Fixes URI assignment. --- boost/network/uri/uri.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/boost/network/uri/uri.hpp b/boost/network/uri/uri.hpp index ff9b4db63..1cfdea7d1 100644 --- a/boost/network/uri/uri.hpp +++ b/boost/network/uri/uri.hpp @@ -64,8 +64,9 @@ class BOOST_URI_DECL uri { } - uri &operator = (const uri &other) { - uri(other).swap(*this); + uri &operator = (uri other) { + other.swap(*this); + parse(); return *this; } From 2f2890f0ceae0f2f30561509e453d0ba935030f3 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Fri, 16 Mar 2012 02:36:45 +1100 Subject: [PATCH 065/196] Lots of debugging. At this point in the development, I'm stuck as to why the asynchronous reads aren't returning data after writing the request down through the sockets. I may just be missing some crucial setting on the created sockets to properly enable the asynchronous processing, or the HTTP request isn't well-formed, or there's some deadlock that I'm not seeing. I'll debug this after a few hours of sleep. Upped the version to 0.10.0a (a for the alpha) and hopefully this gets functional sooner than later. --- boost/network/constants.hpp | 5 +- boost/network/constants.ipp | 20 +++---- boost/network/message/message.hpp | 2 +- boost/network/message/wrappers/headers.hpp | 25 ++------- boost/network/message/wrappers/headers.ipp | 53 +++---------------- .../protocol/http/algorithms/linearize.hpp | 18 +++++-- .../http/client/connection/async_normal.ipp | 21 ++++++++ .../client/connection/normal_delegate.ipp | 3 ++ boost/network/protocol/http/client/facade.ipp | 22 ++++---- boost/network/version.hpp | 4 +- .../http/client_get_different_port_test.cpp | 14 ++--- .../test/http/client_get_streaming_test.cpp | 4 +- libs/network/test/http/client_get_test.cpp | 3 +- libs/network/test/http/request_test.cpp | 14 ++++- libs/network/test/message_test.cpp | 20 ++++--- libs/network/test/uri/CMakeLists.txt | 2 +- 16 files changed, 112 insertions(+), 118 deletions(-) diff --git a/boost/network/constants.hpp b/boost/network/constants.hpp index 12d7e33b3..c22dcd7a7 100644 --- a/boost/network/constants.hpp +++ b/boost/network/constants.hpp @@ -25,6 +25,7 @@ struct constants { static char const * accept_encoding(); static char const * default_accept_encoding(); static char const * user_agent(); + static char const * default_user_agent(); static char const * cpp_netlib_slash(); static char question_mark_char(); static char hash_char(); @@ -33,10 +34,6 @@ struct constants { static char const * https(); }; -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif - } // namespace network } // namespace boost diff --git a/boost/network/constants.ipp b/boost/network/constants.ipp index e6e10cd4d..73a7d3e93 100644 --- a/boost/network/constants.ipp +++ b/boost/network/constants.ipp @@ -8,23 +8,24 @@ // http://www.boost.org/LICENSE_1_0.txt) #include +#include namespace boost { namespace network { char const * constants::crlf() { - static char crlf_[] = { '\r', '\n', 0 }; + static char crlf_[] = "\r\n"; return crlf_; } char const * constants::dot() { - static char dot_[] = { '.', 0 }; + static char dot_[] = "."; return dot_; } char constants::dot_char() { return '.'; } char const * constants::http_slash() { - static char http_slash_[] = { 'H', 'T', 'T', 'P', '/', 0 }; + static char http_slash_[] = "HTTP/"; return http_slash_; } @@ -103,16 +104,12 @@ char constants::hash_char() { } char const * constants::connection() { - static char connection_[] = { - 'C','o','n','n','e','c','t','i','o','n',0 - }; + static char connection_[] = "Connection"; return connection_; } char const * constants::close() { - static char close_[] = { - 'C','l','o','s','e', 0 - }; + static char close_[] = "close"; return close_; } @@ -121,6 +118,11 @@ char const * constants::https() { return https_; } +char const * constants::default_user_agent() { + static char user_agent_[] = "cpp-netlib/" BOOST_NETLIB_VERSION; + return user_agent_; +} + } /* network */ } /* boost */ diff --git a/boost/network/message/message.hpp b/boost/network/message/message.hpp index 2d570a506..e9be07051 100644 --- a/boost/network/message/message.hpp +++ b/boost/network/message/message.hpp @@ -22,7 +22,7 @@ struct message_pimpl; struct message : message_base { // Nested types typedef iterator_range< - shared_container_iterator > > + std::multimap::const_iterator> headers_range; // Constructors diff --git a/boost/network/message/wrappers/headers.hpp b/boost/network/message/wrappers/headers.hpp index a7a44aeae..0a9bceeca 100644 --- a/boost/network/message/wrappers/headers.hpp +++ b/boost/network/message/wrappers/headers.hpp @@ -4,17 +4,15 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef __NETWORK_MESSAGE_WRAPPERS_HEADERS_HPP__ -#define __NETWORK_MESSAGE_WRAPPERS_HEADERS_HPP__ +#ifndef NETWORK_MESSAGE_WRAPPERS_HEADERS_HPP__ +#define NETWORK_MESSAGE_WRAPPERS_HEADERS_HPP__ #include -#include -#include -#include -#include namespace boost { namespace network { +struct message_base; + /** headers wrapper for messages. * * This exposes an interface similar to a map, indexable @@ -25,21 +23,10 @@ namespace boost { namespace network { */ struct headers_wrapper { typedef std::multimap container_type; - typedef shared_container_iterator iterator; - typedef iterator_range range_type; - explicit headers_wrapper(message_base const & message); - range_type operator[] (std::string const & key) const; - operator range_type () const; operator container_type () const; - container_type::size_type count() const; - container_type::size_type count(std::string const &key) const; - iterator begin() const; - iterator end() const; private: - void init_cache_all() const; message_base const & message_; - mutable shared_ptr cache_; }; /// Factory method to create the right wrapper object @@ -52,8 +39,4 @@ headers(message_base const & message_) { } // namespace boost -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif - #endif // __NETWORK_MESSAGE_WRAPPERS_HEADERS_HPP__ diff --git a/boost/network/message/wrappers/headers.ipp b/boost/network/message/wrappers/headers.ipp index 38d917189..2b55db975 100644 --- a/boost/network/message/wrappers/headers.ipp +++ b/boost/network/message/wrappers/headers.ipp @@ -8,6 +8,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include +#include #include namespace boost { namespace network { @@ -16,45 +17,6 @@ headers_wrapper::headers_wrapper(message_base const & message) : message_(message) {} -headers_wrapper::range_type headers_wrapper::operator[] (std::string const & key) const { - this->init_cache_all(); - std::pair p = - cache_->equal_range(key); - return boost::make_iterator_range( - boost::make_shared_container_iterator( - p.first, cache_), - boost::make_shared_container_iterator( - p.second, cache_)); -} - -headers_wrapper::container_type::size_type -headers_wrapper::count(std::string const & key) const { - this->init_cache_all(); - return cache_->size(); -} - -headers_wrapper::iterator headers_wrapper::begin() const { - this->init_cache_all(); - container_type::iterator begin = cache_->begin(); - return make_shared_container_iterator(begin, cache_); -} - -headers_wrapper::iterator headers_wrapper::end() const { - this->init_cache_all(); - container_type::iterator end = cache_->end(); - return make_shared_container_iterator(end, cache_); -}; - -headers_wrapper::operator headers_wrapper::range_type () const { - this->init_cache_all(); - return make_shared_container_range(cache_); -}; - -headers_wrapper::operator headers_wrapper::container_type () const { - this->init_cache_all(); - return *cache_; -} - template struct kv_inserter { kv_inserter(Map & m) @@ -66,14 +28,11 @@ struct kv_inserter { Map & m_; }; -void headers_wrapper::init_cache_all() const { - if (!cache_.get()) { - cache_.reset(new (std::nothrow) container_type); - if (!cache_.get()) - BOOST_THROW_EXCEPTION(std::runtime_error( - "Cannot allocate cache multimap for headers wrapper.")); - message_.get_headers(kv_inserter(*cache_)); - } +headers_wrapper::operator headers_wrapper::container_type () const { + container_type tmp; + kv_inserter inserter(tmp); + message_.get_headers(inserter); + return tmp; } } /* network */ diff --git a/boost/network/protocol/http/algorithms/linearize.hpp b/boost/network/protocol/http/algorithms/linearize.hpp index b0214ab21..cc13adf2c 100644 --- a/boost/network/protocol/http/algorithms/linearize.hpp +++ b/boost/network/protocol/http/algorithms/linearize.hpp @@ -63,6 +63,8 @@ namespace boost { namespace network { namespace http { , accept_mime = consts::default_accept_mime() , accept_encoding = consts::accept_encoding() , default_accept_encoding = consts::default_accept_encoding() + , default_user_agent = consts::default_user_agent() + , user_agent = consts::user_agent() , crlf = consts::crlf() , host_const = consts::host() , connection = consts::connection() @@ -124,11 +126,12 @@ namespace boost { namespace network { namespace http { boost::copy(default_accept_encoding, oi); boost::copy(crlf, oi); } - typedef headers_wrapper::range_type headers_range; - typedef typename range_iterator::type headers_iterator; - headers_range request_headers = boost::network::headers(request); + typedef headers_wrapper::container_type headers_container; + typedef headers_container::const_iterator headers_iterator; + headers_container const & request_headers = boost::network::headers(request); headers_iterator iterator = boost::begin(request_headers), end = boost::end(request_headers); + bool has_user_agent = false; for (; iterator != end; ++iterator) { string_type header_name = name(*iterator), header_value = value(*iterator); @@ -137,6 +140,15 @@ namespace boost { namespace network { namespace http { *oi = consts::space_char(); boost::copy(header_value, oi); boost::copy(crlf, oi); + boost::to_lower(header_name); + has_user_agent = has_user_agent || header_name == "user-agent"; + } + if (!has_user_agent) { + boost::copy(user_agent, oi); + *oi = consts::colon_char(); + *oi = consts::space_char(); + boost::copy(default_user_agent, oi); + boost::copy(crlf, oi); } boost::copy(crlf, oi); boost::iterator_range body_data = diff --git a/boost/network/protocol/http/client/connection/async_normal.ipp b/boost/network/protocol/http/client/connection/async_normal.ipp index 955eac80b..a3969d7a1 100644 --- a/boost/network/protocol/http/client/connection/async_normal.ipp +++ b/boost/network/protocol/http/client/connection/async_normal.ipp @@ -163,6 +163,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thiswrite(command_streambuf, request_strand_.wrap( boost::bind( @@ -203,7 +204,9 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisread_some( boost::asio::mutable_buffers_1(this->part.c_array(), this->part.size()), @@ -214,16 +217,20 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisparse_version(request_strand_.wrap( boost::bind( @@ -235,6 +242,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisparse_status(request_strand_.wrap( boost::bind( @@ -246,6 +254,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisparse_status_message( request_strand_.wrap( @@ -260,6 +269,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thissource_promise.set_value(""); this->part.assign('\0'); this->response_parser_.reset(); + BOOST_NETWORK_MESSAGE("processing done."); return; } if (callback) { + BOOST_NETWORK_MESSAGE("callback provided, processing body..."); // Here we deal with the spill-over data from the // headers processing. This means the headers data // has already been parsed appropriately and we're @@ -323,6 +336,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisparse_body( @@ -338,12 +352,15 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thispart.begin(), end = begin; @@ -354,6 +371,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thispartial_parsed); body_string.append( @@ -368,9 +386,11 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thispart.assign('\0'); this->response_parser_.reset(); } else { + BOOST_NETWORK_MESSAGE("connection still active..."); // This means the connection has not been closed yet and we want to get more // data. if (callback) { + BOOST_NETWORK_MESSAGE("callback provided, invoking callback..."); // Here we have a body_handler callback. Let's invoke the // callback from here and make sure we're getting more data // right after. @@ -392,6 +412,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this #include #include +#include boost::network::http::normal_delegate::normal_delegate(asio::io_service & service) : service_(service) @@ -34,6 +35,8 @@ void boost::network::http::normal_delegate::write( void boost::network::http::normal_delegate::read_some( asio::mutable_buffers_1 const & read_buffer, function handler) { + BOOST_NETWORK_MESSAGE("normal_delegate::read_some(...)"); + BOOST_NETWORK_MESSAGE("scheduling asynchronous read some..."); socket_->async_read_some(read_buffer, handler); } diff --git a/boost/network/protocol/http/client/facade.ipp b/boost/network/protocol/http/client/facade.ipp index 28e7e1313..7f626285d 100644 --- a/boost/network/protocol/http/client/facade.ipp +++ b/boost/network/protocol/http/client/facade.ipp @@ -46,16 +46,15 @@ response const basic_client_facade::post(request request, << boost::network::body(*body); } - headers_wrapper::range_type content_type_headers = - headers(request)["Content-Type"]; + headers_wrapper::container_type const & headers_ = + headers(request); if (content_type) { BOOST_NETWORK_MESSAGE("using provided content type."); - if (!boost::empty(content_type_headers)) - request << remove_header("Content-Type"); - request << header("Content-Type", *content_type); + request << remove_header("Content-Type") + << header("Content-Type", *content_type); } else { BOOST_NETWORK_MESSAGE("using default content type."); - if (boost::empty(content_type_headers)) { + if (boost::empty(headers_.equal_range("Content-Type"))) { static char default_content_type[] = "x-application/octet-stream"; request << header("Content-Type", default_content_type); } @@ -76,16 +75,15 @@ response const basic_client_facade::put(request request, << boost::network::body(*body); } - headers_wrapper::range_type content_type_headers = - headers(request)["Content-Type"]; + headers_wrapper::container_type const & headers_ = + headers(request); if (content_type) { BOOST_NETWORK_MESSAGE("using provided content type."); - if (!boost::empty(content_type_headers)) - request << remove_header("Content-Type"); - request << header("Content-Type", *content_type); + request << remove_header("Content-Type") + << header("Content-Type", *content_type); } else { BOOST_NETWORK_MESSAGE("using default content type."); - if (boost::empty(content_type_headers)) { + if (boost::empty(headers_.equal_range("Content-Type"))) { static char default_content_type[] = "x-application/octet-stream"; request << header("Content-Type", default_content_type); } diff --git a/boost/network/version.hpp b/boost/network/version.hpp index f22fb8628..7e08f6b6e 100644 --- a/boost/network/version.hpp +++ b/boost/network/version.hpp @@ -10,8 +10,8 @@ #include #define BOOST_NETLIB_VERSION_MAJOR 0 -#define BOOST_NETLIB_VERSION_MINOR 9 -#define BOOST_NETLIB_VERSION_INCREMENT 0 +#define BOOST_NETLIB_VERSION_MINOR 10 +#define BOOST_NETLIB_VERSION_INCREMENT 0a #ifndef BOOST_NETLIB_VERSION # define BOOST_NETLIB_VERSION \ diff --git a/libs/network/test/http/client_get_different_port_test.cpp b/libs/network/test/http/client_get_different_port_test.cpp index 81bcb4716..5b19dade1 100644 --- a/libs/network/test/http/client_get_different_port_test.cpp +++ b/libs/network/test/http/client_get_different_port_test.cpp @@ -8,13 +8,15 @@ #include #include +namespace http = boost::network::http; +namespace net = boost::network; + BOOST_AUTO_TEST_CASE(http_get_test_different_port) { - using namespace boost::network::http; - request request_("http://www.boost.org/"); - client client_; - response response_ = client_.get(request_); - boost::network::headers_wrapper::range_type headers_ = headers(response_)["Content-Type"]; - BOOST_CHECK( boost::begin(headers_) != boost::end(headers_) ); + http::request request_("http://www.boost.org/"); + http::client client_; + http::response response_ = client_.get(request_); + net::headers_wrapper::container_type const &headers_ = headers(response_); + BOOST_CHECK( !headers_.empty() ); BOOST_CHECK( body(response_).size() > 0 ); } diff --git a/libs/network/test/http/client_get_streaming_test.cpp b/libs/network/test/http/client_get_streaming_test.cpp index 680d05504..301649c7f 100644 --- a/libs/network/test/http/client_get_streaming_test.cpp +++ b/libs/network/test/http/client_get_streaming_test.cpp @@ -34,8 +34,8 @@ BOOST_AUTO_TEST_CASE(http_client_get_streaming_test) { { http::client client_; BOOST_CHECK_NO_THROW( response = client_.get(request, handler_instance) ); - net::headers_wrapper::range_type range = headers(response)["Content-Type"]; - BOOST_CHECK ( !boost::empty(range) ); + net::headers_wrapper::container_type const & headers_ = headers(response); + BOOST_CHECK ( !boost::empty(headers_) ); BOOST_CHECK_EQUAL ( body(response).size(), 0u ); std::string version_, status_message_; boost::uint16_t status_; diff --git a/libs/network/test/http/client_get_test.cpp b/libs/network/test/http/client_get_test.cpp index 27723d056..1aea187e9 100644 --- a/libs/network/test/http/client_get_test.cpp +++ b/libs/network/test/http/client_get_test.cpp @@ -11,7 +11,8 @@ namespace net = boost::network; namespace http = boost::network::http; BOOST_AUTO_TEST_CASE(http_client_get_test) { - http::client::request request("http://www.boost.org/"); + http::client::request request("http://www.google.com/"); + request << net::header("Connection", "close"); http::client client_; http::client::response response; BOOST_REQUIRE_NO_THROW ( response = client_.get(request) ); diff --git a/libs/network/test/http/request_test.cpp b/libs/network/test/http/request_test.cpp index 147b5700a..5a9a2654f 100644 --- a/libs/network/test/http/request_test.cpp +++ b/libs/network/test/http/request_test.cpp @@ -54,6 +54,16 @@ BOOST_AUTO_TEST_CASE(request_uri_test) { other.get_uri(copied); BOOST_CHECK_EQUAL(std::string("http://www.google.com/"), original); BOOST_CHECK_EQUAL(original, copied); + + // Now we test the bare uri instance with accessing using the request + // convenience wrapper. + uri::uri uri_; + request.get_uri(uri_); + std::string host_ = http::host(request); + BOOST_CHECK(uri::valid(uri_)); + BOOST_CHECK_EQUAL(std::string("www.google.com"), host_); + BOOST_CHECK_EQUAL(uri_.host(), host_); + BOOST_CHECK_EQUAL(std::string("www.google.com"), uri_.host()); } BOOST_AUTO_TEST_CASE(request_url_constructor_test) { @@ -81,7 +91,7 @@ BOOST_AUTO_TEST_CASE(request_basics_test) { uri::uri uri_; std::string source_, destination_, body_; - net::headers_wrapper::range_type headers_range = headers(request); + net::headers_wrapper::container_type const &headers_ = headers(request); request.get_uri(uri_); request.get_source(source_); request.get_destination(destination_); @@ -91,5 +101,5 @@ BOOST_AUTO_TEST_CASE(request_basics_test) { BOOST_CHECK_EQUAL(source_, std::string("127.0.0.1")); BOOST_CHECK_EQUAL(destination_, std::string("destination!")); BOOST_CHECK_EQUAL(body_, std::string("The quick brown fox jumps over the lazy dog!")); - BOOST_CHECK(!boost::empty(headers_range)); + BOOST_CHECK(!boost::empty(headers_)); } diff --git a/libs/network/test/message_test.cpp b/libs/network/test/message_test.cpp index d5f50fbf9..3c566cee5 100644 --- a/libs/network/test/message_test.cpp +++ b/libs/network/test/message_test.cpp @@ -21,8 +21,9 @@ BOOST_AUTO_TEST_CASE(copy_constructor_test) { message instance; instance << header("name", "value"); message copy(instance); - BOOST_CHECK_EQUAL(headers(copy).count("name"), static_cast(1)); - message::headers_range range = headers(copy)["name"]; + headers_wrapper::container_type const &headers_ = headers(copy); + BOOST_CHECK_EQUAL(headers_.count("name"), static_cast(1)); + message::headers_range range = headers_.equal_range("name"); BOOST_CHECK (!boost::empty(range)); } @@ -31,15 +32,18 @@ BOOST_AUTO_TEST_CASE(swap_test) { instance << header("name", "value"); message other; swap(instance, other); - BOOST_CHECK_EQUAL (headers(instance).count("name"), static_cast(0)); - BOOST_CHECK_EQUAL (headers(other).count("name"), static_cast(1)); + headers_wrapper::container_type const &instance_headers = headers(instance); + headers_wrapper::container_type const &other_headers = headers(other); + BOOST_CHECK_EQUAL (instance_headers.count("name"), static_cast(0)); + BOOST_CHECK_EQUAL (other_headers.count("name"), static_cast(1)); } BOOST_AUTO_TEST_CASE(headers_directive_test) { message instance; instance << header("name", "value"); - BOOST_CHECK_EQUAL ( headers(instance).count("name"), static_cast(1) ); - message::headers_range range = headers(instance)["name"]; + headers_wrapper::container_type const &instance_headers = headers(instance); + BOOST_CHECK_EQUAL ( instance_headers.count("name"), static_cast(1) ); + message::headers_range range = instance_headers.equal_range("name"); BOOST_CHECK (boost::begin(range) != boost::end(range)); } @@ -68,6 +72,8 @@ BOOST_AUTO_TEST_CASE(remove_header_directive_test) { message instance; instance << header("name", "value") << remove_header("name"); - message::headers_range range = headers(instance)["name"]; + headers_wrapper::container_type const &instance_headers = + headers(instance); + message::headers_range range = instance_headers.equal_range("name"); BOOST_CHECK ( boost::begin(range) == boost::end(range) ); } diff --git a/libs/network/test/uri/CMakeLists.txt b/libs/network/test/uri/CMakeLists.txt index 228e7ce0d..5d689ea91 100644 --- a/libs/network/test/uri/CMakeLists.txt +++ b/libs/network/test/uri/CMakeLists.txt @@ -10,7 +10,7 @@ if (Boost_FOUND) TESTS url_test url_builder_test - url_builder_stream_test +# url_builder_stream_test url_encoding_test relative_url_test ) From 83f17fd82f4ce7b5b623ca3b9c30bfb5359812e0 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Fri, 16 Mar 2012 16:38:21 +1100 Subject: [PATCH 066/196] Lesson: Be Careful with Print Debugging So it's been all good all along -- apparently in my eagerness to do print debugging, actually getting the information from the stream_buf actually causes the characters to be consumed. Removing the printing of the linearized command_stream alleviates the hanging issue -- now I can concentrate on other more pressing matters with the SSL implementation and the other missing functionality with the response type. --- .../protocol/http/client/connection/async_normal.ipp | 7 ------- .../protocol/http/client/connection/normal_delegate.ipp | 3 +++ boost/network/protocol/http/response/response.ipp | 6 ++++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/boost/network/protocol/http/client/connection/async_normal.ipp b/boost/network/protocol/http/client/connection/async_normal.ipp index a3969d7a1..97f06749e 100644 --- a/boost/network/protocol/http/client/connection/async_normal.ipp +++ b/boost/network/protocol/http/client/connection/async_normal.ipp @@ -55,13 +55,6 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this(&command_streambuf)); -#ifdef BOOST_NETWORK_DEBUG - { - std::ostringstream linearized; - linearized << &command_streambuf; - BOOST_NETWORK_MESSAGE("linearized request: ['" << linearized.str() << "']"); - } -#endif this->method = method; BOOST_NETWORK_MESSAGE("method: " << this->method); boost::uint16_t port_ = port(request); diff --git a/boost/network/protocol/http/client/connection/normal_delegate.ipp b/boost/network/protocol/http/client/connection/normal_delegate.ipp index 0e9cbdd7d..5732c93fa 100644 --- a/boost/network/protocol/http/client/connection/normal_delegate.ipp +++ b/boost/network/protocol/http/client/connection/normal_delegate.ipp @@ -29,6 +29,8 @@ void boost::network::http::normal_delegate::connect( void boost::network::http::normal_delegate::write( asio::streambuf & command_streambuf, function handler) { + BOOST_NETWORK_MESSAGE("normal_delegate::write(...)"); + BOOST_NETWORK_MESSAGE("scheduling asynchronous write..."); asio::async_write(*socket_, command_streambuf, handler); } @@ -38,6 +40,7 @@ void boost::network::http::normal_delegate::read_some( BOOST_NETWORK_MESSAGE("normal_delegate::read_some(...)"); BOOST_NETWORK_MESSAGE("scheduling asynchronous read some..."); socket_->async_read_some(read_buffer, handler); + BOOST_NETWORK_MESSAGE("scheduled asynchronous read some..."); } boost::network::http::normal_delegate::~normal_delegate() {} diff --git a/boost/network/protocol/http/response/response.ipp b/boost/network/protocol/http/response/response.ipp index 36f7d8066..e93ed66ec 100644 --- a/boost/network/protocol/http/response/response.ipp +++ b/boost/network/protocol/http/response/response.ipp @@ -81,8 +81,10 @@ struct response_pimpl { } } } else { - it = headers_future_.get().begin(); - for (;it != headers_future_.get().end(); ++it) { + std::multimap const & headers_ = + headers_future_.get(); + it = headers_.begin(); + for (;it != headers_.end(); ++it) { if (removed_headers_.find(it->first) == removed_headers_.end()) { inserter(it->first, it->second); } From 833469530491818c24ef9ad20554afe2cbe83b24 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Fri, 16 Mar 2012 22:36:57 +1100 Subject: [PATCH 067/196] Functional HTTP Client! So, now this particular non-HTTPS implementation is doing what it's supposed to be doing. There's still a bug in the HTTP implementation which needs some squashing, but I'm proud to announce that we're now in (almost) feature parity with the 0.9.3 implementation, *without the header-only dogma*. There's still quite a lot to do, but this is a milestone commit for the refactoring effort. --- .../network/protocol/http/client/connection/async_normal.ipp | 1 + libs/network/test/http/client_get_test.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/boost/network/protocol/http/client/connection/async_normal.ipp b/boost/network/protocol/http/client/connection/async_normal.ipp index 97f06749e..d3dd6364f 100644 --- a/boost/network/protocol/http/client/connection/async_normal.ipp +++ b/boost/network/protocol/http/client/connection/async_normal.ipp @@ -99,6 +99,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisheaders_promise); accessor.set_body_promise(r, this->body_promise); accessor.set_version_promise(r, this->version_promise); + accessor.set_status_promise(r, this->status_promise); accessor.set_status_message_promise(r, this->status_message_promise); BOOST_NETWORK_MESSAGE("futures and promises lined up."); } diff --git a/libs/network/test/http/client_get_test.cpp b/libs/network/test/http/client_get_test.cpp index 1aea187e9..be096cfe9 100644 --- a/libs/network/test/http/client_get_test.cpp +++ b/libs/network/test/http/client_get_test.cpp @@ -25,8 +25,8 @@ BOOST_AUTO_TEST_CASE(http_client_get_test) { response.get_status(status_); response.get_status_message(status_message_); BOOST_CHECK_EQUAL ( version_.substr(0,7), "HTTP/1."); - BOOST_CHECK_EQUAL ( status_, 200u ); - BOOST_CHECK_EQUAL ( status_message_, std::string("OK") ); + BOOST_CHECK_EQUAL ( status_, 302u ); + BOOST_CHECK_EQUAL ( status_message_, std::string("Found") ); } #ifdef BOOST_NETWORK_ENABLE_HTTPS From f1f322ecc9f9fda8d1f413d71f9b21fcf97865d4 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sat, 17 Mar 2012 18:52:27 +1100 Subject: [PATCH 068/196] Updating example dependencies. --- libs/network/example/CMakeLists.txt | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/libs/network/example/CMakeLists.txt b/libs/network/example/CMakeLists.txt index d8208ab28..7dd0aa5d2 100644 --- a/libs/network/example/CMakeLists.txt +++ b/libs/network/example/CMakeLists.txt @@ -35,12 +35,26 @@ target_link_libraries(http_client ${BOOST_CLIENT_LIBS} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri + cppnetlib-message + cppnetlib-message-directives + cppnetlib-message-wrappers + cppnetlib-http-message-wrappers + cppnetlib-http-message + cppnetlib-constants + cppnetlib-http-client cppnetlib-http-client-connections) target_link_libraries(simple_wget ${BOOST_CLIENT_LIBS} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri + cppnetlib-message + cppnetlib-message-directives + cppnetlib-message-wrappers + cppnetlib-http-message-wrappers + cppnetlib-http-message + cppnetlib-constants + cppnetlib-http-client cppnetlib-http-client-connections) target_link_libraries(atom_reader @@ -51,6 +65,7 @@ target_link_libraries(atom_reader cppnetlib-message-directives cppnetlib-message-wrappers cppnetlib-http-message + cppnetlib-http-message-wrappers cppnetlib-constants cppnetlib-http-client cppnetlib-http-client-connections) @@ -59,12 +74,25 @@ target_link_libraries(rss_reader ${BOOST_CLIENT_LIBS} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri + cppnetlib-message + cppnetlib-message-directives + cppnetlib-message-wrappers + cppnetlib-http-message + cppnetlib-constants + cppnetlib-http-client cppnetlib-http-client-connections) target_link_libraries(twitter_search ${BOOST_CLIENT_LIBS} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri + cppnetlib-message + cppnetlib-message-directives + cppnetlib-message-wrappers + cppnetlib-http-message-wrappers + cppnetlib-http-message + cppnetlib-constants + cppnetlib-http-client cppnetlib-http-client-connections) target_link_libraries(hello_world_server @@ -75,6 +103,13 @@ target_link_libraries(hello_world_client ${BOOST_CLIENT_LIBS} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri + cppnetlib-message + cppnetlib-message-directives + cppnetlib-message-wrappers + cppnetlib-http-message-wrappers + cppnetlib-http-message + cppnetlib-constants + cppnetlib-http-client cppnetlib-http-client-connections) if (OPENSSL_FOUND) From 1cfd77a06a10ebd2b75b87ca9c6764e111f64d8e Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sat, 17 Mar 2012 19:02:50 +1100 Subject: [PATCH 069/196] Moving some includes around for quicker compile-times. --- boost/network/protocol/http/client/base.hpp | 13 ++++++++++--- .../protocol/http/client/client_connection.hpp | 4 ---- .../http/client/connection/normal_delegate.hpp | 9 ++++++++- .../http/client/connection/resolver_delegate.hpp | 2 +- .../http/client/connection/ssl_delegate.hpp | 10 ++++++++-- .../http/client/connection/ssl_delegate.ipp | 1 + 6 files changed, 28 insertions(+), 11 deletions(-) diff --git a/boost/network/protocol/http/client/base.hpp b/boost/network/protocol/http/client/base.hpp index 04a5916ea..c67d0fb83 100644 --- a/boost/network/protocol/http/client/base.hpp +++ b/boost/network/protocol/http/client/base.hpp @@ -9,13 +9,20 @@ #include #include -#include -#include -#include + +namespace boost { namespace asio { + +class io_service; + +} // namespace asio + +} // namespace boost namespace boost { namespace network { namespace http { struct client_base_pimpl; +struct request; +struct response; class request_options; diff --git a/boost/network/protocol/http/client/client_connection.hpp b/boost/network/protocol/http/client/client_connection.hpp index 89bd0b4e8..5f76644e4 100644 --- a/boost/network/protocol/http/client/client_connection.hpp +++ b/boost/network/protocol/http/client/client_connection.hpp @@ -38,8 +38,4 @@ struct client_connection { } /* boost */ -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif - #endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CLIENT_CONNECTION_HPP_20111103 */ diff --git a/boost/network/protocol/http/client/connection/normal_delegate.hpp b/boost/network/protocol/http/client/connection/normal_delegate.hpp index 15c44c595..b421274ee 100644 --- a/boost/network/protocol/http/client/connection/normal_delegate.hpp +++ b/boost/network/protocol/http/client/connection/normal_delegate.hpp @@ -9,7 +9,14 @@ #include #include -#include + +namespace boost { namespace asio { + +class io_service; + +} // namespace asio + +} // namespace boost namespace boost { namespace network { namespace http { diff --git a/boost/network/protocol/http/client/connection/resolver_delegate.hpp b/boost/network/protocol/http/client/connection/resolver_delegate.hpp index 1804cd7c5..c805a2fc1 100644 --- a/boost/network/protocol/http/client/connection/resolver_delegate.hpp +++ b/boost/network/protocol/http/client/connection/resolver_delegate.hpp @@ -8,8 +8,8 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include #include +#include namespace boost { namespace network { namespace http { diff --git a/boost/network/protocol/http/client/connection/ssl_delegate.hpp b/boost/network/protocol/http/client/connection/ssl_delegate.hpp index 47e1c960c..4c5b5dc0a 100644 --- a/boost/network/protocol/http/client/connection/ssl_delegate.hpp +++ b/boost/network/protocol/http/client/connection/ssl_delegate.hpp @@ -7,13 +7,19 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include #include #include #include -#include #include +namespace boost { namespace asio { + +class io_service; + +} // namespace asio + +} // namespace boost + namespace boost { namespace network { namespace http { struct ssl_delegate : connection_delegate, enable_shared_from_this { diff --git a/boost/network/protocol/http/client/connection/ssl_delegate.ipp b/boost/network/protocol/http/client/connection/ssl_delegate.ipp index 302fa180a..e4ec9c044 100755 --- a/boost/network/protocol/http/client/connection/ssl_delegate.ipp +++ b/boost/network/protocol/http/client/connection/ssl_delegate.ipp @@ -9,6 +9,7 @@ #include #include +#include #include #include From 7ff00ac8b728b41ebb4fb6bc4bc071e8979faa8e Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sat, 17 Mar 2012 19:04:03 +1100 Subject: [PATCH 070/196] Removing unnecessary file. --- .../http/client/connection/async_base.hpp | 80 ------------------- 1 file changed, 80 deletions(-) delete mode 100644 boost/network/protocol/http/client/connection/async_base.hpp diff --git a/boost/network/protocol/http/client/connection/async_base.hpp b/boost/network/protocol/http/client/connection/async_base.hpp deleted file mode 100644 index 2ada508c9..000000000 --- a/boost/network/protocol/http/client/connection/async_base.hpp +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_IMPL_ASYNC_CONNECTION_BASE_20100529 -#define BOOST_NETWORK_PROTOCOL_HTTP_IMPL_ASYNC_CONNECTION_BASE_20100529 - -// Copyright 2010 (C) Dean Michael Berris -// Copyright 2010 (C) Sinefunc, Inc. -// 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) - -#include -#include -#include - -namespace boost { namespace network { namespace http { namespace impl { - - template - struct async_connection_base { - typedef async_connection_base this_type; - typedef typename resolver_policy::type resolver_base; - typedef typename resolver_base::resolver_type resolver_type; - typedef typename resolver_base::resolve_function resolve_function; - typedef typename string::type string_type; - typedef basic_request request; - typedef basic_response response; - typedef iterator_range char_const_range; - typedef function - body_callback_function_type; - typedef shared_ptr connection_ptr; - - // This is the factory function which constructs the appropriate async - // connection implementation with the correct delegate chosen based on the - // tag. - static connection_ptr new_connection( - resolve_function resolve, - resolver_type & resolver, - bool follow_redirect, - bool https, - optional certificate_filename=optional(), - optional const & verify_path=optional()) { - typedef http_async_connection - async_connection; - typedef typename delegate_factory::type delegate_factory_type; - connection_ptr temp; - typedef typename resolver_delegate_factory::type - resolver_delegate_factory_type; - temp.reset( - new async_connection( - resolver_delegate_factory_type::new_resolver_delegate( - resolve, - resolver), - follow_redirect, - delegate_factory_type::new_connection_delegate( - resolver.get_io_service(), - https, - certificate_filename, - verify_path))); - BOOST_ASSERT(temp.get() != 0); - return temp; - } - - // This is the pure virtual entry-point for all asynchronous connections. - virtual response start( - request const & request, - string_type const & method, - bool get_body, - body_callback_function_type callback) = 0; - - virtual ~async_connection_base() {} - - }; - -} // namespace impl - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_IMPL_ASYNC_CONNECTION_BASE_20100529 From b26c4409dae0b39c10d4cb503e1a38e129a0a001 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sat, 17 Mar 2012 23:21:21 +1100 Subject: [PATCH 071/196] Squashed Asio SSL FUBAR Issue So, this affects the HTTPS implementation in 0.9.3 as well, where Asio is not exactly being smart about how it deals with SSL errors. We've had to do some acrobatics just to determine whether the error code returned by an operation performed on an SSL stream resulted in a short read. The change is simple, but tracking it down is so much of a PITA. We probably should file a bug in Asio to be able to better detect the situation with short reads on SSL streams, and somehow also file a bug for it. At worst the short read should just use an asio::error::eof so that it's not too hard to deal with this issue from the user side. Also, this commit has some header-fudging to reduce dependencies and incremental compile-times. A more extensive effort should be done to reduce dependencies across header-files library-wide. --- .../http/client/connection/async_normal.hpp | 19 +++++-- .../http/client/connection/async_normal.ipp | 53 +++++++++++++----- .../client/connection/connection_delegate.hpp | 1 + .../client/connection/normal_delegate.hpp | 1 + .../client/connection/normal_delegate.ipp | 1 + .../connection/simple_connection_factory.ipp | 1 + .../http/client/connection/ssl_delegate.hpp | 1 + .../http/client/connection/ssl_delegate.ipp | 55 +++++++++++++------ .../protocol/http/message/wrappers/port.ipp | 8 +++ .../protocol/http/response/response.ipp | 28 +++++----- libs/network/test/http/client_get_test.cpp | 5 +- 11 files changed, 121 insertions(+), 52 deletions(-) diff --git a/boost/network/protocol/http/client/connection/async_normal.hpp b/boost/network/protocol/http/client/connection/async_normal.hpp index dd7459c5f..98de6206d 100644 --- a/boost/network/protocol/http/client/connection/async_normal.hpp +++ b/boost/network/protocol/http/client/connection/async_normal.hpp @@ -9,15 +9,24 @@ #include #include -#include -#include -#include #include -#include -#include +#include + +namespace boost { namespace asio { + +class io_service; + +} // namespace asio + +} // namespace boost namespace boost { namespace network { namespace http { +struct request; +struct response; +struct resolver_delegate; +struct connection_delegate; + struct http_async_connection_pimpl; struct http_async_connection : client_connection diff --git a/boost/network/protocol/http/client/connection/async_normal.ipp b/boost/network/protocol/http/client/connection/async_normal.ipp index d3dd6364f..9b2ff73c5 100644 --- a/boost/network/protocol/http/client/connection/async_normal.ipp +++ b/boost/network/protocol/http/client/connection/async_normal.ipp @@ -10,10 +10,16 @@ #include #include #include +#include +#include +#include #include #include #include #include +#ifdef BOOST_NETWORK_ENABLE_HTTPS +#include +#endif namespace boost { namespace network { namespace http { @@ -59,8 +65,9 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thismethod); boost::uint16_t port_ = port(request); BOOST_NETWORK_MESSAGE("port: " << port_); + this->host_ = host(request); resolver_delegate_->resolve( - host(request), + this->host_, port_, request_strand_.wrap( boost::bind( @@ -131,17 +138,19 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisendpoint().address() << ":" << port); asio::ip::tcp::endpoint endpoint(iter->endpoint().address(), port); - connection_delegate_->connect(endpoint, - request_strand_.wrap( - boost::bind( - &this_type::handle_connected, - this_type::shared_from_this(), - port, - get_body, - callback, - std::make_pair(++iter, - resolver_iterator()), - placeholders::error))); + connection_delegate_->connect( + endpoint, + this->host_, + request_strand_.wrap( + boost::bind( + &this_type::handle_connected, + this_type::shared_from_this(), + port, + get_body, + callback, + std::make_pair(++iter, + resolver_iterator()), + placeholders::error))); } else { BOOST_NETWORK_MESSAGE("error encountered while resolving."); set_errors(ec ? ec : boost::asio::error::host_not_found); @@ -174,6 +183,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisendpoint().address() << ":" << port); asio::ip::tcp::endpoint endpoint(iter->endpoint().address(), port); connection_delegate_->connect(endpoint, + this->host_, request_strand_.wrap( boost::bind( &this_type::handle_connected, @@ -218,7 +228,20 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thissource_promise.set_exception(boost::copy_exception(error)); this->destination_promise.set_exception(boost::copy_exception(error)); switch (state) { @@ -773,6 +797,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this handler) = 0; virtual void write(asio::streambuf & command_streambuf, function handler) = 0; diff --git a/boost/network/protocol/http/client/connection/normal_delegate.hpp b/boost/network/protocol/http/client/connection/normal_delegate.hpp index b421274ee..24f697949 100644 --- a/boost/network/protocol/http/client/connection/normal_delegate.hpp +++ b/boost/network/protocol/http/client/connection/normal_delegate.hpp @@ -24,6 +24,7 @@ struct normal_delegate : connection_delegate { normal_delegate(asio::io_service & service); virtual void connect(asio::ip::tcp::endpoint & endpoint, + std::string const &host, function handler); virtual void write(asio::streambuf & command_streambuf, function handler); diff --git a/boost/network/protocol/http/client/connection/normal_delegate.ipp b/boost/network/protocol/http/client/connection/normal_delegate.ipp index 5732c93fa..2dda88fbd 100644 --- a/boost/network/protocol/http/client/connection/normal_delegate.ipp +++ b/boost/network/protocol/http/client/connection/normal_delegate.ipp @@ -21,6 +21,7 @@ boost::network::http::normal_delegate::normal_delegate(asio::io_service & servic void boost::network::http::normal_delegate::connect( asio::ip::tcp::endpoint & endpoint, + std::string const &host, function handler) { socket_.reset(new asio::ip::tcp::socket(service_)); socket_->async_connect(endpoint, handler); diff --git a/boost/network/protocol/http/client/connection/simple_connection_factory.ipp b/boost/network/protocol/http/client/connection/simple_connection_factory.ipp index 14573daa3..20881eb9b 100644 --- a/boost/network/protocol/http/client/connection/simple_connection_factory.ipp +++ b/boost/network/protocol/http/client/connection/simple_connection_factory.ipp @@ -16,6 +16,7 @@ #ifdef BOOST_NETWORK_DEBUG #include #endif +#include #include diff --git a/boost/network/protocol/http/client/connection/ssl_delegate.hpp b/boost/network/protocol/http/client/connection/ssl_delegate.hpp index 4c5b5dc0a..9e33b0bdb 100644 --- a/boost/network/protocol/http/client/connection/ssl_delegate.hpp +++ b/boost/network/protocol/http/client/connection/ssl_delegate.hpp @@ -27,6 +27,7 @@ struct ssl_delegate : connection_delegate, enable_shared_from_this client_options const &options); virtual void connect(asio::ip::tcp::endpoint & endpoint, + std::string const &host, function handler); virtual void write(asio::streambuf & command_streambuf, function handler); diff --git a/boost/network/protocol/http/client/connection/ssl_delegate.ipp b/boost/network/protocol/http/client/connection/ssl_delegate.ipp index e4ec9c044..b5970addb 100755 --- a/boost/network/protocol/http/client/connection/ssl_delegate.ipp +++ b/boost/network/protocol/http/client/connection/ssl_delegate.ipp @@ -16,30 +16,39 @@ boost::network::http::ssl_delegate::ssl_delegate(asio::io_service & service, client_options const &options) : service_(service), - options_(options) {} + options_(options) { + BOOST_NETWORK_MESSAGE("ssl_delegate::ssl_delegate(...)"); +} void boost::network::http::ssl_delegate::connect( asio::ip::tcp::endpoint & endpoint, + std::string const &host, function handler) { BOOST_NETWORK_MESSAGE("ssl_delegate::connect(...)"); context_.reset(new asio::ssl::context( - service_, - asio::ssl::context::sslv23_client)); + asio::ssl::context::sslv23)); std::list const & certificate_paths = options_.openssl_certificate_paths(); std::list const & verifier_paths = options_.openssl_verify_paths(); - bool verify_peer = !certificate_paths.empty() || !verifier_paths.empty(); - BOOST_NETWORK_MESSAGE("verify peer setting is: " << verify_peer); - if (verify_peer) context_->set_verify_mode(asio::ssl::context::verify_peer); - else context_->set_verify_mode(asio::ssl::context::verify_none); - for (std::list::const_iterator it = certificate_paths.begin(); - it != certificate_paths.end(); ++it) { - context_->load_verify_file(*it); - } - for (std::list::const_iterator it = verifier_paths.begin(); - it != verifier_paths.begin(); ++it) { - context_->add_verify_path(*it); + bool use_default_verification = certificate_paths.empty() && verifier_paths.empty(); + if (!use_default_verification) { + for (std::list::const_iterator it = certificate_paths.begin(); + it != certificate_paths.end(); ++it) { + context_->load_verify_file(*it); + } + for (std::list::const_iterator it = verifier_paths.begin(); + it != verifier_paths.begin(); ++it) { + context_->add_verify_path(*it); + } + BOOST_NETWORK_MESSAGE("verifying peer: " << host); + context_->set_verify_mode(asio::ssl::context::verify_peer); + context_->set_verify_callback(asio::ssl::rfc2818_verification(host)); + } else { + BOOST_NETWORK_MESSAGE("not verifying peer"); + context_->set_default_verify_paths(); + context_->set_verify_mode(asio::ssl::context::verify_peer); + context_->set_verify_callback(asio::ssl::rfc2818_verification(host)); } socket_.reset(new asio::ssl::stream(service_, *context_)); BOOST_NETWORK_MESSAGE("scheduling asynchronous connection..."); @@ -51,12 +60,24 @@ void boost::network::http::ssl_delegate::connect( handler)); } -void boost::network::http::ssl_delegate::handle_connected(system::error_code const & ec, - function handler) { + +void boost::network::http::ssl_delegate::handle_connected( + system::error_code const & ec, + function handler) { BOOST_NETWORK_MESSAGE("ssl_delegate::handle_connected(...)"); if (!ec) { BOOST_NETWORK_MESSAGE("connected to endpoint."); - socket_->async_handshake(asio::ssl::stream_base::client, handler); + // Here we check if there's an existing session for the connection. + SSL_SESSION *existing_session = SSL_get1_session(socket_->impl()->ssl); + if (existing_session == NULL) { + BOOST_NETWORK_MESSAGE("found no existing session, performing handshake."); + socket_->async_handshake(asio::ssl::stream_base::client, handler); + } else { + BOOST_NETWORK_MESSAGE("found existing session, bypassing handshake."); + SSL_set_session(socket_->impl()->ssl, existing_session); + SSL_connect(socket_->impl()->ssl); + handler(ec); + } } else { BOOST_NETWORK_MESSAGE("encountered error: " << ec); handler(ec); diff --git a/boost/network/protocol/http/message/wrappers/port.ipp b/boost/network/protocol/http/message/wrappers/port.ipp index 6a4472fa5..683bc2340 100644 --- a/boost/network/protocol/http/message/wrappers/port.ipp +++ b/boost/network/protocol/http/message/wrappers/port.ipp @@ -19,6 +19,14 @@ port_wrapper::operator boost::uint16_t () const { uri::uri uri_; request_.get_uri(uri_); optional optional_port = port_us(uri_); + if (!optional_port) { + std::string scheme_ = scheme(uri_); + if (scheme_ == "http") { + return 80u; + } else if (scheme_ == "https") { + return 443u; + } + } return optional_port ? *optional_port : 80u; } diff --git a/boost/network/protocol/http/response/response.ipp b/boost/network/protocol/http/response/response.ipp index e93ed66ec..138b9207b 100644 --- a/boost/network/protocol/http/response/response.ipp +++ b/boost/network/protocol/http/response/response.ipp @@ -23,7 +23,7 @@ struct response_pimpl { promise destination_promise; destination_promise.set_value(destination); unique_future tmp_future = destination_promise.get_future(); - destination_future_ = move(tmp_future); + destination_future_ = boost::move(tmp_future); } void get_destination(std::string &destination) { @@ -38,7 +38,7 @@ struct response_pimpl { promise source_promise; source_promise.set_value(source); unique_future tmp_future = source_promise.get_future(); - source_future_ = move(tmp_future); + source_future_ = boost::move(tmp_future); } void get_source(std::string &source) { @@ -66,7 +66,7 @@ struct response_pimpl { headers_promise.get_future(); std::multimap().swap(added_headers_); std::set().swap(removed_headers_); - headers_future_ = move(tmp); + headers_future_ = boost::move(tmp); } } @@ -102,7 +102,7 @@ struct response_pimpl { promise body_promise; body_promise.set_value(body); unique_future tmp_future = body_promise.get_future(); - body_future_ = move(tmp_future); + body_future_ = boost::move(tmp_future); } void append_body(std::string const & data) { /* FIXME: Do something! */ } @@ -123,7 +123,7 @@ struct response_pimpl { promise status_promise; status_promise.set_value(status); unique_future tmp_future = status_promise.get_future(); - status_future_ = move(tmp_future); + status_future_ = boost::move(tmp_future); } void get_status(boost::uint16_t &status) { @@ -138,7 +138,7 @@ struct response_pimpl { promise status_message_promise_; status_message_promise_.set_value(status_message); unique_future tmp_future = status_message_promise_.get_future(); - status_message_future_ = move(tmp_future); + status_message_future_ = boost::move(tmp_future); } void get_status_message(std::string &status_message) { @@ -153,7 +153,7 @@ struct response_pimpl { promise version_promise; version_promise.set_value(version); unique_future tmp_future = version_promise.get_future(); - version_future_ = move(tmp_future); + version_future_ = boost::move(tmp_future); } void get_version(std::string &version) { @@ -166,37 +166,37 @@ struct response_pimpl { void set_source_promise(promise &promise_) { unique_future tmp_future = promise_.get_future(); - source_future_ = move(tmp_future); + source_future_ = boost::move(tmp_future); } void set_destination_promise(promise &promise_) { unique_future tmp_future = promise_.get_future(); - destination_future_ = move(tmp_future); + destination_future_ = boost::move(tmp_future); } void set_headers_promise(promise > &promise_) { unique_future > tmp_future = promise_.get_future(); - headers_future_ = move(tmp_future); + headers_future_ = boost::move(tmp_future); } void set_status_promise(promise &promise_) { unique_future tmp_future = promise_.get_future(); - status_future_ = move(tmp_future); + status_future_ = boost::move(tmp_future); } void set_status_message_promise(promise &promise_) { unique_future tmp_future = promise_.get_future(); - status_message_future_ = move(tmp_future); + status_message_future_ = boost::move(tmp_future); } void set_version_promise(promise &promise_) { unique_future tmp_future = promise_.get_future(); - version_future_ = move(tmp_future); + version_future_ = boost::move(tmp_future); } void set_body_promise(promise &promise_) { unique_future tmp_future = promise_.get_future(); - body_future_ = move(tmp_future); + body_future_ = boost::move(tmp_future); } bool equals(response_pimpl const &other) { diff --git a/libs/network/test/http/client_get_test.cpp b/libs/network/test/http/client_get_test.cpp index be096cfe9..30eea05bf 100644 --- a/libs/network/test/http/client_get_test.cpp +++ b/libs/network/test/http/client_get_test.cpp @@ -33,6 +33,7 @@ BOOST_AUTO_TEST_CASE(http_client_get_test) { BOOST_AUTO_TEST_CASE(https_client_get_test) { http::client::request request("https://www.google.com/"); + request << net::header("Connection", "close"); http::client client_; http::client::response response; BOOST_REQUIRE_NO_THROW ( response = client_.get(request) ); @@ -45,8 +46,8 @@ BOOST_AUTO_TEST_CASE(https_client_get_test) { response.get_status(status_); response.get_status_message(status_message_); BOOST_CHECK_EQUAL ( version_.substr(0,7), "HTTP/1."); - BOOST_CHECK_EQUAL ( status_, 200u ); - BOOST_CHECK_EQUAL ( status_message_, std::string("OK") ); + BOOST_CHECK_EQUAL ( status_, 302u ); + BOOST_CHECK_EQUAL ( status_message_, std::string("Found") ); } #endif From 7d35dc6471a463fd695556e2e7c59d8d3ddef9e0 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sun, 18 Mar 2012 18:47:50 +1100 Subject: [PATCH 072/196] Uncomment the test builds. This introduces all the failures we want to fix in this branch. --- libs/network/test/http/CMakeLists.txt | 32 +++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/libs/network/test/http/CMakeLists.txt b/libs/network/test/http/CMakeLists.txt index dedbe384e..4e92039a7 100644 --- a/libs/network/test/http/CMakeLists.txt +++ b/libs/network/test/http/CMakeLists.txt @@ -74,21 +74,21 @@ if (Boost_FOUND) ${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-http-${test}) endforeach (test) -# set ( SERVER_API_TESTS -# server_constructor_test -# server_async_run_stop_concurrency -# ) -# foreach ( test ${SERVER_API_TESTS} ) -# if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) -# set_source_files_properties(${test}.cpp -# PROPERTIES COMPILE_FLAGS "-Wall") -# endif() -# add_executable(cpp-netlib-http-${test} ${test}.cpp) -# target_link_libraries(cpp-netlib-http-${test} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-server-parsers) -# set_target_properties(cpp-netlib-http-${test} -# PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests) -# add_test(cpp-netlib-http-${test} -# ${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-http-${test}) -# endforeach (test) + set ( SERVER_API_TESTS + server_constructor_test + server_async_run_stop_concurrency + ) + foreach ( test ${SERVER_API_TESTS} ) + if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) + set_source_files_properties(${test}.cpp + PROPERTIES COMPILE_FLAGS "-Wall") + endif() + add_executable(cpp-netlib-http-${test} ${test}.cpp) + target_link_libraries(cpp-netlib-http-${test} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-server-parsers) + set_target_properties(cpp-netlib-http-${test} + PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests) + add_test(cpp-netlib-http-${test} + ${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-http-${test}) + endforeach (test) endif() From 8f26ea89242b28e920873a6daa871b3364f00fca Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sun, 18 Mar 2012 20:21:20 +1100 Subject: [PATCH 073/196] Get one test to build. This set of changes gets one of the server tests (async_run_stop_concurrency) to build correctly. --- boost/network/include/http/server.hpp | 3 + boost/network/protocol/http/server.hpp | 142 ++++++++---------- .../protocol/http/server/async_impl.hpp | 55 +++++++ .../network/protocol/http/server/options.hpp | 83 ++++++++++ boost/network/protocol/http/server/server.ipp | 72 +++++++++ .../protocol/http/server/sync_impl.hpp | 46 ++++++ libs/network/test/http/server_async.cpp | 6 +- .../server_async_run_stop_concurrency.cpp | 10 +- libs/network/test/http/server_hello_world.cpp | 8 +- 9 files changed, 337 insertions(+), 88 deletions(-) create mode 100644 boost/network/protocol/http/server/async_impl.hpp create mode 100644 boost/network/protocol/http/server/options.hpp create mode 100644 boost/network/protocol/http/server/server.ipp create mode 100644 boost/network/protocol/http/server/sync_impl.hpp diff --git a/boost/network/include/http/server.hpp b/boost/network/include/http/server.hpp index 021eefe0b..0771ea026 100644 --- a/boost/network/include/http/server.hpp +++ b/boost/network/include/http/server.hpp @@ -8,6 +8,9 @@ // // This is the modular include file for using the HTTP Client +#include #include +#include +#include #endif diff --git a/boost/network/protocol/http/server.hpp b/boost/network/protocol/http/server.hpp index a15613573..98445db3a 100644 --- a/boost/network/protocol/http/server.hpp +++ b/boost/network/protocol/http/server.hpp @@ -1,7 +1,8 @@ -// Copyright 2009 (c) Tarro, Inc. -// Copyright 2009 (c) Dean Michael Berris -// Copyright 2010 (c) Glyn Matthews -// Copyright 2003-2008 (c) Chris Kholhoff +// Copyright 2009 Tarroo, Inc. +// Copyright 2010 Glyn Matthews +// Copyright 2003-2008 Chris Kholhoff +// Copyright 2009-2012 Dean Michael Berris +// Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -9,84 +10,61 @@ #ifndef BOOST_NETWORK_HTTP_SERVER_HPP_ #define BOOST_NETWORK_HTTP_SERVER_HPP_ -#include -#include -#include -#include -#include +#include + +namespace boost { namespace network { namespace utils { + +struct thread_pool; + +} // namespace utils + +} // namespace network + +} // namespace boost namespace boost { namespace network { namespace http { - - template - struct server_base { - typedef unsupported_tag type; - }; - - template - struct server_base >::type> { - typedef async_server_base type; - }; - - template - struct server_base >::type> { - typedef sync_server_base type; - }; - - template - struct basic_server : server_base::type - {}; - - template - struct server : server_base::type { - typedef typename server_base::type - server_base; - - BOOST_PARAMETER_CONSTRUCTOR( - server, (server_base), tag, - (required - (address, (typename server_base::string_type const &)) - (port, (typename server_base::string_type const &)) - (in_out(handler), (Handler &))) - (optional - (in_out(io_service), (boost::asio::io_service &)) - (reuse_address, (bool)) - (report_aborted, (bool)) - (receive_buffer_size, (int)) - (send_buffer_size, (int)) - (receive_low_watermark, (int)) - (send_low_watermark, (int)) - (non_blocking_io, (int)) - (linger, (bool)) - (linger_timeout, (int))) - ) - }; - - template - struct async_server : server_base::type - { - typedef typename server_base::type - server_base; - - BOOST_PARAMETER_CONSTRUCTOR( - async_server, (server_base), tag, - (required - (address, (typename server_base::string_type const &)) - (port, (typename server_base::string_type const &)) - (in_out(handler), (Handler&)) - (in_out(thread_pool), (utils::thread_pool&))) - (optional - (in_out(io_service), (boost::asio::io_service&)) - (reuse_address, (bool)) - (report_aborted, (bool)) - (receive_buffer_size, (int)) - (send_buffer_size, (int)) - (receive_low_watermark, (int)) - (send_low_watermark, (int)) - (non_blocking_io, (bool)) - (linger, (bool)) - (linger_timeout, (int))) - ) - }; + +class server_options; +class sync_server_impl; +class async_server_impl; +class async_server_connection; +struct request; +struct response; + + +template +class sync_server { + public: + sync_server(server_options const &options, SyncHandler &handler); + void run(); + void stop(); + void listen(); + ~sync_server(); + + typedef http::request request; + typedef http::response response; + private: + sync_server_impl *pimpl_; + sync_server(sync_server const &other); // = delete + sync_server& operator=(sync_server other); // = delete +}; + +template +class async_server { + public: + explicit async_server(server_options const &options, AsyncHandler &handler, utils::thread_pool &pool); + void run(); + void stop(); + void listen(); + ~async_server(); + + typedef http::request request; + typedef shared_ptr connection_ptr; + private: + async_server_impl *pimpl_; + async_server(async_server const &other); // = delete + async_server& operator=(async_server other); // = delete +}; } // namespace http @@ -94,5 +72,9 @@ namespace boost { namespace network { namespace http { } // namespace boost +// We're hiding the implementation from here, but still explicitly including +// it here. This is mostly a style point, to keep this header clean. +#include + #endif // BOOST_NETWORK_HTTP_SERVER_HPP_ diff --git a/boost/network/protocol/http/server/async_impl.hpp b/boost/network/protocol/http/server/async_impl.hpp new file mode 100644 index 000000000..37c4c9042 --- /dev/null +++ b/boost/network/protocol/http/server/async_impl.hpp @@ -0,0 +1,55 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_IMPL_20120318 +#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_IMPL_20120318 + +// Copyright 2012 Dean Michael Berris . +// Copyright 2012 Google, Inc. +// 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) + +#include +#include + +namespace boost { namespace network { namespace utils { + +struct thread_pool; + +} // namespace util + +} // namespace network + +} // namespace boost + +namespace boost { namespace network { namespace http { + +class async_server_connection; + +class async_server_impl { + public: + typedef shared_ptr connection_ptr; + async_server_impl(server_options const &options, + function handler, + utils::thread_pool &thread_pool); + void run(); + void stop(); + void listen(); + + private: + server_options options_; + std::string address_, port_; + asio::io_service *service_; + asio::ip::tcp::acceptor *acceptor_; + shared_ptr new_connection_; + mutex listening_mutex_; + bool listening_, owned_service_; + function handler_; + utils::thread_pool &pool_; +}; + +} // namespace http + +} // namespace network + +} // namespace boost + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_IMPL_20120318 diff --git a/boost/network/protocol/http/server/options.hpp b/boost/network/protocol/http/server/options.hpp new file mode 100644 index 000000000..bd2507106 --- /dev/null +++ b/boost/network/protocol/http/server/options.hpp @@ -0,0 +1,83 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_HPP_20120318 +#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_HPP_20120318 + +// Copyright 2012 Dean Michael Berris . +// Copyright 2012 Google, Inc. +// 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) + +#include + +namespace boost { namespace asio { + +class io_service; + +} // namespace asio + +} // namespace boost + +namespace boost { namespace network { namespace http { + +class server_options_pimpl; + +class server_options { + public: + server_options(); + server_options(server_options const &other); + void swap(server_options &other); + server_options& operator=(server_options rhs); + + server_options& address(std::string const &address="0.0.0.0"); + std::string const address() const; + + server_options& port(std::string const &port="80"); + std::string const port() const; + + server_options& io_service(asio::io_service *service = 0); + asio::io_service *io_service() const; + + server_options& reuse_address(bool setting=true); + bool reuse_address(); + + server_options& report_aborted(bool setting=false); + bool report_aborted(); + + // Set the receive buffer size for a socket. -1 means just use the default. + server_options& receive_buffer_size(int buffer_size=-1); + int receive_buffer_size(); + + // Set the send buffer size for a socket. -1 means just use the default. + server_options& send_buffer_size(int buffer_size=-1); + int send_buffer_size(); + + // Set the receive low watermark for a socket. -1 means just use the default. + server_options& receive_low_watermark(int low_watermark=-1); + int receive_low_watermark(); + + // Set the send low watermark for a socket. -1 means just use the default. + server_options& send_low_watermark(int low_watermark=-1); + int send_low_watermark(); + + server_options& non_blocking_io(bool setting=true); + bool non_blocking_io(); + + server_options& linger(bool setting=false); + bool linger(); + + // Set the socket linger timeout. This is only relevant if linger is true + // (see linger above). -1 means just use the default. + server_options& linger_timeout(int setting=-1); + int linger_timeout(); + + private: + server_options_pimpl *pimpl_; +}; + +} // namespace http + +} // namespace network + +} // namespace boost + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_HPP_20120318 diff --git a/boost/network/protocol/http/server/server.ipp b/boost/network/protocol/http/server/server.ipp new file mode 100644 index 000000000..6fa6c390b --- /dev/null +++ b/boost/network/protocol/http/server/server.ipp @@ -0,0 +1,72 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_SERVER_IPP_20120318 +#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_SERVER_IPP_20120318 + +// Copyright 2012 Dean Michael Berris . +// Copyright 2012 Google, Inc. +// 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) + +#include +#include +#include + +namespace boost { namespace network { namespace http { + +template +sync_server::sync_server(server_options const &options, SyncHandler &handler) +: pimpl_(new sync_server_impl(options, handler)) +{} + +template +void sync_server::run() { + pimpl_->run(); +} + +template +void sync_server::stop() { + pimpl_->stop(); +} + +template +void sync_server::listen() { + pimpl_->listen(); +} + +template +sync_server::~sync_server() { + delete pimpl_; +} + +template +async_server::async_server(server_options const &options, AsyncHandler &handler, utils::thread_pool &pool) +: pimpl_(new async_server_impl(options, handler, pool)) +{} + +template +void async_server::run() { + pimpl_->run(); +} + +template +void async_server::stop() { + pimpl_->stop(); +} + +template +void async_server::listen() { + pimpl_->listen(); +} + +template +async_server::~async_server() { + delete pimpl_; +} + +} // namespace http + +} // namespace network + +} // namespace boost + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_SERVER_SERVER_IPP_20120318 diff --git a/boost/network/protocol/http/server/sync_impl.hpp b/boost/network/protocol/http/server/sync_impl.hpp new file mode 100644 index 000000000..d36ff4e7d --- /dev/null +++ b/boost/network/protocol/http/server/sync_impl.hpp @@ -0,0 +1,46 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_IMPL_HPP_20120318 +#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_IMPL_HPP_20120318 + +// Copyright 2012 Dean Michael Berris . +// Copyright 2012 Google, Inc. +// 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) + +#include +#include +#include +#include + +namespace boost { namespace network { namespace http { + +class sync_server_connection; +struct request; +struct response; + +class sync_server_impl { + public: + sync_server_impl(server_options const &options, + function handler); + void run(); + void stop(); + void listen(); + + private: + server_options options_; + std::string address_, port_; + asio::io_service *service_; + asio::ip::tcp::acceptor *acceptor_; + shared_ptr new_connection_; + mutex listening_mutex_; + bool listening_, owned_service_; + function handler_; +}; + +} // namespace http + +} // namespace network + +} // namespace boost + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_SERVER_IMPL_HPP_20120318 diff --git a/libs/network/test/http/server_async.cpp b/libs/network/test/http/server_async.cpp index 95f8646dd..c808cab0b 100644 --- a/libs/network/test/http/server_async.cpp +++ b/libs/network/test/http/server_async.cpp @@ -46,7 +46,11 @@ int main(int argc, char * argv[]) { async_hello_world handler; std::string port = "8000"; if (argc > 1) port = argv[1]; - server instance("localhost", port, handler, thread_pool, http::_reuse_address=true); + http::server_options options; + options.port(port) + .address("localhost") + .reuse_address(true); + server instance(options, thread_pool, handler); instance.run(); return 0; } diff --git a/libs/network/test/http/server_async_run_stop_concurrency.cpp b/libs/network/test/http/server_async_run_stop_concurrency.cpp index e9a4e25ac..af9745c4d 100644 --- a/libs/network/test/http/server_async_run_stop_concurrency.cpp +++ b/libs/network/test/http/server_async_run_stop_concurrency.cpp @@ -21,13 +21,13 @@ struct dummy_async_handler { int main(int argc, char * argv[]) { dummy_async_handler async_handler; + http::server_options options; + options.address("127.0.0.1") + .port("8007") + .reuse_address(true); #define ASYNC_SERVER_TEST_CONFIG \ - http::_address = "127.0.0.1", \ - http::_port = "8007", \ - http::_handler = async_handler, \ - http::_thread_pool = pool, \ - http::_reuse_address = true + options, async_handler, pool #define ASYNC_SERVER_SLEEP_TIME \ boost::posix_time::milliseconds(100) diff --git a/libs/network/test/http/server_hello_world.cpp b/libs/network/test/http/server_hello_world.cpp index 86857a9f2..8174f91ed 100644 --- a/libs/network/test/http/server_hello_world.cpp +++ b/libs/network/test/http/server_hello_world.cpp @@ -21,7 +21,7 @@ using std::cerr; using std::endl; struct hello_world; -typedef http::server server; +typedef http::sync_server server; struct hello_world { @@ -45,7 +45,11 @@ int main(int argc, char * argv[]) { hello_world handler; std::string port = "8000"; if (argc > 1) port = argv[1]; - server server_("127.0.0.1", port, handler, http::_reuse_address=true); + http::server_options options; + options.address("127.0.0.1") + .port(port) + .reuse_address(true); + server server_(options, handler); server_.run(); return EXIT_SUCCESS; } From 1b765f0ca54a7230c6f507daf8d405dd178fe2cf Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sun, 18 Mar 2012 21:52:45 +1100 Subject: [PATCH 074/196] WIP: Asynchronous Server Implementation This is an incremental installment into the asynchronous server implementation revamp. The goal here is to isolate the parts that are actually necessary to build client code and move more of the implementation into externally-linked libraries. This allows us to tweak, add features, and generally make the API/ABI more stable for future extension and updates. --- boost/network/include/http/server.hpp | 3 +- .../protocol/http/server/async_impl.hpp | 17 +- .../protocol/http/server/async_impl.ipp | 189 ++++++++++++++++++ .../network/protocol/http/server/options.hpp | 40 ++-- libs/network/src/CMakeLists.txt | 14 +- libs/network/src/http/server_async_impl.cpp | 7 + libs/network/test/http/CMakeLists.txt | 6 +- 7 files changed, 250 insertions(+), 26 deletions(-) create mode 100644 boost/network/protocol/http/server/async_impl.ipp create mode 100644 libs/network/src/http/server_async_impl.cpp diff --git a/boost/network/include/http/server.hpp b/boost/network/include/http/server.hpp index 0771ea026..10b66e2b5 100644 --- a/boost/network/include/http/server.hpp +++ b/boost/network/include/http/server.hpp @@ -1,7 +1,8 @@ #ifndef BOOST_NETWORK_INCLUDE_HTTP_SERVER_HPP_ #define BOOST_NETWORK_INCLUDE_HTTP_SERVER_HPP_ -// Copyright 2010 Dean Michael Berris +// Copyright 2010-2012 Dean Michael Berris . +// Copyright 2012 Google, Inc. // 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) diff --git a/boost/network/protocol/http/server/async_impl.hpp b/boost/network/protocol/http/server/async_impl.hpp index 37c4c9042..619526664 100644 --- a/boost/network/protocol/http/server/async_impl.hpp +++ b/boost/network/protocol/http/server/async_impl.hpp @@ -9,6 +9,9 @@ #include #include +#include +#include +#include namespace boost { namespace network { namespace utils { @@ -22,6 +25,8 @@ struct thread_pool; namespace boost { namespace network { namespace http { +struct request; + class async_server_connection; class async_server_impl { @@ -30,6 +35,7 @@ class async_server_impl { async_server_impl(server_options const &options, function handler, utils::thread_pool &thread_pool); + ~async_server_impl(); void run(); void stop(); void listen(); @@ -40,10 +46,17 @@ class async_server_impl { asio::io_service *service_; asio::ip::tcp::acceptor *acceptor_; shared_ptr new_connection_; - mutex listening_mutex_; - bool listening_, owned_service_; + mutex listening_mutex_, stopping_mutex_; function handler_; utils::thread_pool &pool_; + bool listening_, owned_service_, stopping_; + + void handle_stop(); + void start_listening(); + void handle_accept(system::error_code const &ec); + + void set_socket_options(asio::ip::tcp::socket &socket); + void set_acceptor_options(asio::ip::tcp::acceptor &acceptor); }; } // namespace http diff --git a/boost/network/protocol/http/server/async_impl.ipp b/boost/network/protocol/http/server/async_impl.ipp new file mode 100644 index 000000000..cba5e97cb --- /dev/null +++ b/boost/network/protocol/http/server/async_impl.ipp @@ -0,0 +1,189 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_IMPL_IPP_20120318 +#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_IMPL_IPP_20120318 + +// Copyright 2012 Dean Michael Berris . +// Copyright 2012 Google, Inc. +// 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) + +#include +#include +#include +#include +#include +#include + +namespace boost { namespace network { namespace http { + +async_server_impl::async_server_impl(server_options const &options, + function handler, + utils::thread_pool &thread_pool) +: options_(options) +, address_(options.address()) +, port_(options.port()) +, service_(options.io_service()) +, acceptor_(0) +, new_connection_() +, listening_mutex_() +, stopping_mutex_() +, handler_(handler) +, pool_(thread_pool) +, listening_(false) +, owned_service_(false) +, stopping_(false) { + if (service_ == 0) { + service_ = new (std::nothrow) asio::io_service; + owned_service_ = true; + } + BOOST_ASSERT(service_ != 0); + acceptor_ = new (std::nothrow) asio::ip::tcp::acceptor(*service_); + BOOST_ASSERT(acceptor_ != 0); +} + +async_server_impl::~async_server_impl() { + if (owned_service_) delete service_; + delete acceptor_; +} + +void async_server_impl::run() { + listen(); + service_->run(); +} + +void async_server_impl::stop() { + lock_guard listening_lock(listening_mutex_); + if (listening_) { + lock_guard stopping_lock(stopping_mutex_); + stopping_ = true; + system::error_code ignored; + acceptor_->close(ignored); + listening_ = false; + service_->post( + boost::bind(&async_server_impl::handle_stop, this)); + } +} + +void async_server_impl::listen() { + lock_guard listening_lock(listening_mutex_); + BOOST_NETWORK_MESSAGE("listening on " << address_ << ':' << port_); + if (!listening_) start_listening(); + if (!listening_) { + BOOST_NETWORK_MESSAGE("error listening on " << address_ << ':' << port_); + BOOST_THROW_EXCEPTION(std::runtime_error("Error listening on provided address:port.")); + } +} + +void async_server_impl::handle_stop() { + lock_guard stopping_lock(stopping_mutex_); + // A user may have stopped listening again before the stop command is + // reached. + if (stopping_) service_->stop(); +} + +void async_server_impl::handle_accept(boost::system::error_code const & ec) { + { + lock_guard stopping_lock(stopping_mutex_); + // We dont want to add another handler instance, and we dont want to know + // about errors for a socket we dont need anymore. + if (stopping_) return; + } + if (!ec) { + set_socket_options(new_connection_->socket()); + new_connection_->start(); + new_connection_.reset( + new async_server_connection(*service_, handler_, pool_)); + acceptor_->async_accept( + new_connection_->socket(), + boost::bind( + &async_server_impl::handle_accept, + this, + asio::placeholders::error)); + } else { + BOOST_NETWORK_MESSAGE("Error accepting connection, reason: " << ec); + } +} + +void async_server_impl::start_listening() { + using asio::ip::tcp; + system::error_code error; + service_->reset(); // allows repeated cycles of run->stop->run + tcp::resolver resolver(*service_); + tcp::resolver::query query(address_, port_); + tcp::resolver::iterator endpoint_iterator = resolver.resolve(query, error); + if (error) { + BOOST_NETWORK_MESSAGE("error resolving '" << address_ << ':' << port_); + BOOST_THROW_EXCEPTION(std::runtime_error("Error resolving address:port combination.")); + } + tcp::endpoint endpoint = *endpoint_iterator; + acceptor_->open(endpoint.protocol(), error); + if (error) { + BOOST_NETWORK_MESSAGE("error opening socket: " << address_ << ":" << port_); + BOOST_THROW_EXCEPTION(std::runtime_error("Error opening socket.")); + } + set_acceptor_options(*acceptor_); + acceptor_->bind(endpoint, error); + if (error) { + BOOST_NETWORK_MESSAGE("error binding socket: " << address_ << ":" << port_); + BOOST_THROW_EXCEPTION(std::runtime_error("Error binding socket.")); + } + acceptor_->listen(asio::socket_base::max_connections, error); + if (error) { + BOOST_NETWORK_MESSAGE("error listening on socket: '" << error << "' on " << address_ << ":" << port_); + BOOST_THROW_EXCEPTION(std::runtime_error("Error listening on socket.")); + } + new_connection_.reset(new async_server_connection(*service_, handler_, pool_)); + acceptor_->async_accept( + new_connection_->socket(), + boost::bind( + &async_server_impl::handle_accept, + this, + asio::placeholders::error)); + listening_ = true; + lock_guard stopping_lock(stopping_mutex_); + stopping_ = false; // if we were in the process of stopping, we revoke that command and continue listening + BOOST_NETWORK_MESSAGE("now listening on '" << address_ << ":" << port_ << "'"); +} + +void async_server_impl::set_socket_options(asio::ip::tcp::socket &socket) { + system::error_code ignored; + socket.non_blocking(options_.non_blocking_io(), ignored); + if (options_.linger()) { + asio::ip::tcp::socket::linger linger(true, options_.linger_timeout()); + socket.set_option(linger, ignored); + } + if (int buf_size = options_.receive_buffer_size() >= 0) { + asio::ip::tcp::socket::receive_buffer_size receive_buffer_size(buf_size); + socket.set_option(receive_buffer_size, ignored); + } + if (int buf_size = options_.send_buffer_size() >= 0) { + asio::ip::tcp::socket::send_buffer_size send_buffer_size(buf_size); + socket.set_option(send_buffer_size, ignored); + } + if (int buf_size = options_.receive_low_watermark() >= 0) { + asio::ip::tcp::socket::receive_low_watermark receive_low_watermark(buf_size); + socket.set_option(receive_low_watermark, ignored); + } + if (int buf_size = options_.send_low_watermark() >= 0) { + asio::ip::tcp::socket::send_low_watermark send_low_watermark(buf_size); + socket.set_option(send_low_watermark, ignored); + } +} + +void async_server_impl::set_acceptor_options(asio::ip::tcp::acceptor &acceptor) { + system::error_code ignored; + acceptor.set_option( + asio::ip::tcp::acceptor::reuse_address(options_.reuse_address()), + ignored); + acceptor.set_option( + asio::ip::tcp::acceptor::enable_connection_aborted(options_.report_aborted()), + ignored); +} + +} // namespace http + +} // namespace network + +} // namespace boost + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_IMPL_IPP_20120318 diff --git a/boost/network/protocol/http/server/options.hpp b/boost/network/protocol/http/server/options.hpp index bd2507106..481d45666 100644 --- a/boost/network/protocol/http/server/options.hpp +++ b/boost/network/protocol/http/server/options.hpp @@ -28,46 +28,46 @@ class server_options { void swap(server_options &other); server_options& operator=(server_options rhs); - server_options& address(std::string const &address="0.0.0.0"); + server_options& address(std::string const &address); std::string const address() const; - server_options& port(std::string const &port="80"); + server_options& port(std::string const &port); std::string const port() const; - server_options& io_service(asio::io_service *service = 0); + server_options& io_service(asio::io_service *service); asio::io_service *io_service() const; - server_options& reuse_address(bool setting=true); - bool reuse_address(); + server_options& reuse_address(bool setting); + bool reuse_address() const; - server_options& report_aborted(bool setting=false); - bool report_aborted(); + server_options& report_aborted(bool setting); + bool report_aborted() const; // Set the receive buffer size for a socket. -1 means just use the default. - server_options& receive_buffer_size(int buffer_size=-1); - int receive_buffer_size(); + server_options& receive_buffer_size(int buffer_size); + int receive_buffer_size() const; // Set the send buffer size for a socket. -1 means just use the default. - server_options& send_buffer_size(int buffer_size=-1); - int send_buffer_size(); + server_options& send_buffer_size(int buffer_size); + int send_buffer_size() const; // Set the receive low watermark for a socket. -1 means just use the default. - server_options& receive_low_watermark(int low_watermark=-1); - int receive_low_watermark(); + server_options& receive_low_watermark(int low_watermark); + int receive_low_watermark() const; // Set the send low watermark for a socket. -1 means just use the default. - server_options& send_low_watermark(int low_watermark=-1); - int send_low_watermark(); + server_options& send_low_watermark(int low_watermark); + int send_low_watermark() const; - server_options& non_blocking_io(bool setting=true); - bool non_blocking_io(); + server_options& non_blocking_io(bool setting); + bool non_blocking_io() const; - server_options& linger(bool setting=false); - bool linger(); + server_options& linger(bool setting); + bool linger() const; // Set the socket linger timeout. This is only relevant if linger is true // (see linger above). -1 means just use the default. - server_options& linger_timeout(int setting=-1); + server_options& linger_timeout(int setting); int linger_timeout(); private: diff --git a/libs/network/src/CMakeLists.txt b/libs/network/src/CMakeLists.txt index d0d03d1a8..bc76308f1 100644 --- a/libs/network/src/CMakeLists.txt +++ b/libs/network/src/CMakeLists.txt @@ -17,8 +17,18 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) endif() endforeach(src_file) -set(CPP-NETLIB_HTTP_SERVER_SRCS server_request_parsers_impl.cpp) -add_library(cppnetlib-server-parsers ${CPP-NETLIB_HTTP_SERVER_SRCS}) +set(CPP-NETLIB_HTTP_SERVER_PARSERS_SRCS server_request_parsers_impl.cpp) +add_library(cppnetlib-http-server-parsers ${CPP-NETLIB_HTTP_SERVER_PARSERS_SRCS}) +foreach (src_file ${CPP-NETLIB_HTTP_SERVER_PARSERS_SRCS}) +if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) + set_source_files_properties(${src_file} + PROPERTIES COMPILE_FLAGS "-Wall -Werror") +endif() +endforeach(src_file) + +set(CPP-NETLIB_HTTP_SERVER_SRCS + http/server_async_impl.cpp) +add_library(cppnetlib-http-servers ${CPP-NETLIB_HTTP_SERVER_SRCS}) foreach (src_file ${CPP-NETLIB_HTTP_SERVER_SRCS}) if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) set_source_files_properties(${src_file} diff --git a/libs/network/src/http/server_async_impl.cpp b/libs/network/src/http/server_async_impl.cpp new file mode 100644 index 000000000..721f7bcf6 --- /dev/null +++ b/libs/network/src/http/server_async_impl.cpp @@ -0,0 +1,7 @@ +// Copyright 2012 Dean Michael Berris . +// Copyright 2012 Google, Inc. +// 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) + +#include diff --git a/libs/network/test/http/CMakeLists.txt b/libs/network/test/http/CMakeLists.txt index 4e92039a7..33b36a731 100644 --- a/libs/network/test/http/CMakeLists.txt +++ b/libs/network/test/http/CMakeLists.txt @@ -84,7 +84,11 @@ if (Boost_FOUND) PROPERTIES COMPILE_FLAGS "-Wall") endif() add_executable(cpp-netlib-http-${test} ${test}.cpp) - target_link_libraries(cpp-netlib-http-${test} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-server-parsers) + target_link_libraries(cpp-netlib-http-${test} + ${Boost_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} + cppnetlib-http-servers + cppnetlib-http-server-parsers) set_target_properties(cpp-netlib-http-${test} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests) add_test(cpp-netlib-http-${test} From 84a6a5a635e71f76dcf0486b272e2f782aa57004 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Mon, 19 Mar 2012 00:08:55 +1100 Subject: [PATCH 075/196] Asynchronous Server Builds! So I set out to do one server test building, and I'm happy to say that this commit does it. The other server tests just need to be jiggered a bit to use the new interface. This means we're a few steps closer to being able to merge to master! --- .../http/server/{async_connection.hpp => connection/async.hpp} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename boost/network/protocol/http/server/{async_connection.hpp => connection/async.hpp} (100%) diff --git a/boost/network/protocol/http/server/async_connection.hpp b/boost/network/protocol/http/server/connection/async.hpp similarity index 100% rename from boost/network/protocol/http/server/async_connection.hpp rename to boost/network/protocol/http/server/connection/async.hpp From a9a3c808e88e7ca935b8a5876f6f667a50300364 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Mon, 19 Mar 2012 00:11:23 +1100 Subject: [PATCH 076/196] Continuation of previous commit. Getting used to the Github app... --- .../network/protocol/http/request/request.hpp | 4 + .../network/protocol/http/request/request.ipp | 33 + .../protocol/http/server/async_impl.ipp | 1 + .../protocol/http/server/connection/async.hpp | 1185 +++++++++-------- .../protocol/http/server/impl/parsers.ipp | 3 +- .../network/protocol/http/server/options.hpp | 3 +- .../network/protocol/http/server/options.ipp | 292 ++++ .../protocol/http/server/request_parser.hpp | 1 - libs/network/src/CMakeLists.txt | 3 +- libs/network/src/http/server_options.cpp | 7 + libs/network/test/http/CMakeLists.txt | 7 +- 11 files changed, 949 insertions(+), 590 deletions(-) create mode 100644 boost/network/protocol/http/server/options.ipp create mode 100644 libs/network/src/http/server_options.cpp diff --git a/boost/network/protocol/http/request/request.hpp b/boost/network/protocol/http/request/request.hpp index a506d63ab..9169b5bc6 100644 --- a/boost/network/protocol/http/request/request.hpp +++ b/boost/network/protocol/http/request/request.hpp @@ -55,6 +55,8 @@ struct request : request_base { virtual void set_body_writer(function writer); virtual void set_uri(std::string const &uri); virtual void set_uri(network::uri::uri const &uri); + virtual void set_version_major(unsigned short major_version); + virtual void set_version_minor(unsigned short minor_version); // Getters virtual void get_uri(network::uri::uri &uri) const; @@ -64,6 +66,8 @@ struct request : request_base { virtual void get_status_message(std::string & status_message) const; virtual void get_body(function chunk_reader) const; virtual void get_body(std::string const & body) const; + virtual void get_version_major(unsigned short &major_version); + virtual void get_version_minor(unsigned short &minor_version); virtual ~request(); private: diff --git a/boost/network/protocol/http/request/request.ipp b/boost/network/protocol/http/request/request.ipp index 2fbc6fb9a..f7696cdca 100644 --- a/boost/network/protocol/http/request/request.ipp +++ b/boost/network/protocol/http/request/request.ipp @@ -117,6 +117,22 @@ struct request_pimpl { headers_ == other.headers_; } + void set_version_major(unsigned short major_version) { + version_major_ = major_version; + } + + void set_version_minor(unsigned short minor_version) { + version_minor_ = minor_version; + } + + void get_version_major(unsigned short &major_version) { + major_version = version_major_; + } + + void get_version_minor(unsigned short &minor_version) { + minor_version = version_minor_; + } + private: typedef std::multimap headers_type; @@ -124,6 +140,7 @@ struct request_pimpl { size_t read_offset_; std::string source_, destination_; headers_type headers_; + unsigned short version_major_, version_minor_; request_pimpl(request_pimpl const &other) : uri_(other.uri_) @@ -253,6 +270,14 @@ void request::set_uri(network::uri::uri const &uri) { pimpl_->set_uri(uri); } +void request::set_version_major(unsigned short major_version) { + pimpl_->set_version_major(major_version); +} + +void request::set_version_minor(unsigned short minor_version) { + pimpl_->set_version_minor(minor_version); +} + // Getters void request::get_uri(network::uri::uri &uri) const { pimpl_->get_uri(uri); @@ -262,6 +287,14 @@ void request::get_uri(std::string &uri) const { pimpl_->get_uri(uri); } +void request::get_version_major(unsigned short &major_version) { + pimpl_->get_version_major(major_version); +} + +void request::get_version_minor(unsigned short &minor_version) { + pimpl_->get_version_minor(minor_version); +} + void request::get_method(std::string & method) const { } diff --git a/boost/network/protocol/http/server/async_impl.ipp b/boost/network/protocol/http/server/async_impl.ipp index cba5e97cb..aa781c833 100644 --- a/boost/network/protocol/http/server/async_impl.ipp +++ b/boost/network/protocol/http/server/async_impl.ipp @@ -8,6 +8,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include +#include #include #include #include diff --git a/boost/network/protocol/http/server/connection/async.hpp b/boost/network/protocol/http/server/connection/async.hpp index 377ec5738..bc8c65fa0 100644 --- a/boost/network/protocol/http/server/connection/async.hpp +++ b/boost/network/protocol/http/server/connection/async.hpp @@ -1,13 +1,15 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_CONNECTION_HPP_20101027 -#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_CONNECTION_HPP_20101027 +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_CONNECTION_ASYNC_HPP_20101027 +#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_CONNECTION_ASYNC_HPP_20101027 -// Copyright 2010 Dean Michael Berris. +// Copyright 2010-2012 Dean Michael Berris +// Copyright 2012 Google, Inc. // 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) #include #include +#include #include #include #include @@ -17,6 +19,8 @@ #include #include #include +#include +#include #include #include #include @@ -31,6 +35,7 @@ #ifdef BOOST_NETWORK_NO_LIB #include #endif +#include #ifndef BOOST_NETWORK_HTTP_SERVER_CONNECTION_HEADER_BUFFER_MAX_SIZE /** Here we define a page's worth of header connection buffer data. @@ -47,595 +52,605 @@ #define BOOST_NETWORK_HTTP_SERVER_CONNECTION_HEADER_BUFFER_MAX_SIZE 4096 #endif /* BOOST_NETWORK_HTTP_SERVER_CONNECTION_HEADER_BUFFER_MAX_SIZE */ +#ifndef BOOST_NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE +/** Here we're making the assumption again that the page size of the system + * is 4096 and that it's better to have page-aligned chunks when creating + * buffers for memory use efficiency. + */ +#define BOOST_NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE 4096uL +#endif + namespace boost { namespace network { namespace http { #ifndef BOOST_NETWORK_NO_LIB - extern void parse_version(std::string const & partial_parsed, fusion::tuple & version_pair); - extern void parse_headers(std::string const & input, std::vector & container); + extern void parse_version(std::string const & partial_parsed, fusion::tuple & version_pair); + extern void parse_headers(std::string const & input, std::vector > & container); #endif - template - struct async_connection : boost::enable_shared_from_this > { - - enum status_t { - ok = 200 - , created = 201 - , accepted = 202 - , no_content = 204 - , multiple_choices = 300 - , moved_permanently = 301 - , moved_temporarily = 302 - , not_modified = 304 - , bad_request = 400 - , unauthorized = 401 - , forbidden = 403 - , not_found = 404 - , not_supported = 405 - , not_acceptable = 406 - , internal_server_error = 500 - , not_implemented = 501 - , bad_gateway = 502 - , service_unavailable = 503 - }; - - typedef typename string::type string_type; - typedef basic_request request; - typedef shared_ptr connection_ptr; - - private: - static char const * status_message(status_t status) { - static char const - ok_[] = "OK" - , created_[] = "Created" - , accepted_[] = "Accepted" - , no_content_[] = "No Content" - , multiple_choices_[] = "Multiple Choices" - , moved_permanently_[] = "Moved Permanently" - , moved_temporarily_[] = "Moved Temporarily" - , not_modified_[] = "Not Modified" - , bad_request_[] = "Bad Request" - , unauthorized_[] = "Unauthorized" - , forbidden_[] = "Fobidden" - , not_found_[] = "Not Found" - , not_supported_[] = "Not Supported" - , not_acceptable_[] = "Not Acceptable" - , internal_server_error_[] = "Internal Server Error" - , not_implemented_[] = "Not Implemented" - , bad_gateway_[] = "Bad Gateway" - , service_unavailable_[] = "Service Unavailable" - , unknown_[] = "Unknown" - ; - switch(status) { - case ok: return ok_; - case created: return created_; - case accepted: return accepted_; - case no_content: return no_content_; - case multiple_choices: return multiple_choices_; - case moved_permanently: return moved_permanently_; - case moved_temporarily: return moved_temporarily_; - case not_modified: return not_modified_; - case bad_request: return bad_request_; - case unauthorized: return unauthorized_; - case forbidden: return forbidden_; - case not_found: return not_found_; - case not_supported: return not_supported_; - case not_acceptable: return not_acceptable_; - case internal_server_error: return internal_server_error_; - case not_implemented: return not_implemented_; - case bad_gateway: return bad_gateway_; - case service_unavailable: return service_unavailable_; - default: return unknown_; - } - } - - public: - - async_connection( - asio::io_service & io_service - , Handler & handler - , utils::thread_pool & thread_pool - ) - : socket_(io_service) - , strand(io_service) - , handler(handler) - , thread_pool_(thread_pool) - , headers_already_sent(false) - , headers_in_progress(false) - , headers_buffer(BOOST_NETWORK_HTTP_SERVER_CONNECTION_HEADER_BUFFER_MAX_SIZE) - { - new_start = read_buffer_.begin(); - } - - ~async_connection() throw () { - boost::system::error_code ignored; - socket_.shutdown(asio::ip::tcp::socket::shutdown_receive, ignored); - } - - /** Function: template set_headers(Range headers) - * Precondition: headers have not been sent yet - * Postcondition: headers have been linearized to a buffer, - * and assumed to have been sent already when the function exits - * Throws: std::logic_error in case the headers have already been sent. - * - * A call to set_headers takes a Range where each element models the - * Header concept. This Range will be linearized onto a buffer, which is - * then sent as soon as the first call to `write` or `flush` commences. - */ - template - void set_headers(Range headers) { - lock_guard lock(headers_mutex); - if (headers_in_progress || headers_already_sent) - boost::throw_exception(std::logic_error("Headers have already been sent.")); - - if (error_encountered) - boost::throw_exception(boost::system::system_error(*error_encountered)); - - typedef constants consts; - { - std::ostream stream(&headers_buffer); - stream - << consts::http_slash() << 1<< consts::dot() << 1 << consts::space() - << status << consts::space() << status_message(status) - << consts::crlf(); - if (!boost::empty(headers)) { - typedef typename Range::const_iterator iterator; - typedef typename string::type string_type; - boost::transform(headers, - std::ostream_iterator(stream), - linearize_header()); - } else { - stream << consts::crlf(); - } - stream << consts::crlf(); - } - - write_headers_only( - boost::bind( - &async_connection::do_nothing - , async_connection::shared_from_this() - )); - } - - void set_status(status_t new_status) { - lock_guard lock(headers_mutex); - if (headers_already_sent) boost::throw_exception(std::logic_error("Headers have already been sent, cannot reset status.")); - if (error_encountered) boost::throw_exception(boost::system::system_error(*error_encountered)); - - status = new_status; - } - - template - void write(Range const & range) { - lock_guard lock(headers_mutex); - if (error_encountered) boost::throw_exception(boost::system::system_error(*error_encountered)); - - boost::function f = - boost::bind( - &async_connection::default_error - , async_connection::shared_from_this() - , _1); - - write_impl( - boost::make_iterator_range(range) - , f - ); - } - - template - typename disable_if, void>::type - write(Range const & range, Callback const & callback) { - lock_guard lock(headers_mutex); - if (error_encountered) boost::throw_exception(boost::system::system_error(*error_encountered)); - write_impl(boost::make_iterator_range(range), callback); - } - - template - typename enable_if, void>::type - write(ConstBufferSeq const & seq, Callback const & callback) - { - write_vec_impl(seq, callback, shared_array_list(), shared_buffers()); - } - - private: - typedef boost::array buffer_type; - - public: - typedef iterator_range input_range; - typedef boost::function read_callback_function; - - void read(read_callback_function callback) { - if (error_encountered) boost::throw_exception(boost::system::system_error(*error_encountered)); - if (new_start != read_buffer_.begin()) - { - input_range input = boost::make_iterator_range(new_start, read_buffer_.end()); - thread_pool().post( - boost::bind( - callback - , input - , boost::system::error_code() - , std::distance(new_start, data_end) - , async_connection::shared_from_this()) - ); - new_start = read_buffer_.begin(); - return; - } - - socket().async_read_some( - asio::buffer(read_buffer_) - , strand.wrap( - boost::bind( - &async_connection::wrap_read_handler - , async_connection::shared_from_this() - , callback - , asio::placeholders::error, asio::placeholders::bytes_transferred))); - } - - asio::ip::tcp::socket & socket() { return socket_; } - utils::thread_pool & thread_pool() { return thread_pool_; } - bool has_error() { return (!!error_encountered); } - optional error() - { return error_encountered; } - - private: - - void wrap_read_handler(read_callback_function callback, boost::system::error_code const & ec, std::size_t bytes_transferred) { - if (ec) error_encountered = in_place(ec); - buffer_type::const_iterator data_start = read_buffer_.begin() - ,data_end = read_buffer_.begin(); - std::advance(data_end, bytes_transferred); - thread_pool().post( - boost::bind( - callback - , boost::make_iterator_range(data_start, data_end) - , ec - , bytes_transferred - , async_connection::shared_from_this())); - } - - void default_error(boost::system::error_code const & ec) { - error_encountered = in_place(ec); - } - - typedef boost::array array; - typedef std::list > array_list; - typedef boost::shared_ptr shared_array_list; - typedef boost::shared_ptr > shared_buffers; - typedef request_parser request_parser_type; - typedef boost::lock_guard lock_guard; - typedef std::list > pending_actions_list; - - asio::ip::tcp::socket socket_; - asio::io_service::strand strand; - Handler & handler; - utils::thread_pool & thread_pool_; - volatile bool headers_already_sent, headers_in_progress; - asio::streambuf headers_buffer; - - boost::recursive_mutex headers_mutex; - buffer_type read_buffer_; - status_t status; - request_parser_type parser; - request request_; - buffer_type::iterator new_start, data_end; - string_type partial_parsed; - optional error_encountered; - pending_actions_list pending_actions; - - template friend struct async_server_base; - - enum state_t { - method, uri, version, headers - }; - - void start() { - typename ostringstream::type ip_stream; - ip_stream << socket_.remote_endpoint().address().to_v4().to_string() << ':' - << socket_.remote_endpoint().port(); - request_.source = ip_stream.str(); - read_more(method); - } - - void read_more(state_t state) { - socket_.async_read_some( - asio::buffer(read_buffer_) - , strand.wrap( - boost::bind( - &async_connection::handle_read_data, - async_connection::shared_from_this(), - state, - boost::asio::placeholders::error, - boost::asio::placeholders::bytes_transferred - ) - ) - ); - } - - void handle_read_data(state_t state, boost::system::error_code const & ec, std::size_t bytes_transferred) { - if (!ec) { - logic::tribool parsed_ok; - iterator_range result_range, input_range; - data_end = read_buffer_.begin(); - std::advance(data_end, bytes_transferred); - switch (state) { - case method: - input_range = boost::make_iterator_range( - new_start, data_end); - fusion::tie(parsed_ok, result_range) = parser.parse_until( - request_parser_type::method_done, input_range); - if (!parsed_ok) { - client_error(); - break; - } else if (parsed_ok == true) { - swap(partial_parsed, request_.method); - request_.method.append( - boost::begin(result_range), - boost::end(result_range)); - trim(request_.method); - new_start = boost::end(result_range); - } else { - partial_parsed.append( - boost::begin(result_range), - boost::end(result_range)); - new_start = read_buffer_.begin(); - read_more(method); - break; - } - case uri: - input_range = boost::make_iterator_range( - new_start, data_end); - fusion::tie(parsed_ok, result_range) = parser.parse_until( - request_parser_type::uri_done, - input_range); - if (!parsed_ok) { - client_error(); - break; - } else if (parsed_ok == true) { - swap(partial_parsed, request_.destination); - request_.destination.append( - boost::begin(result_range), - boost::end(result_range)); - trim(request_.destination); - new_start = boost::end(result_range); - } else { - partial_parsed.append( - boost::begin(result_range), - boost::end(result_range)); - new_start = read_buffer_.begin(); - read_more(uri); - break; - } - case version: - input_range = boost::make_iterator_range( - new_start, data_end); - fusion::tie(parsed_ok, result_range) = parser.parse_until( - request_parser_type::version_done, - input_range); - if (!parsed_ok) { - client_error(); - break; - } else if (parsed_ok == true) { - fusion::tuple version_pair; - partial_parsed.append(boost::begin(result_range), boost::end(result_range)); - parse_version(partial_parsed, version_pair); - request_.http_version_major = fusion::get<0>(version_pair); - request_.http_version_minor = fusion::get<1>(version_pair); - new_start = boost::end(result_range); - partial_parsed.clear(); - } else { - partial_parsed.append( - boost::begin(result_range), - boost::end(result_range)); - new_start = read_buffer_.begin(); - read_more(version); - break; - } - case headers: - input_range = boost::make_iterator_range( - new_start, data_end); - fusion::tie(parsed_ok, result_range) = parser.parse_until( - request_parser_type::headers_done, - input_range); - if (!parsed_ok) { - client_error(); - break; - } else if (parsed_ok == true) { - partial_parsed.append( - boost::begin(result_range), - boost::end(result_range)); - parse_headers(partial_parsed, request_.headers); - new_start = boost::end(result_range); - thread_pool().post( - boost::bind( - &Handler::operator(), - handler, - cref(request_), - async_connection::shared_from_this())); - return; - } else { - partial_parsed.append( - boost::begin(result_range), - boost::end(result_range)); - new_start = read_buffer_.begin(); - read_more(headers); - break; - } - default: - BOOST_ASSERT(false && "This is a bug, report to the cpp-netlib devel mailing list!"); - std::abort(); - } - } else { - error_encountered = in_place(ec); - } - } - - void client_error() { - static char const * bad_request = - "HTTP/1.0 400 Bad Request\r\nConnection: close\r\nContent-Type: text/plain\r\nContent-Length: 12\r\n\r\nBad Request."; - - asio::async_write( - socket() - , asio::buffer(bad_request, strlen(bad_request)) - , strand.wrap( - boost::bind( - &async_connection::client_error_sent - , async_connection::shared_from_this() - , asio::placeholders::error - , asio::placeholders::bytes_transferred))); - } - - void client_error_sent(boost::system::error_code const & ec, std::size_t bytes_transferred) { - if (!ec) { - boost::system::error_code ignored; - socket().shutdown(asio::ip::tcp::socket::shutdown_both, ignored); - socket().close(ignored); - } else { - error_encountered = in_place(ec); - } - } - - void do_nothing() {} - - void write_headers_only(boost::function callback) { - if (headers_in_progress) return; - headers_in_progress = true; - asio::async_write( - socket() - , headers_buffer - , strand.wrap( - boost::bind( - &async_connection::handle_write_headers - , async_connection::shared_from_this() - , callback - , asio::placeholders::error - , asio::placeholders::bytes_transferred))); - } - - void handle_write_headers(boost::function callback, boost::system::error_code const & ec, std::size_t bytes_transferred) { - lock_guard lock(headers_mutex); - if (!ec) { - headers_buffer.consume(headers_buffer.size()); - headers_already_sent = true; - thread_pool().post(callback); - pending_actions_list::iterator start = pending_actions.begin() - , end = pending_actions.end(); - while (start != end) { - thread_pool().post(*start++); - } - pending_actions_list().swap(pending_actions); - } else { - error_encountered = in_place(ec); - } - } - - void handle_write( - boost::function callback - , shared_array_list temporaries - , shared_buffers buffers - , boost::system::error_code const & ec - , std::size_t bytes_transferred - ) { - // we want to forget the temporaries and buffers - thread_pool().post(boost::bind(callback, ec)); - } - - template - void write_impl(Range range, boost::function callback) { - // linearize the whole range into a vector - // of fixed-sized buffers, then schedule an asynchronous - // write of these buffers -- make sure they are live - // by making these linearized buffers shared and made - // part of the completion handler. - // - // once the range has been linearized and sent, schedule - // a wrapper to be called in the io_service's thread, that - // will re-schedule the given callback into the thread pool - // referred to here so that the io_service's thread can concentrate - // on doing I/O. - // - - static std::size_t const connection_buffer_size = - BOOST_NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE; - shared_array_list temporaries = - boost::make_shared(); - shared_buffers buffers = - boost::make_shared >(0); - - std::size_t range_size = boost::distance(range); - buffers->reserve( - (range_size / connection_buffer_size) - + ((range_size % connection_buffer_size)?1:0) - ); - std::size_t slice_size = - std::min(range_size,connection_buffer_size); - typename boost::range_iterator::type - start = boost::begin(range) - , end = boost::end(range); - while (slice_size != 0) { - using boost::adaptors::sliced; - shared_ptr new_array = make_shared(); - boost::copy( - range | sliced(0,slice_size) - , new_array->begin() - ); - temporaries->push_back(new_array); - buffers->push_back(asio::buffer(new_array->data(), slice_size)); - std::advance(start, slice_size); - range = boost::make_iterator_range(start, end); - range_size = boost::distance(range); - slice_size = std::min(range_size, connection_buffer_size); - } - - if (!buffers->empty()) { - write_vec_impl(*buffers, callback, temporaries, buffers); - } - } - - template - void write_vec_impl(ConstBufferSeq const & seq - ,Callback const & callback - ,shared_array_list temporaries - ,shared_buffers buffers) - { - lock_guard lock(headers_mutex); - if (error_encountered) - boost::throw_exception(boost::system::system_error(*error_encountered)); - - boost::function callback_function = - callback; - - boost::function continuation = boost::bind( - &async_connection::template write_vec_impl > - ,async_connection::shared_from_this() - ,seq, callback_function, temporaries, buffers - ); - - if (!headers_already_sent && !headers_in_progress) { - write_headers_only(continuation); - return; - } else if (headers_in_progress && !headers_already_sent) { - pending_actions.push_back(continuation); - return; - } - - asio::async_write( - socket_ - ,seq - ,boost::bind( - &async_connection::handle_write - ,async_connection::shared_from_this() - ,callback_function - ,temporaries - ,buffers - ,asio::placeholders::error - ,asio::placeholders::bytes_transferred) - ); - } - }; - + class async_server_connection : public boost::enable_shared_from_this { + public: + enum status_t { + ok = 200 + , created = 201 + , accepted = 202 + , no_content = 204 + , multiple_choices = 300 + , moved_permanently = 301 + , moved_temporarily = 302 + , not_modified = 304 + , bad_request = 400 + , unauthorized = 401 + , forbidden = 403 + , not_found = 404 + , not_supported = 405 + , not_acceptable = 406 + , internal_server_error = 500 + , not_implemented = 501 + , bad_gateway = 502 + , service_unavailable = 503 + }; + + typedef std::string string_type; + typedef shared_ptr connection_ptr; + + private: + static char const * status_message(status_t status) { + static char const + ok_[] = "OK" + , created_[] = "Created" + , accepted_[] = "Accepted" + , no_content_[] = "No Content" + , multiple_choices_[] = "Multiple Choices" + , moved_permanently_[] = "Moved Permanently" + , moved_temporarily_[] = "Moved Temporarily" + , not_modified_[] = "Not Modified" + , bad_request_[] = "Bad Request" + , unauthorized_[] = "Unauthorized" + , forbidden_[] = "Fobidden" + , not_found_[] = "Not Found" + , not_supported_[] = "Not Supported" + , not_acceptable_[] = "Not Acceptable" + , internal_server_error_[] = "Internal Server Error" + , not_implemented_[] = "Not Implemented" + , bad_gateway_[] = "Bad Gateway" + , service_unavailable_[] = "Service Unavailable" + , unknown_[] = "Unknown" + ; + switch(status) { + case ok: return ok_; + case created: return created_; + case accepted: return accepted_; + case no_content: return no_content_; + case multiple_choices: return multiple_choices_; + case moved_permanently: return moved_permanently_; + case moved_temporarily: return moved_temporarily_; + case not_modified: return not_modified_; + case bad_request: return bad_request_; + case unauthorized: return unauthorized_; + case forbidden: return forbidden_; + case not_found: return not_found_; + case not_supported: return not_supported_; + case not_acceptable: return not_acceptable_; + case internal_server_error: return internal_server_error_; + case not_implemented: return not_implemented_; + case bad_gateway: return bad_gateway_; + case service_unavailable: return service_unavailable_; + default: return unknown_; + } + } + + public: + + async_server_connection( + asio::io_service & io_service + , function handler + , utils::thread_pool & thread_pool + ) + : socket_(io_service) + , strand(io_service) + , handler(handler) + , thread_pool_(thread_pool) + , headers_already_sent(false) + , headers_in_progress(false) + , headers_buffer(BOOST_NETWORK_HTTP_SERVER_CONNECTION_HEADER_BUFFER_MAX_SIZE) + { + new_start = read_buffer_.begin(); + } + + ~async_server_connection() throw () { + boost::system::error_code ignored; + socket_.shutdown(asio::ip::tcp::socket::shutdown_receive, ignored); + } + + /** Function: template set_headers(Range headers) + * Precondition: headers have not been sent yet + * Postcondition: headers have been linearized to a buffer, + * and assumed to have been sent already when the function exits + * Throws: std::logic_error in case the headers have already been sent. + * + * A call to set_headers takes a Range where each element models the + * Header concept. This Range will be linearized onto a buffer, which is + * then sent as soon as the first call to `write` or `flush` commences. + */ + template + void set_headers(Range headers) { + lock_guard lock(headers_mutex); + if (headers_in_progress || headers_already_sent) + boost::throw_exception(std::logic_error("Headers have already been sent.")); + + if (error_encountered) + boost::throw_exception(boost::system::system_error(*error_encountered)); + + { + std::ostream stream(&headers_buffer); + stream + << constants::http_slash() << 1<< constants::dot() << 1 << constants::space() + << status << constants::space() << status_message(status) + << constants::crlf(); + if (!boost::empty(headers)) { + typedef typename Range::const_iterator iterator; + boost::transform(headers, + std::ostream_iterator(stream), + linearize_header()); + } else { + stream << constants::crlf(); + } + stream << constants::crlf(); + } + + write_headers_only( + boost::bind( + &async_server_connection::do_nothing + , async_server_connection::shared_from_this() + )); + } + + void set_status(status_t new_status) { + lock_guard lock(headers_mutex); + if (headers_already_sent) boost::throw_exception(std::logic_error("Headers have already been sent, cannot reset status.")); + if (error_encountered) boost::throw_exception(boost::system::system_error(*error_encountered)); + + status = new_status; + } + + template + void write(Range const & range) { + lock_guard lock(headers_mutex); + if (error_encountered) boost::throw_exception(boost::system::system_error(*error_encountered)); + + boost::function f = + boost::bind( + &async_server_connection::default_error + , async_server_connection::shared_from_this() + , _1); + + write_impl( + boost::make_iterator_range(range) + , f + ); + } + + template + typename disable_if, void>::type + write(Range const & range, Callback const & callback) { + lock_guard lock(headers_mutex); + if (error_encountered) boost::throw_exception(boost::system::system_error(*error_encountered)); + write_impl(boost::make_iterator_range(range), callback); + } + + template + typename enable_if, void>::type + write(ConstBufferSeq const & seq, Callback const & callback) + { + write_vec_impl(seq, callback, shared_array_list(), shared_buffers()); + } + + private: + typedef boost::array buffer_type; + + public: + typedef iterator_range input_range; + typedef boost::function read_callback_function; + + void read(read_callback_function callback) { + if (error_encountered) boost::throw_exception(boost::system::system_error(*error_encountered)); + if (new_start != read_buffer_.begin()) + { + input_range input = boost::make_iterator_range(new_start, read_buffer_.end()); + thread_pool().post( + boost::bind( + callback + , input + , boost::system::error_code() + , std::distance(new_start, data_end) + , async_server_connection::shared_from_this()) + ); + new_start = read_buffer_.begin(); + return; + } + + socket().async_read_some( + asio::buffer(read_buffer_) + , strand.wrap( + boost::bind( + &async_server_connection::wrap_read_handler + , async_server_connection::shared_from_this() + , callback + , asio::placeholders::error, asio::placeholders::bytes_transferred))); + } + + asio::ip::tcp::socket & socket() { return socket_; } + utils::thread_pool & thread_pool() { return thread_pool_; } + bool has_error() { return (!!error_encountered); } + optional error() + { return error_encountered; } + + private: + + void wrap_read_handler(read_callback_function callback, boost::system::error_code const & ec, std::size_t bytes_transferred) { + if (ec) error_encountered = in_place(ec); + buffer_type::const_iterator data_start = read_buffer_.begin() + ,data_end = read_buffer_.begin(); + std::advance(data_end, bytes_transferred); + thread_pool().post( + boost::bind( + callback + , boost::make_iterator_range(data_start, data_end) + , ec + , bytes_transferred + , async_server_connection::shared_from_this())); + } + + void default_error(boost::system::error_code const & ec) { + error_encountered = in_place(ec); + } + + typedef boost::array array; + typedef std::list > array_list; + typedef boost::shared_ptr shared_array_list; + typedef boost::shared_ptr > shared_buffers; + typedef boost::lock_guard lock_guard; + typedef std::list > pending_actions_list; + + asio::ip::tcp::socket socket_; + asio::io_service::strand strand; + function handler; + utils::thread_pool & thread_pool_; + volatile bool headers_already_sent, headers_in_progress; + asio::streambuf headers_buffer; + + boost::recursive_mutex headers_mutex; + buffer_type read_buffer_; + status_t status; + request_parser parser; + request request_; + buffer_type::iterator new_start, data_end; + std::string partial_parsed; + optional error_encountered; + pending_actions_list pending_actions; + + friend class async_server_impl; + + enum state_t { + method, uri, version, headers + }; + + void start() { + std::ostringstream ip_stream; + ip_stream << socket_.remote_endpoint().address().to_string() << ':' + << socket_.remote_endpoint().port(); + request_.set_source(ip_stream.str()); + read_more(method); + } + + void read_more(state_t state) { + socket_.async_read_some( + asio::buffer(read_buffer_) + , strand.wrap( + boost::bind( + &async_server_connection::handle_read_data, + async_server_connection::shared_from_this(), + state, + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred + ) + ) + ); + } + + void handle_read_data(state_t state, boost::system::error_code const & ec, std::size_t bytes_transferred) { + if (!ec) { + logic::tribool parsed_ok; + iterator_range result_range, input_range; + data_end = read_buffer_.begin(); + std::advance(data_end, bytes_transferred); + switch (state) { + case method: + input_range = boost::make_iterator_range( + new_start, data_end); + fusion::tie(parsed_ok, result_range) = parser.parse_until( + request_parser::method_done, input_range); + if (!parsed_ok) { + client_error(); + break; + } else if (parsed_ok == true) { + std::string method; + swap(partial_parsed, method); + method.append(boost::begin(result_range), + boost::end(result_range)); + trim(method); + request_.set_method(method); + new_start = boost::end(result_range); + } else { + partial_parsed.append( + boost::begin(result_range), + boost::end(result_range)); + new_start = read_buffer_.begin(); + read_more(method); + break; + } + case uri: + input_range = boost::make_iterator_range( + new_start, data_end); + fusion::tie(parsed_ok, result_range) = parser.parse_until( + request_parser::uri_done, + input_range); + if (!parsed_ok) { + client_error(); + break; + } else if (parsed_ok == true) { + std::string destination; + swap(partial_parsed, destination); + destination.append(boost::begin(result_range), + boost::end(result_range)); + trim(destination); + request_.set_destination(destination); + new_start = boost::end(result_range); + } else { + partial_parsed.append( + boost::begin(result_range), + boost::end(result_range)); + new_start = read_buffer_.begin(); + read_more(uri); + break; + } + case version: + input_range = boost::make_iterator_range( + new_start, data_end); + fusion::tie(parsed_ok, result_range) = parser.parse_until( + request_parser::version_done, + input_range); + if (!parsed_ok) { + client_error(); + break; + } else if (parsed_ok == true) { + fusion::tuple version_pair; + partial_parsed.append(boost::begin(result_range), boost::end(result_range)); + parse_version(partial_parsed, version_pair); + request_.set_version_major(fusion::get<0>(version_pair)); + request_.set_version_minor(fusion::get<1>(version_pair)); + new_start = boost::end(result_range); + partial_parsed.clear(); + } else { + partial_parsed.append( + boost::begin(result_range), + boost::end(result_range)); + new_start = read_buffer_.begin(); + read_more(version); + break; + } + case headers: + input_range = boost::make_iterator_range( + new_start, data_end); + fusion::tie(parsed_ok, result_range) = parser.parse_until( + request_parser::headers_done, + input_range); + if (!parsed_ok) { + client_error(); + break; + } else if (parsed_ok == true) { + partial_parsed.append( + boost::begin(result_range), + boost::end(result_range)); + std::vector > headers; + parse_headers(partial_parsed, headers); + for (std::vector >::const_iterator it = headers.begin(); + it != headers.end(); + ++it) { + request_.append_header(it->first, it->second); + } + new_start = boost::end(result_range); + thread_pool().post( + boost::bind( + handler, + cref(request_), + async_server_connection::shared_from_this())); + return; + } else { + partial_parsed.append( + boost::begin(result_range), + boost::end(result_range)); + new_start = read_buffer_.begin(); + read_more(headers); + break; + } + default: + BOOST_ASSERT(false && "This is a bug, report to the cpp-netlib devel mailing list!"); + std::abort(); + } + } else { + error_encountered = in_place(ec); + } + } + + void client_error() { + static char const * bad_request = + "HTTP/1.0 400 Bad Request\r\nConnection: close\r\nContent-Type: text/plain\r\nContent-Length: 12\r\n\r\nBad Request."; + + asio::async_write( + socket() + , asio::buffer(bad_request, strlen(bad_request)) + , strand.wrap( + boost::bind( + &async_server_connection::client_error_sent + , async_server_connection::shared_from_this() + , asio::placeholders::error + , asio::placeholders::bytes_transferred))); + } + + void client_error_sent(boost::system::error_code const & ec, std::size_t bytes_transferred) { + if (!ec) { + boost::system::error_code ignored; + socket().shutdown(asio::ip::tcp::socket::shutdown_both, ignored); + socket().close(ignored); + } else { + error_encountered = in_place(ec); + } + } + + void do_nothing() {} + + void write_headers_only(boost::function callback) { + if (headers_in_progress) return; + headers_in_progress = true; + asio::async_write( + socket() + , headers_buffer + , strand.wrap( + boost::bind( + &async_server_connection::handle_write_headers + , async_server_connection::shared_from_this() + , callback + , asio::placeholders::error + , asio::placeholders::bytes_transferred))); + } + + void handle_write_headers(boost::function callback, boost::system::error_code const & ec, std::size_t bytes_transferred) { + lock_guard lock(headers_mutex); + if (!ec) { + headers_buffer.consume(headers_buffer.size()); + headers_already_sent = true; + thread_pool().post(callback); + pending_actions_list::iterator start = pending_actions.begin() + , end = pending_actions.end(); + while (start != end) { + thread_pool().post(*start++); + } + pending_actions_list().swap(pending_actions); + } else { + error_encountered = in_place(ec); + } + } + + void handle_write( + boost::function callback + , shared_array_list temporaries + , shared_buffers buffers + , boost::system::error_code const & ec + , std::size_t bytes_transferred + ) { + // we want to forget the temporaries and buffers + thread_pool().post(boost::bind(callback, ec)); + } + + template + void write_impl(Range range, boost::function callback) { + // linearize the whole range into a vector + // of fixed-sized buffers, then schedule an asynchronous + // write of these buffers -- make sure they are live + // by making these linearized buffers shared and made + // part of the completion handler. + // + // once the range has been linearized and sent, schedule + // a wrapper to be called in the io_service's thread, that + // will re-schedule the given callback into the thread pool + // referred to here so that the io_service's thread can concentrate + // on doing I/O. + // + + static std::size_t const connection_buffer_size = + BOOST_NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE; + shared_array_list temporaries = + boost::make_shared(); + shared_buffers buffers = + boost::make_shared >(0); + + std::size_t range_size = boost::distance(range); + buffers->reserve( + (range_size / connection_buffer_size) + + ((range_size % connection_buffer_size)?1:0) + ); + std::size_t slice_size = + std::min(range_size,connection_buffer_size); + typename boost::range_iterator::type + start = boost::begin(range) + , end = boost::end(range); + while (slice_size != 0) { + using boost::adaptors::sliced; + shared_ptr new_array = make_shared(); + boost::copy( + range | sliced(0,slice_size) + , new_array->begin() + ); + temporaries->push_back(new_array); + buffers->push_back(asio::buffer(new_array->data(), slice_size)); + std::advance(start, slice_size); + range = boost::make_iterator_range(start, end); + range_size = boost::distance(range); + slice_size = std::min(range_size, connection_buffer_size); + } + + if (!buffers->empty()) { + write_vec_impl(*buffers, callback, temporaries, buffers); + } + } + + template + void write_vec_impl(ConstBufferSeq const & seq + ,Callback const & callback + ,shared_array_list temporaries + ,shared_buffers buffers) + { + lock_guard lock(headers_mutex); + if (error_encountered) + boost::throw_exception(boost::system::system_error(*error_encountered)); + + boost::function callback_function = + callback; + + boost::function continuation = boost::bind( + &async_server_connection::template write_vec_impl > + ,async_server_connection::shared_from_this() + ,seq, callback_function, temporaries, buffers + ); + + if (!headers_already_sent && !headers_in_progress) { + write_headers_only(continuation); + return; + } else if (headers_in_progress && !headers_already_sent) { + pending_actions.push_back(continuation); + return; + } + + asio::async_write( + socket_ + ,seq + ,boost::bind( + &async_server_connection::handle_write + ,async_server_connection::shared_from_this() + ,callback_function + ,temporaries + ,buffers + ,asio::placeholders::error + ,asio::placeholders::bytes_transferred) + ); + } + }; + } /* http */ - + } /* network */ - + } /* boost */ #endif /* BOOST_NETWORK_PROTOCOL_HTTP_SERVER_CONNECTION_HPP_20101027 */ diff --git a/boost/network/protocol/http/server/impl/parsers.ipp b/boost/network/protocol/http/server/impl/parsers.ipp index 848b0fc4d..7c20c7d34 100644 --- a/boost/network/protocol/http/server/impl/parsers.ipp +++ b/boost/network/protocol/http/server/impl/parsers.ipp @@ -9,6 +9,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include +#include #include #ifdef BOOST_NETWORK_NO_LIB @@ -35,7 +36,7 @@ namespace boost { namespace network { namespace http { , version_pair); } - BOOST_NETWORK_INLINE void parse_headers(std::string const & input, std::vector & container) { + BOOST_NETWORK_INLINE void parse_headers(std::string const & input, std::vector > & container) { using namespace boost::spirit::qi; parse( input.begin(), input.end(), diff --git a/boost/network/protocol/http/server/options.hpp b/boost/network/protocol/http/server/options.hpp index 481d45666..97a727ca9 100644 --- a/boost/network/protocol/http/server/options.hpp +++ b/boost/network/protocol/http/server/options.hpp @@ -27,6 +27,7 @@ class server_options { server_options(server_options const &other); void swap(server_options &other); server_options& operator=(server_options rhs); + ~server_options(); server_options& address(std::string const &address); std::string const address() const; @@ -68,7 +69,7 @@ class server_options { // Set the socket linger timeout. This is only relevant if linger is true // (see linger above). -1 means just use the default. server_options& linger_timeout(int setting); - int linger_timeout(); + int linger_timeout() const; private: server_options_pimpl *pimpl_; diff --git a/boost/network/protocol/http/server/options.ipp b/boost/network/protocol/http/server/options.ipp new file mode 100644 index 000000000..890cdae21 --- /dev/null +++ b/boost/network/protocol/http/server/options.ipp @@ -0,0 +1,292 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_IPP_20120318 +#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_IPP_20120318 + +// Copyright 2012 Dean Michael Berris . +// Copyright 2012 Google, Inc. +// 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) + +#include +#include + +namespace boost { namespace network { namespace http { + +class server_options_pimpl { + public: + server_options_pimpl() + : address_("0.0.0.0") + , port_("80") + , io_service_(0) + , receive_buffer_size_(-1) + , send_buffer_size_(-1) + , receive_low_watermark_(-1) + , send_low_watermark_(-1) + , linger_timeout_(30) + , reuse_address_(false) + , report_aborted_(false) + , non_blocking_io_(true) + , linger_(false) + {} + + server_options_pimpl *clone() const { + return new server_options_pimpl(*this); + } + + void address(std::string const &address) { + address_ = address; + } + + std::string const address() const { + return address_; + } + + void port(std::string const &port) { + port_ = port; + } + + std::string const port() const { + return port_; + } + + void io_service(asio::io_service *service) { + io_service_ = service; + } + + asio::io_service *io_service() const { + return io_service_; + } + + void reuse_address(bool setting) { + reuse_address_ = setting; + } + + bool reuse_address() const { + return reuse_address_; + } + + void report_aborted(bool setting) { + report_aborted_ = setting; + } + + bool report_aborted() const { + return report_aborted_; + } + + void receive_buffer_size(int buffer_size) { + receive_buffer_size_ = buffer_size; + } + + int receive_buffer_size() const { + return receive_buffer_size_; + } + + void send_buffer_size(int buffer_size) { + send_buffer_size_ = buffer_size; + } + + int send_buffer_size() const { + return send_buffer_size_; + } + + void receive_low_watermark(int buffer_size) { + receive_low_watermark_ = buffer_size; + } + + int receive_low_watermark() const { + return receive_low_watermark_; + } + + void send_low_watermark(int buffer_size) { + send_low_watermark_ = buffer_size; + } + + int send_low_watermark() const { + return send_low_watermark_; + } + + void non_blocking_io(bool setting) { + non_blocking_io_ = setting; + } + + bool non_blocking_io() const { + return non_blocking_io_; + } + + void linger(bool setting) { + linger_ = setting; + } + + bool linger() const { + return linger_; + } + + void linger_timeout(int setting) { + linger_timeout_ = setting; + } + + int linger_timeout() const { + return linger_timeout_; + } + + private: + std::string address_, port_; + asio::io_service *io_service_; + int receive_buffer_size_, send_buffer_size_, + receive_low_watermark_, send_low_watermark_, + linger_timeout_; + bool reuse_address_, report_aborted_, + non_blocking_io_, linger_; + + server_options_pimpl(server_options_pimpl const &other) + : address_(other.address_) + , port_(other.port_) + , io_service_(other.io_service_) + , receive_buffer_size_(other.receive_buffer_size_) + , send_buffer_size_(other.send_buffer_size_) + , receive_low_watermark_(other.receive_low_watermark_) + , send_low_watermark_(other.send_low_watermark_) + , linger_timeout_(other.linger_timeout_) + , reuse_address_(other.reuse_address_) + , report_aborted_(other.report_aborted_) + , non_blocking_io_(other.non_blocking_io_) + , linger_(other.linger_) {} + +}; + +server_options::server_options() +: pimpl_(new (std::nothrow) server_options_pimpl) +{} + +server_options::server_options(server_options const &other) +: pimpl_(other.pimpl_->clone()) +{} + +server_options::~server_options() { + delete pimpl_; +} + +void server_options::swap(server_options &other) { + std::swap(other.pimpl_, this->pimpl_); +} + +server_options& server_options::operator=(server_options other) { + other.swap(*this); + return *this; +} + +server_options& server_options::address(std::string const &address) { + pimpl_->address(address); + return *this; +} + +std::string const server_options::address() const { + return pimpl_->address(); +} + +server_options& server_options::port(std::string const &port) { + pimpl_->port(port); + return *this; +} + +std::string const server_options::port() const { + return pimpl_->port(); +} + +server_options& server_options::io_service(asio::io_service *io_service) { + pimpl_->io_service(io_service); + return *this; +} + +asio::io_service* server_options::io_service() const { + return pimpl_->io_service(); +} + +server_options& server_options::non_blocking_io(bool setting) { + pimpl_->non_blocking_io(setting); + return *this; +} + +bool server_options::non_blocking_io() const { + return pimpl_->non_blocking_io(); +} + +server_options& server_options::reuse_address(bool setting) { + pimpl_->reuse_address(setting); + return *this; +} + +bool server_options::reuse_address() const { + return pimpl_->reuse_address(); +} + +server_options& server_options::report_aborted(bool setting) { + pimpl_->report_aborted(setting); + return *this; +} + +bool server_options::report_aborted() const { + return pimpl_->report_aborted(); +} + +server_options& server_options::receive_buffer_size(int buffer_size) { + pimpl_->receive_buffer_size(buffer_size); + return *this; +} + +int server_options::receive_buffer_size() const { + return pimpl_->receive_buffer_size(); +} + +server_options& server_options::send_buffer_size(int buffer_size) { + pimpl_->send_buffer_size(buffer_size); + return *this; +} + +int server_options::send_buffer_size() const { + return pimpl_->send_buffer_size(); +} + +server_options& server_options::receive_low_watermark(int buffer_size) { + pimpl_->receive_low_watermark(buffer_size); + return *this; +} + +int server_options::receive_low_watermark() const { + return pimpl_->receive_low_watermark(); +} + +server_options& server_options::send_low_watermark(int buffer_size) { + pimpl_->send_low_watermark(buffer_size); + return *this; +} + +int server_options::send_low_watermark() const { + return pimpl_->send_low_watermark(); +} + +server_options& server_options::linger(bool setting) { + pimpl_->linger(setting); + return *this; +} + +bool server_options::linger() const { + return pimpl_->linger(); +} + +server_options& server_options::linger_timeout(int buffer_size) { + pimpl_->linger_timeout(buffer_size); + return *this; +} + +int server_options::linger_timeout() const { + return pimpl_->linger_timeout(); +} + +} // namespace http + +} // namespace network + +} // namespace boost + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_IPP_20120318 diff --git a/boost/network/protocol/http/server/request_parser.hpp b/boost/network/protocol/http/server/request_parser.hpp index bb6421b66..b4672529a 100644 --- a/boost/network/protocol/http/server/request_parser.hpp +++ b/boost/network/protocol/http/server/request_parser.hpp @@ -14,7 +14,6 @@ namespace boost { namespace network { namespace http { - template struct request_parser { enum state_t { diff --git a/libs/network/src/CMakeLists.txt b/libs/network/src/CMakeLists.txt index bc76308f1..4bc6ec27f 100644 --- a/libs/network/src/CMakeLists.txt +++ b/libs/network/src/CMakeLists.txt @@ -27,7 +27,8 @@ endif() endforeach(src_file) set(CPP-NETLIB_HTTP_SERVER_SRCS - http/server_async_impl.cpp) + http/server_async_impl.cpp + http/server_options.cpp) add_library(cppnetlib-http-servers ${CPP-NETLIB_HTTP_SERVER_SRCS}) foreach (src_file ${CPP-NETLIB_HTTP_SERVER_SRCS}) if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) diff --git a/libs/network/src/http/server_options.cpp b/libs/network/src/http/server_options.cpp new file mode 100644 index 000000000..85b142d84 --- /dev/null +++ b/libs/network/src/http/server_options.cpp @@ -0,0 +1,7 @@ +// Copyright 2012 Dean Michael Berris . +// Copyright 2012 Google, Inc. +// 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) + +#include diff --git a/libs/network/test/http/CMakeLists.txt b/libs/network/test/http/CMakeLists.txt index 33b36a731..768ced7cd 100644 --- a/libs/network/test/http/CMakeLists.txt +++ b/libs/network/test/http/CMakeLists.txt @@ -87,8 +87,13 @@ if (Boost_FOUND) target_link_libraries(cpp-netlib-http-${test} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} + cppnetlib-uri + cppnetlib-message + cppnetlib-http-message cppnetlib-http-servers - cppnetlib-http-server-parsers) + cppnetlib-http-server-parsers + cppnetlib-utils-thread_pool + ) set_target_properties(cpp-netlib-http-${test} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests) add_test(cpp-netlib-http-${test} From efd97fd247df7061815f46412e79e71518821d1f Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Mon, 19 Mar 2012 16:56:46 +1100 Subject: [PATCH 077/196] Adapting Server Constructor Test This change gets the test building against the new server APIs. Next up, getting it linked. --- .../test/http/server_constructor_test.cpp | 54 +++++++++---------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/libs/network/test/http/server_constructor_test.cpp b/libs/network/test/http/server_constructor_test.cpp index b2b4fe8eb..4d6bc3441 100644 --- a/libs/network/test/http/server_constructor_test.cpp +++ b/libs/network/test/http/server_constructor_test.cpp @@ -14,7 +14,7 @@ namespace util = boost::network::utils; struct dummy_sync_handler; struct dummy_async_handler; -typedef http::server sync_server; +typedef http::sync_server sync_server; typedef http::async_server async_server; struct dummy_sync_handler { @@ -38,9 +38,12 @@ BOOST_AUTO_TEST_CASE(minimal_constructor) { dummy_sync_handler sync_handler; dummy_async_handler async_handler; util::thread_pool pool; + http::server_options options; + options.address("127.0.0.1") + .port("80"); - BOOST_CHECK_NO_THROW(sync_server sync_instance("127.0.0.1", "80", sync_handler) ); - BOOST_CHECK_NO_THROW(async_server async_instance("127.0.0.1", "80", async_handler, pool) ); + BOOST_CHECK_NO_THROW(sync_server sync_instance(options, sync_handler) ); + BOOST_CHECK_NO_THROW(async_server async_instance(options, async_handler, pool) ); } BOOST_AUTO_TEST_CASE(with_io_service_parameter) { @@ -48,37 +51,32 @@ BOOST_AUTO_TEST_CASE(with_io_service_parameter) { dummy_async_handler async_handler; util::thread_pool pool; boost::asio::io_service io_service; + http::server_options options; + options.address("127.0.0.1") + .port("80") + .io_service(&io_service); - BOOST_CHECK_NO_THROW(sync_server sync_instance("127.0.0.1", "80", sync_handler, io_service)); - BOOST_CHECK_NO_THROW(async_server async_instance("127.0.0.1", "80", async_handler, pool, io_service)); + BOOST_CHECK_NO_THROW(sync_server sync_instance(options, sync_handler)); + BOOST_CHECK_NO_THROW(async_server async_instance(options, async_handler, pool)); } BOOST_AUTO_TEST_CASE(with_socket_options_parameter) { dummy_sync_handler sync_handler; dummy_async_handler async_handler; util::thread_pool pool; + http::server_options options; + options.address("127.0.0.1") + .port("80") + .reuse_address(true) + .report_aborted(true) + .receive_buffer_size(4096) + .send_buffer_size(4096) + .receive_low_watermark(1024) + .send_low_watermark(1024) + .non_blocking_io(true) + .linger(true) + .linger_timeout(0); - BOOST_CHECK_NO_THROW(sync_server sync_instance("127.0.0.1", "80", sync_handler, - http::_reuse_address=true, - http::_report_aborted=true, - http::_receive_buffer_size=4096, - http::_send_buffer_size=4096, - http::_receive_low_watermark=1024, - http::_send_low_watermark=1024, - http::_non_blocking_io=true, - http::_linger=true, - http::_linger_timeout=0 - )); - BOOST_CHECK_NO_THROW(async_server async_instance("127.0.0.1", "80", async_handler, pool, - http::_reuse_address=true, - http::_report_aborted=true, - http::_receive_buffer_size=4096, - http::_send_buffer_size=4096, - http::_receive_low_watermark=1024, - http::_send_low_watermark=1024, - http::_non_blocking_io=true, - http::_linger=true, - http::_linger_timeout=0 - )); - + BOOST_CHECK_NO_THROW(sync_server sync_instance(options, sync_handler)); + BOOST_CHECK_NO_THROW(async_server async_instance(options, async_handler, pool)); } From 007fef705da4633c4791badc95277ae4de2b7aa7 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Mon, 19 Mar 2012 18:06:24 +1100 Subject: [PATCH 078/196] WIP: Converting the Synchronous Server Implementation Okay, I've hit a little road-block here. It seems that the synchronous server implementation doesn't use the same parsing mechanism in the async server implementation. This is going to have to change, but before I go on I'd like to save the work I've already done to get to this point. --- .../http/server/{sync_connection.hpp => connection/sync.hpp} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename boost/network/protocol/http/server/{sync_connection.hpp => connection/sync.hpp} (100%) diff --git a/boost/network/protocol/http/server/sync_connection.hpp b/boost/network/protocol/http/server/connection/sync.hpp similarity index 100% rename from boost/network/protocol/http/server/sync_connection.hpp rename to boost/network/protocol/http/server/connection/sync.hpp From 034098c373f0383a9653a8bd9b5e9fb9decad3fc Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Mon, 19 Mar 2012 18:07:12 +1100 Subject: [PATCH 079/196] WIP: More Changes Here's some more changes that are really part of the previous commit. I should really be using the command-line utility more than this Github app... --- .../network/protocol/http/request_parser.hpp | 16 +-- .../protocol/http/server/async_impl.hpp | 6 +- .../protocol/http/server/async_impl.ipp | 39 +------ .../protocol/http/server/connection/sync.hpp | 63 +++++------ .../server/impl/socket_options_setter.hpp | 28 +++++ .../server/impl/socket_options_setter.ipp | 56 +++++++++ .../protocol/http/server/sync_impl.hpp | 5 + .../protocol/http/server/sync_impl.ipp | 106 ++++++++++++++++++ libs/network/src/CMakeLists.txt | 5 +- .../src/http/server_socket_options_setter.cpp | 7 ++ libs/network/src/http/server_sync_impl.cpp | 7 ++ 11 files changed, 256 insertions(+), 82 deletions(-) create mode 100644 boost/network/protocol/http/server/impl/socket_options_setter.hpp create mode 100644 boost/network/protocol/http/server/impl/socket_options_setter.ipp create mode 100644 boost/network/protocol/http/server/sync_impl.ipp create mode 100644 libs/network/src/http/server_socket_options_setter.cpp create mode 100644 libs/network/src/http/server_sync_impl.cpp diff --git a/boost/network/protocol/http/request_parser.hpp b/boost/network/protocol/http/request_parser.hpp index 13818cbf2..c97f6f892 100644 --- a/boost/network/protocol/http/request_parser.hpp +++ b/boost/network/protocol/http/request_parser.hpp @@ -2,9 +2,10 @@ // request_parser.hpp // ~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// Copyright (c) 2009 Dean Michael Berris (mikhailberis at gmail dot com) -// Copyright (c) 2009 Tarro, Inc. +// Copyright 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright 2009-2012 Dean Michael Berris . +// Copyright 2012 Google, Inc. +// Copyright 2009 Tarroo, Inc. // // 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) @@ -26,12 +27,11 @@ namespace tag { } /// Parser for incoming requests. -template -class basic_request_parser +class request_parser { public: /// Construct ready to parse the request method. - basic_request_parser() : state_(method_start) {} + request_parser() : state_(method_start) {} /// Reset to initial parser state. void reset() { state_ = method_start; } @@ -41,7 +41,7 @@ class basic_request_parser /// data is required. The InputIterator return value indicates how much of the /// input has been consumed. template - boost::tuple parse_headers(basic_request & req, + boost::tuple parse_headers(request & req, InputIterator begin, InputIterator end) { while (begin != end) @@ -56,7 +56,7 @@ class basic_request_parser private: /// Handle the next character of input. - boost::tribool consume(basic_request & req, char input); + boost::tribool consume(request & req, char input); /// Check if a byte is an HTTP character. static bool is_char(int c); diff --git a/boost/network/protocol/http/server/async_impl.hpp b/boost/network/protocol/http/server/async_impl.hpp index 619526664..242d2b14a 100644 --- a/boost/network/protocol/http/server/async_impl.hpp +++ b/boost/network/protocol/http/server/async_impl.hpp @@ -12,6 +12,7 @@ #include #include #include +#include namespace boost { namespace network { namespace utils { @@ -29,7 +30,7 @@ struct request; class async_server_connection; -class async_server_impl { +class async_server_impl : protected socket_options_setter { public: typedef shared_ptr connection_ptr; async_server_impl(server_options const &options, @@ -54,9 +55,6 @@ class async_server_impl { void handle_stop(); void start_listening(); void handle_accept(system::error_code const &ec); - - void set_socket_options(asio::ip::tcp::socket &socket); - void set_acceptor_options(asio::ip::tcp::acceptor &acceptor); }; } // namespace http diff --git a/boost/network/protocol/http/server/async_impl.ipp b/boost/network/protocol/http/server/async_impl.ipp index aa781c833..9fffa483f 100644 --- a/boost/network/protocol/http/server/async_impl.ipp +++ b/boost/network/protocol/http/server/async_impl.ipp @@ -90,7 +90,7 @@ void async_server_impl::handle_accept(boost::system::error_code const & ec) { if (stopping_) return; } if (!ec) { - set_socket_options(new_connection_->socket()); + set_socket_options(options_, new_connection_->socket()); new_connection_->start(); new_connection_.reset( new async_server_connection(*service_, handler_, pool_)); @@ -122,7 +122,7 @@ void async_server_impl::start_listening() { BOOST_NETWORK_MESSAGE("error opening socket: " << address_ << ":" << port_); BOOST_THROW_EXCEPTION(std::runtime_error("Error opening socket.")); } - set_acceptor_options(*acceptor_); + set_acceptor_options(options_, *acceptor_); acceptor_->bind(endpoint, error); if (error) { BOOST_NETWORK_MESSAGE("error binding socket: " << address_ << ":" << port_); @@ -146,41 +146,6 @@ void async_server_impl::start_listening() { BOOST_NETWORK_MESSAGE("now listening on '" << address_ << ":" << port_ << "'"); } -void async_server_impl::set_socket_options(asio::ip::tcp::socket &socket) { - system::error_code ignored; - socket.non_blocking(options_.non_blocking_io(), ignored); - if (options_.linger()) { - asio::ip::tcp::socket::linger linger(true, options_.linger_timeout()); - socket.set_option(linger, ignored); - } - if (int buf_size = options_.receive_buffer_size() >= 0) { - asio::ip::tcp::socket::receive_buffer_size receive_buffer_size(buf_size); - socket.set_option(receive_buffer_size, ignored); - } - if (int buf_size = options_.send_buffer_size() >= 0) { - asio::ip::tcp::socket::send_buffer_size send_buffer_size(buf_size); - socket.set_option(send_buffer_size, ignored); - } - if (int buf_size = options_.receive_low_watermark() >= 0) { - asio::ip::tcp::socket::receive_low_watermark receive_low_watermark(buf_size); - socket.set_option(receive_low_watermark, ignored); - } - if (int buf_size = options_.send_low_watermark() >= 0) { - asio::ip::tcp::socket::send_low_watermark send_low_watermark(buf_size); - socket.set_option(send_low_watermark, ignored); - } -} - -void async_server_impl::set_acceptor_options(asio::ip::tcp::acceptor &acceptor) { - system::error_code ignored; - acceptor.set_option( - asio::ip::tcp::acceptor::reuse_address(options_.reuse_address()), - ignored); - acceptor.set_option( - asio::ip::tcp::acceptor::enable_connection_aborted(options_.report_aborted()), - ignored); -} - } // namespace http } // namespace network diff --git a/boost/network/protocol/http/server/connection/sync.hpp b/boost/network/protocol/http/server/connection/sync.hpp index 32d562b93..ece0e8417 100644 --- a/boost/network/protocol/http/server/connection/sync.hpp +++ b/boost/network/protocol/http/server/connection/sync.hpp @@ -9,11 +9,11 @@ #define BOOST_NETWORK_HTTP_SERVER_SYNC_CONNECTION_HPP_ #ifndef BOOST_NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE -#define BOOST_NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE 1024uL +#define BOOST_NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE 4096uL #endif #include -#include +#include #include #include #include @@ -29,10 +29,9 @@ namespace boost { namespace network { namespace http { - template - struct sync_connection : boost::enable_shared_from_this > { + class sync_server_connection : public boost::enable_shared_from_this { - sync_connection(boost::asio::io_service & service, Handler & handler) + sync_server_connection(boost::asio::io_service & service, function handler) : service_(service) , handler_(handler) , socket_(service_) @@ -58,8 +57,8 @@ namespace boost { namespace network { namespace http { boost::asio::buffer(buffer_), wrapper_.wrap( boost::bind( - &sync_connection::handle_read_headers, - sync_connection::shared_from_this(), + &sync_server_connection::handle_read_headers, + sync_server_connection::shared_from_this(), boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred ) @@ -92,14 +91,14 @@ namespace boost { namespace network { namespace http { is_content_length() ); if (it == request_.headers.end()) { - response_= basic_response::stock_reply(basic_response::bad_request); + response_= stock_reply(bad_request); boost::asio::async_write( socket_, response_.to_buffers(), wrapper_.wrap( boost::bind( - &sync_connection::handle_write, - sync_connection::shared_from_this(), + &sync_server_connection::handle_write, + sync_server_connection::shared_from_this(), boost::asio::placeholders::error ) ) @@ -112,14 +111,14 @@ namespace boost { namespace network { namespace http { try { content_length = boost::lexical_cast(it->value); } catch (...) { - response_= basic_response::stock_reply(basic_response::bad_request); + response_= stock_reply(bad_request); boost::asio::async_write( socket_, response_.to_buffers(), wrapper_.wrap( boost::bind( - &sync_connection::handle_write, - sync_connection::shared_from_this(), + &sync_server_connection::handle_write, + sync_server_connection::shared_from_this(), boost::asio::placeholders::error ) ) @@ -137,8 +136,8 @@ namespace boost { namespace network { namespace http { boost::asio::buffer(buffer_), wrapper_.wrap( boost::bind( - &sync_connection::handle_read_body_contents, - sync_connection::shared_from_this(), + &sync_server_connection::handle_read_body_contents, + sync_server_connection::shared_from_this(), boost::asio::placeholders::error, content_length, boost::asio::placeholders::bytes_transferred @@ -155,8 +154,8 @@ namespace boost { namespace network { namespace http { response_.to_buffers(), wrapper_.wrap( boost::bind( - &sync_connection::handle_write, - sync_connection::shared_from_this(), + &sync_server_connection::handle_write, + sync_server_connection::shared_from_this(), boost::asio::placeholders::error ) ) @@ -168,22 +167,22 @@ namespace boost { namespace network { namespace http { response_.to_buffers(), wrapper_.wrap( boost::bind( - &sync_connection::handle_write, - sync_connection::shared_from_this(), + &sync_server_connection::handle_write, + sync_server_connection::shared_from_this(), boost::asio::placeholders::error ) ) ); } } else if (!done) { - response_= basic_response::stock_reply(basic_response::bad_request); + response_= stock_reply(bad_request); boost::asio::async_write( socket_, response_.to_buffers(), wrapper_.wrap( boost::bind( - &sync_connection::handle_write, - sync_connection::shared_from_this(), + &sync_server_connection::handle_write, + sync_server_connection::shared_from_this(), boost::asio::placeholders::error ) ) @@ -193,8 +192,8 @@ namespace boost { namespace network { namespace http { boost::asio::buffer(buffer_), wrapper_.wrap( boost::bind( - &sync_connection::handle_read_headers, - sync_connection::shared_from_this(), + &sync_server_connection::handle_read_headers, + sync_server_connection::shared_from_this(), boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred ) @@ -219,8 +218,8 @@ namespace boost { namespace network { namespace http { response_.to_buffers(), wrapper_.wrap( boost::bind( - &sync_connection::handle_write, - sync_connection::shared_from_this(), + &sync_server_connection::handle_write, + sync_server_connection::shared_from_this(), boost::asio::placeholders::error ) ) @@ -230,8 +229,8 @@ namespace boost { namespace network { namespace http { boost::asio::buffer(buffer_), wrapper_.wrap( boost::bind( - &sync_connection::handle_read_body_contents, - sync_connection::shared_from_this(), + &sync_server_connection::handle_read_body_contents, + sync_server_connection::shared_from_this(), boost::asio::placeholders::error, difference, boost::asio::placeholders::bytes_transferred @@ -252,16 +251,16 @@ namespace boost { namespace network { namespace http { } boost::asio::io_service & service_; - Handler & handler_; + function handler_; boost::asio::ip::tcp::socket socket_; boost::asio::io_service::strand wrapper_; typedef boost::array buffer_type; buffer_type buffer_; - typedef basic_request_parser request_parser; + request_parser request_parser; request_parser parser_; - basic_request request_; - basic_response response_; + request request_; + response response_; }; diff --git a/boost/network/protocol/http/server/impl/socket_options_setter.hpp b/boost/network/protocol/http/server/impl/socket_options_setter.hpp new file mode 100644 index 000000000..db88d0d2e --- /dev/null +++ b/boost/network/protocol/http/server/impl/socket_options_setter.hpp @@ -0,0 +1,28 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_IMPL_SOCKET_OPIONS_SETTER_20120319 +#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_IMPL_SOCKET_OPIONS_SETTER_20120319 + +// Copyright 2012 Dean Michael Berris . +// Copyright 2012 Google, Inc. +// 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) + +#include + +namespace boost { namespace network { namespace http { + +class server_options; + +class socket_options_setter { + protected: + void set_socket_options(server_options const &options, asio::ip::tcp::socket &socket); + void set_acceptor_options(server_options const &options, asio::ip::tcp::acceptor &acceptor); +}; + +} // namespace http + +} // namespace network + +} // namespace boost + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_SERVER_IMPL_SOCKET_OPIONS_SETTER_20120319 diff --git a/boost/network/protocol/http/server/impl/socket_options_setter.ipp b/boost/network/protocol/http/server/impl/socket_options_setter.ipp new file mode 100644 index 000000000..b20c3d4bc --- /dev/null +++ b/boost/network/protocol/http/server/impl/socket_options_setter.ipp @@ -0,0 +1,56 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_IMPL_SOCKET_OPTIONS_SETTER_IPP_20120319 +#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_IMPL_SOCKET_OPTIONS_SETTER_IPP_20120319 + +// Copyright 2012 Dean Michael Berris . +// Copyright 2012 Google, Inc. +// 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) + +#include +#include + +namespace boost { namespace network { namespace http { + +void socket_options_setter::set_socket_options(server_options const & options, asio::ip::tcp::socket &socket) { + system::error_code ignored; + socket.non_blocking(options.non_blocking_io(), ignored); + if (options.linger()) { + asio::ip::tcp::socket::linger linger(true, options.linger_timeout()); + socket.set_option(linger, ignored); + } + if (int buf_size = options.receive_buffer_size() >= 0) { + asio::ip::tcp::socket::receive_buffer_size receive_buffer_size(buf_size); + socket.set_option(receive_buffer_size, ignored); + } + if (int buf_size = options.send_buffer_size() >= 0) { + asio::ip::tcp::socket::send_buffer_size send_buffer_size(buf_size); + socket.set_option(send_buffer_size, ignored); + } + if (int buf_size = options.receive_low_watermark() >= 0) { + asio::ip::tcp::socket::receive_low_watermark receive_low_watermark(buf_size); + socket.set_option(receive_low_watermark, ignored); + } + if (int buf_size = options.send_low_watermark() >= 0) { + asio::ip::tcp::socket::send_low_watermark send_low_watermark(buf_size); + socket.set_option(send_low_watermark, ignored); + } +} + +void socket_options_setter::set_acceptor_options(server_options const &options, asio::ip::tcp::acceptor &acceptor) { + system::error_code ignored; + acceptor.set_option( + asio::ip::tcp::acceptor::reuse_address(options.reuse_address()), + ignored); + acceptor.set_option( + asio::ip::tcp::acceptor::enable_connection_aborted(options.report_aborted()), + ignored); +} + +} // namespace http + +} // namespace network + +} // namespace boost + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_SERVER_IMPL_SOCKET_OPTIONS_SETTER_IPP_20120319 diff --git a/boost/network/protocol/http/server/sync_impl.hpp b/boost/network/protocol/http/server/sync_impl.hpp index d36ff4e7d..b054d1417 100644 --- a/boost/network/protocol/http/server/sync_impl.hpp +++ b/boost/network/protocol/http/server/sync_impl.hpp @@ -11,6 +11,8 @@ #include #include #include +#include +#include namespace boost { namespace network { namespace http { @@ -35,6 +37,9 @@ class sync_server_impl { mutex listening_mutex_; bool listening_, owned_service_; function handler_; + + void start_listening(); + void handle_accept(system::error_code const &ec); }; } // namespace http diff --git a/boost/network/protocol/http/server/sync_impl.ipp b/boost/network/protocol/http/server/sync_impl.ipp new file mode 100644 index 000000000..48b0dd439 --- /dev/null +++ b/boost/network/protocol/http/server/sync_impl.ipp @@ -0,0 +1,106 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_SYNC_IMPL_IPP_20120319 +#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_SYNC_IMPL_IPP_20120319 + +// Copyright 2012 Dean Michael Berris . +// Copyright 2012 Google, Inc. +// 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) + +#include +#include +#include + +namespace boost { namespace network { namespace http { + +sync_server_impl::sync_server_impl(server_options const &options, + function handler) +: options_(options) +, address_(options.address()) +, port_(options.port()) +, service_(options.io_service()) +, acceptor_(0) +, new_connection_() +, listening_mutex_() +, listening_(false) +, owned_service_(false) { + if (service_ == 0) { + service_ = new (std::nothrow) asio::io_service; + owned_service_ = true; + BOOST_ASSERT(service_ != 0); + } + acceptor_ = new (std::nothrow) asio::ip::tcp::acceptor(*service_); + BOOST_ASSERT(acceptor_ != 0); +} + +void sync_server_impl::run() { + listen(); + service_->run(); +} + +void sync_server_impl::stop() { + system::error_code ignored; + acceptor_->close(ignored); + service_->stop(); +} + +void sync_server_impl::listen() { + lock_guard listening_lock(listening_mutex_); + if (!listening_) start_listening(); +} + +void sync_server_impl::handle_accept(system::error_code const &ec) { + if (!ec) { + set_socket_options(options_, new_connection_->socket()); + new_connection_->start(); + new_connection.reset(new sync_server_connection(*service_, handler_)); + aceptor_.async_accept(new_connection_->socket(), + bind(&sync_server_impl::handle_accept, + this, + asio::placeholders::error)); + } else { + BOOST_NETWORK_MESSAGE("error accepting connection: " << ec); + this->stop(); + } +} // namespace http + +void sync_server_impl::start_listening() { + using asio::ip::tcp; + system::error_code error; + tcp::resolver resolver(*service_); + tcp::resolver::query query(address_, port_); + tcp::resolver::iterator endpoint_ = resolver.resolve(query, error); + if (error) { + BOOST_NETWORK_MESSAGE("error resolving address: " << address_ << ':' << port_ << " -- reason: '" << error << '\''); + BOOST_THROW_EXCEPTION(std::runtime_error("Error resolving provided address:port combination.")); + } + tcp::endpoint endpoint = *endpoint_iterator; + acceptor_->open(endpoint.protocol(), error); + if (error) { + BOOST_NETWORK_MESSAGE("error opening socket: " << address_ << ':' << port_ << " -- reason: '" << error << '\''); + BOOST_THROW_EXCEPTION(std::runtime_error("Error opening socket for acceptor.")); + } + set_acceptor_options(options_, *acceptor_); + acceptor_->bind(endpoint, error); + if (error) { + BOOST_NETWORK_MESSAGE("error binding to socket: " << address_ << ':' << port_ << " -- reason: '" << error << '\''); + BOOST_THROW_EXCEPTION(std::runtime_error("Error binding to socket for acceptor.")); + } + acceptor_.listen(tcp::socket::max_connections, error); + if (error) { + BOOST_NETWORK_MESSAGE("error listening on socket: " << address_ << ':' << port_ << " -- reason: '" << error << '\''); + BOOST_THROW_EXCEPTION(std::runtime_error("Error listening on socket for acceptor.")); + } + new_connection_.reset(new sync_server_connection(*service_, handler_)); + acceptor_->async_accept(new_connection_->socket(), + bind(&sync_server_impl::handle_accept, + this, + asio::placeholders::error)); + listening_ = true; +} + +} // namespace network + +} // namespace boost + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_SERVER_SYNC_IMPL_IPP_20120319 diff --git a/libs/network/src/CMakeLists.txt b/libs/network/src/CMakeLists.txt index 4bc6ec27f..210f1d6a6 100644 --- a/libs/network/src/CMakeLists.txt +++ b/libs/network/src/CMakeLists.txt @@ -28,7 +28,10 @@ endforeach(src_file) set(CPP-NETLIB_HTTP_SERVER_SRCS http/server_async_impl.cpp - http/server_options.cpp) + http/server_options.cpp + http/server_socket_options_setter.cpp + http/server_sync_impl.cpp + ) add_library(cppnetlib-http-servers ${CPP-NETLIB_HTTP_SERVER_SRCS}) foreach (src_file ${CPP-NETLIB_HTTP_SERVER_SRCS}) if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) diff --git a/libs/network/src/http/server_socket_options_setter.cpp b/libs/network/src/http/server_socket_options_setter.cpp new file mode 100644 index 000000000..25b975f14 --- /dev/null +++ b/libs/network/src/http/server_socket_options_setter.cpp @@ -0,0 +1,7 @@ +// Copyright 2012 Dean Michael Berris . +// Copyright 2012 Google, Inc. +// 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) + +#include diff --git a/libs/network/src/http/server_sync_impl.cpp b/libs/network/src/http/server_sync_impl.cpp new file mode 100644 index 000000000..3a4cc5c42 --- /dev/null +++ b/libs/network/src/http/server_sync_impl.cpp @@ -0,0 +1,7 @@ +// Copyright 2012 Dean Michael Berris . +// Copyright 2012 Google, Inc. +// 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) + +#include From e8cccb65c9928876970eeb2d9035a378e7cb4bdb Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Wed, 21 Mar 2012 23:21:31 +1100 Subject: [PATCH 080/196] We want to standardize the packaging across releases. --- package.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 package.sh diff --git a/package.sh b/package.sh new file mode 100755 index 000000000..fbc517ea4 --- /dev/null +++ b/package.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# +# Copyright 2012 Dean Michael Berris +# Copyright 2012 Google, Inc. +# 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) +# + +VERSION="$1" +if [ "$VERSION" == "" ]; then + VERSION="`git log --format=oneline | awk '{print $1}' | head -1`" +fi + +TAG="cpp-netlib-$VERSION" +git tag $TAG +echo "Tagged $TAG." + +git archive --prefix=cpp-netlib-$VERSION/ --format=zip $TAG >cpp-netlib-$VERSION.zip +git archive --prefix=cpp-netlib-$VERSION/ --format=tar $TAG | gzip >cpp-netlib-$VERSION.tar.gz +git archive --prefix=cpp-netlib-$VERSION/ --format=tar $TAG | bzip2 >cpp-netlib-$VERSION.tar.bz2 +echo "Packaged $TAG." From bd118e77696693363c8962d00c7f17f0217cb57a Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Mon, 26 Mar 2012 20:00:35 +1100 Subject: [PATCH 081/196] Getting the synchronous server building! --- .../protocol/http/server/connection/sync.hpp | 455 +++++++++--------- .../protocol/http/server/sync_impl.hpp | 2 +- .../protocol/http/server/sync_impl.ipp | 12 +- 3 files changed, 243 insertions(+), 226 deletions(-) diff --git a/boost/network/protocol/http/server/connection/sync.hpp b/boost/network/protocol/http/server/connection/sync.hpp index ece0e8417..258fcd8dc 100644 --- a/boost/network/protocol/http/server/connection/sync.hpp +++ b/boost/network/protocol/http/server/connection/sync.hpp @@ -26,242 +26,257 @@ #include #include #include +#include namespace boost { namespace network { namespace http { - class sync_server_connection : public boost::enable_shared_from_this { +#ifndef BOOST_NETWORK_NO_LIB + extern void parse_version(std::string const & partial_parsed, fusion::tuple & version_pair); + extern void parse_headers(std::string const & input, std::vector > & container); +#endif - sync_server_connection(boost::asio::io_service & service, function handler) - : service_(service) - , handler_(handler) - , socket_(service_) - , wrapper_(service_) - { - } +class sync_server_connection : public boost::enable_shared_from_this { + public: + sync_server_connection(boost::asio::io_service & service, + function handler) + : service_(service) + , handler_(handler) + , socket_(service_) + , wrapper_(service_) + { + } - boost::asio::ip::tcp::socket & socket() { - return socket_; - } + boost::asio::ip::tcp::socket & socket() { + return socket_; + } - void start() { - // This is HTTP so we really want to just - // read and parse a request that's incoming - // and then pass that request object to the - // handler_ instance. - // - using boost::asio::ip::tcp; - boost::system::error_code option_error; - socket_.set_option(tcp::no_delay(true), option_error); - if (option_error) handler_.log(boost::system::system_error(option_error).what()); - socket_.async_read_some( - boost::asio::buffer(buffer_), - wrapper_.wrap( - boost::bind( - &sync_server_connection::handle_read_headers, - sync_server_connection::shared_from_this(), - boost::asio::placeholders::error, - boost::asio::placeholders::bytes_transferred - ) - ) - ); - } + void start() { + using boost::asio::ip::tcp; + boost::system::error_code option_error; + // TODO make no_delay an option in server_options. + socket_.set_option(tcp::no_delay(true), option_error); + std::ostringstream ip_stream; + ip_stream << socket_.remote_endpoint().address().to_string() << ':' + << socket_.remote_endpoint().port(); + request_.set_source(ip_stream.str()); + socket_.async_read_some( + boost::asio::buffer(read_buffer_), + wrapper_.wrap( + boost::bind( + &sync_server_connection::handle_read_data, + sync_server_connection::shared_from_this(), + method, + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred))); + } - private: + private: + + enum state_t { + method, uri, version, headers, body + }; - struct is_content_length { - template - bool operator()(Header const & header) { - return boost::to_lower_copy(header.name) == "content-length"; - } - }; - void handle_read_headers(boost::system::error_code const &ec, size_t bytes_transferred) { - if (!ec) { - request_.source = socket_.remote_endpoint().address().to_string(); - boost::tribool done; - buffer_type::iterator new_start; - tie(done,new_start) = parser_.parse_headers(request_, buffer_.data(), buffer_.data() + bytes_transferred); - if (done) { - if (request_.method[0] == 'P') { - // look for the content-length header - typename std::vector::type >::iterator it = - std::find_if( - request_.headers.begin(), - request_.headers.end(), - is_content_length() - ); - if (it == request_.headers.end()) { - response_= stock_reply(bad_request); - boost::asio::async_write( - socket_, - response_.to_buffers(), - wrapper_.wrap( - boost::bind( - &sync_server_connection::handle_write, - sync_server_connection::shared_from_this(), - boost::asio::placeholders::error - ) - ) - ); - return; - } - - size_t content_length = 0; + void handle_read_data(state_t state, boost::system::error_code const & ec, std::size_t bytes_transferred) { + if (!ec) { + logic::tribool parsed_ok; + iterator_range result_range, input_range; + data_end = read_buffer_.begin(); + std::advance(data_end, bytes_transferred); + switch (state) { + case method: + input_range = boost::make_iterator_range( + new_start, data_end); + fusion::tie(parsed_ok, result_range) = parser_.parse_until( + request_parser::method_done, input_range); + if (!parsed_ok) { + client_error(); + break; + } else if (parsed_ok == true) { + std::string method; + swap(partial_parsed, method); + method.append(boost::begin(result_range), + boost::end(result_range)); + trim(method); + request_.set_method(method); + new_start = boost::end(result_range); + // Determine whether we're going to need to parse the body of the + // request. All we do is peek at the first character of the method + // to determine whether it's a POST or a PUT. + read_body_ = method.size() ? method[0] == 'P' : false; + } else { + partial_parsed.append( + boost::begin(result_range), + boost::end(result_range)); + new_start = read_buffer_.begin(); + read_more(method); + break; + } + case uri: + input_range = boost::make_iterator_range( + new_start, data_end); + fusion::tie(parsed_ok, result_range) = parser_.parse_until( + request_parser::uri_done, + input_range); + if (!parsed_ok) { + client_error(); + break; + } else if (parsed_ok == true) { + std::string destination; + swap(partial_parsed, destination); + destination.append(boost::begin(result_range), + boost::end(result_range)); + trim(destination); + request_.set_destination(destination); + new_start = boost::end(result_range); + } else { + partial_parsed.append( + boost::begin(result_range), + boost::end(result_range)); + new_start = read_buffer_.begin(); + read_more(uri); + break; + } + case version: + input_range = boost::make_iterator_range( + new_start, data_end); + fusion::tie(parsed_ok, result_range) = parser_.parse_until( + request_parser::version_done, + input_range); + if (!parsed_ok) { + client_error(); + break; + } else if (parsed_ok == true) { + fusion::tuple version_pair; + partial_parsed.append(boost::begin(result_range), boost::end(result_range)); + parse_version(partial_parsed, version_pair); + request_.set_version_major(fusion::get<0>(version_pair)); + request_.set_version_minor(fusion::get<1>(version_pair)); + new_start = boost::end(result_range); + partial_parsed.clear(); + } else { + partial_parsed.append( + boost::begin(result_range), + boost::end(result_range)); + new_start = read_buffer_.begin(); + read_more(version); + break; + } + case headers: + input_range = boost::make_iterator_range( + new_start, data_end); + fusion::tie(parsed_ok, result_range) = parser_.parse_until( + request_parser::headers_done, + input_range); + if (!parsed_ok) { + client_error(); + break; + } else if (parsed_ok == true) { + partial_parsed.append( + boost::begin(result_range), + boost::end(result_range)); + std::vector > headers; + parse_headers(partial_parsed, headers); + for (std::vector >::const_iterator it = headers.begin(); + it != headers.end(); + ++it) { + request_.append_header(it->first, it->second); + } + new_start = boost::end(result_range); + if (read_body_) { + } else { + response response_; + handler_(request_, response_); + std::vector response_buffers; + flatten(response_, response_buffers); + boost::asio::async_write( + socket_, + response_buffers, + wrapper_.wrap( + boost::bind( + &sync_server_connection::handle_write, + sync_server_connection::shared_from_this(), + boost::asio::placeholders::error))); + } + return; + } else { + partial_parsed.append( + boost::begin(result_range), + boost::end(result_range)); + new_start = read_buffer_.begin(); + read_more(headers); + break; + } + default: + BOOST_ASSERT(false && "This is a bug, report to the cpp-netlib devel mailing list!"); + std::abort(); + } + } else { + error_encountered = in_place(ec); + } + } - try { - content_length = boost::lexical_cast(it->value); - } catch (...) { - response_= stock_reply(bad_request); - boost::asio::async_write( - socket_, - response_.to_buffers(), - wrapper_.wrap( - boost::bind( - &sync_server_connection::handle_write, - sync_server_connection::shared_from_this(), - boost::asio::placeholders::error - ) - ) - ); - return; - } + void handle_write(system::error_code const &ec) { + if (ec) { + // TODO maybe log the error here. + } + } - if (content_length != 0) { - if (new_start != (buffer_.begin() + bytes_transferred)) { - request_.body.append(new_start, buffer_.begin() + bytes_transferred); - content_length -= std::distance(new_start, buffer_.begin() + bytes_transferred); - } - if (content_length > 0) { - socket_.async_read_some( - boost::asio::buffer(buffer_), - wrapper_.wrap( - boost::bind( - &sync_server_connection::handle_read_body_contents, - sync_server_connection::shared_from_this(), - boost::asio::placeholders::error, - content_length, - boost::asio::placeholders::bytes_transferred - ) - ) - ); - return; - } - } + void client_error() { + static char const * bad_request = + "HTTP/1.0 400 Bad Request\r\nConnection: close\r\nContent-Type: text/plain\r\nContent-Length: 12\r\n\r\nBad Request."; - handler_(request_, response_); - boost::asio::async_write( - socket_, - response_.to_buffers(), - wrapper_.wrap( - boost::bind( - &sync_server_connection::handle_write, - sync_server_connection::shared_from_this(), - boost::asio::placeholders::error - ) - ) - ); - } else { - handler_(request_, response_); - boost::asio::async_write( - socket_, - response_.to_buffers(), - wrapper_.wrap( - boost::bind( - &sync_server_connection::handle_write, - sync_server_connection::shared_from_this(), - boost::asio::placeholders::error - ) - ) - ); - } - } else if (!done) { - response_= stock_reply(bad_request); - boost::asio::async_write( - socket_, - response_.to_buffers(), - wrapper_.wrap( - boost::bind( - &sync_server_connection::handle_write, - sync_server_connection::shared_from_this(), - boost::asio::placeholders::error - ) - ) - ); - } else { - socket_.async_read_some( - boost::asio::buffer(buffer_), - wrapper_.wrap( - boost::bind( - &sync_server_connection::handle_read_headers, - sync_server_connection::shared_from_this(), - boost::asio::placeholders::error, - boost::asio::placeholders::bytes_transferred - ) - ) - ); - } - } - // TODO Log the error? - } + asio::async_write( + socket() + , asio::buffer(bad_request, strlen(bad_request)) + , wrapper_.wrap( + boost::bind( + &sync_server_connection::client_error_sent + , sync_server_connection::shared_from_this() + , asio::placeholders::error + , asio::placeholders::bytes_transferred))); + } - void handle_read_body_contents(boost::system::error_code const & ec, size_t bytes_to_read, size_t bytes_transferred) { - if (!ec) { - size_t difference = bytes_to_read - bytes_transferred; - buffer_type::iterator start = buffer_.begin(), - past_end = start; - std::advance(past_end, (std::min)(bytes_to_read,bytes_transferred)); - request_.body.append(buffer_.begin(), past_end); - if (difference == 0) { - handler_(request_, response_); - boost::asio::async_write( - socket_, - response_.to_buffers(), - wrapper_.wrap( - boost::bind( - &sync_server_connection::handle_write, - sync_server_connection::shared_from_this(), - boost::asio::placeholders::error - ) - ) - ); - } else { - socket_.async_read_some( - boost::asio::buffer(buffer_), - wrapper_.wrap( - boost::bind( - &sync_server_connection::handle_read_body_contents, - sync_server_connection::shared_from_this(), - boost::asio::placeholders::error, - difference, - boost::asio::placeholders::bytes_transferred - ) - ) - ); - } - } - // TODO Log the error? - } + void client_error_sent(boost::system::error_code const & ec, std::size_t bytes_transferred) { + if (!ec) { + boost::system::error_code ignored; + socket().shutdown(asio::ip::tcp::socket::shutdown_both, ignored); + socket().close(ignored); + } else { + error_encountered = in_place(ec); + } + } - void handle_write(boost::system::error_code const & ec) { - if (!ec) { - using boost::asio::ip::tcp; - boost::system::error_code ignored_ec; - socket_.shutdown(tcp::socket::shutdown_receive, ignored_ec); - } - } + void read_more(state_t state) { + socket_.async_read_some( + asio::buffer(read_buffer_) + , wrapper_.wrap( + boost::bind( + &sync_server_connection::handle_read_data, + sync_server_connection::shared_from_this(), + state, + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred + ) + ) + ); + } - boost::asio::io_service & service_; - function handler_; - boost::asio::ip::tcp::socket socket_; - boost::asio::io_service::strand wrapper_; + boost::asio::io_service & service_; + function handler_; + boost::asio::ip::tcp::socket socket_; + boost::asio::io_service::strand wrapper_; - typedef boost::array buffer_type; - buffer_type buffer_; - request_parser request_parser; - request_parser parser_; - request request_; - response response_; - }; + typedef boost::array buffer_type; + buffer_type read_buffer_; + buffer_type::iterator new_start, data_end; + request_parser parser_; + request request_; + response response_; + std::string partial_parsed; + optional error_encountered; + bool read_body_; +}; } // namespace http diff --git a/boost/network/protocol/http/server/sync_impl.hpp b/boost/network/protocol/http/server/sync_impl.hpp index b054d1417..49ee45cb5 100644 --- a/boost/network/protocol/http/server/sync_impl.hpp +++ b/boost/network/protocol/http/server/sync_impl.hpp @@ -20,7 +20,7 @@ class sync_server_connection; struct request; struct response; -class sync_server_impl { +class sync_server_impl : protected socket_options_setter { public: sync_server_impl(server_options const &options, function handler); diff --git a/boost/network/protocol/http/server/sync_impl.ipp b/boost/network/protocol/http/server/sync_impl.ipp index 48b0dd439..d67cbbeaa 100644 --- a/boost/network/protocol/http/server/sync_impl.ipp +++ b/boost/network/protocol/http/server/sync_impl.ipp @@ -53,8 +53,8 @@ void sync_server_impl::handle_accept(system::error_code const &ec) { if (!ec) { set_socket_options(options_, new_connection_->socket()); new_connection_->start(); - new_connection.reset(new sync_server_connection(*service_, handler_)); - aceptor_.async_accept(new_connection_->socket(), + new_connection_.reset(new sync_server_connection(*service_, handler_)); + acceptor_->async_accept(new_connection_->socket(), bind(&sync_server_impl::handle_accept, this, asio::placeholders::error)); @@ -62,7 +62,7 @@ void sync_server_impl::handle_accept(system::error_code const &ec) { BOOST_NETWORK_MESSAGE("error accepting connection: " << ec); this->stop(); } -} // namespace http +} void sync_server_impl::start_listening() { using asio::ip::tcp; @@ -74,7 +74,7 @@ void sync_server_impl::start_listening() { BOOST_NETWORK_MESSAGE("error resolving address: " << address_ << ':' << port_ << " -- reason: '" << error << '\''); BOOST_THROW_EXCEPTION(std::runtime_error("Error resolving provided address:port combination.")); } - tcp::endpoint endpoint = *endpoint_iterator; + tcp::endpoint endpoint = *endpoint_; acceptor_->open(endpoint.protocol(), error); if (error) { BOOST_NETWORK_MESSAGE("error opening socket: " << address_ << ':' << port_ << " -- reason: '" << error << '\''); @@ -86,7 +86,7 @@ void sync_server_impl::start_listening() { BOOST_NETWORK_MESSAGE("error binding to socket: " << address_ << ':' << port_ << " -- reason: '" << error << '\''); BOOST_THROW_EXCEPTION(std::runtime_error("Error binding to socket for acceptor.")); } - acceptor_.listen(tcp::socket::max_connections, error); + acceptor_->listen(tcp::socket::max_connections, error); if (error) { BOOST_NETWORK_MESSAGE("error listening on socket: " << address_ << ':' << port_ << " -- reason: '" << error << '\''); BOOST_THROW_EXCEPTION(std::runtime_error("Error listening on socket for acceptor.")); @@ -99,6 +99,8 @@ void sync_server_impl::start_listening() { listening_ = true; } +} // namespace http + } // namespace network } // namespace boost From a0f68a7297d8b5db5e0fa4526e01e7fdb48e1306 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Mon, 26 Mar 2012 20:01:26 +1100 Subject: [PATCH 082/196] Stub for flatten algorithm. --- .../protocol/http/algorithms/flatten.hpp | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 boost/network/protocol/http/algorithms/flatten.hpp diff --git a/boost/network/protocol/http/algorithms/flatten.hpp b/boost/network/protocol/http/algorithms/flatten.hpp new file mode 100644 index 000000000..60fa8c468 --- /dev/null +++ b/boost/network/protocol/http/algorithms/flatten.hpp @@ -0,0 +1,25 @@ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_ALGORITHMS_FLATTEN_HPP_20120326 +#define BOOST_NETWORK_PROTOCOL_HTTP_ALGORITHMS_FLATTEN_HPP_20120326 + +// Copyright 2012 Dean Michael Berris . +// Copyright 2012 Google, Inc. +// 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) + +#include +#include + +namespace boost { namespace network { namespace http { + +class response; + +void flatten(response const &response_, std::vector &buffers); + +} // namespace http + +} // namespace network + +} // namespace boost + +#endif // BOOST_NETWORK_PROTOCOL_HTTP_ALGORITHMS_FLATTEN_HPP_20120326 From a7963291f0e9c72e37d494e90e9b09004ac7233a Mon Sep 17 00:00:00 2001 From: Glyn Matthews Date: Wed, 2 May 2012 20:24:41 +0200 Subject: [PATCH 083/196] [uri] Moved around some deckchairs. Now the main namespace is 'network'. URI headers moved to include/network/uri* --- include/network/uri.hpp | 13 + include/network/uri/accessors.hpp | 108 +++++ include/network/uri/builder.hpp | 132 ++++++ include/network/uri/config.hpp | 21 + include/network/uri/decode.hpp | 104 +++++ include/network/uri/detail/uri_parts.hpp | 98 ++++ include/network/uri/directives.hpp | 44 ++ include/network/uri/directives/authority.hpp | 35 ++ include/network/uri/directives/fragment.hpp | 41 ++ include/network/uri/directives/host.hpp | 40 ++ include/network/uri/directives/path.hpp | 61 +++ include/network/uri/directives/port.hpp | 52 +++ include/network/uri/directives/query.hpp | 76 ++++ include/network/uri/directives/scheme.hpp | 64 +++ include/network/uri/directives/user_info.hpp | 41 ++ include/network/uri/encode.hpp | 172 +++++++ include/network/uri/schemes.hpp | 33 ++ include/network/uri/uri.hpp | 421 ++++++++++++++++++ include/network/uri/uri.ipp | 235 ++++++++++ include/network/uri/uri_io.hpp | 22 + libs/network/src/CMakeLists.txt | 4 +- libs/network/src/uri/schemes.cpp | 6 +- libs/network/src/uri/uri.cpp | 2 +- libs/network/test/uri/CMakeLists.txt | 3 +- .../test/uri/uri_builder_stream_test.cpp | 109 +++-- libs/network/test/uri/uri_builder_test.cpp | 79 ++-- libs/network/test/uri/uri_encoding_test.cpp | 15 +- libs/network/test/uri/uri_test.cpp | 407 +++++++++-------- 28 files changed, 2118 insertions(+), 320 deletions(-) create mode 100644 include/network/uri.hpp create mode 100644 include/network/uri/accessors.hpp create mode 100644 include/network/uri/builder.hpp create mode 100644 include/network/uri/config.hpp create mode 100644 include/network/uri/decode.hpp create mode 100644 include/network/uri/detail/uri_parts.hpp create mode 100644 include/network/uri/directives.hpp create mode 100644 include/network/uri/directives/authority.hpp create mode 100644 include/network/uri/directives/fragment.hpp create mode 100644 include/network/uri/directives/host.hpp create mode 100644 include/network/uri/directives/path.hpp create mode 100644 include/network/uri/directives/port.hpp create mode 100644 include/network/uri/directives/query.hpp create mode 100644 include/network/uri/directives/scheme.hpp create mode 100644 include/network/uri/directives/user_info.hpp create mode 100644 include/network/uri/encode.hpp create mode 100644 include/network/uri/schemes.hpp create mode 100644 include/network/uri/uri.hpp create mode 100644 include/network/uri/uri.ipp create mode 100644 include/network/uri/uri_io.hpp diff --git a/include/network/uri.hpp b/include/network/uri.hpp new file mode 100644 index 000000000..5a4d99323 --- /dev/null +++ b/include/network/uri.hpp @@ -0,0 +1,13 @@ +// Copyright (c) Glyn Matthews 2012. +// 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 __NETWORK_URI_INC__ +# define __NETWORK_URI_INC__ + +#include +#include + +#endif // __NETWORK_URI_INC__ diff --git a/include/network/uri/accessors.hpp b/include/network/uri/accessors.hpp new file mode 100644 index 000000000..a6fedf38a --- /dev/null +++ b/include/network/uri/accessors.hpp @@ -0,0 +1,108 @@ +// Copyright (c) Glyn Matthews 2011, 2012. +// 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 __BOOST_NETWORK_URI_URI_ACCESSORS_INC__ +# define __BOOST_NETWORK_URI_URI_ACCESSORS_INC__ + + +# include +# include +# include +# include +# include + + +namespace network { +namespace details { +template < + typename Map + > +struct key_value_sequence + : boost::spirit::qi::grammar +{ + typedef typename Map::key_type key_type; + typedef typename Map::mapped_type mapped_type; + typedef std::pair pair_type; + + key_value_sequence() + : key_value_sequence::base_type(query) + { + query = pair >> *((boost::spirit::qi::lit(';') | '&') >> pair); + pair = key >> -('=' >> value); + key = boost::spirit::qi::char_("a-zA-Z_") >> *boost::spirit::qi::char_("a-zA-Z_0-9/%"); + value = +boost::spirit::qi::char_("a-zA-Z_0-9/%"); + } + + boost::spirit::qi::rule query; + boost::spirit::qi::rule pair; + boost::spirit::qi::rule key; + boost::spirit::qi::rule value; +}; +} // namespace details + +template < + class Map + > +inline +Map &query_map(const uri &uri_, Map &map) { + const uri::string_type range = uri_.query(); + details::key_value_sequence parser; + boost::spirit::qi::parse(boost::begin(range), boost::end(range), parser, map); + return map; +} + +inline +uri::string_type username(const uri &uri_) { + const uri::string_type user_info = uri_.user_info(); + uri::const_iterator it(boost::begin(user_info)), end(boost::end(user_info)); + for (; it != end; ++it) { + if (*it == ':') { + break; + } + } + return uri::string_type(boost::begin(user_info), it); +} + +inline +uri::string_type password(const uri &uri_) { + const uri::string_type user_info = uri_.user_info(); + uri::const_iterator it(boost::begin(user_info)), end(boost::end(user_info)); + for (; it != end; ++it) { + if (*it == ':') { + ++it; + break; + } + } + return uri::string_type(it, boost::end(user_info)); +} + +inline +uri::string_type decoded_path(const uri &uri_) { + const uri::string_type path = uri_.path(); + uri::string_type decoded_path; + decode(path, std::back_inserter(decoded_path)); + return decoded_path; +} + +inline +uri::string_type decoded_query(const uri &uri_) { + const uri::string_type query = uri_.query(); + uri::string_type decoded_query; + decode(query, std::back_inserter(decoded_query)); + return decoded_query; +} + +inline +uri::string_type decoded_fragment(const uri &uri_) { + const uri::string_type fragment = uri_.fragment(); + uri::string_type decoded_fragment; + decode(fragment, std::back_inserter(decoded_fragment)); + return decoded_fragment; +} +} // namespace network + + +#endif // __BOOST_NETWORK_URI_URI_ACCESSORS_INC__ diff --git a/include/network/uri/builder.hpp b/include/network/uri/builder.hpp new file mode 100644 index 000000000..a8c7e76aa --- /dev/null +++ b/include/network/uri/builder.hpp @@ -0,0 +1,132 @@ +// Copyright (c) Glyn Matthews 2012. +// 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 __BOOST_NETWORK_URI_BUILDER_INC__ +# define __BOOST_NETWORK_URI_BUILDER_INC__ + + +# include + + +namespace network { +class builder { + + typedef uri::string_type string_type; + +public: + + builder(uri &uri_) + : uri_(uri_) { + + } + + builder &scheme(const string_type &scheme) { + uri_.uri_.append(scheme); + if (opaque_schemes::exists(scheme)) { + uri_.uri_.append(":"); + } + else { + uri_.uri_.append("://"); + } + uri_.parse(); + return *this; + } + + builder &user_info(const string_type &user_info) { + uri_.uri_.append(user_info); + uri_.uri_.append("@"); + uri_.parse(); + return *this; + } + + builder &host(const string_type &host) { + uri_.uri_.append(host); + uri_.parse(); + return *this; + } + + builder &host(const boost::asio::ip::address &host) { + uri_.uri_.append(host.to_string()); + uri_.parse(); + return *this; + } + + builder &host(const boost::asio::ip::address_v4 &host) { + uri_.uri_.append(host.to_string()); + uri_.parse(); + return *this; + } + + builder &host(const boost::asio::ip::address_v6 &host) { + uri_.uri_.append("["); + uri_.uri_.append(host.to_string()); + uri_.uri_.append("]"); + uri_.parse(); + return *this; + } + + builder &port(const string_type &port) { + uri_.uri_.append(":"); + uri_.uri_.append(port); + uri_.parse(); + return *this; + } + + builder &port(uint16_t port) { + return this->port(boost::lexical_cast(port)); + } + + builder &path(const string_type &path) { + uri_.uri_.append(path); + uri_.parse(); + return *this; + } + + builder &encoded_path(const string_type &path) { + string_type encoded_path; + encode(path, std::back_inserter(encoded_path)); + return this->path(encoded_path); + } + + builder &query(const string_type &query) { + uri_.uri_.append("?"); + uri_.uri_.append(query); + uri_.parse(); + return *this; + } + + builder &query(const string_type &key, const string_type &value) { + if (!uri_.query_range()) + { + uri_.uri_.append("?"); + } + else + { + uri_.uri_.append("&"); + } + uri_.uri_.append(key); + uri_.uri_.append("="); + uri_.uri_.append(value); + uri_.parse(); + return *this; + } + + builder &fragment(const string_type &fragment) { + uri_.uri_.append("#"); + uri_.uri_.append(fragment); + uri_.parse(); + return *this; + } + +private: + + uri &uri_; + +}; +} // namespace network + + +#endif // __BOOST_NETWORK_URI_BUILDER_INC__ diff --git a/include/network/uri/config.hpp b/include/network/uri/config.hpp new file mode 100644 index 000000000..0cb9e17a9 --- /dev/null +++ b/include/network/uri/config.hpp @@ -0,0 +1,21 @@ +// Copyright (c) Glyn Matthews 2012. +// 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 __BOOST_NETWORK_URI_CONFIG_INC__ +# define __BOOST_NETWORK_URI_CONFIG_INC__ + + +# include +# include + +# if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_URI_DYN_LINK) +# define BOOST_URI_DECL +# else +# define BOOST_URI_DECL +# endif // defined(BOOST_ALL_DYN_LINK) || defined(BOOST_URI_DYN_LINK) + + +#endif // __BOOST_NETWORK_URI_CONFIG_INC__ diff --git a/include/network/uri/decode.hpp b/include/network/uri/decode.hpp new file mode 100644 index 000000000..78cf098a7 --- /dev/null +++ b/include/network/uri/decode.hpp @@ -0,0 +1,104 @@ +// Copyright (c) Glyn Matthews 2011, 2012. +// 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 __BOOST_NETWORK_URI_DECODE_INC__ +# define __BOOST_NETWORK_URI_DECODE_INC__ + + +# include +# include +# include +# include + + +namespace network { +namespace detail { +template < + typename CharT + > +CharT letter_to_hex(CharT in) +{ + switch (in) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + return in - '0'; + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + return in + 10 - 'a'; + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + return in + 10 - 'A'; + } + return CharT(); +} +} // namespace detail + +template < + class InputIterator, + class OutputIterator + > +OutputIterator decode(const InputIterator &in_begin, + const InputIterator &in_end, + const OutputIterator &out_begin) { + typedef typename boost::iterator_value::type value_type; + + InputIterator it = in_begin; + OutputIterator out = out_begin; + while (it != in_end) { + if (*it == '%') + { + ++it; + value_type v0 = detail::letter_to_hex(*it); + ++it; + value_type v1 = detail::letter_to_hex(*it); + ++it; + *out++ = 0x10 * v0 + v1; + } + else + { + *out++ = *it++; + } + } + return out; +} + +template < + class SinglePassRange, + class OutputIterator + > +inline +OutputIterator decode(const SinglePassRange &range, + const OutputIterator &out) { + return decode(boost::begin(range), boost::end(range), out); +} + +inline +std::string decoded(const std::string &input) { + std::string decoded; + decode(input, std::back_inserter(decoded)); + return decoded; +} +} // namespace network + + +#endif // __BOOST_NETWORK_URI_DECODE_INC__ diff --git a/include/network/uri/detail/uri_parts.hpp b/include/network/uri/detail/uri_parts.hpp new file mode 100644 index 000000000..9293fb860 --- /dev/null +++ b/include/network/uri/detail/uri_parts.hpp @@ -0,0 +1,98 @@ +// Copyright 2009-2012 Dean Michael Berris, Jeroen Habraken, Glyn Matthews. +// 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 BOOST_NETWORK_URL_DETAIL_URL_PARTS_HPP_ +# define BOOST_NETWORK_URL_DETAIL_URL_PARTS_HPP_ + + +# include +# include + +namespace network { +namespace detail { +template < + class FwdIter + > +struct hierarchical_part { + boost::optional > user_info; + boost::optional > host; + boost::optional > port; + boost::optional > path; + + FwdIter begin() const { + return boost::begin(user_info); + } + + FwdIter end() const { + return boost::end(path); + } + + void update() { + if (!user_info) { + if (host) { + user_info = boost::iterator_range(boost::begin(host.get()), + boost::begin(host.get())); + } + else if (path) { + user_info = boost::iterator_range(boost::begin(path.get()), + boost::begin(path.get())); + } + } + + if (!host) { + host = boost::iterator_range(boost::begin(path.get()), + boost::begin(path.get())); + } + + if (!port) { + port = boost::iterator_range(boost::end(host.get()), + boost::end(host.get())); + } + + if (!path) { + path = boost::iterator_range(boost::end(port.get()), + boost::end(port.get())); + } + } + +}; + +template < + class FwdIter + > +struct uri_parts { +boost::iterator_range scheme; + hierarchical_part hier_part; + boost::optional > query; + boost::optional > fragment; + + FwdIter begin() const { + return boost::begin(scheme); + } + + FwdIter end() const { + return boost::end(fragment); + } + + void update() { + + hier_part.update(); + + if (!query) { + query = boost::iterator_range(boost::end(hier_part.path.get()), + boost::end(hier_part.path.get())); + } + + if (!fragment) { + fragment = boost::iterator_range(boost::end(query.get()), + boost::end(query.get())); + } + } +}; +} // namespace detail +} // namespace network + + +#endif // BOOST_NETWORK_URL_DETAIL_URL_PARTS_HPP_ diff --git a/include/network/uri/directives.hpp b/include/network/uri/directives.hpp new file mode 100644 index 000000000..e4558a4d0 --- /dev/null +++ b/include/network/uri/directives.hpp @@ -0,0 +1,44 @@ +// Copyright (c) Glyn Matthews 2011, 2012. +// 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 __BOOST_NETWORK_URI_DIRECTIVES_INC__ +# define __BOOST_NETWORK_URI_DIRECTIVES_INC__ + + +# include + + +namespace network { +inline +uri &operator << (uri &uri_, const uri &root_uri) { + if (boost::empty(uri_) && valid(root_uri)) { + uri_.append(boost::begin(root_uri), boost::end(root_uri)); + } + return uri_; +} + +template < + class Directive + > +inline +uri &operator << (uri &uri_, const Directive &directive) { + directive(uri_); + return uri_; +} +} // namespace network + + +# include +# include +# include +# include +# include +# include +# include +# include + + +#endif // __BOOST_NETWORK_URI_DIRECTIVES_INC__ diff --git a/include/network/uri/directives/authority.hpp b/include/network/uri/directives/authority.hpp new file mode 100644 index 000000000..eab8bffd8 --- /dev/null +++ b/include/network/uri/directives/authority.hpp @@ -0,0 +1,35 @@ +// Copyright (c) Glyn Matthews 2011, 2012. +// 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 __BOOST_NETWORK_URI_DIRECTIVES_AUTHORITY_INC__ +# define __BOOST_NETWORK_URI_DIRECTIVES_AUTHORITY_INC__ + +namespace network { +struct authority_directive { + + explicit authority_directive(const std::string &authority) + : authority(authority) + {} + + template < + class Uri + > + void operator () (Uri &uri) const { + uri.append(authority); + } + + std::string authority; + +}; + +inline +authority_directive authority(const std::string &authority) { + return authority_directive(authority); +} +} // namespace network + + +#endif // __BOOST_NETWORK_URI_DIRECTIVES_AUTHORITY_INC__ diff --git a/include/network/uri/directives/fragment.hpp b/include/network/uri/directives/fragment.hpp new file mode 100644 index 000000000..14ee12d99 --- /dev/null +++ b/include/network/uri/directives/fragment.hpp @@ -0,0 +1,41 @@ +// Copyright (c) Glyn Matthews 2011, 2012. +// 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 __BOOST_NETWORK_URI_DIRECTIVES_FRAGMENT_INC__ +# define __BOOST_NETWORK_URI_DIRECTIVES_FRAGMENT_INC__ + + +# include +# include +# include + +namespace network { +struct fragment_directive { + + explicit fragment_directive(const std::string &fragment) + : fragment(fragment) + {} + + template < + class Uri + > + void operator () (Uri &uri) const { + uri.append("#"); + uri.append(fragment); + } + + std::string fragment; + +}; + +inline +fragment_directive fragment(const std::string &fragment) { + return fragment_directive(fragment); +} +} // namespace network + + +#endif // __BOOST_NETWORK_URI_DIRECTIVES_FRAGMENT_INC__ diff --git a/include/network/uri/directives/host.hpp b/include/network/uri/directives/host.hpp new file mode 100644 index 000000000..9a0e9342b --- /dev/null +++ b/include/network/uri/directives/host.hpp @@ -0,0 +1,40 @@ +// Copyright (c) Glyn Matthews 2011, 2012. +// 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 __BOOST_NETWORK_URI_DIRECTIVES_HOST_INC__ +# define __BOOST_NETWORK_URI_DIRECTIVES_HOST_INC__ + + +# include +# include + + +namespace network { +struct host_directive { + + explicit host_directive(const std::string &host) + : host(host) + {} + + template < + class Uri + > + void operator () (Uri &uri) const { + uri.append(host); + } + + std::string host; + +}; + +inline +host_directive host(const std::string &host) { + return host_directive(host); +} +} // namespace network + + +#endif // __BOOST_NETWORK_URI_DIRECTIVES_HOST_INC__ diff --git a/include/network/uri/directives/path.hpp b/include/network/uri/directives/path.hpp new file mode 100644 index 000000000..7ea5ada0b --- /dev/null +++ b/include/network/uri/directives/path.hpp @@ -0,0 +1,61 @@ +// Copyright (c) Glyn Matthews 2011, 2012. +// 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 __BOOST_NETWORK_URI_DIRECTIVES_PATH_INC__ +# define __BOOST_NETWORK_URI_DIRECTIVES_PATH_INC__ + + +# include +# include + + +namespace network { +struct path_directive { + + explicit path_directive(const std::string &path) + : path(path) + {} + + template < + class Uri + > + void operator () (Uri &uri) const { + uri.append(path); + } + + std::string path; + +}; + +struct encoded_path_directive { + + explicit encoded_path_directive(const std::string &path) + : path(path) + {} + + void operator () (uri &uri_) const { + std::string encoded_path; + encode(path, std::back_inserter(encoded_path)); + uri_.append(encoded_path); + } + + std::string path; + +}; + +inline +path_directive path(const std::string &path) { + return path_directive(path); +} + +inline +encoded_path_directive encoded_path(const std::string &path) { + return encoded_path_directive(path); +} +} // namespace network + + +#endif // __BOOST_NETWORK_URI_DIRECTIVES_PATH_INC__ diff --git a/include/network/uri/directives/port.hpp b/include/network/uri/directives/port.hpp new file mode 100644 index 000000000..672ee7921 --- /dev/null +++ b/include/network/uri/directives/port.hpp @@ -0,0 +1,52 @@ +// Copyright (c) Glyn Matthews 2011, 2012. +// 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 __BOOST_NETWORK_URI_DIRECTIVES_PORT_INC__ +# define __BOOST_NETWORK_URI_DIRECTIVES_PORT_INC__ + + +# include +# include +# include +# include + + +namespace network { +struct port_directive { + + explicit port_directive(const std::string &port) + : port(port) + {} + + explicit port_directive(boost::uint16_t port) + : port(boost::lexical_cast(port)) + {} + + template < + class Uri + > + void operator () (Uri &uri) const { + uri.append(":"); + uri.append(port); + } + + std::string port; + +}; + +inline +port_directive port(const std::string &port) { + return port_directive(port); +} + +inline +port_directive port(boost::uint16_t port) { + return port_directive(port); +} +} // namespace network + + +#endif // __BOOST_NETWORK_URI_DIRECTIVES_PORT_INC__ diff --git a/include/network/uri/directives/query.hpp b/include/network/uri/directives/query.hpp new file mode 100644 index 000000000..a6c20b2d4 --- /dev/null +++ b/include/network/uri/directives/query.hpp @@ -0,0 +1,76 @@ +// Copyright (c) Glyn Matthews 2011, 2012. +// 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 __BOOST_NETWORK_URI_DIRECTIVES_QUERY_INC__ +# define __BOOST_NETWORK_URI_DIRECTIVES_QUERY_INC__ + + +# include +# include +# include + + +namespace network { +struct query_directive { + + explicit query_directive(const std::string &query) + : query(query) + {} + + template < + class Uri + > + void operator () (Uri &uri) const { + uri.append("?"); + uri.append(query); + } + + std::string query; + +}; + +inline +query_directive query(const std::string &query) { + return query_directive(query); +} + +struct query_key_query_directive { + + query_key_query_directive(const std::string &key, const std::string &query) + : key(key), query(query) + {} + + template < + class Uri + > + void operator () (Uri &uri) const { + std::string encoded_key, encoded_query; + if (boost::empty(uri.query())) + { + uri.append("?"); + } + else + { + uri.append("&"); + } + uri.append(key); + uri.append("="); + uri.append(query); + } + + std::string key; + std::string query; + +}; + +inline +query_key_query_directive query(const std::string &key, const std::string &query) { + return query_key_query_directive(key, query); +} +} // namespace network + + +#endif // __BOOST_NETWORK_URI_DIRECTIVES_QUERY_INC__ diff --git a/include/network/uri/directives/scheme.hpp b/include/network/uri/directives/scheme.hpp new file mode 100644 index 000000000..9b4ea23ca --- /dev/null +++ b/include/network/uri/directives/scheme.hpp @@ -0,0 +1,64 @@ +// Copyright (c) Glyn Matthews 2011, 2012. +// 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 __BOOST_NETWORK_URI_DIRECTIVES_SCHEME_INC__ +# define __BOOST_NETWORK_URI_DIRECTIVES_SCHEME_INC__ + + +# include +# include +# include + + +namespace network { +struct scheme_directive { + + explicit scheme_directive(const std::string &scheme) + : scheme(scheme) + {} + + template < + class Uri + > + void operator () (Uri &uri) const { + uri.append(scheme); + if (opaque_schemes::exists(scheme)) { + uri.append(":"); + } + else { + uri.append("://"); + } + } + + std::string scheme; + +}; + +inline +scheme_directive scheme(const std::string &scheme) { + return scheme_directive(scheme); +} + +namespace schemes { +inline +uri &http(uri &uri_) { + return uri_ << scheme("http"); +} + +inline +uri &https(uri &uri_) { + return uri_ << scheme("https"); +} + +inline +uri &file(uri &uri_) { + return uri_ << scheme("file"); +} +} // namespace schemes +} // namespace network + + +#endif // __BOOST_NETWORK_URI_DIRECTIVES_SCHEME_INC__ diff --git a/include/network/uri/directives/user_info.hpp b/include/network/uri/directives/user_info.hpp new file mode 100644 index 000000000..9969e63f9 --- /dev/null +++ b/include/network/uri/directives/user_info.hpp @@ -0,0 +1,41 @@ +// Copyright (c) Glyn Matthews 2011, 2012. +// 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 __BOOST_NETWORK_URI_DIRECTIVES_USER_INFO_INC__ +# define __BOOST_NETWORK_URI_DIRECTIVES_USER_INFO_INC__ + + +# include +# include + + +namespace network { +struct user_info_directive { + + explicit user_info_directive(const std::string &user_info) + : user_info(user_info) + {} + + template < + class Uri + > + void operator () (Uri &uri) const { + uri.append(user_info); + uri.append("@"); + } + + std::string user_info; + +}; + +inline +user_info_directive user_info(const std::string &user_info) { + return user_info_directive(user_info); +} +} // namespace network + + +#endif // __BOOST_NETWORK_URI_DIRECTIVES_USER_INFO_INC__ diff --git a/include/network/uri/encode.hpp b/include/network/uri/encode.hpp new file mode 100644 index 000000000..3d0945781 --- /dev/null +++ b/include/network/uri/encode.hpp @@ -0,0 +1,172 @@ +// Copyright (c) Glyn Matthews 2011, 2012. +// 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 __BOOST_NETWORK_URI_ENCODE_INC__ +# define __BOOST_NETWORK_URI_ENCODE_INC__ + + +# include +# include +# include +# include +# include + + +namespace network { +namespace detail { +template < + typename CharT + > +inline +CharT hex_to_letter(CharT in) { + switch (in) + { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + return in + '0'; + case 10: + case 11: + case 12: + case 13: + case 14: + default: + return in - 10 + 'A'; + } + return CharT(); +} + + +template < + typename CharT, + class OutputIterator + > +void encode_char(CharT in, OutputIterator &out) { + switch (in) + { + case 'a': + case 'A': + case 'b': + case 'B': + case 'c': + case 'C': + case 'd': + case 'D': + case 'e': + case 'E': + case 'f': + case 'F': + case 'g': + case 'G': + case 'h': + case 'H': + case 'i': + case 'I': + case 'j': + case 'J': + case 'k': + case 'K': + case 'l': + case 'L': + case 'm': + case 'M': + case 'n': + case 'N': + case 'o': + case 'O': + case 'p': + case 'P': + case 'q': + case 'Q': + case 'r': + case 'R': + case 's': + case 'S': + case 't': + case 'T': + case 'u': + case 'U': + case 'v': + case 'V': + case 'w': + case 'W': + case 'x': + case 'X': + case 'y': + case 'Y': + case 'z': + case 'Z': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case '-': + case '.': + case '_': + case '~': + case '/': + out++ = in; + break; + default: + out++ = '%'; + out++ = hex_to_letter(in >> 4); + out++ = hex_to_letter(in & 0x0f); + ; + } +} +} // namespace detail + +template < + class InputIterator, + class OutputIterator + > +OutputIterator encode(const InputIterator &in_begin, + const InputIterator &in_end, + const OutputIterator &out_begin) { + typedef typename boost::iterator_value::type value_type; + + InputIterator it = in_begin; + OutputIterator out = out_begin; + while (it != in_end) { + detail::encode_char(*it, out); + ++it; + } + return out; +} + +template < + class SinglePassRange, + class OutputIterator + > +inline +OutputIterator encode(const SinglePassRange &range, + const OutputIterator &out) { + return encode(boost::begin(range), boost::end(range), out); +} + +inline +std::string encoded(const std::string &input) { + std::string encoded; + encode(input, std::back_inserter(encoded)); + return encoded; +} +} // namespace network + + +#endif // __BOOST_NETWORK_URI_ENCODE_INC__ diff --git a/include/network/uri/schemes.hpp b/include/network/uri/schemes.hpp new file mode 100644 index 000000000..10bb3bce4 --- /dev/null +++ b/include/network/uri/schemes.hpp @@ -0,0 +1,33 @@ +// Copyright 2012 Glyn Matthews. +// 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 __BOOST_NETWORK_URI_SCHEMES_INC__ +# define __BOOST_NETWORK_URI_SCHEMES_INC__ + + +#include + + +namespace network { +class hierarchical_schemes { + +public: + + static bool exists(const std::string &scheme); + +}; + +class opaque_schemes { + +public: + + static bool exists(const std::string &scheme); + +}; +} // namespace network + + +#endif // __BOOST_NETWORK_URI_SCHEMES_INC__ diff --git a/include/network/uri/uri.hpp b/include/network/uri/uri.hpp new file mode 100644 index 000000000..332cbeae2 --- /dev/null +++ b/include/network/uri/uri.hpp @@ -0,0 +1,421 @@ +// Copyright 2009-2012 Dean Michael Berris, Jeroen Habraken, Glyn Matthews. +// 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 __BOOST_NETWORK_URI_INC__ +# define __BOOST_NETWORK_URI_INC__ + +# pragma once + +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include + +namespace network { +namespace detail { +bool parse(std::string::const_iterator first, + std::string::const_iterator last, + uri_parts &parts); +} // namespace detail + + +class BOOST_URI_DECL uri { + + friend class builder; + +public: + + typedef std::string string_type; + typedef string_type::value_type value_type; + typedef string_type::const_iterator const_iterator; + typedef boost::iterator_range const_range_type; + + uri() + : is_valid_(false) { + + } + + //uri(const value_type *uri) + // : uri_(uri), is_valid_(false) { + // parse(); + //} + + uri(const string_type &uri) + : uri_(uri), is_valid_(false) { + parse(); + } + + template < + class FwdIter + > + uri(const FwdIter &first, const FwdIter &last) + : uri_(first, last), is_valid_(false) { + parse(); + } + + uri(const uri &other) + : uri_(other.uri_) { + parse(); + } + + uri &operator = (const uri &other) { + uri(other).swap(*this); + return *this; + } + + uri &operator = (const string_type &uri_string) { + uri(uri_string).swap(*this); + return *this; + } + + ~uri() { + + } + + void swap(uri &other) { + boost::swap(uri_, other.uri_); + boost::swap(uri_parts_, other.uri_parts_); + boost::swap(is_valid_, other.is_valid_); + } + + const_iterator begin() const { + return uri_.begin(); + } + + const_iterator end() const { + return uri_.end(); + } + + const_range_type scheme_range() const { + return uri_parts_.scheme; + } + + const_range_type user_info_range() const { + return uri_parts_.hier_part.user_info? + uri_parts_.hier_part.user_info.get() : + const_range_type(); + } + + const_range_type host_range() const { + return uri_parts_.hier_part.host? + uri_parts_.hier_part.host.get() : + const_range_type(); + } + + const_range_type port_range() const { + return uri_parts_.hier_part.port? + uri_parts_.hier_part.port.get() : + const_range_type(); + } + + const_range_type path_range() const { + return uri_parts_.hier_part.path? + uri_parts_.hier_part.path.get() : + const_range_type(); + } + + const_range_type query_range() const { + return uri_parts_.query ? + uri_parts_.query.get() : + const_range_type(); + } + + const_range_type fragment_range() const { + return uri_parts_.fragment? + uri_parts_.fragment.get() : + const_range_type(); + } + + string_type scheme() const { + const_range_type range = scheme_range(); + return range? string_type(boost::begin(range), boost::end(range)) : string_type(); + } + + string_type user_info() const { + const_range_type range = user_info_range(); + return range? string_type(boost::begin(range), boost::end(range)) : string_type(); + } + + string_type host() const { + const_range_type range = host_range(); + return range? string_type(boost::begin(range), boost::end(range)) : string_type(); + } + + string_type port() const { + const_range_type range = port_range(); + return range? string_type(boost::begin(range), boost::end(range)) : string_type(); + } + + string_type path() const { + const_range_type range = path_range(); + return range? string_type(boost::begin(range), boost::end(range)) : string_type(); + } + + string_type query() const { + const_range_type range = query_range(); + return range? string_type(boost::begin(range), boost::end(range)) : string_type(); + } + + string_type fragment() const { + const_range_type range = fragment_range(); + return range? string_type(boost::begin(range), boost::end(range)) : string_type(); + } + + string_type string() const { + return uri_; + } + + bool is_valid() const { + return is_valid_; + } + + void append(const string_type &data) { + uri_.append(data); + parse(); + } + + template < + class FwdIter + > + void append(const FwdIter &first, const FwdIter &last) { + uri_.append(first, last); + parse(); + } + +private: + + void parse(); + + string_type uri_; + detail::uri_parts uri_parts_; + bool is_valid_; + +}; + +inline +void uri::parse() { + const_iterator first(boost::begin(uri_)), last(boost::end(uri_)); + is_valid_ = detail::parse(first, last, uri_parts_); + if (is_valid_) { + if (!uri_parts_.scheme) { + uri_parts_.scheme = const_range_type(boost::begin(uri_), + boost::begin(uri_)); + } + uri_parts_.update(); + } +} + +inline +uri::string_type scheme(const uri &uri_) { + return uri_.scheme(); +} + +inline +uri::string_type user_info(const uri &uri_) { + return uri_.user_info(); +} + +inline +uri::string_type host(const uri &uri_) { + return uri_.host(); +} + +inline +uri::string_type port(const uri &uri_) { + return uri_.port(); +} + +inline +boost::optional port_us(const uri &uri_) { + uri::string_type port = uri_.port(); + return (port.empty())? + boost::optional() : + boost::optional(boost::lexical_cast(port)); +} + +inline +uri::string_type path(const uri &uri_) { + return uri_.path(); +} + +inline +uri::string_type query(const uri &uri_) { + return uri_.query(); +} + +inline +uri::string_type fragment(const uri &uri_) { + return uri_.fragment(); +} + +inline +uri::string_type hierarchical_part(const uri &uri_) { + return uri::string_type(boost::begin(uri_.user_info_range()), + boost::end(uri_.path_range())); +} + +inline +uri::string_type authority(const uri &uri_) { + return uri::string_type(boost::begin(uri_.user_info_range()), + boost::end(uri_.port_range())); +} + +inline +bool valid(const uri &uri_) { + return uri_.is_valid(); +} + +inline +bool is_absolute(const uri &uri_) { + return uri_.is_valid() && !boost::empty(uri_.scheme_range()); +} + +inline +bool is_relative(const uri &uri_) { + return uri_.is_valid() && boost::empty(uri_.scheme_range()); +} + +inline +bool is_hierarchical(const uri &uri_) { + return is_absolute(uri_) && hierarchical_schemes::exists(scheme(uri_)); +} + +inline +bool is_opaque(const uri &uri_) { + return is_absolute(uri_) && opaque_schemes::exists(scheme(uri_)); +} + +inline +bool is_valid(const uri &uri_) { + return valid(uri_); +} + +inline +void swap(uri &lhs, uri &rhs) { + lhs.swap(rhs); +} + +inline +std::size_t hash_value(const uri &uri_) +{ + std::size_t seed = 0; + for (uri::const_iterator it = boost::begin(uri_); it != boost::end(uri_); ++it) { + boost::hash_combine(seed, *it); + } + return seed; +} + +inline +bool operator == (const uri &lhs, const uri &rhs) { + return boost::equal(lhs, rhs); +} + +inline +bool operator == (const uri &lhs, const uri::string_type &rhs) { + return boost::equal(lhs, rhs); +} + +inline +bool operator == (const uri::string_type &lhs, const uri &rhs) { + return boost::equal(lhs, rhs); +} + +inline +bool operator == (const uri &lhs, const uri::value_type *rhs) { + return boost::equal(lhs, boost::as_literal(rhs)); +} + +inline +bool operator == (const uri::value_type *lhs, const uri &rhs) { + return boost::equal(boost::as_literal(lhs), rhs); +} + +inline +bool operator != (const uri &lhs, const uri &rhs) { + return !(lhs == rhs); +} + +inline +bool operator < (const uri &lhs, const uri &rhs) { + return lhs.string() < rhs.string(); +} +} // namespace network + +# include +# include +# include + + +namespace network { +inline +uri from_parts(const uri &base_uri, + const uri::string_type &path_, + const uri::string_type &query_, + const uri::string_type &fragment_) { + uri uri_(base_uri); + builder(uri_).path(path_).query(query_).fragment(fragment_); + return uri_; +} + +inline +uri from_parts(const uri &base_uri, + const uri::string_type &path_, + const uri::string_type &query_) { + uri uri_(base_uri); + builder(uri_).path(path_).query(query_); + return uri_; +} + +inline +uri from_parts(const uri &base_uri, + const uri::string_type &path_) { + uri uri_(base_uri); + builder(uri_).path(path_); + return uri_; +} + +inline +uri from_parts(const uri::string_type &base_uri, + const uri::string_type &path, + const uri::string_type &query, + const uri::string_type &fragment) { + return from_parts(uri(base_uri), path, query, fragment); +} + +inline +uri from_parts(const uri::string_type &base_uri, + const uri::string_type &path, + const uri::string_type &query) { + return from_parts(uri(base_uri), path, query); +} + +inline +uri from_parts(const uri::string_type &base_uri, + const uri::string_type &path) { + return from_parts(uri(base_uri), path); +} +} // namespace network + +# include + +namespace network { +inline +uri from_file(const boost::filesystem::path &path_) { + uri uri_; + builder(uri_).scheme("file").path(path_.string()); + return uri_; +} +} // namespace network + + +#endif // __BOOST_NETWORK_URI_INC__ diff --git a/include/network/uri/uri.ipp b/include/network/uri/uri.ipp new file mode 100644 index 000000000..38bcf53f6 --- /dev/null +++ b/include/network/uri/uri.ipp @@ -0,0 +1,235 @@ +// Copyright 2009-2012 Dean Michael Berris, Jeroen Habraken, Glyn Matthews. +// 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) + + +#include +#include +#include +#include + +BOOST_FUSION_ADAPT_TPL_STRUCT +( + (FwdIter), + (network::detail::hierarchical_part)(FwdIter), + (boost::optional >, user_info) + (boost::optional >, host) + (boost::optional >, port) + (boost::optional >, path) + ); + +BOOST_FUSION_ADAPT_TPL_STRUCT +( + (FwdIter), + (network::detail::uri_parts)(FwdIter), + (boost::iterator_range, scheme) + (network::detail::hierarchical_part, hier_part) + (boost::optional >, query) + (boost::optional >, fragment) + ); + +namespace network { +namespace detail { +namespace qi = boost::spirit::qi; + +template < + class String + > +struct uri_grammar : qi::grammar< + typename String::const_iterator + , detail::uri_parts()> { + + typedef String string_type; + typedef typename String::const_iterator const_iterator; + + uri_grammar() : uri_grammar::base_type(start, "uri") { + // gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@" + gen_delims %= qi::char_(":/?#[]@"); + // sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "=" + sub_delims %= qi::char_("!$&'()*+,;="); + // reserved = gen-delims / sub-delims + reserved %= gen_delims | sub_delims; + // unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" + unreserved %= qi::alnum | qi::char_("-._~"); + // pct-encoded = "%" HEXDIG HEXDIG + pct_encoded %= qi::char_("%") >> qi::repeat(2)[qi::xdigit]; + + // pchar = unreserved / pct-encoded / sub-delims / ":" / "@" + pchar %= qi::raw[ + unreserved | pct_encoded | sub_delims | qi::char_(":@") + ]; + + // segment = *pchar + segment %= qi::raw[*pchar]; + // segment-nz = 1*pchar + segment_nz %= qi::raw[+pchar]; + // segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" ) + segment_nz_nc %= qi::raw[ + +(unreserved | pct_encoded | sub_delims | qi::char_("@")) + ]; + // path-abempty = *( "/" segment ) + path_abempty %= + qi::raw[*(qi::char_("/") >> segment)] + ; + // path-absolute = "/" [ segment-nz *( "/" segment ) ] + path_absolute %= + qi::raw[ + qi::char_("/") + >> -(segment_nz >> *(qi::char_("/") >> segment)) + ] + ; + // path-rootless = segment-nz *( "/" segment ) + path_rootless %= + qi::raw[segment_nz >> *(qi::char_("/") >> segment)] + ; + // path-empty = 0 + path_empty %= + qi::raw[qi::eps] + ; + + // scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) + scheme %= + qi::raw[qi::alpha >> *(qi::alnum | qi::char_("+.-"))] + ; + + // user_info = *( unreserved / pct-encoded / sub-delims / ":" ) + user_info %= + qi::raw[*(unreserved | pct_encoded | sub_delims | qi::char_(":"))] + ; + + ip_literal %= + qi::lit('[') >> (ipv6address | ipvfuture) >> ']' + ; + + ipvfuture %= + qi::lit('v') >> +qi::xdigit >> '.' >> +( unreserved | sub_delims | ':') + ; + + ipv6address %= qi::raw[ + qi::repeat(6)[h16 >> ':'] >> ls32 + | "::" >> qi::repeat(5)[h16 >> ':'] >> ls32 + | qi::raw[ h16] >> "::" >> qi::repeat(4)[h16 >> ':'] >> ls32 + | qi::raw[ +(*(h16 >> ':')) >> h16] >> "::" >> qi::repeat(3)[h16 >> ':'] >> ls32 + | qi::raw[qi::repeat(2)[*(h16 >> ':')] >> h16] >> "::" >> qi::repeat(2)[h16 >> ':'] >> ls32 + | qi::raw[qi::repeat(3)[*(h16 >> ':')] >> h16] >> "::" >> h16 >> ':' >> ls32 + | qi::raw[qi::repeat(4)[*(h16 >> ':')] >> h16] >> "::" >> ls32 + | qi::raw[qi::repeat(5)[*(h16 >> ':')] >> h16] >> "::" >> h16 + | qi::raw[qi::repeat(6)[*(h16 >> ':')] >> h16] >> "::" + ]; + + // ls32 = ( h16 ":" h16 ) / IPv4address + ls32 %= (h16 >> ':' >> h16) | ipv4address + ; + + // h16 = 1*4HEXDIG + h16 %= qi::repeat(1, 4)[qi::xdigit] + ; + + // dec-octet = DIGIT / %x31-39 DIGIT / "1" 2DIGIT / "2" %x30-34 DIGIT / "25" %x30-35 + dec_octet %= + !(qi::lit('0') >> qi::digit) + >> qi::raw[ + qi::uint_parser() + ]; + + // IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet + ipv4address %= qi::raw[ + dec_octet >> qi::repeat(3)[qi::lit('.') >> dec_octet] + ]; + + // reg-name = *( unreserved / pct-encoded / sub-delims ) + reg_name %= qi::raw[ + *(unreserved | pct_encoded | sub_delims) + ]; + + // TODO, host = IP-literal / IPv4address / reg-name + host %= + qi::raw[ip_literal | ipv4address | reg_name] + ; + + // port %= qi::ushort_; + port %= + qi::raw[*qi::digit] + ; + + // query = *( pchar / "/" / "?" ) + query %= + qi::raw[*(pchar | qi::char_("/?"))] + ; + + // fragment = *( pchar / "/" / "?" ) + fragment %= + qi::raw[*(pchar | qi::char_("/?"))] + ; + + // hier-part = "//" authority path-abempty / path-absolute / path-rootless / path-empty + // authority = [ userinfo "@" ] host [ ":" port ] + hier_part %= + ( + (("//" >> user_info >> '@') | "//") + >> host + >> -(':' >> port) + >> path_abempty + ) + | + ( + qi::attr(boost::iterator_range()) + >> qi::attr(boost::iterator_range()) + >> qi::attr(boost::iterator_range()) + >> ( + path_absolute + | path_rootless + | path_empty + ) + ) + ; + + start %= + (scheme >> ':') + >> hier_part + >> -('?' >> query) + >> -('#' >> fragment) + ; + } + + qi::rule::value_type()> + gen_delims, sub_delims, reserved, unreserved; + qi::rule + pct_encoded, pchar; + + qi::rule + segment, segment_nz, segment_nz_nc; + qi::rule()> + path_abempty, path_absolute, path_rootless, path_empty; + + qi::rule + dec_octet, ipv4address, reg_name, ipv6address, ipvfuture, ip_literal; + + qi::rule + h16, ls32; + + qi::rule()> + host, port; + + qi::rule()> + scheme, user_info, query, fragment; + + qi::rule()> + hier_part; + + // actual uri parser + qi::rule()> start; + +}; + +bool parse(std::string::const_iterator first, + std::string::const_iterator last, + uri_parts &parts) { + namespace qi = boost::spirit::qi; + static detail::uri_grammar grammar; + bool is_valid = qi::parse(first, last, grammar, parts); + return is_valid && (first == last); +} +} // namespace detail +} // namespace network diff --git a/include/network/uri/uri_io.hpp b/include/network/uri/uri_io.hpp new file mode 100644 index 000000000..e06c03143 --- /dev/null +++ b/include/network/uri/uri_io.hpp @@ -0,0 +1,22 @@ +// Copyright (c) Glyn Matthews 2011, 2012. +// 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 __BOOST_NETWORK_URI_URI_IO_INC__ +# define __BOOST_NETWORK_URI_URI_IO_INC__ + + +# include + + +namespace network { +inline +std::ostream &operator << (std::ostream &os, const uri &uri_) { + return os << uri_.string(); +} +} // namespace network + + +#endif // __BOOST_NETWORK_URI_URI_IO_INC__ diff --git a/libs/network/src/CMakeLists.txt b/libs/network/src/CMakeLists.txt index 2722a5542..d78ee860e 100644 --- a/libs/network/src/CMakeLists.txt +++ b/libs/network/src/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Glyn Matthews 2011. +# Copyright (c) Glyn Matthews 2011, 2012. # Copyright 2011 Dean Michael Berris (dberris@google.com) # Copyright 2011 Google, Inc. # Distributed under the Boost Software License, Version 1.0. @@ -6,7 +6,7 @@ # http://www.boost.org/LICENSE_1_0.txt) -include_directories(${CPP-NETLIB_SOURCE_DIR}) +include_directories(${CPP-NETLIB_SOURCE_DIR}/include) set(CPP-NETLIB_URI_SRCS uri/uri.cpp uri/schemes.cpp) add_library(cppnetlib-uri ${CPP-NETLIB_URI_SRCS}) diff --git a/libs/network/src/uri/schemes.cpp b/libs/network/src/uri/schemes.cpp index e0b671196..c03eac06e 100644 --- a/libs/network/src/uri/schemes.cpp +++ b/libs/network/src/uri/schemes.cpp @@ -4,13 +4,11 @@ // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include -namespace boost { namespace network { -namespace uri { namespace { static boost::unordered_set hierarchical_schemes_; static boost::unordered_set opaque_schemes_; @@ -58,6 +56,4 @@ bool hierarchical_schemes::exists(const std::string &scheme) { bool opaque_schemes::exists(const std::string &scheme) { return opaque_schemes_.end() != opaque_schemes_.find(scheme); } -} // namespace uri } // namespace network -} // namespace boost diff --git a/libs/network/src/uri/uri.cpp b/libs/network/src/uri/uri.cpp index 613bcb1fa..edfca04dc 100644 --- a/libs/network/src/uri/uri.cpp +++ b/libs/network/src/uri/uri.cpp @@ -4,4 +4,4 @@ // http://www.boost.org/LICENSE_1_0.txt) -#include +#include diff --git a/libs/network/test/uri/CMakeLists.txt b/libs/network/test/uri/CMakeLists.txt index ad899b1e7..2b94e9093 100644 --- a/libs/network/test/uri/CMakeLists.txt +++ b/libs/network/test/uri/CMakeLists.txt @@ -1,9 +1,10 @@ # Copyright (c) Dean Michael Berris 2010. +# Copyright (c) Glyn Matthews 2011, 2012. # 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) -include_directories(${CPP-NETLIB_SOURCE_DIR}) +include_directories(${CPP-NETLIB_SOURCE_DIR}/include) if (Boost_FOUND) set( diff --git a/libs/network/test/uri/uri_builder_stream_test.cpp b/libs/network/test/uri/uri_builder_stream_test.cpp index cf8f7660e..5899a3b51 100644 --- a/libs/network/test/uri/uri_builder_stream_test.cpp +++ b/libs/network/test/uri/uri_builder_stream_test.cpp @@ -6,109 +6,106 @@ #define BOOST_TEST_MODULE URI builder stream test #include #include -#include -#include -#include - - -using namespace boost::network; +#include +#include +#include BOOST_AUTO_TEST_CASE(builder_test) { - uri::uri instance; - instance << uri::scheme("http") << uri::host("www.example.com") << uri::path("/"); - BOOST_REQUIRE(uri::valid(instance)); + network::uri instance; + instance << network::scheme("http") << network::host("www.example.com") << network::path("/"); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK_EQUAL("http://www.example.com/", instance.string()); } BOOST_AUTO_TEST_CASE(full_uri_builder_test) { - uri::uri instance; - instance << uri::scheme("http") - << uri::user_info("user:password") - << uri::host("www.example.com") - << uri::port("80") - << uri::path("/path") - << uri::query("query") - << uri::fragment("fragment") + network::uri instance; + instance << network::scheme("http") + << network::user_info("user:password") + << network::host("www.example.com") + << network::port("80") + << network::path("/path") + << network::query("query") + << network::fragment("fragment") ; - BOOST_REQUIRE(uri::valid(instance)); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK_EQUAL("http://user:password@www.example.com/path?query#fragment", instance.string()); } BOOST_AUTO_TEST_CASE(port_test) { - uri::uri instance; - instance << uri::scheme("http") << uri::host("www.example.com") << uri::port(8000) << uri::path("/"); - BOOST_REQUIRE(uri::valid(instance)); + network::uri instance; + instance << network::scheme("http") << network::host("www.example.com") << network::port(8000) << network::path("/"); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK_EQUAL("http://www.example.com:8000/", instance.string()); } BOOST_AUTO_TEST_CASE(encoded_path_test) { - uri::uri instance; - instance << uri::scheme("http") - << uri::host("www.example.com") - << uri::port(8000) - << uri::encoded_path("/Path With (Some) Encoded Characters!") + network::uri instance; + instance << network::scheme("http") + << network::host("www.example.com") + << network::port(8000) + << network::encoded_path("/Path With (Some) Encoded Characters!") ; ; - BOOST_REQUIRE(uri::valid(instance)); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK_EQUAL("http://www.example.com:8000/Path%20With%20%28Some%29%20Encoded%20Characters%21", instance.string()); } BOOST_AUTO_TEST_CASE(query_test) { - uri::uri instance; - instance << uri::scheme("http") << uri::host("www.example.com") << uri::path("/") - << uri::query("key", "value") + network::uri instance; + instance << network::scheme("http") << network::host("www.example.com") << network::path("/") + << network::query("key", "value") ; - BOOST_REQUIRE(uri::valid(instance)); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK_EQUAL("http://www.example.com/?key=value", instance.string()); } BOOST_AUTO_TEST_CASE(query_2_test) { - uri::uri instance; - instance << uri::scheme("http") << uri::host("www.example.com") << uri::path("/") - << uri::query("key1", "value1") << uri::query("key2", "value2") + network::uri instance; + instance << network::scheme("http") << network::host("www.example.com") << network::path("/") + << network::query("key1", "value1") << network::query("key2", "value2") ; - BOOST_REQUIRE(uri::valid(instance)); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK_EQUAL("http://www.example.com/?key1=value1&key2=value2", instance.string()); } BOOST_AUTO_TEST_CASE(fragment_test) { - uri::uri instance; - instance << uri::scheme("http") << uri::host("www.example.com") << uri::path("/") << uri::fragment("fragment"); - BOOST_REQUIRE(uri::valid(instance)); + network::uri instance; + instance << network::scheme("http") << network::host("www.example.com") << network::path("/") << network::fragment("fragment"); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK_EQUAL("http://www.example.com/#fragment", instance.string()); } BOOST_AUTO_TEST_CASE(from_base_test) { - uri::uri base_uri("http://www.example.com/"); - uri::uri instance; - instance << base_uri << uri::path("/") << uri::fragment("fragment"); - BOOST_REQUIRE(uri::valid(instance)); + network::uri base_uri("http://www.example.com/"); + network::uri instance; + instance << base_uri << network::path("/") << network::fragment("fragment"); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK_EQUAL("http://www.example.com/#fragment", instance.string()); } BOOST_AUTO_TEST_CASE(scheme_http_test) { - uri::uri instance; - instance << uri::schemes::http << uri::host("www.example.com") << uri::path("/"); - BOOST_REQUIRE(uri::valid(instance)); + network::uri instance; + instance << network::schemes::http << network::host("www.example.com") << network::path("/"); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK_EQUAL("http://www.example.com/", instance.string()); } BOOST_AUTO_TEST_CASE(scheme_https_test) { - uri::uri instance; - instance << uri::schemes::https << uri::host("www.example.com") << uri::path("/"); - BOOST_REQUIRE(uri::valid(instance)); + network::uri instance; + instance << network::schemes::https << network::host("www.example.com") << network::path("/"); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK_EQUAL("https://www.example.com/", instance.string()); } @@ -116,19 +113,19 @@ BOOST_AUTO_TEST_CASE(encoded_null_char_test) { // there is a potential bug in the way we process ranges if the // strings are null terminated. - uri::uri instance; - instance << uri::scheme("http") - << uri::host("www.example.com") - << uri::encoded_path("/") + network::uri instance; + instance << network::scheme("http") + << network::host("www.example.com") + << network::encoded_path("/") ; - BOOST_REQUIRE(uri::valid(instance)); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK_EQUAL("http://www.example.com/", instance.string()); } BOOST_AUTO_TEST_CASE(mailto_builder_test) { - uri::uri instance; - instance << uri::scheme("mailto") << uri::path("cpp-netlib@example.com"); - BOOST_REQUIRE(uri::valid(instance)); + network::uri instance; + instance << network::scheme("mailto") << network::path("cpp-netlib@example.com"); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK_EQUAL("mailto:cpp-netlib@example.com", instance.string()); } diff --git a/libs/network/test/uri/uri_builder_test.cpp b/libs/network/test/uri/uri_builder_test.cpp index 3d864d50f..cb17f5bce 100644 --- a/libs/network/test/uri/uri_builder_test.cpp +++ b/libs/network/test/uri/uri_builder_test.cpp @@ -6,30 +6,27 @@ #define BOOST_TEST_MODULE URI builder test #include #include -#include -#include - - -using namespace boost::network; +#include +#include BOOST_AUTO_TEST_CASE(builder_test) { - uri::uri instance; - uri::builder builder(instance); + network::uri instance; + network::builder builder(instance); builder .scheme("http") .host("www.example.com") .path("/") ; - BOOST_REQUIRE(uri::valid(instance)); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK_EQUAL("http://www.example.com/", instance.string()); } BOOST_AUTO_TEST_CASE(full_uri_builder_test) { - uri::uri instance; - uri::builder builder(instance); + network::uri instance; + network::builder builder(instance); builder .scheme("http") .user_info("user:password") @@ -39,50 +36,50 @@ BOOST_AUTO_TEST_CASE(full_uri_builder_test) .query("query") .fragment("fragment") ; - BOOST_REQUIRE(uri::valid(instance)); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK_EQUAL("http://user:password@www.example.com/path?query#fragment", instance.string()); } BOOST_AUTO_TEST_CASE(port_test) { - uri::uri instance; - uri::builder(instance).scheme("http").host("www.example.com").port(8000).path("/"); - BOOST_REQUIRE(uri::valid(instance)); + network::uri instance; + network::builder(instance).scheme("http").host("www.example.com").port(8000).path("/"); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK_EQUAL("http://www.example.com:8000/", instance.string()); } BOOST_AUTO_TEST_CASE(encoded_path_test) { - uri::uri instance; - uri::builder builder(instance); + network::uri instance; + network::builder builder(instance); builder .scheme("http") .host("www.example.com") .port(8000) .encoded_path("/Path With (Some) Encoded Characters!") ; - BOOST_REQUIRE(uri::valid(instance)); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK_EQUAL("http://www.example.com:8000/Path%20With%20%28Some%29%20Encoded%20Characters%21", instance.string()); } BOOST_AUTO_TEST_CASE(query_test) { - uri::uri instance; - uri::builder builder(instance); + network::uri instance; + network::builder builder(instance); builder .scheme("http") .host("www.example.com") .path("/") .query("key", "value") ; - BOOST_REQUIRE(uri::valid(instance)); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK_EQUAL("http://www.example.com/?key=value", instance.string()); } BOOST_AUTO_TEST_CASE(query_2_test) { - uri::uri instance; - uri::builder builder(instance); + network::uri instance; + network::builder builder(instance); builder .scheme("http") .host("www.example.com") @@ -90,33 +87,33 @@ BOOST_AUTO_TEST_CASE(query_2_test) .query("key1", "value1") .query("key2", "value2") ; - BOOST_REQUIRE(uri::valid(instance)); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK_EQUAL("http://www.example.com/?key1=value1&key2=value2", instance.string()); } BOOST_AUTO_TEST_CASE(fragment_test) { - uri::uri instance; - uri::builder builder(instance); + network::uri instance; + network::builder builder(instance); builder .scheme("http") .host("www.example.com") .path("/") .fragment("fragment") ; - BOOST_REQUIRE(uri::valid(instance)); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK_EQUAL("http://www.example.com/#fragment", instance.string()); } BOOST_AUTO_TEST_CASE(from_base_test) { - uri::uri instance("http://www.example.com/"); - uri::builder builder(instance); + network::uri instance("http://www.example.com/"); + network::builder builder(instance); builder .path("/") .fragment("fragment") ; - BOOST_REQUIRE(uri::valid(instance)); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK_EQUAL("http://www.example.com/#fragment", instance.string()); } @@ -124,51 +121,51 @@ BOOST_AUTO_TEST_CASE(encoded_null_char_test) { // there is a potential bug in the way we process ranges if the // strings are null terminated. - uri::uri instance; - uri::builder builder(instance); + network::uri instance; + network::builder builder(instance); builder .scheme("http") .host("www.example.com") .encoded_path("/") ; - BOOST_REQUIRE(uri::valid(instance)); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK_EQUAL("http://www.example.com/", instance.string()); } BOOST_AUTO_TEST_CASE(mailto_builder_test) { - uri::uri instance; - uri::builder builder(instance); + network::uri instance; + network::builder builder(instance); builder .scheme("mailto") .path("cpp-netlib@example.com") ; - BOOST_REQUIRE(uri::valid(instance)); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK_EQUAL("mailto:cpp-netlib@example.com", instance.string()); } BOOST_AUTO_TEST_CASE(ipv4_address) { using namespace boost::asio::ip; - uri::uri instance; - uri::builder builder(instance); + network::uri instance; + network::builder builder(instance); builder .scheme("http") .host(address_v4::loopback()) .path("/") ; - BOOST_REQUIRE(uri::valid(instance)); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK_EQUAL("http://127.0.0.1/", instance.string()); } //BOOST_AUTO_TEST_CASE(ipv6_address) { // using namespace boost::asio::ip; -// uri::uri instance; -// uri::builder builder(instance); +// network::uri instance; +// network::builder builder(instance); // builder // .scheme("http") // .host(address_v6::loopback()) // .path("/") // ; -// BOOST_REQUIRE(uri::valid(instance)); +// BOOST_REQUIRE(network::valid(instance)); // BOOST_CHECK_EQUAL("http://[::1]/", instance.string()); //} diff --git a/libs/network/test/uri/uri_encoding_test.cpp b/libs/network/test/uri/uri_encoding_test.cpp index 6ca37939b..bc184006b 100644 --- a/libs/network/test/uri/uri_encoding_test.cpp +++ b/libs/network/test/uri/uri_encoding_test.cpp @@ -1,25 +1,22 @@ -// Copyright (c) Glyn Matthews 2011. +// Copyright (c) Glyn Matthews 2011, 2012. // 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) -#define BOOST_TEST_MODULE URL encoding test +#define BOOST_TEST_MODULE URI encoding test #include #include -#include -#include +#include +#include #include -using namespace boost::network; - - BOOST_AUTO_TEST_CASE(encoding_test) { const std::string unencoded(" !\"#$%&\'()*"); const std::string encoded("%20%21%22%23%24%25%26%27%28%29%2A"); std::string instance; - uri::encode(unencoded, std::back_inserter(instance)); + network::encode(unencoded, std::back_inserter(instance)); BOOST_CHECK_EQUAL(instance, encoded); } @@ -28,6 +25,6 @@ BOOST_AUTO_TEST_CASE(decoding_test) { const std::string encoded("%20%21%22%23%24%25%26%27%28%29%2A"); std::string instance; - uri::decode(encoded, std::back_inserter(instance)); + network::decode(encoded, std::back_inserter(instance)); BOOST_CHECK_EQUAL(instance, unencoded); } diff --git a/libs/network/test/uri/uri_test.cpp b/libs/network/test/uri/uri_test.cpp index 7a601991d..80dae667b 100644 --- a/libs/network/test/uri/uri_test.cpp +++ b/libs/network/test/uri/uri_test.cpp @@ -1,437 +1,434 @@ -// Copyright 2009, 2010, 2011 Dean Michael Berris, Jeroen Habraken, Glyn Matthews. +// Copyright 2009-2012 Dean Michael Berris, Jeroen Habraken, Glyn Matthews. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt of copy at // http://www.boost.org/LICENSE_1_0.txt) -#define BOOST_TEST_MODULE URL Test +#define BOOST_TEST_MODULE URI Test #include #include -#include -#include -#include #include #include +#include +#include #include #include #include -using namespace boost::network; - BOOST_AUTO_TEST_CASE(basic_uri_scheme_test) { - uri::uri instance("http://www.example.com/"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::scheme(instance), "http"); + network::uri instance("http://www.example.com/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::scheme(instance), "http"); } BOOST_AUTO_TEST_CASE(basic_uri_user_info_test) { - uri::uri instance("http://www.example.com/"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::user_info(instance), ""); + network::uri instance("http://www.example.com/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::user_info(instance), ""); } BOOST_AUTO_TEST_CASE(basic_uri_host_test) { - uri::uri instance("http://www.example.com/"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::host(instance), "www.example.com"); + network::uri instance("http://www.example.com/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::host(instance), "www.example.com"); } BOOST_AUTO_TEST_CASE(basic_uri_port_test) { - uri::uri instance("http://www.example.com/"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::port(instance), ""); + network::uri instance("http://www.example.com/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::port(instance), ""); } BOOST_AUTO_TEST_CASE(basic_uri_path_test) { - uri::uri instance("http://www.example.com/"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::path(instance), "/"); + network::uri instance("http://www.example.com/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::path(instance), "/"); } BOOST_AUTO_TEST_CASE(basic_uri_query_test) { - uri::uri instance("http://www.example.com/"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::query(instance), ""); + network::uri instance("http://www.example.com/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::query(instance), ""); } BOOST_AUTO_TEST_CASE(basic_uri_fragment_test) { - uri::uri instance("http://www.example.com/"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::fragment(instance), ""); + network::uri instance("http://www.example.com/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::fragment(instance), ""); } BOOST_AUTO_TEST_CASE(basic_uri_value_semantics_test) { - uri::uri original; - uri::uri assigned; + network::uri original; + network::uri assigned; assigned = original; BOOST_CHECK(original == assigned); assigned = "http://www.example.com/"; BOOST_CHECK(original != assigned); - uri::uri copy(assigned); + network::uri copy(assigned); BOOST_CHECK(copy == assigned); } BOOST_AUTO_TEST_CASE(basic_uri_range_scheme_test) { - uri::uri instance("http://www.example.com/"); - BOOST_REQUIRE(uri::valid(instance)); + network::uri instance("http://www.example.com/"); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK(instance.scheme_range()); BOOST_CHECK(instance.begin() == boost::begin(instance.scheme_range())); BOOST_CHECK(boost::equal(instance.scheme_range(), boost::as_literal("http"))); } BOOST_AUTO_TEST_CASE(basic_uri_range_user_info_test) { - uri::uri instance("http://www.example.com/"); - BOOST_REQUIRE(uri::valid(instance)); + network::uri instance("http://www.example.com/"); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK(!instance.user_info_range()); BOOST_CHECK(boost::begin(instance.host_range()) == boost::begin(instance.user_info_range())); BOOST_CHECK(boost::begin(instance.host_range()) == boost::end(instance.user_info_range())); } BOOST_AUTO_TEST_CASE(basic_uri_range_host_test) { - uri::uri instance("http://www.example.com/"); - BOOST_REQUIRE(uri::valid(instance)); + network::uri instance("http://www.example.com/"); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK(instance.host_range()); BOOST_CHECK(boost::equal(instance.host_range(), boost::as_literal("www.example.com"))); } BOOST_AUTO_TEST_CASE(basic_uri_range_port_test) { - uri::uri instance("http://www.example.com/"); - BOOST_REQUIRE(uri::valid(instance)); + network::uri instance("http://www.example.com/"); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK(!instance.port_range()); BOOST_CHECK(boost::end(instance.host_range()) == boost::begin(instance.port_range())); BOOST_CHECK(boost::end(instance.host_range()) == boost::end(instance.port_range())); } BOOST_AUTO_TEST_CASE(basic_uri_range_path_test) { - uri::uri instance("http://www.example.com/"); - BOOST_REQUIRE(uri::valid(instance)); + network::uri instance("http://www.example.com/"); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK(instance.path_range()); BOOST_CHECK(boost::equal(instance.path_range(), boost::as_literal("/"))); BOOST_CHECK(instance.end() == boost::end(instance.path_range())); } BOOST_AUTO_TEST_CASE(basic_uri_range_query_test) { - uri::uri instance("http://www.example.com/"); - BOOST_REQUIRE(uri::valid(instance)); + network::uri instance("http://www.example.com/"); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK(!instance.query_range()); BOOST_CHECK(instance.end() == boost::begin(instance.query_range())); BOOST_CHECK(instance.end() == boost::end(instance.query_range())); } BOOST_AUTO_TEST_CASE(basic_uri_range_fragment_test) { - uri::uri instance("http://www.example.com/"); - BOOST_REQUIRE(uri::valid(instance)); + network::uri instance("http://www.example.com/"); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK(!instance.fragment_range()); BOOST_CHECK(instance.end() == boost::begin(instance.fragment_range())); BOOST_CHECK(instance.end() == boost::end(instance.fragment_range())); } BOOST_AUTO_TEST_CASE(full_uri_scheme_test) { - uri::uri instance("http://user:password@www.example.com/path?query#fragment"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::scheme(instance), "http"); + network::uri instance("http://user:password@www.example.com/path?query#fragment"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::scheme(instance), "http"); } BOOST_AUTO_TEST_CASE(full_uri_user_info_test) { - uri::uri instance("http://user:password@www.example.com/path?query#fragment"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::user_info(instance), "user:password"); + network::uri instance("http://user:password@www.example.com/path?query#fragment"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::user_info(instance), "user:password"); } BOOST_AUTO_TEST_CASE(full_uri_host_test) { - uri::uri instance("http://user:password@www.example.com/path?query#fragment"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::host(instance), "www.example.com"); + network::uri instance("http://user:password@www.example.com/path?query#fragment"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::host(instance), "www.example.com"); } BOOST_AUTO_TEST_CASE(full_uri_port_test) { - uri::uri instance("http://user:password@www.example.com/path?query#fragment"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::port(instance), "80"); - BOOST_CHECK(uri::port_us(instance)); - BOOST_CHECK_EQUAL(uri::port_us(instance).get(), 80); + network::uri instance("http://user:password@www.example.com/path?query#fragment"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::port(instance), "80"); + BOOST_CHECK(network::port_us(instance)); + BOOST_CHECK_EQUAL(network::port_us(instance).get(), 80); } BOOST_AUTO_TEST_CASE(full_uri_path_test) { - uri::uri instance("http://user:password@www.example.com/path?query#fragment"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::path(instance), "/path"); + network::uri instance("http://user:password@www.example.com/path?query#fragment"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::path(instance), "/path"); } BOOST_AUTO_TEST_CASE(full_uri_query_test) { - uri::uri instance("http://user:password@www.example.com/path?query#fragment"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::query(instance), "query"); + network::uri instance("http://user:password@www.example.com/path?query#fragment"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::query(instance), "query"); } BOOST_AUTO_TEST_CASE(full_uri_fragment_test) { - uri::uri instance("http://user:password@www.example.com/path?query#fragment"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::fragment(instance), "fragment"); + network::uri instance("http://user:password@www.example.com/path?query#fragment"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::fragment(instance), "fragment"); } BOOST_AUTO_TEST_CASE(full_uri_range_scheme_test) { - uri::uri instance("http://user:password@www.example.com/path?query#fragment"); - BOOST_REQUIRE(uri::valid(instance)); + network::uri instance("http://user:password@www.example.com/path?query#fragment"); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK(instance.scheme_range()); BOOST_CHECK(instance.begin() == boost::begin(instance.scheme_range())); BOOST_CHECK(boost::equal(instance.scheme_range(), boost::as_literal("http"))); } BOOST_AUTO_TEST_CASE(full_uri_range_user_info_test) { - uri::uri instance("http://user:password@www.example.com/path?query#fragment"); - BOOST_REQUIRE(uri::valid(instance)); + network::uri instance("http://user:password@www.example.com/path?query#fragment"); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK(instance.user_info_range()); BOOST_CHECK(boost::equal(instance.user_info_range(), boost::as_literal("user:password"))); } BOOST_AUTO_TEST_CASE(full_uri_range_host_test) { - uri::uri instance("http://user:password@www.example.com/path?query#fragment"); - BOOST_REQUIRE(uri::valid(instance)); + network::uri instance("http://user:password@www.example.com/path?query#fragment"); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK(instance.host_range()); BOOST_CHECK(boost::equal(instance.host_range(), boost::as_literal("www.example.com"))); } BOOST_AUTO_TEST_CASE(full_uri_range_port_test) { - uri::uri instance("http://user:password@www.example.com/path?query#fragment"); - BOOST_REQUIRE(uri::valid(instance)); + network::uri instance("http://user:password@www.example.com/path?query#fragment"); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK(instance.port_range()); BOOST_CHECK(boost::equal(instance.port_range(), boost::as_literal("80"))); } BOOST_AUTO_TEST_CASE(full_uri_range_path_test) { - uri::uri instance("http://user:password@www.example.com/path?query#fragment"); - BOOST_REQUIRE(uri::valid(instance)); + network::uri instance("http://user:password@www.example.com/path?query#fragment"); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK(instance.path_range()); BOOST_CHECK(boost::equal(instance.path_range(), boost::as_literal("/path"))); } BOOST_AUTO_TEST_CASE(full_uri_range_query_test) { - uri::uri instance("http://user:password@www.example.com/path?query#fragment"); - BOOST_REQUIRE(uri::valid(instance)); + network::uri instance("http://user:password@www.example.com/path?query#fragment"); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK(instance.query_range()); BOOST_CHECK(boost::equal(instance.query_range(), boost::as_literal("query"))); } BOOST_AUTO_TEST_CASE(full_uri_range_fragment_test) { - uri::uri instance("http://user:password@www.example.com/path?query#fragment"); - BOOST_REQUIRE(uri::valid(instance)); + network::uri instance("http://user:password@www.example.com/path?query#fragment"); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK(instance.fragment_range()); BOOST_CHECK(boost::equal(instance.fragment_range(), boost::as_literal("fragment"))); BOOST_CHECK(instance.end() == boost::end(instance.fragment_range())); } BOOST_AUTO_TEST_CASE(mailto_test) { - uri::uri instance("mailto:john.doe@example.com"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::scheme(instance), "mailto"); - BOOST_CHECK_EQUAL(uri::path(instance), "john.doe@example.com"); + network::uri instance("mailto:john.doe@example.com"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::scheme(instance), "mailto"); + BOOST_CHECK_EQUAL(network::path(instance), "john.doe@example.com"); } BOOST_AUTO_TEST_CASE(file_test) { - uri::uri instance("file:///bin/bash"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::scheme(instance), "file"); - BOOST_CHECK_EQUAL(uri::path(instance), "/bin/bash"); + network::uri instance("file:///bin/bash"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::scheme(instance), "file"); + BOOST_CHECK_EQUAL(network::path(instance), "/bin/bash"); } BOOST_AUTO_TEST_CASE(xmpp_test) { - uri::uri instance("xmpp:example-node@example.com?message;subject=Hello%20World"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::scheme(instance), "xmpp"); - BOOST_CHECK_EQUAL(uri::path(instance), "example-node@example.com"); - BOOST_CHECK_EQUAL(uri::query(instance), "message;subject=Hello%20World"); + network::uri instance("xmpp:example-node@example.com?message;subject=Hello%20World"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::scheme(instance), "xmpp"); + BOOST_CHECK_EQUAL(network::path(instance), "example-node@example.com"); + BOOST_CHECK_EQUAL(network::query(instance), "message;subject=Hello%20World"); } BOOST_AUTO_TEST_CASE(ipv4_address_test) { - uri::uri instance("http://129.79.245.252/"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::scheme(instance), "http"); - BOOST_CHECK_EQUAL(uri::host(instance), "129.79.245.252"); - BOOST_CHECK_EQUAL(uri::path(instance), "/"); + network::uri instance("http://129.79.245.252/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::scheme(instance), "http"); + BOOST_CHECK_EQUAL(network::host(instance), "129.79.245.252"); + BOOST_CHECK_EQUAL(network::path(instance), "/"); } BOOST_AUTO_TEST_CASE(ipv4_loopback_test) { - uri::uri instance("http://127.0.0.1/"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::scheme(instance), "http"); - BOOST_CHECK_EQUAL(uri::host(instance), "127.0.0.1"); - BOOST_CHECK_EQUAL(uri::path(instance), "/"); + network::uri instance("http://127.0.0.1/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::scheme(instance), "http"); + BOOST_CHECK_EQUAL(network::host(instance), "127.0.0.1"); + BOOST_CHECK_EQUAL(network::path(instance), "/"); } BOOST_AUTO_TEST_CASE(ipv6_address_test_1) { - uri::uri instance("http://[1080::8:800:200c:417a]/"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::scheme(instance), "http"); - BOOST_CHECK_EQUAL(uri::host(instance), "[1080:0:0:0:8:800:200C:417A]"); - BOOST_CHECK_EQUAL(uri::path(instance), "/"); + network::uri instance("http://[1080::8:800:200c:417a]/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::scheme(instance), "http"); + BOOST_CHECK_EQUAL(network::host(instance), "[1080:0:0:0:8:800:200C:417A]"); + BOOST_CHECK_EQUAL(network::path(instance), "/"); } BOOST_AUTO_TEST_CASE(ipv6_address_test_2) { - uri::uri instance("http://[2001:db8:85a3:8d3:1319:8a2e:370:7348]/"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::scheme(instance), "http"); - BOOST_CHECK_EQUAL(uri::host(instance), "[2001:db8:85a3:8d3:1319:8a2e:370:7348]"); - BOOST_CHECK_EQUAL(uri::path(instance), "/"); + network::uri instance("http://[2001:db8:85a3:8d3:1319:8a2e:370:7348]/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::scheme(instance), "http"); + BOOST_CHECK_EQUAL(network::host(instance), "[2001:db8:85a3:8d3:1319:8a2e:370:7348]"); + BOOST_CHECK_EQUAL(network::path(instance), "/"); } //BOOST_AUTO_TEST_CASE(ipv6_loopback_test) { -// uri::uri instance("http://[::1]/"); -// BOOST_REQUIRE(uri::valid(instance)); -// BOOST_CHECK_EQUAL(uri::scheme(instance), "http"); -// BOOST_CHECK_EQUAL(uri::host(instance), "[::1]"); -// BOOST_CHECK_EQUAL(uri::path(instance), "/"); +// network::uri instance("http://[::1]/"); +// BOOST_REQUIRE(network::valid(instance)); +// BOOST_CHECK_EQUAL(network::scheme(instance), "http"); +// BOOST_CHECK_EQUAL(network::host(instance), "[::1]"); +// BOOST_CHECK_EQUAL(network::path(instance), "/"); //} BOOST_AUTO_TEST_CASE(ftp_test) { - uri::uri instance("ftp://john.doe@ftp.example.com/"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::scheme(instance), "ftp"); - BOOST_CHECK_EQUAL(uri::user_info(instance), "john.doe"); - BOOST_CHECK_EQUAL(uri::host(instance), "ftp.example.com"); - BOOST_CHECK_EQUAL(uri::path(instance), "/"); + network::uri instance("ftp://john.doe@ftp.example.com/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::scheme(instance), "ftp"); + BOOST_CHECK_EQUAL(network::user_info(instance), "john.doe"); + BOOST_CHECK_EQUAL(network::host(instance), "ftp.example.com"); + BOOST_CHECK_EQUAL(network::path(instance), "/"); } BOOST_AUTO_TEST_CASE(news_test) { - uri::uri instance("news:comp.infosystems.www.servers.unix"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::scheme(instance), "news"); - BOOST_CHECK_EQUAL(uri::path(instance), "comp.infosystems.www.servers.unix"); + network::uri instance("news:comp.infosystems.www.servers.unix"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::scheme(instance), "news"); + BOOST_CHECK_EQUAL(network::path(instance), "comp.infosystems.www.servers.unix"); } BOOST_AUTO_TEST_CASE(tel_test) { - uri::uri instance("tel:+1-816-555-1212"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::scheme(instance), "tel"); - BOOST_CHECK_EQUAL(uri::path(instance), "+1-816-555-1212"); + network::uri instance("tel:+1-816-555-1212"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::scheme(instance), "tel"); + BOOST_CHECK_EQUAL(network::path(instance), "+1-816-555-1212"); } BOOST_AUTO_TEST_CASE(encoded_uri_test) { - uri::uri instance("http://www.example.com/Path%20With%20%28Some%29%20Encoded%20Characters%21"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::scheme(instance), "http"); - BOOST_CHECK_EQUAL(uri::host(instance), "www.example.com"); - BOOST_CHECK_EQUAL(uri::path(instance), "/Path%20With%20%28Some%29%20Encoded%20Characters%21"); - BOOST_CHECK_EQUAL(uri::decoded_path(instance), "/Path With (Some) Encoded Characters!"); + network::uri instance("http://www.example.com/Path%20With%20%28Some%29%20Encoded%20Characters%21"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::scheme(instance), "http"); + BOOST_CHECK_EQUAL(network::host(instance), "www.example.com"); + BOOST_CHECK_EQUAL(network::path(instance), "/Path%20With%20%28Some%29%20Encoded%20Characters%21"); + BOOST_CHECK_EQUAL(network::decoded_path(instance), "/Path With (Some) Encoded Characters!"); } BOOST_AUTO_TEST_CASE(copy_constructor_test) { - uri::uri instance("http://www.example.com/"); - uri::uri copy = instance; + network::uri instance("http://www.example.com/"); + network::uri copy = instance; BOOST_CHECK_EQUAL(instance, copy); } BOOST_AUTO_TEST_CASE(assignment_test) { - uri::uri instance("http://www.example.com/"); - uri::uri copy; + network::uri instance("http://www.example.com/"); + network::uri copy; copy = instance; BOOST_CHECK_EQUAL(instance, copy); } BOOST_AUTO_TEST_CASE(swap_test) { - uri::uri instance("http://www.example.com/"); - uri::uri copy("http://www.example.org/"); - uri::swap(instance, copy); + network::uri instance("http://www.example.com/"); + network::uri copy("http://www.example.org/"); + network::swap(instance, copy); BOOST_CHECK_EQUAL(instance.string(), "http://www.example.org/"); BOOST_CHECK_EQUAL(copy.string(), "http://www.example.com/"); } BOOST_AUTO_TEST_CASE(equality_test) { - uri::uri uri_1("http://www.example.com/"); - uri::uri uri_2("http://www.example.com/"); + network::uri uri_1("http://www.example.com/"); + network::uri uri_2("http://www.example.com/"); BOOST_CHECK(uri_1 == uri_2); } BOOST_AUTO_TEST_CASE(equality_test_1) { - uri::uri uri_1("http://www.example.com/"); + network::uri uri_1("http://www.example.com/"); std::string uri_2("http://www.example.com/"); BOOST_CHECK(uri_1 == uri_2); } BOOST_AUTO_TEST_CASE(equality_test_2) { std::string uri_1("http://www.example.com/"); - uri::uri uri_2("http://www.example.com/"); + network::uri uri_2("http://www.example.com/"); BOOST_CHECK(uri_1 == uri_2); } BOOST_AUTO_TEST_CASE(equality_test_3) { - uri::uri uri_1("http://www.example.com/"); + network::uri uri_1("http://www.example.com/"); std::string uri_2("http://www.example.com/"); BOOST_CHECK(uri_1 == uri_2.c_str()); } BOOST_AUTO_TEST_CASE(equality_test_4) { std::string uri_1("http://www.example.com/"); - uri::uri uri_2("http://www.example.com/"); + network::uri uri_2("http://www.example.com/"); BOOST_CHECK(uri_1.c_str() == uri_2); } BOOST_AUTO_TEST_CASE(inequality_test) { - uri::uri uri_1("http://www.example.com/"); - uri::uri uri_2("http://www.example.com/"); + network::uri uri_1("http://www.example.com/"); + network::uri uri_2("http://www.example.com/"); BOOST_CHECK(!(uri_1 != uri_2)); } BOOST_AUTO_TEST_CASE(less_than_test) { // uri_1 is lexicographically less than uri_2 - uri::uri uri_1("http://www.example.com/"); - uri::uri uri_2("http://www.example.org/"); + network::uri uri_1("http://www.example.com/"); + network::uri uri_2("http://www.example.org/"); BOOST_CHECK(uri_1 < uri_2); } BOOST_AUTO_TEST_CASE(username_test) { - uri::uri instance("ftp://john.doe@ftp.example.com/"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::username(instance), "john.doe"); + network::uri instance("ftp://john.doe@ftp.example.com/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::username(instance), "john.doe"); } BOOST_AUTO_TEST_CASE(pasword_test) { - uri::uri instance("ftp://john.doe:password@ftp.example.com/"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::password(instance), "password"); + network::uri instance("ftp://john.doe:password@ftp.example.com/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::password(instance), "password"); } BOOST_AUTO_TEST_CASE(hierarchical_part_test) { - uri::uri instance("http://user:password@www.example.com/path?query#fragment"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::hierarchical_part(instance), "user:password@www.example.com:80/path"); + network::uri instance("http://user:password@www.example.com/path?query#fragment"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::hierarchical_part(instance), "user:password@www.example.com:80/path"); } BOOST_AUTO_TEST_CASE(partial_hierarchical_part_test) { - uri::uri instance("http://www.example.com/?query#fragment"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::hierarchical_part(instance), "www.example.com"); + network::uri instance("http://www.example.com/?query#fragment"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::hierarchical_part(instance), "www.example.com"); } BOOST_AUTO_TEST_CASE(authority_test) { - uri::uri instance("http://user:password@www.example.com/path?query#fragment"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::authority(instance), "user:password@www.example.com:80"); + network::uri instance("http://user:password@www.example.com/path?query#fragment"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::authority(instance), "user:password@www.example.com:80"); } BOOST_AUTO_TEST_CASE(partial_authority_test) { - uri::uri instance("http://www.example.com/path?query#fragment"); - BOOST_REQUIRE(uri::valid(instance)); - BOOST_CHECK_EQUAL(uri::authority(instance), "www.example.com"); + network::uri instance("http://www.example.com/path?query#fragment"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::authority(instance), "www.example.com"); } BOOST_AUTO_TEST_CASE(http_query_map_test) { - uri::uri instance("http://user:password@www.example.com/path?query=something#fragment"); - BOOST_REQUIRE(uri::valid(instance)); + network::uri instance("http://user:password@www.example.com/path?query=something#fragment"); + BOOST_REQUIRE(network::valid(instance)); std::map queries; - uri::query_map(instance, queries); + network::query_map(instance, queries); BOOST_REQUIRE_EQUAL(queries.size(), std::size_t(1)); BOOST_CHECK_EQUAL(queries.begin()->first, "query"); BOOST_CHECK_EQUAL(queries.begin()->second, "something"); } BOOST_AUTO_TEST_CASE(xmpp_query_map_test) { - uri::uri instance("xmpp:example-node@example.com?message;subject=Hello%20World"); - BOOST_REQUIRE(uri::valid(instance)); + network::uri instance("xmpp:example-node@example.com?message;subject=Hello%20World"); + BOOST_REQUIRE(network::valid(instance)); std::map queries; - uri::query_map(instance, queries); + network::query_map(instance, queries); BOOST_REQUIRE_EQUAL(queries.size(), std::size_t(2)); BOOST_CHECK_EQUAL(queries.begin()->first, "message"); BOOST_CHECK_EQUAL(queries.begin()->second, ""); @@ -441,64 +438,64 @@ BOOST_AUTO_TEST_CASE(xmpp_query_map_test) { BOOST_AUTO_TEST_CASE(range_test) { const std::string url("http://www.example.com/"); - uri::uri instance(url); - BOOST_REQUIRE(uri::valid(instance)); + network::uri instance(url); + BOOST_REQUIRE(network::valid(instance)); BOOST_CHECK(boost::equal(instance, url)); } BOOST_AUTO_TEST_CASE(issue_67_test) { // https://github.com/cpp-netlib/cpp-netlib/issues/67 const std::string site_name("http://www.google.com/"); - uri::uri bar0; - uri::uri bar1 = site_name; + network::uri bar0; + network::uri bar1 = site_name; bar0 = site_name; - BOOST_CHECK(uri::is_valid(bar0)); - BOOST_CHECK(uri::is_valid(bar1)); + BOOST_CHECK(network::is_valid(bar0)); + BOOST_CHECK(network::is_valid(bar1)); } BOOST_AUTO_TEST_CASE(from_parts_1) { - BOOST_CHECK_EQUAL(uri::uri("http://www.example.com/path?query#fragment"), - uri::from_parts(uri::uri("http://www.example.com/"), "/path", "query", "fragment")); + BOOST_CHECK_EQUAL(network::uri("http://www.example.com/path?query#fragment"), + network::from_parts(network::uri("http://www.example.com/"), "/path", "query", "fragment")); } BOOST_AUTO_TEST_CASE(from_parts_2) { - BOOST_CHECK_EQUAL(uri::uri("http://www.example.com/path?query#fragment"), - uri::from_parts("http://www.example.com/", "/path", "query", "fragment")); + BOOST_CHECK_EQUAL(network::uri("http://www.example.com/path?query#fragment"), + network::from_parts("http://www.example.com/", "/path", "query", "fragment")); } BOOST_AUTO_TEST_CASE(from_parts_3) { - BOOST_CHECK_EQUAL(uri::uri("http://www.example.com/path?query"), - uri::from_parts("http://www.example.com/", "/path", "query")); + BOOST_CHECK_EQUAL(network::uri("http://www.example.com/path?query"), + network::from_parts("http://www.example.com/", "/path", "query")); } BOOST_AUTO_TEST_CASE(from_parts_4) { - BOOST_CHECK_EQUAL(uri::uri("http://www.example.com/path"), - uri::from_parts("http://www.example.com/", "/path")); + BOOST_CHECK_EQUAL(network::uri("http://www.example.com/path"), + network::from_parts("http://www.example.com/", "/path")); } BOOST_AUTO_TEST_CASE(from_file) { boost::filesystem::path path("/a/path/to/a/file.txt"); - BOOST_CHECK_EQUAL(uri::uri("file:///a/path/to/a/file.txt"), uri::from_file(path)); + BOOST_CHECK_EQUAL(network::uri("file:///a/path/to/a/file.txt"), network::from_file(path)); } BOOST_AUTO_TEST_CASE(issue_104_test) { // https://github.com/cpp-netlib/cpp-netlib/issues/104 - boost::scoped_ptr instance(new uri::uri("http://www.example.com/")); - uri::uri copy = *instance; + boost::scoped_ptr instance(new network::uri("http://www.example.com/")); + network::uri copy = *instance; instance.reset(); - BOOST_CHECK_EQUAL(uri::scheme(copy), "http"); + BOOST_CHECK_EQUAL(network::scheme(copy), "http"); } BOOST_AUTO_TEST_CASE(uri_set_test) { - std::set uri_set; - uri_set.insert(uri::uri("http://www.example.com/")); + std::set uri_set; + uri_set.insert(network::uri("http://www.example.com/")); BOOST_REQUIRE(!uri_set.empty()); - BOOST_CHECK_EQUAL((*uri_set.begin()), uri::uri("http://www.example.com/")); + BOOST_CHECK_EQUAL((*uri_set.begin()), network::uri("http://www.example.com/")); } BOOST_AUTO_TEST_CASE(uri_unordered_set_test) { - boost::unordered_set uri_set; - uri_set.insert(uri::uri("http://www.example.com/")); + boost::unordered_set uri_set; + uri_set.insert(network::uri("http://www.example.com/")); BOOST_REQUIRE(!uri_set.empty()); - BOOST_CHECK_EQUAL((*uri_set.begin()), uri::uri("http://www.example.com/")); + BOOST_CHECK_EQUAL((*uri_set.begin()), network::uri("http://www.example.com/")); } From 567f9769a9ade8d598ebb445ea6a993ed3910e7e Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Tue, 8 May 2012 18:23:55 +1000 Subject: [PATCH 084/196] C++11 features to implement server stuff. --- boost/network/message/wrappers/headers.hpp | 8 --- .../protocol/http/algorithms/flatten.hpp | 25 --------- .../protocol/http/server/connection/sync.hpp | 55 +++++++++++++++++-- libs/network/test/http/CMakeLists.txt | 2 + 4 files changed, 53 insertions(+), 37 deletions(-) delete mode 100644 boost/network/protocol/http/algorithms/flatten.hpp diff --git a/boost/network/message/wrappers/headers.hpp b/boost/network/message/wrappers/headers.hpp index 0a9bceeca..81179d8e3 100644 --- a/boost/network/message/wrappers/headers.hpp +++ b/boost/network/message/wrappers/headers.hpp @@ -13,14 +13,6 @@ namespace boost { namespace network { struct message_base; -/** headers wrapper for messages. - * - * This exposes an interface similar to a map, indexable - * using operator[] taking a string as the index and returns - * a range of iterators (std::pair) - * whose keys are all equal to the index string. - * - */ struct headers_wrapper { typedef std::multimap container_type; explicit headers_wrapper(message_base const & message); diff --git a/boost/network/protocol/http/algorithms/flatten.hpp b/boost/network/protocol/http/algorithms/flatten.hpp deleted file mode 100644 index 60fa8c468..000000000 --- a/boost/network/protocol/http/algorithms/flatten.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_ALGORITHMS_FLATTEN_HPP_20120326 -#define BOOST_NETWORK_PROTOCOL_HTTP_ALGORITHMS_FLATTEN_HPP_20120326 - -// Copyright 2012 Dean Michael Berris . -// Copyright 2012 Google, Inc. -// 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) - -#include -#include - -namespace boost { namespace network { namespace http { - -class response; - -void flatten(response const &response_, std::vector &buffers); - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_ALGORITHMS_FLATTEN_HPP_20120326 diff --git a/boost/network/protocol/http/server/connection/sync.hpp b/boost/network/protocol/http/server/connection/sync.hpp index 258fcd8dc..0487bd9c2 100644 --- a/boost/network/protocol/http/server/connection/sync.hpp +++ b/boost/network/protocol/http/server/connection/sync.hpp @@ -12,7 +12,10 @@ #define BOOST_NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE 4096uL #endif +#include +#include #include +#include #include #include #include @@ -26,7 +29,6 @@ #include #include #include -#include namespace boost { namespace network { namespace http { @@ -187,8 +189,13 @@ class sync_server_connection : public boost::enable_shared_from_this response_buffers; - flatten(response_, response_buffers); + flatten_response(); + std::vector response_buffers(output_buffers_.size()); + std::transform(output_buffers_.begin(), output_buffers_.end(), + response_buffers.begin(), + [](buffer_type const &buffer) { + return asio::const_buffer(buffer.data(), buffer.size()); + }); boost::asio::async_write( socket_, response_buffers, @@ -217,13 +224,15 @@ class sync_server_connection : public boost::enable_shared_from_this data) { + if (boost::empty(data)) done = true; + else std::copy(begin(data), end(data), buffer.begin()); + }, buffer.size()); + if (!done) output_buffers_.emplace_back(std::move(buffer)); + } + } + + void segmented_write(std::string data) { + while (!boost::empty(data)) { + buffer_type buffer; + auto end = std::copy_n(boost::begin(data), buffer.size(), buffer.begin()); + data.erase(0, std::distance(buffer.begin(), end)); + output_buffers_.emplace_back(std::move(buffer)); + } + } + boost::asio::io_service & service_; function handler_; boost::asio::ip::tcp::socket socket_; @@ -273,6 +319,7 @@ class sync_server_connection : public boost::enable_shared_from_this output_buffers_; std::string partial_parsed; optional error_encountered; bool read_body_; diff --git a/libs/network/test/http/CMakeLists.txt b/libs/network/test/http/CMakeLists.txt index 768ced7cd..555541558 100644 --- a/libs/network/test/http/CMakeLists.txt +++ b/libs/network/test/http/CMakeLists.txt @@ -87,8 +87,10 @@ if (Boost_FOUND) target_link_libraries(cpp-netlib-http-${test} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} + cppnetlib-constants cppnetlib-uri cppnetlib-message + cppnetlib-message-wrappers cppnetlib-http-message cppnetlib-http-servers cppnetlib-http-server-parsers From 42feebfec1e4e64af4886718a87e79772e57d1f3 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Thu, 10 May 2012 16:31:04 +1000 Subject: [PATCH 085/196] Addressing issue with status_wrapper. --- boost/network/protocol/http/client/connection/async_normal.ipp | 2 +- boost/network/protocol/http/message/wrappers/status.ipp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/boost/network/protocol/http/client/connection/async_normal.ipp b/boost/network/protocol/http/client/connection/async_normal.ipp index 9b2ff73c5..5198a53ea 100644 --- a/boost/network/protocol/http/client/connection/async_normal.ipp +++ b/boost/network/protocol/http/client/connection/async_normal.ipp @@ -329,7 +329,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thispart_begin; buffer_type::const_iterator end = begin; - std::advance(end, remainder); + std::advance(end, std::min(bytes_transferred, remainder)); // We're setting the body promise here to an empty string because // this can be used as a signaling mechanism for the user to diff --git a/boost/network/protocol/http/message/wrappers/status.ipp b/boost/network/protocol/http/message/wrappers/status.ipp index 70480ac8d..338176d06 100644 --- a/boost/network/protocol/http/message/wrappers/status.ipp +++ b/boost/network/protocol/http/message/wrappers/status.ipp @@ -12,7 +12,7 @@ namespace boost { namespace network { namespace http { status_wrapper::status_wrapper(response_base &response) -: response_(response_) +: response_(response) {} status_wrapper::operator uint16_t () const { From 822b9fcdb7be29afc11dff5584bed194be393374 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Thu, 10 May 2012 16:56:07 +1000 Subject: [PATCH 086/196] Making fixes to the CMakeLists for sanity. --- libs/network/src/CMakeLists.txt | 1 + libs/network/test/uri/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/network/src/CMakeLists.txt b/libs/network/src/CMakeLists.txt index a6ddfb980..2912d7df6 100644 --- a/libs/network/src/CMakeLists.txt +++ b/libs/network/src/CMakeLists.txt @@ -7,6 +7,7 @@ include_directories(${CPP-NETLIB_SOURCE_DIR}/include) +include_directories(${CPP-NETLIB_SOURCE_DIR}) set(CPP-NETLIB_URI_SRCS uri/uri.cpp uri/schemes.cpp) add_library(cppnetlib-uri ${CPP-NETLIB_URI_SRCS}) diff --git a/libs/network/test/uri/CMakeLists.txt b/libs/network/test/uri/CMakeLists.txt index 65c326905..92fb226fa 100644 --- a/libs/network/test/uri/CMakeLists.txt +++ b/libs/network/test/uri/CMakeLists.txt @@ -4,7 +4,7 @@ # (See accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) -include_directories(${CPP-NETLIB_SOURCE_DIR}/include) +include_directories(${CPP-NETLIB_SOURCE_DIR}) if (Boost_FOUND) set( From 6ec03b610787dcdbffa33fbf07a21ce618a40c77 Mon Sep 17 00:00:00 2001 From: Glyn Matthews Date: Sun, 13 May 2012 09:38:50 +0200 Subject: [PATCH 087/196] [http_refactor] Updated sources and build scripts to ensure full compilation on Linux (GCC 4.6) --- CMakeLists.txt | 12 ++ boost/network/message/message_base.hpp | 4 - .../connection/simple_connection_factory.ipp | 10 +- boost/network/protocol/http/impl/request.hpp | 10 +- .../protocol/http/message/modifiers/uri.hpp | 2 +- .../protocol/http/message/wrappers/anchor.ipp | 4 +- .../protocol/http/message/wrappers/host.ipp | 4 +- .../protocol/http/message/wrappers/path.ipp | 4 +- .../protocol/http/message/wrappers/port.ipp | 6 +- .../protocol/http/message/wrappers/query.ipp | 4 +- .../protocol/http/message/wrappers/uri.hpp | 4 +- .../protocol/http/message/wrappers/uri.ipp | 4 +- .../network/protocol/http/request/request.hpp | 8 +- .../network/protocol/http/request/request.ipp | 22 ++- .../protocol/http/request/request_base.hpp | 10 +- .../protocol/http/server/connection/sync.hpp | 8 +- libs/network/example/CMakeLists.txt | 65 +++++---- .../example/http/hello_world_server.cpp | 19 +-- libs/network/example/simple_wget.cpp | 13 +- libs/network/example/twitter/search.cpp | 14 +- libs/network/example/uri_builder.cpp | 18 +-- libs/network/src/CMakeLists.txt | 126 +++++++++++++----- libs/network/test/http/CMakeLists.txt | 12 +- libs/network/test/http/request_test.cpp | 11 +- libs/network/test/uri/CMakeLists.txt | 1 + libs/network/test/uri/relative_uri_test.cpp | 10 +- 26 files changed, 252 insertions(+), 153 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4667f235f..06f6460ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,18 @@ if (OPENSSL_FOUND) add_definitions(-DBOOST_NETWORK_ENABLE_HTTPS) endif() +if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) + INCLUDE(CheckCXXCompilerFlag) + CHECK_CXX_COMPILER_FLAG(-std=c++0x HAVE_STD0X) + CHECK_CXX_COMPILER_FLAG(-std=c++11 HAVE_STD11) + + if (NOT HAVE_STD0X) + if (NOT HAVE_STD11) + message(FATAL_ERROR "No advanced standard C++ support (-std=c++0x and -std=c++11 not defined).") + endif() + endif() +endif() + if (Boost_FOUND) if (MSVC) add_definitions(-D_SCL_SECURE_NO_WARNINGS) diff --git a/boost/network/message/message_base.hpp b/boost/network/message/message_base.hpp index 5f3681e5a..b19a5a74b 100644 --- a/boost/network/message/message_base.hpp +++ b/boost/network/message/message_base.hpp @@ -40,8 +40,4 @@ struct message_base { } /* boost */ -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif - #endif /* BOOST_NETWORK_MESSAGE_BASE_HPP_20110910 */ diff --git a/boost/network/protocol/http/client/connection/simple_connection_factory.ipp b/boost/network/protocol/http/client/connection/simple_connection_factory.ipp index 20881eb9b..1ea211678 100644 --- a/boost/network/protocol/http/client/connection/simple_connection_factory.ipp +++ b/boost/network/protocol/http/client/connection/simple_connection_factory.ipp @@ -14,7 +14,7 @@ #include #include #ifdef BOOST_NETWORK_DEBUG -#include +#include #endif #include @@ -35,9 +35,9 @@ struct simple_connection_factory_pimpl { request_base const & request, client_options const & options) { BOOST_NETWORK_MESSAGE("simple_connection_factory_pimpl::create_connection(...)"); - uri::uri uri_ = http::uri(request); + ::network::uri uri_ = http::uri(request); BOOST_NETWORK_MESSAGE("destination: " << uri_); - bool https = to_lower_copy(scheme(uri_)) == "https"; + bool https = to_lower_copy(::network::scheme(uri_)) == "https"; shared_ptr conn_; conn_.reset(new (std::nothrow) http_async_connection( res_delegate_factory_->create_resolver_delegate(service, options.cache_resolved()), @@ -83,9 +83,9 @@ simple_connection_factory::~simple_connection_factory() { } } /* http */ - + } /* network */ - + } /* boost */ #endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SIMPLE_CONNECTION_FACTORY_20111120 */ diff --git a/boost/network/protocol/http/impl/request.hpp b/boost/network/protocol/http/impl/request.hpp index 5ba92d6c1..af0aab56d 100644 --- a/boost/network/protocol/http/impl/request.hpp +++ b/boost/network/protocol/http/impl/request.hpp @@ -15,7 +15,7 @@ #include #include -#include +#include #include #include @@ -51,7 +51,7 @@ namespace http { struct basic_request : public basic_message { - mutable boost::network::uri::uri uri_; + mutable network::uri uri_; typedef basic_message base_type; public: @@ -63,7 +63,7 @@ namespace http { : uri_(uri_) { } - explicit basic_request(boost::network::uri::uri const & uri_) + explicit basic_request(network::uri const & uri_) : uri_(uri_) { } @@ -71,7 +71,7 @@ namespace http { uri_ = new_uri; } - void uri(boost::network::uri::uri const & new_uri) { + void uri(network::uri const & new_uri) { uri_ = new_uri; } @@ -130,7 +130,7 @@ namespace http { uri_ = new_uri; } - boost::network::uri::uri const & uri() const { + network::uri const & uri() const { return uri_; } diff --git a/boost/network/protocol/http/message/modifiers/uri.hpp b/boost/network/protocol/http/message/modifiers/uri.hpp index 298ffb4fa..a106cf7be 100644 --- a/boost/network/protocol/http/message/modifiers/uri.hpp +++ b/boost/network/protocol/http/message/modifiers/uri.hpp @@ -16,7 +16,7 @@ inline void uri(request_base & request, std::string const & value) { request.set_uri(value); } -inline void uri(request_base & request, uri::uri const & value) { +inline void uri(request_base & request, ::network::uri const & value) { request.set_uri(value); } diff --git a/boost/network/protocol/http/message/wrappers/anchor.ipp b/boost/network/protocol/http/message/wrappers/anchor.ipp index b439b9c58..a29bed667 100644 --- a/boost/network/protocol/http/message/wrappers/anchor.ipp +++ b/boost/network/protocol/http/message/wrappers/anchor.ipp @@ -8,7 +8,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include +#include namespace boost { namespace network { namespace http { @@ -16,7 +16,7 @@ anchor_wrapper::anchor_wrapper(request_base const & request) : request_(request) {} anchor_wrapper::operator std::string () const { - uri::uri uri_; + ::network::uri uri_; request_.get_uri(uri_); return fragment(uri_); } diff --git a/boost/network/protocol/http/message/wrappers/host.ipp b/boost/network/protocol/http/message/wrappers/host.ipp index db047655b..54158f8e3 100644 --- a/boost/network/protocol/http/message/wrappers/host.ipp +++ b/boost/network/protocol/http/message/wrappers/host.ipp @@ -8,7 +8,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include +#include namespace boost { namespace network { namespace http { @@ -16,7 +16,7 @@ host_wrapper::host_wrapper(request_base const & request) : request_(request) {} host_wrapper::operator std::string () const { - uri::uri uri_; + ::network::uri uri_; request_.get_uri(uri_); return host(uri_); } diff --git a/boost/network/protocol/http/message/wrappers/path.ipp b/boost/network/protocol/http/message/wrappers/path.ipp index 5427fa2a8..25272a8c5 100644 --- a/boost/network/protocol/http/message/wrappers/path.ipp +++ b/boost/network/protocol/http/message/wrappers/path.ipp @@ -8,7 +8,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include +#include namespace boost { namespace network { namespace http { @@ -16,7 +16,7 @@ path_wrapper::path_wrapper(request_base const & request) : request_(request) {} path_wrapper::operator std::string () const { - uri::uri uri_; + ::network::uri uri_; request_.get_uri(uri_); return path(uri_); } diff --git a/boost/network/protocol/http/message/wrappers/port.ipp b/boost/network/protocol/http/message/wrappers/port.ipp index 683bc2340..fddceb3be 100644 --- a/boost/network/protocol/http/message/wrappers/port.ipp +++ b/boost/network/protocol/http/message/wrappers/port.ipp @@ -8,7 +8,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include +#include namespace boost { namespace network { namespace http { @@ -16,7 +16,7 @@ port_wrapper::port_wrapper(request_base const & request) : request_(request) {} port_wrapper::operator boost::uint16_t () const { - uri::uri uri_; + ::network::uri uri_; request_.get_uri(uri_); optional optional_port = port_us(uri_); if (!optional_port) { @@ -31,7 +31,7 @@ port_wrapper::operator boost::uint16_t () const { } port_wrapper::operator optional () const { - uri::uri uri_; + ::network::uri uri_; request_.get_uri(uri_); return port_us(uri_); } diff --git a/boost/network/protocol/http/message/wrappers/query.ipp b/boost/network/protocol/http/message/wrappers/query.ipp index 806f0314d..3b1f4d24d 100644 --- a/boost/network/protocol/http/message/wrappers/query.ipp +++ b/boost/network/protocol/http/message/wrappers/query.ipp @@ -8,7 +8,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include +#include namespace boost { namespace network { namespace http { @@ -16,7 +16,7 @@ query_wrapper::query_wrapper(request_base const & request) : request_(request) {} query_wrapper::operator std::string () const { - uri::uri uri_; + ::network::uri uri_; request_.get_uri(uri_); return query(uri_); } diff --git a/boost/network/protocol/http/message/wrappers/uri.hpp b/boost/network/protocol/http/message/wrappers/uri.hpp index 7db8ce961..8e56dacb9 100644 --- a/boost/network/protocol/http/message/wrappers/uri.hpp +++ b/boost/network/protocol/http/message/wrappers/uri.hpp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include namespace boost { namespace network { namespace http { @@ -15,7 +15,7 @@ namespace boost { namespace network { namespace http { struct uri_wrapper { explicit uri_wrapper(request_base const & request_); operator std::string() const; - operator boost::network::uri::uri() const; + operator ::network::uri() const; private: request_base const & request_; }; diff --git a/boost/network/protocol/http/message/wrappers/uri.ipp b/boost/network/protocol/http/message/wrappers/uri.ipp index 8034d387d..d3a24d30e 100644 --- a/boost/network/protocol/http/message/wrappers/uri.ipp +++ b/boost/network/protocol/http/message/wrappers/uri.ipp @@ -22,8 +22,8 @@ uri_wrapper::operator std::string() const { return uri; } -uri_wrapper::operator boost::network::uri::uri() const { - boost::network::uri::uri uri; +uri_wrapper::operator ::network::uri() const { + ::network::uri uri; request_.get_uri(uri); return uri; } diff --git a/boost/network/protocol/http/request/request.hpp b/boost/network/protocol/http/request/request.hpp index 9169b5bc6..a92fda54b 100644 --- a/boost/network/protocol/http/request/request.hpp +++ b/boost/network/protocol/http/request/request.hpp @@ -8,7 +8,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include +#include #include #include #include @@ -21,7 +21,7 @@ struct request : request_base { // We support full value semantics. request(); explicit request(std::string const & url); - explicit request(uri::uri const & url); + explicit request(::network::uri const & url); request(request const &); request& operator=(request); void swap(request & other); @@ -54,12 +54,12 @@ struct request : request_base { virtual void set_status_message(std::string const & status_message); virtual void set_body_writer(function writer); virtual void set_uri(std::string const &uri); - virtual void set_uri(network::uri::uri const &uri); + virtual void set_uri(::network::uri const &uri); virtual void set_version_major(unsigned short major_version); virtual void set_version_minor(unsigned short minor_version); // Getters - virtual void get_uri(network::uri::uri &uri) const; + virtual void get_uri(::network::uri &uri) const; virtual void get_uri(std::string &uri) const; virtual void get_method(std::string & method) const; virtual void get_status(std::string & status) const; diff --git a/boost/network/protocol/http/request/request.ipp b/boost/network/protocol/http/request/request.ipp index f7696cdca..70e6bbfed 100644 --- a/boost/network/protocol/http/request/request.ipp +++ b/boost/network/protocol/http/request/request.ipp @@ -34,6 +34,14 @@ struct request_pimpl { , headers_() {} + explicit request_pimpl(::network::uri const & url) + : uri_(url) + , read_offset_(0) + , source_() + , destination_() + , headers_() + {} + request_pimpl* clone() const { return new (std::nothrow) request_pimpl(*this); } @@ -42,7 +50,7 @@ struct request_pimpl { uri_ = uri; } - void set_uri(uri::uri const & uri) { + void set_uri(::network::uri const & uri) { uri_ = uri; } @@ -50,7 +58,7 @@ struct request_pimpl { uri = uri_.string(); } - void get_uri(uri::uri &uri) { + void get_uri(::network::uri &uri) { uri = uri_; } @@ -136,7 +144,7 @@ struct request_pimpl { private: typedef std::multimap headers_type; - uri::uri uri_; + ::network::uri uri_; size_t read_offset_; std::string source_, destination_; headers_type headers_; @@ -163,6 +171,10 @@ request::request(std::string const & url) : pimpl_(new (std::nothrow) request_pimpl(url)) {} +request::request(::network::uri const & url) +: pimpl_(new (std::nothrow) request_pimpl(url)) +{} + request::request(request const &other) : pimpl_(other.pimpl_->clone()) {} @@ -266,7 +278,7 @@ void request::set_uri(std::string const &uri) { pimpl_->set_uri(uri); } -void request::set_uri(network::uri::uri const &uri) { +void request::set_uri(::network::uri const &uri) { pimpl_->set_uri(uri); } @@ -279,7 +291,7 @@ void request::set_version_minor(unsigned short minor_version) { } // Getters -void request::get_uri(network::uri::uri &uri) const { +void request::get_uri(::network::uri &uri) const { pimpl_->get_uri(uri); } diff --git a/boost/network/protocol/http/request/request_base.hpp b/boost/network/protocol/http/request/request_base.hpp index fdb39d1cd..91510430c 100644 --- a/boost/network/protocol/http/request/request_base.hpp +++ b/boost/network/protocol/http/request/request_base.hpp @@ -12,7 +12,7 @@ #endif #include -#include +#include namespace boost { namespace network { namespace http { @@ -46,10 +46,10 @@ struct request_base : message_base, request_storage_base { virtual void set_status_message(std::string const & status_message) = 0; virtual void set_body_writer(function writer) = 0; virtual void set_uri(std::string const &uri) = 0; - virtual void set_uri(network::uri::uri const &uri) = 0; + virtual void set_uri(::network::uri const &uri) = 0; // Getters - virtual void get_uri(network::uri::uri &uri) const = 0; + virtual void get_uri(::network::uri &uri) const = 0; virtual void get_uri(std::string &uri) const = 0; virtual void get_method(std::string & method) const = 0; virtual void get_status(std::string & status) const = 0; @@ -60,9 +60,9 @@ struct request_base : message_base, request_storage_base { }; } /* http */ - + } /* network */ - + } /* boost */ #endif /* BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_BASE_HPP_20111008 */ diff --git a/boost/network/protocol/http/server/connection/sync.hpp b/boost/network/protocol/http/server/connection/sync.hpp index 0487bd9c2..3ed2107d3 100644 --- a/boost/network/protocol/http/server/connection/sync.hpp +++ b/boost/network/protocol/http/server/connection/sync.hpp @@ -73,7 +73,7 @@ class sync_server_connection : public boost::enable_shared_from_this>*/ struct hello_world; -typedef http::server server; +typedef http::sync_server server; /*<< Defines the request handler. It's a class that defines two functions, `operator()` and `log()` >>*/ @@ -28,11 +28,11 @@ struct hello_world { /*<< This is the function that handles the incoming request. >>*/ void operator() (server::request const &request, server::response &response) { - server::string_type ip = source(request); - std::ostringstream data; - data << "Hello, " << ip << "!"; - response = server::response::stock_reply( - server::response::ok, data.str()); + //server::string_type ip = source(request); + //std::ostringstream data; + //data << "Hello, " << ip << "!"; + //response = server::response::stock_reply( + // server::response::ok, data.str()); } /*<< It's necessary to define a log function, but it's ignored in this example. >>*/ @@ -43,7 +43,7 @@ struct hello_world { int main(int argc, char * argv[]) { - + if (argc != 3) { std::cerr << "Usage: " << argv[0] << " address port" << std::endl; return 1; @@ -53,7 +53,8 @@ int main(int argc, char * argv[]) { /*<< Creates the request handler. >>*/ hello_world handler; /*<< Creates the server. >>*/ - server server_(argv[1], argv[2], handler); + http::server_options options; + server server_(options.address(argv[1]).port(argv[2]), handler); /*<< Runs the server. >>*/ server_.run(); } @@ -61,7 +62,7 @@ int main(int argc, char * argv[]) { std::cerr << e.what() << std::endl; return 1; } - + return 0; } //] diff --git a/libs/network/example/simple_wget.cpp b/libs/network/example/simple_wget.cpp index baf9aaae6..760b82c8a 100644 --- a/libs/network/example/simple_wget.cpp +++ b/libs/network/example/simple_wget.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Glyn Matthews 2009, 2010. +// Copyright (c) Glyn Matthews 2009-2012. // 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) @@ -15,19 +15,18 @@ #include -#include +#include #include #include #include namespace http = boost::network::http; -namespace uri = boost::network::uri; namespace { -std::string get_filename(const uri::uri &url) { - std::string path = uri::path(url); +std::string get_filename(const network::uri &url) { + std::string path = network::path(url); std::size_t index = path.find_last_of('/'); std::string filename = path.substr(index + 1); return filename.empty()? "index.html" : filename; @@ -48,7 +47,9 @@ main(int argc, char *argv[]) { http::client::request request(argv[1]); http::client::response response = client.get(request); - std::string filename = get_filename(request.uri()); + network::uri uri; + request.get_uri(uri); + std::string filename = get_filename(uri); std::cout << "Saving to: " << filename << std::endl; std::ofstream ofs(filename.c_str()); ofs << static_cast(body(response)) << std::endl; diff --git a/libs/network/example/twitter/search.cpp b/libs/network/example/twitter/search.cpp index 1d0f2fafa..d4e4d8db6 100644 --- a/libs/network/example/twitter/search.cpp +++ b/libs/network/example/twitter/search.cpp @@ -3,7 +3,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) - +#include #include #include "rapidjson/rapidjson.h" #include "rapidjson/document.h" @@ -14,7 +14,7 @@ // https://dev.twitter.com/docs/using-search int main(int argc, char *argv[]) { - using namespace boost::network; + namespace http = boost::network::http; using namespace rapidjson; if (argc != 2) { @@ -25,16 +25,18 @@ int main(int argc, char *argv[]) { try { http::client client; - uri::uri base_uri("http://search.twitter.com/search.json"); + network::uri base_uri("http://search.twitter.com/search.json"); std::cout << "Searching Twitter for query: " << argv[1] << std::endl; - uri::uri search; - search << base_uri << uri::query("q", uri::encoded(argv[1])); + network::uri search; + search << base_uri << network::query("q", network::encoded(argv[1])); http::client::request request(search); http::client::response response = client.get(request); Document d; - if (!d.Parse<0>(response.body().c_str()).HasParseError()) { + std::string body; + response.get_body(body); + if (!d.Parse<0>(body.c_str()).HasParseError()) { const Value &results = d["results"]; for (SizeType i = 0; i < results.Size(); ++i) { diff --git a/libs/network/example/uri_builder.cpp b/libs/network/example/uri_builder.cpp index e37160d0b..5045c63b9 100644 --- a/libs/network/example/uri_builder.cpp +++ b/libs/network/example/uri_builder.cpp @@ -1,24 +1,20 @@ -// Copyright (c) Glyn Matthews 2011. +// Copyright (c) Glyn Matthews 2011, 2012. // 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) #include -#include -#include - - -using namespace boost::network; - +#include +#include int main(int argc, char *argv[]) { - uri::uri url; - url << uri::scheme("http") - << uri::host("www.github.com") - << uri::path("/cpp-netlib"); + network::uri url; + url << network::scheme("http") + << network::host("www.github.com") + << network::path("/cpp-netlib"); std::cout << url << std::endl; return 0; diff --git a/libs/network/src/CMakeLists.txt b/libs/network/src/CMakeLists.txt index 2912d7df6..255051dcd 100644 --- a/libs/network/src/CMakeLists.txt +++ b/libs/network/src/CMakeLists.txt @@ -9,44 +9,31 @@ include_directories(${CPP-NETLIB_SOURCE_DIR}/include) include_directories(${CPP-NETLIB_SOURCE_DIR}) -set(CPP-NETLIB_URI_SRCS uri/uri.cpp uri/schemes.cpp) -add_library(cppnetlib-uri ${CPP-NETLIB_URI_SRCS}) -foreach (src_file ${CPP-NETLIB_URI_SRCS}) -if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) - set_source_files_properties(${src_file} - PROPERTIES COMPILE_FLAGS "-Wall -Werror") -endif() -endforeach(src_file) - -set(CPP-NETLIB_HTTP_SERVER_PARSERS_SRCS server_request_parsers_impl.cpp) -add_library(cppnetlib-http-server-parsers ${CPP-NETLIB_HTTP_SERVER_PARSERS_SRCS}) -foreach (src_file ${CPP-NETLIB_HTTP_SERVER_PARSERS_SRCS}) if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) - set_source_files_properties(${src_file} - PROPERTIES COMPILE_FLAGS "-Wall -Werror") + if (HAVE_STD11) + set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11") + elseif (HAVE_STD0X) + set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++0x") + endif() endif() -endforeach(src_file) -set(CPP-NETLIB_HTTP_SERVER_SRCS - http/server_async_impl.cpp - http/server_options.cpp - http/server_socket_options_setter.cpp - http/server_sync_impl.cpp - ) -add_library(cppnetlib-http-servers ${CPP-NETLIB_HTTP_SERVER_SRCS}) -foreach (src_file ${CPP-NETLIB_HTTP_SERVER_SRCS}) +set(CPP-NETLIB_URI_SRCS uri/uri.cpp uri/schemes.cpp) +add_library(cppnetlib-uri ${CPP-NETLIB_URI_SRCS}) +foreach (src_file ${CPP-NETLIB_URI_SRCS}) if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) set_source_files_properties(${src_file} - PROPERTIES COMPILE_FLAGS "-Wall -Werror") + PROPERTIES COMPILE_FLAGS ${CPP-NETLIB_CXXFLAGS}) endif() endforeach(src_file) set(CPP-NETLIB_MESSAGE_SRCS message/message.cpp) add_library(cppnetlib-message ${CPP-NETLIB_MESSAGE_SRCS}) +add_dependencies(cppnetlib-message cppnetlib-uri) +target_link_libraries(cppnetlib-message cppnetlib-uri) foreach (src_file ${CPP-NETLIB_MESSAGE_SRCS}) if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) set_source_files_properties(${src_file} - PROPERTIES COMPILE_FLAGS "-Wall -Werror") + PROPERTIES COMPILE_FLAGS ${CPP-NETLIB_CXXFLAGS}) endif() endforeach(src_file) @@ -55,7 +42,7 @@ add_library(cppnetlib-message-directives ${CPP-NETLIB_MESSAGE_DIRECTIVES_SRCS}) foreach (src_file ${CPP-NETLIB_MESSAGE_DIRECTIVES_SRCS}) if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) set_source_files_properties(${src_file} - PROPERTIES COMPILE_FLAGS "-Wall -Werror") + PROPERTIES COMPILE_FLAGS ${CPP-NETLIB_CXXFLAGS}) endif() endforeach(src_file) @@ -64,16 +51,22 @@ add_library(cppnetlib-message-wrappers ${CPP-NETLIB_MESSAGE_WRAPPERS_SRCS}) foreach (src_file ${CPP-NETLIB_MESSAGE_WRAPPERS_SRCS}) if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) set_source_files_properties(${src_file} - PROPERTIES COMPILE_FLAGS "-Wall -Werror") + PROPERTIES COMPILE_FLAGS ${CPP-NETLIB_CXXFLAGS}) endif() endforeach(src_file) set(CPP-NETLIB_HTTP_MESSAGE_SRCS http/request.cpp http/response.cpp) add_library(cppnetlib-http-message ${CPP-NETLIB_HTTP_MESSAGE_SRCS}) +add_dependencies(cppnetlib-http-message + ${Boost_LIBRARIES} + cppnetlib-message) +target_link_libraries(cppnetlib-http-message + ${Boost_LIBRARIES} + cppnetlib-message) foreach (src_file ${CPP-NETLIB_HTTP_MESSAGE_SRCS}) if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) set_source_files_properties(${src_file} - PROPERTIES COMPILE_FLAGS "-Wall -Werror") + PROPERTIES COMPILE_FLAGS ${CPP-NETLIB_CXXFLAGS}) endif() endforeach(src_file) @@ -82,7 +75,52 @@ add_library(cppnetlib-http-message-wrappers ${CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_S foreach (src_file ${CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS}) if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) set_source_files_properties(${src_file} - PROPERTIES COMPILE_FLAGS "-Wall -Werror") + PROPERTIES COMPILE_FLAGS ${CPP-NETLIB_CXXFLAGS}) +endif() +endforeach(src_file) + +set(CPP-NETLIB_HTTP_SERVER_PARSERS_SRCS server_request_parsers_impl.cpp) +add_library(cppnetlib-http-server-parsers ${CPP-NETLIB_HTTP_SERVER_PARSERS_SRCS}) +foreach (src_file ${CPP-NETLIB_HTTP_SERVER_PARSERS_SRCS}) +if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) + set_source_files_properties(${src_file} + PROPERTIES COMPILE_FLAGS ${CPP-NETLIB_CXXFLAGS}) +endif() +endforeach(src_file) + +set(CPP-NETLIB_HTTP_SERVER_SRCS + http/server_async_impl.cpp + http/server_options.cpp + http/server_socket_options_setter.cpp + http/server_sync_impl.cpp + ) +add_library(cppnetlib-http-server ${CPP-NETLIB_HTTP_SERVER_SRCS}) +add_dependencies(cppnetlib-http-server + ${Boost_LIBRARIES} + cppnetlib-constants + cppnetlib-uri + cppnetlib-message + cppnetlib-message-wrappers + cppnetlib-message-directives + cppnetlib-http-message + cppnetlib-http-message-wrappers + cppnetlib-http-server-parsers + ) +target_link_libraries(cppnetlib-http-server + ${Boost_LIBRARIES} + cppnetlib-constants + cppnetlib-uri + cppnetlib-message + cppnetlib-message-wrappers + cppnetlib-message-directives + cppnetlib-http-message + cppnetlib-http-message-wrappers + cppnetlib-http-server-parsers + ) +foreach (src_file ${CPP-NETLIB_HTTP_SERVER_SRCS}) +if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) + set_source_files_properties(${src_file} + PROPERTIES COMPILE_FLAGS ${CPP-NETLIB_CXXFLAGS}) endif() endforeach(src_file) @@ -101,17 +139,39 @@ add_library(cppnetlib-http-client-connections ${CPP-NETLIB_HTTP_CLIENT_CONNECTIO foreach (src_file ${CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS}) if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) set_source_files_properties(${src_file} - PROPERTIES COMPILE_FLAGS "-Wall -Werror") + PROPERTIES COMPILE_FLAGS ${CPP-NETLIB_CXXFLAGS}) endif() endforeach(src_file) set(CPP-NETLIB_HTTP_CLIENT_SRCS http/client.cpp) add_library(cppnetlib-http-client ${CPP-NETLIB_HTTP_CLIENT_SRCS}) +add_dependencies(cppnetlib-http-client + ${Boost_LIBRARIES} + cppnetlib-constants + cppnetlib-uri + cppnetlib-message + cppnetlib-message-wrappers + cppnetlib-message-directives + cppnetlib-http-message + cppnetlib-http-message-wrappers + cppnetlib-http-client-connections + ) +target_link_libraries(cppnetlib-http-client + ${Boost_LIBRARIES} + cppnetlib-constants + cppnetlib-uri + cppnetlib-message + cppnetlib-message-wrappers + cppnetlib-message-directives + cppnetlib-http-message + cppnetlib-http-message-wrappers + cppnetlib-http-client-connections + ) foreach (src_file ${CPP-NETLIB_HTTP_CLIENT_SRCS}) if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) set_source_files_properties(${src_file} - PROPERTIES COMPILE_FLAGS "-Wall -Werror") + PROPERTIES COMPILE_FLAGS ${CPP-NETLIB_CXXFLAGS}) endif() endforeach(src_file) @@ -120,7 +180,7 @@ add_library(cppnetlib-utils-thread_pool ${CPP-NETLIB_UTILS_THREAD_POOL_SRCS}) foreach (src_file ${CPP-NETLIB_UTILS_THREAD_POOL_SRCS}) if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) set_source_files_properties(${src_file} - PROPERTIES COMPILE_FLAGS "-Wall -Werror") + PROPERTIES COMPILE_FLAGS ${CPP-NETLIB_CXXFLAGS}) endif() endforeach(src_file) @@ -129,6 +189,6 @@ add_library(cppnetlib-constants ${CPP-NETLIB_CONSTANTS_SRCS}) foreach (src_file ${CPP-NETLIB_CONSTANTS_SRCS}) if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) set_source_files_properties(${src_file} - PROPERTIES COMPILE_FLAGS "-Wall -Werror") + PROPERTIES COMPILE_FLAGS ${CPP-NETLIB_CXXFLAGS}) endif() endforeach(src_file) diff --git a/libs/network/test/http/CMakeLists.txt b/libs/network/test/http/CMakeLists.txt index 555541558..135c7d0ab 100644 --- a/libs/network/test/http/CMakeLists.txt +++ b/libs/network/test/http/CMakeLists.txt @@ -4,6 +4,7 @@ # (See accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) +include_directories(${CPP-NETLIB_SOURCE_DIR}/include) include_directories(${CPP-NETLIB_SOURCE_DIR}) if (OPENSSL_FOUND) @@ -25,8 +26,17 @@ if (Boost_FOUND) PROPERTIES COMPILE_FLAGS "-Wall") endif() add_executable(cpp-netlib-http-${test} ${test}.cpp) + add_dependencies(cpp-netlib-http-${test} + cppnetlib-message + cppnetlib-message-wrappers + cppnetlib-http-message + cppnetlib-http-message-wrappers + cppnetlib-uri + cppnetlib-constants + ) target_link_libraries(cpp-netlib-http-${test} ${Boost_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} cppnetlib-message cppnetlib-message-wrappers cppnetlib-http-message @@ -92,7 +102,7 @@ if (Boost_FOUND) cppnetlib-message cppnetlib-message-wrappers cppnetlib-http-message - cppnetlib-http-servers + cppnetlib-http-server cppnetlib-http-server-parsers cppnetlib-utils-thread_pool ) diff --git a/libs/network/test/http/request_test.cpp b/libs/network/test/http/request_test.cpp index 5a9a2654f..1f87d30f2 100644 --- a/libs/network/test/http/request_test.cpp +++ b/libs/network/test/http/request_test.cpp @@ -12,7 +12,6 @@ #include namespace http = boost::network::http; -namespace uri = boost::network::uri; namespace net = boost::network; BOOST_AUTO_TEST_CASE(request_construction) { @@ -57,10 +56,10 @@ BOOST_AUTO_TEST_CASE(request_uri_test) { // Now we test the bare uri instance with accessing using the request // convenience wrapper. - uri::uri uri_; + network::uri uri_; request.get_uri(uri_); std::string host_ = http::host(request); - BOOST_CHECK(uri::valid(uri_)); + BOOST_CHECK(network::valid(uri_)); BOOST_CHECK_EQUAL(std::string("www.google.com"), host_); BOOST_CHECK_EQUAL(uri_.host(), host_); BOOST_CHECK_EQUAL(std::string("www.google.com"), uri_.host()); @@ -70,13 +69,13 @@ BOOST_AUTO_TEST_CASE(request_url_constructor_test) { http::request request("http://www.google.com/"); http::request other; other.set_uri("http://www.google.com/"); - uri::uri original, other_uri; + network::uri original, other_uri; request.get_uri(original); other.get_uri(other_uri); BOOST_CHECK_EQUAL(original, other_uri); // Now test the directives.. - uri::uri directive_original = http::uri(request); + network::uri directive_original = http::uri(request); BOOST_CHECK_EQUAL(original, directive_original); } @@ -89,7 +88,7 @@ BOOST_AUTO_TEST_CASE(request_basics_test) { request.append_header("Connection", "close"); request.append_body("The quick brown fox jumps over the lazy dog!"); - uri::uri uri_; + network::uri uri_; std::string source_, destination_, body_; net::headers_wrapper::container_type const &headers_ = headers(request); request.get_uri(uri_); diff --git a/libs/network/test/uri/CMakeLists.txt b/libs/network/test/uri/CMakeLists.txt index 92fb226fa..dc3a323de 100644 --- a/libs/network/test/uri/CMakeLists.txt +++ b/libs/network/test/uri/CMakeLists.txt @@ -4,6 +4,7 @@ # (See accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) +include_directories(${CPP-NETLIB_SOURCE_DIR}/include) include_directories(${CPP-NETLIB_SOURCE_DIR}) if (Boost_FOUND) diff --git a/libs/network/test/uri/relative_uri_test.cpp b/libs/network/test/uri/relative_uri_test.cpp index a12836e8b..4c8dd52c3 100644 --- a/libs/network/test/uri/relative_uri_test.cpp +++ b/libs/network/test/uri/relative_uri_test.cpp @@ -6,13 +6,11 @@ #define BOOST_TEST_MODULE Relative URL Test #include #include -#include -#include - -using namespace boost::network; +#include +#include BOOST_AUTO_TEST_CASE(relative_uri_test) { // don't yet support relative URIs - uri::uri instance("example.com"); - BOOST_REQUIRE(!uri::valid(instance)); + network::uri instance("example.com"); + BOOST_REQUIRE(!network::valid(instance)); } From 190c310f6c6edf5216098b4e47b8fb0085cf5970 Mon Sep 17 00:00:00 2001 From: Glyn Matthews Date: Sun, 13 May 2012 10:22:50 +0200 Subject: [PATCH 088/196] [http_refactor] Removed boost/network/uri subdirectory to avoid confusion. --- boost/network/uri.hpp | 12 - boost/network/uri/accessors.hpp | 112 ----- boost/network/uri/builder.hpp | 181 -------- boost/network/uri/config.hpp | 21 - boost/network/uri/decode.hpp | 108 ----- boost/network/uri/detail/uri_parts.hpp | 103 ----- boost/network/uri/directives.hpp | 48 --- boost/network/uri/directives/authority.hpp | 40 -- boost/network/uri/directives/fragment.hpp | 46 --- boost/network/uri/directives/host.hpp | 44 -- boost/network/uri/directives/path.hpp | 65 --- boost/network/uri/directives/port.hpp | 56 --- boost/network/uri/directives/query.hpp | 80 ---- boost/network/uri/directives/scheme.hpp | 68 --- boost/network/uri/directives/user_info.hpp | 45 -- boost/network/uri/encode.hpp | 176 -------- boost/network/uri/schemes.hpp | 37 -- boost/network/uri/uri.hpp | 435 -------------------- boost/network/uri/uri.ipp | 239 ----------- boost/network/uri/uri_io.hpp | 27 -- include/network/uri/directives/fragment.hpp | 1 - include/network/uri/directives/query.hpp | 1 - libs/network/test/CMakeLists.txt | 2 +- libs/network/test/http/request_test.cpp | 2 +- 24 files changed, 2 insertions(+), 1947 deletions(-) delete mode 100644 boost/network/uri.hpp delete mode 100644 boost/network/uri/accessors.hpp delete mode 100644 boost/network/uri/builder.hpp delete mode 100644 boost/network/uri/config.hpp delete mode 100644 boost/network/uri/decode.hpp delete mode 100644 boost/network/uri/detail/uri_parts.hpp delete mode 100644 boost/network/uri/directives.hpp delete mode 100644 boost/network/uri/directives/authority.hpp delete mode 100644 boost/network/uri/directives/fragment.hpp delete mode 100644 boost/network/uri/directives/host.hpp delete mode 100644 boost/network/uri/directives/path.hpp delete mode 100644 boost/network/uri/directives/port.hpp delete mode 100644 boost/network/uri/directives/query.hpp delete mode 100644 boost/network/uri/directives/scheme.hpp delete mode 100644 boost/network/uri/directives/user_info.hpp delete mode 100644 boost/network/uri/encode.hpp delete mode 100644 boost/network/uri/schemes.hpp delete mode 100644 boost/network/uri/uri.hpp delete mode 100644 boost/network/uri/uri.ipp delete mode 100644 boost/network/uri/uri_io.hpp diff --git a/boost/network/uri.hpp b/boost/network/uri.hpp deleted file mode 100644 index e9ad1ffea..000000000 --- a/boost/network/uri.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef BOOST_NETWORK_URL_HPP_ -#define BOOST_NETWORK_URL_HPP_ - -// Copyright 2009 Dean Michael Berris. -// 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) - -#include - -#endif - diff --git a/boost/network/uri/accessors.hpp b/boost/network/uri/accessors.hpp deleted file mode 100644 index 0462150f5..000000000 --- a/boost/network/uri/accessors.hpp +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright (c) Glyn Matthews 2011. -// 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 __BOOST_NETWORK_URI_URI_ACCESSORS_INC__ -# define __BOOST_NETWORK_URI_URI_ACCESSORS_INC__ - - -# include -# include -# include -# include -# include - - -namespace boost { -namespace network { -namespace uri { -namespace details { -template < - typename Map - > -struct key_value_sequence - : spirit::qi::grammar -{ - typedef typename Map::key_type key_type; - typedef typename Map::mapped_type mapped_type; - typedef std::pair pair_type; - - key_value_sequence() - : key_value_sequence::base_type(query) - { - query = pair >> *((spirit::qi::lit(';') | '&') >> pair); - pair = key >> -('=' >> value); - key = spirit::qi::char_("a-zA-Z_") >> *spirit::qi::char_("a-zA-Z_0-9/%"); - value = +spirit::qi::char_("a-zA-Z_0-9/%"); - } - - spirit::qi::rule query; - spirit::qi::rule pair; - spirit::qi::rule key; - spirit::qi::rule value; -}; -} // namespace details - -template < - class Map - > -inline -Map &query_map(const uri &uri_, Map &map) { - const uri::string_type range = uri_.query(); - details::key_value_sequence parser; - spirit::qi::parse(boost::begin(range), boost::end(range), parser, map); - return map; -} - -inline -uri::string_type username(const uri &uri_) { - const uri::string_type user_info = uri_.user_info(); - uri::const_iterator it(boost::begin(user_info)), end(boost::end(user_info)); - for (; it != end; ++it) { - if (*it == ':') { - break; - } - } - return uri::string_type(boost::begin(user_info), it); -} - -inline -uri::string_type password(const uri &uri_) { - const uri::string_type user_info = uri_.user_info(); - uri::const_iterator it(boost::begin(user_info)), end(boost::end(user_info)); - for (; it != end; ++it) { - if (*it == ':') { - ++it; - break; - } - } - return uri::string_type(it, boost::end(user_info)); -} - -inline -uri::string_type decoded_path(const uri &uri_) { - const uri::string_type path = uri_.path(); - uri::string_type decoded_path; - decode(path, std::back_inserter(decoded_path)); - return decoded_path; -} - -inline -uri::string_type decoded_query(const uri &uri_) { - const uri::string_type query = uri_.query(); - uri::string_type decoded_query; - decode(query, std::back_inserter(decoded_query)); - return decoded_query; -} - -inline -uri::string_type decoded_fragment(const uri &uri_) { - const uri::string_type fragment = uri_.fragment(); - uri::string_type decoded_fragment; - decode(fragment, std::back_inserter(decoded_fragment)); - return decoded_fragment; -} -} // namespace uri -} // namespace network -} // namespace boost - - -#endif // __BOOST_NETWORK_URI_URI_ACCESSORS_INC__ diff --git a/boost/network/uri/builder.hpp b/boost/network/uri/builder.hpp deleted file mode 100644 index 7f0103e36..000000000 --- a/boost/network/uri/builder.hpp +++ /dev/null @@ -1,181 +0,0 @@ -// Copyright (c) Glyn Matthews 2012. -// 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 __BOOST_NETWORK_URI_BUILDER_INC__ -# define __BOOST_NETWORK_URI_BUILDER_INC__ - - -# include -# include - - -namespace boost { -namespace network { -namespace uri { -class builder { - - typedef uri::string_type string_type; - -public: - - builder(uri &uri_) - : uri_(uri_) { - - } - - builder &set_scheme(const string_type &scheme) { - uri_.uri_.append(scheme); - if (opaque_schemes::exists(scheme)) { - uri_.uri_.append(":"); - } - else { - uri_.uri_.append("://"); - } - uri_.parse(); - return *this; - } - - builder &scheme(const string_type &scheme) { - return set_scheme(scheme); - } - - builder &set_user_info(const string_type &user_info) { - uri_.uri_.append(user_info); - uri_.uri_.append("@"); - uri_.parse(); - return *this; - } - - builder &user_info(const string_type &user_info) { - return set_user_info(user_info); - } - - builder &set_host(const string_type &host) { - uri_.uri_.append(host); - uri_.parse(); - return *this; - } - - builder &host(const string_type &host) { - return set_host(host); - } - - builder &set_host(const asio::ip::address &address) { - uri_.uri_.append(address.to_string()); - uri_.parse(); - return *this; - } - - builder &host(const asio::ip::address &host) { - return set_host(host); - } - - builder &set_host(const asio::ip::address_v4 &address) { - uri_.uri_.append(address.to_string()); - uri_.parse(); - return *this; - } - - builder &host(const asio::ip::address_v4 &host) { - return set_host(host); - } - - builder &set_host(const asio::ip::address_v6 &address) { - uri_.uri_.append("["); - uri_.uri_.append(address.to_string()); - uri_.uri_.append("]"); - uri_.parse(); - return *this; - } - - builder &host(const asio::ip::address_v6 &host) { - return set_host(host); - } - - builder &set_port(const string_type &port) { - uri_.uri_.append(":"); - uri_.uri_.append(port); - uri_.parse(); - return *this; - } - - builder &port(const string_type &port) { - return set_port(port); - } - - builder &port(uint16_t port) { - return set_port(boost::lexical_cast(port)); - } - - builder &set_path(const string_type &path) { - uri_.uri_.append(path); - uri_.parse(); - return *this; - } - - builder &path(const string_type &path) { - return set_path(path); - } - - builder &encoded_path(const string_type &path) { - string_type encoded_path; - encode(path, std::back_inserter(encoded_path)); - return set_path(encoded_path); - } - - builder &set_query(const string_type &query) { - uri_.uri_.append("?"); - uri_.uri_.append(query); - uri_.parse(); - return *this; - } - - builder &set_query(const string_type &key, const string_type &value) { - if (!uri_.query_range()) - { - uri_.uri_.append("?"); - } - else - { - uri_.uri_.append("&"); - } - uri_.uri_.append(key); - uri_.uri_.append("="); - uri_.uri_.append(value); - uri_.parse(); - return *this; - } - - builder &query(const string_type &query) { - return set_query(query); - } - - builder &query(const string_type &key, const string_type &value) { - return set_query(key, value); - } - - builder &set_fragment(const string_type &fragment) { - uri_.uri_.append("#"); - uri_.uri_.append(fragment); - uri_.parse(); - return *this; - } - - builder &fragment(const string_type &fragment) { - return set_fragment(fragment); - } - -private: - - uri &uri_; - -}; -} // namespace uri -} // namespace network -} // namespace boost - - -#endif // __BOOST_NETWORK_URI_BUILDER_INC__ diff --git a/boost/network/uri/config.hpp b/boost/network/uri/config.hpp deleted file mode 100644 index 0cb9e17a9..000000000 --- a/boost/network/uri/config.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Glyn Matthews 2012. -// 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 __BOOST_NETWORK_URI_CONFIG_INC__ -# define __BOOST_NETWORK_URI_CONFIG_INC__ - - -# include -# include - -# if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_URI_DYN_LINK) -# define BOOST_URI_DECL -# else -# define BOOST_URI_DECL -# endif // defined(BOOST_ALL_DYN_LINK) || defined(BOOST_URI_DYN_LINK) - - -#endif // __BOOST_NETWORK_URI_CONFIG_INC__ diff --git a/boost/network/uri/decode.hpp b/boost/network/uri/decode.hpp deleted file mode 100644 index 2f950dfad..000000000 --- a/boost/network/uri/decode.hpp +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (c) Glyn Matthews 2011. -// 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 __BOOST_NETWORK_URI_DECODE_INC__ -# define __BOOST_NETWORK_URI_DECODE_INC__ - - -# include -# include -# include -# include - - -namespace boost { -namespace network { -namespace uri { -namespace detail { -template < - typename CharT - > -CharT letter_to_hex(CharT in) -{ - switch (in) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - return in - '0'; - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - return in + 10 - 'a'; - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - return in + 10 - 'A'; - } - return CharT(); -} -} // namespace detail - -template < - class InputIterator, - class OutputIterator - > -OutputIterator decode(const InputIterator &in_begin, - const InputIterator &in_end, - const OutputIterator &out_begin) { - typedef typename boost::iterator_value::type value_type; - - InputIterator it = in_begin; - OutputIterator out = out_begin; - while (it != in_end) { - if (*it == '%') - { - ++it; - value_type v0 = detail::letter_to_hex(*it); - ++it; - value_type v1 = detail::letter_to_hex(*it); - ++it; - *out++ = 0x10 * v0 + v1; - } - else - { - *out++ = *it++; - } - } - return out; -} - -template < - class SinglePassRange, - class OutputIterator - > -inline -OutputIterator decode(const SinglePassRange &range, - const OutputIterator &out) { - return decode(boost::begin(range), boost::end(range), out); -} - -inline -std::string decoded(const std::string &input) { - std::string decoded; - decode(input, std::back_inserter(decoded)); - return decoded; -} -} // namespace uri -} // namespace network -} // namespace boost - - -#endif // __BOOST_NETWORK_URI_DECODE_INC__ diff --git a/boost/network/uri/detail/uri_parts.hpp b/boost/network/uri/detail/uri_parts.hpp deleted file mode 100644 index f9c89f8a1..000000000 --- a/boost/network/uri/detail/uri_parts.hpp +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2009, 2010, 2011, 2012 Dean Michael Berris, Jeroen Habraken, Glyn Matthews. -// 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 BOOST_NETWORK_URL_DETAIL_URL_PARTS_HPP_ -# define BOOST_NETWORK_URL_DETAIL_URL_PARTS_HPP_ - - -# include -# include - - -namespace boost { -namespace network { -namespace uri { -namespace detail { -template < - class FwdIter - > -struct hierarchical_part { - optional > user_info; - optional > host; - optional > port; - optional > path; - - FwdIter begin() const { - return boost::begin(user_info); - } - - FwdIter end() const { - return boost::end(path); - } - - void update() { - if (!user_info) { - if (host) { - user_info = iterator_range(boost::begin(host.get()), - boost::begin(host.get())); - } - else if (path) { - user_info = iterator_range(boost::begin(path.get()), - boost::begin(path.get())); - } - } - - if (!host) { - host = iterator_range(boost::begin(path.get()), - boost::begin(path.get())); - } - - if (!port) { - port = iterator_range(boost::end(host.get()), - boost::end(host.get())); - } - - if (!path) { - path = iterator_range(boost::end(port.get()), - boost::end(port.get())); - } - } - -}; - -template < - class FwdIter - > -struct uri_parts { - iterator_range scheme; - hierarchical_part hier_part; - optional > query; - optional > fragment; - - FwdIter begin() const { - return boost::begin(scheme); - } - - FwdIter end() const { - return boost::end(fragment); - } - - void update() { - - hier_part.update(); - - if (!query) { - query = iterator_range(boost::end(hier_part.path.get()), - boost::end(hier_part.path.get())); - } - - if (!fragment) { - fragment = iterator_range(boost::end(query.get()), - boost::end(query.get())); - } - } -}; -} // namespace detail -} // namespace uri -} // namespace network -} // namespace boost - - -#endif // BOOST_NETWORK_URL_DETAIL_URL_PARTS_HPP_ diff --git a/boost/network/uri/directives.hpp b/boost/network/uri/directives.hpp deleted file mode 100644 index eb5beaa12..000000000 --- a/boost/network/uri/directives.hpp +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Glyn Matthews 2011, 2012. -// 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 __BOOST_NETWORK_URI_DIRECTIVES_INC__ -# define __BOOST_NETWORK_URI_DIRECTIVES_INC__ - - -# include - - -namespace boost { -namespace network { -namespace uri { -inline -uri &operator << (uri &uri_, const uri &root_uri) { - if (empty(uri_) && valid(root_uri)) { - uri_.append(boost::begin(root_uri), boost::end(root_uri)); - } - return uri_; -} - -template < - class Directive - > -inline -uri &operator << (uri &uri_, const Directive &directive) { - directive(uri_); - return uri_; -} -} // namespace uri -} // namespace network -} // namespace boost - - -# include -# include -# include -# include -# include -# include -# include -# include - - -#endif // __BOOST_NETWORK_URI_DIRECTIVES_INC__ diff --git a/boost/network/uri/directives/authority.hpp b/boost/network/uri/directives/authority.hpp deleted file mode 100644 index 189d4649c..000000000 --- a/boost/network/uri/directives/authority.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Glyn Matthews 2011, 2012. -// 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 __BOOST_NETWORK_URI_DIRECTIVES_AUTHORITY_INC__ -# define __BOOST_NETWORK_URI_DIRECTIVES_AUTHORITY_INC__ - - -namespace boost { -namespace network { -namespace uri { -struct authority_directive { - - explicit authority_directive(const std::string &authority) - : authority(authority) - {} - - template < - class Uri - > - void operator () (Uri &uri) const { - uri.append(authority); - } - - std::string authority; - -}; - -inline -authority_directive authority(const std::string &authority) { - return authority_directive(authority); -} -} // namespace uri -} // namespace network -} // namespace boost - - -#endif // __BOOST_NETWORK_URI_DIRECTIVES_AUTHORITY_INC__ diff --git a/boost/network/uri/directives/fragment.hpp b/boost/network/uri/directives/fragment.hpp deleted file mode 100644 index 2342f7079..000000000 --- a/boost/network/uri/directives/fragment.hpp +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) Glyn Matthews 2011, 2012. -// 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 __BOOST_NETWORK_URI_DIRECTIVES_FRAGMENT_INC__ -# define __BOOST_NETWORK_URI_DIRECTIVES_FRAGMENT_INC__ - - -# include -# include -# include - - -namespace boost { -namespace network { -namespace uri { -struct fragment_directive { - - explicit fragment_directive(const std::string &fragment) - : fragment(fragment) - {} - - template < - class Uri - > - void operator () (Uri &uri) const { - uri.append("#"); - uri.append(fragment); - } - - std::string fragment; - -}; - -inline -fragment_directive fragment(const std::string &fragment) { - return fragment_directive(fragment); -} -} // namespace uri -} // namespace network -} // namespace boost - - -#endif // __BOOST_NETWORK_URI_DIRECTIVES_FRAGMENT_INC__ diff --git a/boost/network/uri/directives/host.hpp b/boost/network/uri/directives/host.hpp deleted file mode 100644 index 6aded4e47..000000000 --- a/boost/network/uri/directives/host.hpp +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) Glyn Matthews 2011, 2012. -// 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 __BOOST_NETWORK_URI_DIRECTIVES_HOST_INC__ -# define __BOOST_NETWORK_URI_DIRECTIVES_HOST_INC__ - - -# include -# include - - -namespace boost { -namespace network { -namespace uri { -struct host_directive { - - explicit host_directive(const std::string &host) - : host(host) - {} - - template < - class Uri - > - void operator () (Uri &uri) const { - uri.append(host); - } - - std::string host; - -}; - -inline -host_directive host(const std::string &host) { - return host_directive(host); -} -} // namespace uri -} // namespace network -} // namespace boost - - -#endif // __BOOST_NETWORK_URI_DIRECTIVES_HOST_INC__ diff --git a/boost/network/uri/directives/path.hpp b/boost/network/uri/directives/path.hpp deleted file mode 100644 index 89ec5f6f9..000000000 --- a/boost/network/uri/directives/path.hpp +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) Glyn Matthews 2011, 2012. -// 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 __BOOST_NETWORK_URI_DIRECTIVES_PATH_INC__ -# define __BOOST_NETWORK_URI_DIRECTIVES_PATH_INC__ - - -# include -# include - - -namespace boost { -namespace network { -namespace uri { -struct path_directive { - - explicit path_directive(const std::string &path) - : path(path) - {} - - template < - class Uri - > - void operator () (Uri &uri) const { - uri.append(path); - } - - std::string path; - -}; - -struct encoded_path_directive { - - explicit encoded_path_directive(const std::string &path) - : path(path) - {} - - void operator () (uri &uri_) const { - std::string encoded_path; - encode(path, std::back_inserter(encoded_path)); - uri_.append(encoded_path); - } - - std::string path; - -}; - -inline -path_directive path(const std::string &path) { - return path_directive(path); -} - -inline -encoded_path_directive encoded_path(const std::string &path) { - return encoded_path_directive(path); -} -} // namespace uri -} // namespace network -} // namespace boost - - -#endif // __BOOST_NETWORK_URI_DIRECTIVES_PATH_INC__ diff --git a/boost/network/uri/directives/port.hpp b/boost/network/uri/directives/port.hpp deleted file mode 100644 index c9e6818a6..000000000 --- a/boost/network/uri/directives/port.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) Glyn Matthews 2011, 2012. -// 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 __BOOST_NETWORK_URI_DIRECTIVES_PORT_INC__ -# define __BOOST_NETWORK_URI_DIRECTIVES_PORT_INC__ - - -# include -# include -# include -# include - - -namespace boost { -namespace network { -namespace uri { -struct port_directive { - - explicit port_directive(const std::string &port) - : port(port) - {} - - explicit port_directive(boost::uint16_t port) - : port(boost::lexical_cast(port)) - {} - - template < - class Uri - > - void operator () (Uri &uri) const { - uri.append(":"); - uri.append(port); - } - - std::string port; - -}; - -inline -port_directive port(const std::string &port) { - return port_directive(port); -} - -inline -port_directive port(boost::uint16_t port) { - return port_directive(port); -} -} // namespace uri -} // namespace network -} // namespace boost - - -#endif // __BOOST_NETWORK_URI_DIRECTIVES_PORT_INC__ diff --git a/boost/network/uri/directives/query.hpp b/boost/network/uri/directives/query.hpp deleted file mode 100644 index 8b795bd38..000000000 --- a/boost/network/uri/directives/query.hpp +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (c) Glyn Matthews 2011, 2012. -// 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 __BOOST_NETWORK_URI_DIRECTIVES_QUERY_INC__ -# define __BOOST_NETWORK_URI_DIRECTIVES_QUERY_INC__ - - -# include -# include -# include - - -namespace boost { -namespace network { -namespace uri { -struct query_directive { - - explicit query_directive(const std::string &query) - : query(query) - {} - - template < - class Uri - > - void operator () (Uri &uri) const { - uri.append("?"); - uri.append(query); - } - - std::string query; - -}; - -inline -query_directive query(const std::string &query) { - return query_directive(query); -} - -struct query_key_query_directive { - - query_key_query_directive(const std::string &key, const std::string &query) - : key(key), query(query) - {} - - template < - class Uri - > - void operator () (Uri &uri) const { - std::string encoded_key, encoded_query; - if (boost::empty(uri.query())) - { - uri.append("?"); - } - else - { - uri.append("&"); - } - uri.append(key); - uri.append("="); - uri.append(query); - } - - std::string key; - std::string query; - -}; - -inline -query_key_query_directive query(const std::string &key, const std::string &query) { - return query_key_query_directive(key, query); -} -} // namespace uri -} // namespace network -} // namespace boost - - -#endif // __BOOST_NETWORK_URI_DIRECTIVES_QUERY_INC__ diff --git a/boost/network/uri/directives/scheme.hpp b/boost/network/uri/directives/scheme.hpp deleted file mode 100644 index 65c6cc9ce..000000000 --- a/boost/network/uri/directives/scheme.hpp +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) Glyn Matthews 2011, 2012. -// 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 __BOOST_NETWORK_URI_DIRECTIVES_SCHEME_INC__ -# define __BOOST_NETWORK_URI_DIRECTIVES_SCHEME_INC__ - - -# include -# include -# include - - -namespace boost { -namespace network { -namespace uri { -struct scheme_directive { - - explicit scheme_directive(const std::string &scheme) - : scheme(scheme) - {} - - template < - class Uri - > - void operator () (Uri &uri) const { - uri.append(scheme); - if (opaque_schemes::exists(scheme)) { - uri.append(":"); - } - else { - uri.append("://"); - } - } - - std::string scheme; - -}; - -inline -scheme_directive scheme(const std::string &scheme) { - return scheme_directive(scheme); -} - -namespace schemes { -inline -uri &http(uri &uri_) { - return uri_ << scheme("http"); -} - -inline -uri &https(uri &uri_) { - return uri_ << scheme("https"); -} - -inline -uri &file(uri &uri_) { - return uri_ << scheme("file"); -} -} // namespace schemes -} // namespace uri -} // namespace network -} // namespace boost - - -#endif // __BOOST_NETWORK_URI_DIRECTIVES_SCHEME_INC__ diff --git a/boost/network/uri/directives/user_info.hpp b/boost/network/uri/directives/user_info.hpp deleted file mode 100644 index 177c0b7a6..000000000 --- a/boost/network/uri/directives/user_info.hpp +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) Glyn Matthews 2011, 2012. -// 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 __BOOST_NETWORK_URI_DIRECTIVES_USER_INFO_INC__ -# define __BOOST_NETWORK_URI_DIRECTIVES_USER_INFO_INC__ - - -# include -# include - - -namespace boost { -namespace network { -namespace uri { -struct user_info_directive { - - explicit user_info_directive(const std::string &user_info) - : user_info(user_info) - {} - - template < - class Uri - > - void operator () (Uri &uri) const { - uri.append(user_info); - uri.append("@"); - } - - std::string user_info; - -}; - -inline -user_info_directive user_info(const std::string &user_info) { - return user_info_directive(user_info); -} -} // namespace uri -} // namespace network -} // namespace boost - - -#endif // __BOOST_NETWORK_URI_DIRECTIVES_USER_INFO_INC__ diff --git a/boost/network/uri/encode.hpp b/boost/network/uri/encode.hpp deleted file mode 100644 index a68f62658..000000000 --- a/boost/network/uri/encode.hpp +++ /dev/null @@ -1,176 +0,0 @@ -// Copyright (c) Glyn Matthews 2011. -// 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 __BOOST_NETWORK_URI_ENCODE_INC__ -# define __BOOST_NETWORK_URI_ENCODE_INC__ - - -# include -# include -# include -# include -# include - - -namespace boost { -namespace network { -namespace uri { -namespace detail { -template < - typename CharT - > -inline -CharT hex_to_letter(CharT in) { - switch (in) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - return in + '0'; - case 10: - case 11: - case 12: - case 13: - case 14: - default: - return in - 10 + 'A'; - } - return CharT(); -} - - -template < - typename CharT, - class OutputIterator - > -void encode_char(CharT in, OutputIterator &out) { - switch (in) - { - case 'a': - case 'A': - case 'b': - case 'B': - case 'c': - case 'C': - case 'd': - case 'D': - case 'e': - case 'E': - case 'f': - case 'F': - case 'g': - case 'G': - case 'h': - case 'H': - case 'i': - case 'I': - case 'j': - case 'J': - case 'k': - case 'K': - case 'l': - case 'L': - case 'm': - case 'M': - case 'n': - case 'N': - case 'o': - case 'O': - case 'p': - case 'P': - case 'q': - case 'Q': - case 'r': - case 'R': - case 's': - case 'S': - case 't': - case 'T': - case 'u': - case 'U': - case 'v': - case 'V': - case 'w': - case 'W': - case 'x': - case 'X': - case 'y': - case 'Y': - case 'z': - case 'Z': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case '-': - case '.': - case '_': - case '~': - case '/': - out++ = in; - break; - default: - out++ = '%'; - out++ = hex_to_letter(in >> 4); - out++ = hex_to_letter(in & 0x0f); - ; - } -} -} // namespace detail - -template < - class InputIterator, - class OutputIterator - > -OutputIterator encode(const InputIterator &in_begin, - const InputIterator &in_end, - const OutputIterator &out_begin) { - typedef typename boost::iterator_value::type value_type; - - InputIterator it = in_begin; - OutputIterator out = out_begin; - while (it != in_end) { - detail::encode_char(*it, out); - ++it; - } - return out; -} - -template < - class SinglePassRange, - class OutputIterator - > -inline -OutputIterator encode(const SinglePassRange &range, - const OutputIterator &out) { - return encode(boost::begin(range), boost::end(range), out); -} - -inline -std::string encoded(const std::string &input) { - std::string encoded; - encode(input, std::back_inserter(encoded)); - return encoded; -} -} // namespace uri -} // namespace network -} // namespace boost - - -#endif // __BOOST_NETWORK_URI_ENCODE_INC__ diff --git a/boost/network/uri/schemes.hpp b/boost/network/uri/schemes.hpp deleted file mode 100644 index b8c7d94a2..000000000 --- a/boost/network/uri/schemes.hpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2012 Glyn Matthews. -// 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 __BOOST_NETWORK_URI_SCHEMES_INC__ -# define __BOOST_NETWORK_URI_SCHEMES_INC__ - - -#include - - -namespace boost { -namespace network { -namespace uri { -class hierarchical_schemes { - -public: - - static bool exists(const std::string &scheme); - -}; - -class opaque_schemes { - -public: - - static bool exists(const std::string &scheme); - -}; -} // namespace uri -} // namespace network -} // namespace boost - - -#endif // __BOOST_NETWORK_URI_SCHEMES_INC__ diff --git a/boost/network/uri/uri.hpp b/boost/network/uri/uri.hpp deleted file mode 100644 index f46dbd377..000000000 --- a/boost/network/uri/uri.hpp +++ /dev/null @@ -1,435 +0,0 @@ -// Copyright 2009, 2010, 2011, 2012 Dean Michael Berris, Jeroen Habraken, Glyn Matthews. -// 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 __BOOST_NETWORK_URI_INC__ -# define __BOOST_NETWORK_URI_INC__ - -# pragma once - -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include - - -namespace boost { -namespace network { -namespace uri { -namespace detail { -bool parse(std::string::const_iterator first, - std::string::const_iterator last, - uri_parts &parts); -} // namespace detail - - -class BOOST_URI_DECL uri { - - friend class builder; - -public: - - typedef std::string string_type; - typedef string_type::value_type value_type; - typedef string_type::const_iterator const_iterator; - typedef boost::iterator_range const_range_type; - - uri() - : is_valid_(false) { - - } - - //uri(const value_type *uri) - // : uri_(uri), is_valid_(false) { - // parse(); - //} - - uri(const string_type &uri) - : uri_(uri), is_valid_(false) { - parse(); - } - - template < - class FwdIter - > - uri(const FwdIter &first, const FwdIter &last) - : uri_(first, last), is_valid_(false) { - parse(); - } - - uri(const uri &other) - : uri_(other.uri_) { - parse(); - } - - uri &operator = (uri other) { - other.swap(*this); - parse(); - return *this; - } - - uri &operator = (const string_type &uri_string) { - uri(uri_string).swap(*this); - return *this; - } - - ~uri() { - - } - - void swap(uri &other) { - boost::swap(uri_, other.uri_); - boost::swap(uri_parts_, other.uri_parts_); - boost::swap(is_valid_, other.is_valid_); - } - - const_iterator begin() const { - return uri_.begin(); - } - - const_iterator end() const { - return uri_.end(); - } - - const_range_type scheme_range() const { - return uri_parts_.scheme; - } - - const_range_type user_info_range() const { - return uri_parts_.hier_part.user_info? - uri_parts_.hier_part.user_info.get() : - const_range_type(); - } - - const_range_type host_range() const { - return uri_parts_.hier_part.host? - uri_parts_.hier_part.host.get() : - const_range_type(); - } - - const_range_type port_range() const { - return uri_parts_.hier_part.port? - uri_parts_.hier_part.port.get() : - const_range_type(); - } - - const_range_type path_range() const { - return uri_parts_.hier_part.path? - uri_parts_.hier_part.path.get() : - const_range_type(); - } - - const_range_type query_range() const { - return uri_parts_.query ? - uri_parts_.query.get() : - const_range_type(); - } - - const_range_type fragment_range() const { - return uri_parts_.fragment? - uri_parts_.fragment.get() : - const_range_type(); - } - - string_type scheme() const { - const_range_type range = scheme_range(); - return range? string_type(boost::begin(range), boost::end(range)) : string_type(); - } - - string_type user_info() const { - const_range_type range = user_info_range(); - return range? string_type(boost::begin(range), boost::end(range)) : string_type(); - } - - string_type host() const { - const_range_type range = host_range(); - return range? string_type(boost::begin(range), boost::end(range)) : string_type(); - } - - string_type port() const { - const_range_type range = port_range(); - return range? string_type(boost::begin(range), boost::end(range)) : string_type(); - } - - string_type path() const { - const_range_type range = path_range(); - return range? string_type(boost::begin(range), boost::end(range)) : string_type(); - } - - string_type query() const { - const_range_type range = query_range(); - return range? string_type(boost::begin(range), boost::end(range)) : string_type(); - } - - string_type fragment() const { - const_range_type range = fragment_range(); - return range? string_type(boost::begin(range), boost::end(range)) : string_type(); - } - - string_type string() const { - return uri_; - } - - bool is_valid() const { - return is_valid_; - } - - void append(const string_type &data) { - uri_.append(data); - parse(); - } - - template < - class FwdIter - > - void append(const FwdIter &first, const FwdIter &last) { - uri_.append(first, last); - parse(); - } - -private: - - void parse(); - - string_type uri_; - detail::uri_parts uri_parts_; - bool is_valid_; - -}; - -inline -void uri::parse() { - const_iterator first(boost::begin(uri_)), last(boost::end(uri_)); - is_valid_ = detail::parse(first, last, uri_parts_); - if (is_valid_) { - if (!uri_parts_.scheme) { - uri_parts_.scheme = const_range_type(boost::begin(uri_), - boost::begin(uri_)); - } - uri_parts_.update(); - } -} - -inline -uri::string_type scheme(const uri &uri_) { - return uri_.scheme(); -} - -inline -uri::string_type user_info(const uri &uri_) { - return uri_.user_info(); -} - -inline -uri::string_type host(const uri &uri_) { - return uri_.host(); -} - -inline -uri::string_type port(const uri &uri_) { - return uri_.port(); -} - -inline -boost::optional port_us(const uri &uri_) { - uri::string_type port = uri_.port(); - return (port.empty())? - boost::optional() : - boost::optional(boost::lexical_cast(port)); -} - -inline -uri::string_type path(const uri &uri_) { - return uri_.path(); -} - -inline -uri::string_type query(const uri &uri_) { - return uri_.query(); -} - -inline -uri::string_type fragment(const uri &uri_) { - return uri_.fragment(); -} - -inline -uri::string_type hierarchical_part(const uri &uri_) { - return uri::string_type(boost::begin(uri_.user_info_range()), - boost::end(uri_.path_range())); -} - -inline -uri::string_type authority(const uri &uri_) { - return uri::string_type(boost::begin(uri_.user_info_range()), - boost::end(uri_.port_range())); -} - -inline -bool valid(const uri &uri_) { - return uri_.is_valid(); -} - -inline -bool is_absolute(const uri &uri_) { - return uri_.is_valid() && !boost::empty(uri_.scheme_range()); -} - -inline -bool is_relative(const uri &uri_) { - return uri_.is_valid() && boost::empty(uri_.scheme_range()); -} - -inline -bool is_hierarchical(const uri &uri_) { - return is_absolute(uri_) && hierarchical_schemes::exists(scheme(uri_)); -} - -inline -bool is_opaque(const uri &uri_) { - return is_absolute(uri_) && opaque_schemes::exists(scheme(uri_)); -} - -inline -bool is_valid(const uri &uri_) { - return valid(uri_); -} - -inline -void swap(uri &lhs, uri &rhs) { - lhs.swap(rhs); -} - -inline -std::size_t hash_value(const uri &uri_) -{ - std::size_t seed = 0; - for (uri::const_iterator it = begin(uri_); it != end(uri_); ++it) { - hash_combine(seed, *it); - } - return seed; -} - -inline -bool operator == (const uri &lhs, const uri &rhs) { - return boost::equal(lhs, rhs); -} - -inline -bool operator == (const uri &lhs, const uri::string_type &rhs) { - return boost::equal(lhs, rhs); -} - -inline -bool operator == (const uri::string_type &lhs, const uri &rhs) { - return boost::equal(lhs, rhs); -} - -inline -bool operator == (const uri &lhs, const uri::value_type *rhs) { - return boost::equal(lhs, boost::as_literal(rhs)); -} - -inline -bool operator == (const uri::value_type *lhs, const uri &rhs) { - return boost::equal(boost::as_literal(lhs), rhs); -} - -inline -bool operator != (const uri &lhs, const uri &rhs) { - return !(lhs == rhs); -} - -inline -bool operator < (const uri &lhs, const uri &rhs) { - return lhs.string() < rhs.string(); -} -} // namespace uri -} // namespace network -} // namespace boost - -# include -# include -# include - - -namespace boost { -namespace network { -namespace uri { -inline -uri from_parts(const uri &base_uri, - const uri::string_type &path_, - const uri::string_type &query_, - const uri::string_type &fragment_) { - uri uri_(base_uri); - builder(uri_).path(path_).query(query_).fragment(fragment_); - return uri_; -} - -inline -uri from_parts(const uri &base_uri, - const uri::string_type &path_, - const uri::string_type &query_) { - uri uri_(base_uri); - builder(uri_).path(path_).query(query_); - return uri_; -} - -inline -uri from_parts(const uri &base_uri, - const uri::string_type &path_) { - uri uri_(base_uri); - builder(uri_).path(path_); - return uri_; -} - -inline -uri from_parts(const uri::string_type &base_uri, - const uri::string_type &path, - const uri::string_type &query, - const uri::string_type &fragment) { - return from_parts(uri(base_uri), path, query, fragment); -} - -inline -uri from_parts(const uri::string_type &base_uri, - const uri::string_type &path, - const uri::string_type &query) { - return from_parts(uri(base_uri), path, query); -} - -inline -uri from_parts(const uri::string_type &base_uri, - const uri::string_type &path) { - return from_parts(uri(base_uri), path); -} -} // namespace uri -} // namespace network -} // namespace boost - -# include - -namespace boost { -namespace network { -namespace uri { -inline -uri from_file(const filesystem::path &path_) { - uri uri_; - builder(uri_).scheme("file").path(path_.string()); - return uri_; -} -} // namespace uri -} // namespace network -} // namespace boost - - -#endif // __BOOST_NETWORK_URI_INC__ diff --git a/boost/network/uri/uri.ipp b/boost/network/uri/uri.ipp deleted file mode 100644 index 7af1f48ab..000000000 --- a/boost/network/uri/uri.ipp +++ /dev/null @@ -1,239 +0,0 @@ -// Copyright 2009, 2010, 2011, 2012 Dean Michael Berris, Jeroen Habraken, Glyn Matthews. -// 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) - - -#include -#include -#include -#include - -BOOST_FUSION_ADAPT_TPL_STRUCT -( - (FwdIter), - (boost::network::uri::detail::hierarchical_part)(FwdIter), - (boost::optional >, user_info) - (boost::optional >, host) - (boost::optional >, port) - (boost::optional >, path) - ); - -BOOST_FUSION_ADAPT_TPL_STRUCT -( - (FwdIter), - (boost::network::uri::detail::uri_parts)(FwdIter), - (boost::iterator_range, scheme) - (boost::network::uri::detail::hierarchical_part, hier_part) - (boost::optional >, query) - (boost::optional >, fragment) - ); - -namespace boost { -namespace network { -namespace uri { -namespace detail { -namespace qi = boost::spirit::qi; - -template < - class String - > -struct uri_grammar : qi::grammar< - typename String::const_iterator - , detail::uri_parts()> { - - typedef String string_type; - typedef typename String::const_iterator const_iterator; - - uri_grammar() : uri_grammar::base_type(start, "uri") { - // gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@" - gen_delims %= qi::char_(":/?#[]@"); - // sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "=" - sub_delims %= qi::char_("!$&'()*+,;="); - // reserved = gen-delims / sub-delims - reserved %= gen_delims | sub_delims; - // unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" - unreserved %= qi::alnum | qi::char_("-._~"); - // pct-encoded = "%" HEXDIG HEXDIG - pct_encoded %= qi::char_("%") >> qi::repeat(2)[qi::xdigit]; - - // pchar = unreserved / pct-encoded / sub-delims / ":" / "@" - pchar %= qi::raw[ - unreserved | pct_encoded | sub_delims | qi::char_(":@") - ]; - - // segment = *pchar - segment %= qi::raw[*pchar]; - // segment-nz = 1*pchar - segment_nz %= qi::raw[+pchar]; - // segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" ) - segment_nz_nc %= qi::raw[ - +(unreserved | pct_encoded | sub_delims | qi::char_("@")) - ]; - // path-abempty = *( "/" segment ) - path_abempty %= - qi::raw[*(qi::char_("/") >> segment)] - ; - // path-absolute = "/" [ segment-nz *( "/" segment ) ] - path_absolute %= - qi::raw[ - qi::char_("/") - >> -(segment_nz >> *(qi::char_("/") >> segment)) - ] - ; - // path-rootless = segment-nz *( "/" segment ) - path_rootless %= - qi::raw[segment_nz >> *(qi::char_("/") >> segment)] - ; - // path-empty = 0 - path_empty %= - qi::raw[qi::eps] - ; - - // scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) - scheme %= - qi::raw[qi::alpha >> *(qi::alnum | qi::char_("+.-"))] - ; - - // user_info = *( unreserved / pct-encoded / sub-delims / ":" ) - user_info %= - qi::raw[*(unreserved | pct_encoded | sub_delims | qi::char_(":"))] - ; - - ip_literal %= - qi::lit('[') >> (ipv6address | ipvfuture) >> ']' - ; - - ipvfuture %= - qi::lit('v') >> +qi::xdigit >> '.' >> +( unreserved | sub_delims | ':') - ; - - ipv6address %= qi::raw[ - qi::repeat(6)[h16 >> ':'] >> ls32 - | "::" >> qi::repeat(5)[h16 >> ':'] >> ls32 - | qi::raw[ h16] >> "::" >> qi::repeat(4)[h16 >> ':'] >> ls32 - | qi::raw[ +(*(h16 >> ':')) >> h16] >> "::" >> qi::repeat(3)[h16 >> ':'] >> ls32 - | qi::raw[qi::repeat(2)[*(h16 >> ':')] >> h16] >> "::" >> qi::repeat(2)[h16 >> ':'] >> ls32 - | qi::raw[qi::repeat(3)[*(h16 >> ':')] >> h16] >> "::" >> h16 >> ':' >> ls32 - | qi::raw[qi::repeat(4)[*(h16 >> ':')] >> h16] >> "::" >> ls32 - | qi::raw[qi::repeat(5)[*(h16 >> ':')] >> h16] >> "::" >> h16 - | qi::raw[qi::repeat(6)[*(h16 >> ':')] >> h16] >> "::" - ]; - - // ls32 = ( h16 ":" h16 ) / IPv4address - ls32 %= (h16 >> ':' >> h16) | ipv4address - ; - - // h16 = 1*4HEXDIG - h16 %= qi::repeat(1, 4)[qi::xdigit] - ; - - // dec-octet = DIGIT / %x31-39 DIGIT / "1" 2DIGIT / "2" %x30-34 DIGIT / "25" %x30-35 - dec_octet %= - !(qi::lit('0') >> qi::digit) - >> qi::raw[ - qi::uint_parser() - ]; - - // IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet - ipv4address %= qi::raw[ - dec_octet >> qi::repeat(3)[qi::lit('.') >> dec_octet] - ]; - - // reg-name = *( unreserved / pct-encoded / sub-delims ) - reg_name %= qi::raw[ - *(unreserved | pct_encoded | sub_delims) - ]; - - // TODO, host = IP-literal / IPv4address / reg-name - host %= - qi::raw[ip_literal | ipv4address | reg_name] - ; - - // port %= qi::ushort_; - port %= - qi::raw[*qi::digit] - ; - - // query = *( pchar / "/" / "?" ) - query %= - qi::raw[*(pchar | qi::char_("/?"))] - ; - - // fragment = *( pchar / "/" / "?" ) - fragment %= - qi::raw[*(pchar | qi::char_("/?"))] - ; - - // hier-part = "//" authority path-abempty / path-absolute / path-rootless / path-empty - // authority = [ userinfo "@" ] host [ ":" port ] - hier_part %= - ( - (("//" >> user_info >> '@') | "//") - >> host - >> -(':' >> port) - >> path_abempty - ) - | - ( - qi::attr(iterator_range()) - >> qi::attr(iterator_range()) - >> qi::attr(iterator_range()) - >> ( - path_absolute - | path_rootless - | path_empty - ) - ) - ; - - start %= - (scheme >> ':') - >> hier_part - >> -('?' >> query) - >> -('#' >> fragment) - ; - } - - qi::rule::value_type()> - gen_delims, sub_delims, reserved, unreserved; - qi::rule - pct_encoded, pchar; - - qi::rule - segment, segment_nz, segment_nz_nc; - qi::rule()> - path_abempty, path_absolute, path_rootless, path_empty; - - qi::rule - dec_octet, ipv4address, reg_name, ipv6address, ipvfuture, ip_literal; - - qi::rule - h16, ls32; - - qi::rule()> - host, port; - - qi::rule()> - scheme, user_info, query, fragment; - - qi::rule()> - hier_part; - - // actual uri parser - qi::rule()> start; - -}; - -bool parse(std::string::const_iterator first, - std::string::const_iterator last, - uri_parts &parts) { - namespace qi = boost::spirit::qi; - static detail::uri_grammar grammar; - bool is_valid = qi::parse(first, last, grammar, parts); - return is_valid && (first == last); -} -} // namespace detail -} // namespace uri -} // namespace network -} // namespace boost diff --git a/boost/network/uri/uri_io.hpp b/boost/network/uri/uri_io.hpp deleted file mode 100644 index 68da1b014..000000000 --- a/boost/network/uri/uri_io.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Glyn Matthews 2011, 2012. -// 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 __BOOST_NETWORK_URI_URI_IO_INC__ -# define __BOOST_NETWORK_URI_URI_IO_INC__ - - -# include - - -namespace boost { -namespace network { -namespace uri { - -inline -std::ostream &operator << (std::ostream &os, const uri &uri_) { - return os << uri_.string(); -} -} // namespace uri -} // namespace network -} // namespace boost - - -#endif // __BOOST_NETWORK_URI_URI_IO_INC__ diff --git a/include/network/uri/directives/fragment.hpp b/include/network/uri/directives/fragment.hpp index 14ee12d99..60dfb6636 100644 --- a/include/network/uri/directives/fragment.hpp +++ b/include/network/uri/directives/fragment.hpp @@ -8,7 +8,6 @@ # define __BOOST_NETWORK_URI_DIRECTIVES_FRAGMENT_INC__ -# include # include # include diff --git a/include/network/uri/directives/query.hpp b/include/network/uri/directives/query.hpp index a6c20b2d4..80a37adb2 100644 --- a/include/network/uri/directives/query.hpp +++ b/include/network/uri/directives/query.hpp @@ -8,7 +8,6 @@ # define __BOOST_NETWORK_URI_DIRECTIVES_QUERY_INC__ -# include # include # include diff --git a/libs/network/test/CMakeLists.txt b/libs/network/test/CMakeLists.txt index e459f8b98..6f5c92c6f 100644 --- a/libs/network/test/CMakeLists.txt +++ b/libs/network/test/CMakeLists.txt @@ -51,7 +51,7 @@ if (Boost_FOUND) ${CMAKE_THREAD_LIBS_INIT}) set_target_properties(cpp-netlib-utils_thread_pool PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests) - add_test(cpp-netlib-utils_thread_pool ${CPP-NETLIB_BRINARY_DIR}/tests/cpp-netlib-utils_thread_pool) + add_test(cpp-netlib-utils_thread_pool ${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-utils_thread_pool) endif() diff --git a/libs/network/test/http/request_test.cpp b/libs/network/test/http/request_test.cpp index 1f87d30f2..7a99a6186 100644 --- a/libs/network/test/http/request_test.cpp +++ b/libs/network/test/http/request_test.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include namespace http = boost::network::http; namespace net = boost::network; From 51fe2561f24b54cfda30d48343bf275f5762e911 Mon Sep 17 00:00:00 2001 From: Divye Kapoor Date: Sat, 19 May 2012 14:17:15 -0700 Subject: [PATCH 089/196] Fix compile error because of an invalid include. --- .../http/client/connection/simple_connection_factory.ipp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boost/network/protocol/http/client/connection/simple_connection_factory.ipp b/boost/network/protocol/http/client/connection/simple_connection_factory.ipp index 1ea211678..762706cac 100644 --- a/boost/network/protocol/http/client/connection/simple_connection_factory.ipp +++ b/boost/network/protocol/http/client/connection/simple_connection_factory.ipp @@ -14,7 +14,7 @@ #include #include #ifdef BOOST_NETWORK_DEBUG -#include +#include #endif #include From bc2fbdedd132c8748d1d839ff548041553df9f72 Mon Sep 17 00:00:00 2001 From: Glyn Matthews Date: Sat, 30 Jun 2012 17:07:48 +0200 Subject: [PATCH 090/196] Fixed bug issue 111. It seems there was a problem in the assignment operators where the parsing was not done correctly, causing undefined behaviour. --- include/network/uri/uri.hpp | 13 +++++-------- libs/network/example/CMakeLists.txt | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/network/uri/uri.hpp b/include/network/uri/uri.hpp index 332cbeae2..ec8a5ec93 100644 --- a/include/network/uri/uri.hpp +++ b/include/network/uri/uri.hpp @@ -45,11 +45,6 @@ class BOOST_URI_DECL uri { } - //uri(const value_type *uri) - // : uri_(uri), is_valid_(false) { - // parse(); - //} - uri(const string_type &uri) : uri_(uri), is_valid_(false) { parse(); @@ -69,13 +64,15 @@ class BOOST_URI_DECL uri { } uri &operator = (const uri &other) { - uri(other).swap(*this); + uri_ = other.uri_; + parse(); return *this; } uri &operator = (const string_type &uri_string) { - uri(uri_string).swap(*this); - return *this; + uri_ = uri_string; + parse(); + return *this; } ~uri() { diff --git a/libs/network/example/CMakeLists.txt b/libs/network/example/CMakeLists.txt index 9d820f14a..9fe8aa69d 100644 --- a/libs/network/example/CMakeLists.txt +++ b/libs/network/example/CMakeLists.txt @@ -121,8 +121,8 @@ target_link_libraries(hello_world_client cppnetlib-http-client cppnetlib-http-client-connections) -target_link_libraries(uri_builder ${OPENSSL_LIBRARIES}) if (OPENSSL_FOUND) + target_link_libraries(uri_builder ${OPENSSL_LIBRARIES}) #target_link_libraries(http_client ${OPENSSL_LIBRARIES}) target_link_libraries(simple_wget ${OPENSSL_LIBRARIES}) target_link_libraries(atom_reader ${OPENSSL_LIBRARIES}) From d4ebe016527815dae1a09ac8c09f4c3a4d417c4e Mon Sep 17 00:00:00 2001 From: Glyn Matthews Date: Sat, 30 Jun 2012 18:22:19 +0200 Subject: [PATCH 091/196] I made some changes to the code to make sure that everything compiles on MSVC 2010 (using C++11 features). Not all HTTP tests run successfully on Windows. --- CMakeLists.txt | 2 +- boost/network/protocol/http/algorithms/linearize.hpp | 5 ++--- boost/network/protocol/http/client/client_connection.ipp | 1 + .../protocol/http/message/wrappers/status_message.hpp | 1 + boost/network/protocol/http/message/wrappers/version.hpp | 1 + boost/network/protocol/http/server/connection/async.hpp | 1 + boost/network/protocol/http/server/connection/sync.hpp | 7 +++++-- libs/network/example/CMakeLists.txt | 3 +++ 8 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 06f6460ce..c3ccfcf42 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ cmake_minimum_required(VERSION 2.8) project(CPP-NETLIB) set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_MULTI_THREADED ON) -find_package( Boost 1.45.0 REQUIRED unit_test_framework system regex date_time thread filesystem program_options ) +find_package( Boost 1.45.0 REQUIRED unit_test_framework system regex date_time thread chrono filesystem program_options ) find_package( OpenSSL ) find_package( Threads ) set(CMAKE_VERBOSE_MAKEFILE true) diff --git a/boost/network/protocol/http/algorithms/linearize.hpp b/boost/network/protocol/http/algorithms/linearize.hpp index cc13adf2c..f9163f3e9 100644 --- a/boost/network/protocol/http/algorithms/linearize.hpp +++ b/boost/network/protocol/http/algorithms/linearize.hpp @@ -151,9 +151,8 @@ namespace boost { namespace network { namespace http { boost::copy(crlf, oi); } boost::copy(crlf, oi); - boost::iterator_range body_data = - boost::network::body(request); - return boost::copy(body_data, oi); + auto body_data = boost::network::body(request); + return std::copy(body_data.begin(), body_data.end(), oi); } } /* http */ diff --git a/boost/network/protocol/http/client/client_connection.ipp b/boost/network/protocol/http/client/client_connection.ipp index bb4ac9eff..b997e10d1 100644 --- a/boost/network/protocol/http/client/client_connection.ipp +++ b/boost/network/protocol/http/client/client_connection.ipp @@ -22,6 +22,7 @@ client_connection * client_connection::clone() const { BOOST_NETWORK_MESSAGE("client_connection::clone()"); // For exposition only. BOOST_ASSERT(false && "This should not ever be called."); + return 0; } diff --git a/boost/network/protocol/http/message/wrappers/status_message.hpp b/boost/network/protocol/http/message/wrappers/status_message.hpp index a9258026c..d8331d9d9 100644 --- a/boost/network/protocol/http/message/wrappers/status_message.hpp +++ b/boost/network/protocol/http/message/wrappers/status_message.hpp @@ -7,6 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#include #include namespace boost { namespace network { namespace http { diff --git a/boost/network/protocol/http/message/wrappers/version.hpp b/boost/network/protocol/http/message/wrappers/version.hpp index b166758b6..e38623637 100644 --- a/boost/network/protocol/http/message/wrappers/version.hpp +++ b/boost/network/protocol/http/message/wrappers/version.hpp @@ -8,6 +8,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#include #include namespace boost { namespace network { namespace http { diff --git a/boost/network/protocol/http/server/connection/async.hpp b/boost/network/protocol/http/server/connection/async.hpp index bc8c65fa0..c22611807 100644 --- a/boost/network/protocol/http/server/connection/async.hpp +++ b/boost/network/protocol/http/server/connection/async.hpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include diff --git a/boost/network/protocol/http/server/connection/sync.hpp b/boost/network/protocol/http/server/connection/sync.hpp index 3ed2107d3..04882a88f 100644 --- a/boost/network/protocol/http/server/connection/sync.hpp +++ b/boost/network/protocol/http/server/connection/sync.hpp @@ -282,7 +282,10 @@ class sync_server_connection : public boost::enable_shared_from_this data) { if (boost::empty(data)) done = true; - else std::copy(begin(data), end(data), buffer.begin()); + else std::copy(std::begin(data), std::end(data), buffer.begin()); }, buffer.size()); if (!done) output_buffers_.emplace_back(std::move(buffer)); } diff --git a/libs/network/example/CMakeLists.txt b/libs/network/example/CMakeLists.txt index 9fe8aa69d..507ac1c39 100644 --- a/libs/network/example/CMakeLists.txt +++ b/libs/network/example/CMakeLists.txt @@ -23,12 +23,15 @@ add_executable(hello_world_client http/hello_world_client.cpp) set(BOOST_CLIENT_LIBS ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_THREAD_LIBRARY} + ${Boost_CHRONO_LIBRARY} ${Boost_DATE_TIME_LIBRARY} ${Boost_REGEX_LIBRARY} + ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY}) set(BOOST_SERVER_LIBS ${Boost_THREAD_LIBRARY} + ${Boost_CHRONO_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_DATE_TIME_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) From b9a92628ecea68e7c0bc0dc9e4db8ad1a7e2de51 Mon Sep 17 00:00:00 2001 From: Glyn Matthews Date: Mon, 2 Jul 2012 21:25:39 +0200 Subject: [PATCH 092/196] Added C++0x/C++11 compiler flags, where appropriate. --- CMakeLists.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c3ccfcf42..d72438837 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,10 +25,12 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) CHECK_CXX_COMPILER_FLAG(-std=c++0x HAVE_STD0X) CHECK_CXX_COMPILER_FLAG(-std=c++11 HAVE_STD11) - if (NOT HAVE_STD0X) - if (NOT HAVE_STD11) - message(FATAL_ERROR "No advanced standard C++ support (-std=c++0x and -std=c++11 not defined).") - endif() + if (HAVE_STD11) + set(CMAKE_CXX_FLAGS -std=c++11) + elseif (HAVE_STD0X) + set(CMAKE_CXX_FLAGS -std=c++0x) + else() + message(FATAL_ERROR "No advanced standard C++ support (-std=c++0x and -std=c++11 not defined).") endif() endif() From 1338fb47c6936b2c38f88b1c33cbedf1270ca884 Mon Sep 17 00:00:00 2001 From: Glyn Matthews Date: Tue, 3 Jul 2012 18:45:25 +0200 Subject: [PATCH 093/196] Fixed documentation issue #116. --- libs/network/doc/reference/http_client.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/network/doc/reference/http_client.rst b/libs/network/doc/reference/http_client.rst index 52c31a055..3a7e90c67 100644 --- a/libs/network/doc/reference/http_client.rst +++ b/libs/network/doc/reference/http_client.rst @@ -233,11 +233,11 @@ and that there is an appropriately constructed response object named the ``callback`` parameter. The signature of ``callback`` should be the following: ``void(iterator_range const &, boost::system::error_code const &)``. -``response_ = client_.post(request_, content_type, body)`` +``response_ = client_.post(request_, body, content_type)`` The body and content_type parameters are of type ``boost::network::string::type`` where ``Tag`` is the HTTP Client's ``Tag``. This uses the request object's other headers. -``response_ = client_.post(request_, content_type, body, _body_handler=callback)`` +``response_ = client_.post(request_, body, content_type, _body_handler=callback)`` The body and content_type parameters are of type ``boost::network::string::type`` where ``Tag`` is the HTTP Client's ``Tag``. This uses the request object's other headers. Have the response @@ -263,11 +263,11 @@ and that there is an appropriately constructed response object named the ``callback`` parameter. The signature of ``callback`` should be the following: ``void(iterator_range const &, boost::system::error_code const &)``. -``response_ = client_.put(request_, content_type, body)`` +``response_ = client_.put(request_, body, content_type)`` The body and content_type parameters are of type ``boost::network::string::type`` where ``Tag`` is the HTTP Client's ``Tag``. This uses the request object's other headers. -``response_ = client_.put(request_, content_type, body, _body_handler=callback)`` +``response_ = client_.put(request_, body, content_type, _body_handler=callback)`` The body and content_type parameters are of type ``boost::network::string::type`` where ``Tag`` is the HTTP Client's ``Tag``. This uses the request object's other headers. Have the response From 0c778119f1cd327d91aed8ae41bf2b58e8a88f3d Mon Sep 17 00:00:00 2001 From: Glyn Matthews Date: Thu, 5 Jul 2012 20:57:04 +0200 Subject: [PATCH 094/196] Added headers which move boost::network::http::* types into network::http. Updated examples accordingly. --- include/network/http/client.hpp | 22 +++++++ include/network/http/errors.hpp | 19 ++++++ include/network/http/request.hpp | 17 ++++++ include/network/http/response.hpp | 17 ++++++ libs/network/example/CMakeLists.txt | 16 ----- libs/network/example/Jamfile.v2 | 3 - libs/network/example/atom/atom.cpp | 3 - libs/network/example/atom/atom.hpp | 4 +- libs/network/example/atom/main.cpp | 9 +-- libs/network/example/http_client.cpp | 81 ------------------------- libs/network/example/http_client1.cpp | 23 ------- libs/network/example/rss/main.cpp | 7 ++- libs/network/example/rss/rss.cpp | 3 - libs/network/example/rss/rss.hpp | 4 +- libs/network/example/simple_wget.cpp | 4 +- libs/network/example/twitter/search.cpp | 4 +- 16 files changed, 90 insertions(+), 146 deletions(-) create mode 100644 include/network/http/client.hpp create mode 100644 include/network/http/errors.hpp create mode 100644 include/network/http/request.hpp create mode 100644 include/network/http/response.hpp delete mode 100644 libs/network/example/http_client.cpp delete mode 100644 libs/network/example/http_client1.cpp diff --git a/include/network/http/client.hpp b/include/network/http/client.hpp new file mode 100644 index 000000000..22ef1f40f --- /dev/null +++ b/include/network/http/client.hpp @@ -0,0 +1,22 @@ +// Copyright (c) Glyn Matthews 2012. +// 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 __NETWORK_HTTP_CLIENT_INC__ +# define __NETWORK_HTTP_CLIENT_INC__ + +# include +# include +# include +# include + +namespace network { +using boost::network::header; + +namespace http { +using boost::network::http::client; +} // namespace http +} // namespace network + +#endif // __NETWORK_HTTP_CLIENT_INC__ diff --git a/include/network/http/errors.hpp b/include/network/http/errors.hpp new file mode 100644 index 000000000..525fe60c0 --- /dev/null +++ b/include/network/http/errors.hpp @@ -0,0 +1,19 @@ +// Copyright (c) Glyn Matthews 2012. +// 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 __NETWORK_HTTP_ERRORS_INC__ +# define __NETWORK_HTTP_ERRORS_INC__ + +# include + +namespace network { +namespace http { +namespace errors { +using boost::network::http::errors::connection_timeout; +} // namespace errors +} // namespace http +} // namespace network + +#endif // __NETWORK_HTTP_ERRORS_INC__ diff --git a/include/network/http/request.hpp b/include/network/http/request.hpp new file mode 100644 index 000000000..465c3cc49 --- /dev/null +++ b/include/network/http/request.hpp @@ -0,0 +1,17 @@ +// Copyright (c) Glyn Matthews 2012. +// 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 __NETWORK_HTTP_REQUEST_INC__ +# define __NETWORK_HTTP_REQUEST_INC__ + +# include + +namespace network { +namespace http { +using boost::network::http::request; +} // namespace http +} // namespace network + +#endif // __NETWORK_HTTP_REQUEST_INC__ diff --git a/include/network/http/response.hpp b/include/network/http/response.hpp new file mode 100644 index 000000000..160385f99 --- /dev/null +++ b/include/network/http/response.hpp @@ -0,0 +1,17 @@ +// Copyright (c) Glyn Matthews 2012. +// 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 __NETWORK_HTTP_RESPONSE_INC__ +# define __NETWORK_HTTP_RESPONSE_INC__ + +# include + +namespace network { +namespace http { +using boost::network::http::response; +} // namespace http +} // namespace network + +#endif // __NETWORK_HTTP_RESPONSE_INC__ diff --git a/libs/network/example/CMakeLists.txt b/libs/network/example/CMakeLists.txt index 507ac1c39..76c829e95 100644 --- a/libs/network/example/CMakeLists.txt +++ b/libs/network/example/CMakeLists.txt @@ -10,7 +10,6 @@ if (OPENSSL_FOUND) endif (OPENSSL_FOUND) add_executable(uri_builder uri_builder.cpp) -#add_executable(http_client http_client.cpp) add_executable(simple_wget simple_wget.cpp) add_executable(atom_reader atom/atom.cpp atom/main.cpp) add_executable(rss_reader rss/rss.cpp rss/main.cpp) @@ -41,19 +40,6 @@ target_link_libraries(uri_builder ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri) -#target_link_libraries(http_client -# ${BOOST_CLIENT_LIBS} -# ${CMAKE_THREAD_LIBS_INIT} -# cppnetlib-uri -# cppnetlib-message -# cppnetlib-message-directives -# cppnetlib-message-wrappers -# cppnetlib-http-message-wrappers -# cppnetlib-http-message -# cppnetlib-constants -# cppnetlib-http-client -# cppnetlib-http-client-connections) - target_link_libraries(simple_wget ${BOOST_CLIENT_LIBS} ${CMAKE_THREAD_LIBS_INIT} @@ -126,7 +112,6 @@ target_link_libraries(hello_world_client if (OPENSSL_FOUND) target_link_libraries(uri_builder ${OPENSSL_LIBRARIES}) - #target_link_libraries(http_client ${OPENSSL_LIBRARIES}) target_link_libraries(simple_wget ${OPENSSL_LIBRARIES}) target_link_libraries(atom_reader ${OPENSSL_LIBRARIES}) target_link_libraries(rss_reader ${OPENSSL_LIBRARIES}) @@ -144,7 +129,6 @@ endif (OPENSSL_FOUND) #endif (UNIX) set_target_properties(uri_builder PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example) -#set_target_properties(http_client PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example) set_target_properties(simple_wget PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example) set_target_properties(atom_reader PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example) set_target_properties(rss_reader PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example) diff --git a/libs/network/example/Jamfile.v2 b/libs/network/example/Jamfile.v2 index 5bca45589..da6f71f10 100644 --- a/libs/network/example/Jamfile.v2 +++ b/libs/network/example/Jamfile.v2 @@ -23,9 +23,6 @@ project network_test : exe uri : uri.cpp /cpp-netlib//cppnetlib-uri ; -exe http_client : http_client.cpp /cpp-netlib//cppnetlib-uri /cpp-netlib//cppnetlib-client-connections ; - -exe http_client1 : http_client1.cpp /cpp-netlib//cppnetlib-uri /cpp-netlib//cppnetlib-client-connections ; exe simple_wget : simple_wget.cpp /cpp-netlib//cppnetlib-uri /cpp-netlib//cppnetlib-client-connections ; diff --git a/libs/network/example/atom/atom.cpp b/libs/network/example/atom/atom.cpp index 7555956b6..5f2dbbb44 100644 --- a/libs/network/example/atom/atom.cpp +++ b/libs/network/example/atom/atom.cpp @@ -9,8 +9,6 @@ #include #include - -namespace boost { namespace network { namespace atom { feed::feed(const http::client::response &response) { @@ -94,4 +92,3 @@ feed::feed(const http::client::response &response) { } } // namespace atom } // namespace network -} // namespace boost diff --git a/libs/network/example/atom/atom.hpp b/libs/network/example/atom/atom.hpp index b19e4146a..a01fe9a30 100644 --- a/libs/network/example/atom/atom.hpp +++ b/libs/network/example/atom/atom.hpp @@ -9,10 +9,9 @@ # include # include -# include +# include -namespace boost { namespace network { namespace atom { class entry { @@ -172,6 +171,5 @@ class feed { }; } // namespace atom } // namespace network -} // namespace boost #endif // ___ATOM_INC__ diff --git a/libs/network/example/atom/main.cpp b/libs/network/example/atom/main.cpp index b419db720..a21e78c40 100644 --- a/libs/network/example/atom/main.cpp +++ b/libs/network/example/atom/main.cpp @@ -1,16 +1,17 @@ -// Copyright (c) Glyn Matthews 2011. +// Copyright (c) Glyn Matthews 2011, 2012. // 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) #include "atom.hpp" -#include +#include #include #include int main(int argc, char * argv[]) { - using namespace boost::network; + namespace http = network::http; + namespace atom = network::atom; if (argc != 2) { std::cout << "Usage: " << argv[0] << " " << std::endl; @@ -20,7 +21,7 @@ int main(int argc, char * argv[]) { try { http::client client; http::client::request request(argv[1]); - request << header("Connection", "close"); + request << network::header("Connection", "close"); http::client::response response = client.get(request); atom::feed feed(response); diff --git a/libs/network/example/http_client.cpp b/libs/network/example/http_client.cpp deleted file mode 100644 index 1f8264a04..000000000 --- a/libs/network/example/http_client.cpp +++ /dev/null @@ -1,81 +0,0 @@ - -// Copyright Dean Michael Berris 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) - -//[ http_client_main -/*` - This application takes a URL as a command line argument and prints - the resource to the console. -*/ -#include -#include -#include -#include -#include - -namespace po = boost::program_options; - -int main(int argc, char * argv[]) { - using namespace boost::network; - po::options_description options("Allowed options"); - std::string output_filename, source; - bool show_headers; - options.add_options() - ("help,h", "produce help message") - ("headers,H", "print headers") - ("source,s", po::value(&source), "source URL") - ; - - po::positional_options_description positional_options; - positional_options.add("source", 1); - po::variables_map vm; - try { - po::store(po::command_line_parser(argc, argv).options(options).positional(positional_options).run(), - vm); - po::notify(vm); - } catch(std::exception & e) { - std::cout << "Error: " << e.what() << std::endl; - std::cout << options << std::endl; - return EXIT_FAILURE; - }; - - if (vm.count("help")) { - std::cout << options << std::endl; - return EXIT_SUCCESS; - }; - - if (vm.count("source") < 1) { - std::cout << "Error: Source URL required." << std::endl; - std::cout << options << std::endl; - return EXIT_FAILURE; - }; - - show_headers = vm.count("headers") ? true : false ; - - - typedef http::basic_client - http_client; - - http_client::request request(source); - http_client::string_type destination_ = host(request); - - request << ::boost::network::header("Connection", "close"); - http_client client(http::_follow_redirects=true); - http_client::response response = client.get(request); - - if (show_headers) { - headers_range::type headers_ = response.headers(); - typedef std::pair header_type; - BOOST_FOREACH(header_type const & header, headers_) { - std::cout << header.first << ": " << header.second << std::endl; - } - std::cout << std::endl; - }; - - body_range::type body_ = body(response).range(); - boost::copy(body_, std::ostream_iterator::type>(std::cout)); - return EXIT_SUCCESS; -} -//] diff --git a/libs/network/example/http_client1.cpp b/libs/network/example/http_client1.cpp deleted file mode 100644 index 8bdbc0352..000000000 --- a/libs/network/example/http_client1.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright Dean Michael Berris 2011. -// 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) - - -#include -#include - -int main(int argc, char * argv[]) { - using namespace boost::network; - - if (argc != 2) { std::cout << "Usage: " << argv[0] << " " << std::endl; return 1; } - - http::client client; - http::client::request request(argv[1]); - request << header("Connection", "close"); - http::client::response response = client.get(request); - std::cout << body(response) << std::endl; - - return 0; -} - diff --git a/libs/network/example/rss/main.cpp b/libs/network/example/rss/main.cpp index 141f7c335..eee74d1ba 100644 --- a/libs/network/example/rss/main.cpp +++ b/libs/network/example/rss/main.cpp @@ -5,12 +5,13 @@ #include "rss.hpp" -#include +#include #include #include int main(int argc, char * argv[]) { - using namespace boost::network; + namespace http = network::http; + namespace rss = network::rss; if (argc != 2) { std::cout << "Usage: " << argv[0] << " " << std::endl; @@ -20,7 +21,7 @@ int main(int argc, char * argv[]) { try { http::client client; http::client::request request(argv[1]); - request << header("Connection", "close"); + request << network::header("Connection", "close"); http::client::response response = client.get(request); rss::channel channel(response); diff --git a/libs/network/example/rss/rss.cpp b/libs/network/example/rss/rss.cpp index f4864c1ef..ba97ac128 100644 --- a/libs/network/example/rss/rss.cpp +++ b/libs/network/example/rss/rss.cpp @@ -9,8 +9,6 @@ #include #include - -namespace boost { namespace network { namespace rss { channel::channel(const http::client::response &response) { @@ -72,4 +70,3 @@ channel::channel(const http::client::response &response) { } } // namespace rss } // namespace network -} // namespace boost diff --git a/libs/network/example/rss/rss.hpp b/libs/network/example/rss/rss.hpp index 12acd4ad0..2f027bda6 100644 --- a/libs/network/example/rss/rss.hpp +++ b/libs/network/example/rss/rss.hpp @@ -9,10 +9,9 @@ # include # include -# include +# include -namespace boost { namespace network { namespace rss { class item { @@ -107,6 +106,5 @@ class channel { }; } // namespace rss } // namespace network -} // namespace boost #endif // ___RSS_INC__ diff --git a/libs/network/example/simple_wget.cpp b/libs/network/example/simple_wget.cpp index 760b82c8a..7ff6f3fa9 100644 --- a/libs/network/example/simple_wget.cpp +++ b/libs/network/example/simple_wget.cpp @@ -14,14 +14,14 @@ */ -#include +#include #include #include #include #include -namespace http = boost::network::http; +namespace http = network::http; namespace { diff --git a/libs/network/example/twitter/search.cpp b/libs/network/example/twitter/search.cpp index d4e4d8db6..04caf6627 100644 --- a/libs/network/example/twitter/search.cpp +++ b/libs/network/example/twitter/search.cpp @@ -4,7 +4,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include +#include #include "rapidjson/rapidjson.h" #include "rapidjson/document.h" #include @@ -14,7 +14,7 @@ // https://dev.twitter.com/docs/using-search int main(int argc, char *argv[]) { - namespace http = boost::network::http; + namespace http = network::http; using namespace rapidjson; if (argc != 2) { From 6cb7388b4f90cb0024de3aeda24c03ed90117067 Mon Sep 17 00:00:00 2001 From: Glyn Matthews Date: Sun, 22 Jul 2012 13:51:22 +0200 Subject: [PATCH 095/196] [#130] Fixed a typo in the build script for detecting multithreaded variants of Boost libraries. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d72438837..c3bc1ef4e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 2.8) project(CPP-NETLIB) set(Boost_USE_STATIC_LIBS ON) -set(Boost_USE_MULTI_THREADED ON) +set(Boost_USE_MULTITHREADED ON) find_package( Boost 1.45.0 REQUIRED unit_test_framework system regex date_time thread chrono filesystem program_options ) find_package( OpenSSL ) find_package( Threads ) From c60bf3913d3351b041483a24d4c23d99a1ba7503 Mon Sep 17 00:00:00 2001 From: Mike-ECT Date: Fri, 27 Jul 2012 13:57:45 +0200 Subject: [PATCH 096/196] Fixed a bug that too many bytes were expected during chunked body processing. --- .../http/client/connection/sync_base.hpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/boost/network/protocol/http/client/connection/sync_base.hpp b/boost/network/protocol/http/client/connection/sync_base.hpp index 1df519b9f..680ed1806 100644 --- a/boost/network/protocol/http/client/connection/sync_base.hpp +++ b/boost/network/protocol/http/client/connection/sync_base.hpp @@ -147,14 +147,20 @@ namespace boost { namespace network { namespace http { namespace impl { throw boost::system::system_error(error); } else { bool stopping_inner = false; + std::istreambuf_iterator eos; + std::istreambuf_iterator stream_iterator0(&response_buffer); + for (; chunk_size > 0 && stream_iterator0 != eos; --chunk_size) + body_stream << *stream_iterator0++; + do { - std::size_t chunk_bytes_read = read(socket_, response_buffer, boost::asio::transfer_at_least(chunk_size), error); - if (chunk_bytes_read == 0) { - if (error != boost::asio::error::eof) throw boost::system::system_error(error); - stopping_inner = true; + if (chunk_size != 0) { + std::size_t chunk_bytes_read = read(socket_, response_buffer, boost::asio::transfer_at_least(chunk_size), error); + if (chunk_bytes_read == 0) { + if (error != boost::asio::error::eof) throw boost::system::system_error(error); + stopping_inner = true; + } } - std::istreambuf_iterator eos; std::istreambuf_iterator stream_iterator(&response_buffer); for (; chunk_size > 0 && stream_iterator != eos; --chunk_size) body_stream << *stream_iterator++; From e874ef698fad5f7fb6e056c4bca7e7ce62a2d8d1 Mon Sep 17 00:00:00 2001 From: Glyn Matthews Date: Sun, 22 Jul 2012 14:45:50 +0200 Subject: [PATCH 097/196] Used move constructor instead of copy constructor when returning a string object from the encode/decode functions. --- include/network/uri/decode.hpp | 2 +- include/network/uri/encode.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/network/uri/decode.hpp b/include/network/uri/decode.hpp index 78cf098a7..21835dc34 100644 --- a/include/network/uri/decode.hpp +++ b/include/network/uri/decode.hpp @@ -96,7 +96,7 @@ inline std::string decoded(const std::string &input) { std::string decoded; decode(input, std::back_inserter(decoded)); - return decoded; + return std::move(decoded); } } // namespace network diff --git a/include/network/uri/encode.hpp b/include/network/uri/encode.hpp index 3d0945781..825b03716 100644 --- a/include/network/uri/encode.hpp +++ b/include/network/uri/encode.hpp @@ -164,7 +164,7 @@ inline std::string encoded(const std::string &input) { std::string encoded; encode(input, std::back_inserter(encoded)); - return encoded; + return std::move(encoded); } } // namespace network From 64d6030ef82bb44b5fafd5608867e26df3dee97f Mon Sep 17 00:00:00 2001 From: Glyn Matthews Date: Sun, 22 Jul 2012 13:54:53 +0200 Subject: [PATCH 098/196] Added an improvement to the equality operation to be able to compare the URI query, independently of the order of the URI query arguments. --- include/network/uri/uri.hpp | 18 ++++++++++-------- libs/network/src/uri/uri.cpp | 27 +++++++++++++++++++++++++++ libs/network/test/uri/uri_test.cpp | 7 +++++++ 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/include/network/uri/uri.hpp b/include/network/uri/uri.hpp index ec8a5ec93..0e8c3d84a 100644 --- a/include/network/uri/uri.hpp +++ b/include/network/uri/uri.hpp @@ -312,29 +312,31 @@ std::size_t hash_value(const uri &uri_) return seed; } -inline -bool operator == (const uri &lhs, const uri &rhs) { - return boost::equal(lhs, rhs); -} +//inline +//bool operator == (const uri &lhs, const uri &rhs) { +// return boost::equal(lhs, rhs); +//} + +bool operator == (const uri &lhs, const uri &rhs); inline bool operator == (const uri &lhs, const uri::string_type &rhs) { - return boost::equal(lhs, rhs); + return lhs == uri(rhs); } inline bool operator == (const uri::string_type &lhs, const uri &rhs) { - return boost::equal(lhs, rhs); + return uri(lhs) == rhs; } inline bool operator == (const uri &lhs, const uri::value_type *rhs) { - return boost::equal(lhs, boost::as_literal(rhs)); + return lhs == uri(rhs); } inline bool operator == (const uri::value_type *lhs, const uri &rhs) { - return boost::equal(boost::as_literal(lhs), rhs); + return uri(lhs) == rhs; } inline diff --git a/libs/network/src/uri/uri.cpp b/libs/network/src/uri/uri.cpp index edfca04dc..99536d0fe 100644 --- a/libs/network/src/uri/uri.cpp +++ b/libs/network/src/uri/uri.cpp @@ -5,3 +5,30 @@ #include +#include +#include + +#include +#include + +namespace network { +bool operator == (const uri &lhs, const uri &rhs) { + bool equal = boost::equal( + std::make_pair(std::begin(lhs.scheme_range()), std::begin(lhs.path_range())), + std::make_pair(std::begin(rhs.scheme_range()), std::begin(rhs.path_range()))); + if (equal) + { + // TODO: test normalized paths + equal = boost::equal(lhs.path_range(), rhs.path_range()); + } + + if (equal) + { + // test query order + std::map lhs_query_params, rhs_query_params; + equal = (query_map(lhs, lhs_query_params) == query_map(rhs, rhs_query_params)); + } + + return equal; +} +} // namespace network diff --git a/libs/network/test/uri/uri_test.cpp b/libs/network/test/uri/uri_test.cpp index 80dae667b..a8d65cc52 100644 --- a/libs/network/test/uri/uri_test.cpp +++ b/libs/network/test/uri/uri_test.cpp @@ -363,6 +363,12 @@ BOOST_AUTO_TEST_CASE(equality_test_4) { BOOST_CHECK(uri_1.c_str() == uri_2); } +BOOST_AUTO_TEST_CASE(equality_test_reordered_query) { + network::uri uri_1("http://www.example.com/?a=1&b=2"); + network::uri uri_2("http://www.example.com/?b=2&a=1"); + BOOST_CHECK(uri_1 == uri_2); +} + BOOST_AUTO_TEST_CASE(inequality_test) { network::uri uri_1("http://www.example.com/"); network::uri uri_2("http://www.example.com/"); @@ -454,6 +460,7 @@ BOOST_AUTO_TEST_CASE(issue_67_test) { } BOOST_AUTO_TEST_CASE(from_parts_1) { + std::cout << __FUNCTION__ << std::endl; BOOST_CHECK_EQUAL(network::uri("http://www.example.com/path?query#fragment"), network::from_parts(network::uri("http://www.example.com/"), "/path", "query", "fragment")); } From 72f94ec4d4df8af039cb387e9ff594e284705add Mon Sep 17 00:00:00 2001 From: Glyn Matthews Date: Mon, 23 Jul 2012 07:59:07 +0200 Subject: [PATCH 099/196] Added some tests to access the default port given a URI scheme. --- include/network/uri/schemes.hpp | 5 +- libs/network/src/uri/schemes.cpp | 73 +++++++++++++++----------- libs/network/src/uri/uri.cpp | 34 +++++++++--- libs/network/test/uri/CMakeLists.txt | 1 + libs/network/test/uri/scheme_tests.cpp | 25 +++++++++ libs/network/test/uri/uri_test.cpp | 19 ++++++- 6 files changed, 118 insertions(+), 39 deletions(-) create mode 100644 libs/network/test/uri/scheme_tests.cpp diff --git a/include/network/uri/schemes.hpp b/include/network/uri/schemes.hpp index 10bb3bce4..2170e55d0 100644 --- a/include/network/uri/schemes.hpp +++ b/include/network/uri/schemes.hpp @@ -7,9 +7,8 @@ #ifndef __BOOST_NETWORK_URI_SCHEMES_INC__ # define __BOOST_NETWORK_URI_SCHEMES_INC__ - #include - +#include namespace network { class hierarchical_schemes { @@ -27,6 +26,8 @@ class opaque_schemes { static bool exists(const std::string &scheme); }; + +boost::optional default_port(const std::string &scheme); } // namespace network diff --git a/libs/network/src/uri/schemes.cpp b/libs/network/src/uri/schemes.cpp index c03eac06e..b092e584d 100644 --- a/libs/network/src/uri/schemes.cpp +++ b/libs/network/src/uri/schemes.cpp @@ -3,44 +3,39 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) - #include -#include - +#include namespace network { namespace { -static boost::unordered_set hierarchical_schemes_; -static boost::unordered_set opaque_schemes_; +static boost::unordered_map hierarchical_schemes_; +static boost::unordered_map opaque_schemes_; bool register_hierarchical_schemes() { - hierarchical_schemes_.insert("http"); - hierarchical_schemes_.insert("https"); - hierarchical_schemes_.insert("shttp"); - hierarchical_schemes_.insert("ftp"); - hierarchical_schemes_.insert("file"); - hierarchical_schemes_.insert("dns"); - hierarchical_schemes_.insert("nfs"); - hierarchical_schemes_.insert("imap"); - hierarchical_schemes_.insert("nntp"); - hierarchical_schemes_.insert("pop"); - hierarchical_schemes_.insert("rsync"); - hierarchical_schemes_.insert("snmp"); - hierarchical_schemes_.insert("telnet"); - hierarchical_schemes_.insert("svn"); - hierarchical_schemes_.insert("svn+ssh"); - hierarchical_schemes_.insert("git"); - hierarchical_schemes_.insert("git+ssh"); + hierarchical_schemes_.insert(std::make_pair(std::string("http"), std::string("80"))); + hierarchical_schemes_.insert(std::make_pair(std::string("https"), std::string("443"))); + hierarchical_schemes_.insert(std::make_pair(std::string("shttp"), std::string(""))); + hierarchical_schemes_.insert(std::make_pair(std::string("ftp"), std::string("21"))); + hierarchical_schemes_.insert(std::make_pair(std::string("file"), std::string(""))); + hierarchical_schemes_.insert(std::make_pair(std::string("dns"), std::string("53"))); + hierarchical_schemes_.insert(std::make_pair(std::string("nfs"), std::string("2049"))); + hierarchical_schemes_.insert(std::make_pair(std::string("imap"), std::string("143"))); + hierarchical_schemes_.insert(std::make_pair(std::string("nntp"), std::string(""))); + hierarchical_schemes_.insert(std::make_pair(std::string("pop"), std::string("119"))); + hierarchical_schemes_.insert(std::make_pair(std::string("rsync"), std::string("873"))); + hierarchical_schemes_.insert(std::make_pair(std::string("snmp"), std::string("161"))); + hierarchical_schemes_.insert(std::make_pair(std::string("telnet"), std::string("23"))); + hierarchical_schemes_.insert(std::make_pair(std::string("svn"), std::string("3690"))); + hierarchical_schemes_.insert(std::make_pair(std::string("svn+ssh"), std::string(""))); + hierarchical_schemes_.insert(std::make_pair(std::string("git"), std::string("9418"))); + hierarchical_schemes_.insert(std::make_pair(std::string("git+ssh"), std::string(""))); return true; } bool register_opaque_schemes() { - opaque_schemes_.insert("mailto"); - opaque_schemes_.insert("news"); - opaque_schemes_.insert("im"); - opaque_schemes_.insert("sip"); - opaque_schemes_.insert("sms"); - opaque_schemes_.insert("xmpp"); + opaque_schemes_.insert(std::make_pair(std::string("mailto"), std::string("25"))); + opaque_schemes_.insert(std::make_pair(std::string("sip"), std::string("5060"))); + opaque_schemes_.insert(std::make_pair(std::string("xmpp"), std::string("5222"))); return true; } @@ -50,10 +45,28 @@ static bool opaque = register_opaque_schemes(); } // namespace bool hierarchical_schemes::exists(const std::string &scheme) { - return hierarchical_schemes_.end() != hierarchical_schemes_.find(scheme); + return std::end(hierarchical_schemes_) != hierarchical_schemes_.find(scheme); } bool opaque_schemes::exists(const std::string &scheme) { - return opaque_schemes_.end() != opaque_schemes_.find(scheme); + return std::end(opaque_schemes_) != opaque_schemes_.find(scheme); +} + +boost::optional default_port(const std::string &scheme) { + auto it = hierarchical_schemes_.find(scheme); + if (it != std::end(hierarchical_schemes_)) { + if (!it->second.empty()) { + return it->second; + } + } + + it = opaque_schemes_.find(scheme); + if (it != std::end(opaque_schemes_)) { + if (!it->second.empty()) { + return it->second; + } + } + + return boost::optional(); } } // namespace network diff --git a/libs/network/src/uri/uri.cpp b/libs/network/src/uri/uri.cpp index 99536d0fe..cc8c0fd64 100644 --- a/libs/network/src/uri/uri.cpp +++ b/libs/network/src/uri/uri.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -13,20 +14,41 @@ namespace network { bool operator == (const uri &lhs, const uri &rhs) { - bool equal = boost::equal( - std::make_pair(std::begin(lhs.scheme_range()), std::begin(lhs.path_range())), - std::make_pair(std::begin(rhs.scheme_range()), std::begin(rhs.path_range()))); + // the scheme can be compared insensitive to case + bool equal = boost::iequals(lhs.scheme_range(), rhs.scheme_range()); + if (equal) + { + // the user info must be case sensitive + equal = boost::equals(lhs.user_info_range(), rhs.user_info_range()); + } + + if (equal) + { + // the host can be compared insensitive to case + equal = boost::iequals( + std::make_pair(std::begin(lhs.host_range()), std::end(lhs.host_range())), + std::make_pair(std::begin(rhs.host_range()), std::end(rhs.host_range()))); + } + + if (equal) + { + // TODO: test default ports according to scheme + equal = boost::equals( + std::make_pair(std::begin(lhs.port_range()), std::end(lhs.port_range())), + std::make_pair(std::begin(rhs.port_range()), std::end(rhs.port_range()))); + } + if (equal) { // TODO: test normalized paths - equal = boost::equal(lhs.path_range(), rhs.path_range()); + equal = boost::iequals(lhs.path_range(), rhs.path_range()); } if (equal) { - // test query order + // test query, independent of order std::map lhs_query_params, rhs_query_params; - equal = (query_map(lhs, lhs_query_params) == query_map(rhs, rhs_query_params)); + equal = (query_map(lhs, lhs_query_params) == query_map(rhs, rhs_query_params)); } return equal; diff --git a/libs/network/test/uri/CMakeLists.txt b/libs/network/test/uri/CMakeLists.txt index dc3a323de..02e96e7c7 100644 --- a/libs/network/test/uri/CMakeLists.txt +++ b/libs/network/test/uri/CMakeLists.txt @@ -15,6 +15,7 @@ if (Boost_FOUND) uri_builder_stream_test uri_encoding_test relative_uri_test + scheme_tests ) foreach (test ${TESTS}) if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) diff --git a/libs/network/test/uri/scheme_tests.cpp b/libs/network/test/uri/scheme_tests.cpp new file mode 100644 index 000000000..42df85482 --- /dev/null +++ b/libs/network/test/uri/scheme_tests.cpp @@ -0,0 +1,25 @@ +// Copyright 2012 Glyn Matthews. +// 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) + +#define BOOST_TEST_MODULE URI Scheme Test +#include +#include +#include + +BOOST_AUTO_TEST_CASE(http_has_default_port) { + BOOST_CHECK(network::default_port("http")); +} + +BOOST_AUTO_TEST_CASE(http_default_port) { + BOOST_CHECK_EQUAL(std::string("80"), network::default_port("http")); +} + +BOOST_AUTO_TEST_CASE(https_has_default_port) { + BOOST_CHECK(network::default_port("https")); +} + +BOOST_AUTO_TEST_CASE(https_default_port) { + BOOST_CHECK_EQUAL(std::string("443"), network::default_port("https")); +} diff --git a/libs/network/test/uri/uri_test.cpp b/libs/network/test/uri/uri_test.cpp index a8d65cc52..af3792573 100644 --- a/libs/network/test/uri/uri_test.cpp +++ b/libs/network/test/uri/uri_test.cpp @@ -369,6 +369,24 @@ BOOST_AUTO_TEST_CASE(equality_test_reordered_query) { BOOST_CHECK(uri_1 == uri_2); } +BOOST_AUTO_TEST_CASE(equality_test_capitalized_scheme) { + network::uri uri_1("http://www.example.com/"); + network::uri uri_2("HTTP://www.example.com/"); + BOOST_CHECK(uri_1 == uri_2); +} + +BOOST_AUTO_TEST_CASE(equality_test_capitalized_host) { + network::uri uri_1("http://www.example.com/"); + network::uri uri_2("http://www.example.com/"); + BOOST_CHECK(uri_1 == uri_2); +} + +BOOST_AUTO_TEST_CASE(equality_test_user_info) { + network::uri uri_1("ftp://john.doe@ftp.example.com/"); + network::uri uri_2("ftp://JOHN.DOE@ftp.example.com/"); + BOOST_CHECK(uri_1 != uri_2); +} + BOOST_AUTO_TEST_CASE(inequality_test) { network::uri uri_1("http://www.example.com/"); network::uri uri_2("http://www.example.com/"); @@ -460,7 +478,6 @@ BOOST_AUTO_TEST_CASE(issue_67_test) { } BOOST_AUTO_TEST_CASE(from_parts_1) { - std::cout << __FUNCTION__ << std::endl; BOOST_CHECK_EQUAL(network::uri("http://www.example.com/path?query#fragment"), network::from_parts(network::uri("http://www.example.com/"), "/path", "query", "fragment")); } From a127593de0edb4a626fe63754a4c8666bb00a739 Mon Sep 17 00:00:00 2001 From: Glyn Matthews Date: Wed, 25 Jul 2012 18:45:24 +0200 Subject: [PATCH 100/196] Updated equality test to take into account if the default port is specified. --- libs/network/src/uri/uri.cpp | 38 +++++++++++++++++------------- libs/network/test/uri/uri_test.cpp | 24 +++++++++++++++++++ 2 files changed, 45 insertions(+), 17 deletions(-) diff --git a/libs/network/src/uri/uri.cpp b/libs/network/src/uri/uri.cpp index cc8c0fd64..16d08da38 100644 --- a/libs/network/src/uri/uri.cpp +++ b/libs/network/src/uri/uri.cpp @@ -16,36 +16,40 @@ namespace network { bool operator == (const uri &lhs, const uri &rhs) { // the scheme can be compared insensitive to case bool equal = boost::iequals(lhs.scheme_range(), rhs.scheme_range()); - if (equal) - { + if (equal) { // the user info must be case sensitive equal = boost::equals(lhs.user_info_range(), rhs.user_info_range()); } - if (equal) - { + if (equal) { // the host can be compared insensitive to case - equal = boost::iequals( - std::make_pair(std::begin(lhs.host_range()), std::end(lhs.host_range())), - std::make_pair(std::begin(rhs.host_range()), std::end(rhs.host_range()))); + equal = boost::iequals(lhs.host_range(), rhs.host_range()); } - if (equal) - { - // TODO: test default ports according to scheme - equal = boost::equals( - std::make_pair(std::begin(lhs.port_range()), std::end(lhs.port_range())), - std::make_pair(std::begin(rhs.port_range()), std::end(rhs.port_range()))); + if (equal) { + if (lhs.port_range() && rhs.port_range()) { + equal = boost::equals(lhs.port_range(), rhs.port_range()); + } + else if (!lhs.port_range() && rhs.port_range()) { + auto port = default_port(lhs.scheme()); + if (port) { + equal = boost::equals(*port, rhs.port_range()); + } + } + else if (lhs.port_range() && !rhs.port_range()) { + auto port = default_port(rhs.scheme()); + if (port) { + equal = boost::equals(lhs.port_range(), *port); + } + } } - if (equal) - { + if (equal) { // TODO: test normalized paths equal = boost::iequals(lhs.path_range(), rhs.path_range()); } - if (equal) - { + if (equal) { // test query, independent of order std::map lhs_query_params, rhs_query_params; equal = (query_map(lhs, lhs_query_params) == query_map(rhs, rhs_query_params)); diff --git a/libs/network/test/uri/uri_test.cpp b/libs/network/test/uri/uri_test.cpp index af3792573..7bf87b713 100644 --- a/libs/network/test/uri/uri_test.cpp +++ b/libs/network/test/uri/uri_test.cpp @@ -387,6 +387,30 @@ BOOST_AUTO_TEST_CASE(equality_test_user_info) { BOOST_CHECK(uri_1 != uri_2); } +BOOST_AUTO_TEST_CASE(equality_test_default_http_port) { + network::uri uri_1("http://www.example.com/"); + network::uri uri_2("http://www.example.com/"); + BOOST_CHECK(uri_1 == uri_2); +} + +BOOST_AUTO_TEST_CASE(equality_test_default_http_port_2) { + network::uri uri_1("http://www.example.com/"); + network::uri uri_2("http://www.example.com/"); + BOOST_CHECK(uri_1 == uri_2); +} + +BOOST_AUTO_TEST_CASE(equality_test_default_https_port) { + network::uri uri_1("https://www.example.com/"); + network::uri uri_2("https://www.example.com/"); + BOOST_CHECK(uri_1 == uri_2); +} + +BOOST_AUTO_TEST_CASE(equality_test_default_https_port_2) { + network::uri uri_1("https://www.example.com/"); + network::uri uri_2("https://www.example.com/"); + BOOST_CHECK(uri_1 == uri_2); +} + BOOST_AUTO_TEST_CASE(inequality_test) { network::uri uri_1("http://www.example.com/"); network::uri uri_2("http://www.example.com/"); From 275ed5de7eb1a24d225029b131bcd86a01ee1820 Mon Sep 17 00:00:00 2001 From: Glyn Matthews Date: Sun, 29 Jul 2012 12:50:03 +0200 Subject: [PATCH 101/196] Added a function to normalize the URI path and used it to better test URI equality. --- include/network/uri/normalize.hpp | 32 +++++++++++++++++ libs/network/src/CMakeLists.txt | 2 +- libs/network/src/uri/normalize.cpp | 56 +++++++++++++++++++++++++++++ libs/network/src/uri/uri.cpp | 3 +- libs/network/test/uri/uri_test.cpp | 57 +++++++++++++++++++++++------- 5 files changed, 135 insertions(+), 15 deletions(-) create mode 100644 include/network/uri/normalize.hpp create mode 100644 libs/network/src/uri/normalize.cpp diff --git a/include/network/uri/normalize.hpp b/include/network/uri/normalize.hpp new file mode 100644 index 000000000..bfe098d8f --- /dev/null +++ b/include/network/uri/normalize.hpp @@ -0,0 +1,32 @@ +// Copyright (c) Glyn Matthews 2012. +// 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 __BOOST_NETWORK_URI_NORMALIZE_INC__ +# define __BOOST_NETWORK_URI_NORMALIZE_INC__ + +# include + +namespace network { +uri::string_type normalize_path(const uri::const_range_type &path); + +//uri normalize(const uri &uri_); +// +//uri::string_type normalize_scheme(const uri &uri_); +// +//uri::string_type normalize_user_info(const uri &uri_); +// +//uri::string_type normalize_host(const uri &uri_); +// +//uri::string_type normalize_port(const uri &uri_); +// +//uri::string_type normalize_path(const uri &uri_); +// +//uri::string_type normalize_fragment(const uri &uri_); +// +//uri::string_type normalize_query(const uri &uri_); +} // namespace network + +#endif // __BOOST_NETWORK_URI_NORMALIZE_INC__ diff --git a/libs/network/src/CMakeLists.txt b/libs/network/src/CMakeLists.txt index 255051dcd..914f64576 100644 --- a/libs/network/src/CMakeLists.txt +++ b/libs/network/src/CMakeLists.txt @@ -17,7 +17,7 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) endif() endif() -set(CPP-NETLIB_URI_SRCS uri/uri.cpp uri/schemes.cpp) +set(CPP-NETLIB_URI_SRCS uri/uri.cpp uri/schemes.cpp uri/normalize.cpp) add_library(cppnetlib-uri ${CPP-NETLIB_URI_SRCS}) foreach (src_file ${CPP-NETLIB_URI_SRCS}) if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) diff --git a/libs/network/src/uri/normalize.cpp b/libs/network/src/uri/normalize.cpp new file mode 100644 index 000000000..9d9ca2088 --- /dev/null +++ b/libs/network/src/uri/normalize.cpp @@ -0,0 +1,56 @@ +// Copyright (c) Glyn Matthews 2012. +// 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) + + +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include + +namespace network { +uri::string_type normalize_path(const uri::const_range_type &path) { + using namespace boost; + using namespace boost::algorithm; + + // add trailing / + if (empty(path)) { + return uri::string_type("/"); + } + + std::vector path_segments; + split(path_segments, path, is_any_of("/")); + + // remove single dot segments + remove_erase_if(path_segments, [] (const uri::string_type &s) { + return equal(s, as_literal(".")); + }); + + // remove double dot segments + std::vector normalized_segments; + auto depth = 0; + for_each(path_segments, [&normalized_segments, &depth] (const uri::string_type &s) { + assert(depth >= 0); + if (equal(s, as_literal(".."))) { + normalized_segments.pop_back(); + } + else { + normalized_segments.push_back(s); + } + }); + + if (!empty(normalized_segments.back()) && + !contains(normalized_segments.back(), as_literal("."))) { + normalized_segments.push_back(uri::string_type()); + } + + return join(normalized_segments, "/"); +} +} // namespace network diff --git a/libs/network/src/uri/uri.cpp b/libs/network/src/uri/uri.cpp index 16d08da38..f9d27abcc 100644 --- a/libs/network/src/uri/uri.cpp +++ b/libs/network/src/uri/uri.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -46,7 +47,7 @@ bool operator == (const uri &lhs, const uri &rhs) { if (equal) { // TODO: test normalized paths - equal = boost::iequals(lhs.path_range(), rhs.path_range()); + equal = boost::iequals(normalize_path(lhs.path_range()), normalize_path(rhs.path_range())); } if (equal) { diff --git a/libs/network/test/uri/uri_test.cpp b/libs/network/test/uri/uri_test.cpp index 7bf87b713..ff3aabe93 100644 --- a/libs/network/test/uri/uri_test.cpp +++ b/libs/network/test/uri/uri_test.cpp @@ -336,19 +336,19 @@ BOOST_AUTO_TEST_CASE(swap_test) { BOOST_AUTO_TEST_CASE(equality_test) { network::uri uri_1("http://www.example.com/"); network::uri uri_2("http://www.example.com/"); - BOOST_CHECK(uri_1 == uri_2); + BOOST_CHECK_EQUAL(uri_1, uri_2); } BOOST_AUTO_TEST_CASE(equality_test_1) { network::uri uri_1("http://www.example.com/"); std::string uri_2("http://www.example.com/"); - BOOST_CHECK(uri_1 == uri_2); + BOOST_CHECK_EQUAL(uri_1, uri_2); } BOOST_AUTO_TEST_CASE(equality_test_2) { std::string uri_1("http://www.example.com/"); network::uri uri_2("http://www.example.com/"); - BOOST_CHECK(uri_1 == uri_2); + BOOST_CHECK_EQUAL(uri_1, uri_2); } BOOST_AUTO_TEST_CASE(equality_test_3) { @@ -366,62 +366,93 @@ BOOST_AUTO_TEST_CASE(equality_test_4) { BOOST_AUTO_TEST_CASE(equality_test_reordered_query) { network::uri uri_1("http://www.example.com/?a=1&b=2"); network::uri uri_2("http://www.example.com/?b=2&a=1"); - BOOST_CHECK(uri_1 == uri_2); + BOOST_CHECK_EQUAL(uri_1, uri_2); } BOOST_AUTO_TEST_CASE(equality_test_capitalized_scheme) { network::uri uri_1("http://www.example.com/"); network::uri uri_2("HTTP://www.example.com/"); - BOOST_CHECK(uri_1 == uri_2); + BOOST_CHECK_EQUAL(uri_1, uri_2); } BOOST_AUTO_TEST_CASE(equality_test_capitalized_host) { network::uri uri_1("http://www.example.com/"); network::uri uri_2("http://www.example.com/"); - BOOST_CHECK(uri_1 == uri_2); + BOOST_CHECK_EQUAL(uri_1, uri_2); } BOOST_AUTO_TEST_CASE(equality_test_user_info) { network::uri uri_1("ftp://john.doe@ftp.example.com/"); network::uri uri_2("ftp://JOHN.DOE@ftp.example.com/"); - BOOST_CHECK(uri_1 != uri_2); + BOOST_CHECK_PREDICATE(std::not_equal_to(), (uri_1)(uri_2)); } BOOST_AUTO_TEST_CASE(equality_test_default_http_port) { network::uri uri_1("http://www.example.com/"); network::uri uri_2("http://www.example.com/"); - BOOST_CHECK(uri_1 == uri_2); + BOOST_CHECK_EQUAL(uri_1, uri_2); } BOOST_AUTO_TEST_CASE(equality_test_default_http_port_2) { network::uri uri_1("http://www.example.com/"); network::uri uri_2("http://www.example.com/"); - BOOST_CHECK(uri_1 == uri_2); + BOOST_CHECK_EQUAL(uri_1, uri_2); } BOOST_AUTO_TEST_CASE(equality_test_default_https_port) { network::uri uri_1("https://www.example.com/"); network::uri uri_2("https://www.example.com/"); - BOOST_CHECK(uri_1 == uri_2); + BOOST_CHECK_EQUAL(uri_1, uri_2); } BOOST_AUTO_TEST_CASE(equality_test_default_https_port_2) { network::uri uri_1("https://www.example.com/"); network::uri uri_2("https://www.example.com/"); - BOOST_CHECK(uri_1 == uri_2); + BOOST_CHECK_EQUAL(uri_1, uri_2); +} + +BOOST_AUTO_TEST_CASE(equality_test_empty_path_with_trailing_slash) { + network::uri uri_1("http://www.example.com/"); + network::uri uri_2("http://www.example.com/"); + BOOST_CHECK_EQUAL(uri_1, uri_2); +} + +BOOST_AUTO_TEST_CASE(equality_test_with_single_dot_segment) { + network::uri uri_1("http://www.example.com/path"); + network::uri uri_2("http://www.example.com/path"); + BOOST_CHECK_EQUAL(uri_1, uri_2); +} + +BOOST_AUTO_TEST_CASE(equality_test_with_double_dot_segment) { + network::uri uri_1("http://www.example.com/2/"); + network::uri uri_2("http://www.example.com/2/"); + BOOST_CHECK_EQUAL(uri_1, uri_2); +} + +BOOST_AUTO_TEST_CASE(equality_test_with_trailing_slash) { + network::uri uri_1("http://www.example.com/path/"); + network::uri uri_2("http://www.example.com/path"); + BOOST_CHECK_EQUAL(uri_1, uri_2); +} + +BOOST_AUTO_TEST_CASE(equality_test_with_file_ext) { + network::uri uri_1("http://www.example.com/filename.txt"); + network::uri uri_2("http://www.example.com/filename.txt/"); + BOOST_CHECK_PREDICATE(std::not_equal_to(), (uri_1)(uri_2)); } BOOST_AUTO_TEST_CASE(inequality_test) { network::uri uri_1("http://www.example.com/"); network::uri uri_2("http://www.example.com/"); - BOOST_CHECK(!(uri_1 != uri_2)); + BOOST_CHECK(!(uri_1 != uri_2)); } BOOST_AUTO_TEST_CASE(less_than_test) { // uri_1 is lexicographically less than uri_2 network::uri uri_1("http://www.example.com/"); network::uri uri_2("http://www.example.org/"); - BOOST_CHECK(uri_1 < uri_2); + BOOST_CHECK_PREDICATE(std::less(), (uri_1)(uri_2)); + //BOOST_CHECK(uri_1 < uri_2); } BOOST_AUTO_TEST_CASE(username_test) { From 39d7630a89777889f96cf0a53276cfad2f36e80c Mon Sep 17 00:00:00 2001 From: Glyn Matthews Date: Sun, 29 Jul 2012 14:18:30 +0200 Subject: [PATCH 102/196] Fixed some compilation errors on MSVC; Added tests for equality when the URI strings are invalid or empty. --- libs/network/src/uri/normalize.cpp | 4 ++-- libs/network/src/uri/uri.cpp | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/libs/network/src/uri/normalize.cpp b/libs/network/src/uri/normalize.cpp index 9d9ca2088..846b0863b 100644 --- a/libs/network/src/uri/normalize.cpp +++ b/libs/network/src/uri/normalize.cpp @@ -30,7 +30,7 @@ uri::string_type normalize_path(const uri::const_range_type &path) { // remove single dot segments remove_erase_if(path_segments, [] (const uri::string_type &s) { - return equal(s, as_literal(".")); + return equal(s, boost::as_literal(".")); }); // remove double dot segments @@ -38,7 +38,7 @@ uri::string_type normalize_path(const uri::const_range_type &path) { auto depth = 0; for_each(path_segments, [&normalized_segments, &depth] (const uri::string_type &s) { assert(depth >= 0); - if (equal(s, as_literal(".."))) { + if (equal(s, boost::as_literal(".."))) { normalized_segments.pop_back(); } else { diff --git a/libs/network/src/uri/uri.cpp b/libs/network/src/uri/uri.cpp index f9d27abcc..284c39876 100644 --- a/libs/network/src/uri/uri.cpp +++ b/libs/network/src/uri/uri.cpp @@ -10,11 +10,18 @@ #include #include -#include -#include - namespace network { bool operator == (const uri &lhs, const uri &rhs) { + + // if both URIs are empty, then we should define them as equal even though they're still invalid. + if (boost::empty(lhs) && boost::empty(rhs)) { + return true; + } + + if (!valid(lhs) || !valid(rhs)) { + return false; + } + // the scheme can be compared insensitive to case bool equal = boost::iequals(lhs.scheme_range(), rhs.scheme_range()); if (equal) { @@ -46,7 +53,7 @@ bool operator == (const uri &lhs, const uri &rhs) { } if (equal) { - // TODO: test normalized paths + // test normalized paths equal = boost::iequals(normalize_path(lhs.path_range()), normalize_path(rhs.path_range())); } From a4dabd50dcd42f46ac152c733a3d39f32040185d Mon Sep 17 00:00:00 2001 From: Glyn Matthews Date: Mon, 30 Jul 2012 21:26:40 +0200 Subject: [PATCH 103/196] Applied some fixes to the build scripts (#131) --- libs/network/example/CMakeLists.txt | 20 +++++++++++--------- libs/network/src/CMakeLists.txt | 3 +++ libs/network/test/CMakeLists.txt | 1 + 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/libs/network/example/CMakeLists.txt b/libs/network/example/CMakeLists.txt index 76c829e95..1846f5a86 100644 --- a/libs/network/example/CMakeLists.txt +++ b/libs/network/example/CMakeLists.txt @@ -20,21 +20,23 @@ add_executable(hello_world_client http/hello_world_client.cpp) # add_executable(fileserver http/fileserver.cpp) #endif (UNIX) set(BOOST_CLIENT_LIBS - ${Boost_PROGRAM_OPTIONS_LIBRARY} - ${Boost_THREAD_LIBRARY} ${Boost_CHRONO_LIBRARY} ${Boost_DATE_TIME_LIBRARY} - ${Boost_REGEX_LIBRARY} + ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} - ${Boost_SYSTEM_LIBRARY}) - -set(BOOST_SERVER_LIBS + ${Boost_PROGRAM_OPTIONS_LIBRARY} + ${Boost_REGEX_LIBRARY} ${Boost_THREAD_LIBRARY} + ) +set(BOOST_SERVER_LIBS ${Boost_CHRONO_LIBRARY} - ${Boost_SYSTEM_LIBRARY} ${Boost_DATE_TIME_LIBRARY} - ${Boost_PROGRAM_OPTIONS_LIBRARY}) - + ${Boost_SYSTEM_LIBRARY} + ${Boost_FILESYSTEM_LIBRARY} + ${Boost_PROGRAM_OPTIONS_LIBRARY} + ${Boost_THREAD_LIBRARY} + ) + target_link_libraries(uri_builder ${BOOST_CLIENT_LIBS} ${CMAKE_THREAD_LIBS_INIT} diff --git a/libs/network/src/CMakeLists.txt b/libs/network/src/CMakeLists.txt index 914f64576..a94600d55 100644 --- a/libs/network/src/CMakeLists.txt +++ b/libs/network/src/CMakeLists.txt @@ -8,6 +8,9 @@ include_directories(${CPP-NETLIB_SOURCE_DIR}/include) include_directories(${CPP-NETLIB_SOURCE_DIR}) +if (OPENSSL_FOUND) +include_directories(${OPENSSL_INCLUDE_DIR}) +endif() if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) if (HAVE_STD11) diff --git a/libs/network/test/CMakeLists.txt b/libs/network/test/CMakeLists.txt index 6f5c92c6f..2e24dbaf2 100644 --- a/libs/network/test/CMakeLists.txt +++ b/libs/network/test/CMakeLists.txt @@ -34,6 +34,7 @@ if (Boost_FOUND) cppnetlib-message-directives cppnetlib-message-wrappers) if (OPENSSL_FOUND) + include_directories(${OPENSSL_INCLUDE_DIR}) target_link_libraries(cpp-netlib-${test} ${OPENSSL_LIBRARIES}) endif() set_target_properties(cpp-netlib-${test} From 2f5d91ab49726100ab4be23351514e43510feb28 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Mon, 10 Sep 2012 00:36:19 +1000 Subject: [PATCH 104/196] Minor fixes for Clang 3.1 support --- .../http/client/connection/simple_connection_factory.ipp | 2 +- libs/network/example/twitter/rapidjson/document.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/boost/network/protocol/http/client/connection/simple_connection_factory.ipp b/boost/network/protocol/http/client/connection/simple_connection_factory.ipp index 1ea211678..762706cac 100644 --- a/boost/network/protocol/http/client/connection/simple_connection_factory.ipp +++ b/boost/network/protocol/http/client/connection/simple_connection_factory.ipp @@ -14,7 +14,7 @@ #include #include #ifdef BOOST_NETWORK_DEBUG -#include +#include #endif #include diff --git a/libs/network/example/twitter/rapidjson/document.h b/libs/network/example/twitter/rapidjson/document.h index f956ea97d..4062bd841 100644 --- a/libs/network/example/twitter/rapidjson/document.h +++ b/libs/network/example/twitter/rapidjson/document.h @@ -701,7 +701,7 @@ class GenericDocument : public GenericValue { GenericDocument& ParseStream(Stream& stream) { ValueType::SetNull(); // Remove existing root if exist GenericReader reader; - if (reader.Parse(stream, *this)) { + if (reader.template Parse(stream, *this)) { RAPIDJSON_ASSERT(stack_.GetSize() == sizeof(ValueType)); // Got one and only one root object this->RawAssign(*stack_.template Pop(1)); parseError_ = 0; From f7bcd7bf808eb7353b79ad378482446b16ff3e5e Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Mon, 10 Sep 2012 00:39:44 +1000 Subject: [PATCH 105/196] The great rename; breaks everything. --- {boost => include}/network.hpp | 0 {boost => include}/network/constants.hpp | 0 {boost => include}/network/constants.ipp | 0 {boost => include}/network/detail/debug.hpp | 0 {boost => include}/network/detail/directive_base.hpp | 0 {boost => include}/network/detail/wrapper_base.hpp | 0 {boost => include}/network/include/http/client.hpp | 0 {boost => include}/network/include/http/server.hpp | 0 {boost => include}/network/include/message.hpp | 0 {boost => include}/network/message.hpp | 0 {boost => include}/network/message/basic_message.hpp | 0 {boost => include}/network/message/basic_message.ipp | 0 {boost => include}/network/message/directives.hpp | 0 .../network/message/directives/detail/string_directive.hpp | 0 .../network/message/directives/detail/string_value.hpp | 0 {boost => include}/network/message/directives/header.hpp | 0 {boost => include}/network/message/directives/header.ipp | 0 {boost => include}/network/message/directives/remove_header.hpp | 0 {boost => include}/network/message/directives/remove_header.ipp | 0 {boost => include}/network/message/message.hpp | 0 {boost => include}/network/message/message.ipp | 0 {boost => include}/network/message/message_base.hpp | 0 {boost => include}/network/message/message_base.ipp | 0 {boost => include}/network/message/message_concept.hpp | 0 {boost => include}/network/message/modifiers.hpp | 0 {boost => include}/network/message/modifiers/add_header.hpp | 0 {boost => include}/network/message/modifiers/body.hpp | 0 {boost => include}/network/message/modifiers/clear_headers.hpp | 0 {boost => include}/network/message/modifiers/destination.hpp | 0 {boost => include}/network/message/modifiers/remove_header.hpp | 0 {boost => include}/network/message/modifiers/source.hpp | 0 {boost => include}/network/message/transformers.hpp | 0 {boost => include}/network/message/transformers/selectors.hpp | 0 {boost => include}/network/message/transformers/to_lower.hpp | 0 {boost => include}/network/message/transformers/to_upper.hpp | 0 {boost => include}/network/message/wrappers.hpp | 0 {boost => include}/network/message/wrappers/body.hpp | 0 {boost => include}/network/message/wrappers/body.ipp | 0 {boost => include}/network/message/wrappers/destination.hpp | 0 {boost => include}/network/message/wrappers/destination.ipp | 0 {boost => include}/network/message/wrappers/headers.hpp | 0 {boost => include}/network/message/wrappers/headers.ipp | 0 {boost => include}/network/message/wrappers/source.hpp | 0 {boost => include}/network/message/wrappers/source.ipp | 0 {boost => include}/network/message_fwd.hpp | 0 {boost => include}/network/protocol.hpp | 0 {boost => include}/network/protocol/http.hpp | 0 {boost => include}/network/protocol/http/algorithms/linearize.hpp | 0 {boost => include}/network/protocol/http/client.hpp | 0 {boost => include}/network/protocol/http/client.ipp | 0 {boost => include}/network/protocol/http/client/base.hpp | 0 {boost => include}/network/protocol/http/client/base.ipp | 0 .../network/protocol/http/client/client_connection.hpp | 0 .../network/protocol/http/client/client_connection.ipp | 0 .../network/protocol/http/client/connection/async_normal.hpp | 0 .../network/protocol/http/client/connection/async_normal.ipp | 0 .../protocol/http/client/connection/async_protocol_handler.hpp | 0 .../network/protocol/http/client/connection/async_resolver.hpp | 0 .../network/protocol/http/client/connection/async_resolver.ipp | 0 .../protocol/http/client/connection/connection_delegate.hpp | 0 .../http/client/connection/connection_delegate_factory.hpp | 0 .../http/client/connection/connection_delegate_factory.ipp | 0 .../protocol/http/client/connection/connection_factory.hpp | 0 .../protocol/http/client/connection/connection_factory.ipp | 0 .../network/protocol/http/client/connection/normal_delegate.hpp | 0 .../network/protocol/http/client/connection/normal_delegate.ipp | 0 .../network/protocol/http/client/connection/resolver_delegate.hpp | 0 .../network/protocol/http/client/connection/resolver_delegate.ipp | 0 .../protocol/http/client/connection/resolver_delegate_factory.hpp | 0 .../protocol/http/client/connection/resolver_delegate_factory.ipp | 0 .../protocol/http/client/connection/simple_connection_factory.hpp | 0 .../protocol/http/client/connection/simple_connection_factory.ipp | 0 .../network/protocol/http/client/connection/ssl_delegate.hpp | 0 .../network/protocol/http/client/connection/ssl_delegate.ipp | 0 .../network/protocol/http/client/connection/sync_base.hpp | 0 .../network/protocol/http/client/connection/sync_normal.hpp | 0 .../network/protocol/http/client/connection/sync_ssl.hpp | 0 .../network/protocol/http/client/connection_manager.hpp | 0 .../network/protocol/http/client/connection_manager.ipp | 0 {boost => include}/network/protocol/http/client/facade.hpp | 0 {boost => include}/network/protocol/http/client/facade.ipp | 0 {boost => include}/network/protocol/http/client/macros.hpp | 0 {boost => include}/network/protocol/http/client/options.hpp | 0 {boost => include}/network/protocol/http/client/options.ipp | 0 {boost => include}/network/protocol/http/client/parameters.hpp | 0 {boost => include}/network/protocol/http/client/pimpl.hpp | 0 .../network/protocol/http/client/simple_connection_manager.hpp | 0 .../network/protocol/http/client/simple_connection_manager.ipp | 0 {boost => include}/network/protocol/http/client/sync_impl.hpp | 0 {boost => include}/network/protocol/http/client_fwd.hpp | 0 {boost => include}/network/protocol/http/errors.hpp | 0 {boost => include}/network/protocol/http/impl/access.hpp | 0 {boost => include}/network/protocol/http/impl/access.ipp | 0 {boost => include}/network/protocol/http/impl/message.ipp | 0 {boost => include}/network/protocol/http/impl/parser.ipp | 0 {boost => include}/network/protocol/http/impl/request.hpp | 0 {boost => include}/network/protocol/http/impl/request_parser.ipp | 0 {boost => include}/network/protocol/http/impl/response.ipp | 0 .../network/protocol/http/message/async_message.hpp | 0 {boost => include}/network/protocol/http/message/directives.hpp | 0 .../network/protocol/http/message/directives/major_version.hpp | 0 .../network/protocol/http/message/directives/method.hpp | 0 .../network/protocol/http/message/directives/minor_version.hpp | 0 .../network/protocol/http/message/directives/status.hpp | 0 .../network/protocol/http/message/directives/status_message.hpp | 0 .../network/protocol/http/message/directives/uri.hpp | 0 .../network/protocol/http/message/directives/version.hpp | 0 {boost => include}/network/protocol/http/message/header.hpp | 0 {boost => include}/network/protocol/http/message/header/name.hpp | 0 {boost => include}/network/protocol/http/message/header/value.hpp | 0 .../network/protocol/http/message/header_concept.hpp | 0 {boost => include}/network/protocol/http/message/modifiers.hpp | 0 .../network/protocol/http/message/modifiers/major_version.hpp | 0 .../network/protocol/http/message/modifiers/method.hpp | 0 .../network/protocol/http/message/modifiers/minor_version.hpp | 0 .../network/protocol/http/message/modifiers/status.hpp | 0 .../network/protocol/http/message/modifiers/status_message.hpp | 0 .../network/protocol/http/message/modifiers/uri.hpp | 0 .../network/protocol/http/message/modifiers/version.hpp | 0 {boost => include}/network/protocol/http/message/wrappers.hpp | 0 .../network/protocol/http/message/wrappers/anchor.hpp | 0 .../network/protocol/http/message/wrappers/anchor.ipp | 0 .../network/protocol/http/message/wrappers/helper.hpp | 0 .../network/protocol/http/message/wrappers/host.hpp | 0 .../network/protocol/http/message/wrappers/host.ipp | 0 .../network/protocol/http/message/wrappers/major_version.hpp | 0 .../network/protocol/http/message/wrappers/method.hpp | 0 .../network/protocol/http/message/wrappers/minor_version.hpp | 0 .../network/protocol/http/message/wrappers/path.hpp | 0 .../network/protocol/http/message/wrappers/path.ipp | 0 .../network/protocol/http/message/wrappers/port.hpp | 0 .../network/protocol/http/message/wrappers/port.ipp | 0 .../network/protocol/http/message/wrappers/protocol.hpp | 0 .../network/protocol/http/message/wrappers/query.hpp | 0 .../network/protocol/http/message/wrappers/query.ipp | 0 .../network/protocol/http/message/wrappers/ready.hpp | 0 .../network/protocol/http/message/wrappers/status.hpp | 0 .../network/protocol/http/message/wrappers/status.ipp | 0 .../network/protocol/http/message/wrappers/status_message.hpp | 0 .../network/protocol/http/message/wrappers/status_message.ipp | 0 {boost => include}/network/protocol/http/message/wrappers/uri.hpp | 0 {boost => include}/network/protocol/http/message/wrappers/uri.ipp | 0 .../network/protocol/http/message/wrappers/version.hpp | 0 .../network/protocol/http/message/wrappers/version.ipp | 0 {boost => include}/network/protocol/http/parser.hpp | 0 {boost => include}/network/protocol/http/parser/incremental.hpp | 0 .../network/protocol/http/policies/async_connection.hpp | 0 .../network/protocol/http/policies/async_connection.ipp | 0 {boost => include}/network/protocol/http/request.hpp | 0 {boost => include}/network/protocol/http/request/request.hpp | 0 {boost => include}/network/protocol/http/request/request.ipp | 0 {boost => include}/network/protocol/http/request/request_base.hpp | 0 {boost => include}/network/protocol/http/request/request_base.ipp | 0 .../network/protocol/http/request/request_concept.hpp | 0 {boost => include}/network/protocol/http/request_parser.hpp | 0 {boost => include}/network/protocol/http/response.hpp | 0 {boost => include}/network/protocol/http/response/response.hpp | 0 {boost => include}/network/protocol/http/response/response.ipp | 0 .../network/protocol/http/response/response_base.hpp | 0 .../network/protocol/http/response/response_base.ipp | 0 .../network/protocol/http/response/response_concept.hpp | 0 {boost => include}/network/protocol/http/server.hpp | 0 {boost => include}/network/protocol/http/server/async_impl.hpp | 0 {boost => include}/network/protocol/http/server/async_impl.ipp | 0 {boost => include}/network/protocol/http/server/async_server.hpp | 0 .../network/protocol/http/server/connection/async.hpp | 0 .../network/protocol/http/server/connection/sync.hpp | 0 {boost => include}/network/protocol/http/server/impl/parsers.ipp | 0 .../network/protocol/http/server/impl/socket_options_setter.hpp | 0 .../network/protocol/http/server/impl/socket_options_setter.ipp | 0 {boost => include}/network/protocol/http/server/options.hpp | 0 {boost => include}/network/protocol/http/server/options.ipp | 0 {boost => include}/network/protocol/http/server/parameters.hpp | 0 {boost => include}/network/protocol/http/server/request.hpp | 0 .../network/protocol/http/server/request_parser.hpp | 0 {boost => include}/network/protocol/http/server/server.ipp | 0 .../network/protocol/http/server/socket_options_base.hpp | 0 {boost => include}/network/protocol/http/server/storage_base.hpp | 0 {boost => include}/network/protocol/http/server/sync_impl.hpp | 0 {boost => include}/network/protocol/http/server/sync_impl.ipp | 0 {boost => include}/network/protocol/http/server/sync_server.hpp | 0 .../network/protocol/http/support/client_or_server.hpp | 0 {boost => include}/network/protocol/http/support/is_client.hpp | 0 {boost => include}/network/protocol/http/support/is_http.hpp | 0 {boost => include}/network/protocol/http/support/is_keepalive.hpp | 0 {boost => include}/network/protocol/http/support/is_server.hpp | 0 {boost => include}/network/protocol/http/support/is_simple.hpp | 0 {boost => include}/network/protocol/http/support/sync_only.hpp | 0 {boost => include}/network/utils/thread_pool.hpp | 0 {boost => include}/network/utils/thread_pool.ipp | 0 {boost => include}/network/version.hpp | 0 191 files changed, 0 insertions(+), 0 deletions(-) rename {boost => include}/network.hpp (100%) rename {boost => include}/network/constants.hpp (100%) rename {boost => include}/network/constants.ipp (100%) rename {boost => include}/network/detail/debug.hpp (100%) rename {boost => include}/network/detail/directive_base.hpp (100%) rename {boost => include}/network/detail/wrapper_base.hpp (100%) rename {boost => include}/network/include/http/client.hpp (100%) rename {boost => include}/network/include/http/server.hpp (100%) rename {boost => include}/network/include/message.hpp (100%) rename {boost => include}/network/message.hpp (100%) rename {boost => include}/network/message/basic_message.hpp (100%) rename {boost => include}/network/message/basic_message.ipp (100%) rename {boost => include}/network/message/directives.hpp (100%) rename {boost => include}/network/message/directives/detail/string_directive.hpp (100%) rename {boost => include}/network/message/directives/detail/string_value.hpp (100%) rename {boost => include}/network/message/directives/header.hpp (100%) rename {boost => include}/network/message/directives/header.ipp (100%) rename {boost => include}/network/message/directives/remove_header.hpp (100%) rename {boost => include}/network/message/directives/remove_header.ipp (100%) rename {boost => include}/network/message/message.hpp (100%) rename {boost => include}/network/message/message.ipp (100%) rename {boost => include}/network/message/message_base.hpp (100%) rename {boost => include}/network/message/message_base.ipp (100%) rename {boost => include}/network/message/message_concept.hpp (100%) rename {boost => include}/network/message/modifiers.hpp (100%) rename {boost => include}/network/message/modifiers/add_header.hpp (100%) rename {boost => include}/network/message/modifiers/body.hpp (100%) rename {boost => include}/network/message/modifiers/clear_headers.hpp (100%) rename {boost => include}/network/message/modifiers/destination.hpp (100%) rename {boost => include}/network/message/modifiers/remove_header.hpp (100%) rename {boost => include}/network/message/modifiers/source.hpp (100%) rename {boost => include}/network/message/transformers.hpp (100%) rename {boost => include}/network/message/transformers/selectors.hpp (100%) rename {boost => include}/network/message/transformers/to_lower.hpp (100%) rename {boost => include}/network/message/transformers/to_upper.hpp (100%) rename {boost => include}/network/message/wrappers.hpp (100%) rename {boost => include}/network/message/wrappers/body.hpp (100%) rename {boost => include}/network/message/wrappers/body.ipp (100%) rename {boost => include}/network/message/wrappers/destination.hpp (100%) rename {boost => include}/network/message/wrappers/destination.ipp (100%) rename {boost => include}/network/message/wrappers/headers.hpp (100%) rename {boost => include}/network/message/wrappers/headers.ipp (100%) rename {boost => include}/network/message/wrappers/source.hpp (100%) rename {boost => include}/network/message/wrappers/source.ipp (100%) rename {boost => include}/network/message_fwd.hpp (100%) rename {boost => include}/network/protocol.hpp (100%) rename {boost => include}/network/protocol/http.hpp (100%) rename {boost => include}/network/protocol/http/algorithms/linearize.hpp (100%) rename {boost => include}/network/protocol/http/client.hpp (100%) rename {boost => include}/network/protocol/http/client.ipp (100%) rename {boost => include}/network/protocol/http/client/base.hpp (100%) rename {boost => include}/network/protocol/http/client/base.ipp (100%) rename {boost => include}/network/protocol/http/client/client_connection.hpp (100%) rename {boost => include}/network/protocol/http/client/client_connection.ipp (100%) rename {boost => include}/network/protocol/http/client/connection/async_normal.hpp (100%) rename {boost => include}/network/protocol/http/client/connection/async_normal.ipp (100%) rename {boost => include}/network/protocol/http/client/connection/async_protocol_handler.hpp (100%) rename {boost => include}/network/protocol/http/client/connection/async_resolver.hpp (100%) rename {boost => include}/network/protocol/http/client/connection/async_resolver.ipp (100%) rename {boost => include}/network/protocol/http/client/connection/connection_delegate.hpp (100%) rename {boost => include}/network/protocol/http/client/connection/connection_delegate_factory.hpp (100%) rename {boost => include}/network/protocol/http/client/connection/connection_delegate_factory.ipp (100%) rename {boost => include}/network/protocol/http/client/connection/connection_factory.hpp (100%) rename {boost => include}/network/protocol/http/client/connection/connection_factory.ipp (100%) rename {boost => include}/network/protocol/http/client/connection/normal_delegate.hpp (100%) rename {boost => include}/network/protocol/http/client/connection/normal_delegate.ipp (100%) rename {boost => include}/network/protocol/http/client/connection/resolver_delegate.hpp (100%) rename {boost => include}/network/protocol/http/client/connection/resolver_delegate.ipp (100%) rename {boost => include}/network/protocol/http/client/connection/resolver_delegate_factory.hpp (100%) rename {boost => include}/network/protocol/http/client/connection/resolver_delegate_factory.ipp (100%) rename {boost => include}/network/protocol/http/client/connection/simple_connection_factory.hpp (100%) rename {boost => include}/network/protocol/http/client/connection/simple_connection_factory.ipp (100%) rename {boost => include}/network/protocol/http/client/connection/ssl_delegate.hpp (100%) rename {boost => include}/network/protocol/http/client/connection/ssl_delegate.ipp (100%) rename {boost => include}/network/protocol/http/client/connection/sync_base.hpp (100%) rename {boost => include}/network/protocol/http/client/connection/sync_normal.hpp (100%) rename {boost => include}/network/protocol/http/client/connection/sync_ssl.hpp (100%) rename {boost => include}/network/protocol/http/client/connection_manager.hpp (100%) rename {boost => include}/network/protocol/http/client/connection_manager.ipp (100%) rename {boost => include}/network/protocol/http/client/facade.hpp (100%) rename {boost => include}/network/protocol/http/client/facade.ipp (100%) rename {boost => include}/network/protocol/http/client/macros.hpp (100%) rename {boost => include}/network/protocol/http/client/options.hpp (100%) rename {boost => include}/network/protocol/http/client/options.ipp (100%) rename {boost => include}/network/protocol/http/client/parameters.hpp (100%) rename {boost => include}/network/protocol/http/client/pimpl.hpp (100%) rename {boost => include}/network/protocol/http/client/simple_connection_manager.hpp (100%) rename {boost => include}/network/protocol/http/client/simple_connection_manager.ipp (100%) rename {boost => include}/network/protocol/http/client/sync_impl.hpp (100%) rename {boost => include}/network/protocol/http/client_fwd.hpp (100%) rename {boost => include}/network/protocol/http/errors.hpp (100%) rename {boost => include}/network/protocol/http/impl/access.hpp (100%) rename {boost => include}/network/protocol/http/impl/access.ipp (100%) rename {boost => include}/network/protocol/http/impl/message.ipp (100%) rename {boost => include}/network/protocol/http/impl/parser.ipp (100%) rename {boost => include}/network/protocol/http/impl/request.hpp (100%) rename {boost => include}/network/protocol/http/impl/request_parser.ipp (100%) rename {boost => include}/network/protocol/http/impl/response.ipp (100%) rename {boost => include}/network/protocol/http/message/async_message.hpp (100%) rename {boost => include}/network/protocol/http/message/directives.hpp (100%) rename {boost => include}/network/protocol/http/message/directives/major_version.hpp (100%) rename {boost => include}/network/protocol/http/message/directives/method.hpp (100%) rename {boost => include}/network/protocol/http/message/directives/minor_version.hpp (100%) rename {boost => include}/network/protocol/http/message/directives/status.hpp (100%) rename {boost => include}/network/protocol/http/message/directives/status_message.hpp (100%) rename {boost => include}/network/protocol/http/message/directives/uri.hpp (100%) rename {boost => include}/network/protocol/http/message/directives/version.hpp (100%) rename {boost => include}/network/protocol/http/message/header.hpp (100%) rename {boost => include}/network/protocol/http/message/header/name.hpp (100%) rename {boost => include}/network/protocol/http/message/header/value.hpp (100%) rename {boost => include}/network/protocol/http/message/header_concept.hpp (100%) rename {boost => include}/network/protocol/http/message/modifiers.hpp (100%) rename {boost => include}/network/protocol/http/message/modifiers/major_version.hpp (100%) rename {boost => include}/network/protocol/http/message/modifiers/method.hpp (100%) rename {boost => include}/network/protocol/http/message/modifiers/minor_version.hpp (100%) rename {boost => include}/network/protocol/http/message/modifiers/status.hpp (100%) rename {boost => include}/network/protocol/http/message/modifiers/status_message.hpp (100%) rename {boost => include}/network/protocol/http/message/modifiers/uri.hpp (100%) rename {boost => include}/network/protocol/http/message/modifiers/version.hpp (100%) rename {boost => include}/network/protocol/http/message/wrappers.hpp (100%) rename {boost => include}/network/protocol/http/message/wrappers/anchor.hpp (100%) rename {boost => include}/network/protocol/http/message/wrappers/anchor.ipp (100%) rename {boost => include}/network/protocol/http/message/wrappers/helper.hpp (100%) rename {boost => include}/network/protocol/http/message/wrappers/host.hpp (100%) rename {boost => include}/network/protocol/http/message/wrappers/host.ipp (100%) rename {boost => include}/network/protocol/http/message/wrappers/major_version.hpp (100%) rename {boost => include}/network/protocol/http/message/wrappers/method.hpp (100%) rename {boost => include}/network/protocol/http/message/wrappers/minor_version.hpp (100%) rename {boost => include}/network/protocol/http/message/wrappers/path.hpp (100%) rename {boost => include}/network/protocol/http/message/wrappers/path.ipp (100%) rename {boost => include}/network/protocol/http/message/wrappers/port.hpp (100%) rename {boost => include}/network/protocol/http/message/wrappers/port.ipp (100%) rename {boost => include}/network/protocol/http/message/wrappers/protocol.hpp (100%) rename {boost => include}/network/protocol/http/message/wrappers/query.hpp (100%) rename {boost => include}/network/protocol/http/message/wrappers/query.ipp (100%) rename {boost => include}/network/protocol/http/message/wrappers/ready.hpp (100%) rename {boost => include}/network/protocol/http/message/wrappers/status.hpp (100%) rename {boost => include}/network/protocol/http/message/wrappers/status.ipp (100%) rename {boost => include}/network/protocol/http/message/wrappers/status_message.hpp (100%) rename {boost => include}/network/protocol/http/message/wrappers/status_message.ipp (100%) rename {boost => include}/network/protocol/http/message/wrappers/uri.hpp (100%) rename {boost => include}/network/protocol/http/message/wrappers/uri.ipp (100%) rename {boost => include}/network/protocol/http/message/wrappers/version.hpp (100%) rename {boost => include}/network/protocol/http/message/wrappers/version.ipp (100%) rename {boost => include}/network/protocol/http/parser.hpp (100%) rename {boost => include}/network/protocol/http/parser/incremental.hpp (100%) rename {boost => include}/network/protocol/http/policies/async_connection.hpp (100%) rename {boost => include}/network/protocol/http/policies/async_connection.ipp (100%) rename {boost => include}/network/protocol/http/request.hpp (100%) rename {boost => include}/network/protocol/http/request/request.hpp (100%) rename {boost => include}/network/protocol/http/request/request.ipp (100%) rename {boost => include}/network/protocol/http/request/request_base.hpp (100%) rename {boost => include}/network/protocol/http/request/request_base.ipp (100%) rename {boost => include}/network/protocol/http/request/request_concept.hpp (100%) rename {boost => include}/network/protocol/http/request_parser.hpp (100%) rename {boost => include}/network/protocol/http/response.hpp (100%) rename {boost => include}/network/protocol/http/response/response.hpp (100%) rename {boost => include}/network/protocol/http/response/response.ipp (100%) rename {boost => include}/network/protocol/http/response/response_base.hpp (100%) rename {boost => include}/network/protocol/http/response/response_base.ipp (100%) rename {boost => include}/network/protocol/http/response/response_concept.hpp (100%) rename {boost => include}/network/protocol/http/server.hpp (100%) rename {boost => include}/network/protocol/http/server/async_impl.hpp (100%) rename {boost => include}/network/protocol/http/server/async_impl.ipp (100%) rename {boost => include}/network/protocol/http/server/async_server.hpp (100%) rename {boost => include}/network/protocol/http/server/connection/async.hpp (100%) rename {boost => include}/network/protocol/http/server/connection/sync.hpp (100%) rename {boost => include}/network/protocol/http/server/impl/parsers.ipp (100%) rename {boost => include}/network/protocol/http/server/impl/socket_options_setter.hpp (100%) rename {boost => include}/network/protocol/http/server/impl/socket_options_setter.ipp (100%) rename {boost => include}/network/protocol/http/server/options.hpp (100%) rename {boost => include}/network/protocol/http/server/options.ipp (100%) rename {boost => include}/network/protocol/http/server/parameters.hpp (100%) rename {boost => include}/network/protocol/http/server/request.hpp (100%) rename {boost => include}/network/protocol/http/server/request_parser.hpp (100%) rename {boost => include}/network/protocol/http/server/server.ipp (100%) rename {boost => include}/network/protocol/http/server/socket_options_base.hpp (100%) rename {boost => include}/network/protocol/http/server/storage_base.hpp (100%) rename {boost => include}/network/protocol/http/server/sync_impl.hpp (100%) rename {boost => include}/network/protocol/http/server/sync_impl.ipp (100%) rename {boost => include}/network/protocol/http/server/sync_server.hpp (100%) rename {boost => include}/network/protocol/http/support/client_or_server.hpp (100%) rename {boost => include}/network/protocol/http/support/is_client.hpp (100%) rename {boost => include}/network/protocol/http/support/is_http.hpp (100%) rename {boost => include}/network/protocol/http/support/is_keepalive.hpp (100%) rename {boost => include}/network/protocol/http/support/is_server.hpp (100%) rename {boost => include}/network/protocol/http/support/is_simple.hpp (100%) rename {boost => include}/network/protocol/http/support/sync_only.hpp (100%) rename {boost => include}/network/utils/thread_pool.hpp (100%) rename {boost => include}/network/utils/thread_pool.ipp (100%) rename {boost => include}/network/version.hpp (100%) diff --git a/boost/network.hpp b/include/network.hpp similarity index 100% rename from boost/network.hpp rename to include/network.hpp diff --git a/boost/network/constants.hpp b/include/network/constants.hpp similarity index 100% rename from boost/network/constants.hpp rename to include/network/constants.hpp diff --git a/boost/network/constants.ipp b/include/network/constants.ipp similarity index 100% rename from boost/network/constants.ipp rename to include/network/constants.ipp diff --git a/boost/network/detail/debug.hpp b/include/network/detail/debug.hpp similarity index 100% rename from boost/network/detail/debug.hpp rename to include/network/detail/debug.hpp diff --git a/boost/network/detail/directive_base.hpp b/include/network/detail/directive_base.hpp similarity index 100% rename from boost/network/detail/directive_base.hpp rename to include/network/detail/directive_base.hpp diff --git a/boost/network/detail/wrapper_base.hpp b/include/network/detail/wrapper_base.hpp similarity index 100% rename from boost/network/detail/wrapper_base.hpp rename to include/network/detail/wrapper_base.hpp diff --git a/boost/network/include/http/client.hpp b/include/network/include/http/client.hpp similarity index 100% rename from boost/network/include/http/client.hpp rename to include/network/include/http/client.hpp diff --git a/boost/network/include/http/server.hpp b/include/network/include/http/server.hpp similarity index 100% rename from boost/network/include/http/server.hpp rename to include/network/include/http/server.hpp diff --git a/boost/network/include/message.hpp b/include/network/include/message.hpp similarity index 100% rename from boost/network/include/message.hpp rename to include/network/include/message.hpp diff --git a/boost/network/message.hpp b/include/network/message.hpp similarity index 100% rename from boost/network/message.hpp rename to include/network/message.hpp diff --git a/boost/network/message/basic_message.hpp b/include/network/message/basic_message.hpp similarity index 100% rename from boost/network/message/basic_message.hpp rename to include/network/message/basic_message.hpp diff --git a/boost/network/message/basic_message.ipp b/include/network/message/basic_message.ipp similarity index 100% rename from boost/network/message/basic_message.ipp rename to include/network/message/basic_message.ipp diff --git a/boost/network/message/directives.hpp b/include/network/message/directives.hpp similarity index 100% rename from boost/network/message/directives.hpp rename to include/network/message/directives.hpp diff --git a/boost/network/message/directives/detail/string_directive.hpp b/include/network/message/directives/detail/string_directive.hpp similarity index 100% rename from boost/network/message/directives/detail/string_directive.hpp rename to include/network/message/directives/detail/string_directive.hpp diff --git a/boost/network/message/directives/detail/string_value.hpp b/include/network/message/directives/detail/string_value.hpp similarity index 100% rename from boost/network/message/directives/detail/string_value.hpp rename to include/network/message/directives/detail/string_value.hpp diff --git a/boost/network/message/directives/header.hpp b/include/network/message/directives/header.hpp similarity index 100% rename from boost/network/message/directives/header.hpp rename to include/network/message/directives/header.hpp diff --git a/boost/network/message/directives/header.ipp b/include/network/message/directives/header.ipp similarity index 100% rename from boost/network/message/directives/header.ipp rename to include/network/message/directives/header.ipp diff --git a/boost/network/message/directives/remove_header.hpp b/include/network/message/directives/remove_header.hpp similarity index 100% rename from boost/network/message/directives/remove_header.hpp rename to include/network/message/directives/remove_header.hpp diff --git a/boost/network/message/directives/remove_header.ipp b/include/network/message/directives/remove_header.ipp similarity index 100% rename from boost/network/message/directives/remove_header.ipp rename to include/network/message/directives/remove_header.ipp diff --git a/boost/network/message/message.hpp b/include/network/message/message.hpp similarity index 100% rename from boost/network/message/message.hpp rename to include/network/message/message.hpp diff --git a/boost/network/message/message.ipp b/include/network/message/message.ipp similarity index 100% rename from boost/network/message/message.ipp rename to include/network/message/message.ipp diff --git a/boost/network/message/message_base.hpp b/include/network/message/message_base.hpp similarity index 100% rename from boost/network/message/message_base.hpp rename to include/network/message/message_base.hpp diff --git a/boost/network/message/message_base.ipp b/include/network/message/message_base.ipp similarity index 100% rename from boost/network/message/message_base.ipp rename to include/network/message/message_base.ipp diff --git a/boost/network/message/message_concept.hpp b/include/network/message/message_concept.hpp similarity index 100% rename from boost/network/message/message_concept.hpp rename to include/network/message/message_concept.hpp diff --git a/boost/network/message/modifiers.hpp b/include/network/message/modifiers.hpp similarity index 100% rename from boost/network/message/modifiers.hpp rename to include/network/message/modifiers.hpp diff --git a/boost/network/message/modifiers/add_header.hpp b/include/network/message/modifiers/add_header.hpp similarity index 100% rename from boost/network/message/modifiers/add_header.hpp rename to include/network/message/modifiers/add_header.hpp diff --git a/boost/network/message/modifiers/body.hpp b/include/network/message/modifiers/body.hpp similarity index 100% rename from boost/network/message/modifiers/body.hpp rename to include/network/message/modifiers/body.hpp diff --git a/boost/network/message/modifiers/clear_headers.hpp b/include/network/message/modifiers/clear_headers.hpp similarity index 100% rename from boost/network/message/modifiers/clear_headers.hpp rename to include/network/message/modifiers/clear_headers.hpp diff --git a/boost/network/message/modifiers/destination.hpp b/include/network/message/modifiers/destination.hpp similarity index 100% rename from boost/network/message/modifiers/destination.hpp rename to include/network/message/modifiers/destination.hpp diff --git a/boost/network/message/modifiers/remove_header.hpp b/include/network/message/modifiers/remove_header.hpp similarity index 100% rename from boost/network/message/modifiers/remove_header.hpp rename to include/network/message/modifiers/remove_header.hpp diff --git a/boost/network/message/modifiers/source.hpp b/include/network/message/modifiers/source.hpp similarity index 100% rename from boost/network/message/modifiers/source.hpp rename to include/network/message/modifiers/source.hpp diff --git a/boost/network/message/transformers.hpp b/include/network/message/transformers.hpp similarity index 100% rename from boost/network/message/transformers.hpp rename to include/network/message/transformers.hpp diff --git a/boost/network/message/transformers/selectors.hpp b/include/network/message/transformers/selectors.hpp similarity index 100% rename from boost/network/message/transformers/selectors.hpp rename to include/network/message/transformers/selectors.hpp diff --git a/boost/network/message/transformers/to_lower.hpp b/include/network/message/transformers/to_lower.hpp similarity index 100% rename from boost/network/message/transformers/to_lower.hpp rename to include/network/message/transformers/to_lower.hpp diff --git a/boost/network/message/transformers/to_upper.hpp b/include/network/message/transformers/to_upper.hpp similarity index 100% rename from boost/network/message/transformers/to_upper.hpp rename to include/network/message/transformers/to_upper.hpp diff --git a/boost/network/message/wrappers.hpp b/include/network/message/wrappers.hpp similarity index 100% rename from boost/network/message/wrappers.hpp rename to include/network/message/wrappers.hpp diff --git a/boost/network/message/wrappers/body.hpp b/include/network/message/wrappers/body.hpp similarity index 100% rename from boost/network/message/wrappers/body.hpp rename to include/network/message/wrappers/body.hpp diff --git a/boost/network/message/wrappers/body.ipp b/include/network/message/wrappers/body.ipp similarity index 100% rename from boost/network/message/wrappers/body.ipp rename to include/network/message/wrappers/body.ipp diff --git a/boost/network/message/wrappers/destination.hpp b/include/network/message/wrappers/destination.hpp similarity index 100% rename from boost/network/message/wrappers/destination.hpp rename to include/network/message/wrappers/destination.hpp diff --git a/boost/network/message/wrappers/destination.ipp b/include/network/message/wrappers/destination.ipp similarity index 100% rename from boost/network/message/wrappers/destination.ipp rename to include/network/message/wrappers/destination.ipp diff --git a/boost/network/message/wrappers/headers.hpp b/include/network/message/wrappers/headers.hpp similarity index 100% rename from boost/network/message/wrappers/headers.hpp rename to include/network/message/wrappers/headers.hpp diff --git a/boost/network/message/wrappers/headers.ipp b/include/network/message/wrappers/headers.ipp similarity index 100% rename from boost/network/message/wrappers/headers.ipp rename to include/network/message/wrappers/headers.ipp diff --git a/boost/network/message/wrappers/source.hpp b/include/network/message/wrappers/source.hpp similarity index 100% rename from boost/network/message/wrappers/source.hpp rename to include/network/message/wrappers/source.hpp diff --git a/boost/network/message/wrappers/source.ipp b/include/network/message/wrappers/source.ipp similarity index 100% rename from boost/network/message/wrappers/source.ipp rename to include/network/message/wrappers/source.ipp diff --git a/boost/network/message_fwd.hpp b/include/network/message_fwd.hpp similarity index 100% rename from boost/network/message_fwd.hpp rename to include/network/message_fwd.hpp diff --git a/boost/network/protocol.hpp b/include/network/protocol.hpp similarity index 100% rename from boost/network/protocol.hpp rename to include/network/protocol.hpp diff --git a/boost/network/protocol/http.hpp b/include/network/protocol/http.hpp similarity index 100% rename from boost/network/protocol/http.hpp rename to include/network/protocol/http.hpp diff --git a/boost/network/protocol/http/algorithms/linearize.hpp b/include/network/protocol/http/algorithms/linearize.hpp similarity index 100% rename from boost/network/protocol/http/algorithms/linearize.hpp rename to include/network/protocol/http/algorithms/linearize.hpp diff --git a/boost/network/protocol/http/client.hpp b/include/network/protocol/http/client.hpp similarity index 100% rename from boost/network/protocol/http/client.hpp rename to include/network/protocol/http/client.hpp diff --git a/boost/network/protocol/http/client.ipp b/include/network/protocol/http/client.ipp similarity index 100% rename from boost/network/protocol/http/client.ipp rename to include/network/protocol/http/client.ipp diff --git a/boost/network/protocol/http/client/base.hpp b/include/network/protocol/http/client/base.hpp similarity index 100% rename from boost/network/protocol/http/client/base.hpp rename to include/network/protocol/http/client/base.hpp diff --git a/boost/network/protocol/http/client/base.ipp b/include/network/protocol/http/client/base.ipp similarity index 100% rename from boost/network/protocol/http/client/base.ipp rename to include/network/protocol/http/client/base.ipp diff --git a/boost/network/protocol/http/client/client_connection.hpp b/include/network/protocol/http/client/client_connection.hpp similarity index 100% rename from boost/network/protocol/http/client/client_connection.hpp rename to include/network/protocol/http/client/client_connection.hpp diff --git a/boost/network/protocol/http/client/client_connection.ipp b/include/network/protocol/http/client/client_connection.ipp similarity index 100% rename from boost/network/protocol/http/client/client_connection.ipp rename to include/network/protocol/http/client/client_connection.ipp diff --git a/boost/network/protocol/http/client/connection/async_normal.hpp b/include/network/protocol/http/client/connection/async_normal.hpp similarity index 100% rename from boost/network/protocol/http/client/connection/async_normal.hpp rename to include/network/protocol/http/client/connection/async_normal.hpp diff --git a/boost/network/protocol/http/client/connection/async_normal.ipp b/include/network/protocol/http/client/connection/async_normal.ipp similarity index 100% rename from boost/network/protocol/http/client/connection/async_normal.ipp rename to include/network/protocol/http/client/connection/async_normal.ipp diff --git a/boost/network/protocol/http/client/connection/async_protocol_handler.hpp b/include/network/protocol/http/client/connection/async_protocol_handler.hpp similarity index 100% rename from boost/network/protocol/http/client/connection/async_protocol_handler.hpp rename to include/network/protocol/http/client/connection/async_protocol_handler.hpp diff --git a/boost/network/protocol/http/client/connection/async_resolver.hpp b/include/network/protocol/http/client/connection/async_resolver.hpp similarity index 100% rename from boost/network/protocol/http/client/connection/async_resolver.hpp rename to include/network/protocol/http/client/connection/async_resolver.hpp diff --git a/boost/network/protocol/http/client/connection/async_resolver.ipp b/include/network/protocol/http/client/connection/async_resolver.ipp similarity index 100% rename from boost/network/protocol/http/client/connection/async_resolver.ipp rename to include/network/protocol/http/client/connection/async_resolver.ipp diff --git a/boost/network/protocol/http/client/connection/connection_delegate.hpp b/include/network/protocol/http/client/connection/connection_delegate.hpp similarity index 100% rename from boost/network/protocol/http/client/connection/connection_delegate.hpp rename to include/network/protocol/http/client/connection/connection_delegate.hpp diff --git a/boost/network/protocol/http/client/connection/connection_delegate_factory.hpp b/include/network/protocol/http/client/connection/connection_delegate_factory.hpp similarity index 100% rename from boost/network/protocol/http/client/connection/connection_delegate_factory.hpp rename to include/network/protocol/http/client/connection/connection_delegate_factory.hpp diff --git a/boost/network/protocol/http/client/connection/connection_delegate_factory.ipp b/include/network/protocol/http/client/connection/connection_delegate_factory.ipp similarity index 100% rename from boost/network/protocol/http/client/connection/connection_delegate_factory.ipp rename to include/network/protocol/http/client/connection/connection_delegate_factory.ipp diff --git a/boost/network/protocol/http/client/connection/connection_factory.hpp b/include/network/protocol/http/client/connection/connection_factory.hpp similarity index 100% rename from boost/network/protocol/http/client/connection/connection_factory.hpp rename to include/network/protocol/http/client/connection/connection_factory.hpp diff --git a/boost/network/protocol/http/client/connection/connection_factory.ipp b/include/network/protocol/http/client/connection/connection_factory.ipp similarity index 100% rename from boost/network/protocol/http/client/connection/connection_factory.ipp rename to include/network/protocol/http/client/connection/connection_factory.ipp diff --git a/boost/network/protocol/http/client/connection/normal_delegate.hpp b/include/network/protocol/http/client/connection/normal_delegate.hpp similarity index 100% rename from boost/network/protocol/http/client/connection/normal_delegate.hpp rename to include/network/protocol/http/client/connection/normal_delegate.hpp diff --git a/boost/network/protocol/http/client/connection/normal_delegate.ipp b/include/network/protocol/http/client/connection/normal_delegate.ipp similarity index 100% rename from boost/network/protocol/http/client/connection/normal_delegate.ipp rename to include/network/protocol/http/client/connection/normal_delegate.ipp diff --git a/boost/network/protocol/http/client/connection/resolver_delegate.hpp b/include/network/protocol/http/client/connection/resolver_delegate.hpp similarity index 100% rename from boost/network/protocol/http/client/connection/resolver_delegate.hpp rename to include/network/protocol/http/client/connection/resolver_delegate.hpp diff --git a/boost/network/protocol/http/client/connection/resolver_delegate.ipp b/include/network/protocol/http/client/connection/resolver_delegate.ipp similarity index 100% rename from boost/network/protocol/http/client/connection/resolver_delegate.ipp rename to include/network/protocol/http/client/connection/resolver_delegate.ipp diff --git a/boost/network/protocol/http/client/connection/resolver_delegate_factory.hpp b/include/network/protocol/http/client/connection/resolver_delegate_factory.hpp similarity index 100% rename from boost/network/protocol/http/client/connection/resolver_delegate_factory.hpp rename to include/network/protocol/http/client/connection/resolver_delegate_factory.hpp diff --git a/boost/network/protocol/http/client/connection/resolver_delegate_factory.ipp b/include/network/protocol/http/client/connection/resolver_delegate_factory.ipp similarity index 100% rename from boost/network/protocol/http/client/connection/resolver_delegate_factory.ipp rename to include/network/protocol/http/client/connection/resolver_delegate_factory.ipp diff --git a/boost/network/protocol/http/client/connection/simple_connection_factory.hpp b/include/network/protocol/http/client/connection/simple_connection_factory.hpp similarity index 100% rename from boost/network/protocol/http/client/connection/simple_connection_factory.hpp rename to include/network/protocol/http/client/connection/simple_connection_factory.hpp diff --git a/boost/network/protocol/http/client/connection/simple_connection_factory.ipp b/include/network/protocol/http/client/connection/simple_connection_factory.ipp similarity index 100% rename from boost/network/protocol/http/client/connection/simple_connection_factory.ipp rename to include/network/protocol/http/client/connection/simple_connection_factory.ipp diff --git a/boost/network/protocol/http/client/connection/ssl_delegate.hpp b/include/network/protocol/http/client/connection/ssl_delegate.hpp similarity index 100% rename from boost/network/protocol/http/client/connection/ssl_delegate.hpp rename to include/network/protocol/http/client/connection/ssl_delegate.hpp diff --git a/boost/network/protocol/http/client/connection/ssl_delegate.ipp b/include/network/protocol/http/client/connection/ssl_delegate.ipp similarity index 100% rename from boost/network/protocol/http/client/connection/ssl_delegate.ipp rename to include/network/protocol/http/client/connection/ssl_delegate.ipp diff --git a/boost/network/protocol/http/client/connection/sync_base.hpp b/include/network/protocol/http/client/connection/sync_base.hpp similarity index 100% rename from boost/network/protocol/http/client/connection/sync_base.hpp rename to include/network/protocol/http/client/connection/sync_base.hpp diff --git a/boost/network/protocol/http/client/connection/sync_normal.hpp b/include/network/protocol/http/client/connection/sync_normal.hpp similarity index 100% rename from boost/network/protocol/http/client/connection/sync_normal.hpp rename to include/network/protocol/http/client/connection/sync_normal.hpp diff --git a/boost/network/protocol/http/client/connection/sync_ssl.hpp b/include/network/protocol/http/client/connection/sync_ssl.hpp similarity index 100% rename from boost/network/protocol/http/client/connection/sync_ssl.hpp rename to include/network/protocol/http/client/connection/sync_ssl.hpp diff --git a/boost/network/protocol/http/client/connection_manager.hpp b/include/network/protocol/http/client/connection_manager.hpp similarity index 100% rename from boost/network/protocol/http/client/connection_manager.hpp rename to include/network/protocol/http/client/connection_manager.hpp diff --git a/boost/network/protocol/http/client/connection_manager.ipp b/include/network/protocol/http/client/connection_manager.ipp similarity index 100% rename from boost/network/protocol/http/client/connection_manager.ipp rename to include/network/protocol/http/client/connection_manager.ipp diff --git a/boost/network/protocol/http/client/facade.hpp b/include/network/protocol/http/client/facade.hpp similarity index 100% rename from boost/network/protocol/http/client/facade.hpp rename to include/network/protocol/http/client/facade.hpp diff --git a/boost/network/protocol/http/client/facade.ipp b/include/network/protocol/http/client/facade.ipp similarity index 100% rename from boost/network/protocol/http/client/facade.ipp rename to include/network/protocol/http/client/facade.ipp diff --git a/boost/network/protocol/http/client/macros.hpp b/include/network/protocol/http/client/macros.hpp similarity index 100% rename from boost/network/protocol/http/client/macros.hpp rename to include/network/protocol/http/client/macros.hpp diff --git a/boost/network/protocol/http/client/options.hpp b/include/network/protocol/http/client/options.hpp similarity index 100% rename from boost/network/protocol/http/client/options.hpp rename to include/network/protocol/http/client/options.hpp diff --git a/boost/network/protocol/http/client/options.ipp b/include/network/protocol/http/client/options.ipp similarity index 100% rename from boost/network/protocol/http/client/options.ipp rename to include/network/protocol/http/client/options.ipp diff --git a/boost/network/protocol/http/client/parameters.hpp b/include/network/protocol/http/client/parameters.hpp similarity index 100% rename from boost/network/protocol/http/client/parameters.hpp rename to include/network/protocol/http/client/parameters.hpp diff --git a/boost/network/protocol/http/client/pimpl.hpp b/include/network/protocol/http/client/pimpl.hpp similarity index 100% rename from boost/network/protocol/http/client/pimpl.hpp rename to include/network/protocol/http/client/pimpl.hpp diff --git a/boost/network/protocol/http/client/simple_connection_manager.hpp b/include/network/protocol/http/client/simple_connection_manager.hpp similarity index 100% rename from boost/network/protocol/http/client/simple_connection_manager.hpp rename to include/network/protocol/http/client/simple_connection_manager.hpp diff --git a/boost/network/protocol/http/client/simple_connection_manager.ipp b/include/network/protocol/http/client/simple_connection_manager.ipp similarity index 100% rename from boost/network/protocol/http/client/simple_connection_manager.ipp rename to include/network/protocol/http/client/simple_connection_manager.ipp diff --git a/boost/network/protocol/http/client/sync_impl.hpp b/include/network/protocol/http/client/sync_impl.hpp similarity index 100% rename from boost/network/protocol/http/client/sync_impl.hpp rename to include/network/protocol/http/client/sync_impl.hpp diff --git a/boost/network/protocol/http/client_fwd.hpp b/include/network/protocol/http/client_fwd.hpp similarity index 100% rename from boost/network/protocol/http/client_fwd.hpp rename to include/network/protocol/http/client_fwd.hpp diff --git a/boost/network/protocol/http/errors.hpp b/include/network/protocol/http/errors.hpp similarity index 100% rename from boost/network/protocol/http/errors.hpp rename to include/network/protocol/http/errors.hpp diff --git a/boost/network/protocol/http/impl/access.hpp b/include/network/protocol/http/impl/access.hpp similarity index 100% rename from boost/network/protocol/http/impl/access.hpp rename to include/network/protocol/http/impl/access.hpp diff --git a/boost/network/protocol/http/impl/access.ipp b/include/network/protocol/http/impl/access.ipp similarity index 100% rename from boost/network/protocol/http/impl/access.ipp rename to include/network/protocol/http/impl/access.ipp diff --git a/boost/network/protocol/http/impl/message.ipp b/include/network/protocol/http/impl/message.ipp similarity index 100% rename from boost/network/protocol/http/impl/message.ipp rename to include/network/protocol/http/impl/message.ipp diff --git a/boost/network/protocol/http/impl/parser.ipp b/include/network/protocol/http/impl/parser.ipp similarity index 100% rename from boost/network/protocol/http/impl/parser.ipp rename to include/network/protocol/http/impl/parser.ipp diff --git a/boost/network/protocol/http/impl/request.hpp b/include/network/protocol/http/impl/request.hpp similarity index 100% rename from boost/network/protocol/http/impl/request.hpp rename to include/network/protocol/http/impl/request.hpp diff --git a/boost/network/protocol/http/impl/request_parser.ipp b/include/network/protocol/http/impl/request_parser.ipp similarity index 100% rename from boost/network/protocol/http/impl/request_parser.ipp rename to include/network/protocol/http/impl/request_parser.ipp diff --git a/boost/network/protocol/http/impl/response.ipp b/include/network/protocol/http/impl/response.ipp similarity index 100% rename from boost/network/protocol/http/impl/response.ipp rename to include/network/protocol/http/impl/response.ipp diff --git a/boost/network/protocol/http/message/async_message.hpp b/include/network/protocol/http/message/async_message.hpp similarity index 100% rename from boost/network/protocol/http/message/async_message.hpp rename to include/network/protocol/http/message/async_message.hpp diff --git a/boost/network/protocol/http/message/directives.hpp b/include/network/protocol/http/message/directives.hpp similarity index 100% rename from boost/network/protocol/http/message/directives.hpp rename to include/network/protocol/http/message/directives.hpp diff --git a/boost/network/protocol/http/message/directives/major_version.hpp b/include/network/protocol/http/message/directives/major_version.hpp similarity index 100% rename from boost/network/protocol/http/message/directives/major_version.hpp rename to include/network/protocol/http/message/directives/major_version.hpp diff --git a/boost/network/protocol/http/message/directives/method.hpp b/include/network/protocol/http/message/directives/method.hpp similarity index 100% rename from boost/network/protocol/http/message/directives/method.hpp rename to include/network/protocol/http/message/directives/method.hpp diff --git a/boost/network/protocol/http/message/directives/minor_version.hpp b/include/network/protocol/http/message/directives/minor_version.hpp similarity index 100% rename from boost/network/protocol/http/message/directives/minor_version.hpp rename to include/network/protocol/http/message/directives/minor_version.hpp diff --git a/boost/network/protocol/http/message/directives/status.hpp b/include/network/protocol/http/message/directives/status.hpp similarity index 100% rename from boost/network/protocol/http/message/directives/status.hpp rename to include/network/protocol/http/message/directives/status.hpp diff --git a/boost/network/protocol/http/message/directives/status_message.hpp b/include/network/protocol/http/message/directives/status_message.hpp similarity index 100% rename from boost/network/protocol/http/message/directives/status_message.hpp rename to include/network/protocol/http/message/directives/status_message.hpp diff --git a/boost/network/protocol/http/message/directives/uri.hpp b/include/network/protocol/http/message/directives/uri.hpp similarity index 100% rename from boost/network/protocol/http/message/directives/uri.hpp rename to include/network/protocol/http/message/directives/uri.hpp diff --git a/boost/network/protocol/http/message/directives/version.hpp b/include/network/protocol/http/message/directives/version.hpp similarity index 100% rename from boost/network/protocol/http/message/directives/version.hpp rename to include/network/protocol/http/message/directives/version.hpp diff --git a/boost/network/protocol/http/message/header.hpp b/include/network/protocol/http/message/header.hpp similarity index 100% rename from boost/network/protocol/http/message/header.hpp rename to include/network/protocol/http/message/header.hpp diff --git a/boost/network/protocol/http/message/header/name.hpp b/include/network/protocol/http/message/header/name.hpp similarity index 100% rename from boost/network/protocol/http/message/header/name.hpp rename to include/network/protocol/http/message/header/name.hpp diff --git a/boost/network/protocol/http/message/header/value.hpp b/include/network/protocol/http/message/header/value.hpp similarity index 100% rename from boost/network/protocol/http/message/header/value.hpp rename to include/network/protocol/http/message/header/value.hpp diff --git a/boost/network/protocol/http/message/header_concept.hpp b/include/network/protocol/http/message/header_concept.hpp similarity index 100% rename from boost/network/protocol/http/message/header_concept.hpp rename to include/network/protocol/http/message/header_concept.hpp diff --git a/boost/network/protocol/http/message/modifiers.hpp b/include/network/protocol/http/message/modifiers.hpp similarity index 100% rename from boost/network/protocol/http/message/modifiers.hpp rename to include/network/protocol/http/message/modifiers.hpp diff --git a/boost/network/protocol/http/message/modifiers/major_version.hpp b/include/network/protocol/http/message/modifiers/major_version.hpp similarity index 100% rename from boost/network/protocol/http/message/modifiers/major_version.hpp rename to include/network/protocol/http/message/modifiers/major_version.hpp diff --git a/boost/network/protocol/http/message/modifiers/method.hpp b/include/network/protocol/http/message/modifiers/method.hpp similarity index 100% rename from boost/network/protocol/http/message/modifiers/method.hpp rename to include/network/protocol/http/message/modifiers/method.hpp diff --git a/boost/network/protocol/http/message/modifiers/minor_version.hpp b/include/network/protocol/http/message/modifiers/minor_version.hpp similarity index 100% rename from boost/network/protocol/http/message/modifiers/minor_version.hpp rename to include/network/protocol/http/message/modifiers/minor_version.hpp diff --git a/boost/network/protocol/http/message/modifiers/status.hpp b/include/network/protocol/http/message/modifiers/status.hpp similarity index 100% rename from boost/network/protocol/http/message/modifiers/status.hpp rename to include/network/protocol/http/message/modifiers/status.hpp diff --git a/boost/network/protocol/http/message/modifiers/status_message.hpp b/include/network/protocol/http/message/modifiers/status_message.hpp similarity index 100% rename from boost/network/protocol/http/message/modifiers/status_message.hpp rename to include/network/protocol/http/message/modifiers/status_message.hpp diff --git a/boost/network/protocol/http/message/modifiers/uri.hpp b/include/network/protocol/http/message/modifiers/uri.hpp similarity index 100% rename from boost/network/protocol/http/message/modifiers/uri.hpp rename to include/network/protocol/http/message/modifiers/uri.hpp diff --git a/boost/network/protocol/http/message/modifiers/version.hpp b/include/network/protocol/http/message/modifiers/version.hpp similarity index 100% rename from boost/network/protocol/http/message/modifiers/version.hpp rename to include/network/protocol/http/message/modifiers/version.hpp diff --git a/boost/network/protocol/http/message/wrappers.hpp b/include/network/protocol/http/message/wrappers.hpp similarity index 100% rename from boost/network/protocol/http/message/wrappers.hpp rename to include/network/protocol/http/message/wrappers.hpp diff --git a/boost/network/protocol/http/message/wrappers/anchor.hpp b/include/network/protocol/http/message/wrappers/anchor.hpp similarity index 100% rename from boost/network/protocol/http/message/wrappers/anchor.hpp rename to include/network/protocol/http/message/wrappers/anchor.hpp diff --git a/boost/network/protocol/http/message/wrappers/anchor.ipp b/include/network/protocol/http/message/wrappers/anchor.ipp similarity index 100% rename from boost/network/protocol/http/message/wrappers/anchor.ipp rename to include/network/protocol/http/message/wrappers/anchor.ipp diff --git a/boost/network/protocol/http/message/wrappers/helper.hpp b/include/network/protocol/http/message/wrappers/helper.hpp similarity index 100% rename from boost/network/protocol/http/message/wrappers/helper.hpp rename to include/network/protocol/http/message/wrappers/helper.hpp diff --git a/boost/network/protocol/http/message/wrappers/host.hpp b/include/network/protocol/http/message/wrappers/host.hpp similarity index 100% rename from boost/network/protocol/http/message/wrappers/host.hpp rename to include/network/protocol/http/message/wrappers/host.hpp diff --git a/boost/network/protocol/http/message/wrappers/host.ipp b/include/network/protocol/http/message/wrappers/host.ipp similarity index 100% rename from boost/network/protocol/http/message/wrappers/host.ipp rename to include/network/protocol/http/message/wrappers/host.ipp diff --git a/boost/network/protocol/http/message/wrappers/major_version.hpp b/include/network/protocol/http/message/wrappers/major_version.hpp similarity index 100% rename from boost/network/protocol/http/message/wrappers/major_version.hpp rename to include/network/protocol/http/message/wrappers/major_version.hpp diff --git a/boost/network/protocol/http/message/wrappers/method.hpp b/include/network/protocol/http/message/wrappers/method.hpp similarity index 100% rename from boost/network/protocol/http/message/wrappers/method.hpp rename to include/network/protocol/http/message/wrappers/method.hpp diff --git a/boost/network/protocol/http/message/wrappers/minor_version.hpp b/include/network/protocol/http/message/wrappers/minor_version.hpp similarity index 100% rename from boost/network/protocol/http/message/wrappers/minor_version.hpp rename to include/network/protocol/http/message/wrappers/minor_version.hpp diff --git a/boost/network/protocol/http/message/wrappers/path.hpp b/include/network/protocol/http/message/wrappers/path.hpp similarity index 100% rename from boost/network/protocol/http/message/wrappers/path.hpp rename to include/network/protocol/http/message/wrappers/path.hpp diff --git a/boost/network/protocol/http/message/wrappers/path.ipp b/include/network/protocol/http/message/wrappers/path.ipp similarity index 100% rename from boost/network/protocol/http/message/wrappers/path.ipp rename to include/network/protocol/http/message/wrappers/path.ipp diff --git a/boost/network/protocol/http/message/wrappers/port.hpp b/include/network/protocol/http/message/wrappers/port.hpp similarity index 100% rename from boost/network/protocol/http/message/wrappers/port.hpp rename to include/network/protocol/http/message/wrappers/port.hpp diff --git a/boost/network/protocol/http/message/wrappers/port.ipp b/include/network/protocol/http/message/wrappers/port.ipp similarity index 100% rename from boost/network/protocol/http/message/wrappers/port.ipp rename to include/network/protocol/http/message/wrappers/port.ipp diff --git a/boost/network/protocol/http/message/wrappers/protocol.hpp b/include/network/protocol/http/message/wrappers/protocol.hpp similarity index 100% rename from boost/network/protocol/http/message/wrappers/protocol.hpp rename to include/network/protocol/http/message/wrappers/protocol.hpp diff --git a/boost/network/protocol/http/message/wrappers/query.hpp b/include/network/protocol/http/message/wrappers/query.hpp similarity index 100% rename from boost/network/protocol/http/message/wrappers/query.hpp rename to include/network/protocol/http/message/wrappers/query.hpp diff --git a/boost/network/protocol/http/message/wrappers/query.ipp b/include/network/protocol/http/message/wrappers/query.ipp similarity index 100% rename from boost/network/protocol/http/message/wrappers/query.ipp rename to include/network/protocol/http/message/wrappers/query.ipp diff --git a/boost/network/protocol/http/message/wrappers/ready.hpp b/include/network/protocol/http/message/wrappers/ready.hpp similarity index 100% rename from boost/network/protocol/http/message/wrappers/ready.hpp rename to include/network/protocol/http/message/wrappers/ready.hpp diff --git a/boost/network/protocol/http/message/wrappers/status.hpp b/include/network/protocol/http/message/wrappers/status.hpp similarity index 100% rename from boost/network/protocol/http/message/wrappers/status.hpp rename to include/network/protocol/http/message/wrappers/status.hpp diff --git a/boost/network/protocol/http/message/wrappers/status.ipp b/include/network/protocol/http/message/wrappers/status.ipp similarity index 100% rename from boost/network/protocol/http/message/wrappers/status.ipp rename to include/network/protocol/http/message/wrappers/status.ipp diff --git a/boost/network/protocol/http/message/wrappers/status_message.hpp b/include/network/protocol/http/message/wrappers/status_message.hpp similarity index 100% rename from boost/network/protocol/http/message/wrappers/status_message.hpp rename to include/network/protocol/http/message/wrappers/status_message.hpp diff --git a/boost/network/protocol/http/message/wrappers/status_message.ipp b/include/network/protocol/http/message/wrappers/status_message.ipp similarity index 100% rename from boost/network/protocol/http/message/wrappers/status_message.ipp rename to include/network/protocol/http/message/wrappers/status_message.ipp diff --git a/boost/network/protocol/http/message/wrappers/uri.hpp b/include/network/protocol/http/message/wrappers/uri.hpp similarity index 100% rename from boost/network/protocol/http/message/wrappers/uri.hpp rename to include/network/protocol/http/message/wrappers/uri.hpp diff --git a/boost/network/protocol/http/message/wrappers/uri.ipp b/include/network/protocol/http/message/wrappers/uri.ipp similarity index 100% rename from boost/network/protocol/http/message/wrappers/uri.ipp rename to include/network/protocol/http/message/wrappers/uri.ipp diff --git a/boost/network/protocol/http/message/wrappers/version.hpp b/include/network/protocol/http/message/wrappers/version.hpp similarity index 100% rename from boost/network/protocol/http/message/wrappers/version.hpp rename to include/network/protocol/http/message/wrappers/version.hpp diff --git a/boost/network/protocol/http/message/wrappers/version.ipp b/include/network/protocol/http/message/wrappers/version.ipp similarity index 100% rename from boost/network/protocol/http/message/wrappers/version.ipp rename to include/network/protocol/http/message/wrappers/version.ipp diff --git a/boost/network/protocol/http/parser.hpp b/include/network/protocol/http/parser.hpp similarity index 100% rename from boost/network/protocol/http/parser.hpp rename to include/network/protocol/http/parser.hpp diff --git a/boost/network/protocol/http/parser/incremental.hpp b/include/network/protocol/http/parser/incremental.hpp similarity index 100% rename from boost/network/protocol/http/parser/incremental.hpp rename to include/network/protocol/http/parser/incremental.hpp diff --git a/boost/network/protocol/http/policies/async_connection.hpp b/include/network/protocol/http/policies/async_connection.hpp similarity index 100% rename from boost/network/protocol/http/policies/async_connection.hpp rename to include/network/protocol/http/policies/async_connection.hpp diff --git a/boost/network/protocol/http/policies/async_connection.ipp b/include/network/protocol/http/policies/async_connection.ipp similarity index 100% rename from boost/network/protocol/http/policies/async_connection.ipp rename to include/network/protocol/http/policies/async_connection.ipp diff --git a/boost/network/protocol/http/request.hpp b/include/network/protocol/http/request.hpp similarity index 100% rename from boost/network/protocol/http/request.hpp rename to include/network/protocol/http/request.hpp diff --git a/boost/network/protocol/http/request/request.hpp b/include/network/protocol/http/request/request.hpp similarity index 100% rename from boost/network/protocol/http/request/request.hpp rename to include/network/protocol/http/request/request.hpp diff --git a/boost/network/protocol/http/request/request.ipp b/include/network/protocol/http/request/request.ipp similarity index 100% rename from boost/network/protocol/http/request/request.ipp rename to include/network/protocol/http/request/request.ipp diff --git a/boost/network/protocol/http/request/request_base.hpp b/include/network/protocol/http/request/request_base.hpp similarity index 100% rename from boost/network/protocol/http/request/request_base.hpp rename to include/network/protocol/http/request/request_base.hpp diff --git a/boost/network/protocol/http/request/request_base.ipp b/include/network/protocol/http/request/request_base.ipp similarity index 100% rename from boost/network/protocol/http/request/request_base.ipp rename to include/network/protocol/http/request/request_base.ipp diff --git a/boost/network/protocol/http/request/request_concept.hpp b/include/network/protocol/http/request/request_concept.hpp similarity index 100% rename from boost/network/protocol/http/request/request_concept.hpp rename to include/network/protocol/http/request/request_concept.hpp diff --git a/boost/network/protocol/http/request_parser.hpp b/include/network/protocol/http/request_parser.hpp similarity index 100% rename from boost/network/protocol/http/request_parser.hpp rename to include/network/protocol/http/request_parser.hpp diff --git a/boost/network/protocol/http/response.hpp b/include/network/protocol/http/response.hpp similarity index 100% rename from boost/network/protocol/http/response.hpp rename to include/network/protocol/http/response.hpp diff --git a/boost/network/protocol/http/response/response.hpp b/include/network/protocol/http/response/response.hpp similarity index 100% rename from boost/network/protocol/http/response/response.hpp rename to include/network/protocol/http/response/response.hpp diff --git a/boost/network/protocol/http/response/response.ipp b/include/network/protocol/http/response/response.ipp similarity index 100% rename from boost/network/protocol/http/response/response.ipp rename to include/network/protocol/http/response/response.ipp diff --git a/boost/network/protocol/http/response/response_base.hpp b/include/network/protocol/http/response/response_base.hpp similarity index 100% rename from boost/network/protocol/http/response/response_base.hpp rename to include/network/protocol/http/response/response_base.hpp diff --git a/boost/network/protocol/http/response/response_base.ipp b/include/network/protocol/http/response/response_base.ipp similarity index 100% rename from boost/network/protocol/http/response/response_base.ipp rename to include/network/protocol/http/response/response_base.ipp diff --git a/boost/network/protocol/http/response/response_concept.hpp b/include/network/protocol/http/response/response_concept.hpp similarity index 100% rename from boost/network/protocol/http/response/response_concept.hpp rename to include/network/protocol/http/response/response_concept.hpp diff --git a/boost/network/protocol/http/server.hpp b/include/network/protocol/http/server.hpp similarity index 100% rename from boost/network/protocol/http/server.hpp rename to include/network/protocol/http/server.hpp diff --git a/boost/network/protocol/http/server/async_impl.hpp b/include/network/protocol/http/server/async_impl.hpp similarity index 100% rename from boost/network/protocol/http/server/async_impl.hpp rename to include/network/protocol/http/server/async_impl.hpp diff --git a/boost/network/protocol/http/server/async_impl.ipp b/include/network/protocol/http/server/async_impl.ipp similarity index 100% rename from boost/network/protocol/http/server/async_impl.ipp rename to include/network/protocol/http/server/async_impl.ipp diff --git a/boost/network/protocol/http/server/async_server.hpp b/include/network/protocol/http/server/async_server.hpp similarity index 100% rename from boost/network/protocol/http/server/async_server.hpp rename to include/network/protocol/http/server/async_server.hpp diff --git a/boost/network/protocol/http/server/connection/async.hpp b/include/network/protocol/http/server/connection/async.hpp similarity index 100% rename from boost/network/protocol/http/server/connection/async.hpp rename to include/network/protocol/http/server/connection/async.hpp diff --git a/boost/network/protocol/http/server/connection/sync.hpp b/include/network/protocol/http/server/connection/sync.hpp similarity index 100% rename from boost/network/protocol/http/server/connection/sync.hpp rename to include/network/protocol/http/server/connection/sync.hpp diff --git a/boost/network/protocol/http/server/impl/parsers.ipp b/include/network/protocol/http/server/impl/parsers.ipp similarity index 100% rename from boost/network/protocol/http/server/impl/parsers.ipp rename to include/network/protocol/http/server/impl/parsers.ipp diff --git a/boost/network/protocol/http/server/impl/socket_options_setter.hpp b/include/network/protocol/http/server/impl/socket_options_setter.hpp similarity index 100% rename from boost/network/protocol/http/server/impl/socket_options_setter.hpp rename to include/network/protocol/http/server/impl/socket_options_setter.hpp diff --git a/boost/network/protocol/http/server/impl/socket_options_setter.ipp b/include/network/protocol/http/server/impl/socket_options_setter.ipp similarity index 100% rename from boost/network/protocol/http/server/impl/socket_options_setter.ipp rename to include/network/protocol/http/server/impl/socket_options_setter.ipp diff --git a/boost/network/protocol/http/server/options.hpp b/include/network/protocol/http/server/options.hpp similarity index 100% rename from boost/network/protocol/http/server/options.hpp rename to include/network/protocol/http/server/options.hpp diff --git a/boost/network/protocol/http/server/options.ipp b/include/network/protocol/http/server/options.ipp similarity index 100% rename from boost/network/protocol/http/server/options.ipp rename to include/network/protocol/http/server/options.ipp diff --git a/boost/network/protocol/http/server/parameters.hpp b/include/network/protocol/http/server/parameters.hpp similarity index 100% rename from boost/network/protocol/http/server/parameters.hpp rename to include/network/protocol/http/server/parameters.hpp diff --git a/boost/network/protocol/http/server/request.hpp b/include/network/protocol/http/server/request.hpp similarity index 100% rename from boost/network/protocol/http/server/request.hpp rename to include/network/protocol/http/server/request.hpp diff --git a/boost/network/protocol/http/server/request_parser.hpp b/include/network/protocol/http/server/request_parser.hpp similarity index 100% rename from boost/network/protocol/http/server/request_parser.hpp rename to include/network/protocol/http/server/request_parser.hpp diff --git a/boost/network/protocol/http/server/server.ipp b/include/network/protocol/http/server/server.ipp similarity index 100% rename from boost/network/protocol/http/server/server.ipp rename to include/network/protocol/http/server/server.ipp diff --git a/boost/network/protocol/http/server/socket_options_base.hpp b/include/network/protocol/http/server/socket_options_base.hpp similarity index 100% rename from boost/network/protocol/http/server/socket_options_base.hpp rename to include/network/protocol/http/server/socket_options_base.hpp diff --git a/boost/network/protocol/http/server/storage_base.hpp b/include/network/protocol/http/server/storage_base.hpp similarity index 100% rename from boost/network/protocol/http/server/storage_base.hpp rename to include/network/protocol/http/server/storage_base.hpp diff --git a/boost/network/protocol/http/server/sync_impl.hpp b/include/network/protocol/http/server/sync_impl.hpp similarity index 100% rename from boost/network/protocol/http/server/sync_impl.hpp rename to include/network/protocol/http/server/sync_impl.hpp diff --git a/boost/network/protocol/http/server/sync_impl.ipp b/include/network/protocol/http/server/sync_impl.ipp similarity index 100% rename from boost/network/protocol/http/server/sync_impl.ipp rename to include/network/protocol/http/server/sync_impl.ipp diff --git a/boost/network/protocol/http/server/sync_server.hpp b/include/network/protocol/http/server/sync_server.hpp similarity index 100% rename from boost/network/protocol/http/server/sync_server.hpp rename to include/network/protocol/http/server/sync_server.hpp diff --git a/boost/network/protocol/http/support/client_or_server.hpp b/include/network/protocol/http/support/client_or_server.hpp similarity index 100% rename from boost/network/protocol/http/support/client_or_server.hpp rename to include/network/protocol/http/support/client_or_server.hpp diff --git a/boost/network/protocol/http/support/is_client.hpp b/include/network/protocol/http/support/is_client.hpp similarity index 100% rename from boost/network/protocol/http/support/is_client.hpp rename to include/network/protocol/http/support/is_client.hpp diff --git a/boost/network/protocol/http/support/is_http.hpp b/include/network/protocol/http/support/is_http.hpp similarity index 100% rename from boost/network/protocol/http/support/is_http.hpp rename to include/network/protocol/http/support/is_http.hpp diff --git a/boost/network/protocol/http/support/is_keepalive.hpp b/include/network/protocol/http/support/is_keepalive.hpp similarity index 100% rename from boost/network/protocol/http/support/is_keepalive.hpp rename to include/network/protocol/http/support/is_keepalive.hpp diff --git a/boost/network/protocol/http/support/is_server.hpp b/include/network/protocol/http/support/is_server.hpp similarity index 100% rename from boost/network/protocol/http/support/is_server.hpp rename to include/network/protocol/http/support/is_server.hpp diff --git a/boost/network/protocol/http/support/is_simple.hpp b/include/network/protocol/http/support/is_simple.hpp similarity index 100% rename from boost/network/protocol/http/support/is_simple.hpp rename to include/network/protocol/http/support/is_simple.hpp diff --git a/boost/network/protocol/http/support/sync_only.hpp b/include/network/protocol/http/support/sync_only.hpp similarity index 100% rename from boost/network/protocol/http/support/sync_only.hpp rename to include/network/protocol/http/support/sync_only.hpp diff --git a/boost/network/utils/thread_pool.hpp b/include/network/utils/thread_pool.hpp similarity index 100% rename from boost/network/utils/thread_pool.hpp rename to include/network/utils/thread_pool.hpp diff --git a/boost/network/utils/thread_pool.ipp b/include/network/utils/thread_pool.ipp similarity index 100% rename from boost/network/utils/thread_pool.ipp rename to include/network/utils/thread_pool.ipp diff --git a/boost/network/version.hpp b/include/network/version.hpp similarity index 100% rename from boost/network/version.hpp rename to include/network/version.hpp From 035da71901c5ba12d18cfa7363a08abc25644811 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Mon, 10 Sep 2012 01:13:55 +1000 Subject: [PATCH 106/196] The great rename; fixes everything! --- CMakeLists.txt | 7 +++-- include/network.hpp | 4 +-- include/network/constants.ipp | 4 +-- include/network/include/http/client.hpp | 14 ++++----- include/network/include/http/server.hpp | 6 ++-- include/network/include/message.hpp | 2 +- include/network/message.hpp | 28 ++++++++--------- include/network/message/basic_message.hpp | 4 +-- include/network/message/directives.hpp | 6 ++-- .../directives/detail/string_value.hpp | 6 ++-- include/network/message/directives/header.hpp | 4 +-- include/network/message/directives/header.ipp | 2 +- .../message/directives/remove_header.ipp | 2 +- include/network/message/message.hpp | 4 +-- include/network/message/message.ipp | 2 +- include/network/message/message_base.ipp | 2 +- include/network/message/message_concept.hpp | 6 ++-- include/network/message/modifiers.hpp | 12 ++++---- .../message/modifiers/clear_headers.hpp | 2 +- .../message/modifiers/remove_header.hpp | 2 +- include/network/message/transformers.hpp | 8 ++--- .../network/message/transformers/to_lower.hpp | 2 +- .../network/message/transformers/to_upper.hpp | 2 +- include/network/message/wrappers.hpp | 8 ++--- include/network/message/wrappers/body.hpp | 4 +-- include/network/message/wrappers/body.ipp | 2 +- .../network/message/wrappers/destination.hpp | 4 +-- .../network/message/wrappers/destination.ipp | 2 +- include/network/message/wrappers/headers.ipp | 4 +-- include/network/message/wrappers/source.hpp | 4 +-- include/network/message/wrappers/source.ipp | 2 +- include/network/protocol.hpp | 2 +- include/network/protocol/http.hpp | 8 ++--- .../protocol/http/algorithms/linearize.hpp | 10 +++---- include/network/protocol/http/client.hpp | 14 ++++----- include/network/protocol/http/client.ipp | 6 ++-- include/network/protocol/http/client/base.ipp | 12 ++++---- .../http/client/client_connection.ipp | 4 +-- .../http/client/connection/async_normal.hpp | 2 +- .../http/client/connection/async_normal.ipp | 16 +++++----- .../connection/async_protocol_handler.hpp | 4 +-- .../http/client/connection/async_resolver.hpp | 4 +-- .../http/client/connection/async_resolver.ipp | 2 +- .../connection_delegate_factory.hpp | 2 +- .../connection_delegate_factory.ipp | 10 +++---- .../client/connection/connection_factory.ipp | 2 +- .../client/connection/normal_delegate.hpp | 2 +- .../client/connection/normal_delegate.ipp | 4 +-- .../client/connection/resolver_delegate.ipp | 4 +-- .../connection/resolver_delegate_factory.hpp | 4 +-- .../connection/resolver_delegate_factory.ipp | 6 ++-- .../connection/simple_connection_factory.hpp | 6 ++-- .../connection/simple_connection_factory.ipp | 14 ++++----- .../http/client/connection/ssl_delegate.hpp | 4 +-- .../http/client/connection/ssl_delegate.ipp | 6 ++-- .../http/client/connection/sync_base.hpp | 12 ++++---- .../http/client/connection/sync_normal.hpp | 2 +- .../http/client/connection_manager.hpp | 2 +- .../http/client/connection_manager.ipp | 4 +-- .../network/protocol/http/client/facade.hpp | 8 ++--- .../network/protocol/http/client/facade.ipp | 4 +-- .../network/protocol/http/client/options.hpp | 6 ++-- .../network/protocol/http/client/options.ipp | 6 ++-- .../protocol/http/client/parameters.hpp | 2 +- .../network/protocol/http/client/pimpl.hpp | 4 +-- .../http/client/simple_connection_manager.hpp | 4 +-- .../http/client/simple_connection_manager.ipp | 8 ++--- include/network/protocol/http/client_fwd.hpp | 2 +- include/network/protocol/http/impl/access.hpp | 2 +- include/network/protocol/http/impl/access.ipp | 2 +- .../network/protocol/http/impl/message.ipp | 2 +- include/network/protocol/http/impl/parser.ipp | 2 +- .../network/protocol/http/impl/request.hpp | 14 ++++----- .../protocol/http/impl/request_parser.ipp | 2 +- .../network/protocol/http/impl/response.ipp | 2 +- .../protocol/http/message/async_message.hpp | 2 +- .../protocol/http/message/directives.hpp | 10 +++---- .../http/message/directives/minor_version.hpp | 2 +- .../http/message/directives/status.hpp | 2 +- .../message/directives/status_message.hpp | 2 +- .../protocol/http/message/directives/uri.hpp | 2 +- .../http/message/directives/version.hpp | 2 +- .../protocol/http/message/header/name.hpp | 2 +- .../protocol/http/message/modifiers.hpp | 10 +++---- .../http/message/modifiers/major_version.hpp | 2 +- .../http/message/modifiers/method.hpp | 2 +- .../http/message/modifiers/minor_version.hpp | 2 +- .../http/message/modifiers/status.hpp | 2 +- .../http/message/modifiers/status_message.hpp | 2 +- .../protocol/http/message/modifiers/uri.hpp | 2 +- .../http/message/modifiers/version.hpp | 2 +- .../protocol/http/message/wrappers.hpp | 26 ++++++++-------- .../protocol/http/message/wrappers/anchor.hpp | 2 +- .../protocol/http/message/wrappers/anchor.ipp | 2 +- .../protocol/http/message/wrappers/host.hpp | 2 +- .../protocol/http/message/wrappers/host.ipp | 2 +- .../http/message/wrappers/major_version.hpp | 2 +- .../protocol/http/message/wrappers/method.hpp | 2 +- .../http/message/wrappers/minor_version.hpp | 2 +- .../protocol/http/message/wrappers/path.hpp | 2 +- .../protocol/http/message/wrappers/path.ipp | 2 +- .../protocol/http/message/wrappers/port.hpp | 2 +- .../protocol/http/message/wrappers/port.ipp | 2 +- .../http/message/wrappers/protocol.hpp | 2 +- .../protocol/http/message/wrappers/query.hpp | 2 +- .../protocol/http/message/wrappers/query.ipp | 2 +- .../protocol/http/message/wrappers/ready.hpp | 2 +- .../protocol/http/message/wrappers/status.ipp | 2 +- .../http/message/wrappers/status_message.hpp | 2 +- .../http/message/wrappers/status_message.ipp | 2 +- .../protocol/http/message/wrappers/uri.hpp | 2 +- .../protocol/http/message/wrappers/uri.ipp | 2 +- .../http/message/wrappers/version.hpp | 2 +- .../http/message/wrappers/version.ipp | 2 +- include/network/protocol/http/parser.hpp | 8 ++--- .../http/policies/async_connection.hpp | 4 +-- include/network/protocol/http/request.hpp | 2 +- .../network/protocol/http/request/request.hpp | 18 +++++------ .../network/protocol/http/request/request.ipp | 4 +-- .../protocol/http/request/request_base.hpp | 2 +- .../protocol/http/request/request_base.ipp | 2 +- .../protocol/http/request/request_concept.hpp | 2 +- .../network/protocol/http/request_parser.hpp | 4 +-- include/network/protocol/http/response.hpp | 30 +++++++++---------- .../protocol/http/response/response.hpp | 4 +-- .../protocol/http/response/response.ipp | 2 +- .../protocol/http/response/response_base.hpp | 4 +-- .../protocol/http/response/response_base.ipp | 2 +- .../http/response/response_concept.hpp | 2 +- include/network/protocol/http/server.hpp | 2 +- .../protocol/http/server/async_impl.hpp | 4 +-- .../protocol/http/server/async_impl.ipp | 6 ++-- .../protocol/http/server/async_server.hpp | 10 +++---- .../protocol/http/server/connection/async.hpp | 12 ++++---- .../protocol/http/server/connection/sync.hpp | 8 ++--- .../protocol/http/server/impl/parsers.ipp | 2 +- .../server/impl/socket_options_setter.ipp | 4 +-- .../network/protocol/http/server/options.ipp | 2 +- .../protocol/http/server/parameters.hpp | 2 +- .../network/protocol/http/server/server.ipp | 6 ++-- .../http/server/socket_options_base.hpp | 2 +- .../protocol/http/server/storage_base.hpp | 2 +- .../protocol/http/server/sync_impl.hpp | 4 +-- .../protocol/http/server/sync_impl.ipp | 6 ++-- .../protocol/http/server/sync_server.hpp | 16 +++++----- .../http/support/client_or_server.hpp | 4 +-- .../network/protocol/http/support/is_http.hpp | 2 +- .../protocol/http/support/is_keepalive.hpp | 2 +- .../protocol/http/support/is_simple.hpp | 2 +- .../protocol/http/support/sync_only.hpp | 4 +-- include/network/utils/thread_pool.ipp | 2 +- libs/network/example/atom/atom.hpp | 2 +- libs/network/example/atom/main.cpp | 2 +- libs/network/example/http/fileserver.cpp | 2 +- .../example/http/hello_world_client.cpp | 2 +- .../example/http/hello_world_server.cpp | 2 +- libs/network/example/http/one_liner.cpp | 2 +- libs/network/example/http_client.cpp | 2 +- libs/network/example/http_client1.cpp | 2 +- libs/network/example/rss/main.cpp | 2 +- libs/network/example/rss/rss.hpp | 2 +- libs/network/example/simple_wget.cpp | 2 +- libs/network/example/twitter/search.cpp | 2 +- libs/network/src/client.cpp | 4 +-- libs/network/src/constants.cpp | 2 +- libs/network/src/http/client.cpp | 8 ++--- .../src/http/client_async_resolver.cpp | 2 +- .../src/http/client_connection_delegates.cpp | 4 +-- .../src/http/client_connection_factory.cpp | 2 +- .../src/http/client_connection_normal.cpp | 2 +- libs/network/src/http/client_connections.cpp | 12 ++++---- .../src/http/client_resolver_delegate.cpp | 2 +- .../http/client_resolver_delegate_factory.cpp | 2 +- .../src/http/connection_delegate_factory.cpp | 2 +- libs/network/src/http/message/wrappers.cpp | 12 ++++---- libs/network/src/http/request.cpp | 4 +-- libs/network/src/http/response.cpp | 10 +++---- libs/network/src/http/server_async_impl.cpp | 2 +- libs/network/src/http/server_options.cpp | 2 +- .../src/http/server_socket_options_setter.cpp | 2 +- libs/network/src/http/server_sync_impl.cpp | 2 +- .../src/http/simple_connection_factory.cpp | 2 +- .../src/http/simple_connection_manager.cpp | 2 +- libs/network/src/message/directives.cpp | 4 +-- libs/network/src/message/message.cpp | 4 +-- libs/network/src/message/wrappers.cpp | 8 ++--- .../src/server_request_parsers_impl.cpp | 2 +- libs/network/src/utils/thread_pool.cpp | 2 +- libs/network/test/CMakeLists.txt | 8 ++--- .../test/client_server_include_failure.cpp | 4 +-- .../test/http/client_constructor_test.cpp | 2 +- .../http/client_get_different_port_test.cpp | 2 +- .../test/http/client_get_streaming_test.cpp | 2 +- libs/network/test/http/client_get_test.cpp | 2 +- .../test/http/client_get_timeout_test.cpp | 2 +- .../test/http/client_include_inlined.cpp | 2 +- .../http/client_localhost_normal_test.cpp | 2 +- .../test/http/client_localhost_ssl_test.cpp | 2 +- .../test/http/message_async_ready_test.cpp | 2 +- libs/network/test/http/message_test.cpp | 4 +-- libs/network/test/http/request_base_test.cpp | 2 +- .../http/request_incremental_parser_test.cpp | 4 +-- .../test/http/request_linearize_test.cpp | 4 +-- libs/network/test/http/request_test.cpp | 6 ++-- .../http/response_incremental_parser_test.cpp | 2 +- libs/network/test/http/response_test.cpp | 2 +- libs/network/test/http/server_async.cpp | 4 +-- .../test/http/server_async_less_copy.cpp | 4 +-- .../server_async_run_stop_concurrency.cpp | 2 +- .../test/http/server_constructor_test.cpp | 2 +- libs/network/test/http/server_hello_world.cpp | 2 +- .../test/http/server_include_inlined.cpp | 2 +- .../test/http_server_async_less_copy.cpp | 4 +-- libs/network/test/message_test.cpp | 2 +- libs/network/test/message_transform_test.cpp | 2 +- libs/network/test/utils_thread_pool.cpp | 2 +- 216 files changed, 458 insertions(+), 457 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 06f6460ce..07eb2011c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,8 @@ -# Copyright (c) Dean Michael Berris 2010. +# Copyright (c) Dean Michael Berris 2010. +# Copyright (c) Google, Inc. 2012. # Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) cmake_minimum_required(VERSION 2.8) project(CPP-NETLIB) diff --git a/include/network.hpp b/include/network.hpp index 6ef92832e..76bf84ae9 100644 --- a/include/network.hpp +++ b/include/network.hpp @@ -11,8 +11,8 @@ // Author: Dean Michael Berris // Date: May 20, 2007 -#include // message type implementation -#include // protocols implementation +#include // message type implementation +#include // protocols implementation #endif // __NETWORK_HPP__ diff --git a/include/network/constants.ipp b/include/network/constants.ipp index 73a7d3e93..43f7013d1 100644 --- a/include/network/constants.ipp +++ b/include/network/constants.ipp @@ -7,8 +7,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include +#include +#include namespace boost { namespace network { diff --git a/include/network/include/http/client.hpp b/include/network/include/http/client.hpp index 4ca545f9e..67fa571d3 100644 --- a/include/network/include/http/client.hpp +++ b/include/network/include/http/client.hpp @@ -8,13 +8,13 @@ // // This is the modular include file for using the HTTP Client -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #endif // BOOST_NETWORK_INCLUDE_HTTP_CLIENT_HPP_ diff --git a/include/network/include/http/server.hpp b/include/network/include/http/server.hpp index 10b66e2b5..e9d4b93d2 100644 --- a/include/network/include/http/server.hpp +++ b/include/network/include/http/server.hpp @@ -10,8 +10,8 @@ // This is the modular include file for using the HTTP Client #include -#include -#include -#include +#include +#include +#include #endif diff --git a/include/network/include/message.hpp b/include/network/include/message.hpp index 2f7d00897..f170e6a84 100644 --- a/include/network/include/message.hpp +++ b/include/network/include/message.hpp @@ -8,7 +8,7 @@ // // This is the modular include file for using the basic message type -#include +#include #endif // BOOST_NETWORK_INCLUDE_MESSAGE_HPP_ diff --git a/include/network/message.hpp b/include/network/message.hpp index e1b266384..27cdde616 100644 --- a/include/network/message.hpp +++ b/include/network/message.hpp @@ -8,24 +8,24 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -#include +#include #ifdef BOOST_NETWORK_DEBUG -#include +#include #endif #endif // BOOST_NETWORK_MESSAGE_HPP_20111021 diff --git a/include/network/message/basic_message.hpp b/include/network/message/basic_message.hpp index 3bf44db93..18c14dee4 100644 --- a/include/network/message/basic_message.hpp +++ b/include/network/message/basic_message.hpp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include namespace boost { namespace network { @@ -46,7 +46,7 @@ void swap(basic_storage_base & l, basic_storage_base & r); } /* boost */ #ifdef BOOST_NETWORK_NO_LIB -#include +#include #endif #endif /* BOOST_NETWORK_MESSAGE_BASIC_MESSAGE_HPP_20110911 */ diff --git a/include/network/message/directives.hpp b/include/network/message/directives.hpp index 23be513f2..a72ee613e 100644 --- a/include/network/message/directives.hpp +++ b/include/network/message/directives.hpp @@ -7,9 +7,9 @@ #ifndef __NETWORK_MESSAGE_DIRECTIVES_HPP__ #define __NETWORK_MESSAGE_DIRECTIVES_HPP__ -#include -#include -#include +#include +#include +#include namespace boost { namespace network { diff --git a/include/network/message/directives/detail/string_value.hpp b/include/network/message/directives/detail/string_value.hpp index 4d62d9747..3efacbe68 100644 --- a/include/network/message/directives/detail/string_value.hpp +++ b/include/network/message/directives/detail/string_value.hpp @@ -6,9 +6,9 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/include/network/message/directives/header.hpp b/include/network/message/directives/header.hpp index 9edc7e0b0..54ab3b22f 100644 --- a/include/network/message/directives/header.hpp +++ b/include/network/message/directives/header.hpp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { @@ -32,7 +32,7 @@ header(std::string const & header_name, std::string const & header_value) { } // namespace boost #ifdef BOOST_NETWORK_NO_LIB -#include +#include #endif #endif // __NETWORK_MESSAGE_DIRECTIVES_HEADER_HPP__ diff --git a/include/network/message/directives/header.ipp b/include/network/message/directives/header.ipp index 5c5401a1f..08fa65981 100644 --- a/include/network/message/directives/header.ipp +++ b/include/network/message/directives/header.ipp @@ -8,7 +8,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include +#include namespace boost { namespace network { namespace impl { diff --git a/include/network/message/directives/remove_header.ipp b/include/network/message/directives/remove_header.ipp index b732983e6..3c1ae1586 100644 --- a/include/network/message/directives/remove_header.ipp +++ b/include/network/message/directives/remove_header.ipp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace impl { diff --git a/include/network/message/message.hpp b/include/network/message/message.hpp index e9be07051..821271d58 100644 --- a/include/network/message/message.hpp +++ b/include/network/message/message.hpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include namespace boost { namespace network { @@ -81,7 +81,7 @@ message_base & operator<< (message_base & msg, Directive directive) { } /* boost */ #ifdef BOOST_NETWORK_NO_LIB -#include +#include #endif #endif /* BOOST_NETWORK_MESSAGE_MESSAGE_HPP_20111021 */ diff --git a/include/network/message/message.ipp b/include/network/message/message.ipp index fa0e14601..12b1a41fd 100644 --- a/include/network/message/message.ipp +++ b/include/network/message/message.ipp @@ -10,7 +10,7 @@ #include #include #include -#include +#include namespace boost { namespace network { diff --git a/include/network/message/message_base.ipp b/include/network/message/message_base.ipp index 0ef383e9b..cb38c52ae 100644 --- a/include/network/message/message_base.ipp +++ b/include/network/message/message_base.ipp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { diff --git a/include/network/message/message_concept.hpp b/include/network/message/message_concept.hpp index d3731f3e1..581cad05c 100644 --- a/include/network/message/message_concept.hpp +++ b/include/network/message/message_concept.hpp @@ -10,9 +10,9 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include -#include -#include +#include +#include +#include #include namespace boost { namespace network { diff --git a/include/network/message/modifiers.hpp b/include/network/message/modifiers.hpp index 95e998044..de3dfeec0 100644 --- a/include/network/message/modifiers.hpp +++ b/include/network/message/modifiers.hpp @@ -7,11 +7,11 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #endif // BOOST_NETWORK_MESSAGE_MODIFIERS_HPP_20111201 diff --git a/include/network/message/modifiers/clear_headers.hpp b/include/network/message/modifiers/clear_headers.hpp index 671cf0b7d..8595c8273 100644 --- a/include/network/message/modifiers/clear_headers.hpp +++ b/include/network/message/modifiers/clear_headers.hpp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { diff --git a/include/network/message/modifiers/remove_header.hpp b/include/network/message/modifiers/remove_header.hpp index d14146a41..632d1156e 100644 --- a/include/network/message/modifiers/remove_header.hpp +++ b/include/network/message/modifiers/remove_header.hpp @@ -8,7 +8,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include +#include namespace boost { namespace network { diff --git a/include/network/message/transformers.hpp b/include/network/message/transformers.hpp index 68ad230ed..91111db15 100644 --- a/include/network/message/transformers.hpp +++ b/include/network/message/transformers.hpp @@ -11,10 +11,10 @@ * * Pulls in all the transformers files. */ -#include -#include -#include -#include +#include +#include +#include +#include #include namespace boost { namespace network { diff --git a/include/network/message/transformers/to_lower.hpp b/include/network/message/transformers/to_lower.hpp index aa2227c6e..ccf4ed18a 100644 --- a/include/network/message/transformers/to_lower.hpp +++ b/include/network/message/transformers/to_lower.hpp @@ -8,7 +8,7 @@ #define __NETWORK_MESSAGE_TRANSFORMERS_TO_LOWER_HPP__ #include -#include +#include /** to_lower.hpp * diff --git a/include/network/message/transformers/to_upper.hpp b/include/network/message/transformers/to_upper.hpp index f8c684c16..4aee31ef7 100644 --- a/include/network/message/transformers/to_upper.hpp +++ b/include/network/message/transformers/to_upper.hpp @@ -8,7 +8,7 @@ #define __NETWORK_MESSAGE_TRANSFORMERS_TO_UPPER_HPP__ #include -#include +#include /** to_upper.hpp * diff --git a/include/network/message/wrappers.hpp b/include/network/message/wrappers.hpp index 60fbe06ae..d4a9fdc4e 100644 --- a/include/network/message/wrappers.hpp +++ b/include/network/message/wrappers.hpp @@ -11,9 +11,9 @@ * * Pulls in all the wrapper header files. */ -#include -#include -#include -#include +#include +#include +#include +#include #endif // __NETWORK_MESSAGE_WRAPPERS_HPP__ diff --git a/include/network/message/wrappers/body.hpp b/include/network/message/wrappers/body.hpp index fffe9277d..0e3e19d82 100644 --- a/include/network/message/wrappers/body.hpp +++ b/include/network/message/wrappers/body.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include namespace boost { namespace network { @@ -40,7 +40,7 @@ body(message_base const & message_) { } // namespace boost #ifdef BOOST_NETWORK_NO_LIB -#include +#include #endif #endif // __NETWORK_MESSAGE_WRAPPERS_BODY_HPP__ diff --git a/include/network/message/wrappers/body.ipp b/include/network/message/wrappers/body.ipp index 6cda77129..4503007d8 100644 --- a/include/network/message/wrappers/body.ipp +++ b/include/network/message/wrappers/body.ipp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { diff --git a/include/network/message/wrappers/destination.hpp b/include/network/message/wrappers/destination.hpp index 3b269a489..346718719 100644 --- a/include/network/message/wrappers/destination.hpp +++ b/include/network/message/wrappers/destination.hpp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { @@ -33,7 +33,7 @@ inline std::ostream & operator<< (std::ostream &os, destination_wrapper const &d } // namespace boost #ifdef BOOST_NETWORK_NO_LIB -#include +#include #endif #endif // __NETWORK_MESSAGE_WRAPPERS_DESTINATION_HPP__ diff --git a/include/network/message/wrappers/destination.ipp b/include/network/message/wrappers/destination.ipp index 8c25cc1d4..8ebd86880 100644 --- a/include/network/message/wrappers/destination.ipp +++ b/include/network/message/wrappers/destination.ipp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { diff --git a/include/network/message/wrappers/headers.ipp b/include/network/message/wrappers/headers.ipp index 2b55db975..ed8f03e11 100644 --- a/include/network/message/wrappers/headers.ipp +++ b/include/network/message/wrappers/headers.ipp @@ -7,8 +7,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include +#include +#include #include namespace boost { namespace network { diff --git a/include/network/message/wrappers/source.hpp b/include/network/message/wrappers/source.hpp index 05dfac024..4dc537012 100644 --- a/include/network/message/wrappers/source.hpp +++ b/include/network/message/wrappers/source.hpp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { @@ -33,7 +33,7 @@ inline std::ostream & operator<<(std::ostream &os, source_wrapper const &s) { } // namespace boost #ifdef BOOST_NETWORK_NO_LIB -#include +#include #endif #endif // BOOST_NETWORK_MESSAGE_WRAPPERS_SOURCE_HPP_20111021 diff --git a/include/network/message/wrappers/source.ipp b/include/network/message/wrappers/source.ipp index d6219b876..24c225a32 100644 --- a/include/network/message/wrappers/source.ipp +++ b/include/network/message/wrappers/source.ipp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { diff --git a/include/network/protocol.hpp b/include/network/protocol.hpp index 9810697b7..c712beaa9 100644 --- a/include/network/protocol.hpp +++ b/include/network/protocol.hpp @@ -11,6 +11,6 @@ // Author: Dean Michael Berris // Date Created: Oct. 08, 2007 -#include // include HTTP implementation +#include // include HTTP implementation #endif // __NETWORK_PROTOCOLS_20070908-1_HPP__ diff --git a/include/network/protocol/http.hpp b/include/network/protocol/http.hpp index 2304f6f8b..988ba87fb 100644 --- a/include/network/protocol/http.hpp +++ b/include/network/protocol/http.hpp @@ -11,9 +11,9 @@ // Author: Dean Michael Berris // Date Created: Oct. 08, 2007 -#include -#include -#include -#include +#include +#include +#include +#include #endif // __NETWORK_PROTOCOL_HTTP_20070908-1_HPP__ diff --git a/include/network/protocol/http/algorithms/linearize.hpp b/include/network/protocol/http/algorithms/linearize.hpp index cc13adf2c..4c0c04a5e 100644 --- a/include/network/protocol/http/algorithms/linearize.hpp +++ b/include/network/protocol/http/algorithms/linearize.hpp @@ -6,11 +6,11 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/include/network/protocol/http/client.hpp b/include/network/protocol/http/client.hpp index 7662e7cbf..6c5f05549 100644 --- a/include/network/protocol/http/client.hpp +++ b/include/network/protocol/http/client.hpp @@ -7,14 +7,14 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include +#include +#include #include -#include -#include -#include -#include +#include +#include +#include +#include namespace boost { namespace network { namespace http { @@ -46,7 +46,7 @@ struct client : basic_client_facade { } // namespace boost #ifdef BOOST_NETWORK_NO_LIB -#include +#include #endif #endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_20091215 diff --git a/include/network/protocol/http/client.ipp b/include/network/protocol/http/client.ipp index 9b6d3d004..ffe1f833f 100644 --- a/include/network/protocol/http/client.ipp +++ b/include/network/protocol/http/client.ipp @@ -7,9 +7,9 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include -#include +#include +#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/client/base.ipp b/include/network/protocol/http/client/base.ipp index dadc3a3da..7c0492e44 100644 --- a/include/network/protocol/http/client/base.ipp +++ b/include/network/protocol/http/client/base.ipp @@ -7,16 +7,16 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include +#include +#include #include #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/client/client_connection.ipp b/include/network/protocol/http/client/client_connection.ipp index bb4ac9eff..faf6d70cb 100644 --- a/include/network/protocol/http/client/client_connection.ipp +++ b/include/network/protocol/http/client/client_connection.ipp @@ -7,9 +7,9 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/client/connection/async_normal.hpp b/include/network/protocol/http/client/connection/async_normal.hpp index 1408e4276..2a3050c4d 100644 --- a/include/network/protocol/http/client/connection/async_normal.hpp +++ b/include/network/protocol/http/client/connection/async_normal.hpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include namespace boost { namespace asio { diff --git a/include/network/protocol/http/client/connection/async_normal.ipp b/include/network/protocol/http/client/connection/async_normal.ipp index 5198a53ea..81d80a18f 100644 --- a/include/network/protocol/http/client/connection/async_normal.ipp +++ b/include/network/protocol/http/client/connection/async_normal.ipp @@ -8,15 +8,15 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include -#include +#include #ifdef BOOST_NETWORK_ENABLE_HTTPS #include #endif diff --git a/include/network/protocol/http/client/connection/async_protocol_handler.hpp b/include/network/protocol/http/client/connection/async_protocol_handler.hpp index 9f706635b..d45270aeb 100644 --- a/include/network/protocol/http/client/connection/async_protocol_handler.hpp +++ b/include/network/protocol/http/client/connection/async_protocol_handler.hpp @@ -8,8 +8,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include +#include +#include namespace boost { namespace network { namespace http { namespace impl { diff --git a/include/network/protocol/http/client/connection/async_resolver.hpp b/include/network/protocol/http/client/connection/async_resolver.hpp index dc6dfd151..fb5a8e517 100644 --- a/include/network/protocol/http/client/connection/async_resolver.hpp +++ b/include/network/protocol/http/client/connection/async_resolver.hpp @@ -8,7 +8,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include +#include namespace boost { namespace network { namespace http { @@ -37,7 +37,7 @@ struct async_resolver : resolver_delegate { } // namespace boost #ifdef BOOST_NETWORK_NO_LIB -#include +#include #endif #endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_RESOLVER_20111126 diff --git a/include/network/protocol/http/client/connection/async_resolver.ipp b/include/network/protocol/http/client/connection/async_resolver.ipp index e5dad6151..096ad70f5 100644 --- a/include/network/protocol/http/client/connection/async_resolver.ipp +++ b/include/network/protocol/http/client/connection/async_resolver.ipp @@ -21,7 +21,7 @@ #include #include #include -#include +#include namespace boost { namespace network { namespace http { struct async_resolver_pimpl : enable_shared_from_this { diff --git a/include/network/protocol/http/client/connection/connection_delegate_factory.hpp b/include/network/protocol/http/client/connection/connection_delegate_factory.hpp index 4a9923ad2..489b327d5 100644 --- a/include/network/protocol/http/client/connection/connection_delegate_factory.hpp +++ b/include/network/protocol/http/client/connection/connection_delegate_factory.hpp @@ -8,7 +8,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/client/connection/connection_delegate_factory.ipp b/include/network/protocol/http/client/connection/connection_delegate_factory.ipp index d807f6f4c..3c90a9764 100644 --- a/include/network/protocol/http/client/connection/connection_delegate_factory.ipp +++ b/include/network/protocol/http/client/connection/connection_delegate_factory.ipp @@ -7,14 +7,14 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #ifdef BOOST_NETWORK_ENABLE_HTTPS -#include +#include #endif /* BOOST_NETWORK_ENABLE_HTTPS */ -#include -#include -#include +#include +#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/client/connection/connection_factory.ipp b/include/network/protocol/http/client/connection/connection_factory.ipp index fb8004dcd..471faa5a3 100644 --- a/include/network/protocol/http/client/connection/connection_factory.ipp +++ b/include/network/protocol/http/client/connection/connection_factory.ipp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/client/connection/normal_delegate.hpp b/include/network/protocol/http/client/connection/normal_delegate.hpp index 24f697949..4b1f0b21b 100644 --- a/include/network/protocol/http/client/connection/normal_delegate.hpp +++ b/include/network/protocol/http/client/connection/normal_delegate.hpp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include namespace boost { namespace asio { diff --git a/include/network/protocol/http/client/connection/normal_delegate.ipp b/include/network/protocol/http/client/connection/normal_delegate.ipp index 2dda88fbd..f071bffa7 100644 --- a/include/network/protocol/http/client/connection/normal_delegate.ipp +++ b/include/network/protocol/http/client/connection/normal_delegate.ipp @@ -12,8 +12,8 @@ #include #include #include -#include -#include +#include +#include boost::network::http::normal_delegate::normal_delegate(asio::io_service & service) : service_(service) diff --git a/include/network/protocol/http/client/connection/resolver_delegate.ipp b/include/network/protocol/http/client/connection/resolver_delegate.ipp index 4a9c06a2d..c1512ec1c 100644 --- a/include/network/protocol/http/client/connection/resolver_delegate.ipp +++ b/include/network/protocol/http/client/connection/resolver_delegate.ipp @@ -7,8 +7,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include +#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/client/connection/resolver_delegate_factory.hpp b/include/network/protocol/http/client/connection/resolver_delegate_factory.hpp index 48628eac4..a128eee46 100644 --- a/include/network/protocol/http/client/connection/resolver_delegate_factory.hpp +++ b/include/network/protocol/http/client/connection/resolver_delegate_factory.hpp @@ -8,8 +8,8 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include -#include +#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/client/connection/resolver_delegate_factory.ipp b/include/network/protocol/http/client/connection/resolver_delegate_factory.ipp index 16d37de66..87f5720d9 100644 --- a/include/network/protocol/http/client/connection/resolver_delegate_factory.ipp +++ b/include/network/protocol/http/client/connection/resolver_delegate_factory.ipp @@ -7,9 +7,9 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include -#include +#include +#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/client/connection/simple_connection_factory.hpp b/include/network/protocol/http/client/connection/simple_connection_factory.hpp index 00a2c2ab6..1c3c02e9a 100644 --- a/include/network/protocol/http/client/connection/simple_connection_factory.hpp +++ b/include/network/protocol/http/client/connection/simple_connection_factory.hpp @@ -9,9 +9,9 @@ #include #include -#include -#include -#include +#include +#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/client/connection/simple_connection_factory.ipp b/include/network/protocol/http/client/connection/simple_connection_factory.ipp index 762706cac..c4ee55e73 100644 --- a/include/network/protocol/http/client/connection/simple_connection_factory.ipp +++ b/include/network/protocol/http/client/connection/simple_connection_factory.ipp @@ -7,18 +7,18 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #ifdef BOOST_NETWORK_DEBUG #include #endif #include -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/client/connection/ssl_delegate.hpp b/include/network/protocol/http/client/connection/ssl_delegate.hpp index 9e33b0bdb..50eb354df 100644 --- a/include/network/protocol/http/client/connection/ssl_delegate.hpp +++ b/include/network/protocol/http/client/connection/ssl_delegate.hpp @@ -8,8 +8,8 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include -#include +#include +#include #include namespace boost { namespace asio { diff --git a/include/network/protocol/http/client/connection/ssl_delegate.ipp b/include/network/protocol/http/client/connection/ssl_delegate.ipp index b5970addb..0f1811bfc 100755 --- a/include/network/protocol/http/client/connection/ssl_delegate.ipp +++ b/include/network/protocol/http/client/connection/ssl_delegate.ipp @@ -7,11 +7,11 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include +#include +#include #include #include -#include +#include boost::network::http::ssl_delegate::ssl_delegate(asio::io_service & service, client_options const &options) : diff --git a/include/network/protocol/http/client/connection/sync_base.hpp b/include/network/protocol/http/client/connection/sync_base.hpp index 1df519b9f..cd2c5a6c4 100644 --- a/include/network/protocol/http/client/connection/sync_base.hpp +++ b/include/network/protocol/http/client/connection/sync_base.hpp @@ -6,19 +6,19 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include -#include +#include +#include +#include #include #include #include #include #include -#include +#include -#include +#include #ifdef BOOST_NETWORK_ENABLE_HTTPS -#include +#include #endif namespace boost { namespace network { namespace http { namespace impl { diff --git a/include/network/protocol/http/client/connection/sync_normal.hpp b/include/network/protocol/http/client/connection/sync_normal.hpp index 18add4b4d..4fa7009bd 100644 --- a/include/network/protocol/http/client/connection/sync_normal.hpp +++ b/include/network/protocol/http/client/connection/sync_normal.hpp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include namespace boost { namespace network { namespace http { namespace impl { diff --git a/include/network/protocol/http/client/connection_manager.hpp b/include/network/protocol/http/client/connection_manager.hpp index 062b7d742..5f424ea56 100644 --- a/include/network/protocol/http/client/connection_manager.hpp +++ b/include/network/protocol/http/client/connection_manager.hpp @@ -40,7 +40,7 @@ struct connection_manager { } /* boost */ #ifdef BOOST_NETWORK_NO_LIB -#include +#include #endif #endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_MANAGER_HPP_20110930 */ diff --git a/include/network/protocol/http/client/connection_manager.ipp b/include/network/protocol/http/client/connection_manager.ipp index 44539a806..79871615b 100644 --- a/include/network/protocol/http/client/connection_manager.ipp +++ b/include/network/protocol/http/client/connection_manager.ipp @@ -7,8 +7,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include +#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/client/facade.hpp b/include/network/protocol/http/client/facade.hpp index e10d1fbf2..85b92f373 100644 --- a/include/network/protocol/http/client/facade.hpp +++ b/include/network/protocol/http/client/facade.hpp @@ -6,10 +6,10 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include -#include -#include +#include +#include +#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/client/facade.ipp b/include/network/protocol/http/client/facade.ipp index 7f626285d..72fd44c31 100644 --- a/include/network/protocol/http/client/facade.ipp +++ b/include/network/protocol/http/client/facade.ipp @@ -1,8 +1,8 @@ #ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_FACADE_IPP_20120303 #define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_FACADE_IPP_20120303 -#include -#include +#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/client/options.hpp b/include/network/protocol/http/client/options.hpp index 21efc74b2..c0e9b4aa8 100644 --- a/include/network/protocol/http/client/options.hpp +++ b/include/network/protocol/http/client/options.hpp @@ -11,9 +11,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/client/options.ipp b/include/network/protocol/http/client/options.ipp index 3df7151e9..0b9c4850b 100644 --- a/include/network/protocol/http/client/options.ipp +++ b/include/network/protocol/http/client/options.ipp @@ -7,9 +7,9 @@ #ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_OPTIONS_IPP #define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_OPTIONS_IPP -#include -#include -#include +#include +#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/client/parameters.hpp b/include/network/protocol/http/client/parameters.hpp index 340e9506e..30d5656d4 100644 --- a/include/network/protocol/http/client/parameters.hpp +++ b/include/network/protocol/http/client/parameters.hpp @@ -6,7 +6,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/client/pimpl.hpp b/include/network/protocol/http/client/pimpl.hpp index 2f0cab2af..cd36ffa09 100644 --- a/include/network/protocol/http/client/pimpl.hpp +++ b/include/network/protocol/http/client/pimpl.hpp @@ -11,8 +11,8 @@ #include #include -#include -#include +#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/client/simple_connection_manager.hpp b/include/network/protocol/http/client/simple_connection_manager.hpp index ec0382df3..5ba71d425 100644 --- a/include/network/protocol/http/client/simple_connection_manager.hpp +++ b/include/network/protocol/http/client/simple_connection_manager.hpp @@ -8,8 +8,8 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include -#include +#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/client/simple_connection_manager.ipp b/include/network/protocol/http/client/simple_connection_manager.ipp index 0b0bd0a11..e86574c08 100644 --- a/include/network/protocol/http/client/simple_connection_manager.ipp +++ b/include/network/protocol/http/client/simple_connection_manager.ipp @@ -7,10 +7,10 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include -#include -#include +#include +#include +#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/client_fwd.hpp b/include/network/protocol/http/client_fwd.hpp index de67671f7..ebb1e9685 100644 --- a/include/network/protocol/http/client_fwd.hpp +++ b/include/network/protocol/http/client_fwd.hpp @@ -7,7 +7,7 @@ #ifndef __NETWORK_PROTOCOL_HTTP_CLIENT_20080923_1_HPP__ #define __NETWORK_PROTOCOL_HTTP_CLIENT_20080923_1_HPP__ -#include +#include #include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/impl/access.hpp b/include/network/protocol/http/impl/access.hpp index ea38f56f6..402214f6a 100644 --- a/include/network/protocol/http/impl/access.hpp +++ b/include/network/protocol/http/impl/access.hpp @@ -34,7 +34,7 @@ struct setter_access { } // namespace boost #ifdef BOOST_NETWORK_NO_LIB -#include +#include #endif #endif // BOOST_NETWORK_PROTOCOL_HTTP_IMPL_ACCESS_HPP_20111202 diff --git a/include/network/protocol/http/impl/access.ipp b/include/network/protocol/http/impl/access.ipp index 752f48d8f..c5fdc049d 100644 --- a/include/network/protocol/http/impl/access.ipp +++ b/include/network/protocol/http/impl/access.ipp @@ -1,7 +1,7 @@ #ifndef BOOST_NETWORK_PROTOCOL_HTTP_IMPL_ACCESS_IPP_20111202 #define BOOST_NETWORK_PROTOCOL_HTTP_IMPL_ACCESS_IPP_20111202 -#include +#include namespace boost { namespace network { namespace http { namespace impl { diff --git a/include/network/protocol/http/impl/message.ipp b/include/network/protocol/http/impl/message.ipp index b2875092d..4c0d68203 100644 --- a/include/network/protocol/http/impl/message.ipp +++ b/include/network/protocol/http/impl/message.ipp @@ -10,7 +10,7 @@ #ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_IPP #define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_IPP -#include +#include #include #include #include diff --git a/include/network/protocol/http/impl/parser.ipp b/include/network/protocol/http/impl/parser.ipp index 893319bb8..e392facbe 100644 --- a/include/network/protocol/http/impl/parser.ipp +++ b/include/network/protocol/http/impl/parser.ipp @@ -10,7 +10,7 @@ #ifndef BOOST_NETWORK_PROTOCOL_HTTP_PARSER_IPP #define BOOST_NETWORK_PROTOCOL_HTTP_PARSER_IPP -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/impl/request.hpp b/include/network/protocol/http/impl/request.hpp index af0aab56d..776f14892 100644 --- a/include/network/protocol/http/impl/request.hpp +++ b/include/network/protocol/http/impl/request.hpp @@ -8,20 +8,20 @@ #ifndef __NETWORK_PROTOCOL_HTTP_REQUEST_IMPL_20070908_1_HPP__ #define __NETWORK_PROTOCOL_HTTP_REQUEST_IMPL_20070908_1_HPP__ -#include -#include +#include +#include #include #include #include #include -#include -#include +#include +#include -#include -#include -#include +#include +#include +#include #include diff --git a/include/network/protocol/http/impl/request_parser.ipp b/include/network/protocol/http/impl/request_parser.ipp index 071e64f20..59493b6ac 100644 --- a/include/network/protocol/http/impl/request_parser.ipp +++ b/include/network/protocol/http/impl/request_parser.ipp @@ -15,7 +15,7 @@ #ifndef BOOST_NETWORK_HTTP_REQUEST_PARSER_IPP #define BOOST_NETWORK_HTTP_REQUEST_PARSER_IPP -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/impl/response.ipp b/include/network/protocol/http/impl/response.ipp index 5780ef24e..43aa2bc34 100644 --- a/include/network/protocol/http/impl/response.ipp +++ b/include/network/protocol/http/impl/response.ipp @@ -16,7 +16,7 @@ #include #include -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/async_message.hpp b/include/network/protocol/http/message/async_message.hpp index 39b16fd27..9b0e01ed3 100644 --- a/include/network/protocol/http/message/async_message.hpp +++ b/include/network/protocol/http/message/async_message.hpp @@ -16,7 +16,7 @@ //FIXME move this out to a trait #include #include -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/directives.hpp b/include/network/protocol/http/message/directives.hpp index a923e716f..f247f915c 100644 --- a/include/network/protocol/http/message/directives.hpp +++ b/include/network/protocol/http/message/directives.hpp @@ -7,10 +7,10 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_HPP_20111201 diff --git a/include/network/protocol/http/message/directives/minor_version.hpp b/include/network/protocol/http/message/directives/minor_version.hpp index 2dbfe0a55..3e0a2b2e8 100644 --- a/include/network/protocol/http/message/directives/minor_version.hpp +++ b/include/network/protocol/http/message/directives/minor_version.hpp @@ -6,7 +6,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include #include diff --git a/include/network/protocol/http/message/directives/status.hpp b/include/network/protocol/http/message/directives/status.hpp index ff1afea43..bd7ecb91f 100644 --- a/include/network/protocol/http/message/directives/status.hpp +++ b/include/network/protocol/http/message/directives/status.hpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/directives/status_message.hpp b/include/network/protocol/http/message/directives/status_message.hpp index 63c621b8f..dde19a27a 100644 --- a/include/network/protocol/http/message/directives/status_message.hpp +++ b/include/network/protocol/http/message/directives/status_message.hpp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/directives/uri.hpp b/include/network/protocol/http/message/directives/uri.hpp index b7acb68c0..81fdfb1a5 100644 --- a/include/network/protocol/http/message/directives/uri.hpp +++ b/include/network/protocol/http/message/directives/uri.hpp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/directives/version.hpp b/include/network/protocol/http/message/directives/version.hpp index 2d4eec0fd..092640069 100644 --- a/include/network/protocol/http/message/directives/version.hpp +++ b/include/network/protocol/http/message/directives/version.hpp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/header/name.hpp b/include/network/protocol/http/message/header/name.hpp index 712ea312c..0d6ac61a8 100644 --- a/include/network/protocol/http/message/header/name.hpp +++ b/include/network/protocol/http/message/header/name.hpp @@ -6,7 +6,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/modifiers.hpp b/include/network/protocol/http/message/modifiers.hpp index e14a3ff0a..9529d6312 100644 --- a/include/network/protocol/http/message/modifiers.hpp +++ b/include/network/protocol/http/message/modifiers.hpp @@ -7,10 +7,10 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_HPP_20111201 diff --git a/include/network/protocol/http/message/modifiers/major_version.hpp b/include/network/protocol/http/message/modifiers/major_version.hpp index e1510c678..fe4a908ca 100644 --- a/include/network/protocol/http/message/modifiers/major_version.hpp +++ b/include/network/protocol/http/message/modifiers/major_version.hpp @@ -6,7 +6,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include #include diff --git a/include/network/protocol/http/message/modifiers/method.hpp b/include/network/protocol/http/message/modifiers/method.hpp index 98a747f0b..4883f84c0 100644 --- a/include/network/protocol/http/message/modifiers/method.hpp +++ b/include/network/protocol/http/message/modifiers/method.hpp @@ -6,7 +6,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/modifiers/minor_version.hpp b/include/network/protocol/http/message/modifiers/minor_version.hpp index e70c32a6d..cb9afa5e3 100644 --- a/include/network/protocol/http/message/modifiers/minor_version.hpp +++ b/include/network/protocol/http/message/modifiers/minor_version.hpp @@ -6,7 +6,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include #include diff --git a/include/network/protocol/http/message/modifiers/status.hpp b/include/network/protocol/http/message/modifiers/status.hpp index cb33820bd..10cff038a 100644 --- a/include/network/protocol/http/message/modifiers/status.hpp +++ b/include/network/protocol/http/message/modifiers/status.hpp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/modifiers/status_message.hpp b/include/network/protocol/http/message/modifiers/status_message.hpp index ad12bf637..c051479a0 100644 --- a/include/network/protocol/http/message/modifiers/status_message.hpp +++ b/include/network/protocol/http/message/modifiers/status_message.hpp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/modifiers/uri.hpp b/include/network/protocol/http/message/modifiers/uri.hpp index a106cf7be..f00093c71 100644 --- a/include/network/protocol/http/message/modifiers/uri.hpp +++ b/include/network/protocol/http/message/modifiers/uri.hpp @@ -8,7 +8,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/modifiers/version.hpp b/include/network/protocol/http/message/modifiers/version.hpp index 1af1ac567..363205e79 100644 --- a/include/network/protocol/http/message/modifiers/version.hpp +++ b/include/network/protocol/http/message/modifiers/version.hpp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/wrappers.hpp b/include/network/protocol/http/message/wrappers.hpp index cc75c9e32..9186965ab 100644 --- a/include/network/protocol/http/message/wrappers.hpp +++ b/include/network/protocol/http/message/wrappers.hpp @@ -7,18 +7,18 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_HPP_20111201 diff --git a/include/network/protocol/http/message/wrappers/anchor.hpp b/include/network/protocol/http/message/wrappers/anchor.hpp index 7a23b74c5..d7b1716b7 100644 --- a/include/network/protocol/http/message/wrappers/anchor.hpp +++ b/include/network/protocol/http/message/wrappers/anchor.hpp @@ -8,7 +8,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/wrappers/anchor.ipp b/include/network/protocol/http/message/wrappers/anchor.ipp index a29bed667..6742623d8 100644 --- a/include/network/protocol/http/message/wrappers/anchor.ipp +++ b/include/network/protocol/http/message/wrappers/anchor.ipp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/wrappers/host.hpp b/include/network/protocol/http/message/wrappers/host.hpp index 0b33511d4..af4e0bff2 100644 --- a/include/network/protocol/http/message/wrappers/host.hpp +++ b/include/network/protocol/http/message/wrappers/host.hpp @@ -8,7 +8,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/wrappers/host.ipp b/include/network/protocol/http/message/wrappers/host.ipp index 54158f8e3..a90a7cecc 100644 --- a/include/network/protocol/http/message/wrappers/host.ipp +++ b/include/network/protocol/http/message/wrappers/host.ipp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/wrappers/major_version.hpp b/include/network/protocol/http/message/wrappers/major_version.hpp index 7b71736a3..c1b69f167 100644 --- a/include/network/protocol/http/message/wrappers/major_version.hpp +++ b/include/network/protocol/http/message/wrappers/major_version.hpp @@ -7,7 +7,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include +#include #include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/wrappers/method.hpp b/include/network/protocol/http/message/wrappers/method.hpp index 0219d69b5..6c8c375f5 100644 --- a/include/network/protocol/http/message/wrappers/method.hpp +++ b/include/network/protocol/http/message/wrappers/method.hpp @@ -6,7 +6,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/wrappers/minor_version.hpp b/include/network/protocol/http/message/wrappers/minor_version.hpp index b105227a4..27e4bfd05 100644 --- a/include/network/protocol/http/message/wrappers/minor_version.hpp +++ b/include/network/protocol/http/message/wrappers/minor_version.hpp @@ -7,7 +7,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include +#include #include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/wrappers/path.hpp b/include/network/protocol/http/message/wrappers/path.hpp index 8adfe608d..0e0b8f173 100644 --- a/include/network/protocol/http/message/wrappers/path.hpp +++ b/include/network/protocol/http/message/wrappers/path.hpp @@ -8,7 +8,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/wrappers/path.ipp b/include/network/protocol/http/message/wrappers/path.ipp index 25272a8c5..b95669963 100644 --- a/include/network/protocol/http/message/wrappers/path.ipp +++ b/include/network/protocol/http/message/wrappers/path.ipp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/wrappers/port.hpp b/include/network/protocol/http/message/wrappers/port.hpp index 62a3e45ba..8ba29b121 100644 --- a/include/network/protocol/http/message/wrappers/port.hpp +++ b/include/network/protocol/http/message/wrappers/port.hpp @@ -8,7 +8,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/wrappers/port.ipp b/include/network/protocol/http/message/wrappers/port.ipp index fddceb3be..c9a5c1f1c 100644 --- a/include/network/protocol/http/message/wrappers/port.ipp +++ b/include/network/protocol/http/message/wrappers/port.ipp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/wrappers/protocol.hpp b/include/network/protocol/http/message/wrappers/protocol.hpp index 0a069fe4a..be12836a4 100644 --- a/include/network/protocol/http/message/wrappers/protocol.hpp +++ b/include/network/protocol/http/message/wrappers/protocol.hpp @@ -8,7 +8,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/wrappers/query.hpp b/include/network/protocol/http/message/wrappers/query.hpp index d3f04e157..c95477214 100644 --- a/include/network/protocol/http/message/wrappers/query.hpp +++ b/include/network/protocol/http/message/wrappers/query.hpp @@ -8,7 +8,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/wrappers/query.ipp b/include/network/protocol/http/message/wrappers/query.ipp index 3b1f4d24d..260f712f3 100644 --- a/include/network/protocol/http/message/wrappers/query.ipp +++ b/include/network/protocol/http/message/wrappers/query.ipp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/wrappers/ready.hpp b/include/network/protocol/http/message/wrappers/ready.hpp index b45ee4277..1ea06574e 100644 --- a/include/network/protocol/http/message/wrappers/ready.hpp +++ b/include/network/protocol/http/message/wrappers/ready.hpp @@ -6,7 +6,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/wrappers/status.ipp b/include/network/protocol/http/message/wrappers/status.ipp index 338176d06..b42c71a35 100644 --- a/include/network/protocol/http/message/wrappers/status.ipp +++ b/include/network/protocol/http/message/wrappers/status.ipp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/wrappers/status_message.hpp b/include/network/protocol/http/message/wrappers/status_message.hpp index a9258026c..50076d245 100644 --- a/include/network/protocol/http/message/wrappers/status_message.hpp +++ b/include/network/protocol/http/message/wrappers/status_message.hpp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/wrappers/status_message.ipp b/include/network/protocol/http/message/wrappers/status_message.ipp index da76cb7ba..5690407e5 100644 --- a/include/network/protocol/http/message/wrappers/status_message.ipp +++ b/include/network/protocol/http/message/wrappers/status_message.ipp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/wrappers/uri.hpp b/include/network/protocol/http/message/wrappers/uri.hpp index 8e56dacb9..f577fb4d5 100644 --- a/include/network/protocol/http/message/wrappers/uri.hpp +++ b/include/network/protocol/http/message/wrappers/uri.hpp @@ -8,7 +8,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/wrappers/uri.ipp b/include/network/protocol/http/message/wrappers/uri.ipp index d3a24d30e..6ecb92111 100644 --- a/include/network/protocol/http/message/wrappers/uri.ipp +++ b/include/network/protocol/http/message/wrappers/uri.ipp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/wrappers/version.hpp b/include/network/protocol/http/message/wrappers/version.hpp index b166758b6..ce3378719 100644 --- a/include/network/protocol/http/message/wrappers/version.hpp +++ b/include/network/protocol/http/message/wrappers/version.hpp @@ -8,7 +8,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/wrappers/version.ipp b/include/network/protocol/http/message/wrappers/version.ipp index 9620b01b0..85ff99deb 100644 --- a/include/network/protocol/http/message/wrappers/version.ipp +++ b/include/network/protocol/http/message/wrappers/version.ipp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/parser.hpp b/include/network/protocol/http/parser.hpp index a7bd42ff4..bf7cd62b8 100644 --- a/include/network/protocol/http/parser.hpp +++ b/include/network/protocol/http/parser.hpp @@ -10,9 +10,9 @@ #ifndef BOOST_NETWORK_PROTOCOL_HTTP_PARSER_HPP #define BOOST_NETWORK_PROTOCOL_HTTP_PARSER_HPP -#include -#include -#include +#include +#include +#include #include #include #include @@ -309,6 +309,6 @@ namespace boost { namespace network { namespace http { }; // namespace boost // import implementation file -#include +#include #endif // BOOST_NETWORK_PROTOCOL_HTTP_PARSER_HPP diff --git a/include/network/protocol/http/policies/async_connection.hpp b/include/network/protocol/http/policies/async_connection.hpp index 3793fba43..394172aae 100644 --- a/include/network/protocol/http/policies/async_connection.hpp +++ b/include/network/protocol/http/policies/async_connection.hpp @@ -9,7 +9,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include #include #include @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/request.hpp b/include/network/protocol/http/request.hpp index e0ceaff0a..527ee00dc 100644 --- a/include/network/protocol/http/request.hpp +++ b/include/network/protocol/http/request.hpp @@ -8,6 +8,6 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #endif // BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_HPP_20111021 diff --git a/include/network/protocol/http/request/request.hpp b/include/network/protocol/http/request/request.hpp index a92fda54b..afe4d1ad2 100644 --- a/include/network/protocol/http/request/request.hpp +++ b/include/network/protocol/http/request/request.hpp @@ -7,10 +7,10 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include -#include -#include +#include +#include #include namespace boost { namespace network { namespace http { @@ -99,11 +99,11 @@ inline bool operator!=(request const &l, request const &r) { } // namespace boost -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #endif /* BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_REQUEST_HPP_20111021 */ diff --git a/include/network/protocol/http/request/request.ipp b/include/network/protocol/http/request/request.ipp index 70e6bbfed..7cff8fa62 100644 --- a/include/network/protocol/http/request/request.ipp +++ b/include/network/protocol/http/request/request.ipp @@ -7,8 +7,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include +#include +#include #include #ifdef BOOST_NETWORK_DEBUG diff --git a/include/network/protocol/http/request/request_base.hpp b/include/network/protocol/http/request/request_base.hpp index 91510430c..815735c14 100644 --- a/include/network/protocol/http/request/request_base.hpp +++ b/include/network/protocol/http/request/request_base.hpp @@ -11,7 +11,7 @@ #define BOOST_NETWORK_BUFFER_CHUNK 1024 // We want 1KiB worth of data at least. #endif -#include +#include #include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/request/request_base.ipp b/include/network/protocol/http/request/request_base.ipp index 712b5ca39..b819e139b 100644 --- a/include/network/protocol/http/request/request_base.ipp +++ b/include/network/protocol/http/request/request_base.ipp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include #include diff --git a/include/network/protocol/http/request/request_concept.hpp b/include/network/protocol/http/request/request_concept.hpp index e868b3a31..3dd550557 100644 --- a/include/network/protocol/http/request/request_concept.hpp +++ b/include/network/protocol/http/request/request_concept.hpp @@ -8,7 +8,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include +#include #include #include #include diff --git a/include/network/protocol/http/request_parser.hpp b/include/network/protocol/http/request_parser.hpp index c97f6f892..d2d6f7089 100644 --- a/include/network/protocol/http/request_parser.hpp +++ b/include/network/protocol/http/request_parser.hpp @@ -18,7 +18,7 @@ #include #include -#include +#include namespace boost { namespace network { namespace http { @@ -103,6 +103,6 @@ class request_parser } // namespace boost -#include +#include #endif // HTTP_SERVER3_REQUEST_PARSER_HPP diff --git a/include/network/protocol/http/response.hpp b/include/network/protocol/http/response.hpp index 70a9f0521..e30d37eec 100644 --- a/include/network/protocol/http/response.hpp +++ b/include/network/protocol/http/response.hpp @@ -9,23 +9,23 @@ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include +#include +#include #endif // BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_HPP diff --git a/include/network/protocol/http/response/response.hpp b/include/network/protocol/http/response/response.hpp index 915bddd8e..8786da87d 100644 --- a/include/network/protocol/http/response/response.hpp +++ b/include/network/protocol/http/response/response.hpp @@ -7,8 +7,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include +#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/response/response.ipp b/include/network/protocol/http/response/response.ipp index 138b9207b..884678af3 100644 --- a/include/network/protocol/http/response/response.ipp +++ b/include/network/protocol/http/response/response.ipp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/response/response_base.hpp b/include/network/protocol/http/response/response_base.hpp index 5d865b5b2..fbe4364c9 100644 --- a/include/network/protocol/http/response/response_base.hpp +++ b/include/network/protocol/http/response/response_base.hpp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { @@ -28,7 +28,7 @@ struct response_base : message_base { } /* boost */ #ifdef BOOST_NETWORK_NO_LIB -#include +#include #endif #endif /* BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_BASE_HPP_20110930 */ diff --git a/include/network/protocol/http/response/response_base.ipp b/include/network/protocol/http/response/response_base.ipp index 6ff547217..a7e54d357 100644 --- a/include/network/protocol/http/response/response_base.ipp +++ b/include/network/protocol/http/response/response_base.ipp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/response/response_concept.hpp b/include/network/protocol/http/response/response_concept.hpp index 25094ca40..b671b2134 100644 --- a/include/network/protocol/http/response/response_concept.hpp +++ b/include/network/protocol/http/response/response_concept.hpp @@ -8,7 +8,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include +#include #include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/server.hpp b/include/network/protocol/http/server.hpp index 98445db3a..e4553f69b 100644 --- a/include/network/protocol/http/server.hpp +++ b/include/network/protocol/http/server.hpp @@ -74,7 +74,7 @@ class async_server { // We're hiding the implementation from here, but still explicitly including // it here. This is mostly a style point, to keep this header clean. -#include +#include #endif // BOOST_NETWORK_HTTP_SERVER_HPP_ diff --git a/include/network/protocol/http/server/async_impl.hpp b/include/network/protocol/http/server/async_impl.hpp index 242d2b14a..4b2f7edc2 100644 --- a/include/network/protocol/http/server/async_impl.hpp +++ b/include/network/protocol/http/server/async_impl.hpp @@ -11,8 +11,8 @@ #include #include #include -#include -#include +#include +#include namespace boost { namespace network { namespace utils { diff --git a/include/network/protocol/http/server/async_impl.ipp b/include/network/protocol/http/server/async_impl.ipp index 9fffa483f..b7fcf8311 100644 --- a/include/network/protocol/http/server/async_impl.ipp +++ b/include/network/protocol/http/server/async_impl.ipp @@ -7,13 +7,13 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include +#include +#include #include #include #include #include -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/server/async_server.hpp b/include/network/protocol/http/server/async_server.hpp index c56af236e..f9b401974 100644 --- a/include/network/protocol/http/server/async_server.hpp +++ b/include/network/protocol/http/server/async_server.hpp @@ -6,12 +6,12 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include +#include +#include #include -#include -#include -#include +#include +#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/server/connection/async.hpp b/include/network/protocol/http/server/connection/async.hpp index bc8c65fa0..23e102f56 100644 --- a/include/network/protocol/http/server/connection/async.hpp +++ b/include/network/protocol/http/server/connection/async.hpp @@ -9,9 +9,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include #include #include @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include @@ -33,9 +33,9 @@ #include #include #ifdef BOOST_NETWORK_NO_LIB -#include +#include #endif -#include +#include #ifndef BOOST_NETWORK_HTTP_SERVER_CONNECTION_HEADER_BUFFER_MAX_SIZE /** Here we define a page's worth of header connection buffer data. diff --git a/include/network/protocol/http/server/connection/sync.hpp b/include/network/protocol/http/server/connection/sync.hpp index 3ed2107d3..19b7b908c 100644 --- a/include/network/protocol/http/server/connection/sync.hpp +++ b/include/network/protocol/http/server/connection/sync.hpp @@ -15,10 +15,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include diff --git a/include/network/protocol/http/server/impl/parsers.ipp b/include/network/protocol/http/server/impl/parsers.ipp index 7c20c7d34..c9cafb700 100644 --- a/include/network/protocol/http/server/impl/parsers.ipp +++ b/include/network/protocol/http/server/impl/parsers.ipp @@ -8,7 +8,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include #include diff --git a/include/network/protocol/http/server/impl/socket_options_setter.ipp b/include/network/protocol/http/server/impl/socket_options_setter.ipp index b20c3d4bc..7622cc03d 100644 --- a/include/network/protocol/http/server/impl/socket_options_setter.ipp +++ b/include/network/protocol/http/server/impl/socket_options_setter.ipp @@ -7,8 +7,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include +#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/server/options.ipp b/include/network/protocol/http/server/options.ipp index 890cdae21..87a10b64f 100644 --- a/include/network/protocol/http/server/options.ipp +++ b/include/network/protocol/http/server/options.ipp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/server/parameters.hpp b/include/network/protocol/http/server/parameters.hpp index 06b59b174..6ae494238 100644 --- a/include/network/protocol/http/server/parameters.hpp +++ b/include/network/protocol/http/server/parameters.hpp @@ -6,7 +6,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/server/server.ipp b/include/network/protocol/http/server/server.ipp index 6fa6c390b..3247d6f7a 100644 --- a/include/network/protocol/http/server/server.ipp +++ b/include/network/protocol/http/server/server.ipp @@ -7,9 +7,9 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include -#include +#include +#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/server/socket_options_base.hpp b/include/network/protocol/http/server/socket_options_base.hpp index 0563272a6..65be8552c 100644 --- a/include/network/protocol/http/server/socket_options_base.hpp +++ b/include/network/protocol/http/server/socket_options_base.hpp @@ -6,7 +6,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include #include diff --git a/include/network/protocol/http/server/storage_base.hpp b/include/network/protocol/http/server/storage_base.hpp index ccfe3fd12..0943e6a7f 100644 --- a/include/network/protocol/http/server/storage_base.hpp +++ b/include/network/protocol/http/server/storage_base.hpp @@ -6,7 +6,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/server/sync_impl.hpp b/include/network/protocol/http/server/sync_impl.hpp index 49ee45cb5..e5ff76a0d 100644 --- a/include/network/protocol/http/server/sync_impl.hpp +++ b/include/network/protocol/http/server/sync_impl.hpp @@ -11,8 +11,8 @@ #include #include #include -#include -#include +#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/server/sync_impl.ipp b/include/network/protocol/http/server/sync_impl.ipp index d67cbbeaa..dce2e7353 100644 --- a/include/network/protocol/http/server/sync_impl.ipp +++ b/include/network/protocol/http/server/sync_impl.ipp @@ -7,9 +7,9 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include -#include +#include +#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/server/sync_server.hpp b/include/network/protocol/http/server/sync_server.hpp index 71619bce3..8c41839d8 100644 --- a/include/network/protocol/http/server/sync_server.hpp +++ b/include/network/protocol/http/server/sync_server.hpp @@ -8,17 +8,17 @@ #ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_SYNC_SERVER_HPP_20101025 #define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_SYNC_SERVER_HPP_20101025 -#include +#include #include #include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/support/client_or_server.hpp b/include/network/protocol/http/support/client_or_server.hpp index 2ad74b105..e4e3eb41b 100644 --- a/include/network/protocol/http/support/client_or_server.hpp +++ b/include/network/protocol/http/support/client_or_server.hpp @@ -6,8 +6,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include +#include +#include #include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/support/is_http.hpp b/include/network/protocol/http/support/is_http.hpp index 163c3f5f2..d87374526 100644 --- a/include/network/protocol/http/support/is_http.hpp +++ b/include/network/protocol/http/support/is_http.hpp @@ -6,7 +6,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/support/is_keepalive.hpp b/include/network/protocol/http/support/is_keepalive.hpp index c3fa73a07..714328897 100644 --- a/include/network/protocol/http/support/is_keepalive.hpp +++ b/include/network/protocol/http/support/is_keepalive.hpp @@ -6,7 +6,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/support/is_simple.hpp b/include/network/protocol/http/support/is_simple.hpp index 730648f54..720e250ad 100644 --- a/include/network/protocol/http/support/is_simple.hpp +++ b/include/network/protocol/http/support/is_simple.hpp @@ -6,7 +6,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/support/sync_only.hpp b/include/network/protocol/http/support/sync_only.hpp index c9238c254..9198ec847 100644 --- a/include/network/protocol/http/support/sync_only.hpp +++ b/include/network/protocol/http/support/sync_only.hpp @@ -6,8 +6,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include +#include +#include namespace boost { namespace network { namespace http { diff --git a/include/network/utils/thread_pool.ipp b/include/network/utils/thread_pool.ipp index 582739368..96ded564c 100644 --- a/include/network/utils/thread_pool.ipp +++ b/include/network/utils/thread_pool.ipp @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include namespace boost { namespace network { namespace utils { diff --git a/libs/network/example/atom/atom.hpp b/libs/network/example/atom/atom.hpp index b19e4146a..909d69bc9 100644 --- a/libs/network/example/atom/atom.hpp +++ b/libs/network/example/atom/atom.hpp @@ -9,7 +9,7 @@ # include # include -# include +# include namespace boost { diff --git a/libs/network/example/atom/main.cpp b/libs/network/example/atom/main.cpp index b419db720..3c3ab09de 100644 --- a/libs/network/example/atom/main.cpp +++ b/libs/network/example/atom/main.cpp @@ -5,7 +5,7 @@ #include "atom.hpp" -#include +#include #include #include diff --git a/libs/network/example/http/fileserver.cpp b/libs/network/example/http/fileserver.cpp index 076680385..00652177f 100644 --- a/libs/network/example/http/fileserver.cpp +++ b/libs/network/example/http/fileserver.cpp @@ -3,7 +3,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include #include #include diff --git a/libs/network/example/http/hello_world_client.cpp b/libs/network/example/http/hello_world_client.cpp index 333c389d9..1d30e8cec 100644 --- a/libs/network/example/http/hello_world_client.cpp +++ b/libs/network/example/http/hello_world_client.cpp @@ -11,7 +11,7 @@ to the `hello_world_server`, then the output is simply "Hello, World!". */ -#include +#include #include diff --git a/libs/network/example/http/hello_world_server.cpp b/libs/network/example/http/hello_world_server.cpp index bfe2b8be5..87e88867d 100644 --- a/libs/network/example/http/hello_world_server.cpp +++ b/libs/network/example/http/hello_world_server.cpp @@ -11,7 +11,7 @@ demonstrate how easy it is to set up an HTTP server. All we do in this example is create a request handler and run the server. */ -#include +#include #include diff --git a/libs/network/example/http/one_liner.cpp b/libs/network/example/http/one_liner.cpp index 86a98d763..aa0a990b9 100644 --- a/libs/network/example/http/one_liner.cpp +++ b/libs/network/example/http/one_liner.cpp @@ -9,7 +9,7 @@ /*` */ -#include +#include using namespace std; diff --git a/libs/network/example/http_client.cpp b/libs/network/example/http_client.cpp index 1f8264a04..056360af9 100644 --- a/libs/network/example/http_client.cpp +++ b/libs/network/example/http_client.cpp @@ -10,7 +10,7 @@ the resource to the console. */ #include -#include +#include #include #include #include diff --git a/libs/network/example/http_client1.cpp b/libs/network/example/http_client1.cpp index 8bdbc0352..7e641df45 100644 --- a/libs/network/example/http_client1.cpp +++ b/libs/network/example/http_client1.cpp @@ -4,7 +4,7 @@ // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include int main(int argc, char * argv[]) { diff --git a/libs/network/example/rss/main.cpp b/libs/network/example/rss/main.cpp index 141f7c335..138b4fe75 100644 --- a/libs/network/example/rss/main.cpp +++ b/libs/network/example/rss/main.cpp @@ -5,7 +5,7 @@ #include "rss.hpp" -#include +#include #include #include diff --git a/libs/network/example/rss/rss.hpp b/libs/network/example/rss/rss.hpp index 12acd4ad0..067ef8360 100644 --- a/libs/network/example/rss/rss.hpp +++ b/libs/network/example/rss/rss.hpp @@ -9,7 +9,7 @@ # include # include -# include +# include namespace boost { diff --git a/libs/network/example/simple_wget.cpp b/libs/network/example/simple_wget.cpp index 760b82c8a..28e8f43f3 100644 --- a/libs/network/example/simple_wget.cpp +++ b/libs/network/example/simple_wget.cpp @@ -14,7 +14,7 @@ */ -#include +#include #include #include #include diff --git a/libs/network/example/twitter/search.cpp b/libs/network/example/twitter/search.cpp index d4e4d8db6..2a99d8b63 100644 --- a/libs/network/example/twitter/search.cpp +++ b/libs/network/example/twitter/search.cpp @@ -4,7 +4,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include +#include #include "rapidjson/rapidjson.h" #include "rapidjson/document.h" #include diff --git a/libs/network/src/client.cpp b/libs/network/src/client.cpp index 3ce8c1f19..c85c3e368 100644 --- a/libs/network/src/client.cpp +++ b/libs/network/src/client.cpp @@ -10,8 +10,8 @@ #undef BOOST_NETWORK_NO_LIB #endif -#include +#include #ifdef BOOST_NETWORK_ENABLE_HTTPS -#include +#include #endif diff --git a/libs/network/src/constants.cpp b/libs/network/src/constants.cpp index f8674a076..810500b23 100644 --- a/libs/network/src/constants.cpp +++ b/libs/network/src/constants.cpp @@ -8,4 +8,4 @@ #undef BOOST_NETWORK_NO_LIB #endif -#include +#include diff --git a/libs/network/src/http/client.cpp b/libs/network/src/http/client.cpp index f17bb7dcd..50fc0e5d1 100644 --- a/libs/network/src/http/client.cpp +++ b/libs/network/src/http/client.cpp @@ -8,8 +8,8 @@ #undef BOOST_NETWORK_NO_LIB #endif -#include -#include -#include -#include +#include +#include +#include +#include diff --git a/libs/network/src/http/client_async_resolver.cpp b/libs/network/src/http/client_async_resolver.cpp index 19ee682cd..f0597f00c 100644 --- a/libs/network/src/http/client_async_resolver.cpp +++ b/libs/network/src/http/client_async_resolver.cpp @@ -8,4 +8,4 @@ #undef BOOST_NETWORK_NO_LIB #endif -#include +#include diff --git a/libs/network/src/http/client_connection_delegates.cpp b/libs/network/src/http/client_connection_delegates.cpp index f596f841f..3ef3f6c0a 100644 --- a/libs/network/src/http/client_connection_delegates.cpp +++ b/libs/network/src/http/client_connection_delegates.cpp @@ -8,7 +8,7 @@ #undef BOOST_NETWORK_NO_LIB #endif -#include +#include #ifdef BOOST_NETWORK_ENABLE_HTTPS -#include +#include #endif diff --git a/libs/network/src/http/client_connection_factory.cpp b/libs/network/src/http/client_connection_factory.cpp index 63f23e681..6bfa0e88c 100644 --- a/libs/network/src/http/client_connection_factory.cpp +++ b/libs/network/src/http/client_connection_factory.cpp @@ -8,4 +8,4 @@ #undef BOOST_NETWORK_NO_LIB #endif -#include +#include diff --git a/libs/network/src/http/client_connection_normal.cpp b/libs/network/src/http/client_connection_normal.cpp index 48b8ac7c4..42caed650 100644 --- a/libs/network/src/http/client_connection_normal.cpp +++ b/libs/network/src/http/client_connection_normal.cpp @@ -8,4 +8,4 @@ #undef BOOST_NETWORK_NO_LIB #endif -#include +#include diff --git a/libs/network/src/http/client_connections.cpp b/libs/network/src/http/client_connections.cpp index 8208ea855..416222fa2 100644 --- a/libs/network/src/http/client_connections.cpp +++ b/libs/network/src/http/client_connections.cpp @@ -8,9 +8,9 @@ #undef BOOST_NETWORK_NO_LIB #endif -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include diff --git a/libs/network/src/http/client_resolver_delegate.cpp b/libs/network/src/http/client_resolver_delegate.cpp index 04b0bdd08..97ba5d48b 100644 --- a/libs/network/src/http/client_resolver_delegate.cpp +++ b/libs/network/src/http/client_resolver_delegate.cpp @@ -8,4 +8,4 @@ #undef BOOST_NETWORK_NO_LIB #endif -#include +#include diff --git a/libs/network/src/http/client_resolver_delegate_factory.cpp b/libs/network/src/http/client_resolver_delegate_factory.cpp index 06c82f2a8..fed466bc3 100644 --- a/libs/network/src/http/client_resolver_delegate_factory.cpp +++ b/libs/network/src/http/client_resolver_delegate_factory.cpp @@ -8,4 +8,4 @@ #undef BOOST_NETWORK_NO_LIB #endif -#include +#include diff --git a/libs/network/src/http/connection_delegate_factory.cpp b/libs/network/src/http/connection_delegate_factory.cpp index 9c9cf31ee..27ec21611 100644 --- a/libs/network/src/http/connection_delegate_factory.cpp +++ b/libs/network/src/http/connection_delegate_factory.cpp @@ -8,4 +8,4 @@ #undef BOOST_NETWORK_NO_LIB #endif -#include +#include diff --git a/libs/network/src/http/message/wrappers.cpp b/libs/network/src/http/message/wrappers.cpp index 0fafbfc42..d1ab4594f 100644 --- a/libs/network/src/http/message/wrappers.cpp +++ b/libs/network/src/http/message/wrappers.cpp @@ -4,9 +4,9 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include diff --git a/libs/network/src/http/request.cpp b/libs/network/src/http/request.cpp index 658ef67de..72321e4a2 100644 --- a/libs/network/src/http/request.cpp +++ b/libs/network/src/http/request.cpp @@ -8,5 +8,5 @@ #undef BOOST_NETWORK_NO_LIB #endif -#include -#include +#include +#include diff --git a/libs/network/src/http/response.cpp b/libs/network/src/http/response.cpp index d3413fe14..4b1c4cf8f 100644 --- a/libs/network/src/http/response.cpp +++ b/libs/network/src/http/response.cpp @@ -8,9 +8,9 @@ #undef BOOST_NETWORK_NO_LIB #endif -#include -#include +#include +#include -#include -#include -#include +#include +#include +#include diff --git a/libs/network/src/http/server_async_impl.cpp b/libs/network/src/http/server_async_impl.cpp index 721f7bcf6..9393b9b9f 100644 --- a/libs/network/src/http/server_async_impl.cpp +++ b/libs/network/src/http/server_async_impl.cpp @@ -4,4 +4,4 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include diff --git a/libs/network/src/http/server_options.cpp b/libs/network/src/http/server_options.cpp index 85b142d84..5a56bca09 100644 --- a/libs/network/src/http/server_options.cpp +++ b/libs/network/src/http/server_options.cpp @@ -4,4 +4,4 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include diff --git a/libs/network/src/http/server_socket_options_setter.cpp b/libs/network/src/http/server_socket_options_setter.cpp index 25b975f14..c5858de85 100644 --- a/libs/network/src/http/server_socket_options_setter.cpp +++ b/libs/network/src/http/server_socket_options_setter.cpp @@ -4,4 +4,4 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include diff --git a/libs/network/src/http/server_sync_impl.cpp b/libs/network/src/http/server_sync_impl.cpp index 3a4cc5c42..d96258a08 100644 --- a/libs/network/src/http/server_sync_impl.cpp +++ b/libs/network/src/http/server_sync_impl.cpp @@ -4,4 +4,4 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include diff --git a/libs/network/src/http/simple_connection_factory.cpp b/libs/network/src/http/simple_connection_factory.cpp index dc0bd6847..f9720c59e 100644 --- a/libs/network/src/http/simple_connection_factory.cpp +++ b/libs/network/src/http/simple_connection_factory.cpp @@ -8,4 +8,4 @@ #undef BOOST_NETWORK_NO_LIB #endif -#include +#include diff --git a/libs/network/src/http/simple_connection_manager.cpp b/libs/network/src/http/simple_connection_manager.cpp index d446ae037..d2246cf64 100644 --- a/libs/network/src/http/simple_connection_manager.cpp +++ b/libs/network/src/http/simple_connection_manager.cpp @@ -8,4 +8,4 @@ #undef BOOST_NETWORK_NO_LIB #endif -#include +#include diff --git a/libs/network/src/message/directives.cpp b/libs/network/src/message/directives.cpp index 960ce80d9..9cc85fe6f 100644 --- a/libs/network/src/message/directives.cpp +++ b/libs/network/src/message/directives.cpp @@ -11,5 +11,5 @@ #undef BOOST_NETWORK_NO_LIB #endif -#include -#include +#include +#include diff --git a/libs/network/src/message/message.cpp b/libs/network/src/message/message.cpp index d92958017..232a788e8 100644 --- a/libs/network/src/message/message.cpp +++ b/libs/network/src/message/message.cpp @@ -11,5 +11,5 @@ #undef BOOST_NETWORK_NO_LIB #endif -#include -#include +#include +#include diff --git a/libs/network/src/message/wrappers.cpp b/libs/network/src/message/wrappers.cpp index 95374e599..0eb21567b 100644 --- a/libs/network/src/message/wrappers.cpp +++ b/libs/network/src/message/wrappers.cpp @@ -7,7 +7,7 @@ // This file conglomerates all the standard wrappers that come with cpp-netlib. // It just includes all the implementation files that get turned into a library. -#include -#include -#include -#include +#include +#include +#include +#include diff --git a/libs/network/src/server_request_parsers_impl.cpp b/libs/network/src/server_request_parsers_impl.cpp index 91dfafb77..e63497d19 100644 --- a/libs/network/src/server_request_parsers_impl.cpp +++ b/libs/network/src/server_request_parsers_impl.cpp @@ -7,5 +7,5 @@ #undef BOOST_NETWORK_NO_LIB #endif -#include +#include diff --git a/libs/network/src/utils/thread_pool.cpp b/libs/network/src/utils/thread_pool.cpp index 4254f43d4..0140e9a5a 100644 --- a/libs/network/src/utils/thread_pool.cpp +++ b/libs/network/src/utils/thread_pool.cpp @@ -4,4 +4,4 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include diff --git a/libs/network/test/CMakeLists.txt b/libs/network/test/CMakeLists.txt index 6f5c92c6f..0e6c21c4f 100644 --- a/libs/network/test/CMakeLists.txt +++ b/libs/network/test/CMakeLists.txt @@ -1,9 +1,9 @@ -# Copyright (c) Dean Michael Berris 2010. +# Copyright (c) Dean Michael Berris 2010. # Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) -include_directories(${CPP-NETLIB_SOURCE_DIR}) +include_directories(${CPP-NETLIB_SOURCE_DIR}/include) add_subdirectory(uri) add_subdirectory(http) diff --git a/libs/network/test/client_server_include_failure.cpp b/libs/network/test/client_server_include_failure.cpp index 6ce27857e..f43d3949f 100644 --- a/libs/network/test/client_server_include_failure.cpp +++ b/libs/network/test/client_server_include_failure.cpp @@ -14,8 +14,8 @@ // these two files, and instantiating a client. It's described at // http://github.com/cpp-netlib/cpp-netlib/issues#issue/13 // -# include -# include +# include +# include BOOST_AUTO_TEST_CASE(test1) { diff --git a/libs/network/test/http/client_constructor_test.cpp b/libs/network/test/http/client_constructor_test.cpp index 71099a846..fac61d9d2 100644 --- a/libs/network/test/http/client_constructor_test.cpp +++ b/libs/network/test/http/client_constructor_test.cpp @@ -5,7 +5,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #define BOOST_TEST_MODULE HTTP 1.0 Client Constructor Test -#include +#include #include namespace http = boost::network::http; diff --git a/libs/network/test/http/client_get_different_port_test.cpp b/libs/network/test/http/client_get_different_port_test.cpp index 5b19dade1..c60a671d3 100644 --- a/libs/network/test/http/client_get_different_port_test.cpp +++ b/libs/network/test/http/client_get_different_port_test.cpp @@ -5,7 +5,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #define BOOST_TEST_MODULE HTTP Client Get Different Port Test -#include +#include #include namespace http = boost::network::http; diff --git a/libs/network/test/http/client_get_streaming_test.cpp b/libs/network/test/http/client_get_streaming_test.cpp index 301649c7f..c9fe190ab 100644 --- a/libs/network/test/http/client_get_streaming_test.cpp +++ b/libs/network/test/http/client_get_streaming_test.cpp @@ -4,7 +4,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #define BOOST_TEST_MODULE HTTP 1.1 Get Streaming Test -#include +#include #include #include diff --git a/libs/network/test/http/client_get_test.cpp b/libs/network/test/http/client_get_test.cpp index 30eea05bf..57c0397f6 100644 --- a/libs/network/test/http/client_get_test.cpp +++ b/libs/network/test/http/client_get_test.cpp @@ -4,7 +4,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #define BOOST_TEST_MODULE HTTP 1.0 Get Test -#include +#include #include namespace net = boost::network; diff --git a/libs/network/test/http/client_get_timeout_test.cpp b/libs/network/test/http/client_get_timeout_test.cpp index d17c4813b..ce66308c8 100644 --- a/libs/network/test/http/client_get_timeout_test.cpp +++ b/libs/network/test/http/client_get_timeout_test.cpp @@ -5,7 +5,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #define BOOST_TEST_MODULE HTTP Client Get Timeout Test -#include +#include #include namespace http = boost::network::http; diff --git a/libs/network/test/http/client_include_inlined.cpp b/libs/network/test/http/client_include_inlined.cpp index a83664800..69e5847d3 100644 --- a/libs/network/test/http/client_include_inlined.cpp +++ b/libs/network/test/http/client_include_inlined.cpp @@ -4,7 +4,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #define BOOST_NETWORK_NO_LIB -#include +#include int main(int argc, char * argv[]) { using namespace boost; diff --git a/libs/network/test/http/client_localhost_normal_test.cpp b/libs/network/test/http/client_localhost_normal_test.cpp index 3a3711c1c..8f247d54f 100644 --- a/libs/network/test/http/client_localhost_normal_test.cpp +++ b/libs/network/test/http/client_localhost_normal_test.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/libs/network/test/http/client_localhost_ssl_test.cpp b/libs/network/test/http/client_localhost_ssl_test.cpp index 5bbf20390..4e1ac179e 100644 --- a/libs/network/test/http/client_localhost_ssl_test.cpp +++ b/libs/network/test/http/client_localhost_ssl_test.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/libs/network/test/http/message_async_ready_test.cpp b/libs/network/test/http/message_async_ready_test.cpp index 60b3502cc..15d1a85c7 100644 --- a/libs/network/test/http/message_async_ready_test.cpp +++ b/libs/network/test/http/message_async_ready_test.cpp @@ -6,7 +6,7 @@ #define BOOST_TEST_MODULE HTTP Async Response Test #include -#include +#include namespace http = boost::network::http; diff --git a/libs/network/test/http/message_test.cpp b/libs/network/test/http/message_test.cpp index dde3a9303..b7d8dd1bb 100644 --- a/libs/network/test/http/message_test.cpp +++ b/libs/network/test/http/message_test.cpp @@ -7,8 +7,8 @@ #define BOOST_TEST_MODULE HTTP message test #include #include -#include -#include +#include +#include #include #include diff --git a/libs/network/test/http/request_base_test.cpp b/libs/network/test/http/request_base_test.cpp index a5fdaa8de..d916e851f 100644 --- a/libs/network/test/http/request_base_test.cpp +++ b/libs/network/test/http/request_base_test.cpp @@ -5,7 +5,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #define BOOST_TEST_MODULE HTTP Request Storage Base Test -#include +#include #include namespace http = boost::network::http; diff --git a/libs/network/test/http/request_incremental_parser_test.cpp b/libs/network/test/http/request_incremental_parser_test.cpp index 00f1657f2..e865efa02 100644 --- a/libs/network/test/http/request_incremental_parser_test.cpp +++ b/libs/network/test/http/request_incremental_parser_test.cpp @@ -6,8 +6,8 @@ #define BOOST_TEST_MODULE HTTP Incremental Request Parser Test #include #include -#include -#include +#include +#include #include #include #include diff --git a/libs/network/test/http/request_linearize_test.cpp b/libs/network/test/http/request_linearize_test.cpp index e799b75b9..41fc0d81d 100644 --- a/libs/network/test/http/request_linearize_test.cpp +++ b/libs/network/test/http/request_linearize_test.cpp @@ -5,8 +5,8 @@ // http://www.boost.org/LICENSE_1_0.txt) #define BOOST_TEST_MODULE HTTP Request Linearize Test -#include -#include +#include +#include #include #include diff --git a/libs/network/test/http/request_test.cpp b/libs/network/test/http/request_test.cpp index 7a99a6186..88395157a 100644 --- a/libs/network/test/http/request_test.cpp +++ b/libs/network/test/http/request_test.cpp @@ -5,9 +5,9 @@ // http://www.boost.org/LICENSE_1_0.txt) #define BOOST_TEST_MODULE HTTP Request Test -#include -#include -#include +#include +#include +#include #include #include diff --git a/libs/network/test/http/response_incremental_parser_test.cpp b/libs/network/test/http/response_incremental_parser_test.cpp index 9026ec0bc..de26872d1 100644 --- a/libs/network/test/http/response_incremental_parser_test.cpp +++ b/libs/network/test/http/response_incremental_parser_test.cpp @@ -7,7 +7,7 @@ #define BOOST_TEST_MODULE HTTP Incremental Parser Test #include #include -#include +#include #include #include #include diff --git a/libs/network/test/http/response_test.cpp b/libs/network/test/http/response_test.cpp index 75a8be0d9..d80cbbbc2 100644 --- a/libs/network/test/http/response_test.cpp +++ b/libs/network/test/http/response_test.cpp @@ -5,7 +5,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #define BOOST_TEST_MODULE HTTP Client Response Test -#include +#include #include namespace http = boost::network::http; diff --git a/libs/network/test/http/server_async.cpp b/libs/network/test/http/server_async.cpp index c808cab0b..6a3ae78ec 100644 --- a/libs/network/test/http/server_async.cpp +++ b/libs/network/test/http/server_async.cpp @@ -7,8 +7,8 @@ #define BOOST_TEST_MODULE HTTP Asynchronous Server Tests #include -#include -#include +#include +#include #include namespace net = boost::network; diff --git a/libs/network/test/http/server_async_less_copy.cpp b/libs/network/test/http/server_async_less_copy.cpp index c1ca4786b..2f46f25ec 100644 --- a/libs/network/test/http/server_async_less_copy.cpp +++ b/libs/network/test/http/server_async_less_copy.cpp @@ -9,8 +9,8 @@ #include #include -#include -#include +#include +#include #include #include diff --git a/libs/network/test/http/server_async_run_stop_concurrency.cpp b/libs/network/test/http/server_async_run_stop_concurrency.cpp index af9745c4d..918703b5d 100644 --- a/libs/network/test/http/server_async_run_stop_concurrency.cpp +++ b/libs/network/test/http/server_async_run_stop_concurrency.cpp @@ -1,6 +1,6 @@ #define BOOST_TEST_MODULE HTTP Asynchronous Server Tests -#include +#include #include #include diff --git a/libs/network/test/http/server_constructor_test.cpp b/libs/network/test/http/server_constructor_test.cpp index 4d6bc3441..986570942 100644 --- a/libs/network/test/http/server_constructor_test.cpp +++ b/libs/network/test/http/server_constructor_test.cpp @@ -6,7 +6,7 @@ #define BOOST_TEST_MODULE HTTP Server Construtor Tests -#include +#include #include namespace http = boost::network::http; diff --git a/libs/network/test/http/server_hello_world.cpp b/libs/network/test/http/server_hello_world.cpp index 8174f91ed..3da83d2d2 100644 --- a/libs/network/test/http/server_hello_world.cpp +++ b/libs/network/test/http/server_hello_world.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include #include diff --git a/libs/network/test/http/server_include_inlined.cpp b/libs/network/test/http/server_include_inlined.cpp index 1f286bba6..a25d7c9ea 100644 --- a/libs/network/test/http/server_include_inlined.cpp +++ b/libs/network/test/http/server_include_inlined.cpp @@ -8,7 +8,7 @@ #include #include #define BOOST_NETWORK_NO_LIB -#include +#include #include #include #include diff --git a/libs/network/test/http_server_async_less_copy.cpp b/libs/network/test/http_server_async_less_copy.cpp index 8ff076bdc..d443cb12c 100644 --- a/libs/network/test/http_server_async_less_copy.cpp +++ b/libs/network/test/http_server_async_less_copy.cpp @@ -9,8 +9,8 @@ #include #include -#include -#include +#include +#include #include namespace net = boost::network; diff --git a/libs/network/test/message_test.cpp b/libs/network/test/message_test.cpp index 3c566cee5..9891bcb3c 100644 --- a/libs/network/test/message_test.cpp +++ b/libs/network/test/message_test.cpp @@ -7,7 +7,7 @@ #define BOOST_TEST_MODULE message test #include #include -#include +#include #include using namespace boost::network; diff --git a/libs/network/test/message_transform_test.cpp b/libs/network/test/message_transform_test.cpp index 9f77d014c..b45d1586b 100644 --- a/libs/network/test/message_transform_test.cpp +++ b/libs/network/test/message_transform_test.cpp @@ -7,7 +7,7 @@ #define BOOST_TEST_MODULE message test #include #include -#include +#include #include BOOST_AUTO_TEST_CASE ( message_transform_toupper ) { diff --git a/libs/network/test/utils_thread_pool.cpp b/libs/network/test/utils_thread_pool.cpp index d075efafa..429400c94 100644 --- a/libs/network/test/utils_thread_pool.cpp +++ b/libs/network/test/utils_thread_pool.cpp @@ -7,7 +7,7 @@ #define BOOST_TEST_MODULE utils thread pool test #include #include -#include +#include #include using namespace boost::network; From 96fc0d2ab50ba69c4224c65a94b18d0eec7c1a5c Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Mon, 10 Sep 2012 01:46:44 +1000 Subject: [PATCH 107/196] Copyright email updates. --- include/network/protocol/http/client/macros.hpp | 2 +- include/network/protocol/http/impl/request_parser.ipp | 2 +- include/network/protocol/http/impl/response.ipp | 2 +- include/network/protocol/http/message/header.hpp | 2 +- include/network/protocol/http/request_parser.hpp | 2 +- include/network/protocol/http/server/connection/sync.hpp | 2 +- include/network/protocol/http/server/request.hpp | 2 +- libs/network/example/http/hello_world_server.cpp | 2 +- libs/network/test/http/client_get_streaming_test.cpp | 2 +- libs/network/test/http/client_include_inlined.cpp | 2 +- libs/network/test/http/response_incremental_parser_test.cpp | 2 +- libs/network/test/http/server_hello_world.cpp | 2 +- libs/network/test/http/server_include_inlined.cpp | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/network/protocol/http/client/macros.hpp b/include/network/protocol/http/client/macros.hpp index f4fad800c..d00a04d2f 100644 --- a/include/network/protocol/http/client/macros.hpp +++ b/include/network/protocol/http/client/macros.hpp @@ -1,7 +1,7 @@ #ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_MACROS_HPP_20110430 #define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_MACROS_HPP_20110430 -// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Dean Michael Berris . // 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) diff --git a/include/network/protocol/http/impl/request_parser.ipp b/include/network/protocol/http/impl/request_parser.ipp index 59493b6ac..bb75913db 100644 --- a/include/network/protocol/http/impl/request_parser.ipp +++ b/include/network/protocol/http/impl/request_parser.ipp @@ -5,7 +5,7 @@ // Implementation file for the header-only version of the request_parser. // // Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// Copyright (c) 2009 Dean Michael Berris (mikhailberis@gmail.com) +// Copyright (c) 2009 Dean Michael Berris (dberris@google.com) // Copyright (c) 2009 Tarroo, Inc. // // Distributed under the Boost Software License, Version 1.0. (See accompanying diff --git a/include/network/protocol/http/impl/response.ipp b/include/network/protocol/http/impl/response.ipp index 43aa2bc34..661f472dc 100644 --- a/include/network/protocol/http/impl/response.ipp +++ b/include/network/protocol/http/impl/response.ipp @@ -1,6 +1,6 @@ // // Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// Copyright (c) 2009 Dean Michael Berris (mikhailberis@gmail.com) +// Copyright (c) 2009 Dean Michael Berris (dberris@google.com) // Copyright (c) 2009 Tarroo, Inc. // // Distributed under the Boost Software License, Version 1.0. (See accompanying diff --git a/include/network/protocol/http/message/header.hpp b/include/network/protocol/http/message/header.hpp index e842ebd45..8984ef887 100644 --- a/include/network/protocol/http/message/header.hpp +++ b/include/network/protocol/http/message/header.hpp @@ -3,7 +3,7 @@ // ~~~~~~~~~~ // // Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// Copyright (c) 2009,2010 Dean Michael Berris (mikhailberis@gmail.com) +// Copyright (c) 2009,2010 Dean Michael Berris (dberris@google.com) // Copyright (c) 2009 Tarroo, Inc. // // Distributed under the Boost Software License, Version 1.0. (See accompanying diff --git a/include/network/protocol/http/request_parser.hpp b/include/network/protocol/http/request_parser.hpp index d2d6f7089..02f2a22bd 100644 --- a/include/network/protocol/http/request_parser.hpp +++ b/include/network/protocol/http/request_parser.hpp @@ -10,7 +10,7 @@ // 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) // -// Modifications by Dean Michael Berris +// Modifications by Dean Michael Berris // #ifndef HTTP_SERVER3_REQUEST_PARSER_HPP diff --git a/include/network/protocol/http/server/connection/sync.hpp b/include/network/protocol/http/server/connection/sync.hpp index 19b7b908c..4ef7c5ffc 100644 --- a/include/network/protocol/http/server/connection/sync.hpp +++ b/include/network/protocol/http/server/connection/sync.hpp @@ -1,4 +1,4 @@ -// Copyright 2009 (c) Dean Michael Berris +// Copyright 2009 (c) Dean Michael Berris // Copyright 2009 (c) Tarroo, Inc. // Adapted from Christopher Kholhoff's Boost.Asio Example, released under // the Boost Software License, Version 1.0. (See acccompanying file LICENSE_1_0.txt diff --git a/include/network/protocol/http/server/request.hpp b/include/network/protocol/http/server/request.hpp index c5fed5deb..6c6760a47 100644 --- a/include/network/protocol/http/server/request.hpp +++ b/include/network/protocol/http/server/request.hpp @@ -3,7 +3,7 @@ // ~~~~~~~~~~~ // // Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// Copyright (c) 2009 Dean Michael Berris (mikhailberis@gmail.com) +// Copyright (c) 2009 Dean Michael Berris (dberris@google.com) // Copyright (c) 2009 Tarro, Inc. // // Distributed under the Boost Software License, Version 1.0. (See accompanying diff --git a/libs/network/example/http/hello_world_server.cpp b/libs/network/example/http/hello_world_server.cpp index 87e88867d..83f09ec61 100644 --- a/libs/network/example/http/hello_world_server.cpp +++ b/libs/network/example/http/hello_world_server.cpp @@ -1,5 +1,5 @@ // Copyright 2009 (c) Tarro, Inc. -// Copyright 2009 (c) Dean Michael Berris +// Copyright 2009 (c) Dean Michael Berris // 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) diff --git a/libs/network/test/http/client_get_streaming_test.cpp b/libs/network/test/http/client_get_streaming_test.cpp index c9fe190ab..5e2de35a0 100644 --- a/libs/network/test/http/client_get_streaming_test.cpp +++ b/libs/network/test/http/client_get_streaming_test.cpp @@ -1,4 +1,4 @@ -// Copyright 2011 Dean Michael Berris <mikhailberis@gmail.com>. +// Copyright 2011 Dean Michael Berris <dberris@google.com>. // 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) diff --git a/libs/network/test/http/client_include_inlined.cpp b/libs/network/test/http/client_include_inlined.cpp index 69e5847d3..b1a708d21 100644 --- a/libs/network/test/http/client_include_inlined.cpp +++ b/libs/network/test/http/client_include_inlined.cpp @@ -1,4 +1,4 @@ -// Copyright 2011 Dean Michael Berris <mikhailberis@gmail.com>. +// Copyright 2011 Dean Michael Berris <dberris@google.com>. // 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) diff --git a/libs/network/test/http/response_incremental_parser_test.cpp b/libs/network/test/http/response_incremental_parser_test.cpp index de26872d1..afcc3e226 100644 --- a/libs/network/test/http/response_incremental_parser_test.cpp +++ b/libs/network/test/http/response_incremental_parser_test.cpp @@ -45,7 +45,7 @@ * semantics are according to expectations. * * Date: September 9, 2010 - * Author: Dean Michael Berris + * Author: Dean Michael Berris */ namespace tags = boost::network::tags; diff --git a/libs/network/test/http/server_hello_world.cpp b/libs/network/test/http/server_hello_world.cpp index 3da83d2d2..fa3e0963f 100644 --- a/libs/network/test/http/server_hello_world.cpp +++ b/libs/network/test/http/server_hello_world.cpp @@ -1,5 +1,5 @@ // Copyright 2009 (c) Tarro, Inc. -// Copyright 2009-2010 (c) Dean Michael Berris +// Copyright 2009-2010 (c) Dean Michael Berris // 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) diff --git a/libs/network/test/http/server_include_inlined.cpp b/libs/network/test/http/server_include_inlined.cpp index a25d7c9ea..349e79bd5 100644 --- a/libs/network/test/http/server_include_inlined.cpp +++ b/libs/network/test/http/server_include_inlined.cpp @@ -1,5 +1,5 @@ // Copyright 2009 (c) Tarro, Inc. -// Copyright 2009-2010 (c) Dean Michael Berris +// Copyright 2009-2010 (c) Dean Michael Berris // 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) From 9d69d715160771752e6865ea9739d5bba1ad2182 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Mon, 10 Sep 2012 02:06:42 +1000 Subject: [PATCH 108/196] Updating Google copyrights. --- include/network.hpp | 1 + include/network/constants.hpp | 1 + include/network/detail/debug.hpp | 1 + include/network/detail/directive_base.hpp | 1 + include/network/detail/wrapper_base.hpp | 1 + include/network/include/http/client.hpp | 1 + include/network/include/message.hpp | 1 + include/network/message/directives.hpp | 1 + include/network/message/directives/detail/string_directive.hpp | 1 + include/network/message/directives/detail/string_value.hpp | 1 + include/network/message/message_concept.hpp | 1 + include/network/message/modifiers/body.hpp | 1 + include/network/message/modifiers/remove_header.hpp | 1 + include/network/message/modifiers/source.hpp | 1 + include/network/message/transformers.hpp | 1 + include/network/message/transformers/selectors.hpp | 1 + include/network/message/transformers/to_lower.hpp | 1 + include/network/message/transformers/to_upper.hpp | 1 + include/network/message/wrappers.hpp | 1 + include/network/message/wrappers/headers.hpp | 1 + include/network/message_fwd.hpp | 1 + include/network/protocol.hpp | 1 + include/network/protocol/http.hpp | 1 + include/network/protocol/http/algorithms/linearize.hpp | 1 + include/network/protocol/http/client/connection/sync_base.hpp | 1 + include/network/protocol/http/client/connection/sync_normal.hpp | 1 + include/network/protocol/http/client/connection/sync_ssl.hpp | 1 + include/network/protocol/http/client/facade.hpp | 1 + include/network/protocol/http/client/macros.hpp | 1 + include/network/protocol/http/client/parameters.hpp | 1 + include/network/protocol/http/client/pimpl.hpp | 1 + include/network/protocol/http/client/sync_impl.hpp | 1 + include/network/protocol/http/client_fwd.hpp | 1 + include/network/protocol/http/errors.hpp | 1 + include/network/protocol/http/impl/message.ipp | 1 + include/network/protocol/http/impl/parser.ipp | 1 + include/network/protocol/http/impl/request.hpp | 1 + include/network/protocol/http/impl/request_parser.ipp | 1 + include/network/protocol/http/impl/response.ipp | 1 + .../network/protocol/http/message/directives/major_version.hpp | 1 + include/network/protocol/http/message/directives/method.hpp | 1 + .../network/protocol/http/message/directives/minor_version.hpp | 1 + .../network/protocol/http/message/directives/status_message.hpp | 1 + include/network/protocol/http/message/directives/uri.hpp | 1 + include/network/protocol/http/message/directives/version.hpp | 1 + include/network/protocol/http/message/header.hpp | 1 + include/network/protocol/http/message/header/name.hpp | 1 + include/network/protocol/http/message/header/value.hpp | 1 + include/network/protocol/http/message/header_concept.hpp | 1 + .../network/protocol/http/message/modifiers/major_version.hpp | 1 + include/network/protocol/http/message/modifiers/method.hpp | 1 + .../network/protocol/http/message/modifiers/minor_version.hpp | 1 + include/network/protocol/http/message/modifiers/status.hpp | 1 + .../network/protocol/http/message/modifiers/status_message.hpp | 1 + include/network/protocol/http/message/modifiers/version.hpp | 1 + include/network/protocol/http/message/wrappers/anchor.ipp | 1 + include/network/protocol/http/message/wrappers/helper.hpp | 1 + include/network/protocol/http/message/wrappers/major_version.hpp | 1 + include/network/protocol/http/message/wrappers/method.hpp | 1 + include/network/protocol/http/message/wrappers/minor_version.hpp | 1 + include/network/protocol/http/message/wrappers/ready.hpp | 1 + include/network/protocol/http/message/wrappers/status.hpp | 1 + .../network/protocol/http/message/wrappers/status_message.hpp | 1 + include/network/protocol/http/message/wrappers/uri.hpp | 1 + include/network/protocol/http/parser.hpp | 1 + include/network/protocol/http/request/request_concept.hpp | 1 + include/network/protocol/http/response.hpp | 1 + include/network/protocol/http/response/response_concept.hpp | 1 + include/network/protocol/http/server/async_server.hpp | 1 + include/network/protocol/http/server/impl/parsers.ipp | 1 + include/network/protocol/http/server/parameters.hpp | 1 + include/network/protocol/http/server/request.hpp | 1 + include/network/protocol/http/server/request_parser.hpp | 1 + include/network/protocol/http/server/socket_options_base.hpp | 1 + include/network/protocol/http/server/storage_base.hpp | 1 + include/network/protocol/http/server/sync_server.hpp | 1 + include/network/protocol/http/support/client_or_server.hpp | 1 + include/network/protocol/http/support/is_client.hpp | 1 + include/network/protocol/http/support/is_http.hpp | 1 + include/network/protocol/http/support/is_keepalive.hpp | 1 + include/network/protocol/http/support/is_server.hpp | 1 + include/network/protocol/http/support/is_simple.hpp | 1 + include/network/protocol/http/support/sync_only.hpp | 1 + include/network/uri.hpp | 1 + include/network/uri/accessors.hpp | 1 + include/network/uri/builder.hpp | 1 + include/network/uri/config.hpp | 1 + include/network/uri/decode.hpp | 1 + include/network/uri/detail/uri_parts.hpp | 1 + include/network/uri/directives.hpp | 1 + include/network/uri/directives/authority.hpp | 1 + include/network/uri/directives/fragment.hpp | 1 + include/network/uri/directives/host.hpp | 1 + include/network/uri/directives/path.hpp | 1 + include/network/uri/directives/port.hpp | 1 + include/network/uri/directives/query.hpp | 1 + include/network/uri/directives/scheme.hpp | 1 + include/network/uri/directives/user_info.hpp | 1 + include/network/uri/encode.hpp | 1 + include/network/uri/schemes.hpp | 1 + include/network/uri/uri.hpp | 1 + include/network/uri/uri.ipp | 1 + include/network/uri/uri_io.hpp | 1 + include/network/utils/thread_pool.hpp | 1 + include/network/version.hpp | 1 + libs/network/example/atom/atom.cpp | 1 + libs/network/example/atom/atom.hpp | 1 + libs/network/example/atom/main.cpp | 1 + libs/network/example/http/fileserver.cpp | 1 + libs/network/example/http/hello_world_client.cpp | 1 + libs/network/example/http/hello_world_server.cpp | 1 + libs/network/example/http/one_liner.cpp | 1 + libs/network/example/http_client.cpp | 1 + libs/network/example/http_client1.cpp | 1 + libs/network/example/rss/main.cpp | 1 + libs/network/example/rss/rss.cpp | 1 + libs/network/example/rss/rss.hpp | 1 + libs/network/example/simple_wget.cpp | 1 + libs/network/example/twitter/search.cpp | 1 + libs/network/example/uri_builder.cpp | 1 + libs/network/src/server_request_parsers_impl.cpp | 1 + libs/network/src/uri/schemes.cpp | 1 + libs/network/src/uri/uri.cpp | 1 + libs/network/test/client_server_include_failure.cpp | 1 + libs/network/test/http/client_constructor_test.cpp | 1 + libs/network/test/http/client_get_different_port_test.cpp | 1 + libs/network/test/http/client_get_streaming_test.cpp | 1 + libs/network/test/http/client_get_test.cpp | 1 + libs/network/test/http/client_get_timeout_test.cpp | 1 + libs/network/test/http/client_include_inlined.cpp | 1 + libs/network/test/http/client_localhost_normal_test.cpp | 1 + libs/network/test/http/client_localhost_ssl_test.cpp | 1 + libs/network/test/http/http_test_server.hpp | 1 + libs/network/test/http/message_async_ready_test.cpp | 1 + libs/network/test/http/message_test.cpp | 1 + libs/network/test/http/request_incremental_parser_test.cpp | 1 + libs/network/test/http/request_linearize_test.cpp | 1 + libs/network/test/http/response_incremental_parser_test.cpp | 1 + libs/network/test/http/server_async.cpp | 1 + libs/network/test/http/server_async_less_copy.cpp | 1 + libs/network/test/http/server_constructor_test.cpp | 1 + libs/network/test/http/server_hello_world.cpp | 1 + libs/network/test/http/server_include_inlined.cpp | 1 + libs/network/test/http_server_async_less_copy.cpp | 1 + libs/network/test/message_test.cpp | 1 + libs/network/test/message_transform_test.cpp | 1 + libs/network/test/uri/relative_uri_test.cpp | 1 + libs/network/test/uri/uri_builder_stream_test.cpp | 1 + libs/network/test/uri/uri_builder_test.cpp | 1 + libs/network/test/uri/uri_encoding_test.cpp | 1 + libs/network/test/uri/uri_test.cpp | 1 + libs/network/test/utils_thread_pool.cpp | 1 + 152 files changed, 152 insertions(+) diff --git a/include/network.hpp b/include/network.hpp index 76bf84ae9..ef58c1f63 100644 --- a/include/network.hpp +++ b/include/network.hpp @@ -1,5 +1,6 @@ // Copyright Dean Michael Berris 2007. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/constants.hpp b/include/network/constants.hpp index c22dcd7a7..2b4e43d2d 100644 --- a/include/network/constants.hpp +++ b/include/network/constants.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_CONSTANTS_HPP_20100808 // Copyright 2010 (C) Dean Michael Berris +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/detail/debug.hpp b/include/network/detail/debug.hpp index 8b331cdaa..9a5c5329f 100644 --- a/include/network/detail/debug.hpp +++ b/include/network/detail/debug.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_DEBUG_HPP_20110410 // (c) Copyright 2011 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/detail/directive_base.hpp b/include/network/detail/directive_base.hpp index 0667d1345..104cba6d2 100644 --- a/include/network/detail/directive_base.hpp +++ b/include/network/detail/directive_base.hpp @@ -1,5 +1,6 @@ // Copyright Dean Michael Berris 2007. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/detail/wrapper_base.hpp b/include/network/detail/wrapper_base.hpp index 9c1a8fca4..56d6f7c69 100644 --- a/include/network/detail/wrapper_base.hpp +++ b/include/network/detail/wrapper_base.hpp @@ -1,5 +1,6 @@ // Copyright Dean Michael Berris 2007. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/include/http/client.hpp b/include/network/include/http/client.hpp index 67fa571d3..e33d240f4 100644 --- a/include/network/include/http/client.hpp +++ b/include/network/include/http/client.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_INCLUDE_HTTP_CLIENT_HPP_ // Copyright 2009 Dean Michael Berris +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/include/message.hpp b/include/network/include/message.hpp index f170e6a84..416a3caa4 100644 --- a/include/network/include/message.hpp +++ b/include/network/include/message.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_INCLUDE_MESSAGE_HPP_ // Copyright 2009 Dean Michael Berris +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/message/directives.hpp b/include/network/message/directives.hpp index a72ee613e..d30ee5455 100644 --- a/include/network/message/directives.hpp +++ b/include/network/message/directives.hpp @@ -1,5 +1,6 @@ // Copyright Dean Michael Berris 2007. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/message/directives/detail/string_directive.hpp b/include/network/message/directives/detail/string_directive.hpp index 239b3bd44..731d52b50 100644 --- a/include/network/message/directives/detail/string_directive.hpp +++ b/include/network/message/directives/detail/string_directive.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_MESSAGE_DIRECTIVES_DETAIL_STRING_DIRECTIVE_HPP_20100915 // Copyright Dean Michael Berris 2010. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/message/directives/detail/string_value.hpp b/include/network/message/directives/detail/string_value.hpp index 3efacbe68..f04625acc 100644 --- a/include/network/message/directives/detail/string_value.hpp +++ b/include/network/message/directives/detail/string_value.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_MESSAGE_DIRECTIVES_DETAIL_STRING_VALUE_HPP_20100915 // Copyright Dean Michael Berris 2010. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/message/message_concept.hpp b/include/network/message/message_concept.hpp index 581cad05c..dfa877a6e 100644 --- a/include/network/message/message_concept.hpp +++ b/include/network/message/message_concept.hpp @@ -5,6 +5,7 @@ // Copyright (c) Glyn Matthews 2010. // Copyright 2010 (c) Dean Michael Berris. // Copyright 2010 (c) Sinefunc, Inc. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/message/modifiers/body.hpp b/include/network/message/modifiers/body.hpp index fcd5b1422..c22679a15 100644 --- a/include/network/message/modifiers/body.hpp +++ b/include/network/message/modifiers/body.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_MODIFIERS_BODY_HPP_20100824 // Copyright 2010 (c) Dean Michael Berris +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/message/modifiers/remove_header.hpp b/include/network/message/modifiers/remove_header.hpp index 632d1156e..8d943614a 100644 --- a/include/network/message/modifiers/remove_header.hpp +++ b/include/network/message/modifiers/remove_header.hpp @@ -3,6 +3,7 @@ #define BOOST_NETWORK_MESSAGE_MODIFIER_REMOVE_HEADER_HPP_20100824 // Copyright 2010 (c) Dean Michael Berris +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/message/modifiers/source.hpp b/include/network/message/modifiers/source.hpp index f39131181..835834d15 100644 --- a/include/network/message/modifiers/source.hpp +++ b/include/network/message/modifiers/source.hpp @@ -3,6 +3,7 @@ #define BOOST_NETWORK_MESSAGE_MODIFIER_SOURCE_HPP_20100824 // Copyright 2010 (c) Dean Michael Berris +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/message/transformers.hpp b/include/network/message/transformers.hpp index 91111db15..324cc4390 100644 --- a/include/network/message/transformers.hpp +++ b/include/network/message/transformers.hpp @@ -1,5 +1,6 @@ // Copyright Dean Michael Berris 2007. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/message/transformers/selectors.hpp b/include/network/message/transformers/selectors.hpp index 004c7f141..07f52328d 100644 --- a/include/network/message/transformers/selectors.hpp +++ b/include/network/message/transformers/selectors.hpp @@ -1,5 +1,6 @@ // Copyright Dean Michael Berris 2007. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/message/transformers/to_lower.hpp b/include/network/message/transformers/to_lower.hpp index ccf4ed18a..b181737ab 100644 --- a/include/network/message/transformers/to_lower.hpp +++ b/include/network/message/transformers/to_lower.hpp @@ -1,5 +1,6 @@ // Copyright Dean Michael Berris 2007. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/message/transformers/to_upper.hpp b/include/network/message/transformers/to_upper.hpp index 4aee31ef7..0400113cf 100644 --- a/include/network/message/transformers/to_upper.hpp +++ b/include/network/message/transformers/to_upper.hpp @@ -1,5 +1,6 @@ // Copyright Dean Michael Berris 2007. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/message/wrappers.hpp b/include/network/message/wrappers.hpp index d4a9fdc4e..af601e5a8 100644 --- a/include/network/message/wrappers.hpp +++ b/include/network/message/wrappers.hpp @@ -1,5 +1,6 @@ // Copyright Dean Michael Berris 2007. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/message/wrappers/headers.hpp b/include/network/message/wrappers/headers.hpp index 81179d8e3..5b0befa43 100644 --- a/include/network/message/wrappers/headers.hpp +++ b/include/network/message/wrappers/headers.hpp @@ -1,5 +1,6 @@ // Copyright Dean Michael Berris 2007. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/message_fwd.hpp b/include/network/message_fwd.hpp index ca8714e70..6045b0cbf 100644 --- a/include/network/message_fwd.hpp +++ b/include/network/message_fwd.hpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2008. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol.hpp b/include/network/protocol.hpp index c712beaa9..9139a955c 100644 --- a/include/network/protocol.hpp +++ b/include/network/protocol.hpp @@ -1,5 +1,6 @@ // Copyright Dean Michael Berris 2007. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http.hpp b/include/network/protocol/http.hpp index 988ba87fb..15ec9e691 100644 --- a/include/network/protocol/http.hpp +++ b/include/network/protocol/http.hpp @@ -1,5 +1,6 @@ // Copyright Dean Michael Berris 2007, 2008. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/algorithms/linearize.hpp b/include/network/protocol/http/algorithms/linearize.hpp index 4c0c04a5e..8022abd1e 100644 --- a/include/network/protocol/http/algorithms/linearize.hpp +++ b/include/network/protocol/http/algorithms/linearize.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_ALGORITHMS_LINEARIZE_HPP_20101028 // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/client/connection/sync_base.hpp b/include/network/protocol/http/client/connection/sync_base.hpp index cd2c5a6c4..eba7e713b 100644 --- a/include/network/protocol/http/client/connection/sync_base.hpp +++ b/include/network/protocol/http/client/connection/sync_base.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_IMPL_SYNC_CONNECTION_BASE_20091217 // Copyright Dean Michael Berris 2009. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/client/connection/sync_normal.hpp b/include/network/protocol/http/client/connection/sync_normal.hpp index 4fa7009bd..202628534 100644 --- a/include/network/protocol/http/client/connection/sync_normal.hpp +++ b/include/network/protocol/http/client/connection/sync_normal.hpp @@ -3,6 +3,7 @@ // Copyright 2010 (C) Dean Michael Berris // Copyright 2010 (C) Sinefunc, Inc. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/client/connection/sync_ssl.hpp b/include/network/protocol/http/client/connection/sync_ssl.hpp index ce13a78c3..2a8514d75 100644 --- a/include/network/protocol/http/client/connection/sync_ssl.hpp +++ b/include/network/protocol/http/client/connection/sync_ssl.hpp @@ -3,6 +3,7 @@ // Copyright 2010 (C) Dean Michael Berris // Copyright 2010 (C) Sinefunc, Inc. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/client/facade.hpp b/include/network/protocol/http/client/facade.hpp index 85b92f373..0197032fb 100644 --- a/include/network/protocol/http/client/facade.hpp +++ b/include/network/protocol/http/client/facade.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_FACADE_HPP_20100623 // Copyright Dean Michael Berris 2010. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/client/macros.hpp b/include/network/protocol/http/client/macros.hpp index d00a04d2f..b6524e4f7 100644 --- a/include/network/protocol/http/client/macros.hpp +++ b/include/network/protocol/http/client/macros.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_MACROS_HPP_20110430 // Copyright 2011 Dean Michael Berris . +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/client/parameters.hpp b/include/network/protocol/http/client/parameters.hpp index 30d5656d4..618636b3e 100644 --- a/include/network/protocol/http/client/parameters.hpp +++ b/include/network/protocol/http/client/parameters.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_PARAMETERS_HPP_2010127 // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/client/pimpl.hpp b/include/network/protocol/http/client/pimpl.hpp index cd36ffa09..c888016f4 100644 --- a/include/network/protocol/http/client/pimpl.hpp +++ b/include/network/protocol/http/client/pimpl.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_PIMPL_HPP_20100623 // Copyright Dean Michael Berris 2010. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/client/sync_impl.hpp b/include/network/protocol/http/client/sync_impl.hpp index b81c2198a..dc677219a 100644 --- a/include/network/protocol/http/client/sync_impl.hpp +++ b/include/network/protocol/http/client/sync_impl.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_SYNC_IMPL_HPP_20100623 // Copyright Dean Michael Berris 2010. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/client_fwd.hpp b/include/network/protocol/http/client_fwd.hpp index ebb1e9685..acdef99dd 100644 --- a/include/network/protocol/http/client_fwd.hpp +++ b/include/network/protocol/http/client_fwd.hpp @@ -1,5 +1,6 @@ // Copyright Dean Michael Berris 2007-2008. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/errors.hpp b/include/network/protocol/http/errors.hpp index dff069d36..fd1d83094 100644 --- a/include/network/protocol/http/errors.hpp +++ b/include/network/protocol/http/errors.hpp @@ -1,5 +1,6 @@ // Copyright Dean Michael Berris 2007, 2008. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/impl/message.ipp b/include/network/protocol/http/impl/message.ipp index 4c0d68203..4cb554f92 100644 --- a/include/network/protocol/http/impl/message.ipp +++ b/include/network/protocol/http/impl/message.ipp @@ -3,6 +3,7 @@ // Copyright Atomic Labs, Inc. 2007-2008 // See http://cpp-netlib.sourceforge.net for library home page. // +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/impl/parser.ipp b/include/network/protocol/http/impl/parser.ipp index e392facbe..7670f8236 100644 --- a/include/network/protocol/http/impl/parser.ipp +++ b/include/network/protocol/http/impl/parser.ipp @@ -3,6 +3,7 @@ // Copyright Atomic Labs, Inc. 2007-2008 // See http://cpp-netlib.sourceforge.net for library home page. // +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/impl/request.hpp b/include/network/protocol/http/impl/request.hpp index 776f14892..a257d0a39 100644 --- a/include/network/protocol/http/impl/request.hpp +++ b/include/network/protocol/http/impl/request.hpp @@ -1,6 +1,7 @@ // Copyright Dean Michael Berris 2007,2009,2010. // Copyright Michael Dickey 2008. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/impl/request_parser.ipp b/include/network/protocol/http/impl/request_parser.ipp index bb75913db..885f91f2d 100644 --- a/include/network/protocol/http/impl/request_parser.ipp +++ b/include/network/protocol/http/impl/request_parser.ipp @@ -8,6 +8,7 @@ // Copyright (c) 2009 Dean Michael Berris (dberris@google.com) // Copyright (c) 2009 Tarroo, Inc. // +// Copyright 2012 Google, Inc. // 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) // diff --git a/include/network/protocol/http/impl/response.ipp b/include/network/protocol/http/impl/response.ipp index 661f472dc..7513b2169 100644 --- a/include/network/protocol/http/impl/response.ipp +++ b/include/network/protocol/http/impl/response.ipp @@ -3,6 +3,7 @@ // Copyright (c) 2009 Dean Michael Berris (dberris@google.com) // Copyright (c) 2009 Tarroo, Inc. // +// Copyright 2012 Google, Inc. // 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) // diff --git a/include/network/protocol/http/message/directives/major_version.hpp b/include/network/protocol/http/message/directives/major_version.hpp index 55abe29bd..231ff3dc3 100644 --- a/include/network/protocol/http/message/directives/major_version.hpp +++ b/include/network/protocol/http/message/directives/major_version.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_MAJOR_VERSION_HPP_20101120 // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/message/directives/method.hpp b/include/network/protocol/http/message/directives/method.hpp index a79718f54..5e6af91c9 100644 --- a/include/network/protocol/http/message/directives/method.hpp +++ b/include/network/protocol/http/message/directives/method.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_METHOD_HPP_20101120 // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/message/directives/minor_version.hpp b/include/network/protocol/http/message/directives/minor_version.hpp index 3e0a2b2e8..5fbfc3a10 100644 --- a/include/network/protocol/http/message/directives/minor_version.hpp +++ b/include/network/protocol/http/message/directives/minor_version.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_MINOR_VERSION_HPP_20101120 // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/message/directives/status_message.hpp b/include/network/protocol/http/message/directives/status_message.hpp index dde19a27a..f2890be85 100644 --- a/include/network/protocol/http/message/directives/status_message.hpp +++ b/include/network/protocol/http/message/directives/status_message.hpp @@ -3,6 +3,7 @@ // Copyright 2010 (c) Dean Michael Berris // Copyright 2010 (c) Sinefunc, Inc. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/message/directives/uri.hpp b/include/network/protocol/http/message/directives/uri.hpp index 81fdfb1a5..bf1058e60 100644 --- a/include/network/protocol/http/message/directives/uri.hpp +++ b/include/network/protocol/http/message/directives/uri.hpp @@ -3,6 +3,7 @@ // Copyright 2010 (c) Dean Michael Berris // Copyright 2010 (c) Sinefunc, Inc. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/message/directives/version.hpp b/include/network/protocol/http/message/directives/version.hpp index 092640069..13ba37d12 100644 --- a/include/network/protocol/http/message/directives/version.hpp +++ b/include/network/protocol/http/message/directives/version.hpp @@ -3,6 +3,7 @@ // Copyright 2010 (c) Dean Michael Berris // Copyright 2010 (c) Sinefunc, Inc. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/message/header.hpp b/include/network/protocol/http/message/header.hpp index 8984ef887..5d5579ecb 100644 --- a/include/network/protocol/http/message/header.hpp +++ b/include/network/protocol/http/message/header.hpp @@ -6,6 +6,7 @@ // Copyright (c) 2009,2010 Dean Michael Berris (dberris@google.com) // Copyright (c) 2009 Tarroo, Inc. // +// Copyright 2012 Google, Inc. // 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) // diff --git a/include/network/protocol/http/message/header/name.hpp b/include/network/protocol/http/message/header/name.hpp index 0d6ac61a8..55c6210d8 100644 --- a/include/network/protocol/http/message/header/name.hpp +++ b/include/network/protocol/http/message/header/name.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_NAME_HPP_20101028 // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/message/header/value.hpp b/include/network/protocol/http/message/header/value.hpp index 3be67c91e..6aa2c35b1 100644 --- a/include/network/protocol/http/message/header/value.hpp +++ b/include/network/protocol/http/message/header/value.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_VALUE_HPP_20101028 // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/message/header_concept.hpp b/include/network/protocol/http/message/header_concept.hpp index 538a3b067..cd44d9016 100644 --- a/include/network/protocol/http/message/header_concept.hpp +++ b/include/network/protocol/http/message/header_concept.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_CONCEPT_HPP_20101028 // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/message/modifiers/major_version.hpp b/include/network/protocol/http/message/modifiers/major_version.hpp index fe4a908ca..7b25d7b24 100644 --- a/include/network/protocol/http/message/modifiers/major_version.hpp +++ b/include/network/protocol/http/message/modifiers/major_version.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_MAJOR_VERSION_HPP_20101120 // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/message/modifiers/method.hpp b/include/network/protocol/http/message/modifiers/method.hpp index 4883f84c0..7865af698 100644 --- a/include/network/protocol/http/message/modifiers/method.hpp +++ b/include/network/protocol/http/message/modifiers/method.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_METHOD_HPP_20101118 // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/message/modifiers/minor_version.hpp b/include/network/protocol/http/message/modifiers/minor_version.hpp index cb9afa5e3..ad7a60b8a 100644 --- a/include/network/protocol/http/message/modifiers/minor_version.hpp +++ b/include/network/protocol/http/message/modifiers/minor_version.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_MINOR_VERSION_HPP_20101120 // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/message/modifiers/status.hpp b/include/network/protocol/http/message/modifiers/status.hpp index 10cff038a..44e06c5ba 100644 --- a/include/network/protocol/http/message/modifiers/status.hpp +++ b/include/network/protocol/http/message/modifiers/status.hpp @@ -3,6 +3,7 @@ // Copyright 2010 (c) Dean Michael Berris // Copyright 2010 (c) Sinefunc, Inc. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/message/modifiers/status_message.hpp b/include/network/protocol/http/message/modifiers/status_message.hpp index c051479a0..6ea3e509d 100644 --- a/include/network/protocol/http/message/modifiers/status_message.hpp +++ b/include/network/protocol/http/message/modifiers/status_message.hpp @@ -3,6 +3,7 @@ // Copyright 2010 (c) Dean Michael Berris // Copyright 2010 (c) Sinefunc, Inc. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/message/modifiers/version.hpp b/include/network/protocol/http/message/modifiers/version.hpp index 363205e79..54f9151ac 100644 --- a/include/network/protocol/http/message/modifiers/version.hpp +++ b/include/network/protocol/http/message/modifiers/version.hpp @@ -3,6 +3,7 @@ // Copyright 2010 (c) Dean Michael Berris // Copyright 2010 (c) Sinefunc, Inc. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/message/wrappers/anchor.ipp b/include/network/protocol/http/message/wrappers/anchor.ipp index 6742623d8..792b62668 100644 --- a/include/network/protocol/http/message/wrappers/anchor.ipp +++ b/include/network/protocol/http/message/wrappers/anchor.ipp @@ -3,6 +3,7 @@ // Copyright 2011 Dean Michael Berris . // Copyright 2011 Googl,Inc. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/message/wrappers/helper.hpp b/include/network/protocol/http/message/wrappers/helper.hpp index e433249ee..1085da505 100644 --- a/include/network/protocol/http/message/wrappers/helper.hpp +++ b/include/network/protocol/http/message/wrappers/helper.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_HELPER_20101013 // Copyright 2010 (c) Dean Michael Berris +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/message/wrappers/major_version.hpp b/include/network/protocol/http/message/wrappers/major_version.hpp index c1b69f167..a884aaa0f 100644 --- a/include/network/protocol/http/message/wrappers/major_version.hpp +++ b/include/network/protocol/http/message/wrappers/major_version.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_MAJOR_VERSION_HPP_20101120 // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/message/wrappers/method.hpp b/include/network/protocol/http/message/wrappers/method.hpp index 6c8c375f5..e3e46adc8 100644 --- a/include/network/protocol/http/message/wrappers/method.hpp +++ b/include/network/protocol/http/message/wrappers/method.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_METHOD_HPP_20101118 // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/message/wrappers/minor_version.hpp b/include/network/protocol/http/message/wrappers/minor_version.hpp index 27e4bfd05..313e7c1f0 100644 --- a/include/network/protocol/http/message/wrappers/minor_version.hpp +++ b/include/network/protocol/http/message/wrappers/minor_version.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_MINOR_VERSION_HPP_20101120 // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/message/wrappers/ready.hpp b/include/network/protocol/http/message/wrappers/ready.hpp index 1ea06574e..08a068d18 100644 --- a/include/network/protocol/http/message/wrappers/ready.hpp +++ b/include/network/protocol/http/message/wrappers/ready.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_READY_HPP_20100618 // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/message/wrappers/status.hpp b/include/network/protocol/http/message/wrappers/status.hpp index cb902ca54..a2dbe7ca5 100644 --- a/include/network/protocol/http/message/wrappers/status.hpp +++ b/include/network/protocol/http/message/wrappers/status.hpp @@ -3,6 +3,7 @@ // Copyright 2010 (c) Dean Michael Berris // Copyright 2010 (c) Sinefunc, Inc. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/message/wrappers/status_message.hpp b/include/network/protocol/http/message/wrappers/status_message.hpp index 50076d245..95153992c 100644 --- a/include/network/protocol/http/message/wrappers/status_message.hpp +++ b/include/network/protocol/http/message/wrappers/status_message.hpp @@ -3,6 +3,7 @@ // Copyright 2010 (c) Dean Michael Berris // Copyright 2010 (c) Sinefunc, Inc. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/message/wrappers/uri.hpp b/include/network/protocol/http/message/wrappers/uri.hpp index f577fb4d5..3ec2f9864 100644 --- a/include/network/protocol/http/message/wrappers/uri.hpp +++ b/include/network/protocol/http/message/wrappers/uri.hpp @@ -3,6 +3,7 @@ // Copyright 2010 (c) Dean Michael Berris. // Copyright 2010 (c) Sinefunc, Inc. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/parser.hpp b/include/network/protocol/http/parser.hpp index bf7cd62b8..79a252272 100644 --- a/include/network/protocol/http/parser.hpp +++ b/include/network/protocol/http/parser.hpp @@ -3,6 +3,7 @@ // Copyright Atomic Labs, Inc. 2007-2008 // See http://cpp-netlib.sourceforge.net for library home page. // +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/request/request_concept.hpp b/include/network/protocol/http/request/request_concept.hpp index 3dd550557..3d1e5225c 100644 --- a/include/network/protocol/http/request/request_concept.hpp +++ b/include/network/protocol/http/request/request_concept.hpp @@ -3,6 +3,7 @@ // Copyright 2010 (c) Dean Michael Berris. // Copyright 2010 (c) Sinefunc, Inc. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/response.hpp b/include/network/protocol/http/response.hpp index e30d37eec..568a57f38 100644 --- a/include/network/protocol/http/response.hpp +++ b/include/network/protocol/http/response.hpp @@ -1,5 +1,6 @@ // Copyright Dean Michael Berris 2007. // Copyright Michael Dickey 2008. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/response/response_concept.hpp b/include/network/protocol/http/response/response_concept.hpp index b671b2134..b79d3db82 100644 --- a/include/network/protocol/http/response/response_concept.hpp +++ b/include/network/protocol/http/response/response_concept.hpp @@ -3,6 +3,7 @@ // Copyright 2010 (c) Dean Michael Berris. // Copyright 2010 (c) Sinefunc, Inc. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/server/async_server.hpp b/include/network/protocol/http/server/async_server.hpp index f9b401974..c5c4eefb0 100644 --- a/include/network/protocol/http/server/async_server.hpp +++ b/include/network/protocol/http/server/async_server.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_SERVER_HPP_20101025 // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/server/impl/parsers.ipp b/include/network/protocol/http/server/impl/parsers.ipp index c9cafb700..2292e87dd 100644 --- a/include/network/protocol/http/server/impl/parsers.ipp +++ b/include/network/protocol/http/server/impl/parsers.ipp @@ -4,6 +4,7 @@ #include // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/server/parameters.hpp b/include/network/protocol/http/server/parameters.hpp index 6ae494238..73051e554 100644 --- a/include/network/protocol/http/server/parameters.hpp +++ b/include/network/protocol/http/server/parameters.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_PARAMETERS_HPP_20101210 // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/server/request.hpp b/include/network/protocol/http/server/request.hpp index 6c6760a47..907d0b458 100644 --- a/include/network/protocol/http/server/request.hpp +++ b/include/network/protocol/http/server/request.hpp @@ -6,6 +6,7 @@ // Copyright (c) 2009 Dean Michael Berris (dberris@google.com) // Copyright (c) 2009 Tarro, Inc. // +// Copyright 2012 Google, Inc. // 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) // diff --git a/include/network/protocol/http/server/request_parser.hpp b/include/network/protocol/http/server/request_parser.hpp index b4672529a..24df5d6aa 100644 --- a/include/network/protocol/http/server/request_parser.hpp +++ b/include/network/protocol/http/server/request_parser.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_REQUEST_PARSER_HPP_20101005 // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/server/socket_options_base.hpp b/include/network/protocol/http/server/socket_options_base.hpp index 65be8552c..9f4a34751 100644 --- a/include/network/protocol/http/server/socket_options_base.hpp +++ b/include/network/protocol/http/server/socket_options_base.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_SOCKET_OPTIONS_BASE_HPP_20101210 // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/server/storage_base.hpp b/include/network/protocol/http/server/storage_base.hpp index 0943e6a7f..23ad10863 100644 --- a/include/network/protocol/http/server/storage_base.hpp +++ b/include/network/protocol/http/server/storage_base.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_STORAGE_BASE_HPP_20101210 // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/server/sync_server.hpp b/include/network/protocol/http/server/sync_server.hpp index 8c41839d8..27b68fd5f 100644 --- a/include/network/protocol/http/server/sync_server.hpp +++ b/include/network/protocol/http/server/sync_server.hpp @@ -1,6 +1,7 @@ // Copyright 2010 Dean Michael Berris. // Copyright 2010 Glyn Matthews. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/support/client_or_server.hpp b/include/network/protocol/http/support/client_or_server.hpp index e4e3eb41b..90f5ab900 100644 --- a/include/network/protocol/http/support/client_or_server.hpp +++ b/include/network/protocol/http/support/client_or_server.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_SUPPORT_CLIENT_OR_SERVER_HPP_20101127 // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/support/is_client.hpp b/include/network/protocol/http/support/is_client.hpp index 0958401e8..20d275e01 100644 --- a/include/network/protocol/http/support/is_client.hpp +++ b/include/network/protocol/http/support/is_client.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_SUPPORT_IS_CLIENT_HPP_20101118 // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/support/is_http.hpp b/include/network/protocol/http/support/is_http.hpp index d87374526..31fb5e4fb 100644 --- a/include/network/protocol/http/support/is_http.hpp +++ b/include/network/protocol/http/support/is_http.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_SUPPORT_IS_HTTP_HPP_20100622 // Copyright 2010 (c) Dean Michael Berris +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/support/is_keepalive.hpp b/include/network/protocol/http/support/is_keepalive.hpp index 714328897..4331eae1d 100644 --- a/include/network/protocol/http/support/is_keepalive.hpp +++ b/include/network/protocol/http/support/is_keepalive.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_SUPPORT_IS_KEEPALIVE_HPP_20100927 // Copyright 2010 (c) Dean Michael Berris +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/support/is_server.hpp b/include/network/protocol/http/support/is_server.hpp index 934e36a07..4baee3e20 100644 --- a/include/network/protocol/http/support/is_server.hpp +++ b/include/network/protocol/http/support/is_server.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_SUPPORT_IS_SERVER_HPP_20101118 // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/support/is_simple.hpp b/include/network/protocol/http/support/is_simple.hpp index 720e250ad..b2b35006d 100644 --- a/include/network/protocol/http/support/is_simple.hpp +++ b/include/network/protocol/http/support/is_simple.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_SUPPORT_IS_SIMPLE_HPP_20100927 // Copyright 2010 (c) Dean Michael Berris +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/protocol/http/support/sync_only.hpp b/include/network/protocol/http/support/sync_only.hpp index 9198ec847..940948318 100644 --- a/include/network/protocol/http/support/sync_only.hpp +++ b/include/network/protocol/http/support/sync_only.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_PROTOCOL_HTTP_SUPPORT_SYNC_ONLY_HPP_20100927 // Copyright Dean Michael Berris 2010. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/uri.hpp b/include/network/uri.hpp index 5a4d99323..4819cbce0 100644 --- a/include/network/uri.hpp +++ b/include/network/uri.hpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2012. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/uri/accessors.hpp b/include/network/uri/accessors.hpp index a6fedf38a..1afecf471 100644 --- a/include/network/uri/accessors.hpp +++ b/include/network/uri/accessors.hpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2011, 2012. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/uri/builder.hpp b/include/network/uri/builder.hpp index a8c7e76aa..e8881926e 100644 --- a/include/network/uri/builder.hpp +++ b/include/network/uri/builder.hpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2012. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/uri/config.hpp b/include/network/uri/config.hpp index 0cb9e17a9..9b395c9cb 100644 --- a/include/network/uri/config.hpp +++ b/include/network/uri/config.hpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2012. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/uri/decode.hpp b/include/network/uri/decode.hpp index 78cf098a7..ba64148e0 100644 --- a/include/network/uri/decode.hpp +++ b/include/network/uri/decode.hpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2011, 2012. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/uri/detail/uri_parts.hpp b/include/network/uri/detail/uri_parts.hpp index 9293fb860..c012f1de3 100644 --- a/include/network/uri/detail/uri_parts.hpp +++ b/include/network/uri/detail/uri_parts.hpp @@ -1,4 +1,5 @@ // Copyright 2009-2012 Dean Michael Berris, Jeroen Habraken, Glyn Matthews. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/uri/directives.hpp b/include/network/uri/directives.hpp index e4558a4d0..9a6a82c3c 100644 --- a/include/network/uri/directives.hpp +++ b/include/network/uri/directives.hpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2011, 2012. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/uri/directives/authority.hpp b/include/network/uri/directives/authority.hpp index eab8bffd8..f6b9110dc 100644 --- a/include/network/uri/directives/authority.hpp +++ b/include/network/uri/directives/authority.hpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2011, 2012. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/uri/directives/fragment.hpp b/include/network/uri/directives/fragment.hpp index 60dfb6636..54981eef2 100644 --- a/include/network/uri/directives/fragment.hpp +++ b/include/network/uri/directives/fragment.hpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2011, 2012. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/uri/directives/host.hpp b/include/network/uri/directives/host.hpp index 9a0e9342b..531b290c1 100644 --- a/include/network/uri/directives/host.hpp +++ b/include/network/uri/directives/host.hpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2011, 2012. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/uri/directives/path.hpp b/include/network/uri/directives/path.hpp index 7ea5ada0b..e09eda4f4 100644 --- a/include/network/uri/directives/path.hpp +++ b/include/network/uri/directives/path.hpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2011, 2012. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/uri/directives/port.hpp b/include/network/uri/directives/port.hpp index 672ee7921..c5e26a406 100644 --- a/include/network/uri/directives/port.hpp +++ b/include/network/uri/directives/port.hpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2011, 2012. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/uri/directives/query.hpp b/include/network/uri/directives/query.hpp index 80a37adb2..5f107723d 100644 --- a/include/network/uri/directives/query.hpp +++ b/include/network/uri/directives/query.hpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2011, 2012. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/uri/directives/scheme.hpp b/include/network/uri/directives/scheme.hpp index 9b4ea23ca..7446cd0fd 100644 --- a/include/network/uri/directives/scheme.hpp +++ b/include/network/uri/directives/scheme.hpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2011, 2012. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/uri/directives/user_info.hpp b/include/network/uri/directives/user_info.hpp index 9969e63f9..af33e45f3 100644 --- a/include/network/uri/directives/user_info.hpp +++ b/include/network/uri/directives/user_info.hpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2011, 2012. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/uri/encode.hpp b/include/network/uri/encode.hpp index 3d0945781..f359438df 100644 --- a/include/network/uri/encode.hpp +++ b/include/network/uri/encode.hpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2011, 2012. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/uri/schemes.hpp b/include/network/uri/schemes.hpp index 10bb3bce4..ca945b7f5 100644 --- a/include/network/uri/schemes.hpp +++ b/include/network/uri/schemes.hpp @@ -1,4 +1,5 @@ // Copyright 2012 Glyn Matthews. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/uri/uri.hpp b/include/network/uri/uri.hpp index 332cbeae2..d052dd1ed 100644 --- a/include/network/uri/uri.hpp +++ b/include/network/uri/uri.hpp @@ -1,4 +1,5 @@ // Copyright 2009-2012 Dean Michael Berris, Jeroen Habraken, Glyn Matthews. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/uri/uri.ipp b/include/network/uri/uri.ipp index 38bcf53f6..cf3a49ccf 100644 --- a/include/network/uri/uri.ipp +++ b/include/network/uri/uri.ipp @@ -1,4 +1,5 @@ // Copyright 2009-2012 Dean Michael Berris, Jeroen Habraken, Glyn Matthews. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/uri/uri_io.hpp b/include/network/uri/uri_io.hpp index e06c03143..c71ff898f 100644 --- a/include/network/uri/uri_io.hpp +++ b/include/network/uri/uri_io.hpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2011, 2012. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/utils/thread_pool.hpp b/include/network/utils/thread_pool.hpp index d562fb148..375e4acc7 100644 --- a/include/network/utils/thread_pool.hpp +++ b/include/network/utils/thread_pool.hpp @@ -2,6 +2,7 @@ #define BOOST_NETWORK_UTILS_THREAD_POOL_HPP_20101020 // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/include/network/version.hpp b/include/network/version.hpp index 7e08f6b6e..3046c7f3e 100644 --- a/include/network/version.hpp +++ b/include/network/version.hpp @@ -3,6 +3,7 @@ // Copyright Dean Michael Berris 2009. // Copyright Glyn Matthews 2010. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/example/atom/atom.cpp b/libs/network/example/atom/atom.cpp index 7555956b6..7fa57f611 100644 --- a/libs/network/example/atom/atom.cpp +++ b/libs/network/example/atom/atom.cpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2011. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/example/atom/atom.hpp b/libs/network/example/atom/atom.hpp index 909d69bc9..9c5cd06e0 100644 --- a/libs/network/example/atom/atom.hpp +++ b/libs/network/example/atom/atom.hpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2011. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/example/atom/main.cpp b/libs/network/example/atom/main.cpp index 3c3ab09de..71be07864 100644 --- a/libs/network/example/atom/main.cpp +++ b/libs/network/example/atom/main.cpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2011. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/example/http/fileserver.cpp b/libs/network/example/http/fileserver.cpp index 00652177f..5ae98de8e 100644 --- a/libs/network/example/http/fileserver.cpp +++ b/libs/network/example/http/fileserver.cpp @@ -1,4 +1,5 @@ // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/example/http/hello_world_client.cpp b/libs/network/example/http/hello_world_client.cpp index 1d30e8cec..27b0215e3 100644 --- a/libs/network/example/http/hello_world_client.cpp +++ b/libs/network/example/http/hello_world_client.cpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2010. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/example/http/hello_world_server.cpp b/libs/network/example/http/hello_world_server.cpp index 83f09ec61..95880b367 100644 --- a/libs/network/example/http/hello_world_server.cpp +++ b/libs/network/example/http/hello_world_server.cpp @@ -1,5 +1,6 @@ // Copyright 2009 (c) Tarro, Inc. // Copyright 2009 (c) Dean Michael Berris +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/example/http/one_liner.cpp b/libs/network/example/http/one_liner.cpp index aa0a990b9..3122e0f98 100644 --- a/libs/network/example/http/one_liner.cpp +++ b/libs/network/example/http/one_liner.cpp @@ -1,5 +1,6 @@ // Copyright Dean Michael Berris 2010. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/example/http_client.cpp b/libs/network/example/http_client.cpp index 056360af9..74de2895a 100644 --- a/libs/network/example/http_client.cpp +++ b/libs/network/example/http_client.cpp @@ -1,5 +1,6 @@ // Copyright Dean Michael Berris 2008. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/example/http_client1.cpp b/libs/network/example/http_client1.cpp index 7e641df45..f321cb7fc 100644 --- a/libs/network/example/http_client1.cpp +++ b/libs/network/example/http_client1.cpp @@ -1,4 +1,5 @@ // Copyright Dean Michael Berris 2011. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/example/rss/main.cpp b/libs/network/example/rss/main.cpp index 138b4fe75..118a62942 100644 --- a/libs/network/example/rss/main.cpp +++ b/libs/network/example/rss/main.cpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2011. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/example/rss/rss.cpp b/libs/network/example/rss/rss.cpp index f4864c1ef..b7f7edbb4 100644 --- a/libs/network/example/rss/rss.cpp +++ b/libs/network/example/rss/rss.cpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2011. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/example/rss/rss.hpp b/libs/network/example/rss/rss.hpp index 067ef8360..93985f2b8 100644 --- a/libs/network/example/rss/rss.hpp +++ b/libs/network/example/rss/rss.hpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2011. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/example/simple_wget.cpp b/libs/network/example/simple_wget.cpp index 28e8f43f3..bf7253f8d 100644 --- a/libs/network/example/simple_wget.cpp +++ b/libs/network/example/simple_wget.cpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2009-2012. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/example/twitter/search.cpp b/libs/network/example/twitter/search.cpp index 2a99d8b63..87513fdae 100644 --- a/libs/network/example/twitter/search.cpp +++ b/libs/network/example/twitter/search.cpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2011, 2012. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/example/uri_builder.cpp b/libs/network/example/uri_builder.cpp index 5045c63b9..3507e088a 100644 --- a/libs/network/example/uri_builder.cpp +++ b/libs/network/example/uri_builder.cpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2011, 2012. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/src/server_request_parsers_impl.cpp b/libs/network/src/server_request_parsers_impl.cpp index e63497d19..061b5b838 100644 --- a/libs/network/src/server_request_parsers_impl.cpp +++ b/libs/network/src/server_request_parsers_impl.cpp @@ -1,4 +1,5 @@ // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/src/uri/schemes.cpp b/libs/network/src/uri/schemes.cpp index c03eac06e..a9905c74f 100644 --- a/libs/network/src/uri/schemes.cpp +++ b/libs/network/src/uri/schemes.cpp @@ -1,4 +1,5 @@ // Copyright 2012 Glyn Matthews. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/src/uri/uri.cpp b/libs/network/src/uri/uri.cpp index edfca04dc..b0a378e99 100644 --- a/libs/network/src/uri/uri.cpp +++ b/libs/network/src/uri/uri.cpp @@ -1,4 +1,5 @@ // Copyright 2012 Glyn Matthews. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/test/client_server_include_failure.cpp b/libs/network/test/client_server_include_failure.cpp index f43d3949f..e2eecc5a1 100644 --- a/libs/network/test/client_server_include_failure.cpp +++ b/libs/network/test/client_server_include_failure.cpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2010. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/test/http/client_constructor_test.cpp b/libs/network/test/http/client_constructor_test.cpp index fac61d9d2..6448c2eeb 100644 --- a/libs/network/test/http/client_constructor_test.cpp +++ b/libs/network/test/http/client_constructor_test.cpp @@ -1,5 +1,6 @@ // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/test/http/client_get_different_port_test.cpp b/libs/network/test/http/client_get_different_port_test.cpp index c60a671d3..8c3a0dbf2 100644 --- a/libs/network/test/http/client_get_different_port_test.cpp +++ b/libs/network/test/http/client_get_different_port_test.cpp @@ -1,5 +1,6 @@ // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/test/http/client_get_streaming_test.cpp b/libs/network/test/http/client_get_streaming_test.cpp index 5e2de35a0..4db77c9cb 100644 --- a/libs/network/test/http/client_get_streaming_test.cpp +++ b/libs/network/test/http/client_get_streaming_test.cpp @@ -1,4 +1,5 @@ // Copyright 2011 Dean Michael Berris <dberris@google.com>. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/test/http/client_get_test.cpp b/libs/network/test/http/client_get_test.cpp index 57c0397f6..901055730 100644 --- a/libs/network/test/http/client_get_test.cpp +++ b/libs/network/test/http/client_get_test.cpp @@ -1,4 +1,5 @@ // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/test/http/client_get_timeout_test.cpp b/libs/network/test/http/client_get_timeout_test.cpp index ce66308c8..370684b86 100644 --- a/libs/network/test/http/client_get_timeout_test.cpp +++ b/libs/network/test/http/client_get_timeout_test.cpp @@ -1,5 +1,6 @@ // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/test/http/client_include_inlined.cpp b/libs/network/test/http/client_include_inlined.cpp index b1a708d21..cb0c0a20d 100644 --- a/libs/network/test/http/client_include_inlined.cpp +++ b/libs/network/test/http/client_include_inlined.cpp @@ -1,4 +1,5 @@ // Copyright 2011 Dean Michael Berris <dberris@google.com>. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/test/http/client_localhost_normal_test.cpp b/libs/network/test/http/client_localhost_normal_test.cpp index 8f247d54f..d332b430a 100644 --- a/libs/network/test/http/client_localhost_normal_test.cpp +++ b/libs/network/test/http/client_localhost_normal_test.cpp @@ -1,5 +1,6 @@ // // Copyright Divye Kapoor 2008. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/test/http/client_localhost_ssl_test.cpp b/libs/network/test/http/client_localhost_ssl_test.cpp index 4e1ac179e..e1e1f173f 100644 --- a/libs/network/test/http/client_localhost_ssl_test.cpp +++ b/libs/network/test/http/client_localhost_ssl_test.cpp @@ -1,5 +1,6 @@ // // Copyright Divye Kapoor 2008. +// Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // https://www.boost.org/LICENSE_1_0.txt) diff --git a/libs/network/test/http/http_test_server.hpp b/libs/network/test/http/http_test_server.hpp index 293c9d9d8..c5ae823cb 100644 --- a/libs/network/test/http/http_test_server.hpp +++ b/libs/network/test/http/http_test_server.hpp @@ -1,5 +1,6 @@ // // Copyright Kim Grasman 2008. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/test/http/message_async_ready_test.cpp b/libs/network/test/http/message_async_ready_test.cpp index 15d1a85c7..31570aded 100644 --- a/libs/network/test/http/message_async_ready_test.cpp +++ b/libs/network/test/http/message_async_ready_test.cpp @@ -1,5 +1,6 @@ // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/test/http/message_test.cpp b/libs/network/test/http/message_test.cpp index b7d8dd1bb..abffdeef9 100644 --- a/libs/network/test/http/message_test.cpp +++ b/libs/network/test/http/message_test.cpp @@ -1,5 +1,6 @@ // Copyright 2010 (c) Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/test/http/request_incremental_parser_test.cpp b/libs/network/test/http/request_incremental_parser_test.cpp index e865efa02..59dccf2e9 100644 --- a/libs/network/test/http/request_incremental_parser_test.cpp +++ b/libs/network/test/http/request_incremental_parser_test.cpp @@ -1,4 +1,5 @@ // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/test/http/request_linearize_test.cpp b/libs/network/test/http/request_linearize_test.cpp index 41fc0d81d..0b54a5d2a 100644 --- a/libs/network/test/http/request_linearize_test.cpp +++ b/libs/network/test/http/request_linearize_test.cpp @@ -1,5 +1,6 @@ // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/test/http/response_incremental_parser_test.cpp b/libs/network/test/http/response_incremental_parser_test.cpp index afcc3e226..dd3ab1e7b 100644 --- a/libs/network/test/http/response_incremental_parser_test.cpp +++ b/libs/network/test/http/response_incremental_parser_test.cpp @@ -1,5 +1,6 @@ // Copyright Dean Michael Berris 2010. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/test/http/server_async.cpp b/libs/network/test/http/server_async.cpp index 6a3ae78ec..a90eb0d46 100644 --- a/libs/network/test/http/server_async.cpp +++ b/libs/network/test/http/server_async.cpp @@ -1,5 +1,6 @@ // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/test/http/server_async_less_copy.cpp b/libs/network/test/http/server_async_less_copy.cpp index 2f46f25ec..41a65f0c6 100644 --- a/libs/network/test/http/server_async_less_copy.cpp +++ b/libs/network/test/http/server_async_less_copy.cpp @@ -1,5 +1,6 @@ // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/test/http/server_constructor_test.cpp b/libs/network/test/http/server_constructor_test.cpp index 986570942..179f98698 100644 --- a/libs/network/test/http/server_constructor_test.cpp +++ b/libs/network/test/http/server_constructor_test.cpp @@ -1,5 +1,6 @@ // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/test/http/server_hello_world.cpp b/libs/network/test/http/server_hello_world.cpp index fa3e0963f..aaff707c1 100644 --- a/libs/network/test/http/server_hello_world.cpp +++ b/libs/network/test/http/server_hello_world.cpp @@ -1,5 +1,6 @@ // Copyright 2009 (c) Tarro, Inc. // Copyright 2009-2010 (c) Dean Michael Berris +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/test/http/server_include_inlined.cpp b/libs/network/test/http/server_include_inlined.cpp index 349e79bd5..e27802fcd 100644 --- a/libs/network/test/http/server_include_inlined.cpp +++ b/libs/network/test/http/server_include_inlined.cpp @@ -1,5 +1,6 @@ // Copyright 2009 (c) Tarro, Inc. // Copyright 2009-2010 (c) Dean Michael Berris +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/test/http_server_async_less_copy.cpp b/libs/network/test/http_server_async_less_copy.cpp index d443cb12c..62dfa081c 100644 --- a/libs/network/test/http_server_async_less_copy.cpp +++ b/libs/network/test/http_server_async_less_copy.cpp @@ -1,5 +1,6 @@ // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/test/message_test.cpp b/libs/network/test/message_test.cpp index 9891bcb3c..7114dcb7e 100644 --- a/libs/network/test/message_test.cpp +++ b/libs/network/test/message_test.cpp @@ -1,5 +1,6 @@ // Copyright Dean Michael Berris 2007. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/test/message_transform_test.cpp b/libs/network/test/message_transform_test.cpp index b45d1586b..a70341aec 100644 --- a/libs/network/test/message_transform_test.cpp +++ b/libs/network/test/message_transform_test.cpp @@ -1,5 +1,6 @@ // Copyright Dean Michael Berris 2007. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/test/uri/relative_uri_test.cpp b/libs/network/test/uri/relative_uri_test.cpp index 4c8dd52c3..08ebbfd47 100644 --- a/libs/network/test/uri/relative_uri_test.cpp +++ b/libs/network/test/uri/relative_uri_test.cpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2012. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/test/uri/uri_builder_stream_test.cpp b/libs/network/test/uri/uri_builder_stream_test.cpp index 5899a3b51..73ab0dbb5 100644 --- a/libs/network/test/uri/uri_builder_stream_test.cpp +++ b/libs/network/test/uri/uri_builder_stream_test.cpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2011. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/test/uri/uri_builder_test.cpp b/libs/network/test/uri/uri_builder_test.cpp index cb17f5bce..e04a0c3c4 100644 --- a/libs/network/test/uri/uri_builder_test.cpp +++ b/libs/network/test/uri/uri_builder_test.cpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2012. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/test/uri/uri_encoding_test.cpp b/libs/network/test/uri/uri_encoding_test.cpp index bc184006b..6a2b4fa98 100644 --- a/libs/network/test/uri/uri_encoding_test.cpp +++ b/libs/network/test/uri/uri_encoding_test.cpp @@ -1,4 +1,5 @@ // Copyright (c) Glyn Matthews 2011, 2012. +// Copyright 2012 Google, Inc. // 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) diff --git a/libs/network/test/uri/uri_test.cpp b/libs/network/test/uri/uri_test.cpp index 80dae667b..699c2340f 100644 --- a/libs/network/test/uri/uri_test.cpp +++ b/libs/network/test/uri/uri_test.cpp @@ -1,4 +1,5 @@ // Copyright 2009-2012 Dean Michael Berris, Jeroen Habraken, Glyn Matthews. +// Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt of copy at // http://www.boost.org/LICENSE_1_0.txt) diff --git a/libs/network/test/utils_thread_pool.cpp b/libs/network/test/utils_thread_pool.cpp index 429400c94..ca7fc11cd 100644 --- a/libs/network/test/utils_thread_pool.cpp +++ b/libs/network/test/utils_thread_pool.cpp @@ -1,5 +1,6 @@ // Copyright 2010 Dean Michael Berris. +// Copyright 2012 Google, Inc. // 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) From 5be546f79166e6a65e7c07476bcf7f0a75c73e08 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Mon, 10 Sep 2012 03:45:57 +1000 Subject: [PATCH 109/196] Additional edits to fix up merge. --- include/network/http/client.hpp | 2 +- include/network/http/errors.hpp | 2 +- include/network/http/request.hpp | 2 +- include/network/http/response.hpp | 2 +- .../network/protocol/http/message/wrappers/status_message.hpp | 2 +- include/network/protocol/http/message/wrappers/version.hpp | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/network/http/client.hpp b/include/network/http/client.hpp index 22ef1f40f..a044e5902 100644 --- a/include/network/http/client.hpp +++ b/include/network/http/client.hpp @@ -6,7 +6,7 @@ #ifndef __NETWORK_HTTP_CLIENT_INC__ # define __NETWORK_HTTP_CLIENT_INC__ -# include +# include # include # include # include diff --git a/include/network/http/errors.hpp b/include/network/http/errors.hpp index 525fe60c0..a694ed8ed 100644 --- a/include/network/http/errors.hpp +++ b/include/network/http/errors.hpp @@ -6,7 +6,7 @@ #ifndef __NETWORK_HTTP_ERRORS_INC__ # define __NETWORK_HTTP_ERRORS_INC__ -# include +# include namespace network { namespace http { diff --git a/include/network/http/request.hpp b/include/network/http/request.hpp index 465c3cc49..74bd07ee5 100644 --- a/include/network/http/request.hpp +++ b/include/network/http/request.hpp @@ -6,7 +6,7 @@ #ifndef __NETWORK_HTTP_REQUEST_INC__ # define __NETWORK_HTTP_REQUEST_INC__ -# include +# include namespace network { namespace http { diff --git a/include/network/http/response.hpp b/include/network/http/response.hpp index 160385f99..13ee8ba30 100644 --- a/include/network/http/response.hpp +++ b/include/network/http/response.hpp @@ -6,7 +6,7 @@ #ifndef __NETWORK_HTTP_RESPONSE_INC__ # define __NETWORK_HTTP_RESPONSE_INC__ -# include +# include namespace network { namespace http { diff --git a/include/network/protocol/http/message/wrappers/status_message.hpp b/include/network/protocol/http/message/wrappers/status_message.hpp index 811601ed6..85e55a484 100644 --- a/include/network/protocol/http/message/wrappers/status_message.hpp +++ b/include/network/protocol/http/message/wrappers/status_message.hpp @@ -9,7 +9,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include +#include #include namespace boost { namespace network { namespace http { diff --git a/include/network/protocol/http/message/wrappers/version.hpp b/include/network/protocol/http/message/wrappers/version.hpp index 10525d62e..c3a9d8404 100644 --- a/include/network/protocol/http/message/wrappers/version.hpp +++ b/include/network/protocol/http/message/wrappers/version.hpp @@ -9,7 +9,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include +#include #include namespace boost { namespace network { namespace http { From c226fd5a87c320a2b6293210ede5c7ab41548198 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Thu, 20 Sep 2012 23:04:20 +1000 Subject: [PATCH 110/196] The great exodus from Boost. --- include/network/constants.hpp | 10 +- include/network/constants.ipp | 14 +- include/network/detail/debug.hpp | 24 +- include/network/detail/directive_base.hpp | 23 +- include/network/detail/wrapper_base.hpp | 40 +- include/network/http/client.hpp | 30 +- include/network/http/errors.hpp | 22 +- include/network/http/request.hpp | 20 +- include/network/http/response.hpp | 20 +- include/network/include/http/client.hpp | 8 +- include/network/include/http/server.hpp | 6 +- include/network/include/message.hpp | 8 +- include/network/message.hpp | 10 +- include/network/message/basic_message.hpp | 20 +- include/network/message/basic_message.ipp | 12 +- include/network/message/directives.hpp | 24 +- .../directives/detail/string_directive.hpp | 47 +- .../directives/detail/string_value.hpp | 55 +- include/network/message/directives/header.hpp | 16 +- include/network/message/directives/header.ipp | 15 +- .../message/directives/remove_header.hpp | 15 +- .../message/directives/remove_header.ipp | 18 +- include/network/message/message.hpp | 21 +- include/network/message/message.ipp | 12 +- include/network/message/message_base.hpp | 14 +- include/network/message/message_base.ipp | 14 +- include/network/message/message_concept.hpp | 16 +- include/network/message/modifiers.hpp | 8 +- .../network/message/modifiers/add_header.hpp | 15 +- include/network/message/modifiers/body.hpp | 10 +- .../message/modifiers/clear_headers.hpp | 10 +- .../network/message/modifiers/destination.hpp | 13 +- .../message/modifiers/remove_header.hpp | 13 +- include/network/message/modifiers/source.hpp | 13 +- include/network/message/transformers.hpp | 89 +- .../message/transformers/selectors.hpp | 90 +- .../network/message/transformers/to_lower.hpp | 26 +- .../network/message/transformers/to_upper.hpp | 28 +- include/network/message/wrappers.hpp | 11 +- include/network/message/wrappers/body.hpp | 16 +- include/network/message/wrappers/body.ipp | 11 +- .../network/message/wrappers/destination.hpp | 16 +- .../network/message/wrappers/destination.ipp | 14 +- include/network/message/wrappers/headers.hpp | 11 +- include/network/message/wrappers/headers.ipp | 12 +- include/network/message/wrappers/source.hpp | 16 +- include/network/message/wrappers/source.ipp | 12 +- include/network/message_fwd.hpp | 15 +- include/network/protocol.hpp | 13 +- include/network/protocol/http.hpp | 13 +- .../protocol/http/algorithms/linearize.hpp | 268 ++- include/network/protocol/http/client.hpp | 18 +- include/network/protocol/http/client.ipp | 15 +- include/network/protocol/http/client/base.hpp | 21 +- include/network/protocol/http/client/base.ipp | 34 +- .../http/client/client_connection.hpp | 12 +- .../http/client/client_connection.ipp | 18 +- .../http/client/connection/async_normal.hpp | 12 +- .../http/client/connection/async_normal.ipp | 127 +- .../connection/async_protocol_handler.hpp | 42 +- .../http/client/connection/async_resolver.hpp | 17 +- .../http/client/connection/async_resolver.ipp | 24 +- .../client/connection/connection_delegate.hpp | 18 +- .../connection_delegate_factory.hpp | 16 +- .../connection_delegate_factory.ipp | 39 +- .../client/connection/connection_factory.hpp | 15 +- .../client/connection/connection_factory.ipp | 13 +- .../client/connection/normal_delegate.hpp | 18 +- .../client/connection/normal_delegate.ipp | 28 +- .../client/connection/resolver_delegate.hpp | 18 +- .../client/connection/resolver_delegate.ipp | 14 +- .../connection/resolver_delegate_factory.hpp | 15 +- .../connection/resolver_delegate_factory.ipp | 20 +- .../connection/simple_connection_factory.hpp | 19 +- .../connection/simple_connection_factory.ipp | 34 +- .../http/client/connection/ssl_delegate.hpp | 25 +- .../http/client/connection/ssl_delegate.ipp | 54 +- .../http/client/connection/sync_base.hpp | 30 +- .../http/client/connection/sync_normal.hpp | 145 +- .../http/client/connection/sync_ssl.hpp | 182 +- .../http/client/connection_manager.hpp | 22 +- .../http/client/connection_manager.ipp | 17 +- .../network/protocol/http/client/facade.hpp | 16 +- .../network/protocol/http/client/facade.ipp | 47 +- .../network/protocol/http/client/macros.hpp | 12 +- .../network/protocol/http/client/options.hpp | 10 +- .../network/protocol/http/client/options.ipp | 9 +- .../protocol/http/client/parameters.hpp | 35 +- .../network/protocol/http/client/pimpl.hpp | 123 +- .../http/client/simple_connection_manager.hpp | 18 +- .../http/client/simple_connection_manager.ipp | 35 +- .../protocol/http/client/sync_impl.hpp | 114 +- include/network/protocol/http/client_fwd.hpp | 22 +- include/network/protocol/http/errors.hpp | 21 +- include/network/protocol/http/impl/access.hpp | 17 +- include/network/protocol/http/impl/access.ipp | 17 +- .../network/protocol/http/impl/message.ipp | 486 +++--- include/network/protocol/http/impl/parser.ipp | 1495 ++++++++--------- .../network/protocol/http/impl/request.hpp | 439 +++-- .../protocol/http/impl/request_parser.ipp | 15 +- .../network/protocol/http/impl/response.ipp | 570 ++++--- .../protocol/http/message/async_message.hpp | 295 ++-- .../protocol/http/message/directives.hpp | 8 +- .../http/message/directives/major_version.hpp | 17 +- .../http/message/directives/method.hpp | 20 +- .../http/message/directives/minor_version.hpp | 56 +- .../http/message/directives/status.hpp | 18 +- .../message/directives/status_message.hpp | 20 +- .../protocol/http/message/directives/uri.hpp | 16 +- .../http/message/directives/version.hpp | 17 +- .../network/protocol/http/message/header.hpp | 64 +- .../protocol/http/message/header/name.hpp | 44 +- .../protocol/http/message/header/value.hpp | 47 +- .../protocol/http/message/header_concept.hpp | 55 +- .../protocol/http/message/modifiers.hpp | 8 +- .../http/message/modifiers/major_version.hpp | 32 +- .../http/message/modifiers/method.hpp | 17 +- .../http/message/modifiers/minor_version.hpp | 33 +- .../http/message/modifiers/status.hpp | 13 +- .../http/message/modifiers/status_message.hpp | 14 +- .../protocol/http/message/modifiers/uri.hpp | 13 +- .../http/message/modifiers/version.hpp | 14 +- .../protocol/http/message/wrappers.hpp | 8 +- .../protocol/http/message/wrappers/anchor.hpp | 14 +- .../protocol/http/message/wrappers/anchor.ipp | 14 +- .../protocol/http/message/wrappers/helper.hpp | 14 +- .../protocol/http/message/wrappers/host.hpp | 14 +- .../protocol/http/message/wrappers/host.ipp | 13 +- .../http/message/wrappers/major_version.hpp | 52 +- .../protocol/http/message/wrappers/method.hpp | 18 +- .../http/message/wrappers/minor_version.hpp | 17 +- .../protocol/http/message/wrappers/path.hpp | 14 +- .../protocol/http/message/wrappers/path.ipp | 13 +- .../protocol/http/message/wrappers/port.hpp | 11 +- .../protocol/http/message/wrappers/port.ipp | 12 +- .../http/message/wrappers/protocol.hpp | 14 +- .../protocol/http/message/wrappers/query.hpp | 14 +- .../protocol/http/message/wrappers/query.ipp | 13 +- .../protocol/http/message/wrappers/ready.hpp | 17 +- .../protocol/http/message/wrappers/status.hpp | 13 +- .../protocol/http/message/wrappers/status.ipp | 13 +- .../http/message/wrappers/status_message.hpp | 14 +- .../http/message/wrappers/status_message.ipp | 13 +- .../protocol/http/message/wrappers/uri.hpp | 14 +- .../protocol/http/message/wrappers/uri.ipp | 15 +- .../http/message/wrappers/version.hpp | 17 +- .../http/message/wrappers/version.ipp | 13 +- include/network/protocol/http/parser.hpp | 19 +- .../protocol/http/parser/incremental.hpp | 15 +- .../http/policies/async_connection.hpp | 13 +- .../http/policies/async_connection.ipp | 30 +- include/network/protocol/http/request.hpp | 8 +- .../network/protocol/http/request/request.hpp | 13 +- .../network/protocol/http/request/request.ipp | 14 +- .../protocol/http/request/request_base.hpp | 15 +- .../protocol/http/request/request_base.ipp | 17 +- .../protocol/http/request/request_concept.hpp | 12 +- .../network/protocol/http/request_parser.hpp | 5 +- include/network/protocol/http/response.hpp | 14 +- .../protocol/http/response/response.hpp | 13 +- .../protocol/http/response/response.ipp | 12 +- .../protocol/http/response/response_base.hpp | 21 +- .../protocol/http/response/response_base.ipp | 16 +- .../http/response/response_concept.hpp | 13 +- include/network/protocol/http/server.hpp | 14 +- .../protocol/http/server/async_impl.hpp | 16 +- .../protocol/http/server/async_impl.ipp | 28 +- .../protocol/http/server/async_server.hpp | 33 +- .../protocol/http/server/connection/async.hpp | 41 +- .../protocol/http/server/connection/sync.hpp | 19 +- .../protocol/http/server/impl/parsers.ipp | 31 +- .../server/impl/socket_options_setter.hpp | 13 +- .../server/impl/socket_options_setter.ipp | 13 +- .../network/protocol/http/server/options.hpp | 12 +- .../network/protocol/http/server/options.ipp | 10 +- .../protocol/http/server/parameters.hpp | 17 +- .../network/protocol/http/server/request.hpp | 11 +- .../protocol/http/server/request_parser.hpp | 17 +- .../network/protocol/http/server/server.ipp | 12 +- .../http/server/socket_options_base.hpp | 16 +- .../protocol/http/server/storage_base.hpp | 16 +- .../protocol/http/server/sync_impl.hpp | 13 +- .../protocol/http/server/sync_impl.ipp | 23 +- .../protocol/http/server/sync_server.hpp | 24 +- .../http/support/client_or_server.hpp | 17 +- .../protocol/http/support/is_client.hpp | 15 +- .../network/protocol/http/support/is_http.hpp | 12 +- .../protocol/http/support/is_keepalive.hpp | 16 +- .../protocol/http/support/is_server.hpp | 16 +- .../protocol/http/support/is_simple.hpp | 16 +- .../protocol/http/support/sync_only.hpp | 22 +- include/network/uri.hpp | 14 +- include/network/uri/accessors.hpp | 24 +- include/network/uri/builder.hpp | 13 +- include/network/uri/config.hpp | 23 +- include/network/uri/decode.hpp | 25 +- include/network/uri/detail/uri_parts.hpp | 14 +- include/network/uri/directives.hpp | 36 +- include/network/uri/directives/authority.hpp | 15 +- include/network/uri/directives/fragment.hpp | 20 +- include/network/uri/directives/host.hpp | 20 +- include/network/uri/directives/path.hpp | 21 +- include/network/uri/directives/port.hpp | 24 +- include/network/uri/directives/query.hpp | 21 +- include/network/uri/directives/scheme.hpp | 23 +- include/network/uri/directives/user_info.hpp | 21 +- include/network/uri/encode.hpp | 27 +- include/network/uri/normalize.hpp | 17 +- include/network/uri/schemes.hpp | 15 +- include/network/uri/uri.hpp | 42 +- include/network/uri/uri.ipp | 4 +- include/network/uri/uri_io.hpp | 19 +- include/network/utils/thread_pool.hpp | 16 +- include/network/utils/thread_pool.ipp | 17 +- include/network/version.hpp | 35 +- 215 files changed, 3875 insertions(+), 4439 deletions(-) diff --git a/include/network/constants.hpp b/include/network/constants.hpp index 2b4e43d2d..8fc82213b 100644 --- a/include/network/constants.hpp +++ b/include/network/constants.hpp @@ -1,5 +1,5 @@ -#ifndef BOOST_NETWORK_CONSTANTS_HPP_20100808 -#define BOOST_NETWORK_CONSTANTS_HPP_20100808 +#ifndef NETWORK_CONSTANTS_HPP_20100808 +#define NETWORK_CONSTANTS_HPP_20100808 // Copyright 2010 (C) Dean Michael Berris // Copyright 2012 Google, Inc. @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -namespace boost { namespace network { +namespace network { struct constants { static char const * crlf(); @@ -37,6 +37,4 @@ struct constants { } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_CONSTANTS_HPP_20100808 +#endif // NETWORK_CONSTANTS_HPP_20100808 diff --git a/include/network/constants.ipp b/include/network/constants.ipp index 43f7013d1..c72068b7e 100644 --- a/include/network/constants.ipp +++ b/include/network/constants.ipp @@ -1,5 +1,5 @@ -#ifndef BOOST_NETWORK_CONSTANTS_HPP_20111008 -#define BOOST_NETWORK_CONSTANTS_HPP_20111008 +#ifndef NETWORK_CONSTANTS_HPP_20111008 +#define NETWORK_CONSTANTS_HPP_20111008 // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. @@ -10,7 +10,7 @@ #include #include -namespace boost { namespace network { +namespace network { char const * constants::crlf() { static char crlf_[] = "\r\n"; @@ -119,12 +119,10 @@ char const * constants::https() { } char const * constants::default_user_agent() { - static char user_agent_[] = "cpp-netlib/" BOOST_NETLIB_VERSION; + static char user_agent_[] = "cpp-netlib/" NETLIB_VERSION; return user_agent_; } -} /* network */ +} // namespace network -} /* boost */ - -#endif /* BOOST_NETWORK_CONSTANTS_HPP_20111008 */ +#endif /* NETWORK_CONSTANTS_HPP_20111008 */ diff --git a/include/network/detail/debug.hpp b/include/network/detail/debug.hpp index 9a5c5329f..dbded5e1c 100644 --- a/include/network/detail/debug.hpp +++ b/include/network/detail/debug.hpp @@ -1,5 +1,5 @@ -#ifndef BOOST_NETWORK_DEBUG_HPP_20110410 -#define BOOST_NETWORK_DEBUG_HPP_20110410 +#ifndef NETWORK_DEBUG_HPP_20110410 +#define NETWORK_DEBUG_HPP_20110410 // (c) Copyright 2011 Dean Michael Berris. // Copyright 2012 Google, Inc. @@ -7,20 +7,20 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -/** BOOST_NETWORK_MESSAGE is a debugging macro used by cpp-netlib to - print out network-related errors through standard error. This is - only useful when BOOST_NETWORK_DEBUG is turned on. Otherwise - the macro amounts to a no-op. +/** NETWORK_MESSAGE is a debugging macro used by cpp-netlib to + print out network-related errors through standard error. This is only + useful when NETWORK_DEBUG is turned on. Otherwise the macro amounts to a + no-op. */ -#ifdef BOOST_NETWORK_DEBUG +#ifdef NETWORK_DEBUG # include -# ifndef BOOST_NETWORK_MESSAGE -# define BOOST_NETWORK_MESSAGE(msg) std::cerr << "[DEBUG " << __FILE__ << ':' << __LINE__ << "]: " << msg << std::endl; +# ifndef NETWORK_MESSAGE +# define NETWORK_MESSAGE(msg) std::cerr << "[DEBUG " << __FILE__ << ':' << __LINE__ << "]: " << msg << std::endl; # endif #else -# ifndef BOOST_NETWORK_MESSAGE -# define BOOST_NETWORK_MESSAGE(msg) +# ifndef NETWORK_MESSAGE +# define NETWORK_MESSAGE(msg) # endif #endif -#endif /* end of include guard: BOOST_NETWORK_DEBUG_HPP_20110410 */ +#endif /* end of include guard: NETWORK_DEBUG_HPP_20110410 */ diff --git a/include/network/detail/directive_base.hpp b/include/network/detail/directive_base.hpp index 104cba6d2..58cd4f319 100644 --- a/include/network/detail/directive_base.hpp +++ b/include/network/detail/directive_base.hpp @@ -5,31 +5,16 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef __NETWORK_DETAIL_DIRECTIVE_BASE_HPP__ -#define __NETWORK_DETAIL_DIRECTIVE_BASE_HPP__ +#ifndef NETWORK_DETAIL_DIRECTIVE_BASE_HPP__ +#define NETWORK_DETAIL_DIRECTIVE_BASE_HPP__ /** Defines the base type from which all directives inherit * to allow friend access to message and other types' internals. */ -namespace boost { namespace network { namespace detail { - - template - struct directive_base { - typedef Tag tag ; - //explicit directive_base(basic_message & message_) - // : _message(message_) - protected: - ~directive_base() - { }; // can only be extended - - // mutable basic_message & _message; - }; +namespace network { namespace detail { } // namespace detail } // namespace network -} // namespace boost - -#endif // __NETWORK_DETAIL_DIRECTIVE_BASE_HPP__ - +#endif // NETWORK_DETAIL_DIRECTIVE_BASE_HPP__ diff --git a/include/network/detail/wrapper_base.hpp b/include/network/detail/wrapper_base.hpp index 56d6f7c69..84b635b60 100644 --- a/include/network/detail/wrapper_base.hpp +++ b/include/network/detail/wrapper_base.hpp @@ -5,42 +5,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef __NETWORK_DETAIL_WRAPPER_BASE_HPP__ -#define __NETWORK_DETAIL_WRAPPER_BASE_HPP__ +#ifndef NETWORK_DETAIL_WRAPPER_BASE_HPP__ +#define NETWORK_DETAIL_WRAPPER_BASE_HPP__ -namespace boost { namespace network { - - namespace detail { - - template - struct wrapper_base { - explicit wrapper_base(Message & message_) - : _message(message_) - {}; - - protected: - ~wrapper_base() {}; // for extending only - - Message & _message; - }; - - template - struct wrapper_base_const { - explicit wrapper_base_const(Message const & message_) - : _message(message_) - {} - - protected: - ~wrapper_base_const() {}; // for extending only - - Message const & _message; - }; - - } // namespace detail - -} // namespace network - -} // namespace boost - -#endif // __NETWORK_DETAIL_WRAPPER_BASE_HPP__ +#endif // NETWORK_DETAIL_WRAPPER_BASE_HPP__ diff --git a/include/network/http/client.hpp b/include/network/http/client.hpp index a044e5902..3a72eaeff 100644 --- a/include/network/http/client.hpp +++ b/include/network/http/client.hpp @@ -1,22 +1,16 @@ -// Copyright (c) Glyn Matthews 2012. +// Copyright (c) Glyn Matthews 2012. +// Copyright 2012 Dean Michael Berris . +// Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) -#ifndef __NETWORK_HTTP_CLIENT_INC__ -# define __NETWORK_HTTP_CLIENT_INC__ +#ifndef NETWORK_HTTP_CLIENT_INC__ +#define NETWORK_HTTP_CLIENT_INC__ -# include -# include -# include -# include +#include +#include +#include +#include -namespace network { -using boost::network::header; - -namespace http { -using boost::network::http::client; -} // namespace http -} // namespace network - -#endif // __NETWORK_HTTP_CLIENT_INC__ +#endif // NETWORK_HTTP_CLIENT_INC__ diff --git a/include/network/http/errors.hpp b/include/network/http/errors.hpp index a694ed8ed..53a75b67d 100644 --- a/include/network/http/errors.hpp +++ b/include/network/http/errors.hpp @@ -1,19 +1,11 @@ -// Copyright (c) Glyn Matthews 2012. +// Copyright (c) Glyn Matthews 2012. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) -#ifndef __NETWORK_HTTP_ERRORS_INC__ -# define __NETWORK_HTTP_ERRORS_INC__ +#ifndef NETWORK_HTTP_ERRORS_INC__ +#define NETWORK_HTTP_ERRORS_INC__ -# include +#include -namespace network { -namespace http { -namespace errors { -using boost::network::http::errors::connection_timeout; -} // namespace errors -} // namespace http -} // namespace network - -#endif // __NETWORK_HTTP_ERRORS_INC__ +#endif // NETWORK_HTTP_ERRORS_INC__ diff --git a/include/network/http/request.hpp b/include/network/http/request.hpp index 74bd07ee5..bdcd47647 100644 --- a/include/network/http/request.hpp +++ b/include/network/http/request.hpp @@ -1,17 +1,11 @@ -// Copyright (c) Glyn Matthews 2012. +// Copyright (c) Glyn Matthews 2012. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) -#ifndef __NETWORK_HTTP_REQUEST_INC__ -# define __NETWORK_HTTP_REQUEST_INC__ +#ifndef NETWORK_HTTP_REQUEST_INC__ +#define NETWORK_HTTP_REQUEST_INC__ -# include +#include -namespace network { -namespace http { -using boost::network::http::request; -} // namespace http -} // namespace network - -#endif // __NETWORK_HTTP_REQUEST_INC__ +#endif // NETWORK_HTTP_REQUEST_INC__ diff --git a/include/network/http/response.hpp b/include/network/http/response.hpp index 13ee8ba30..323495258 100644 --- a/include/network/http/response.hpp +++ b/include/network/http/response.hpp @@ -1,17 +1,11 @@ -// Copyright (c) Glyn Matthews 2012. +// Copyright (c) Glyn Matthews 2012. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) -#ifndef __NETWORK_HTTP_RESPONSE_INC__ -# define __NETWORK_HTTP_RESPONSE_INC__ +#ifndef NETWORK_HTTP_RESPONSE_INC__ +#define NETWORK_HTTP_RESPONSE_INC__ -# include +#include -namespace network { -namespace http { -using boost::network::http::response; -} // namespace http -} // namespace network - -#endif // __NETWORK_HTTP_RESPONSE_INC__ +#endif // NETWORK_HTTP_RESPONSE_INC__ diff --git a/include/network/include/http/client.hpp b/include/network/include/http/client.hpp index e33d240f4..7bdcee434 100644 --- a/include/network/include/http/client.hpp +++ b/include/network/include/http/client.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_INCLUDE_HTTP_CLIENT_HPP_ -#define BOOST_NETWORK_INCLUDE_HTTP_CLIENT_HPP_ - // Copyright 2009 Dean Michael Berris // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. @@ -9,6 +6,9 @@ // // This is the modular include file for using the HTTP Client +#ifndef NETWORK_INCLUDE_HTTP_CLIENT_HPP_ +#define NETWORK_INCLUDE_HTTP_CLIENT_HPP_ + #include #include #include @@ -17,5 +17,5 @@ #include #include -#endif // BOOST_NETWORK_INCLUDE_HTTP_CLIENT_HPP_ +#endif // NETWORK_INCLUDE_HTTP_CLIENT_HPP_ diff --git a/include/network/include/http/server.hpp b/include/network/include/http/server.hpp index e9d4b93d2..8f8a9f9c6 100644 --- a/include/network/include/http/server.hpp +++ b/include/network/include/http/server.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_INCLUDE_HTTP_SERVER_HPP_ -#define BOOST_NETWORK_INCLUDE_HTTP_SERVER_HPP_ - // Copyright 2010-2012 Dean Michael Berris . // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. @@ -9,6 +6,9 @@ // // This is the modular include file for using the HTTP Client +#ifndef NETWORK_INCLUDE_HTTP_SERVER_HPP_ +#define NETWORK_INCLUDE_HTTP_SERVER_HPP_ + #include #include #include diff --git a/include/network/include/message.hpp b/include/network/include/message.hpp index 416a3caa4..9b7669950 100644 --- a/include/network/include/message.hpp +++ b/include/network/include/message.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_INCLUDE_MESSAGE_HPP_ -#define BOOST_NETWORK_INCLUDE_MESSAGE_HPP_ - // Copyright 2009 Dean Michael Berris // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. @@ -9,7 +6,10 @@ // // This is the modular include file for using the basic message type +#ifndef NETWORK_INCLUDE_MESSAGE_HPP_ +#define NETWORK_INCLUDE_MESSAGE_HPP_ + #include -#endif // BOOST_NETWORK_INCLUDE_MESSAGE_HPP_ +#endif // NETWORK_INCLUDE_MESSAGE_HPP_ diff --git a/include/network/message.hpp b/include/network/message.hpp index 27cdde616..072ab1480 100644 --- a/include/network/message.hpp +++ b/include/network/message.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_MESSAGE_HPP_20111021 -#define BOOST_NETWORK_MESSAGE_HPP_20111021 - // Copyright Dean Michael Berris 2007. // Copyright 2011 Dean Michael Berris (dberris@google.com). // Copyright 2011 Google, Inc. @@ -8,6 +5,9 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_MESSAGE_HPP_20111021 +#define NETWORK_MESSAGE_HPP_20111021 + #include #include #include @@ -24,8 +24,8 @@ #include -#ifdef BOOST_NETWORK_DEBUG +#ifdef NETWORK_DEBUG #include #endif -#endif // BOOST_NETWORK_MESSAGE_HPP_20111021 +#endif // NETWORK_MESSAGE_HPP_20111021 diff --git a/include/network/message/basic_message.hpp b/include/network/message/basic_message.hpp index 18c14dee4..1fdc7ac17 100644 --- a/include/network/message/basic_message.hpp +++ b/include/network/message/basic_message.hpp @@ -1,22 +1,23 @@ -#ifndef BOOST_NETWORK_MESSAGE_BASIC_MESSAGE_HPP_20110911 -#define BOOST_NETWORK_MESSAGE_BASIC_MESSAGE_HPP_20110911 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_MESSAGE_BASIC_MESSAGE_HPP_20110911 +#define NETWORK_MESSAGE_BASIC_MESSAGE_HPP_20110911 + #include #include -namespace boost { namespace network { +namespace network { struct basic_storage_pimpl; struct basic_storage_base : message_base { basic_storage_base(); basic_storage_base(basic_storage_base const &); + basic_storage_base(basic_storage_base &&); virtual void set_destination(std::string const & destination); virtual void set_source(std::string const & source); virtual void append_header(std::string const & name, @@ -33,7 +34,7 @@ struct basic_storage_base : message_base { virtual void get_body(std::string & body); virtual void get_body(function)> chunk_reader, size_t size); - void swap(basic_storage_base & other); + virtual void swap(basic_storage_base & other); virtual ~basic_storage_base(); protected: @@ -42,11 +43,6 @@ struct basic_storage_base : message_base { void swap(basic_storage_base & l, basic_storage_base & r); -} /* network */ -} /* boost */ - -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif +} // namespace network -#endif /* BOOST_NETWORK_MESSAGE_BASIC_MESSAGE_HPP_20110911 */ +#endif /* NETWORK_MESSAGE_BASIC_MESSAGE_HPP_20110911 */ diff --git a/include/network/message/basic_message.ipp b/include/network/message/basic_message.ipp index bd9a94d92..6b7b953d1 100644 --- a/include/network/message/basic_message.ipp +++ b/include/network/message/basic_message.ipp @@ -1,13 +1,13 @@ -#ifndef BOOST_NETWORK_MESSAGE_BASIC_MESSAGE_IPP_20110911 -#define BOOST_NETWORK_MESSAGE_BASIC_MESSAGE_IPP_20110911 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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) -namespace boost { namespace network { +#ifndef NETWORK_MESSAGE_BASIC_MESSAGE_IPP_20110911 +#define NETWORK_MESSAGE_BASIC_MESSAGE_IPP_20110911 + +namespace network { struct basic_storage_pimpl { basic_storage_pimpl(); @@ -107,6 +107,4 @@ void swap(basic_storage_base & l, basic_storage_base & r) { } /* network */ -} /* boost */ - -#endif /* BOOST_NETWORK_MESSAGE_BASIC_MESSAGE_IPP_20110911 */ +#endif /* NETWORK_MESSAGE_BASIC_MESSAGE_IPP_20110911 */ diff --git a/include/network/message/directives.hpp b/include/network/message/directives.hpp index d30ee5455..8c6fad509 100644 --- a/include/network/message/directives.hpp +++ b/include/network/message/directives.hpp @@ -1,26 +1,22 @@ - -// Copyright Dean Michael Berris 2007. +// Copyright Dean Michael Berris 2007. // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) -#ifndef __NETWORK_MESSAGE_DIRECTIVES_HPP__ -#define __NETWORK_MESSAGE_DIRECTIVES_HPP__ +#ifndef NETWORK_MESSAGE_DIRECTIVES_HPP__ +#define NETWORK_MESSAGE_DIRECTIVES_HPP__ #include #include #include -namespace boost { namespace network { +namespace network { - BOOST_NETWORK_STRING_DIRECTIVE(source); - BOOST_NETWORK_STRING_DIRECTIVE(destination); - BOOST_NETWORK_STRING_DIRECTIVE(body); +BOOST_NETWORK_STRING_DIRECTIVE(source); +BOOST_NETWORK_STRING_DIRECTIVE(destination); +BOOST_NETWORK_STRING_DIRECTIVE(body); } // namespace network -} // namespace boost - -#endif // __NETWORK_MESSAGE_DIRECTIVES_HPP__ - +#endif // NETWORK_MESSAGE_DIRECTIVES_HPP__ diff --git a/include/network/message/directives/detail/string_directive.hpp b/include/network/message/directives/detail/string_directive.hpp index 731d52b50..503012866 100644 --- a/include/network/message/directives/detail/string_directive.hpp +++ b/include/network/message/directives/detail/string_directive.hpp @@ -1,11 +1,11 @@ -#ifndef BOOST_NETWORK_MESSAGE_DIRECTIVES_DETAIL_STRING_DIRECTIVE_HPP_20100915 -#define BOOST_NETWORK_MESSAGE_DIRECTIVES_DETAIL_STRING_DIRECTIVE_HPP_20100915 - -// Copyright Dean Michael Berris 2010. +// Copyright 2010-2012 Dean Michael Berris // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef NETWORK_MESSAGE_DIRECTIVES_DETAIL_STRING_DIRECTIVE_HPP_20100915 +#define NETWORK_MESSAGE_DIRECTIVES_DETAIL_STRING_DIRECTIVE_HPP_20100915 #include #include @@ -14,23 +14,20 @@ #include #include -/** - * - * To create your own string directive, you can use the preprocessor macro - * BOOST_NETWORK_STRING_DIRECTIVE which takes three parameters: the name of - * the directive, a name for the variable to use in the directive visitor, - * and the body to be implemented in the visitor. An example directive for - * setting the source of a message would look something like this given the - * BOOST_NETWORK_STRING_DIRECTIVE macro: - * - * BOOST_NETWORK_STRING_DIRECTIVE(source, source_, - * message.source(source_) - * , message.source=source_); - * - */ - -#ifndef BOOST_NETWORK_STRING_DIRECTIVE -#define BOOST_NETWORK_STRING_DIRECTIVE(name) \ +// To create your own string directive, you can use the preprocessor macro +// NETWORK_STRING_DIRECTIVE which takes three parameters: the name of +// the directive, a name for the variable to use in the directive visitor, +// and the body to be implemented in the visitor. An example directive for +// setting the source of a message would look something like this given the +// NETWORK_STRING_DIRECTIVE macro: +// +// NETWORK_STRING_DIRECTIVE(source, source_, +// message.source(source_) +// , message.source=source_); +// + +#ifndef NETWORK_STRING_DIRECTIVE +#define NETWORK_STRING_DIRECTIVE(name) \ struct name##_directive { \ std::string const & value; \ explicit name##_directive(std::string const & value_) \ @@ -47,6 +44,6 @@ name (std::string const & input) { \ return name##_directive(input); \ } -#endif /* BOOST_NETWORK_STRING_DIRECTIVE */ +#endif /* NETWORK_STRING_DIRECTIVE */ -#endif /* BOOST_NETWORK_MESSAGE_DIRECTIVES_DETAIL_STRING_DIRECTIVE_HPP_20100915 */ +#endif /* NETWORK_MESSAGE_DIRECTIVES_DETAIL_STRING_DIRECTIVE_HPP_20100915 */ diff --git a/include/network/message/directives/detail/string_value.hpp b/include/network/message/directives/detail/string_value.hpp index f04625acc..b686e6ab6 100644 --- a/include/network/message/directives/detail/string_value.hpp +++ b/include/network/message/directives/detail/string_value.hpp @@ -1,11 +1,11 @@ -#ifndef BOOST_NETWORK_MESSAGE_DIRECTIVES_DETAIL_STRING_VALUE_HPP_20100915 -#define BOOST_NETWORK_MESSAGE_DIRECTIVES_DETAIL_STRING_VALUE_HPP_20100915 - -// Copyright Dean Michael Berris 2010. +// Copyright Dean Michael Berris 2010. // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef NETWORK_MESSAGE_DIRECTIVES_DETAIL_STRING_VALUE_HPP_20100915 +#define NETWORK_MESSAGE_DIRECTIVES_DETAIL_STRING_VALUE_HPP_20100915 #include #include @@ -15,27 +15,26 @@ #include #include -namespace boost { namespace network { namespace detail { - - template - struct string_value : - mpl::if_< - is_async, - boost::shared_future::type>, - typename mpl::if_< - mpl::or_< - is_sync, - is_same, - is_same - >, - typename string::type, - unsupported_tag - >::type - > - {}; +namespace network { namespace detail { + +template +struct string_value : + mpl::if_< + is_async, + boost::shared_future::type>, + typename mpl::if_< + mpl::or_< + is_sync, + is_same, + is_same + >, + typename string::type, + unsupported_tag + >::type + > +{}; -} /* detail */ -} /* network */ -} /* boost */ +} // namespace detail +} // namespace network -#endif /* BOOST_NETWORK_MESSAGE_DIRECTIVES_DETAIL_STRING_VALUE_HPP_20100915 */ +#endif /* NETWORK_MESSAGE_DIRECTIVES_DETAIL_STRING_VALUE_HPP_20100915 */ diff --git a/include/network/message/directives/header.hpp b/include/network/message/directives/header.hpp index 54ab3b22f..d2e7fdeff 100644 --- a/include/network/message/directives/header.hpp +++ b/include/network/message/directives/header.hpp @@ -1,15 +1,15 @@ -#ifndef __NETWORK_MESSAGE_DIRECTIVES_HEADER_HPP__ -#define __NETWORK_MESSAGE_DIRECTIVES_HEADER_HPP__ - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_MESSAGE_DIRECTIVES_HEADER_HPP__ +#define NETWORK_MESSAGE_DIRECTIVES_HEADER_HPP__ + #include -namespace boost { namespace network { +namespace network { namespace impl { @@ -28,11 +28,7 @@ inline impl::header_directive header(std::string const & header_name, std::string const & header_value) { return impl::header_directive(header_name, header_value); } -} // namespace network -} // namespace boost -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif +} // namespace network -#endif // __NETWORK_MESSAGE_DIRECTIVES_HEADER_HPP__ +#endif // NETWORK_MESSAGE_DIRECTIVES_HEADER_HPP__ diff --git a/include/network/message/directives/header.ipp b/include/network/message/directives/header.ipp index 08fa65981..2030f8cc5 100644 --- a/include/network/message/directives/header.ipp +++ b/include/network/message/directives/header.ipp @@ -1,16 +1,16 @@ -#ifndef BOOST_NETWORK_MESSAGE_DIRECTIVES_IPP_20111021 -#define BOOST_NETWORK_MESSAGE_DIRECTIVES_IPP_20111021 - // Copyright 2011 Dean Michael Berris (dberris@google.com). // Copyright 2011 Google, Inc. // 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 NETWORK_MESSAGE_DIRECTIVES_IPP_20111021 +#define NETWORK_MESSAGE_DIRECTIVES_IPP_20111021 + #include #include -namespace boost { namespace network { namespace impl { +namespace network { namespace impl { header_directive::header_directive(std::string const & name, std::string const & value): @@ -21,8 +21,7 @@ void header_directive::operator() (message_base & msg) const { msg.append_header(name_, value_); } -} /* impl */ -} /* network */ -} /* boost */ +} // namespace impl +} // namespace network -#endif /* BOOST_NETWORK_MESSAGE_DIRECTIVES_IPP_20111021 */ +#endif /* NETWORK_MESSAGE_DIRECTIVES_IPP_20111021 */ diff --git a/include/network/message/directives/remove_header.hpp b/include/network/message/directives/remove_header.hpp index 958434b46..4e7d8c06a 100644 --- a/include/network/message/directives/remove_header.hpp +++ b/include/network/message/directives/remove_header.hpp @@ -1,14 +1,13 @@ -#ifndef BOOST_NETWORK_MESSAGE_DIRECTIVES_REMOVE_HEADER_HPP_20111021 -#define BOOST_NETWORK_MESSAGE_DIRECTIVES_REMOVE_HEADER_HPP_20111021 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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) -namespace boost { namespace network { +#ifndef NETWORK_MESSAGE_DIRECTIVES_REMOVE_HEADER_HPP_20111021 +#define NETWORK_MESSAGE_DIRECTIVES_REMOVE_HEADER_HPP_20111021 +namespace network { namespace impl { struct remove_header_directive { @@ -24,11 +23,7 @@ inline impl::remove_header_directive const remove_header(std::string const & header_name) { return impl::remove_header_directive(header_name); } -} // namespace network -} // namespace boost -#ifdef BOOST_NETWORK_NO_LIB -#undef BOOST_NETWORK_NO_LIB -#endif +} // namespace network -#endif // BOOST_NETWORK_MESSAGE_DIRECTIVES_REMOVE_HEADER_HPP_20111021 +#endif // NETWORK_MESSAGE_DIRECTIVES_REMOVE_HEADER_HPP_20111021 diff --git a/include/network/message/directives/remove_header.ipp b/include/network/message/directives/remove_header.ipp index 3c1ae1586..0c4d9a8af 100644 --- a/include/network/message/directives/remove_header.ipp +++ b/include/network/message/directives/remove_header.ipp @@ -1,15 +1,16 @@ -#ifndef BOOST_NETWORK_MESSAGE_DIRECTIVES_REMOVE_HEADER_IPP_20111021 -#define BOOST_NETWORK_MESSAGE_DIRECTIVES_REMOVE_HEADER_IPP_20111021 - // Copyright 2011 Dean Michael Berris (dberris@google.com). // Copyright 2011 Google, Inc. // 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 NETWORK_MESSAGE_DIRECTIVES_REMOVE_HEADER_IPP_20111021 +#define NETWORK_MESSAGE_DIRECTIVES_REMOVE_HEADER_IPP_20111021 + #include -namespace boost { namespace network { namespace impl { +namespace network { +namespace impl { remove_header_directive::remove_header_directive(std::string const & header_name): header_name_(header_name) {} @@ -18,10 +19,7 @@ void remove_header_directive::operator() (message_base & msg) const { msg.remove_headers(header_name_); } -} /* impl */ - -} /* network */ - -} /* boost */ +} // namespace impl +} // namespace network -#endif /* BOOST_NETWORK_MESSAGE_DIRECTIVES_REMOVE_HEADER_IPP_20111021 */ +#endif /* NETWORK_MESSAGE_DIRECTIVES_REMOVE_HEADER_IPP_20111021 */ diff --git a/include/network/message/message.hpp b/include/network/message/message.hpp index 821271d58..e691059cd 100644 --- a/include/network/message/message.hpp +++ b/include/network/message/message.hpp @@ -1,24 +1,23 @@ -#ifndef BOOST_NETWORK_MESSAGE_MESSAGE_HPP_20111021 -#define BOOST_NETWORK_MESSAGE_MESSAGE_HPP_20111021 - // Copyright 2011 Dean Michael Berris (dberris@google.com). // Copyright 2011 Google, Inc. // 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 NETWORK_MESSAGE_MESSAGE_HPP_20111021 +#define NETWORK_MESSAGE_MESSAGE_HPP_20111021 + #include #include #include #include #include -namespace boost { namespace network { +namespace network { struct message_pimpl; -/** The common message type. - */ +// The common message type. struct message : message_base { // Nested types typedef iterator_range< @@ -76,12 +75,6 @@ message_base & operator<< (message_base & msg, Directive directive) { return msg; } -} /* network */ - -} /* boost */ - -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif +} // namespace network -#endif /* BOOST_NETWORK_MESSAGE_MESSAGE_HPP_20111021 */ +#endif /* NETWORK_MESSAGE_MESSAGE_HPP_20111021 */ diff --git a/include/network/message/message.ipp b/include/network/message/message.ipp index 12b1a41fd..f7b2c905b 100644 --- a/include/network/message/message.ipp +++ b/include/network/message/message.ipp @@ -1,18 +1,18 @@ -#ifndef BOOST_NETWORK_MESSAGE_IPP_20111020 -#define BOOST_NETWORK_MESSAGE_IPP_20111020 - // Copyright 2011 Dean Michael Berris (dberris@google.com). // Copyright 2011 Google, Inc. // 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 NETWORK_MESSAGE_IPP_20111020 +#define NETWORK_MESSAGE_IPP_20111020 + #include #include #include #include -namespace boost { namespace network { +namespace network { struct message_pimpl { message_pimpl() : @@ -207,6 +207,4 @@ void message::swap(message & other) { } /* network */ -} /* boost */ - -#endif /* BOOST_NETWORK_MESSAGE_IPP_20111020 */ +#endif /* NETWORK_MESSAGE_IPP_20111020 */ diff --git a/include/network/message/message_base.hpp b/include/network/message/message_base.hpp index b19a5a74b..a2b14bfed 100644 --- a/include/network/message/message_base.hpp +++ b/include/network/message/message_base.hpp @@ -1,16 +1,16 @@ -#ifndef BOOST_NETWORK_MESSAGE_BASE_HPP_20110910 -#define BOOST_NETWORK_MESSAGE_BASE_HPP_20110910 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_MESSAGE_BASE_HPP_20110910 +#define NETWORK_MESSAGE_BASE_HPP_20110910 + #include #include -namespace boost { namespace network { +namespace network { struct message_base { // Mutators @@ -36,8 +36,6 @@ struct message_base { virtual ~message_base() = 0; // pure virtual }; -} /* network */ - -} /* boost */ +} // namespace network -#endif /* BOOST_NETWORK_MESSAGE_BASE_HPP_20110910 */ +#endif /* NETWORK_MESSAGE_BASE_HPP_20110910 */ diff --git a/include/network/message/message_base.ipp b/include/network/message/message_base.ipp index cb38c52ae..ee7380a12 100644 --- a/include/network/message/message_base.ipp +++ b/include/network/message/message_base.ipp @@ -1,23 +1,21 @@ -#ifndef BOOST_NETWORK_MESSAGE_BASE_IPP_20111020 -#define BOOST_NETWORK_MESSAGE_BASE_IPP_20111020 - // Copyright 2011 Dean Michael Berris (dberris@google.com). // Copyright 2011 Google, Inc. // 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 NETWORK_MESSAGE_BASE_IPP_20111020 +#define NETWORK_MESSAGE_BASE_IPP_20111020 + #include -namespace boost { namespace network { +namespace network { message_base::~message_base() { // This is never used, but is required even though message_base's destructor // is a pure virtual one. } -} /* network */ - -} /* boost */ +} // namespace network -#endif /* BOOST_NETWORK_MESSAGE_BASE_IPP_20111020 */ +#endif /* NETWORK_MESSAGE_BASE_IPP_20111020 */ diff --git a/include/network/message/message_concept.hpp b/include/network/message/message_concept.hpp index dfa877a6e..28c2cdbad 100644 --- a/include/network/message/message_concept.hpp +++ b/include/network/message/message_concept.hpp @@ -1,7 +1,3 @@ - -#ifndef BOOST_NETWORK_MESSAGE_MESSAGE_CONCEPT_HPP_20100903 -#define BOOST_NETWORK_MESSAGE_MESSAGE_CONCEPT_HPP_20100903 - // Copyright (c) Glyn Matthews 2010. // Copyright 2010 (c) Dean Michael Berris. // Copyright 2010 (c) Sinefunc, Inc. @@ -10,19 +6,22 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_MESSAGE_MESSAGE_CONCEPT_HPP_20100903 +#define NETWORK_MESSAGE_MESSAGE_CONCEPT_HPP_20100903 + #include #include #include #include #include -namespace boost { namespace network { +namespace network { template struct Message : DefaultConstructible, CopyConstructible, Assignable { - BOOST_CONCEPT_USAGE(Message) { + CONCEPT_USAGE(Message) { M message_; swap(message, message_); typedef std::string source_type; @@ -61,7 +60,4 @@ namespace boost { namespace network { } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_MESSAGE_MESSAGE_CONCEPT_HPP_20100903 - +#endif // NETWORK_MESSAGE_MESSAGE_CONCEPT_HPP_20100903 diff --git a/include/network/message/modifiers.hpp b/include/network/message/modifiers.hpp index de3dfeec0..89eef3572 100644 --- a/include/network/message/modifiers.hpp +++ b/include/network/message/modifiers.hpp @@ -1,12 +1,12 @@ -#ifndef BOOST_NETWORK_MESSAGE_MODIFIERS_HPP_20111201 -#define BOOST_NETWORK_MESSAGE_MODIFIERS_HPP_20111201 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_MESSAGE_MODIFIERS_HPP_20111201 +#define NETWORK_MESSAGE_MODIFIERS_HPP_20111201 + #include #include #include @@ -14,4 +14,4 @@ #include #include -#endif // BOOST_NETWORK_MESSAGE_MODIFIERS_HPP_20111201 +#endif // NETWORK_MESSAGE_MODIFIERS_HPP_20111201 diff --git a/include/network/message/modifiers/add_header.hpp b/include/network/message/modifiers/add_header.hpp index baeddb6d9..5493f9752 100644 --- a/include/network/message/modifiers/add_header.hpp +++ b/include/network/message/modifiers/add_header.hpp @@ -1,5 +1,5 @@ -#ifndef BOOST_NETWORK_MESSAGE_MODIFIER_ADD_HEADER_HPP_20100824 -#define BOOST_NETWORK_MESSAGE_MODIFIER_ADD_HEADER_HPP_20100824 +#ifndef NETWORK_MESSAGE_MODIFIER_ADD_HEADER_HPP_20100824 +#define NETWORK_MESSAGE_MODIFIER_ADD_HEADER_HPP_20100824 // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. @@ -11,15 +11,14 @@ #include #include -namespace boost { namespace network { +namespace network { -inline -void add_header(message_base & message, std::string const & key, std::string const & value) { +inline void add_header(message_base & message, + std::string const & key, + std::string const & value) { message.append_header(key, value); } } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_MESSAGE_MODIFIER_ADD_HEADER_HPP_20100824 +#endif // NETWORK_MESSAGE_MODIFIER_ADD_HEADER_HPP_20100824 diff --git a/include/network/message/modifiers/body.hpp b/include/network/message/modifiers/body.hpp index c22679a15..f1db40a2a 100644 --- a/include/network/message/modifiers/body.hpp +++ b/include/network/message/modifiers/body.hpp @@ -1,5 +1,5 @@ -#ifndef BOOST_NETWORK_MODIFIERS_BODY_HPP_20100824 -#define BOOST_NETWORK_MODIFIERS_BODY_HPP_20100824 +#ifndef NETWORK_MODIFIERS_BODY_HPP_20100824 +#define NETWORK_MODIFIERS_BODY_HPP_20100824 // Copyright 2010 (c) Dean Michael Berris // Copyright 2012 Google, Inc. @@ -7,7 +7,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -namespace boost { namespace network { +namespace network { inline void body(message_base & message, std::string const & body_) { message.set_body(body_); @@ -19,6 +19,4 @@ inline void append_body(message_base & message, std::string const & data) { } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_MODIFIERS_BODY_HPP_20100824 +#endif // NETWORK_MODIFIERS_BODY_HPP_20100824 diff --git a/include/network/message/modifiers/clear_headers.hpp b/include/network/message/modifiers/clear_headers.hpp index 8595c8273..1d9692404 100644 --- a/include/network/message/modifiers/clear_headers.hpp +++ b/include/network/message/modifiers/clear_headers.hpp @@ -1,5 +1,5 @@ -#ifndef BOOST_NETWORK_MESSAGE_MODIFIER_CLEAR_HEADERS_HPP_20100824 -#define BOOST_NETWORK_MESSAGE_MODIFIER_CLEAR_HEADERS_HPP_20100824 +#ifndef NETWORK_MESSAGE_MODIFIER_CLEAR_HEADERS_HPP_20100824 +#define NETWORK_MESSAGE_MODIFIER_CLEAR_HEADERS_HPP_20100824 // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. @@ -9,7 +9,7 @@ #include -namespace boost { namespace network { +namespace network { inline void clear_headers(message_base & message) { message.remove_headers(); @@ -17,6 +17,4 @@ inline void clear_headers(message_base & message) { } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_MESSAGE_MODIFIER_CLEAR_HEADERS_HPP_20100824 +#endif // NETWORK_MESSAGE_MODIFIER_CLEAR_HEADERS_HPP_20100824 diff --git a/include/network/message/modifiers/destination.hpp b/include/network/message/modifiers/destination.hpp index 5704bd008..a048466e0 100644 --- a/include/network/message/modifiers/destination.hpp +++ b/include/network/message/modifiers/destination.hpp @@ -1,14 +1,13 @@ - -#ifndef BOOST_NETWORK_MESSAGE_MODIFIER_DESTINATION_HPP_20100824 -#define BOOST_NETWORK_MESSAGE_MODIFIER_DESTINATION_HPP_20100824 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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) -namespace boost { namespace network { +#ifndef NETWORK_MESSAGE_MODIFIER_DESTINATION_HPP_20100824 +#define NETWORK_MESSAGE_MODIFIER_DESTINATION_HPP_20100824 + +namespace network { inline void destination(message_base & message, std::string const & destination_) { message.set_destination(destination_); @@ -16,6 +15,4 @@ inline void destination(message_base & message, std::string const & destination_ } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_MESSAGE_MODIFIER_DESTINATION_HPP_20100824 +#endif // NETWORK_MESSAGE_MODIFIER_DESTINATION_HPP_20100824 diff --git a/include/network/message/modifiers/remove_header.hpp b/include/network/message/modifiers/remove_header.hpp index 8d943614a..8902ef5bf 100644 --- a/include/network/message/modifiers/remove_header.hpp +++ b/include/network/message/modifiers/remove_header.hpp @@ -1,17 +1,16 @@ - -#ifndef BOOST_NETWORK_MESSAGE_MODIFIER_REMOVE_HEADER_HPP_20100824 -#define BOOST_NETWORK_MESSAGE_MODIFIER_REMOVE_HEADER_HPP_20100824 - // Copyright 2010 (c) Dean Michael Berris // Copyright 2012 Google, Inc. // 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 NETWORK_MESSAGE_MODIFIER_REMOVE_HEADER_HPP_20100824 +#define NETWORK_MESSAGE_MODIFIER_REMOVE_HEADER_HPP_20100824 + #include #include -namespace boost { namespace network { +namespace network { inline void remove_header(message_base & message, std::string const & key) { @@ -20,6 +19,4 @@ void remove_header(message_base & message, std::string const & key) { } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_MESSAGE_MODIFIER_REMOVE_HEADER_HPP_20100824 +#endif // NETWORK_MESSAGE_MODIFIER_REMOVE_HEADER_HPP_20100824 diff --git a/include/network/message/modifiers/source.hpp b/include/network/message/modifiers/source.hpp index 835834d15..3ddedb1c0 100644 --- a/include/network/message/modifiers/source.hpp +++ b/include/network/message/modifiers/source.hpp @@ -1,14 +1,13 @@ - -#ifndef BOOST_NETWORK_MESSAGE_MODIFIER_SOURCE_HPP_20100824 -#define BOOST_NETWORK_MESSAGE_MODIFIER_SOURCE_HPP_20100824 - // Copyright 2010 (c) Dean Michael Berris // Copyright 2012 Google, Inc. // 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) -namespace boost { namespace network { +#ifndef NETWORK_MESSAGE_MODIFIER_SOURCE_HPP_20100824 +#define NETWORK_MESSAGE_MODIFIER_SOURCE_HPP_20100824 + +namespace network { inline void source(message_base & message, std::string const & source_) { message.set_source(source_); @@ -16,6 +15,4 @@ inline void source(message_base & message, std::string const & source_) { } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_MESSAGE_MODIFIER_SOURCE_HPP_20100824 +#endif // NETWORK_MESSAGE_MODIFIER_SOURCE_HPP_20100824 diff --git a/include/network/message/transformers.hpp b/include/network/message/transformers.hpp index 324cc4390..fdfda264c 100644 --- a/include/network/message/transformers.hpp +++ b/include/network/message/transformers.hpp @@ -1,12 +1,11 @@ - -// Copyright Dean Michael Berris 2007. +// Copyright Dean Michael Berris 2007. // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) -#ifndef __NETWORK_MESSAGE_TRANSFORMERS_HPP__ -#define __NETWORK_MESSAGE_TRANSFORMERS_HPP__ +#ifndef NETWORK_MESSAGE_TRANSFORMERS_HPP +#define NETWORK_MESSAGE_TRANSFORMERS_HPP /** transformers.hpp * @@ -18,45 +17,45 @@ #include #include -namespace boost { namespace network { - namespace impl { - template - struct get_real_algorithm { - typedef typename boost::function_traits< - typename boost::remove_pointer< - Algorithm - >::type - > - ::result_type:: - template type< - typename boost::function_traits< - typename boost::remove_pointer< - Selector - >::type - >::result_type - > type; - }; - - template - struct transform_impl : public get_real_algorithm::type { }; - } // namspace impl - - template - inline impl::transform_impl - transform(Algorithm, Selector) { - return impl::transform_impl(); - } - - template - message_base & operator<< ( - message_base & msg_, - impl::transform_impl const & transformer) { - transformer(msg_); - return msg_; - } +namespace network { +namespace impl { + +template +struct get_real_algorithm { + typedef typename boost::function_traits< + typename boost::remove_pointer< + Algorithm + >::type + > + ::result_type:: + template type< + typename boost::function_traits< + typename boost::remove_pointer< + Selector + >::type + >::result_type + > type; +}; + +template +struct transform_impl : public get_real_algorithm::type {}; + +} // namspace impl + +template +inline impl::transform_impl +transform(Algorithm, Selector) { + return impl::transform_impl(); +} + +template +message_base & operator<< ( + message_base & msg_, + impl::transform_impl const & transformer) { + transformer(msg_); + return msg_; +} } // namespace network -} // namespace boost - -#endif // __NETWORK_MESSAGE_TRANSFORMERS_HPP__ +#endif // NETWORK_MESSAGE_TRANSFORMERS_HPP diff --git a/include/network/message/transformers/selectors.hpp b/include/network/message/transformers/selectors.hpp index 07f52328d..092f6e82b 100644 --- a/include/network/message/transformers/selectors.hpp +++ b/include/network/message/transformers/selectors.hpp @@ -1,52 +1,50 @@ - -// Copyright Dean Michael Berris 2007. +// Copyright Dean Michael Berris 2007. // Copyright 2012 Google, Inc. // 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 __NETWORK_MESSAGE_TRANSFORMERS_SELECTORS_HPP__ -#define __NETWORK_MESSAGE_TRANSFORMERS_SELECTORS_HPP__ - -namespace boost { namespace network { - namespace selectors { - struct source_selector; - struct destination_selector; - } // namespace selectors - - selectors::source_selector source_(selectors::source_selector); - selectors::destination_selector destination_(selectors::destination_selector); - - namespace selectors { - struct source_selector { - private: - source_selector() {}; - source_selector(source_selector const &) {}; - friend source_selector boost::network::source_(source_selector); - }; - - struct destination_selector { - private: - destination_selector() {}; - destination_selector(destination_selector const &) {}; - friend destination_selector boost::network::destination_(destination_selector); - }; - } // namespace selectors - - typedef selectors::source_selector (*source_selector_t)(selectors::source_selector); - typedef selectors::destination_selector (*destination_selector_t)(selectors::destination_selector); - - inline selectors::source_selector source_(selectors::source_selector) { - return selectors::source_selector(); - } - - inline selectors::destination_selector destination_(selectors::destination_selector) { - return selectors::destination_selector(); - } +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) -} // namespace network +#ifndef NETWORK_MESSAGE_TRANSFORMERS_SELECTORS_HPP +#define NETWORK_MESSAGE_TRANSFORMERS_SELECTORS_HPP + +namespace network { +namespace selectors { +struct source_selector; +struct destination_selector; +} // namespace selectors + +selectors::source_selector source_(selectors::source_selector); +selectors::destination_selector destination_(selectors::destination_selector); + +namespace selectors { + +struct source_selector { + private: + source_selector() {}; + source_selector(source_selector const &) {}; + friend source_selector boost::network::source_(source_selector); +}; -} // namespace boost +struct destination_selector { + private: + destination_selector() {}; + destination_selector(destination_selector const &) {}; + friend destination_selector boost::network::destination_(destination_selector); +}; -#endif // __NETWORK_MESSAGE_TRANSFORMERS_SELECTORS_HPP__ +} // namespace selectors + +typedef selectors::source_selector (*source_selector_t)(selectors::source_selector); +typedef selectors::destination_selector (*destination_selector_t)(selectors::destination_selector); + +inline selectors::source_selector source_(selectors::source_selector) { + return selectors::source_selector(); +} + +inline selectors::destination_selector destination_(selectors::destination_selector) { + return selectors::destination_selector(); +} + +} // namespace network +#endif // NETWORK_MESSAGE_TRANSFORMERS_SELECTORS_HPP diff --git a/include/network/message/transformers/to_lower.hpp b/include/network/message/transformers/to_lower.hpp index b181737ab..f2e075d17 100644 --- a/include/network/message/transformers/to_lower.hpp +++ b/include/network/message/transformers/to_lower.hpp @@ -1,12 +1,12 @@ -// Copyright Dean Michael Berris 2007. +// Copyright Dean Michael Berris 2007. // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) -#ifndef __NETWORK_MESSAGE_TRANSFORMERS_TO_LOWER_HPP__ -#define __NETWORK_MESSAGE_TRANSFORMERS_TO_LOWER_HPP__ +#ifndef NETWORK_MESSAGE_TRANSFORMERS_TO_LOWER_HPP +#define NETWORK_MESSAGE_TRANSFORMERS_TO_LOWER_HPP #include #include @@ -20,10 +20,11 @@ * This defines a type, to be applied using template * metaprogramming on the selected string target. */ -namespace boost { namespace network { namespace impl { +namespace network { +namespace impl { template -struct to_lower_transformer { }; +struct to_lower_transformer {}; template <> struct to_lower_transformer { @@ -54,8 +55,8 @@ struct to_lower_transformer { } // namespace impl namespace detail { - struct to_lower_placeholder_helper; -} +struct to_lower_placeholder_helper; +} // namespace detail detail::to_lower_placeholder_helper to_lower_(detail::to_lower_placeholder_helper); @@ -70,7 +71,7 @@ struct to_lower_placeholder_helper { friend to_lower_placeholder_helper boost::network::to_lower_(to_lower_placeholder_helper); }; -} +} // namespace detail typedef detail::to_lower_placeholder_helper (*to_lower_placeholder)(detail::to_lower_placeholder_helper); @@ -80,7 +81,4 @@ inline detail::to_lower_placeholder_helper to_lower_(detail::to_lower_placeholde } // namespace network -} // namespace boost - -#endif // __NETWORK_MESSAGE_TRANSFORMERS_TO_LOWER_HPP__ - +#endif // NETWORK_MESSAGE_TRANSFORMERS_TO_LOWER_HPP diff --git a/include/network/message/transformers/to_upper.hpp b/include/network/message/transformers/to_upper.hpp index 0400113cf..b322652d7 100644 --- a/include/network/message/transformers/to_upper.hpp +++ b/include/network/message/transformers/to_upper.hpp @@ -1,12 +1,12 @@ -// Copyright Dean Michael Berris 2007. +// Copyright Dean Michael Berris 2007. // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) -#ifndef __NETWORK_MESSAGE_TRANSFORMERS_TO_UPPER_HPP__ -#define __NETWORK_MESSAGE_TRANSFORMERS_TO_UPPER_HPP__ +#ifndef NETWORK_MESSAGE_TRANSFORMERS_TO_UPPER_HPP +#define NETWORK_MESSAGE_TRANSFORMERS_TO_UPPER_HPP #include #include @@ -20,10 +20,11 @@ * This defines a type, to be applied using template * metaprogramming on the selected string target. */ -namespace boost { namespace network { namespace impl { +namespace network { +namespace impl { template -struct to_upper_transformer { }; +struct to_upper_transformer {}; template <> struct to_upper_transformer { @@ -35,7 +36,7 @@ struct to_upper_transformer { } protected: - ~to_upper_transformer() { }; + ~to_upper_transformer() {}; }; template <> @@ -48,14 +49,14 @@ struct to_upper_transformer { } protected: - ~to_upper_transformer() { }; + ~to_upper_transformer() {}; }; } // namespace impl namespace detail { struct to_upper_placeholder_helper; -} +} // namespace detail detail::to_upper_placeholder_helper to_upper_(detail::to_upper_placeholder_helper); @@ -71,7 +72,7 @@ struct to_upper_placeholder_helper { friend to_upper_placeholder_helper boost::network::to_upper_(to_upper_placeholder_helper); }; -} +} // namespace detail typedef detail::to_upper_placeholder_helper (*to_upper_placeholder)(detail::to_upper_placeholder_helper); @@ -81,7 +82,4 @@ inline detail::to_upper_placeholder_helper to_upper_(detail::to_upper_placeholde } // namespace network -} // namespace boost - -#endif // __NETWORK_MESSAGE_TRANSFORMERS_TO_UPPER_HPP__ - +#endif // NETWORK_MESSAGE_TRANSFORMERS_TO_UPPER_HPP diff --git a/include/network/message/wrappers.hpp b/include/network/message/wrappers.hpp index af601e5a8..dd943448c 100644 --- a/include/network/message/wrappers.hpp +++ b/include/network/message/wrappers.hpp @@ -1,12 +1,11 @@ - -// Copyright Dean Michael Berris 2007. +// Copyright Dean Michael Berris 2007. // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) -#ifndef __NETWORK_MESSAGE_WRAPPERS_HPP__ -#define __NETWORK_MESSAGE_WRAPPERS_HPP__ +#ifndef NETWORK_MESSAGE_WRAPPERS_HPP +#define NETWORK_MESSAGE_WRAPPERS_HPP /** wrappers.hpp * diff --git a/include/network/message/wrappers/body.hpp b/include/network/message/wrappers/body.hpp index 0e3e19d82..af9223013 100644 --- a/include/network/message/wrappers/body.hpp +++ b/include/network/message/wrappers/body.hpp @@ -1,17 +1,17 @@ -#ifndef BOOST_NETWORK_MESSAGE_WRAPPERS_BODY_HPP_20110930 -#define BOOST_NETWORK_MESSAGE_WRAPPERS_BODY_HPP_20110930 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_MESSAGE_WRAPPERS_BODY_HPP_20110930 +#define NETWORK_MESSAGE_WRAPPERS_BODY_HPP_20110930 + #include #include #include -namespace boost { namespace network { +namespace network { struct body_wrapper { explicit body_wrapper(message_base const & message); @@ -37,10 +37,4 @@ body(message_base const & message_) { } // namespace network -} // namespace boost - -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif - -#endif // __NETWORK_MESSAGE_WRAPPERS_BODY_HPP__ +#endif // NETWORK_MESSAGE_WRAPPERS_BODY_HPP diff --git a/include/network/message/wrappers/body.ipp b/include/network/message/wrappers/body.ipp index 4503007d8..e6ccd6caf 100644 --- a/include/network/message/wrappers/body.ipp +++ b/include/network/message/wrappers/body.ipp @@ -1,15 +1,15 @@ -#ifndef BOOST_NETWORK_MESSAGE_WRAPPERS_BODY_IPP_20111021 -#define BOOST_NETWORK_MESSAGE_WRAPPERS_BODY_IPP_20111021 - // Copyright 2011 Dean Michael Berris (dberris@google.com). // Copyright 2011 Google, Inc. // 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 NETWORK_MESSAGE_WRAPPERS_BODY_IPP_20111021 +#define NETWORK_MESSAGE_WRAPPERS_BODY_IPP_20111021 + #include -namespace boost { namespace network { +namespace network { body_wrapper::body_wrapper(message_base const & message): message_(message) {} @@ -65,6 +65,5 @@ std::string::const_iterator body_wrapper::end() const { } } /* network */ -} /* boost */ -#endif /* BOOST_NETWORK_MESSAGE_WRAPPERS_BODY_IPP_20111021 */ +#endif /* NETWORK_MESSAGE_WRAPPERS_BODY_IPP_20111021 */ diff --git a/include/network/message/wrappers/destination.hpp b/include/network/message/wrappers/destination.hpp index 346718719..c4dcb6862 100644 --- a/include/network/message/wrappers/destination.hpp +++ b/include/network/message/wrappers/destination.hpp @@ -1,15 +1,15 @@ -#ifndef __NETWORK_MESSAGE_WRAPPERS_DESTINATION_HPP__ -#define __NETWORK_MESSAGE_WRAPPERS_DESTINATION_HPP__ - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_MESSAGE_WRAPPERS_DESTINATION_HPP +#define NETWORK_MESSAGE_WRAPPERS_DESTINATION_HPP + #include -namespace boost { namespace network { +namespace network { struct destination_wrapper { explicit destination_wrapper(message_base const & message); @@ -30,10 +30,4 @@ inline std::ostream & operator<< (std::ostream &os, destination_wrapper const &d } // namespace network -} // namespace boost - -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif - -#endif // __NETWORK_MESSAGE_WRAPPERS_DESTINATION_HPP__ +#endif // NETWORK_MESSAGE_WRAPPERS_DESTINATION_HPP diff --git a/include/network/message/wrappers/destination.ipp b/include/network/message/wrappers/destination.ipp index 8ebd86880..3a7b7dfb6 100644 --- a/include/network/message/wrappers/destination.ipp +++ b/include/network/message/wrappers/destination.ipp @@ -1,15 +1,15 @@ -#ifndef BOOST_NETWORK_MESSAGE_WRAPPERS_DESTINATION_IPP_20111021 -#define BOOST_NETWORK_MESSAGE_WRAPPERS_DESTINATION_IPP_20111021 - // Copyright 2011 Dean Michael Berris (dberris@google.com). // Copyright 2011 Google, Inc. // 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 NETWORK_MESSAGE_WRAPPERS_DESTINATION_IPP_20111021 +#define NETWORK_MESSAGE_WRAPPERS_DESTINATION_IPP_20111021 + #include -namespace boost { namespace network { +namespace network { destination_wrapper::destination_wrapper(message_base const & message): message_(message) {} @@ -24,8 +24,6 @@ destination_wrapper::operator std::string () const { return *cache_; } -} /* network */ - -} /* boost */ +} // namespace network -#endif /* BOOST_NETWORK_MESSAGE_WRAPPERS_DESTINATION_IPP_20111021 */ +#endif /* NETWORK_MESSAGE_WRAPPERS_DESTINATION_IPP_20111021 */ diff --git a/include/network/message/wrappers/headers.hpp b/include/network/message/wrappers/headers.hpp index 5b0befa43..18355e5d0 100644 --- a/include/network/message/wrappers/headers.hpp +++ b/include/network/message/wrappers/headers.hpp @@ -1,16 +1,15 @@ - -// Copyright Dean Michael Berris 2007. +// Copyright Dean Michael Berris 2007. // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) #ifndef NETWORK_MESSAGE_WRAPPERS_HEADERS_HPP__ #define NETWORK_MESSAGE_WRAPPERS_HEADERS_HPP__ #include -namespace boost { namespace network { +namespace network { struct message_base; @@ -30,6 +29,4 @@ headers(message_base const & message_) { } // namespace network -} // namespace boost - #endif // __NETWORK_MESSAGE_WRAPPERS_HEADERS_HPP__ diff --git a/include/network/message/wrappers/headers.ipp b/include/network/message/wrappers/headers.ipp index ed8f03e11..f172e5fe2 100644 --- a/include/network/message/wrappers/headers.ipp +++ b/include/network/message/wrappers/headers.ipp @@ -1,17 +1,17 @@ -#ifndef BOOST_NETWORK_MESSAGE_WRAPPERS_HEADERS_IPP_20110911 -#define BOOST_NETWORK_MESSAGE_WRAPPERS_HEADERS_IPP_20110911 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_MESSAGE_WRAPPERS_HEADERS_IPP_20110911 +#define NETWORK_MESSAGE_WRAPPERS_HEADERS_IPP_20110911 + #include #include #include -namespace boost { namespace network { +namespace network { headers_wrapper::headers_wrapper(message_base const & message) : message_(message) @@ -37,6 +37,4 @@ headers_wrapper::operator headers_wrapper::container_type () const { } /* network */ -} /* boost */ - -#endif /* BOOST_NETWORK_MESSAGE_WRAPPERS_HEADERS_IPP_20110911 */ +#endif /* NETWORK_MESSAGE_WRAPPERS_HEADERS_IPP_20110911 */ diff --git a/include/network/message/wrappers/source.hpp b/include/network/message/wrappers/source.hpp index 4dc537012..4a3feb698 100644 --- a/include/network/message/wrappers/source.hpp +++ b/include/network/message/wrappers/source.hpp @@ -1,15 +1,15 @@ -#ifndef BOOST_NETWORK_MESSAGE_WRAPPERS_SOURCE_HPP_20111021 -#define BOOST_NETWORK_MESSAGE_WRAPPERS_SOURCE_HPP_20111021 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_MESSAGE_WRAPPERS_SOURCE_HPP_20111021 +#define NETWORK_MESSAGE_WRAPPERS_SOURCE_HPP_20111021 + #include -namespace boost { namespace network { +namespace network { struct source_wrapper { explicit source_wrapper(message_base & message); @@ -30,10 +30,4 @@ inline std::ostream & operator<<(std::ostream &os, source_wrapper const &s) { } // namespace network -} // namespace boost - -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif - -#endif // BOOST_NETWORK_MESSAGE_WRAPPERS_SOURCE_HPP_20111021 +#endif // NETWORK_MESSAGE_WRAPPERS_SOURCE_HPP_20111021 diff --git a/include/network/message/wrappers/source.ipp b/include/network/message/wrappers/source.ipp index 24c225a32..1e85695b7 100644 --- a/include/network/message/wrappers/source.ipp +++ b/include/network/message/wrappers/source.ipp @@ -1,15 +1,15 @@ -#ifndef BOOST_NETWORK_MESSAGE_WRAPPERS_SOURCE_IPP_20111021 -#define BOOST_NETWORK_MESSAGE_WRAPPERS_SOURCE_IPP_20111021 - // Copyright 2011 Dean Michael Berris (dberris@google.com). // Copyright 2011 Google, Inc. // 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 NETWORK_MESSAGE_WRAPPERS_SOURCE_IPP_20111021 +#define NETWORK_MESSAGE_WRAPPERS_SOURCE_IPP_20111021 + #include -namespace boost { namespace network { +namespace network { source_wrapper::source_wrapper(message_base & message): message_(message) {} @@ -26,6 +26,4 @@ source_wrapper::operator std::string () const { } /* network */ -} /* boost */ - -#endif /* BOOST_NETWORK_MESSAGE_WRAPPERS_SOURCE_IPP_20111021 */ +#endif /* NETWORK_MESSAGE_WRAPPERS_SOURCE_IPP_20111021 */ diff --git a/include/network/message_fwd.hpp b/include/network/message_fwd.hpp index 6045b0cbf..4115cf0ec 100644 --- a/include/network/message_fwd.hpp +++ b/include/network/message_fwd.hpp @@ -1,20 +1,17 @@ -// Copyright (c) Glyn Matthews 2008. +// Copyright (c) Glyn Matthews 2008. // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) -#ifndef __2008817MESSAGE_FWD_INC__ -# define __2008817MESSAGE_FWD_INC__ +#ifndef 2008817MESSAGE_FWD_INC +#define 2008817MESSAGE_FWD_INC -namespace boost { namespace network { template struct basic_message; -} // namespace boost } // namespace network - -#endif // __2008817MESSAGE_FWD_INC__ +#endif // 2008817MESSAGE_FWD_INC diff --git a/include/network/protocol.hpp b/include/network/protocol.hpp index 9139a955c..188a97f8e 100644 --- a/include/network/protocol.hpp +++ b/include/network/protocol.hpp @@ -1,12 +1,11 @@ - -// Copyright Dean Michael Berris 2007. +// Copyright Dean Michael Berris 2007. // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) -#ifndef __NETWORK_PROTOCOLS_20070908_1_HPP__ -#define __NETWORK_PROTOCOLS_20070908_1_HPP__ +#ifndef NETWORK_PROTOCOLS_20070908_1_HPP +#define NETWORK_PROTOCOLS_20070908_1_HPP // Include all protocol implementation headers in protocol/* // Author: Dean Michael Berris @@ -14,4 +13,4 @@ #include // include HTTP implementation -#endif // __NETWORK_PROTOCOLS_20070908-1_HPP__ +#endif // NETWORK_PROTOCOLS_20070908-1_HPP diff --git a/include/network/protocol/http.hpp b/include/network/protocol/http.hpp index 15ec9e691..8c29dc750 100644 --- a/include/network/protocol/http.hpp +++ b/include/network/protocol/http.hpp @@ -1,12 +1,11 @@ - -// Copyright Dean Michael Berris 2007, 2008. +// Copyright Dean Michael Berris 2007, 2008. // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) -#ifndef __NETWORK_PROTOCOL_HTTP_20070908_1_HPP__ -#define __NETWORK_PROTOCOL_HTTP_20070908_1_HPP__ +#ifndef NETWORK_PROTOCOL_HTTP_20070908_1_HPP +#define NETWORK_PROTOCOL_HTTP_20070908_1_HPP // Include HTTP implementation headers // Author: Dean Michael Berris @@ -17,4 +16,4 @@ #include #include -#endif // __NETWORK_PROTOCOL_HTTP_20070908-1_HPP__ +#endif // NETWORK_PROTOCOL_HTTP_20070908-1_HPP diff --git a/include/network/protocol/http/algorithms/linearize.hpp b/include/network/protocol/http/algorithms/linearize.hpp index 6bd1d9931..f70f2ac87 100644 --- a/include/network/protocol/http/algorithms/linearize.hpp +++ b/include/network/protocol/http/algorithms/linearize.hpp @@ -1,12 +1,12 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_ALGORITHMS_LINEARIZE_HPP_20101028 -#define BOOST_NETWORK_PROTOCOL_HTTP_ALGORITHMS_LINEARIZE_HPP_20101028 - // Copyright 2010 Dean Michael Berris. // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_ALGORITHMS_LINEARIZE_HPP_20101028 +#define NETWORK_PROTOCOL_HTTP_ALGORITHMS_LINEARIZE_HPP_20101028 + #include #include #include @@ -16,150 +16,148 @@ #include #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { - struct linearize_header { - typedef std::string string_type; +struct linearize_header { + typedef std::string string_type; - template - struct result; + template + struct result; - template - struct result { - typedef string_type type; - }; + template + struct result { + typedef string_type type; + }; - template - BOOST_CONCEPT_REQUIRES( - ((Header)), - (string_type) - ) operator()(ValueType & header) { - typedef std::ostringstream output_stream; - typedef constants consts; - output_stream header_line; - header_line << name(header) - << consts::colon() << consts::space() - << value(header) << consts::crlf(); - return header_line.str(); - } - }; + template + CONCEPT_REQUIRES( + ((Header)), + (string_type) + ) operator()(ValueType & header) { + typedef std::ostringstream output_stream; + typedef constants consts; + output_stream header_line; + header_line << name(header) + << consts::colon() << consts::space() + << value(header) << consts::crlf(); + return header_line.str(); + } +}; - template - BOOST_CONCEPT_REQUIRES( - ((ClientRequest)), - (OutputIterator) - ) linearize( - Request const & request, - std::string const & method, - unsigned version_major, - unsigned version_minor, - OutputIterator oi - ) +template +CONCEPT_REQUIRES( + ((ClientRequest)), + (OutputIterator) +) linearize( + Request const & request, + std::string const & method, + unsigned version_major, + unsigned version_minor, + OutputIterator oi + ) +{ + typedef constants consts; + typedef std::string string_type; + static string_type + http_slash = consts::http_slash() + , accept = consts::accept() + , accept_mime = consts::default_accept_mime() + , accept_encoding = consts::accept_encoding() + , default_accept_encoding = consts::default_accept_encoding() + , default_user_agent = consts::default_user_agent() + , user_agent = consts::user_agent() + , crlf = consts::crlf() + , host_const = consts::host() + , connection = consts::connection() + , close = consts::close() + ; + boost::copy(method, oi); + *oi = consts::space_char(); { - typedef constants consts; - typedef std::string string_type; - static string_type - http_slash = consts::http_slash() - , accept = consts::accept() - , accept_mime = consts::default_accept_mime() - , accept_encoding = consts::accept_encoding() - , default_accept_encoding = consts::default_accept_encoding() - , default_user_agent = consts::default_user_agent() - , user_agent = consts::user_agent() - , crlf = consts::crlf() - , host_const = consts::host() - , connection = consts::connection() - , close = consts::close() - ; - boost::copy(method, oi); - *oi = consts::space_char(); - { - std::string path_ = path(request); - if (path_.empty() || path_[0] != consts::slash_char()) - *oi = consts::slash_char(); - boost::copy(path_, oi); - } - { - std::string query_ = query(request); - if (!query_.empty()) { - *oi = consts::question_mark_char(); - boost::copy(query_, oi); - } - } - { - std::string anchor_ = anchor(request); - if (!anchor_.empty()) { - *oi = consts::hash_char(); - boost::copy(anchor_, oi); - } - } - *oi = consts::space_char(); - boost::copy(http_slash, oi); - string_type version_major_str = boost::lexical_cast(version_major), - version_minor_str = boost::lexical_cast(version_minor); - boost::copy(version_major_str, oi); - *oi = consts::dot_char(); - boost::copy(version_minor_str, oi); - boost::copy(crlf, oi); - boost::copy(host_const, oi); + std::string path_ = path(request); + if (path_.empty() || path_[0] != consts::slash_char()) + *oi = consts::slash_char(); + boost::copy(path_, oi); + } + { + std::string query_ = query(request); + if (!query_.empty()) { + *oi = consts::question_mark_char(); + boost::copy(query_, oi); + } + } + { + std::string anchor_ = anchor(request); + if (!anchor_.empty()) { + *oi = consts::hash_char(); + boost::copy(anchor_, oi); + } + } + *oi = consts::space_char(); + boost::copy(http_slash, oi); + string_type version_major_str = boost::lexical_cast(version_major), + version_minor_str = boost::lexical_cast(version_minor); + boost::copy(version_major_str, oi); + *oi = consts::dot_char(); + boost::copy(version_minor_str, oi); + boost::copy(crlf, oi); + boost::copy(host_const, oi); + *oi = consts::colon_char(); + *oi = consts::space_char(); + { + std::string host_ = host(request); + boost::copy(host_, oi); + } + boost::optional port_ = port(request); + if (port_) { + string_type port_str = boost::lexical_cast(*port_); + *oi = consts::colon_char(); + boost::copy(port_str, oi); + } + boost::copy(crlf, oi); + boost::copy(accept, oi); + *oi = consts::colon_char(); + *oi = consts::space_char(); + boost::copy(accept_mime, oi); + boost::copy(crlf, oi); + if (version_major == 1u && version_minor == 1u) { + boost::copy(accept_encoding, oi); *oi = consts::colon_char(); *oi = consts::space_char(); - { - std::string host_ = host(request); - boost::copy(host_, oi); - } - boost::optional port_ = port(request); - if (port_) { - string_type port_str = boost::lexical_cast(*port_); - *oi = consts::colon_char(); - boost::copy(port_str, oi); - } + boost::copy(default_accept_encoding, oi); boost::copy(crlf, oi); - boost::copy(accept, oi); + } + typedef headers_wrapper::container_type headers_container; + typedef headers_container::const_iterator headers_iterator; + headers_container const & request_headers = boost::network::headers(request); + headers_iterator iterator = boost::begin(request_headers), + end = boost::end(request_headers); + bool has_user_agent = false; + for (; iterator != end; ++iterator) { + string_type header_name = name(*iterator), + header_value = value(*iterator); + boost::copy(header_name, oi); *oi = consts::colon_char(); *oi = consts::space_char(); - boost::copy(accept_mime, oi); + boost::copy(header_value, oi); boost::copy(crlf, oi); - if (version_major == 1u && version_minor == 1u) { - boost::copy(accept_encoding, oi); - *oi = consts::colon_char(); - *oi = consts::space_char(); - boost::copy(default_accept_encoding, oi); - boost::copy(crlf, oi); - } - typedef headers_wrapper::container_type headers_container; - typedef headers_container::const_iterator headers_iterator; - headers_container const & request_headers = boost::network::headers(request); - headers_iterator iterator = boost::begin(request_headers), - end = boost::end(request_headers); - bool has_user_agent = false; - for (; iterator != end; ++iterator) { - string_type header_name = name(*iterator), - header_value = value(*iterator); - boost::copy(header_name, oi); - *oi = consts::colon_char(); - *oi = consts::space_char(); - boost::copy(header_value, oi); - boost::copy(crlf, oi); - boost::to_lower(header_name); - has_user_agent = has_user_agent || header_name == "user-agent"; - } - if (!has_user_agent) { - boost::copy(user_agent, oi); - *oi = consts::colon_char(); - *oi = consts::space_char(); - boost::copy(default_user_agent, oi); - boost::copy(crlf, oi); - } - boost::copy(crlf, oi); - auto body_data = boost::network::body(request); - return std::copy(body_data.begin(), body_data.end(), oi); + boost::to_lower(header_name); + has_user_agent = has_user_agent || header_name == "user-agent"; } + if (!has_user_agent) { + boost::copy(user_agent, oi); + *oi = consts::colon_char(); + *oi = consts::space_char(); + boost::copy(default_user_agent, oi); + boost::copy(crlf, oi); + } + boost::copy(crlf, oi); + auto body_data = boost::network::body(request); + return std::copy(body_data.begin(), body_data.end(), oi); +} -} /* http */ - -} /* net */ +} // namespace http +} // namespace network -} /* boost */ - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_ALGORITHMS_LINEARIZE_HPP_20101028 */ +#endif /* NETWORK_PROTOCOL_HTTP_ALGORITHMS_LINEARIZE_HPP_20101028 */ diff --git a/include/network/protocol/http/client.hpp b/include/network/protocol/http/client.hpp index 6c5f05549..4cce99248 100644 --- a/include/network/protocol/http/client.hpp +++ b/include/network/protocol/http/client.hpp @@ -1,12 +1,12 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_20091215 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_20091215 - // Copyright 2012 Dean Michael Berris . // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_20091215 +#define NETWORK_PROTOCOL_HTTP_CLIENT_20091215 + #include #include @@ -16,7 +16,8 @@ #include #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { struct client : basic_client_facade { private: @@ -40,13 +41,6 @@ struct client : basic_client_facade { }; } // namespace http - } // namespace network -} // namespace boost - -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_20091215 +#endif // NETWORK_PROTOCOL_HTTP_CLIENT_20091215 diff --git a/include/network/protocol/http/client.ipp b/include/network/protocol/http/client.ipp index ffe1f833f..fa2fb9a6f 100644 --- a/include/network/protocol/http/client.ipp +++ b/include/network/protocol/http/client.ipp @@ -1,31 +1,30 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_IPP_20120306 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_IPP_20120306 - // Copyright 2012 Dean Michael Berris . // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_IPP_20120306 +#define NETWORK_PROTOCOL_HTTP_CLIENT_IPP_20120306 + #include #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { client::client() : base_facade_type() { - BOOST_NETWORK_MESSAGE("client::client()"); + NETWORK_MESSAGE("client::client()"); } client::client(client_options const &options) : base_facade_type(options) { - BOOST_NETWORK_MESSAGE("client::client(client_options const &)"); + NETWORK_MESSAGE("client::client(client_options const &)"); } } // namespace http } // namespace network -} // namespace boost -#endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_IPP_20120306 +#endif // NETWORK_PROTOCOL_HTTP_CLIENT_IPP_20120306 diff --git a/include/network/protocol/http/client/base.hpp b/include/network/protocol/http/client/base.hpp index c67d0fb83..e792020f8 100644 --- a/include/network/protocol/http/client/base.hpp +++ b/include/network/protocol/http/client/base.hpp @@ -1,24 +1,22 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_BASE_HPP_20111008 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_BASE_HPP_20111008 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_BASE_HPP_20111008 +#define NETWORK_PROTOCOL_HTTP_CLIENT_BASE_HPP_20111008 + #include #include namespace boost { namespace asio { - class io_service; - } // namespace asio - } // namespace boost -namespace boost { namespace network { namespace http { +namespace network { +namespace http { struct client_base_pimpl; struct request; @@ -46,10 +44,7 @@ struct client_base { client_base_pimpl * pimpl; }; -} /* http */ - -} /* network */ +} // namespace http +} // namespace network -} /* boost */ - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_BASE_HPP_20111008 */ +#endif /* NETWORK_PROTOCOL_HTTP_CLIENT_BASE_HPP_20111008 */ diff --git a/include/network/protocol/http/client/base.ipp b/include/network/protocol/http/client/base.ipp index 7c0492e44..8736e984f 100644 --- a/include/network/protocol/http/client/base.ipp +++ b/include/network/protocol/http/client/base.ipp @@ -1,12 +1,12 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_ASYNC_IMPL_HPP_20100623 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_ASYNC_IMPL_HPP_20100623 - // Copyright 2011 Dean Michael Berris (dberris@google.com). // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_ASYNC_IMPL_HPP_20100623 +#define NETWORK_PROTOCOL_HTTP_CLIENT_ASYNC_IMPL_HPP_20100623 + #include #include #include @@ -18,7 +18,7 @@ #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { struct client_base_pimpl { typedef @@ -43,12 +43,12 @@ struct client_base_pimpl { client_base::client_base() : pimpl(new (std::nothrow) client_base_pimpl(client_options())) { - BOOST_NETWORK_MESSAGE("client_base::client_base()"); + NETWORK_MESSAGE("client_base::client_base()"); } client_base::client_base(client_options const &options) : pimpl(new (std::nothrow) client_base_pimpl(options)) { - BOOST_NETWORK_MESSAGE("client_base::client_base(client_options const &)"); + NETWORK_MESSAGE("client_base::client_base(client_options const &)"); } void client_base::clear_resolved_cache() { @@ -60,12 +60,12 @@ response const client_base::request_skeleton(request const & request_, bool get_body, body_callback_function_type callback, request_options const &options) { - BOOST_NETWORK_MESSAGE("client_base::request_skeleton(...)"); + NETWORK_MESSAGE("client_base::request_skeleton(...)"); return pimpl->request_skeleton(request_, method, get_body, callback, options); } client_base::~client_base() { - BOOST_NETWORK_MESSAGE("client_base::~client_base()"); + NETWORK_MESSAGE("client_base::~client_base()"); delete pimpl; } @@ -75,14 +75,14 @@ client_base_pimpl::client_base_pimpl(client_options const &options) sentinel_(), connection_manager_(options.connection_manager()), owned_service_(false) { - BOOST_NETWORK_MESSAGE("client_base_pimpl::client_base_pimpl(client_options const &)"); + NETWORK_MESSAGE("client_base_pimpl::client_base_pimpl(client_options const &)"); if (service_ptr == 0) { - BOOST_NETWORK_MESSAGE("creating owned io_service."); + NETWORK_MESSAGE("creating owned io_service."); service_ptr = new(std::nothrow) asio::io_service; owned_service_ = true; } if (!connection_manager_.get()) { - BOOST_NETWORK_MESSAGE("creating owned simple_connection_manager"); + NETWORK_MESSAGE("creating owned simple_connection_manager"); connection_manager_.reset( new (std::nothrow) simple_connection_manager(options)); } @@ -93,12 +93,12 @@ client_base_pimpl::client_base_pimpl(client_options const &options) service_ptr ))); if (!lifetime_thread_.get()) - BOOST_THROW_EXCEPTION(std::runtime_error("Cannot allocate client lifetime thread; not enough memory.")); + THROW_EXCEPTION(std::runtime_error("Cannot allocate client lifetime thread; not enough memory.")); } client_base_pimpl::~client_base_pimpl() { - BOOST_NETWORK_MESSAGE("client_base_pimpl::~client_base_pimpl()"); + NETWORK_MESSAGE("client_base_pimpl::~client_base_pimpl()"); sentinel_.reset(); connection_manager_->reset(); if (lifetime_thread_.get()) { @@ -116,14 +116,14 @@ response const client_base_pimpl::request_skeleton( request_options const &options ) { - BOOST_NETWORK_MESSAGE("client_base_pimpl::request_skeleton(...)"); + NETWORK_MESSAGE("client_base_pimpl::request_skeleton(...)"); shared_ptr connection_; connection_ = connection_manager_->get_connection(*service_ptr, request_, options_); return connection_->send_request(method, request_, get_body, callback, options); } void client_base_pimpl::clear_resolved_cache() { - BOOST_NETWORK_MESSAGE("client_base_pimpl::clear_resolved_cache()"); + NETWORK_MESSAGE("client_base_pimpl::clear_resolved_cache()"); connection_manager_->clear_resolved_cache(); } @@ -131,6 +131,4 @@ void client_base_pimpl::clear_resolved_cache() { } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_ASYNC_IMPL_HPP_20100623 +#endif // NETWORK_PROTOCOL_HTTP_CLIENT_ASYNC_IMPL_HPP_20100623 diff --git a/include/network/protocol/http/client/client_connection.hpp b/include/network/protocol/http/client/client_connection.hpp index 5f76644e4..1fa392348 100644 --- a/include/network/protocol/http/client/client_connection.hpp +++ b/include/network/protocol/http/client/client_connection.hpp @@ -1,17 +1,17 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CLIENT_CONNECTION_HPP_20111103 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CLIENT_CONNECTION_HPP_20111103 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_CLIENT_CONNECTION_HPP_20111103 +#define NETWORK_PROTOCOL_HTTP_CLIENT_CLIENT_CONNECTION_HPP_20111103 + #include #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { struct request; struct response; @@ -36,6 +36,4 @@ struct client_connection { } /* network */ -} /* boost */ - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CLIENT_CONNECTION_HPP_20111103 */ +#endif /* NETWORK_PROTOCOL_HTTP_CLIENT_CLIENT_CONNECTION_HPP_20111103 */ diff --git a/include/network/protocol/http/client/client_connection.ipp b/include/network/protocol/http/client/client_connection.ipp index 6e6ba1539..18e2da53d 100644 --- a/include/network/protocol/http/client/client_connection.ipp +++ b/include/network/protocol/http/client/client_connection.ipp @@ -1,27 +1,27 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CLIENT_CONNECTION_IPP_20111103 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CLIENT_CONNECTION_IPP_20111103 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_CLIENT_CONNECTION_IPP_20111103 +#define NETWORK_PROTOCOL_HTTP_CLIENT_CLIENT_CONNECTION_IPP_20111103 + #include #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { client_connection::~client_connection() { - BOOST_NETWORK_MESSAGE("client_connection::~client_connection()"); + NETWORK_MESSAGE("client_connection::~client_connection()"); // Do nothing here. } client_connection * client_connection::clone() const { - BOOST_NETWORK_MESSAGE("client_connection::clone()"); + NETWORK_MESSAGE("client_connection::clone()"); // For exposition only. - BOOST_ASSERT(false && "This should not ever be called."); + ASSERT(false && "This should not ever be called."); return 0; } @@ -30,6 +30,4 @@ client_connection * client_connection::clone() const { } /* network */ -} /* boost */ - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CLIENT_CONNECTION_IPP_20111103 */ +#endif /* NETWORK_PROTOCOL_HTTP_CLIENT_CLIENT_CONNECTION_IPP_20111103 */ diff --git a/include/network/protocol/http/client/connection/async_normal.hpp b/include/network/protocol/http/client/connection/async_normal.hpp index 2a3050c4d..ede0d81fe 100644 --- a/include/network/protocol/http/client/connection/async_normal.hpp +++ b/include/network/protocol/http/client/connection/async_normal.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_IMPL_HTTP_ASYNC_CONNECTION_HPP_20100601 -#define BOOST_NETWORK_PROTOCOL_HTTP_IMPL_HTTP_ASYNC_CONNECTION_HPP_20100601 - // Copyright 2010 (C) Dean Michael Berris // Copyright 2010 (C) Sinefunc, Inc. // Copyright 2011 Dean Michael Berris (dberris@google.com). @@ -9,6 +6,9 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_PROTOCOL_HTTP_IMPL_HTTP_ASYNC_CONNECTION_HPP_20100601 +#define NETWORK_PROTOCOL_HTTP_IMPL_HTTP_ASYNC_CONNECTION_HPP_20100601 + #include #include #include @@ -22,7 +22,7 @@ class io_service; } // namespace boost -namespace boost { namespace network { namespace http { +namespace network { namespace http { struct request; struct response; @@ -55,6 +55,4 @@ struct http_async_connection : client_connection } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_IMPL_HTTP_ASYNC_CONNECTION_HPP_20100601 +#endif // NETWORK_PROTOCOL_HTTP_IMPL_HTTP_ASYNC_CONNECTION_HPP_20100601 diff --git a/include/network/protocol/http/client/connection/async_normal.ipp b/include/network/protocol/http/client/connection/async_normal.ipp index 81d80a18f..9c57678e5 100644 --- a/include/network/protocol/http/client/connection/async_normal.ipp +++ b/include/network/protocol/http/client/connection/async_normal.ipp @@ -1,12 +1,12 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_NORMAL_IPP_20111123 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_NORMAL_IPP_20111123 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_NORMAL_IPP_20111123 +#define NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_NORMAL_IPP_20111123 + #include #include #include @@ -17,11 +17,11 @@ #include #include #include -#ifdef BOOST_NETWORK_ENABLE_HTTPS +#ifdef NETWORK_ENABLE_HTTPS #include #endif -namespace boost { namespace network { namespace http { +namespace network { namespace http { namespace placeholders = boost::asio::placeholders; @@ -42,7 +42,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisinit_response(response_); // Use HTTP/1.1 -- at some point we might want to implement a different @@ -62,9 +62,9 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this(&command_streambuf)); this->method = method; - BOOST_NETWORK_MESSAGE("method: " << this->method); + NETWORK_MESSAGE("method: " << this->method); boost::uint16_t port_ = port(request); - BOOST_NETWORK_MESSAGE("port: " << port_); + NETWORK_MESSAGE("port: " << port_); this->host_ = host(request); resolver_delegate_->resolve( this->host_, @@ -82,7 +82,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisresolver_delegate_, this->connection_delegate_, @@ -99,7 +99,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thissource_promise); accessor.set_destination_promise(r, this->destination_promise); @@ -108,12 +108,12 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisversion_promise); accessor.set_status_promise(r, this->status_promise); accessor.set_status_message_promise(r, this->status_message_promise); - BOOST_NETWORK_MESSAGE("futures and promises lined up."); + NETWORK_MESSAGE("futures and promises lined up."); } void set_errors(boost::system::error_code const & ec) { - BOOST_NETWORK_MESSAGE("http_async_connection_pimpl::set_errors(...)"); - BOOST_NETWORK_MESSAGE("error: " << ec); + NETWORK_MESSAGE("http_async_connection_pimpl::set_errors(...)"); + NETWORK_MESSAGE("error: " << ec); boost::system::system_error error(ec); this->version_promise.set_exception(boost::copy_exception(error)); this->status_promise.set_exception(boost::copy_exception(error)); @@ -122,7 +122,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thissource_promise.set_exception(boost::copy_exception(error)); this->destination_promise.set_exception(boost::copy_exception(error)); this->body_promise.set_exception(boost::copy_exception(error)); - BOOST_NETWORK_MESSAGE("promise+future exceptions set."); + NETWORK_MESSAGE("promise+future exceptions set."); } void handle_resolved(boost::uint16_t port, @@ -130,12 +130,12 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisendpoint().address() << ":" << port); asio::ip::tcp::endpoint endpoint(iter->endpoint().address(), port); connection_delegate_->connect( @@ -152,7 +152,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thiswrite(command_streambuf, request_strand_.wrap( boost::bind( @@ -177,10 +177,10 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisendpoint().address() << ":" << port); + NETWORK_MESSAGE("trying: " << iter->endpoint().address() << ":" << port); asio::ip::tcp::endpoint endpoint(iter->endpoint().address(), port); connection_delegate_->connect(endpoint, this->host_, @@ -208,9 +208,9 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisread_some( boost::asio::mutable_buffers_1(this->part.c_array(), this->part.size()), @@ -221,20 +221,20 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisparse_version(request_strand_.wrap( boost::bind( @@ -259,7 +259,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisparse_status(request_strand_.wrap( boost::bind( @@ -271,7 +271,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisparse_status_message( request_strand_.wrap( @@ -286,7 +286,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thissource_promise.set_value(""); this->part.assign('\0'); this->response_parser_.reset(); - BOOST_NETWORK_MESSAGE("processing done."); + NETWORK_MESSAGE("processing done."); return; } if (callback) { - BOOST_NETWORK_MESSAGE("callback provided, processing body..."); + NETWORK_MESSAGE("callback provided, processing body..."); // Here we deal with the spill-over data from the // headers processing. This means the headers data // has already been parsed appropriately and we're @@ -353,7 +353,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisparse_body( @@ -369,15 +369,15 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thispart.begin(), end = begin; @@ -388,7 +388,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thispartial_parsed); body_string.append( @@ -403,11 +403,11 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thispart.assign('\0'); this->response_parser_.reset(); } else { - BOOST_NETWORK_MESSAGE("connection still active..."); + NETWORK_MESSAGE("connection still active..."); // This means the connection has not been closed yet and we want to get more // data. if (callback) { - BOOST_NETWORK_MESSAGE("callback provided, invoking callback..."); + NETWORK_MESSAGE("callback provided, invoking callback..."); // Here we have a body_handler callback. Let's invoke the // callback from here and make sure we're getting more data // right after. @@ -429,7 +429,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thissource_promise.set_exception(boost::copy_exception(error)); this->destination_promise.set_exception(boost::copy_exception(error)); switch (state) { @@ -468,12 +468,12 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisbody_promise.set_exception(boost::copy_exception(error)); break; default: - BOOST_ASSERT(false && "Bug, report this to the developers!"); + ASSERT(false && "Bug, report this to the developers!"); } } } -#ifdef BOOST_NETWORK_DEBUG +#ifdef NETWORK_DEBUG struct debug_escaper { std::string & string; explicit debug_escaper(std::string & string_) @@ -533,11 +533,11 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this source_promise; boost::promise destination_promise; boost::promise body_promise; - typedef boost::array buffer_type; + typedef boost::array buffer_type; buffer_type part; buffer_type::const_iterator part_begin; std::string partial_parsed; @@ -833,10 +833,7 @@ void http_async_connection::reset() { pimpl->reset(); // NOTE: We're not resetting the pimpl, just the internal state. } -} /* http */ +} // namespace http +} // namespace network -} /* network */ - -} /* boost */ - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_NORMAL_IPP_20111123 */ +#endif /* NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_NORMAL_IPP_20111123 */ diff --git a/include/network/protocol/http/client/connection/async_protocol_handler.hpp b/include/network/protocol/http/client/connection/async_protocol_handler.hpp index d45270aeb..f436a11b0 100644 --- a/include/network/protocol/http/client/connection/async_protocol_handler.hpp +++ b/include/network/protocol/http/client/connection/async_protocol_handler.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_IMPL_HTTP_ASYNC_PROTOCOL_HANDLER_HPP_ -#define BOOST_NETWORK_PROTOCOL_HTTP_IMPL_HTTP_ASYNC_PROTOCOL_HANDLER_HPP_ - // Copyright 2010 (C) Dean Michael Berris // Copyright 2011 Dean Michael Berris (dberris@google.com). // Copyright 2011 Google, Inc. @@ -8,15 +5,20 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_PROTOCOL_HTTP_IMPL_HTTP_ASYNC_PROTOCOL_HANDLER_HPP_ +#define NETWORK_PROTOCOL_HTTP_IMPL_HTTP_ASYNC_PROTOCOL_HANDLER_HPP_ + #include #include -namespace boost { namespace network { namespace http { namespace impl { +namespace network { +namespace http { +namespace impl { struct http_async_protocol_handler { protected: -#ifdef BOOST_NETWORK_DEBUG +#ifdef NETWORK_DEBUG struct debug_escaper { std::string & string; explicit debug_escaper(std::string & string_) @@ -101,11 +103,11 @@ namespace boost { namespace network { namespace http { namespace impl { version_promise.set_value(version); part_begin = boost::end(result_range); } else if (parsed_ok == false) { -#ifdef BOOST_NETWORK_DEBUG +#ifdef NETWORK_DEBUG std::string escaped; debug_escaper escaper(escaped); std::for_each(part_begin, part_end, escaper); - BOOST_NETWORK_MESSAGE("[parser:" + NETWORK_MESSAGE("[parser:" << response_parser_.state() << "] buffer contents: \"" << escaped @@ -158,11 +160,11 @@ namespace boost { namespace network { namespace http { namespace impl { status_promise.set_value(status_int); part_begin = boost::end(result_range); } else if (parsed_ok == false) { -#ifdef BOOST_NETWORK_DEBUG +#ifdef NETWORK_DEBUG std::string escaped; debug_escaper escaper(escaped); std::for_each(part_begin, part_end, escaper); - BOOST_NETWORK_MESSAGE("[parser:" + NETWORK_MESSAGE("[parser:" << response_parser_.state() << "] buffer contents: \"" << escaped @@ -212,11 +214,11 @@ namespace boost { namespace network { namespace http { namespace impl { status_message_promise.set_value(status_message); part_begin = boost::end(result_range); } else if (parsed_ok == false) { -#ifdef BOOST_NETWORK_DEBUG +#ifdef NETWORK_DEBUG std::string escaped; debug_escaper escaper(escaped); std::for_each(part_begin, part_end, escaper); - BOOST_NETWORK_MESSAGE("[parser:" + NETWORK_MESSAGE("[parser:" << response_parser_.state() << "] buffer contents: \"" << escaped @@ -305,11 +307,11 @@ namespace boost { namespace network { namespace http { namespace impl { } else if (parsed_ok == false) { // We want to output the contents of the buffer that caused // the error in debug builds. -#ifdef BOOST_NETWORK_DEBUG +#ifdef NETWORK_DEBUG std::string escaped; debug_escaper escaper(escaped); std::for_each(part_begin, part_end, escaper); - BOOST_NETWORK_MESSAGE("[parser:" + NETWORK_MESSAGE("[parser:" << response_parser_.state() << "] buffer contents: \"" << escaped @@ -359,19 +361,15 @@ namespace boost { namespace network { namespace http { namespace impl { boost::promise source_promise; boost::promise destination_promise; boost::promise body_promise; - typedef boost::array buffer_type; + typedef boost::array buffer_type; buffer_type part; buffer_type::const_iterator part_begin; std::string partial_parsed; }; -} /* impl */ - -} /* http */ - -} /* network */ - -} /* boost */ +} // namespace impl +} // namespace http +} // namespace network -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_IMPL_HTTP_ASYNC_PROTOCOL_HANDLER_HPP_20101015 */ +#endif /* NETWORK_PROTOCOL_HTTP_IMPL_HTTP_ASYNC_PROTOCOL_HANDLER_HPP_20101015 */ diff --git a/include/network/protocol/http/client/connection/async_resolver.hpp b/include/network/protocol/http/client/connection/async_resolver.hpp index fb5a8e517..e55bd8efb 100644 --- a/include/network/protocol/http/client/connection/async_resolver.hpp +++ b/include/network/protocol/http/client/connection/async_resolver.hpp @@ -1,16 +1,17 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_RESOLVER_20111126 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_RESOLVER_20111126 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_RESOLVER_20111126 +#define NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_RESOLVER_20111126 + #include #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { struct async_resolver_pimpl; @@ -34,10 +35,4 @@ struct async_resolver : resolver_delegate { } // namespace network -} // namespace boost - -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_RESOLVER_20111126 +#endif // NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_RESOLVER_20111126 diff --git a/include/network/protocol/http/client/connection/async_resolver.ipp b/include/network/protocol/http/client/connection/async_resolver.ipp index 096ad70f5..e5eb15e8c 100644 --- a/include/network/protocol/http/client/connection/async_resolver.ipp +++ b/include/network/protocol/http/client/connection/async_resolver.ipp @@ -1,12 +1,12 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_RESOLVER_IPP_20110911 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_RESOLVER_IPP_20111126 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_RESOLVER_IPP_20110911 +#define NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_RESOLVER_IPP_20111126 + #include #include #include @@ -23,7 +23,7 @@ #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { struct async_resolver_pimpl : enable_shared_from_this { typedef resolver_delegate::resolve_completion_function resolve_completion_function; async_resolver_pimpl(asio::io_service & service, bool cache_resolved); @@ -65,7 +65,7 @@ void async_resolver_pimpl::resolve(std::string const & host, boost::uint16_t port, resolve_completion_function once_resolved) { if (!resolver_strand_.get()) - BOOST_THROW_EXCEPTION(std::runtime_error( + THROW_EXCEPTION(std::runtime_error( "Uninitialized resolver strand, ran out of memory.")); if (cache_resolved_) { @@ -117,12 +117,12 @@ async_resolver::async_resolver(asio::io_service & service, bool cache_resolved) void async_resolver::resolve(std::string const & host, uint16_t port, resolve_completion_function once_resolved) { - BOOST_ASSERT(pimpl.get() && "Uninitialized pimpl, probably ran out of memory."); + ASSERT(pimpl.get() && "Uninitialized pimpl, probably ran out of memory."); pimpl->resolve(host, port, once_resolved); } void async_resolver::clear_resolved_cache() { - BOOST_ASSERT(pimpl.get() && "Uninitialized pimpl, probably ran out of memory."); + ASSERT(pimpl.get() && "Uninitialized pimpl, probably ran out of memory."); pimpl->clear_resolved_cache(); } @@ -130,11 +130,7 @@ async_resolver::~async_resolver() { // Do nothing } -} /* http */ - -} /* network */ +} // namespace http +} // namespace network -} /* boost */ - - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_RESOLVER_IPP_20111126 */ +#endif /* NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_RESOLVER_IPP_20111126 */ diff --git a/include/network/protocol/http/client/connection/connection_delegate.hpp b/include/network/protocol/http/client/connection/connection_delegate.hpp index 24d143f70..6c2a39c57 100644 --- a/include/network/protocol/http/client/connection/connection_delegate.hpp +++ b/include/network/protocol/http/client/connection/connection_delegate.hpp @@ -1,17 +1,18 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_DELEGATE_HPP_ -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_DELEGATE_HPP_ - // Copyright 2011 Dean Michael Berris (dberris@google.com). // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_DELEGATE_HPP_ +#define NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_DELEGATE_HPP_ + #include #include #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { struct connection_delegate { virtual void connect(asio::ip::tcp::endpoint & endpoint, @@ -24,10 +25,7 @@ struct connection_delegate { virtual ~connection_delegate() {} }; -} /* http */ - -} /* network */ - -} /* boost */ +} // namespace http +} // namespace network -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_DELEGATE_HPP_ */ +#endif /* NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_DELEGATE_HPP_ */ diff --git a/include/network/protocol/http/client/connection/connection_delegate_factory.hpp b/include/network/protocol/http/client/connection/connection_delegate_factory.hpp index 489b327d5..fc5af848c 100644 --- a/include/network/protocol/http/client/connection/connection_delegate_factory.hpp +++ b/include/network/protocol/http/client/connection/connection_delegate_factory.hpp @@ -1,16 +1,17 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_DELEGATE_FACTORY_HPP_20110819 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_DELEGATE_FACTORY_HPP_20110819 - // Copyright 2011 Dean Michael Berris (dberris@google.com). // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_DELEGATE_FACTORY_HPP_20110819 +#define NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_DELEGATE_FACTORY_HPP_20110819 + #include #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { class client_options; @@ -32,8 +33,7 @@ struct connection_delegate_factory { connection_delegate_factory& operator=(connection_delegate_factory); // = delete }; -} /* http */ -} /* network */ -} /* boost */ +} // namespace http +} // namespace network -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_DELEGATE_FACTORY_HPP_20110819 */ +#endif /* NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_DELEGATE_FACTORY_HPP_20110819 */ diff --git a/include/network/protocol/http/client/connection/connection_delegate_factory.ipp b/include/network/protocol/http/client/connection/connection_delegate_factory.ipp index 3c90a9764..83a5d58e0 100644 --- a/include/network/protocol/http/client/connection/connection_delegate_factory.ipp +++ b/include/network/protocol/http/client/connection/connection_delegate_factory.ipp @@ -1,25 +1,25 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_DELEGATE_FACTORY_IPP_20111123 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_DELEGATE_FACTORY_IPP_20111123 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_DELEGATE_FACTORY_IPP_20111123 +#define NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_DELEGATE_FACTORY_IPP_20111123 + #include -#ifdef BOOST_NETWORK_ENABLE_HTTPS +#ifdef NETWORK_ENABLE_HTTPS #include -#endif /* BOOST_NETWORK_ENABLE_HTTPS */ +#endif /* NETWORK_ENABLE_HTTPS */ #include #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { connection_delegate_factory::connection_delegate_factory() { - BOOST_NETWORK_MESSAGE("connection_delegate_factory::connection_delegate_factory()"); + NETWORK_MESSAGE("connection_delegate_factory::connection_delegate_factory()"); } connection_delegate_factory::connection_delegate_ptr @@ -27,32 +27,29 @@ connection_delegate_factory::create_connection_delegate( asio::io_service & service, bool https, client_options const &options) { - BOOST_NETWORK_MESSAGE("connection_delegate_factory::create_connection_delegate(...)"); + NETWORK_MESSAGE("connection_delegate_factory::create_connection_delegate(...)"); connection_delegate_ptr delegate; if (https) { -#ifdef BOOST_NETWORK_ENABLE_HTTPS - BOOST_NETWORK_MESSAGE("creating an SSL delegate"); +#ifdef NETWORK_ENABLE_HTTPS + NETWORK_MESSAGE("creating an SSL delegate"); delegate.reset(new ssl_delegate(service, options)); #else - BOOST_NETWORK_MESSAGE("creating an SSL delegate, but not supported"); - BOOST_THROW_EXCEPTION(std::runtime_error("HTTPS not supported.")); -#endif /* BOOST_NETWORK_ENABLE_HTTPS */ + NETWORK_MESSAGE("creating an SSL delegate, but not supported"); + THROW_EXCEPTION(std::runtime_error("HTTPS not supported.")); +#endif /* NETWORK_ENABLE_HTTPS */ } else { - BOOST_NETWORK_MESSAGE("creating a normal delegate"); + NETWORK_MESSAGE("creating a normal delegate"); delegate.reset(new normal_delegate(service)); } return delegate; } connection_delegate_factory::~connection_delegate_factory() { - BOOST_NETWORK_MESSAGE("connection_delegate_factory::~connection_delegate_factory()"); + NETWORK_MESSAGE("connection_delegate_factory::~connection_delegate_factory()"); } -} /* http */ - -} /* network */ - -} /* boost */ +} // namespace http +} // namespace network -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_DELEGATE_FACTORY_IPP_20111123 */ +#endif /* NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_DELEGATE_FACTORY_IPP_20111123 */ diff --git a/include/network/protocol/http/client/connection/connection_factory.hpp b/include/network/protocol/http/client/connection/connection_factory.hpp index aa7dc8388..10cb744a1 100644 --- a/include/network/protocol/http/client/connection/connection_factory.hpp +++ b/include/network/protocol/http/client/connection/connection_factory.hpp @@ -1,12 +1,12 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_FACTORY_HPP_20111112 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_FACTORY_HPP_20111112 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_FACTORY_HPP_20111112 +#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_FACTORY_HPP_20111112 + #include namespace boost { namespace asio { @@ -17,7 +17,7 @@ class io_service; } // namespace boost -namespace boost { namespace network { namespace http { +namespace network { namespace http { class client_options; struct client_connection; @@ -30,10 +30,7 @@ struct connection_factory { virtual ~connection_factory() = 0; // pure virtual, interface only. }; -} /* http */ - -} /* network */ - -} /* boost */ +} // namespace http +} // namespace network #endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_FACTORY_HPP_20111112 */ diff --git a/include/network/protocol/http/client/connection/connection_factory.ipp b/include/network/protocol/http/client/connection/connection_factory.ipp index 471faa5a3..5816adb3d 100644 --- a/include/network/protocol/http/client/connection/connection_factory.ipp +++ b/include/network/protocol/http/client/connection/connection_factory.ipp @@ -1,22 +1,19 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_FACTORY_IPP_20111126 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_FACTORY_IPP_20111126 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_FACTORY_IPP_20111126 +#define NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_FACTORY_IPP_20111126 + #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { connection_factory::~connection_factory() {} } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_FACTORY_IPP_20111126 +#endif // NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_FACTORY_IPP_20111126 diff --git a/include/network/protocol/http/client/connection/normal_delegate.hpp b/include/network/protocol/http/client/connection/normal_delegate.hpp index 4b1f0b21b..255c8db66 100644 --- a/include/network/protocol/http/client/connection/normal_delegate.hpp +++ b/include/network/protocol/http/client/connection/normal_delegate.hpp @@ -1,12 +1,12 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_NORMAL_DELEGATE_20110819 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_NORMAL_DELEGATE_20110819 - // Copyright 2011 Dean Michael Berris (dberris@google.com). // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_NORMAL_DELEGATE_20110819 +#define NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_NORMAL_DELEGATE_20110819 + #include #include @@ -18,7 +18,8 @@ class io_service; } // namespace boost -namespace boost { namespace network { namespace http { +namespace network { +namespace http { struct normal_delegate : connection_delegate { normal_delegate(asio::io_service & service); @@ -40,10 +41,7 @@ struct normal_delegate : connection_delegate { normal_delegate& operator=(normal_delegate); // = delete }; -} /* http */ - -} /* network */ - -} /* boost */ +} // namespace http +} // namespace network -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_NORMAL_DELEGATE_20110819 */ +#endif /* NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_NORMAL_DELEGATE_20110819 */ diff --git a/include/network/protocol/http/client/connection/normal_delegate.ipp b/include/network/protocol/http/client/connection/normal_delegate.ipp index f071bffa7..be469a65e 100644 --- a/include/network/protocol/http/client/connection/normal_delegate.ipp +++ b/include/network/protocol/http/client/connection/normal_delegate.ipp @@ -1,12 +1,12 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_NORMAL_DELEGATE_IPP_20110819 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_NORMAL_DELEGATE_IPP_20110819 - // Copyright 2011 Dean Michael Berris (dberris@google.com). // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_NORMAL_DELEGATE_IPP_20110819 +#define NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_NORMAL_DELEGATE_IPP_20110819 + #include #include #include @@ -15,11 +15,11 @@ #include #include -boost::network::http::normal_delegate::normal_delegate(asio::io_service & service) +network::http::normal_delegate::normal_delegate(asio::io_service & service) : service_(service) {} -void boost::network::http::normal_delegate::connect( +void network::http::normal_delegate::connect( asio::ip::tcp::endpoint & endpoint, std::string const &host, function handler) { @@ -27,23 +27,23 @@ void boost::network::http::normal_delegate::connect( socket_->async_connect(endpoint, handler); } -void boost::network::http::normal_delegate::write( +void network::http::normal_delegate::write( asio::streambuf & command_streambuf, function handler) { - BOOST_NETWORK_MESSAGE("normal_delegate::write(...)"); - BOOST_NETWORK_MESSAGE("scheduling asynchronous write..."); + NETWORK_MESSAGE("normal_delegate::write(...)"); + NETWORK_MESSAGE("scheduling asynchronous write..."); asio::async_write(*socket_, command_streambuf, handler); } -void boost::network::http::normal_delegate::read_some( +void network::http::normal_delegate::read_some( asio::mutable_buffers_1 const & read_buffer, function handler) { - BOOST_NETWORK_MESSAGE("normal_delegate::read_some(...)"); - BOOST_NETWORK_MESSAGE("scheduling asynchronous read some..."); + NETWORK_MESSAGE("normal_delegate::read_some(...)"); + NETWORK_MESSAGE("scheduling asynchronous read some..."); socket_->async_read_some(read_buffer, handler); - BOOST_NETWORK_MESSAGE("scheduled asynchronous read some..."); + NETWORK_MESSAGE("scheduled asynchronous read some..."); } -boost::network::http::normal_delegate::~normal_delegate() {} +network::http::normal_delegate::~normal_delegate() {} -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_NORMAL_DELEGATE_IPP_20110819 */ +#endif /* NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_NORMAL_DELEGATE_IPP_20110819 */ diff --git a/include/network/protocol/http/client/connection/resolver_delegate.hpp b/include/network/protocol/http/client/connection/resolver_delegate.hpp index c805a2fc1..55b973e00 100644 --- a/include/network/protocol/http/client/connection/resolver_delegate.hpp +++ b/include/network/protocol/http/client/connection/resolver_delegate.hpp @@ -1,17 +1,18 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_HPP_20111016 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_HPP_20111016 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_HPP_20111016 +#define NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_HPP_20111016 + #include #include #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { struct resolver_delegate { typedef asio::ip::udp::resolver::iterator resolver_iterator; @@ -26,10 +27,7 @@ struct resolver_delegate { virtual ~resolver_delegate() = 0; }; -} /* http */ - -} /* network */ - -} /* boost */ +} // namespace http +} // namespace network -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_HPP_20111016 */ +#endif /* NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_HPP_20111016 */ diff --git a/include/network/protocol/http/client/connection/resolver_delegate.ipp b/include/network/protocol/http/client/connection/resolver_delegate.ipp index c1512ec1c..b6646c1bf 100644 --- a/include/network/protocol/http/client/connection/resolver_delegate.ipp +++ b/include/network/protocol/http/client/connection/resolver_delegate.ipp @@ -1,23 +1,21 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_IPP_20111126 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_IPP_20111126 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_IPP_20111126 +#define NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_IPP_20111126 + #include #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { resolver_delegate::~resolver_delegate() {} } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_IPP_20111126 +#endif // NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_IPP_20111126 diff --git a/include/network/protocol/http/client/connection/resolver_delegate_factory.hpp b/include/network/protocol/http/client/connection/resolver_delegate_factory.hpp index a128eee46..2b7c3780c 100644 --- a/include/network/protocol/http/client/connection/resolver_delegate_factory.hpp +++ b/include/network/protocol/http/client/connection/resolver_delegate_factory.hpp @@ -1,17 +1,17 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_FACTORY_HPP_20110930 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_FACTORY_HPP_20110930 - // Copyright 2011 Dean Michael Berris (dberris@google.com). // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_FACTORY_HPP_20110930 +#define NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_FACTORY_HPP_20110930 + #include #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { struct resolver_delegate_factory { resolver_delegate_factory(); @@ -24,8 +24,7 @@ struct resolver_delegate_factory { resolver_delegate_factory& operator=(resolver_delegate_factory); // = delete }; -} /* http */ -} /* network */ -} /* boost */ +} // namespace http +} // namespace network -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_FACTORY_HPP_20110930 */ +#endif /* NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_FACTORY_HPP_20110930 */ diff --git a/include/network/protocol/http/client/connection/resolver_delegate_factory.ipp b/include/network/protocol/http/client/connection/resolver_delegate_factory.ipp index 87f5720d9..4cf4d9839 100644 --- a/include/network/protocol/http/client/connection/resolver_delegate_factory.ipp +++ b/include/network/protocol/http/client/connection/resolver_delegate_factory.ipp @@ -1,39 +1,37 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_FACTORY_IPP_20111126 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_FACTORY_IPP_20111126 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_FACTORY_IPP_20111126 +#define NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_FACTORY_IPP_20111126 + #include #include #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { resolver_delegate_factory::resolver_delegate_factory() { - BOOST_NETWORK_MESSAGE("resolver_delegate_factory::resolver_delegate_factory()"); + NETWORK_MESSAGE("resolver_delegate_factory::resolver_delegate_factory()"); } shared_ptr resolver_delegate_factory::create_resolver_delegate(asio::io_service & service, bool cache_resolved) { - BOOST_NETWORK_MESSAGE("resolver_delegate_factory::create_resolver_delegate(...)"); + NETWORK_MESSAGE("resolver_delegate_factory::create_resolver_delegate(...)"); shared_ptr resolver_( new (std::nothrow) async_resolver(service, cache_resolved)); return resolver_; } resolver_delegate_factory::~resolver_delegate_factory() { - BOOST_NETWORK_MESSAGE("resolver_delegate_factory::~resolver_delegate_factory()"); + NETWORK_MESSAGE("resolver_delegate_factory::~resolver_delegate_factory()"); } } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_FACTORY_IPP_20111126 +#endif // NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_RESOLVER_DELEGATE_FACTORY_IPP_20111126 diff --git a/include/network/protocol/http/client/connection/simple_connection_factory.hpp b/include/network/protocol/http/client/connection/simple_connection_factory.hpp index 1c3c02e9a..6057dfb9a 100644 --- a/include/network/protocol/http/client/connection/simple_connection_factory.hpp +++ b/include/network/protocol/http/client/connection/simple_connection_factory.hpp @@ -1,19 +1,20 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SIMPLE_CONNECTION_FACTORY_20111112 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SIMPLE_CONNECTION_FACTORY_20111112 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SIMPLE_CONNECTION_FACTORY_20111112 +#define NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SIMPLE_CONNECTION_FACTORY_20111112 + #include #include #include #include #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { struct simple_connection_factory_pimpl; @@ -31,11 +32,7 @@ struct simple_connection_factory : connection_factory { simple_connection_factory& operator=(simple_connection_factory); // = delete }; -} /* http */ - -} /* network */ +} // namespace http +} // namespace network -} /* boost */ - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SIMPLE_CONNECTION_FACTORY_20111112 */ - +#endif /* NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SIMPLE_CONNECTION_FACTORY_20111112 */ diff --git a/include/network/protocol/http/client/connection/simple_connection_factory.ipp b/include/network/protocol/http/client/connection/simple_connection_factory.ipp index c4ee55e73..04e5f3750 100644 --- a/include/network/protocol/http/client/connection/simple_connection_factory.ipp +++ b/include/network/protocol/http/client/connection/simple_connection_factory.ipp @@ -1,42 +1,43 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SIMPLE_CONNECTION_FACTORY_20111120 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SIMPLE_CONNECTION_FACTORY_20111120 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SIMPLE_CONNECTION_FACTORY_20111120 +#define NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SIMPLE_CONNECTION_FACTORY_20111120 + #include #include #include #include #include #include -#ifdef BOOST_NETWORK_DEBUG +#ifdef NETWORK_DEBUG #include #endif #include #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { struct simple_connection_factory_pimpl { simple_connection_factory_pimpl(shared_ptr conn_delegate_factory, shared_ptr res_delegate_factory) : conn_delegate_factory_(conn_delegate_factory) , res_delegate_factory_(res_delegate_factory) { - BOOST_NETWORK_MESSAGE("simple_connection_factory_pimpl::simple_connection_factory_pimpl(...)"); + NETWORK_MESSAGE("simple_connection_factory_pimpl::simple_connection_factory_pimpl(...)"); } shared_ptr create_connection( asio::io_service & service, request_base const & request, client_options const & options) { - BOOST_NETWORK_MESSAGE("simple_connection_factory_pimpl::create_connection(...)"); + NETWORK_MESSAGE("simple_connection_factory_pimpl::create_connection(...)"); ::network::uri uri_ = http::uri(request); - BOOST_NETWORK_MESSAGE("destination: " << uri_); + NETWORK_MESSAGE("destination: " << uri_); bool https = to_lower_copy(::network::scheme(uri_)) == "https"; shared_ptr conn_; conn_.reset(new (std::nothrow) http_async_connection( @@ -53,7 +54,7 @@ struct simple_connection_factory_pimpl { }; simple_connection_factory::simple_connection_factory() { - BOOST_NETWORK_MESSAGE("simple_connection_factory::simple_connection_factory()"); + NETWORK_MESSAGE("simple_connection_factory::simple_connection_factory()"); shared_ptr connection_delegate_factory_; connection_delegate_factory_.reset(new (std::nothrow) connection_delegate_factory()); shared_ptr resolver_delegate_factory_; @@ -66,26 +67,23 @@ simple_connection_factory::simple_connection_factory(shared_ptr res_delegate_factory) : pimpl(new (std::nothrow) simple_connection_factory_pimpl(conn_delegate_factory, res_delegate_factory)) { - BOOST_NETWORK_MESSAGE("simple_connection_factory::simple_connection_factory(...)"); + NETWORK_MESSAGE("simple_connection_factory::simple_connection_factory(...)"); } shared_ptr simple_connection_factory::create_connection(asio::io_service & service, request_base const & request, client_options const &options) { - BOOST_NETWORK_MESSAGE("simple_connection_factory::create_connection(...)"); + NETWORK_MESSAGE("simple_connection_factory::create_connection(...)"); return pimpl->create_connection(service, request, options); } simple_connection_factory::~simple_connection_factory() { - BOOST_NETWORK_MESSAGE("simple_connection_factory::~simple_connection_factory()"); + NETWORK_MESSAGE("simple_connection_factory::~simple_connection_factory()"); // do nothing } -} /* http */ - -} /* network */ - -} /* boost */ +} // namespace http +} // namespace network -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SIMPLE_CONNECTION_FACTORY_20111120 */ +#endif /* NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SIMPLE_CONNECTION_FACTORY_20111120 */ diff --git a/include/network/protocol/http/client/connection/ssl_delegate.hpp b/include/network/protocol/http/client/connection/ssl_delegate.hpp index 50eb354df..e04083393 100644 --- a/include/network/protocol/http/client/connection/ssl_delegate.hpp +++ b/include/network/protocol/http/client/connection/ssl_delegate.hpp @@ -1,26 +1,25 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SSL_DELEGATE_20110819 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SSL_DELEGATE_20110819 - // Copyright 2011 Dean Michael Berris (dberris@google.com). // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SSL_DELEGATE_20110819 +#define NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SSL_DELEGATE_20110819 + #include #include #include #include -namespace boost { namespace asio { - +namespace boost { +namespace asio { class io_service; - } // namespace asio - } // namespace boost -namespace boost { namespace network { namespace http { +namespace network { +namespace http { struct ssl_delegate : connection_delegate, enable_shared_from_this { ssl_delegate(asio::io_service & service, @@ -48,10 +47,8 @@ struct ssl_delegate : connection_delegate, enable_shared_from_this function handler); }; -} /* http */ - -} /* network */ - -} /* boost */ +} // namespace http +} // namespace network +} // namespace boost -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SSL_DELEGATE_20110819 */ +#endif /* NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SSL_DELEGATE_20110819 */ diff --git a/include/network/protocol/http/client/connection/ssl_delegate.ipp b/include/network/protocol/http/client/connection/ssl_delegate.ipp index 0f1811bfc..18bbce6c7 100755 --- a/include/network/protocol/http/client/connection/ssl_delegate.ipp +++ b/include/network/protocol/http/client/connection/ssl_delegate.ipp @@ -1,30 +1,30 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SSL_DELEGATE_IPP_20110819 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SSL_DELEGATE_IPP_20110819 - // Copyright 2011 Dean Michael Berris (dberris@google.com). // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SSL_DELEGATE_IPP_20110819 +#define NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SSL_DELEGATE_IPP_20110819 + #include #include #include #include #include -boost::network::http::ssl_delegate::ssl_delegate(asio::io_service & service, +network::http::ssl_delegate::ssl_delegate(asio::io_service & service, client_options const &options) : service_(service), options_(options) { - BOOST_NETWORK_MESSAGE("ssl_delegate::ssl_delegate(...)"); + NETWORK_MESSAGE("ssl_delegate::ssl_delegate(...)"); } -void boost::network::http::ssl_delegate::connect( +void network::http::ssl_delegate::connect( asio::ip::tcp::endpoint & endpoint, std::string const &host, function handler) { - BOOST_NETWORK_MESSAGE("ssl_delegate::connect(...)"); + NETWORK_MESSAGE("ssl_delegate::connect(...)"); context_.reset(new asio::ssl::context( asio::ssl::context::sslv23)); std::list const & certificate_paths = @@ -41,67 +41,67 @@ void boost::network::http::ssl_delegate::connect( it != verifier_paths.begin(); ++it) { context_->add_verify_path(*it); } - BOOST_NETWORK_MESSAGE("verifying peer: " << host); + NETWORK_MESSAGE("verifying peer: " << host); context_->set_verify_mode(asio::ssl::context::verify_peer); context_->set_verify_callback(asio::ssl::rfc2818_verification(host)); } else { - BOOST_NETWORK_MESSAGE("not verifying peer"); + NETWORK_MESSAGE("not verifying peer"); context_->set_default_verify_paths(); context_->set_verify_mode(asio::ssl::context::verify_peer); context_->set_verify_callback(asio::ssl::rfc2818_verification(host)); } socket_.reset(new asio::ssl::stream(service_, *context_)); - BOOST_NETWORK_MESSAGE("scheduling asynchronous connection..."); + NETWORK_MESSAGE("scheduling asynchronous connection..."); socket_->lowest_layer().async_connect( endpoint, - ::boost::bind(&boost::network::http::ssl_delegate::handle_connected, - boost::network::http::ssl_delegate::shared_from_this(), + ::boost::bind(&network::http::ssl_delegate::handle_connected, + network::http::ssl_delegate::shared_from_this(), asio::placeholders::error, handler)); } -void boost::network::http::ssl_delegate::handle_connected( +void network::http::ssl_delegate::handle_connected( system::error_code const & ec, function handler) { - BOOST_NETWORK_MESSAGE("ssl_delegate::handle_connected(...)"); + NETWORK_MESSAGE("ssl_delegate::handle_connected(...)"); if (!ec) { - BOOST_NETWORK_MESSAGE("connected to endpoint."); + NETWORK_MESSAGE("connected to endpoint."); // Here we check if there's an existing session for the connection. SSL_SESSION *existing_session = SSL_get1_session(socket_->impl()->ssl); if (existing_session == NULL) { - BOOST_NETWORK_MESSAGE("found no existing session, performing handshake."); + NETWORK_MESSAGE("found no existing session, performing handshake."); socket_->async_handshake(asio::ssl::stream_base::client, handler); } else { - BOOST_NETWORK_MESSAGE("found existing session, bypassing handshake."); + NETWORK_MESSAGE("found existing session, bypassing handshake."); SSL_set_session(socket_->impl()->ssl, existing_session); SSL_connect(socket_->impl()->ssl); handler(ec); } } else { - BOOST_NETWORK_MESSAGE("encountered error: " << ec); + NETWORK_MESSAGE("encountered error: " << ec); handler(ec); } } -void boost::network::http::ssl_delegate::write( +void network::http::ssl_delegate::write( asio::streambuf & command_streambuf, function handler) { - BOOST_NETWORK_MESSAGE("ssl_delegate::write(...)"); - BOOST_NETWORK_MESSAGE("scheduling asynchronous write..."); + NETWORK_MESSAGE("ssl_delegate::write(...)"); + NETWORK_MESSAGE("scheduling asynchronous write..."); asio::async_write(*socket_, command_streambuf, handler); } -void boost::network::http::ssl_delegate::read_some( +void network::http::ssl_delegate::read_some( asio::mutable_buffers_1 const & read_buffer, function handler) { - BOOST_NETWORK_MESSAGE("ssl_delegate::read_some(...)"); - BOOST_NETWORK_MESSAGE("scheduling asynchronous read_some..."); + NETWORK_MESSAGE("ssl_delegate::read_some(...)"); + NETWORK_MESSAGE("scheduling asynchronous read_some..."); socket_->async_read_some(read_buffer, handler); } -boost::network::http::ssl_delegate::~ssl_delegate() { - BOOST_NETWORK_MESSAGE("ssl_delegate::~ssl_delegate()"); +network::http::ssl_delegate::~ssl_delegate() { + NETWORK_MESSAGE("ssl_delegate::~ssl_delegate()"); } -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SSL_DELEGATE_IPP_20110819 */ +#endif /* NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SSL_DELEGATE_IPP_20110819 */ diff --git a/include/network/protocol/http/client/connection/sync_base.hpp b/include/network/protocol/http/client/connection/sync_base.hpp index 44a9609cf..9d5719c92 100644 --- a/include/network/protocol/http/client/connection/sync_base.hpp +++ b/include/network/protocol/http/client/connection/sync_base.hpp @@ -1,11 +1,11 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_IMPL_SYNC_CONNECTION_BASE_20091217 -#define BOOST_NETWORK_PROTOCOL_HTTP_IMPL_SYNC_CONNECTION_BASE_20091217 - -// Copyright Dean Michael Berris 2009. +// Copyright Dean Michael Berris 2009. // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef NETWORK_PROTOCOL_HTTP_IMPL_SYNC_CONNECTION_BASE_20091217 +#define NETWORK_PROTOCOL_HTTP_IMPL_SYNC_CONNECTION_BASE_20091217 #include #include @@ -18,11 +18,11 @@ #include #include -#ifdef BOOST_NETWORK_ENABLE_HTTPS +#ifdef NETWORK_ENABLE_HTTPS #include #endif -namespace boost { namespace network { namespace http { namespace impl { +namespace network { namespace http { namespace impl { template struct sync_connection_base_impl { @@ -220,7 +220,7 @@ namespace boost { namespace network { namespace http { namespace impl { // FIXME make the certificate filename and verify path parameters be optional ranges static sync_connection_base * new_connection(resolver_type & resolver, resolver_function_type resolve, bool https, optional const & cert_filename = optional(), optional const & verify_path = optional()) { if (https) { -#ifdef BOOST_NETWORK_ENABLE_HTTPS +#ifdef NETWORK_ENABLE_HTTPS return dynamic_cast*>(new https_sync_connection(resolver, resolve, cert_filename, verify_path)); #else throw std::runtime_error("HTTPS not supported."); @@ -241,13 +241,9 @@ namespace boost { namespace network { namespace http { namespace impl { sync_connection_base() {} }; -} // namespace impl - -} // namespace http - -} // namespace network - -} // namespace boost +} // namespace impl +} // namespace http +} // namespace network -#endif // BOOST_NETWORK_PROTOCOL_HTTP_IMPL_SYNC_CONNECTION_BASE_20091217 +#endif // NETWORK_PROTOCOL_HTTP_IMPL_SYNC_CONNECTION_BASE_20091217 diff --git a/include/network/protocol/http/client/connection/sync_normal.hpp b/include/network/protocol/http/client/connection/sync_normal.hpp index 202628534..36538aa21 100644 --- a/include/network/protocol/http/client/connection/sync_normal.hpp +++ b/include/network/protocol/http/client/connection/sync_normal.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_IMPL_HTTP_SYNC_CONNECTION_20100601 -#define BOOST_NETWORK_PROTOCOL_HTTP_IMPL_HTTP_SYNC_CONNECTION_20100601 - // Copyright 2010 (C) Dean Michael Berris // Copyright 2010 (C) Sinefunc, Inc. // Copyright 2012 Google, Inc. @@ -8,82 +5,82 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_PROTOCOL_HTTP_IMPL_HTTP_SYNC_CONNECTION_20100601 +#define NETWORK_PROTOCOL_HTTP_IMPL_HTTP_SYNC_CONNECTION_20100601 + #include #include -namespace boost { namespace network { namespace http { namespace impl { - - template - struct sync_connection_base_impl; - - template - struct sync_connection_base; - - template - struct http_sync_connection : public virtual sync_connection_base, sync_connection_base_impl { - typedef typename resolver_policy::type resolver_base; - typedef typename resolver_base::resolver_type resolver_type; - typedef typename string::type string_type; - typedef function resolver_function_type; - typedef sync_connection_base_impl connection_base; - - http_sync_connection(resolver_type & resolver, resolver_function_type resolve) - : connection_base(), resolver_(resolver), resolve_(resolve), socket_(resolver.get_io_service()) { } - - void init_socket(string_type const & hostname, string_type const & port) { - connection_base::init_socket(socket_, resolver_, hostname, port, resolve_); - } - - void send_request_impl(string_type const & method, basic_request const & request_) { - boost::asio::streambuf request_buffer; - linearize(request_, method, version_major, version_minor, - std::ostreambuf_iterator::type>(&request_buffer)); - connection_base::send_request_impl(socket_, method, request_buffer); - } - - void read_status(basic_response & response_, boost::asio::streambuf & response_buffer) { - connection_base::read_status(socket_, response_, response_buffer); - } - - void read_headers(basic_response & response, boost::asio::streambuf & response_buffer) { - connection_base::read_headers(socket_, response, response_buffer); - } - - void read_body(basic_response & response_, boost::asio::streambuf & response_buffer) { - connection_base::read_body(socket_, response_, response_buffer); - typename headers_range >::type connection_range = - headers(response_)["Connection"]; - if (version_major == 1 && version_minor == 1 && !empty(connection_range) && boost::iequals(boost::begin(connection_range)->second, "close")) { - close_socket(); - } else if (version_major == 1 && version_minor == 0) { - close_socket(); - } - } - - bool is_open() { return socket_.is_open(); } - - void close_socket() { - if (!is_open()) return; - boost::system::error_code ignored; - socket_.shutdown(boost::asio::ip::tcp::socket::shutdown_both, ignored); - if (ignored) return; - socket_.close(ignored); - } - - private: - - resolver_type & resolver_; - resolver_function_type resolve_; - boost::asio::ip::tcp::socket socket_; - - }; +namespace network { +namespace http { +namespace impl { + +template +struct sync_connection_base_impl; + +template +struct sync_connection_base; + +template +struct http_sync_connection : public virtual sync_connection_base, sync_connection_base_impl { + typedef typename resolver_policy::type resolver_base; + typedef typename resolver_base::resolver_type resolver_type; + typedef typename string::type string_type; + typedef function resolver_function_type; + typedef sync_connection_base_impl connection_base; + + http_sync_connection(resolver_type & resolver, resolver_function_type resolve) + : connection_base(), resolver_(resolver), resolve_(resolve), socket_(resolver.get_io_service()) { } + + void init_socket(string_type const & hostname, string_type const & port) { + connection_base::init_socket(socket_, resolver_, hostname, port, resolve_); + } + + void send_request_impl(string_type const & method, basic_request const & request_) { + boost::asio::streambuf request_buffer; + linearize(request_, method, version_major, version_minor, + std::ostreambuf_iterator::type>(&request_buffer)); + connection_base::send_request_impl(socket_, method, request_buffer); + } + + void read_status(basic_response & response_, boost::asio::streambuf & response_buffer) { + connection_base::read_status(socket_, response_, response_buffer); + } + + void read_headers(basic_response & response, boost::asio::streambuf & response_buffer) { + connection_base::read_headers(socket_, response, response_buffer); + } + + void read_body(basic_response & response_, boost::asio::streambuf & response_buffer) { + connection_base::read_body(socket_, response_, response_buffer); + typename headers_range >::type connection_range = + headers(response_)["Connection"]; + if (version_major == 1 && version_minor == 1 && !empty(connection_range) && boost::iequals(boost::begin(connection_range)->second, "close")) { + close_socket(); + } else if (version_major == 1 && version_minor == 0) { + close_socket(); + } + } + + bool is_open() { return socket_.is_open(); } + + void close_socket() { + if (!is_open()) return; + boost::system::error_code ignored; + socket_.shutdown(boost::asio::ip::tcp::socket::shutdown_both, ignored); + if (ignored) return; + socket_.close(ignored); + } + + private: + + resolver_type & resolver_; + resolver_function_type resolve_; + boost::asio::ip::tcp::socket socket_; +}; } // namespace impl - } // nmaespace http - } // namespace network -} // nmaespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_IMPL_HTTP_SYNC_CONNECTION_20100 +#endif // NETWORK_PROTOCOL_HTTP_IMPL_HTTP_SYNC_CONNECTION_20100 diff --git a/include/network/protocol/http/client/connection/sync_ssl.hpp b/include/network/protocol/http/client/connection/sync_ssl.hpp index 2a8514d75..f263281e7 100644 --- a/include/network/protocol/http/client/connection/sync_ssl.hpp +++ b/include/network/protocol/http/client/connection/sync_ssl.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_IMPL_HTTPS_SYNC_CONNECTION_HTTP_20100601 -#define BOOST_NETWORK_PROTOCOL_HTTP_IMPL_HTTPS_SYNC_CONNECTION_HTTP_20100601 - // Copyright 2010 (C) Dean Michael Berris // Copyright 2010 (C) Sinefunc, Inc. // Copyright 2012 Google, Inc. @@ -8,97 +5,102 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_PROTOCOL_HTTP_IMPL_HTTPS_SYNC_CONNECTION_HTTP_20100601 +#define NETWORK_PROTOCOL_HTTP_IMPL_HTTPS_SYNC_CONNECTION_HTTP_20100601 + #include -namespace boost { namespace network { namespace http { namespace impl { - - template - struct sync_connection_base_impl; - - template - struct sync_connection_base; - - template - struct https_sync_connection : public virtual sync_connection_base, sync_connection_base_impl { - typedef typename resolver_policy::type resolver_base; - typedef typename resolver_base::resolver_type resolver_type; - typedef typename string::type string_type; - typedef function resolver_function_type; - typedef sync_connection_base_impl connection_base; - - // FIXME make the certificate filename and verify path parameters be optional ranges - https_sync_connection(resolver_type & resolver, resolver_function_type resolve, optional const & certificate_filename = optional(), optional const & verify_path = optional()) - : connection_base(), resolver_(resolver), resolve_(resolve), context_(resolver.get_io_service(), boost::asio::ssl::context::sslv23_client), socket_(resolver.get_io_service(), context_) { - if (certificate_filename || verify_path) { - context_.set_verify_mode(boost::asio::ssl::context::verify_peer); - // FIXME make the certificate filename and verify path parameters be optional ranges - if (certificate_filename) context_.load_verify_file(*certificate_filename); - if (verify_path) context_.add_verify_path(*verify_path); - } else { - context_.set_verify_mode(boost::asio::ssl::context::verify_none); - } - } - - void init_socket(string_type const & hostname, string_type const & port) { - connection_base::init_socket(socket_.lowest_layer(), resolver_, hostname, port, resolve_); - socket_.handshake(boost::asio::ssl::stream_base::client); - } - - void send_request_impl(string_type const & method, basic_request const & request_) { - boost::asio::streambuf request_buffer; - linearize(request_, method, version_major, version_minor, - std::ostreambuf_iterator::type>(&request_buffer)); - connection_base::send_request_impl(socket_, method, request_buffer); - } - - void read_status(basic_response & response_, boost::asio::streambuf & response_buffer) { - connection_base::read_status(socket_, response_, response_buffer); - } - - void read_headers(basic_response & response_, boost::asio::streambuf & response_buffer) { - connection_base::read_headers(socket_, response_, response_buffer); - } - - void read_body(basic_response & response_, boost::asio::streambuf & response_buffer) { - connection_base::read_body(socket_, response_, response_buffer); - typename headers_range >::type connection_range = - headers(response_)["Connection"]; - if (version_major == 1 && version_minor == 1 && !empty(connection_range) && boost::iequals(boost::begin(connection_range)->second, "close")) { - close_socket(); - } else if (version_major == 1 && version_minor == 0) { - close_socket(); - } - } - - bool is_open() { - return socket_.lowest_layer().is_open(); - } - - void close_socket() { - boost::system::error_code ignored; - socket_.lowest_layer().shutdown(boost::asio::ip::tcp::socket::shutdown_both, ignored); - if (ignored) return; - socket_.lowest_layer().close(ignored); - } - - ~https_sync_connection() { - close_socket(); - } - - private: - resolver_type & resolver_; - resolver_function_type resolve_; - boost::asio::ssl::context context_; - boost::asio::ssl::stream socket_; - - }; +namespace network { +namespace http { +namespace impl { + +template +struct sync_connection_base_impl; + +template +struct sync_connection_base; + +template +struct https_sync_connection : public virtual sync_connection_base, sync_connection_base_impl { + typedef typename resolver_policy::type resolver_base; + typedef typename resolver_base::resolver_type resolver_type; + typedef typename string::type string_type; + typedef function resolver_function_type; + typedef sync_connection_base_impl connection_base; + + // FIXME make the certificate filename and verify path parameters be optional ranges + https_sync_connection(resolver_type & resolver, resolver_function_type resolve, optional const & certificate_filename = optional(), optional const & verify_path = optional()) + : connection_base(), + resolver_(resolver), + resolve_(resolve), + context_(resolver.get_io_service(), boost::asio::ssl::context::sslv23_client), + socket_(resolver.get_io_service(), context_) { + if (certificate_filename || verify_path) { + context_.set_verify_mode(boost::asio::ssl::context::verify_peer); + // FIXME make the certificate filename and verify path parameters be optional ranges + if (certificate_filename) context_.load_verify_file(*certificate_filename); + if (verify_path) context_.add_verify_path(*verify_path); + } else { + context_.set_verify_mode(boost::asio::ssl::context::verify_none); + } + } + + void init_socket(string_type const & hostname, string_type const & port) { + connection_base::init_socket(socket_.lowest_layer(), resolver_, hostname, port, resolve_); + socket_.handshake(boost::asio::ssl::stream_base::client); + } + + void send_request_impl(string_type const & method, basic_request const & request_) { + boost::asio::streambuf request_buffer; + linearize(request_, method, version_major, version_minor, + std::ostreambuf_iterator::type>(&request_buffer)); + connection_base::send_request_impl(socket_, method, request_buffer); + } + + void read_status(basic_response & response_, boost::asio::streambuf & response_buffer) { + connection_base::read_status(socket_, response_, response_buffer); + } + + void read_headers(basic_response & response_, boost::asio::streambuf & response_buffer) { + connection_base::read_headers(socket_, response_, response_buffer); + } + + void read_body(basic_response & response_, boost::asio::streambuf & response_buffer) { + connection_base::read_body(socket_, response_, response_buffer); + typename headers_range >::type connection_range = + headers(response_)["Connection"]; + if (version_major == 1 && version_minor == 1 && !empty(connection_range) && boost::iequals(boost::begin(connection_range)->second, "close")) { + close_socket(); + } else if (version_major == 1 && version_minor == 0) { + close_socket(); + } + } + + bool is_open() { + return socket_.lowest_layer().is_open(); + } + + void close_socket() { + boost::system::error_code ignored; + socket_.lowest_layer().shutdown(boost::asio::ip::tcp::socket::shutdown_both, ignored); + if (ignored) return; + socket_.lowest_layer().close(ignored); + } + + ~https_sync_connection() { + close_socket(); + } + + private: + resolver_type & resolver_; + resolver_function_type resolve_; + boost::asio::ssl::context context_; + boost::asio::ssl::stream socket_; + +}; } // namespace impl - } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_IMPL_HTTPS_SYNC_CONNECTION_HTTP_20100601 +#endif // NETWORK_PROTOCOL_HTTP_IMPL_HTTPS_SYNC_CONNECTION_HTTP_20100601 diff --git a/include/network/protocol/http/client/connection_manager.hpp b/include/network/protocol/http/client/connection_manager.hpp index 5f424ea56..ed8552fff 100644 --- a/include/network/protocol/http/client/connection_manager.hpp +++ b/include/network/protocol/http/client/connection_manager.hpp @@ -1,12 +1,12 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_MANAGER_HPP_20110930 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_MANAGER_HPP_20110930 - // Copyright 2011 Dean Michael Berris (dberris@google.com). // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_MANAGER_HPP_20110930 +#define NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_MANAGER_HPP_20110930 + #include namespace boost { namespace asio { @@ -17,7 +17,8 @@ class io_service; } // namespace boost -namespace boost { namespace network { namespace http { +namespace network { +namespace http { struct client_connection; struct request_base; @@ -33,14 +34,7 @@ struct connection_manager { virtual ~connection_manager() = 0; }; -} /* http */ - -} /* network */ - -} /* boost */ - -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif +} // namespace http +} // namespace network -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_MANAGER_HPP_20110930 */ +#endif /* NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_MANAGER_HPP_20110930 */ diff --git a/include/network/protocol/http/client/connection_manager.ipp b/include/network/protocol/http/client/connection_manager.ipp index 79871615b..e9e773d1f 100644 --- a/include/network/protocol/http/client/connection_manager.ipp +++ b/include/network/protocol/http/client/connection_manager.ipp @@ -1,24 +1,23 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_MANAGER_IPP_20111103 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_MANAGER_IPP_20111103 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_MANAGER_IPP_20111103 +#define NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_MANAGER_IPP_20111103 + #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { connection_manager::~connection_manager() { - BOOST_NETWORK_MESSAGE("connection_manager::~connection_manager()"); + NETWORK_MESSAGE("connection_manager::~connection_manager()"); // default implementation, for linkage only. } -} /* http */ -} /* network */ -} /* boost */ +} // namespace http +} // namespace network -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_MANAGER_IPP_20111103 */ +#endif /* NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_MANAGER_IPP_20111103 */ diff --git a/include/network/protocol/http/client/facade.hpp b/include/network/protocol/http/client/facade.hpp index 0197032fb..c6220d442 100644 --- a/include/network/protocol/http/client/facade.hpp +++ b/include/network/protocol/http/client/facade.hpp @@ -1,18 +1,19 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_FACADE_HPP_20100623 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_FACADE_HPP_20100623 - // Copyright Dean Michael Berris 2010. // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_FACADE_HPP_20100623 +#define NETWORK_PROTOCOL_HTTP_CLIENT_FACADE_HPP_20100623 + #include #include #include #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { struct basic_client_facade { typedef client_base::body_callback_function_type body_callback_function_type; @@ -45,9 +46,6 @@ struct basic_client_facade { }; } // namespace http +} // namespace network -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_FACADE_HPP_20100623 +#endif // NETWORK_PROTOCOL_HTTP_CLIENT_FACADE_HPP_20100623 diff --git a/include/network/protocol/http/client/facade.ipp b/include/network/protocol/http/client/facade.ipp index 72fd44c31..a113c10bf 100644 --- a/include/network/protocol/http/client/facade.ipp +++ b/include/network/protocol/http/client/facade.ipp @@ -1,24 +1,31 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_FACADE_IPP_20120303 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_FACADE_IPP_20120303 +// Copyright Dean Michael Berris 2012. +// Copyright 2012 Google, Inc. +// 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 NETWORK_PROTOCOL_HTTP_CLIENT_FACADE_IPP_20120303 +#define NETWORK_PROTOCOL_HTTP_CLIENT_FACADE_IPP_20120303 #include #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { basic_client_facade::basic_client_facade() : base(new (std::nothrow) client_base()) { - BOOST_NETWORK_MESSAGE("basic_client_facade::basic_client_facade()"); + NETWORK_MESSAGE("basic_client_facade::basic_client_facade()"); } basic_client_facade::basic_client_facade(client_options const &options) : base(new (std::nothrow) client_base(options)) { - BOOST_NETWORK_MESSAGE("basic_client_facade::basic_client_facade(client_options const &)"); + NETWORK_MESSAGE("basic_client_facade::basic_client_facade(client_options const &)"); } response const basic_client_facade::head(request const &request, request_options const&options) { - BOOST_NETWORK_MESSAGE("basic_client_facade::head(...)"); + NETWORK_MESSAGE("basic_client_facade::head(...)"); return base->request_skeleton(request, "HEAD", false, @@ -29,7 +36,7 @@ response const basic_client_facade::head(request const &request, response const basic_client_facade::get(request const &request, body_callback_function_type body_handler, request_options const &options) { - BOOST_NETWORK_MESSAGE("basic_client_facade::get(...)"); + NETWORK_MESSAGE("basic_client_facade::get(...)"); return base->request_skeleton(request, "GET", true, body_handler, options); } @@ -38,9 +45,9 @@ response const basic_client_facade::post(request request, optional content_type, body_callback_function_type body_handler, request_options const &options) { - BOOST_NETWORK_MESSAGE("basic_client_facade::post(...)"); + NETWORK_MESSAGE("basic_client_facade::post(...)"); if (body) { - BOOST_NETWORK_MESSAGE("using body provided."); + NETWORK_MESSAGE("using body provided."); request << remove_header("Content-Length") << header("Content-Length", boost::lexical_cast(body->size())) << boost::network::body(*body); @@ -49,11 +56,11 @@ response const basic_client_facade::post(request request, headers_wrapper::container_type const & headers_ = headers(request); if (content_type) { - BOOST_NETWORK_MESSAGE("using provided content type."); + NETWORK_MESSAGE("using provided content type."); request << remove_header("Content-Type") << header("Content-Type", *content_type); } else { - BOOST_NETWORK_MESSAGE("using default content type."); + NETWORK_MESSAGE("using default content type."); if (boost::empty(headers_.equal_range("Content-Type"))) { static char default_content_type[] = "x-application/octet-stream"; request << header("Content-Type", default_content_type); @@ -67,9 +74,9 @@ response const basic_client_facade::put(request request, optional content_type, body_callback_function_type body_handler, request_options const & options) { - BOOST_NETWORK_MESSAGE("basic_client_facade::put(...)"); + NETWORK_MESSAGE("basic_client_facade::put(...)"); if (body) { - BOOST_NETWORK_MESSAGE("using body provided."); + NETWORK_MESSAGE("using body provided."); request << remove_header("Content-Length") << header("Content-Length", boost::lexical_cast(body->size())) << boost::network::body(*body); @@ -78,11 +85,11 @@ response const basic_client_facade::put(request request, headers_wrapper::container_type const & headers_ = headers(request); if (content_type) { - BOOST_NETWORK_MESSAGE("using provided content type."); + NETWORK_MESSAGE("using provided content type."); request << remove_header("Content-Type") << header("Content-Type", *content_type); } else { - BOOST_NETWORK_MESSAGE("using default content type."); + NETWORK_MESSAGE("using default content type."); if (boost::empty(headers_.equal_range("Content-Type"))) { static char default_content_type[] = "x-application/octet-stream"; request << header("Content-Type", default_content_type); @@ -94,21 +101,17 @@ response const basic_client_facade::put(request request, response const basic_client_facade::delete_(request const & request, body_callback_function_type body_handler, request_options const & options) { - BOOST_NETWORK_MESSAGE("basic_client_facade::delete_(...)"); + NETWORK_MESSAGE("basic_client_facade::delete_(...)"); return base->request_skeleton(request, "DELETE", true, body_handler, options); } void basic_client_facade::clear_resolved_cache() { - BOOST_NETWORK_MESSAGE("basic_client_facade::clear_resolved_cache()"); + NETWORK_MESSAGE("basic_client_facade::clear_resolved_cache()"); base->clear_resolved_cache(); } } // namespace http - } // namespace network -} // namespace boost - - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_FACADE_IPP_20120303 +#endif // NETWORK_PROTOCOL_HTTP_CLIENT_FACADE_IPP_20120303 diff --git a/include/network/protocol/http/client/macros.hpp b/include/network/protocol/http/client/macros.hpp index b6524e4f7..beee2a827 100644 --- a/include/network/protocol/http/client/macros.hpp +++ b/include/network/protocol/http/client/macros.hpp @@ -1,19 +1,19 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_MACROS_HPP_20110430 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_MACROS_HPP_20110430 - // Copyright 2011 Dean Michael Berris . // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_MACROS_HPP_20110430 +#define NETWORK_PROTOCOL_HTTP_CLIENT_MACROS_HPP_20110430 + #include #include -#ifndef BOOST_NETWORK_HTTP_BODY_CALLBACK -#define BOOST_NETWORK_HTTP_BODY_CALLBACK(function_name, range_name, error_name) \ +#ifndef NETWORK_HTTP_BODY_CALLBACK +#define NETWORK_HTTP_BODY_CALLBACK(function_name, range_name, error_name) \ void function_name (boost::iterator_range const & range_name, boost::system::error_code const & error_name) #endif -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_MACROS_HPP_20110430 */ +#endif /* NETWORK_PROTOCOL_HTTP_CLIENT_MACROS_HPP_20110430 */ diff --git a/include/network/protocol/http/client/options.hpp b/include/network/protocol/http/client/options.hpp index c0e9b4aa8..724debbc6 100644 --- a/include/network/protocol/http/client/options.hpp +++ b/include/network/protocol/http/client/options.hpp @@ -4,8 +4,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_OPTIONS_HPP -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_OPTIONS_HPP +#ifndef NETWORK_PROTOCOL_HTTP_CLIENT_OPTIONS_HPP +#define NETWORK_PROTOCOL_HTTP_CLIENT_OPTIONS_HPP #include #include @@ -15,7 +15,8 @@ #include #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { // Forward-declare the pimpl. class client_options_pimpl; @@ -143,6 +144,5 @@ namespace boost { namespace network { namespace http { } // namespace http } // namespace network -} // namespace boost -#endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_OPTIONS_HPP +#endif // NETWORK_PROTOCOL_HTTP_CLIENT_OPTIONS_HPP diff --git a/include/network/protocol/http/client/options.ipp b/include/network/protocol/http/client/options.ipp index 0b9c4850b..dfb4fa139 100644 --- a/include/network/protocol/http/client/options.ipp +++ b/include/network/protocol/http/client/options.ipp @@ -4,14 +4,15 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_OPTIONS_IPP -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_OPTIONS_IPP +#ifndef NETWORK_PROTOCOL_HTTP_CLIENT_OPTIONS_IPP +#define NETWORK_PROTOCOL_HTTP_CLIENT_OPTIONS_IPP #include #include #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { class client_options_pimpl { public: @@ -274,7 +275,5 @@ int request_options::max_redirects() const { } // namespace http } // namespace network -} // namespace boost - #endif diff --git a/include/network/protocol/http/client/parameters.hpp b/include/network/protocol/http/client/parameters.hpp index 618636b3e..ee178826b 100644 --- a/include/network/protocol/http/client/parameters.hpp +++ b/include/network/protocol/http/client/parameters.hpp @@ -1,31 +1,30 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_PARAMETERS_HPP_2010127 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_PARAMETERS_HPP_2010127 - // Copyright 2010 Dean Michael Berris. // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_PARAMETERS_HPP_2010127 +#define NETWORK_PROTOCOL_HTTP_CLIENT_PARAMETERS_HPP_2010127 + #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { - BOOST_PARAMETER_NAME(follow_redirects) - BOOST_PARAMETER_NAME(cache_resolved) - BOOST_PARAMETER_NAME(openssl_certificate) - BOOST_PARAMETER_NAME(openssl_verify_path) + PARAMETER_NAME(follow_redirects) + PARAMETER_NAME(cache_resolved) + PARAMETER_NAME(openssl_certificate) + PARAMETER_NAME(openssl_verify_path) - BOOST_PARAMETER_NAME(request) - BOOST_PARAMETER_NAME(body) - BOOST_PARAMETER_NAME(content_type) - BOOST_PARAMETER_NAME(body_handler) + PARAMETER_NAME(request) + PARAMETER_NAME(body) + PARAMETER_NAME(content_type) + PARAMETER_NAME(body_handler) - BOOST_PARAMETER_NAME(connection_manager) - BOOST_PARAMETER_NAME(connection_factory) + PARAMETER_NAME(connection_manager) + PARAMETER_NAME(connection_factory) -} /* http */ -} /* network */ -} /* boost */ +} // namespace http +} // namespace network -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_PARAMETERS_HPP_2010127 */ +#endif /* NETWORK_PROTOCOL_HTTP_CLIENT_PARAMETERS_HPP_2010127 */ diff --git a/include/network/protocol/http/client/pimpl.hpp b/include/network/protocol/http/client/pimpl.hpp index c888016f4..624e07698 100644 --- a/include/network/protocol/http/client/pimpl.hpp +++ b/include/network/protocol/http/client/pimpl.hpp @@ -1,12 +1,12 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_PIMPL_HPP_20100623 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_PIMPL_HPP_20100623 - // Copyright Dean Michael Berris 2010. // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_PIMPL_HPP_20100623 +#define NETWORK_PROTOCOL_HTTP_CLIENT_PIMPL_HPP_20100623 + #include #include #include @@ -15,72 +15,71 @@ #include #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { - template - struct basic_client_impl; - - namespace impl { - - template - struct async_client; - - template - struct sync_client; - - - template - struct client_base { - typedef unsupported_tag type; - }; - - template - struct client_base >::type> { - typedef async_client type; - }; - - template - struct client_base >::type> { - typedef sync_client type; - }; - - } // namespace impl +template +struct basic_client_impl; - template - struct basic_client; +namespace impl { template - struct basic_client_impl - : impl::client_base::type - { - BOOST_STATIC_ASSERT(( - mpl::not_< - mpl::and_< - is_async, - is_sync - > - >::value - )); - - typedef typename impl::client_base::type base_type; - typedef typename base_type::string_type string_type; - - basic_client_impl(bool cache_resolved, bool follow_redirect, optional const & certificate_filename, optional const & verify_path) - : base_type(cache_resolved, follow_redirect, certificate_filename, verify_path) - {} - - basic_client_impl(bool cache_resolved, bool follow_redirect, boost::asio::io_service & service, optional const & certificate_filename, optional const & verify_path) - : base_type(cache_resolved, follow_redirect, service, certificate_filename, verify_path) - {} - - ~basic_client_impl() - {} + struct async_client; + + template + struct sync_client; + + + template + struct client_base { + typedef unsupported_tag type; + }; + + template + struct client_base >::type> { + typedef async_client type; + }; + + template + struct client_base >::type> { + typedef sync_client type; }; +} // namespace impl + +template +struct basic_client; + +template +struct basic_client_impl + : impl::client_base::type +{ + STATIC_ASSERT(( + mpl::not_< + mpl::and_< + is_async, + is_sync + > + >::value + )); + + typedef typename impl::client_base::type base_type; + typedef typename base_type::string_type string_type; + + basic_client_impl(bool cache_resolved, bool follow_redirect, optional const & certificate_filename, optional const & verify_path) + : base_type(cache_resolved, follow_redirect, certificate_filename, verify_path) + {} + + basic_client_impl(bool cache_resolved, bool follow_redirect, boost::asio::io_service & service, optional const & certificate_filename, optional const & verify_path) + : base_type(cache_resolved, follow_redirect, service, certificate_filename, verify_path) + {} + + ~basic_client_impl() + {} +}; + } // namespace http } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_PIMPL_HPP_20100623 +#endif // NETWORK_PROTOCOL_HTTP_CLIENT_PIMPL_HPP_20100623 diff --git a/include/network/protocol/http/client/simple_connection_manager.hpp b/include/network/protocol/http/client/simple_connection_manager.hpp index 5ba71d425..e264fa288 100644 --- a/include/network/protocol/http/client/simple_connection_manager.hpp +++ b/include/network/protocol/http/client/simple_connection_manager.hpp @@ -1,17 +1,18 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_SIMPLE_CONNECTION_MANAGER_HPP_20111105 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_SIMPLE_CONNECTION_MANAGER_HPP_20111105 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_SIMPLE_CONNECTION_MANAGER_HPP_20111105 +#define NETWORK_PROTOCOL_HTTP_CLIENT_SIMPLE_CONNECTION_MANAGER_HPP_20111105 + #include #include #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { /// Forward declaration of simple_connection_manager_pimpl. struct simple_connection_manager_pimpl; @@ -81,10 +82,7 @@ struct simple_connection_manager : connection_manager { simple_connection_manager & operator=(simple_connection_manager); // = delete }; -} /* http */ - -} /* network */ - -} /* boost */ +} // namespace http +} // namespace network -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_SIMPLE_CONNECTION_MANAGER_HPP_20111105 */ +#endif /* NETWORK_PROTOCOL_HTTP_CLIENT_SIMPLE_CONNECTION_MANAGER_HPP_20111105 */ diff --git a/include/network/protocol/http/client/simple_connection_manager.ipp b/include/network/protocol/http/client/simple_connection_manager.ipp index e86574c08..a6e6a6a26 100644 --- a/include/network/protocol/http/client/simple_connection_manager.ipp +++ b/include/network/protocol/http/client/simple_connection_manager.ipp @@ -1,29 +1,29 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_SIMPLE_CONNECTION_MANAGER_IPP_20111112 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_SIMPLE_CONNECTION_MANAGER_IPP_20111112 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_CLIENT_SIMPLE_CONNECTION_MANAGER_IPP_20111112 +#define NETWORK_PROTOCOL_HTTP_CLIENT_SIMPLE_CONNECTION_MANAGER_IPP_20111112 + #include #include #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { struct simple_connection_manager_pimpl { simple_connection_manager_pimpl(client_options const &options) : options_(options) , connection_factory_(options.connection_factory()) { - BOOST_NETWORK_MESSAGE( + NETWORK_MESSAGE( "simple_connection_manager_pimpl::simple_connection_manager_pimpl(" "client_options const &)"); if (!connection_factory_.get()) { - BOOST_NETWORK_MESSAGE("creating simple connection factory"); + NETWORK_MESSAGE("creating simple connection factory"); connection_factory_.reset( new (std::nothrow) simple_connection_factory()); } @@ -32,7 +32,7 @@ struct simple_connection_manager_pimpl { shared_ptr get_connection(asio::io_service & service, request_base const & request, client_options const &options) { - BOOST_NETWORK_MESSAGE("simple_connection_manager_pimpl::get_connection(...)"); + NETWORK_MESSAGE("simple_connection_manager_pimpl::get_connection(...)"); return connection_factory_->create_connection(service, request, options_); } @@ -45,7 +45,7 @@ struct simple_connection_manager_pimpl { } ~simple_connection_manager_pimpl() { - BOOST_NETWORK_MESSAGE("simple_connection_manager_pimpl::~simple_connection_manager_pimpl()"); + NETWORK_MESSAGE("simple_connection_manager_pimpl::~simple_connection_manager_pimpl()"); // do nothing here. } @@ -57,7 +57,7 @@ private: simple_connection_manager::simple_connection_manager(client_options const &options) : pimpl(new (std::nothrow) simple_connection_manager_pimpl(options)) { - BOOST_NETWORK_MESSAGE("simple_connection_manager::simple_connection_manager(" + NETWORK_MESSAGE("simple_connection_manager::simple_connection_manager(" "client_options const &)"); } @@ -65,29 +65,26 @@ shared_ptr simple_connection_manager::get_connection( asio::io_service & service, request_base const & request, client_options const &options) { - BOOST_NETWORK_MESSAGE("simple_connection_manager::get_connection(...)"); + NETWORK_MESSAGE("simple_connection_manager::get_connection(...)"); return pimpl->get_connection(service, request, options); } void simple_connection_manager::reset() { - BOOST_NETWORK_MESSAGE("simple_connection_manager::reset()"); + NETWORK_MESSAGE("simple_connection_manager::reset()"); pimpl->reset(); } void simple_connection_manager::clear_resolved_cache() { - BOOST_NETWORK_MESSAGE("simple_connection_manager::clear_resolved_cache()"); + NETWORK_MESSAGE("simple_connection_manager::clear_resolved_cache()"); pimpl->clear_resolved_cache(); } simple_connection_manager::~simple_connection_manager() { - BOOST_NETWORK_MESSAGE("simple_connection_manager::~simple_connection_manager()"); + NETWORK_MESSAGE("simple_connection_manager::~simple_connection_manager()"); // do nothing here. } -} /* http */ - -} /* network */ - -} /* boost */ +} // namespace http +} // namespace network -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_SIMPLE_CONNECTION_MANAGER_IPP_20111112 */ +#endif /* NETWORK_PROTOCOL_HTTP_CLIENT_SIMPLE_CONNECTION_MANAGER_IPP_20111112 */ diff --git a/include/network/protocol/http/client/sync_impl.hpp b/include/network/protocol/http/client/sync_impl.hpp index dc677219a..d95122e88 100644 --- a/include/network/protocol/http/client/sync_impl.hpp +++ b/include/network/protocol/http/client/sync_impl.hpp @@ -1,76 +1,74 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_SYNC_IMPL_HPP_20100623 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_SYNC_IMPL_HPP_20100623 - // Copyright Dean Michael Berris 2010. // Copyright 2012 Google, Inc. // 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) -namespace boost { namespace network { namespace http { +#ifndef NETWORK_PROTOCOL_HTTP_CLIENT_SYNC_IMPL_HPP_20100623 +#define NETWORK_PROTOCOL_HTTP_CLIENT_SYNC_IMPL_HPP_20100623 - template - struct basic_client_impl; +namespace network { namespace http { - namespace impl { - template - struct sync_client : - connection_policy::type - { - typedef typename string::type string_type; - typedef typename connection_policy::type connection_base; - typedef typename resolver::type resolver_type; - typedef function const &, system::error_code const &)> body_callback_function_type; - friend struct basic_client_impl; +template +struct basic_client_impl; - boost::asio::io_service * service_ptr; - boost::asio::io_service & service_; - resolver_type resolver_; - optional certificate_file, verify_path; +namespace impl { - sync_client(bool cache_resolved, bool follow_redirect - , optional const & certificate_file = optional() - , optional const & verify_path = optional() - ) - : connection_base(cache_resolved, follow_redirect), - service_ptr(new boost::asio::io_service), - service_(*service_ptr), - resolver_(service_) - , certificate_file(certificate_file) - , verify_path(verify_path) - {} +template +struct sync_client : + connection_policy::type +{ + typedef typename string::type string_type; + typedef typename connection_policy::type connection_base; + typedef typename resolver::type resolver_type; + typedef function const &, system::error_code const &)> body_callback_function_type; + friend struct basic_client_impl; - sync_client(bool cache_resolved, bool follow_redirect, boost::asio::io_service & service - , optional const & certificate_file = optional() - , optional const & verify_path = optional() - ) - : connection_base(cache_resolved, follow_redirect), - service_ptr(0), - service_(service), - resolver_(service_) - , certificate_file(certificate_file) - , verify_path(verify_path) - {} + boost::asio::io_service * service_ptr; + boost::asio::io_service & service_; + resolver_type resolver_; + optional certificate_file, verify_path; - ~sync_client() { - connection_base::cleanup(); - delete service_ptr; - } + sync_client(bool cache_resolved, bool follow_redirect + , optional const & certificate_file = optional() + , optional const & verify_path = optional() + ) + : connection_base(cache_resolved, follow_redirect), + service_ptr(new boost::asio::io_service), + service_(*service_ptr), + resolver_(service_) + , certificate_file(certificate_file) + , verify_path(verify_path) + {} - basic_response const request_skeleton(basic_request const & request_, string_type method, bool get_body, body_callback_function_type callback) { - typename connection_base::connection_ptr connection_; - connection_ = connection_base::get_connection(resolver_, request_, certificate_file, verify_path); - return connection_->send_request(method, request_, get_body, callback); - } + sync_client(bool cache_resolved, bool follow_redirect, boost::asio::io_service & service + , optional const & certificate_file = optional() + , optional const & verify_path = optional() + ) + : connection_base(cache_resolved, follow_redirect), + service_ptr(0), + service_(service), + resolver_(service_) + , certificate_file(certificate_file) + , verify_path(verify_path) + {} - }; - - } // namespace impl + ~sync_client() { + connection_base::cleanup(); + delete service_ptr; + } -} // namespace http + basic_response const request_skeleton(basic_request const & request_, string_type method, bool get_body, body_callback_function_type callback) { + typename connection_base::connection_ptr connection_; + connection_ = connection_base::get_connection(resolver_, request_, certificate_file, verify_path); + return connection_->send_request(method, request_, get_body, callback); + } -} // namespace network + }; + +} // namespace impl -} // namespace boost +} // namespace http +} // namespace network -#endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_SYNC_IMPL_HPP_20100623 +#endif // NETWORK_PROTOCOL_HTTP_CLIENT_SYNC_IMPL_HPP_20100623 diff --git a/include/network/protocol/http/client_fwd.hpp b/include/network/protocol/http/client_fwd.hpp index acdef99dd..2c8379c60 100644 --- a/include/network/protocol/http/client_fwd.hpp +++ b/include/network/protocol/http/client_fwd.hpp @@ -1,29 +1,25 @@ - -// Copyright Dean Michael Berris 2007-2008. +// Copyright Dean Michael Berris 2007-2008. // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) -#ifndef __NETWORK_PROTOCOL_HTTP_CLIENT_20080923_1_HPP__ -#define __NETWORK_PROTOCOL_HTTP_CLIENT_20080923_1_HPP__ +#ifndef NETWORK_PROTOCOL_HTTP_CLIENT_20080923_1_HPP +#define NETWORK_PROTOCOL_HTTP_CLIENT_20080923_1_HPP #include #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { -//! Forward declaration of basic_client template. +// Forward declaration of basic_client template. template class basic_client; typedef basic_client client; } // namespace http - } // namespace network -} // namespace boost - -#endif // __NETWORK_PROTOCOL_HTTP_CLIENT_20080923_1_HPP__ - +#endif // NETWORK_PROTOCOL_HTTP_CLIENT_20080923_1_HPP diff --git a/include/network/protocol/http/errors.hpp b/include/network/protocol/http/errors.hpp index fd1d83094..7935939e5 100644 --- a/include/network/protocol/http/errors.hpp +++ b/include/network/protocol/http/errors.hpp @@ -1,16 +1,17 @@ - -// Copyright Dean Michael Berris 2007, 2008. +// Copyright Dean Michael Berris 2007, 2008. // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) -#ifndef __NETWORK_PROTOCOL_HTTP_ERRORS_20080516_HPP__ -#define __NETWORK_PROTOCOL_HTTP_ERRORS_20080516_HPP__ +#ifndef NETWORK_PROTOCOL_HTTP_ERRORS_20080516_HPP +#define NETWORK_PROTOCOL_HTTP_ERRORS_20080516_HPP #include -namespace boost { namespace network { namespace http { namespace errors { +namespace network { +namespace http { +namespace errors { struct connection_timeout_exception : std::runtime_error {}; @@ -18,12 +19,8 @@ struct connection_timeout_exception : std::runtime_error typedef connection_timeout_exception connection_timeout; } // namespace errors - } // namespace http - } // namespace network -} // namespace boost - -#endif // __NETWORK_PROTOCOL_HTTP_20080516_HPP__ +#endif // NETWORK_PROTOCOL_HTTP_20080516_HPP diff --git a/include/network/protocol/http/impl/access.hpp b/include/network/protocol/http/impl/access.hpp index 402214f6a..373683ed8 100644 --- a/include/network/protocol/http/impl/access.hpp +++ b/include/network/protocol/http/impl/access.hpp @@ -1,15 +1,16 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_IMPL_ACCESS_HPP_20111202 -#define BOOST_NETWORK_PROTOCOL_HTTP_IMPL_ACCESS_HPP_20111202 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_IMPL_ACCESS_HPP_20111202 +#define NETWORK_PROTOCOL_HTTP_IMPL_ACCESS_HPP_20111202 + #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { struct response; @@ -31,10 +32,4 @@ struct setter_access { } // namespace network -} // namespace boost - -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_IMPL_ACCESS_HPP_20111202 +#endif // NETWORK_PROTOCOL_HTTP_IMPL_ACCESS_HPP_20111202 diff --git a/include/network/protocol/http/impl/access.ipp b/include/network/protocol/http/impl/access.ipp index c5fdc049d..93af540b2 100644 --- a/include/network/protocol/http/impl/access.ipp +++ b/include/network/protocol/http/impl/access.ipp @@ -1,9 +1,14 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_IMPL_ACCESS_IPP_20111202 -#define BOOST_NETWORK_PROTOCOL_HTTP_IMPL_ACCESS_IPP_20111202 +// Copyright 2011 Dean Michael Berris . +// Copyright 2011 Google, Inc. +// 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) #include -namespace boost { namespace network { namespace http { namespace impl { +namespace network { +namespace http { +namespace impl { void setter_access::set_version_promise(response &r, promise &p) { return r.set_version_promise(p); @@ -35,11 +40,5 @@ void setter_access::set_body_promise(response &r, promise &p) { } } // namespace impl - } // namespace http - } // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_IMPL_ACCESS_IPP_20111202 diff --git a/include/network/protocol/http/impl/message.ipp b/include/network/protocol/http/impl/message.ipp index 4cb554f92..5e0f7fe4a 100644 --- a/include/network/protocol/http/impl/message.ipp +++ b/include/network/protocol/http/impl/message.ipp @@ -5,266 +5,264 @@ // // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_IPP -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_IPP +#ifndef NETWORK_PROTOCOL_HTTP_MESSAGE_IPP +#define NETWORK_PROTOCOL_HTTP_MESSAGE_IPP #include #include #include #include -namespace boost { namespace network { namespace http { - - // static member functions of boost::network::http::message - - template - typename message_impl::string_type const message_impl::url_decode(typename message_impl::string_type const & str) - { - char decode_buf[3]; - typename message_impl::string_type result; - result.reserve(str.size()); - - for (typename message_impl::string_type::size_type pos = 0; pos < str.size(); ++pos) { - switch(str[pos]) { - case '+': - // convert to space character - result += ' '; - break; - case '%': - // decode hexidecimal value - if (pos + 2 < str.size()) { - decode_buf[0] = str[++pos]; - decode_buf[1] = str[++pos]; - decode_buf[2] = '\0'; - result += static_cast( strtol(decode_buf, 0, 16) ); - } else { - // recover from error by not decoding character - result += '%'; - } - break; - default: - // character does not need to be escaped - result += str[pos]; - } - }; - - return result; +namespace network { +namespace http { + +// static member functions of boost::network::http::message + +template +typename message_impl::string_type const message_impl::url_decode(typename message_impl::string_type const & str) +{ + char decode_buf[3]; + typename message_impl::string_type result; + result.reserve(str.size()); + + for (typename message_impl::string_type::size_type pos = 0; pos < str.size(); ++pos) { + switch(str[pos]) { + case '+': + // convert to space character + result += ' '; + break; + case '%': + // decode hexidecimal value + if (pos + 2 < str.size()) { + decode_buf[0] = str[++pos]; + decode_buf[1] = str[++pos]; + decode_buf[2] = '\0'; + result += static_cast( strtol(decode_buf, 0, 16) ); + } else { + // recover from error by not decoding character + result += '%'; + } + break; + default: + // character does not need to be escaped + result += str[pos]; } - - template - typename message_impl::string_type const message_impl::url_encode(typename message_impl::string_type const & str) - { - char encode_buf[4]; - typename message_impl::string_type result; - encode_buf[0] = '%'; - result.reserve(str.size()); - - // character selection for this algorithm is based on the following url: - // http://www.blooberry.com/indexdot/html/topics/urlencoding.htm - - for (typename message_impl::string_type::size_type pos = 0; pos < str.size(); ++pos) { - switch(str[pos]) { - default: - if (str[pos] >= 32 && str[pos] < 127) { - // character does not need to be escaped - result += str[pos]; - break; - } - // else pass through to next case - - case '$': case '&': case '+': case ',': case '/': case ':': - case ';': case '=': case '?': case '@': case '"': case '<': - case '>': case '#': case '%': case '{': case '}': case '|': - case '\\': case '^': case '~': case '[': case ']': case '`': - // the character needs to be encoded - sprintf(encode_buf+1, "%02X", str[pos]); - result += encode_buf; - break; - } - }; - - return result; - } - - template - typename message_impl::string_type const message_impl::make_query_string(typename query_container::type const & query_params) - { - typename message_impl::string_type query_string; - for (typename query_container::type::const_iterator i = query_params.begin(); - i != query_params.end(); ++i) - { - if (i != query_params.begin()) - query_string += '&'; - query_string += url_encode(i->first); - query_string += '='; - query_string += url_encode(i->second); - } - return query_string; - } - - template - typename message_impl::string_type const message_impl::make_set_cookie_header(typename message_impl::string_type const & name, - typename message_impl::string_type const & value, - typename message_impl::string_type const & path, - bool const has_max_age, - unsigned long const max_age) - { - typename message_impl::string_type set_cookie_header(name); - set_cookie_header += "=\""; - set_cookie_header += value; - set_cookie_header += "\"; Version=\"1\""; - if (! path.empty()) { - set_cookie_header += "; Path=\""; - set_cookie_header += path; - set_cookie_header += '\"'; - } - if (has_max_age) { - set_cookie_header += "; Max-Age=\""; - set_cookie_header += boost::lexical_cast::string_type>(max_age); - set_cookie_header += '\"'; - } - return set_cookie_header; + }; + + return result; +} + +template +typename message_impl::string_type const message_impl::url_encode(typename message_impl::string_type const & str) +{ + char encode_buf[4]; + typename message_impl::string_type result; + encode_buf[0] = '%'; + result.reserve(str.size()); + + // character selection for this algorithm is based on the following url: + // http://www.blooberry.com/indexdot/html/topics/urlencoding.htm + + for (typename message_impl::string_type::size_type pos = 0; pos < str.size(); ++pos) { + switch(str[pos]) { + default: + if (str[pos] >= 32 && str[pos] < 127) { + // character does not need to be escaped + result += str[pos]; + break; + } + // else pass through to next case + + case '$': case '&': case '+': case ',': case '/': case ':': + case ';': case '=': case '?': case '@': case '"': case '<': + case '>': case '#': case '%': case '{': case '}': case '|': + case '\\': case '^': case '~': case '[': case ']': case '`': + // the character needs to be encoded + sprintf(encode_buf+1, "%02X", str[pos]); + result += encode_buf; + break; } + }; + + return result; +} + +template +typename message_impl::string_type const message_impl::make_query_string(typename query_container::type const & query_params) +{ + typename message_impl::string_type query_string; + for (typename query_container::type::const_iterator i = query_params.begin(); + i != query_params.end(); ++i) + { + if (i != query_params.begin()) + query_string += '&'; + query_string += url_encode(i->first); + query_string += '='; + query_string += url_encode(i->second); + } + return query_string; +} + +template +typename message_impl::string_type const message_impl::make_set_cookie_header(typename message_impl::string_type const & name, + typename message_impl::string_type const & value, + typename message_impl::string_type const & path, + bool const has_max_age, + unsigned long const max_age) +{ + typename message_impl::string_type set_cookie_header(name); + set_cookie_header += "=\""; + set_cookie_header += value; + set_cookie_header += "\"; Version=\"1\""; + if (! path.empty()) { + set_cookie_header += "; Path=\""; + set_cookie_header += path; + set_cookie_header += '\"'; + } + if (has_max_age) { + set_cookie_header += "; Max-Age=\""; + set_cookie_header += boost::lexical_cast::string_type>(max_age); + set_cookie_header += '\"'; + } + return set_cookie_header; +} + +template +bool message_impl::base64_decode(const typename message_impl::string_type &input, typename message_impl::string_type &output) +{ + static const char nop = -1; + static const char decoding_data[] = { + nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, + nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, + nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop, 62, nop,nop,nop, 63, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,nop,nop, nop,nop,nop,nop, + nop, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,nop, nop,nop,nop,nop, + nop,26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,nop, nop,nop,nop,nop, + nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, + nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, + nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, + nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, + nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, + nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, + nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, + nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop + }; + + unsigned int input_length=input.size(); + const char * input_ptr = input.data(); + + // allocate space for output string + output.clear(); + output.reserve(((input_length+2)/3)*4); - template - bool message_impl::base64_decode(const typename message_impl::string_type &input, typename message_impl::string_type &output) - { - static const char nop = -1; - static const char decoding_data[] = { - nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, - nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, - nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop, 62, nop,nop,nop, 63, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,nop,nop, nop,nop,nop,nop, - nop, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,nop, nop,nop,nop,nop, - nop,26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,nop, nop,nop,nop,nop, - nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, - nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, - nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, - nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, - nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, - nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, - nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, - nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop, nop,nop,nop,nop - }; - - unsigned int input_length=input.size(); - const char * input_ptr = input.data(); - - // allocate space for output string - output.clear(); - output.reserve(((input_length+2)/3)*4); - - // for each 4-bytes sequence from the input, extract 4 6-bits sequences by droping first two bits - // and regenerate into 3 8-bits sequence - - for (unsigned int i=0; i(input_ptr[i])]; - if(base64code0==nop) // non base64 character - return false; - if(!(++i(input_ptr[i])]; - if(base64code1==nop) // non base64 character - return false; - - output += ((base64code0 << 2) | ((base64code1 >> 4) & 0x3)); - - if(++i(input_ptr[i])]; - if(base64code2==nop) // non base64 character - return false; - - output += ((base64code1 << 4) & 0xf0) | ((base64code2 >> 2) & 0x0f); - } - - if(++i(input_ptr[i])]; - if(base64code3==nop) // non base64 character - return false; - - output += (((base64code2 << 6) & 0xc0) | base64code3 ); - } - - } - + // for each 4-bytes sequence from the input, extract 4 6-bits sequences by droping first two bits + // and regenerate into 3 8-bits sequence + + for (unsigned int i=0; i(input_ptr[i])]; + if(base64code0==nop) // non base64 character + return false; + if(!(++i(input_ptr[i])]; + if(base64code1==nop) // non base64 character + return false; + + output += ((base64code0 << 2) | ((base64code1 >> 4) & 0x3)); + + if(++i(input_ptr[i])]; + if(base64code2==nop) // non base64 character + return false; + + output += ((base64code1 << 4) & 0xf0) | ((base64code2 >> 2) & 0x0f); } - - template - bool message_impl::base64_encode(typename message_impl::string_type const & input, typename message_impl::string_type & output) - { - static const char encoding_data[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - - unsigned int input_length=input.size(); - const char * input_ptr = input.data(); - - // allocate space for output string - output.clear(); - output.reserve(((input_length+2)/3)*4); - - // for each 3-bytes sequence from the input, extract 4 6-bits sequences and encode using - // encoding_data lookup table. - // if input do not contains enough chars to complete 3-byte sequence,use pad char '=' - for (unsigned int i=0; i> 2) & 0x3f; // 1-byte 6 bits - output += encoding_data[base64code0]; - base64code1 = (input_ptr[i] << 4 ) & 0x3f; // 1-byte 2 bits + - - if (++i < input_length) { - base64code1 |= (input_ptr[i] >> 4) & 0x0f; // 2-byte 4 bits - output += encoding_data[base64code1]; - base64code2 = (input_ptr[i] << 2) & 0x3f; // 2-byte 4 bits + - - if (++i < input_length) { - base64code2 |= (input_ptr[i] >> 6) & 0x03; // 3-byte 2 bits - base64code3 = input_ptr[i] & 0x3f; // 3-byte 6 bits - output += encoding_data[base64code2]; - output += encoding_data[base64code3]; - } else { - output += encoding_data[base64code2]; - output += '='; - } - } else { - output += encoding_data[base64code1]; - output += '='; - output += '='; - } - } - + + if(++i(input_ptr[i])]; + if(base64code3==nop) // non base64 character + return false; + + output += (((base64code2 << 6) & 0xc0) | base64code3 ); } + } -} // namespace http + return true; +} -} // namespace network +template +bool message_impl::base64_encode(typename message_impl::string_type const & input, typename message_impl::string_type & output) +{ + static const char encoding_data[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + + unsigned int input_length=input.size(); + const char * input_ptr = input.data(); + + // allocate space for output string + output.clear(); + output.reserve(((input_length+2)/3)*4); + + // for each 3-bytes sequence from the input, extract 4 6-bits sequences and encode using + // encoding_data lookup table. + // if input do not contains enough chars to complete 3-byte sequence,use pad char '=' + for (unsigned int i=0; i> 2) & 0x3f; // 1-byte 6 bits + output += encoding_data[base64code0]; + base64code1 = (input_ptr[i] << 4 ) & 0x3f; // 1-byte 2 bits + + + if (++i < input_length) { + base64code1 |= (input_ptr[i] >> 4) & 0x0f; // 2-byte 4 bits + output += encoding_data[base64code1]; + base64code2 = (input_ptr[i] << 2) & 0x3f; // 2-byte 4 bits + -} // namespace boost + if (++i < input_length) { + base64code2 |= (input_ptr[i] >> 6) & 0x03; // 3-byte 2 bits + base64code3 = input_ptr[i] & 0x3f; // 3-byte 6 bits + output += encoding_data[base64code2]; + output += encoding_data[base64code3]; + } else { + output += encoding_data[base64code2]; + output += '='; + } + } else { + output += encoding_data[base64code1]; + output += '='; + output += '='; + } + } + + return true; +} + + +} // namespace http +} // namespace network -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HPP +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_HPP diff --git a/include/network/protocol/http/impl/parser.ipp b/include/network/protocol/http/impl/parser.ipp index 7670f8236..d79db56aa 100644 --- a/include/network/protocol/http/impl/parser.ipp +++ b/include/network/protocol/http/impl/parser.ipp @@ -5,779 +5,776 @@ // // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_NETWORK_PROTOCOL_HTTP_PARSER_IPP #define BOOST_NETWORK_PROTOCOL_HTTP_PARSER_IPP #include -namespace boost { namespace network { namespace http { - - // member functions for class basic_parser - - template - boost::tribool basic_parser::parse_http_headers(basic_message& http_msg) - { - // - // note that boost::tribool may have one of THREE states: - // - // false: encountered an error while parsing HTTP headers - // true: finished successfully parsing the HTTP headers - // indeterminate: parsed bytes, but the HTTP headers are not yet finished - // - const char *read_start_ptr = m_read_ptr; - m_bytes_last_read = 0; - while (m_read_ptr < m_read_end_ptr) { - - switch (m_headers_parse_state) { - case PARSE_METHOD_START: - // we have not yet started parsing the HTTP method string - if (*m_read_ptr != ' ' && *m_read_ptr!='\r' && *m_read_ptr!='\n') { // ignore leading whitespace - if (!is_char(*m_read_ptr) || is_control(*m_read_ptr) || is_special(*m_read_ptr)) - return false; - m_headers_parse_state = PARSE_METHOD; - m_method.erase(); - m_method.push_back(*m_read_ptr); - } - break; - - case PARSE_METHOD: - // we have started parsing the HTTP method string - if (*m_read_ptr == ' ') { - m_resource.erase(); - m_headers_parse_state = PARSE_URI_STEM; - } else if (!is_char(*m_read_ptr) || is_control(*m_read_ptr) || is_special(*m_read_ptr)) { - return false; - } else if (m_method.size() >= ParserTraits::METHOD_MAX) { - return false; - } else { - m_method.push_back(*m_read_ptr); - } - break; - - case PARSE_URI_STEM: - // we have started parsing the URI stem (or resource name) - if (*m_read_ptr == ' ') { - m_headers_parse_state = PARSE_HTTP_VERSION_H; - } else if (*m_read_ptr == '?') { - m_query_string.erase(); - m_headers_parse_state = PARSE_URI_QUERY; - } else if (is_control(*m_read_ptr)) { - return false; - } else if (m_resource.size() >= ParserTraits::RESOURCE_MAX) { - return false; - } else { - m_resource.push_back(*m_read_ptr); - } - break; - - case PARSE_URI_QUERY: - // we have started parsing the URI query string - if (*m_read_ptr == ' ') { - m_headers_parse_state = PARSE_HTTP_VERSION_H; - } else if (is_control(*m_read_ptr)) { - return false; - } else if (m_query_string.size() >= ParserTraits::QUERY_STRING_MAX) { - return false; - } else { - m_query_string.push_back(*m_read_ptr); - } - break; - - case PARSE_HTTP_VERSION_H: - // parsing "HTTP" - if (*m_read_ptr != 'H') return false; - m_headers_parse_state = PARSE_HTTP_VERSION_T_1; - break; - - case PARSE_HTTP_VERSION_T_1: - // parsing "HTTP" - if (*m_read_ptr != 'T') return false; - m_headers_parse_state = PARSE_HTTP_VERSION_T_2; - break; - - case PARSE_HTTP_VERSION_T_2: - // parsing "HTTP" - if (*m_read_ptr != 'T') return false; - m_headers_parse_state = PARSE_HTTP_VERSION_P; - break; - - case PARSE_HTTP_VERSION_P: - // parsing "HTTP" - if (*m_read_ptr != 'P') return false; - m_headers_parse_state = PARSE_HTTP_VERSION_SLASH; - break; - - case PARSE_HTTP_VERSION_SLASH: - // parsing slash after "HTTP" - if (*m_read_ptr != '/') return false; - m_headers_parse_state = PARSE_HTTP_VERSION_MAJOR_START; - break; - - case PARSE_HTTP_VERSION_MAJOR_START: - // parsing the first digit of the major version number - if (!is_digit(*m_read_ptr)) return false; - http_msg.setVersionMajor(*m_read_ptr - '0'); - m_headers_parse_state = PARSE_HTTP_VERSION_MAJOR; - break; - - case PARSE_HTTP_VERSION_MAJOR: - // parsing the major version number (not first digit) - if (*m_read_ptr == '.') { - m_headers_parse_state = PARSE_HTTP_VERSION_MINOR_START; - } else if (is_digit(*m_read_ptr)) { - http_msg.setVersionMajor( (http_msg.getVersionMajor() * 10) - + (*m_read_ptr - '0') ); - } else { - return false; - } - break; - - case PARSE_HTTP_VERSION_MINOR_START: - // parsing the first digit of the minor version number - if (!is_digit(*m_read_ptr)) return false; - http_msg.setVersionMinor(*m_read_ptr - '0'); - m_headers_parse_state = PARSE_HTTP_VERSION_MINOR; - break; - - case PARSE_HTTP_VERSION_MINOR: - // parsing the major version number (not first digit) - if (*m_read_ptr == ' ') { - // should only happen for responses - if (m_is_request) return false; - m_headers_parse_state = PARSE_STATUS_CODE_START; - } else if (*m_read_ptr == '\r') { - // should only happen for requests - if (! m_is_request) return false; - m_headers_parse_state = PARSE_EXPECTING_NEWLINE; - } else if (*m_read_ptr == '\n') { - // should only happen for requests - if (! m_is_request) return false; - m_headers_parse_state = PARSE_EXPECTING_CR; - } else if (is_digit(*m_read_ptr)) { - http_msg.setVersionMinor( (http_msg.getVersionMinor() * 10) - + (*m_read_ptr - '0') ); - } else { - return false; - } - break; - - case PARSE_STATUS_CODE_START: - // parsing the first digit of the response status code - if (!is_digit(*m_read_ptr)) return false; - m_status_code = (*m_read_ptr - '0'); - m_headers_parse_state = PARSE_STATUS_CODE; - break; - - case PARSE_STATUS_CODE: - // parsing the response status code (not first digit) - if (*m_read_ptr == ' ') { - m_status_message.erase(); - m_headers_parse_state = PARSE_STATUS_MESSAGE; - } else if (is_digit(*m_read_ptr)) { - m_status_code = ( (m_status_code * 10) + (*m_read_ptr - '0') ); - } else { - return false; - } - break; - - case PARSE_STATUS_MESSAGE: - // parsing the response status message - if (*m_read_ptr == '\r') { - m_headers_parse_state = PARSE_EXPECTING_NEWLINE; - } else if (*m_read_ptr == '\n') { - m_headers_parse_state = PARSE_EXPECTING_CR; - } else if (is_control(*m_read_ptr)) { - return false; - } else if (m_status_message.size() >= ParserTraits::STATUS_MESSAGE_MAX) { - return false; - } else { - m_status_message.push_back(*m_read_ptr); - } - break; - - case PARSE_EXPECTING_NEWLINE: - // we received a CR; expecting a newline to follow - if (*m_read_ptr == '\n') { - m_headers_parse_state = PARSE_HEADER_START; - } else if (*m_read_ptr == '\r') { - // we received two CR's in a row - // assume CR only is (incorrectly) being used for line termination - // therefore, the message is finished - ++m_read_ptr; - m_bytes_last_read = (m_read_ptr - read_start_ptr); - m_bytes_total_read += m_bytes_last_read; - return true; - } else if (*m_read_ptr == '\t' || *m_read_ptr == ' ') { - m_headers_parse_state = PARSE_HEADER_WHITESPACE; - } else if (!is_char(*m_read_ptr) || is_control(*m_read_ptr) || is_special(*m_read_ptr)) { - return false; - } else { - // assume it is the first character for the name of a header - m_header_name.erase(); - m_header_name.push_back(*m_read_ptr); - m_headers_parse_state = PARSE_HEADER_NAME; - } - break; - - case PARSE_EXPECTING_CR: - // we received a newline without a CR - if (*m_read_ptr == '\r') { - m_headers_parse_state = PARSE_HEADER_START; - } else if (*m_read_ptr == '\n') { - // we received two newlines in a row - // assume newline only is (incorrectly) being used for line termination - // therefore, the message is finished - ++m_read_ptr; - m_bytes_last_read = (m_read_ptr - read_start_ptr); - m_bytes_total_read += m_bytes_last_read; - return true; - } else if (*m_read_ptr == '\t' || *m_read_ptr == ' ') { - m_headers_parse_state = PARSE_HEADER_WHITESPACE; - } else if (!is_char(*m_read_ptr) || is_control(*m_read_ptr) || is_special(*m_read_ptr)) { - return false; - } else { - // assume it is the first character for the name of a header - m_header_name.erase(); - m_header_name.push_back(*m_read_ptr); - m_headers_parse_state = PARSE_HEADER_NAME; - } - break; - - case PARSE_HEADER_WHITESPACE: - // parsing whitespace before a header name - if (*m_read_ptr == '\r') { - m_headers_parse_state = PARSE_EXPECTING_NEWLINE; - } else if (*m_read_ptr == '\n') { - m_headers_parse_state = PARSE_EXPECTING_CR; - } else if (*m_read_ptr != '\t' && *m_read_ptr != ' ') { - if (!is_char(*m_read_ptr) || is_control(*m_read_ptr) || is_special(*m_read_ptr)) - return false; - // assume it is the first character for the name of a header - m_header_name.erase(); - m_header_name.push_back(*m_read_ptr); - m_headers_parse_state = PARSE_HEADER_NAME; - } - break; - - case PARSE_HEADER_START: - // parsing the start of a new header - if (*m_read_ptr == '\r') { - m_headers_parse_state = PARSE_EXPECTING_FINAL_NEWLINE; - } else if (*m_read_ptr == '\n') { - m_headers_parse_state = PARSE_EXPECTING_FINAL_CR; - } else if (*m_read_ptr == '\t' || *m_read_ptr == ' ') { - m_headers_parse_state = PARSE_HEADER_WHITESPACE; - } else if (!is_char(*m_read_ptr) || is_control(*m_read_ptr) || is_special(*m_read_ptr)) { - return false; - } else { - // first character for the name of a header - m_header_name.erase(); - m_header_name.push_back(*m_read_ptr); - m_headers_parse_state = PARSE_HEADER_NAME; - } - break; - - case PARSE_HEADER_NAME: - // parsing the name of a header - if (*m_read_ptr == ':') { - m_header_value.erase(); - m_headers_parse_state = PARSE_SPACE_BEFORE_HEADER_VALUE; - } else if (!is_char(*m_read_ptr) || is_control(*m_read_ptr) || is_special(*m_read_ptr)) { - return false; - } else if (m_header_name.size() >= ParserTraits::HEADER_NAME_MAX) { - return false; - } else { - // character (not first) for the name of a header - m_header_name.push_back(*m_read_ptr); - } - break; - - case PARSE_SPACE_BEFORE_HEADER_VALUE: - // parsing space character before a header's value - if (*m_read_ptr == ' ') { - m_headers_parse_state = PARSE_HEADER_VALUE; - } else if (*m_read_ptr == '\r') { - http_msg.addHeader(m_header_name, m_header_value); - m_headers_parse_state = PARSE_EXPECTING_NEWLINE; - } else if (*m_read_ptr == '\n') { - http_msg.addHeader(m_header_name, m_header_value); - m_headers_parse_state = PARSE_EXPECTING_CR; - } else if (!is_char(*m_read_ptr) || is_control(*m_read_ptr) || is_special(*m_read_ptr)) { - return false; - } else { - // assume it is the first character for the value of a header - m_header_value.push_back(*m_read_ptr); - m_headers_parse_state = PARSE_HEADER_VALUE; - } - break; - - case PARSE_HEADER_VALUE: - // parsing the value of a header - if (*m_read_ptr == '\r') { - http_msg.addHeader(m_header_name, m_header_value); - m_headers_parse_state = PARSE_EXPECTING_NEWLINE; - } else if (*m_read_ptr == '\n') { - http_msg.addHeader(m_header_name, m_header_value); - m_headers_parse_state = PARSE_EXPECTING_CR; - } else if (is_control(*m_read_ptr)) { - return false; - } else if (m_header_value.size() >= ParserTraits::HEADER_VALUE_MAX) { - return false; - } else { - // character (not first) for the value of a header - m_header_value.push_back(*m_read_ptr); - } - break; - - case PARSE_EXPECTING_FINAL_NEWLINE: - if (*m_read_ptr == '\n') ++m_read_ptr; - m_bytes_last_read = (m_read_ptr - read_start_ptr); - m_bytes_total_read += m_bytes_last_read; - return true; - - case PARSE_EXPECTING_FINAL_CR: - if (*m_read_ptr == '\r') ++m_read_ptr; - m_bytes_last_read = (m_read_ptr - read_start_ptr); - m_bytes_total_read += m_bytes_last_read; - return true; - } - - ++m_read_ptr; - } - +namespace network { namespace http { + +// member functions for class basic_parser + +template +boost::tribool basic_parser::parse_http_headers(basic_message& http_msg) +{ + // + // note that boost::tribool may have one of THREE states: + // + // false: encountered an error while parsing HTTP headers + // true: finished successfully parsing the HTTP headers + // indeterminate: parsed bytes, but the HTTP headers are not yet finished + // + const char *read_start_ptr = m_read_ptr; + m_bytes_last_read = 0; + while (m_read_ptr < m_read_end_ptr) { + + switch (m_headers_parse_state) { + case PARSE_METHOD_START: + // we have not yet started parsing the HTTP method string + if (*m_read_ptr != ' ' && *m_read_ptr!='\r' && *m_read_ptr!='\n') { // ignore leading whitespace + if (!is_char(*m_read_ptr) || is_control(*m_read_ptr) || is_special(*m_read_ptr)) + return false; + m_headers_parse_state = PARSE_METHOD; + m_method.erase(); + m_method.push_back(*m_read_ptr); + } + break; + + case PARSE_METHOD: + // we have started parsing the HTTP method string + if (*m_read_ptr == ' ') { + m_resource.erase(); + m_headers_parse_state = PARSE_URI_STEM; + } else if (!is_char(*m_read_ptr) || is_control(*m_read_ptr) || is_special(*m_read_ptr)) { + return false; + } else if (m_method.size() >= ParserTraits::METHOD_MAX) { + return false; + } else { + m_method.push_back(*m_read_ptr); + } + break; + + case PARSE_URI_STEM: + // we have started parsing the URI stem (or resource name) + if (*m_read_ptr == ' ') { + m_headers_parse_state = PARSE_HTTP_VERSION_H; + } else if (*m_read_ptr == '?') { + m_query_string.erase(); + m_headers_parse_state = PARSE_URI_QUERY; + } else if (is_control(*m_read_ptr)) { + return false; + } else if (m_resource.size() >= ParserTraits::RESOURCE_MAX) { + return false; + } else { + m_resource.push_back(*m_read_ptr); + } + break; + + case PARSE_URI_QUERY: + // we have started parsing the URI query string + if (*m_read_ptr == ' ') { + m_headers_parse_state = PARSE_HTTP_VERSION_H; + } else if (is_control(*m_read_ptr)) { + return false; + } else if (m_query_string.size() >= ParserTraits::QUERY_STRING_MAX) { + return false; + } else { + m_query_string.push_back(*m_read_ptr); + } + break; + + case PARSE_HTTP_VERSION_H: + // parsing "HTTP" + if (*m_read_ptr != 'H') return false; + m_headers_parse_state = PARSE_HTTP_VERSION_T_1; + break; + + case PARSE_HTTP_VERSION_T_1: + // parsing "HTTP" + if (*m_read_ptr != 'T') return false; + m_headers_parse_state = PARSE_HTTP_VERSION_T_2; + break; + + case PARSE_HTTP_VERSION_T_2: + // parsing "HTTP" + if (*m_read_ptr != 'T') return false; + m_headers_parse_state = PARSE_HTTP_VERSION_P; + break; + + case PARSE_HTTP_VERSION_P: + // parsing "HTTP" + if (*m_read_ptr != 'P') return false; + m_headers_parse_state = PARSE_HTTP_VERSION_SLASH; + break; + + case PARSE_HTTP_VERSION_SLASH: + // parsing slash after "HTTP" + if (*m_read_ptr != '/') return false; + m_headers_parse_state = PARSE_HTTP_VERSION_MAJOR_START; + break; + + case PARSE_HTTP_VERSION_MAJOR_START: + // parsing the first digit of the major version number + if (!is_digit(*m_read_ptr)) return false; + http_msg.setVersionMajor(*m_read_ptr - '0'); + m_headers_parse_state = PARSE_HTTP_VERSION_MAJOR; + break; + + case PARSE_HTTP_VERSION_MAJOR: + // parsing the major version number (not first digit) + if (*m_read_ptr == '.') { + m_headers_parse_state = PARSE_HTTP_VERSION_MINOR_START; + } else if (is_digit(*m_read_ptr)) { + http_msg.setVersionMajor( (http_msg.getVersionMajor() * 10) + + (*m_read_ptr - '0') ); + } else { + return false; + } + break; + + case PARSE_HTTP_VERSION_MINOR_START: + // parsing the first digit of the minor version number + if (!is_digit(*m_read_ptr)) return false; + http_msg.setVersionMinor(*m_read_ptr - '0'); + m_headers_parse_state = PARSE_HTTP_VERSION_MINOR; + break; + + case PARSE_HTTP_VERSION_MINOR: + // parsing the major version number (not first digit) + if (*m_read_ptr == ' ') { + // should only happen for responses + if (m_is_request) return false; + m_headers_parse_state = PARSE_STATUS_CODE_START; + } else if (*m_read_ptr == '\r') { + // should only happen for requests + if (! m_is_request) return false; + m_headers_parse_state = PARSE_EXPECTING_NEWLINE; + } else if (*m_read_ptr == '\n') { + // should only happen for requests + if (! m_is_request) return false; + m_headers_parse_state = PARSE_EXPECTING_CR; + } else if (is_digit(*m_read_ptr)) { + http_msg.setVersionMinor( (http_msg.getVersionMinor() * 10) + + (*m_read_ptr - '0') ); + } else { + return false; + } + break; + + case PARSE_STATUS_CODE_START: + // parsing the first digit of the response status code + if (!is_digit(*m_read_ptr)) return false; + m_status_code = (*m_read_ptr - '0'); + m_headers_parse_state = PARSE_STATUS_CODE; + break; + + case PARSE_STATUS_CODE: + // parsing the response status code (not first digit) + if (*m_read_ptr == ' ') { + m_status_message.erase(); + m_headers_parse_state = PARSE_STATUS_MESSAGE; + } else if (is_digit(*m_read_ptr)) { + m_status_code = ( (m_status_code * 10) + (*m_read_ptr - '0') ); + } else { + return false; + } + break; + + case PARSE_STATUS_MESSAGE: + // parsing the response status message + if (*m_read_ptr == '\r') { + m_headers_parse_state = PARSE_EXPECTING_NEWLINE; + } else if (*m_read_ptr == '\n') { + m_headers_parse_state = PARSE_EXPECTING_CR; + } else if (is_control(*m_read_ptr)) { + return false; + } else if (m_status_message.size() >= ParserTraits::STATUS_MESSAGE_MAX) { + return false; + } else { + m_status_message.push_back(*m_read_ptr); + } + break; + + case PARSE_EXPECTING_NEWLINE: + // we received a CR; expecting a newline to follow + if (*m_read_ptr == '\n') { + m_headers_parse_state = PARSE_HEADER_START; + } else if (*m_read_ptr == '\r') { + // we received two CR's in a row + // assume CR only is (incorrectly) being used for line termination + // therefore, the message is finished + ++m_read_ptr; m_bytes_last_read = (m_read_ptr - read_start_ptr); m_bytes_total_read += m_bytes_last_read; - return boost::indeterminate; - } - - template - boost::tribool basic_parser::parse_chunks(types::chunk_cache_t& chunk_buffers) - { - // - // note that boost::tribool may have one of THREE states: - // - // false: encountered an error while parsing message - // true: finished successfully parsing the message - // indeterminate: parsed bytes, but the message is not yet finished - // - const char *read_start_ptr = m_read_ptr; - m_bytes_last_read = 0; - while (m_read_ptr < m_read_end_ptr) { - - switch (m_chunked_content_parse_state) { - case PARSE_CHUNK_SIZE_START: - // we have not yet started parsing the next chunk size - if (is_hex_digit(*m_read_ptr)) { - m_chunk_size_str.erase(); - m_chunk_size_str.push_back(*m_read_ptr); - m_chunked_content_parse_state = PARSE_CHUNK_SIZE; - } else if (*m_read_ptr == ' ' || *m_read_ptr == '\x09' || *m_read_ptr == '\x0D' || *m_read_ptr == '\x0A') { - // Ignore leading whitespace. Technically, the standard probably doesn't allow white space here, - // but we'll be flexible, since there's no ambiguity. - break; - } else { - return false; - } - break; - - case PARSE_CHUNK_SIZE: - if (is_hex_digit(*m_read_ptr)) { - m_chunk_size_str.push_back(*m_read_ptr); - } else if (*m_read_ptr == '\x0D') { - m_chunked_content_parse_state = PARSE_EXPECTING_LF_AFTER_CHUNK_SIZE; - } else if (*m_read_ptr == ' ' || *m_read_ptr == '\x09') { - // Ignore trailing tabs or spaces. Technically, the standard probably doesn't allow this, - // but we'll be flexible, since there's no ambiguity. - m_chunked_content_parse_state = PARSE_EXPECTING_CR_AFTER_CHUNK_SIZE; - } else { - return false; - } - break; - - case PARSE_EXPECTING_CR_AFTER_CHUNK_SIZE: - if (*m_read_ptr == '\x0D') { - m_chunked_content_parse_state = PARSE_EXPECTING_LF_AFTER_CHUNK_SIZE; - } else if (*m_read_ptr == ' ' || *m_read_ptr == '\x09') { - // Ignore trailing tabs or spaces. Technically, the standard probably doesn't allow this, - // but we'll be flexible, since there's no ambiguity. - break; - } else { - return false; - } - break; - - case PARSE_EXPECTING_LF_AFTER_CHUNK_SIZE: - // We received a CR; expecting LF to follow. We can't be flexible here because - // if we see anything other than LF, we can't be certain where the chunk starts. - if (*m_read_ptr == '\x0A') { - m_bytes_read_in_current_chunk = 0; - m_size_of_current_chunk = strtol(m_chunk_size_str.c_str(), 0, 16); - if (m_size_of_current_chunk == 0) { - m_chunked_content_parse_state = PARSE_EXPECTING_FINAL_CR_AFTER_LAST_CHUNK; - } else { - m_current_chunk.clear(); - m_chunked_content_parse_state = PARSE_CHUNK; - } - } else { - return false; - } - break; - - case PARSE_CHUNK: - if (m_bytes_read_in_current_chunk < m_size_of_current_chunk) { - m_current_chunk.push_back(*m_read_ptr); - m_bytes_read_in_current_chunk++; - } - if (m_bytes_read_in_current_chunk == m_size_of_current_chunk) { - chunk_buffers.push_back(m_current_chunk); - m_current_chunk.clear(); - m_chunked_content_parse_state = PARSE_EXPECTING_CR_AFTER_CHUNK; - } - break; - - case PARSE_EXPECTING_CR_AFTER_CHUNK: - // we've read exactly m_size_of_current_chunk bytes since starting the current chunk - if (*m_read_ptr == '\x0D') { - m_chunked_content_parse_state = PARSE_EXPECTING_LF_AFTER_CHUNK; - } else { - return false; - } - break; - - case PARSE_EXPECTING_LF_AFTER_CHUNK: - // we received a CR; expecting LF to follow - if (*m_read_ptr == '\x0A') { - m_chunked_content_parse_state = PARSE_CHUNK_SIZE_START; - } else { - return false; - } - break; - - case PARSE_EXPECTING_FINAL_CR_AFTER_LAST_CHUNK: - // we've read the final chunk; expecting final CRLF - if (*m_read_ptr == '\x0D') { - m_chunked_content_parse_state = PARSE_EXPECTING_FINAL_LF_AFTER_LAST_CHUNK; - } else { - return false; - } - break; - - case PARSE_EXPECTING_FINAL_LF_AFTER_LAST_CHUNK: - // we received the final CR; expecting LF to follow - if (*m_read_ptr == '\x0A') { - ++m_read_ptr; - m_bytes_last_read = (m_read_ptr - read_start_ptr); - m_bytes_total_read += m_bytes_last_read; - return true; - } else { - return false; - } - } - - ++m_read_ptr; - } - + return true; + } else if (*m_read_ptr == '\t' || *m_read_ptr == ' ') { + m_headers_parse_state = PARSE_HEADER_WHITESPACE; + } else if (!is_char(*m_read_ptr) || is_control(*m_read_ptr) || is_special(*m_read_ptr)) { + return false; + } else { + // assume it is the first character for the name of a header + m_header_name.erase(); + m_header_name.push_back(*m_read_ptr); + m_headers_parse_state = PARSE_HEADER_NAME; + } + break; + + case PARSE_EXPECTING_CR: + // we received a newline without a CR + if (*m_read_ptr == '\r') { + m_headers_parse_state = PARSE_HEADER_START; + } else if (*m_read_ptr == '\n') { + // we received two newlines in a row + // assume newline only is (incorrectly) being used for line termination + // therefore, the message is finished + ++m_read_ptr; m_bytes_last_read = (m_read_ptr - read_start_ptr); m_bytes_total_read += m_bytes_last_read; - return boost::indeterminate; - } + return true; + } else if (*m_read_ptr == '\t' || *m_read_ptr == ' ') { + m_headers_parse_state = PARSE_HEADER_WHITESPACE; + } else if (!is_char(*m_read_ptr) || is_control(*m_read_ptr) || is_special(*m_read_ptr)) { + return false; + } else { + // assume it is the first character for the name of a header + m_header_name.erase(); + m_header_name.push_back(*m_read_ptr); + m_headers_parse_state = PARSE_HEADER_NAME; + } + break; - template - std::size_t basic_parser::consume_content(basic_message& http_msg) - { - // get the payload content length from the HTTP headers - http_msg.updateContentLengthUsingHeader(); - - // read the post content - std::size_t content_bytes_to_read = http_msg.getContentLength(); - char *post_buffer = http_msg.createContentBuffer(); - - if (m_read_ptr < m_read_end_ptr) { - // there are extra bytes left from the last read operation - // copy them into the beginning of the content buffer - const std::size_t bytes_left_in_read_buffer = bytes_available(); - - if (bytes_left_in_read_buffer >= http_msg.getContentLength()) { - // the last read operation included all of the payload content - memcpy(post_buffer, m_read_ptr, http_msg.getContentLength()); - content_bytes_to_read = 0; - m_read_ptr += http_msg.getContentLength(); - } else { - // only some of the post content has been read so far - memcpy(post_buffer, m_read_ptr, bytes_left_in_read_buffer); - content_bytes_to_read -= bytes_left_in_read_buffer; - m_read_ptr = m_read_end_ptr; - } - } - - m_bytes_last_read = (http_msg.getContentLength() - content_bytes_to_read); - m_bytes_total_read += m_bytes_last_read; - return m_bytes_last_read; + case PARSE_HEADER_WHITESPACE: + // parsing whitespace before a header name + if (*m_read_ptr == '\r') { + m_headers_parse_state = PARSE_EXPECTING_NEWLINE; + } else if (*m_read_ptr == '\n') { + m_headers_parse_state = PARSE_EXPECTING_CR; + } else if (*m_read_ptr != '\t' && *m_read_ptr != ' ') { + if (!is_char(*m_read_ptr) || is_control(*m_read_ptr) || is_special(*m_read_ptr)) + return false; + // assume it is the first character for the name of a header + m_header_name.erase(); + m_header_name.push_back(*m_read_ptr); + m_headers_parse_state = PARSE_HEADER_NAME; + } + break; + + case PARSE_HEADER_START: + // parsing the start of a new header + if (*m_read_ptr == '\r') { + m_headers_parse_state = PARSE_EXPECTING_FINAL_NEWLINE; + } else if (*m_read_ptr == '\n') { + m_headers_parse_state = PARSE_EXPECTING_FINAL_CR; + } else if (*m_read_ptr == '\t' || *m_read_ptr == ' ') { + m_headers_parse_state = PARSE_HEADER_WHITESPACE; + } else if (!is_char(*m_read_ptr) || is_control(*m_read_ptr) || is_special(*m_read_ptr)) { + return false; + } else { + // first character for the name of a header + m_header_name.erase(); + m_header_name.push_back(*m_read_ptr); + m_headers_parse_state = PARSE_HEADER_NAME; + } + break; + + case PARSE_HEADER_NAME: + // parsing the name of a header + if (*m_read_ptr == ':') { + m_header_value.erase(); + m_headers_parse_state = PARSE_SPACE_BEFORE_HEADER_VALUE; + } else if (!is_char(*m_read_ptr) || is_control(*m_read_ptr) || is_special(*m_read_ptr)) { + return false; + } else if (m_header_name.size() >= ParserTraits::HEADER_NAME_MAX) { + return false; + } else { + // character (not first) for the name of a header + m_header_name.push_back(*m_read_ptr); + } + break; + + case PARSE_SPACE_BEFORE_HEADER_VALUE: + // parsing space character before a header's value + if (*m_read_ptr == ' ') { + m_headers_parse_state = PARSE_HEADER_VALUE; + } else if (*m_read_ptr == '\r') { + http_msg.addHeader(m_header_name, m_header_value); + m_headers_parse_state = PARSE_EXPECTING_NEWLINE; + } else if (*m_read_ptr == '\n') { + http_msg.addHeader(m_header_name, m_header_value); + m_headers_parse_state = PARSE_EXPECTING_CR; + } else if (!is_char(*m_read_ptr) || is_control(*m_read_ptr) || is_special(*m_read_ptr)) { + return false; + } else { + // assume it is the first character for the value of a header + m_header_value.push_back(*m_read_ptr); + m_headers_parse_state = PARSE_HEADER_VALUE; + } + break; + + case PARSE_HEADER_VALUE: + // parsing the value of a header + if (*m_read_ptr == '\r') { + http_msg.addHeader(m_header_name, m_header_value); + m_headers_parse_state = PARSE_EXPECTING_NEWLINE; + } else if (*m_read_ptr == '\n') { + http_msg.addHeader(m_header_name, m_header_value); + m_headers_parse_state = PARSE_EXPECTING_CR; + } else if (is_control(*m_read_ptr)) { + return false; + } else if (m_header_value.size() >= ParserTraits::HEADER_VALUE_MAX) { + return false; + } else { + // character (not first) for the value of a header + m_header_value.push_back(*m_read_ptr); + } + break; + + case PARSE_EXPECTING_FINAL_NEWLINE: + if (*m_read_ptr == '\n') ++m_read_ptr; + m_bytes_last_read = (m_read_ptr - read_start_ptr); + m_bytes_total_read += m_bytes_last_read; + return true; + + case PARSE_EXPECTING_FINAL_CR: + if (*m_read_ptr == '\r') ++m_read_ptr; + m_bytes_last_read = (m_read_ptr - read_start_ptr); + m_bytes_total_read += m_bytes_last_read; + return true; } - - template - std::size_t basic_parser::consume_content_as_next_chunk(types::chunk_cache_t& chunk_buffers) - { - if (bytes_available() == 0) { - m_bytes_last_read = 0; + + ++m_read_ptr; + } + + m_bytes_last_read = (m_read_ptr - read_start_ptr); + m_bytes_total_read += m_bytes_last_read; + return boost::indeterminate; +} + +template +boost::tribool basic_parser::parse_chunks(types::chunk_cache_t& chunk_buffers) +{ + // + // note that boost::tribool may have one of THREE states: + // + // false: encountered an error while parsing message + // true: finished successfully parsing the message + // indeterminate: parsed bytes, but the message is not yet finished + // + const char *read_start_ptr = m_read_ptr; + m_bytes_last_read = 0; + while (m_read_ptr < m_read_end_ptr) { + + switch (m_chunked_content_parse_state) { + case PARSE_CHUNK_SIZE_START: + // we have not yet started parsing the next chunk size + if (is_hex_digit(*m_read_ptr)) { + m_chunk_size_str.erase(); + m_chunk_size_str.push_back(*m_read_ptr); + m_chunked_content_parse_state = PARSE_CHUNK_SIZE; + } else if (*m_read_ptr == ' ' || *m_read_ptr == '\x09' || *m_read_ptr == '\x0D' || *m_read_ptr == '\x0A') { + // Ignore leading whitespace. Technically, the standard probably doesn't allow white space here, + // but we'll be flexible, since there's no ambiguity. + break; + } else { + return false; + } + break; + + case PARSE_CHUNK_SIZE: + if (is_hex_digit(*m_read_ptr)) { + m_chunk_size_str.push_back(*m_read_ptr); + } else if (*m_read_ptr == '\x0D') { + m_chunked_content_parse_state = PARSE_EXPECTING_LF_AFTER_CHUNK_SIZE; + } else if (*m_read_ptr == ' ' || *m_read_ptr == '\x09') { + // Ignore trailing tabs or spaces. Technically, the standard probably doesn't allow this, + // but we'll be flexible, since there's no ambiguity. + m_chunked_content_parse_state = PARSE_EXPECTING_CR_AFTER_CHUNK_SIZE; + } else { + return false; + } + break; + + case PARSE_EXPECTING_CR_AFTER_CHUNK_SIZE: + if (*m_read_ptr == '\x0D') { + m_chunked_content_parse_state = PARSE_EXPECTING_LF_AFTER_CHUNK_SIZE; + } else if (*m_read_ptr == ' ' || *m_read_ptr == '\x09') { + // Ignore trailing tabs or spaces. Technically, the standard probably doesn't allow this, + // but we'll be flexible, since there's no ambiguity. + break; + } else { + return false; + } + break; + + case PARSE_EXPECTING_LF_AFTER_CHUNK_SIZE: + // We received a CR; expecting LF to follow. We can't be flexible here because + // if we see anything other than LF, we can't be certain where the chunk starts. + if (*m_read_ptr == '\x0A') { + m_bytes_read_in_current_chunk = 0; + m_size_of_current_chunk = strtol(m_chunk_size_str.c_str(), 0, 16); + if (m_size_of_current_chunk == 0) { + m_chunked_content_parse_state = PARSE_EXPECTING_FINAL_CR_AFTER_LAST_CHUNK; } else { - std::vector next_chunk; - while (m_read_ptr < m_read_end_ptr) { - next_chunk.push_back(*m_read_ptr); - ++m_read_ptr; - } - chunk_buffers.push_back(next_chunk); - m_bytes_last_read = next_chunk.size(); - m_bytes_total_read += m_bytes_last_read; + m_current_chunk.clear(); + m_chunked_content_parse_state = PARSE_CHUNK; } - return m_bytes_last_read; + } else { + return false; + } + break; + + case PARSE_CHUNK: + if (m_bytes_read_in_current_chunk < m_size_of_current_chunk) { + m_current_chunk.push_back(*m_read_ptr); + m_bytes_read_in_current_chunk++; + } + if (m_bytes_read_in_current_chunk == m_size_of_current_chunk) { + chunk_buffers.push_back(m_current_chunk); + m_current_chunk.clear(); + m_chunked_content_parse_state = PARSE_EXPECTING_CR_AFTER_CHUNK; + } + break; + + case PARSE_EXPECTING_CR_AFTER_CHUNK: + // we've read exactly m_size_of_current_chunk bytes since starting the current chunk + if (*m_read_ptr == '\x0D') { + m_chunked_content_parse_state = PARSE_EXPECTING_LF_AFTER_CHUNK; + } else { + return false; + } + break; + + case PARSE_EXPECTING_LF_AFTER_CHUNK: + // we received a CR; expecting LF to follow + if (*m_read_ptr == '\x0A') { + m_chunked_content_parse_state = PARSE_CHUNK_SIZE_START; + } else { + return false; + } + break; + + case PARSE_EXPECTING_FINAL_CR_AFTER_LAST_CHUNK: + // we've read the final chunk; expecting final CRLF + if (*m_read_ptr == '\x0D') { + m_chunked_content_parse_state = PARSE_EXPECTING_FINAL_LF_AFTER_LAST_CHUNK; + } else { + return false; + } + break; + + case PARSE_EXPECTING_FINAL_LF_AFTER_LAST_CHUNK: + // we received the final CR; expecting LF to follow + if (*m_read_ptr == '\x0A') { + ++m_read_ptr; + m_bytes_last_read = (m_read_ptr - read_start_ptr); + m_bytes_total_read += m_bytes_last_read; + return true; + } else { + return false; + } } - - template - void basic_parser::finish(basic_request& http_request) - { - http_request.setIsValid(true); - http_request.setMethod(m_method); - http_request.setResource(m_resource); - http_request.setQueryString(m_query_string); - - // parse query pairs from the URI query string - if (! m_query_string.empty()) { - if (! parseURLEncoded(http_request.getQueryParams(), - m_query_string.c_str(), - m_query_string.size())) - } - - // parse query pairs from post content (x-www-form-urlencoded) - if (http_request.getHeader(types::HEADER_CONTENT_TYPE) == - types::CONTENT_TYPE_URLENCODED) - { - if (! parseURLEncoded(http_request.getQueryParams(), - http_request.getContent(), - http_request.getContentLength())) - } - - // parse "Cookie" headers - std::pair - cookie_pair = http_request.getHeaders().equal_range(types::HEADER_COOKIE); - for (types::headers::const_iterator cookie_iterator = cookie_pair.first; - cookie_iterator != http_request.getHeaders().end() - && cookie_iterator != cookie_pair.second; ++cookie_iterator) - { - if (! parseCookieHeader(http_request.getCookieParams(), - cookie_iterator->second) ) - } + + ++m_read_ptr; + } + + m_bytes_last_read = (m_read_ptr - read_start_ptr); + m_bytes_total_read += m_bytes_last_read; + return boost::indeterminate; +} + +template +std::size_t basic_parser::consume_content(basic_message& http_msg) +{ + // get the payload content length from the HTTP headers + http_msg.updateContentLengthUsingHeader(); + + // read the post content + std::size_t content_bytes_to_read = http_msg.getContentLength(); + char *post_buffer = http_msg.createContentBuffer(); + + if (m_read_ptr < m_read_end_ptr) { + // there are extra bytes left from the last read operation + // copy them into the beginning of the content buffer + const std::size_t bytes_left_in_read_buffer = bytes_available(); + + if (bytes_left_in_read_buffer >= http_msg.getContentLength()) { + // the last read operation included all of the payload content + memcpy(post_buffer, m_read_ptr, http_msg.getContentLength()); + content_bytes_to_read = 0; + m_read_ptr += http_msg.getContentLength(); + } else { + // only some of the post content has been read so far + memcpy(post_buffer, m_read_ptr, bytes_left_in_read_buffer); + content_bytes_to_read -= bytes_left_in_read_buffer; + m_read_ptr = m_read_end_ptr; } + } + + m_bytes_last_read = (http_msg.getContentLength() - content_bytes_to_read); + m_bytes_total_read += m_bytes_last_read; + return m_bytes_last_read; +} - template - void basic_parser::finish(basic_response& http_response) - { - http_response.setIsValid(true); - http_response.setStatusCode(m_status_code); - http_response.setStatusMessage(m_status_message); +template +std::size_t basic_parser::consume_content_as_next_chunk(types::chunk_cache_t& chunk_buffers) +{ + if (bytes_available() == 0) { + m_bytes_last_read = 0; + } else { + std::vector next_chunk; + while (m_read_ptr < m_read_end_ptr) { + next_chunk.push_back(*m_read_ptr); + ++m_read_ptr; } - - template - inline void basic_parser::reset(void) - { - m_headers_parse_state = (m_is_request ? PARSE_METHOD_START : PARSE_HTTP_VERSION_H); - m_chunked_content_parse_state = PARSE_CHUNK_SIZE_START; - m_status_code = 0; - m_status_message.erase(); - m_method.erase(); - m_resource.erase(); - m_query_string.erase(); - m_current_chunk.clear(); - m_bytes_last_read = m_bytes_total_read = 0; + chunk_buffers.push_back(next_chunk); + m_bytes_last_read = next_chunk.size(); + m_bytes_total_read += m_bytes_last_read; + } + return m_bytes_last_read; +} + +template +void basic_parser::finish(basic_request& http_request) +{ + http_request.setIsValid(true); + http_request.setMethod(m_method); + http_request.setResource(m_resource); + http_request.setQueryString(m_query_string); + + // parse query pairs from the URI query string + if (! m_query_string.empty()) { + if (! parseURLEncoded(http_request.getQueryParams(), + m_query_string.c_str(), + m_query_string.size())) + } + + // parse query pairs from post content (x-www-form-urlencoded) + if (http_request.getHeader(types::HEADER_CONTENT_TYPE) == + types::CONTENT_TYPE_URLENCODED) + { + if (! parseURLEncoded(http_request.getQueryParams(), + http_request.getContent(), + http_request.getContentLength())) + } + + // parse "Cookie" headers + std::pair + cookie_pair = http_request.getHeaders().equal_range(types::HEADER_COOKIE); + for (types::headers::const_iterator cookie_iterator = cookie_pair.first; + cookie_iterator != http_request.getHeaders().end() + && cookie_iterator != cookie_pair.second; ++cookie_iterator) + { + if (! parseCookieHeader(http_request.getCookieParams(), + cookie_iterator->second) ) + } +} + +template +void basic_parser::finish(basic_response& http_response) +{ + http_response.setIsValid(true); + http_response.setStatusCode(m_status_code); + http_response.setStatusMessage(m_status_message); +} + +template +inline void basic_parser::reset(void) +{ + m_headers_parse_state = (m_is_request ? PARSE_METHOD_START : PARSE_HTTP_VERSION_H); + m_chunked_content_parse_state = PARSE_CHUNK_SIZE_START; + m_status_code = 0; + m_status_message.erase(); + m_method.erase(); + m_resource.erase(); + m_query_string.erase(); + m_current_chunk.clear(); + m_bytes_last_read = m_bytes_total_read = 0; +} + + template + static bool basic_parser::parse_url_encoded(types::query_params& params, + const char *ptr, const std::size_t len) +{ + // used to track whether we are parsing the name or value + enum query_parse_state_t { + QUERY_PARSE_NAME, QUERY_PARSE_VALUE + } parse_state = QUERY_PARSE_NAME; + + // misc other variables used for parsing + const char * const end = ptr + len; + string_type query_name; + string_type query_value; + + // iterate through each encoded character + while (ptr < end) { + switch (parse_state) { + + case QUERY_PARSE_NAME: + // parsing query name + if (*ptr == '=') { + // end of name found + if (query_name.empty()) return false; + parse_state = QUERY_PARSE_VALUE; + } else if (*ptr == '&') { + // value is empty (OK) + if (query_name.empty()) return false; + params.insert( std::make_pair(query_name, query_value) ); + query_name.erase(); + } else if (is_control(*ptr) || query_name.size() >= ParserTraits::QUERY_NAME_MAX) { + // control character detected, or max sized exceeded + return false; + } else { + // character is part of the name + query_name.push_back(*ptr); + } + break; + + case QUERY_PARSE_VALUE: + // parsing query value + if (*ptr == '&') { + // end of value found (OK if empty) + params.insert( std::make_pair(query_name, query_value) ); + query_name.erase(); + query_value.erase(); + parse_state = QUERY_PARSE_NAME; + } else if (is_control(*ptr) || query_value.size() >= ParserTraits::QUERY_VALUE_MAX) { + // control character detected, or max sized exceeded + return false; + } else { + // character is part of the value + query_value.push_back(*ptr); + } + break; } - - template - static bool basic_parser::parse_url_encoded(types::query_params& params, - const char *ptr, const std::size_t len) - { - // used to track whether we are parsing the name or value - enum query_parse_state_t { - QUERY_PARSE_NAME, QUERY_PARSE_VALUE - } parse_state = QUERY_PARSE_NAME; - - // misc other variables used for parsing - const char * const end = ptr + len; - string_type query_name; - string_type query_value; - - // iterate through each encoded character - while (ptr < end) { - switch (parse_state) { - - case QUERY_PARSE_NAME: - // parsing query name - if (*ptr == '=') { - // end of name found - if (query_name.empty()) return false; - parse_state = QUERY_PARSE_VALUE; - } else if (*ptr == '&') { - // value is empty (OK) - if (query_name.empty()) return false; - params.insert( std::make_pair(query_name, query_value) ); - query_name.erase(); - } else if (is_control(*ptr) || query_name.size() >= ParserTraits::QUERY_NAME_MAX) { - // control character detected, or max sized exceeded - return false; - } else { - // character is part of the name - query_name.push_back(*ptr); - } - break; - case QUERY_PARSE_VALUE: - // parsing query value - if (*ptr == '&') { - // end of value found (OK if empty) - params.insert( std::make_pair(query_name, query_value) ); - query_name.erase(); - query_value.erase(); - parse_state = QUERY_PARSE_NAME; - } else if (is_control(*ptr) || query_value.size() >= ParserTraits::QUERY_VALUE_MAX) { - // control character detected, or max sized exceeded - return false; - } else { - // character is part of the value - query_value.push_back(*ptr); - } - break; - } - - ++ptr; + ++ptr; + } + + // handle last pair in string + if (! query_name.empty()) + params.insert( std::make_pair(query_name, query_value) ); + + return true; +} + +template +static bool basic_parser::parse_cookie_header(types::cookie_params& params, + const string_type& cookie_header) +{ + // BASED ON RFC 2109 + // + // The current implementation ignores cookie attributes which begin with '$' + // (i.e. $Path=/, $Domain=, etc.) + + // used to track what we are parsing + enum cookie_parse_state_t { + COOKIE_PARSE_NAME, COOKIE_PARSE_VALUE, COOKIE_PARSE_IGNORE + } parse_state = COOKIE_PARSE_NAME; + + // misc other variables used for parsing + string_type cookie_name; + string_type cookie_value; + char value_quote_character = '\0'; + + // iterate through each character + for (string_type::const_iterator string_iterator = cookie_header.begin(); + string_iterator != cookie_header.end(); ++string_iterator) + { + switch (parse_state) { + + case COOKIE_PARSE_NAME: + // parsing cookie name + if (*string_iterator == '=') { + // end of name found + if (cookie_name.empty()) return false; + value_quote_character = '\0'; + parse_state = COOKIE_PARSE_VALUE; + } else if (*string_iterator == ';' || *string_iterator == ',') { + // ignore empty cookie names since this may occur naturally + // when quoted values are encountered + if (! cookie_name.empty()) { + // value is empty (OK) + if (cookie_name[0] != '$') + params.insert( std::make_pair(cookie_name, cookie_value) ); + cookie_name.erase(); } - - // handle last pair in string - if (! query_name.empty()) - params.insert( std::make_pair(query_name, query_value) ); - - return true; - } - - template - static bool basic_parser::parse_cookie_header(types::cookie_params& params, - const string_type& cookie_header) - { - // BASED ON RFC 2109 - // - // The current implementation ignores cookie attributes which begin with '$' - // (i.e. $Path=/, $Domain=, etc.) - - // used to track what we are parsing - enum cookie_parse_state_t { - COOKIE_PARSE_NAME, COOKIE_PARSE_VALUE, COOKIE_PARSE_IGNORE - } parse_state = COOKIE_PARSE_NAME; - - // misc other variables used for parsing - string_type cookie_name; - string_type cookie_value; - char value_quote_character = '\0'; - - // iterate through each character - for (string_type::const_iterator string_iterator = cookie_header.begin(); - string_iterator != cookie_header.end(); ++string_iterator) - { - switch (parse_state) { - - case COOKIE_PARSE_NAME: - // parsing cookie name - if (*string_iterator == '=') { - // end of name found - if (cookie_name.empty()) return false; - value_quote_character = '\0'; - parse_state = COOKIE_PARSE_VALUE; - } else if (*string_iterator == ';' || *string_iterator == ',') { - // ignore empty cookie names since this may occur naturally - // when quoted values are encountered - if (! cookie_name.empty()) { - // value is empty (OK) - if (cookie_name[0] != '$') - params.insert( std::make_pair(cookie_name, cookie_value) ); - cookie_name.erase(); - } - } else if (*string_iterator != ' ') { // ignore whitespace - // check if control character detected, or max sized exceeded - if (is_control(*string_iterator) || cookie_name.size() >= ParserTraits::COOKIE_NAME_MAX) - return false; - // character is part of the name - // cookie names are case insensitive -> convert to lowercase - cookie_name.push_back( tolower(*string_iterator) ); - } - break; - - case COOKIE_PARSE_VALUE: - // parsing cookie value - if (value_quote_character == '\0') { - // value is not (yet) quoted - if (*string_iterator == ';' || *string_iterator == ',') { - // end of value found (OK if empty) - if (cookie_name[0] != '$') - params.insert( std::make_pair(cookie_name, cookie_value) ); - cookie_name.erase(); - cookie_value.erase(); - parse_state = COOKIE_PARSE_NAME; - } else if (*string_iterator == '\'' || *string_iterator == '"') { - if (cookie_value.empty()) { - // begin quoted value - value_quote_character = *string_iterator; - } else if (cookie_value.size() >= ParserTraits::COOKIE_VALUE_MAX) { - // max size exceeded - return false; - } else { - // assume character is part of the (unquoted) value - cookie_value.push_back(*string_iterator); - } - } else if (*string_iterator != ' ') { // ignore unquoted whitespace - // check if control character detected, or max sized exceeded - if (is_control(*string_iterator) || cookie_value.size() >= ParserTraits::COOKIE_VALUE_MAX) - return false; - // character is part of the (unquoted) value - cookie_value.push_back(*string_iterator); - } - } else { - // value is quoted - if (*string_iterator == value_quote_character) { - // end of value found (OK if empty) - if (cookie_name[0] != '$') - params.insert( std::make_pair(cookie_name, cookie_value) ); - cookie_name.erase(); - cookie_value.erase(); - parse_state = COOKIE_PARSE_IGNORE; - } else if (cookie_value.size() >= ParserTraits::COOKIE_VALUE_MAX) { - // max size exceeded - return false; - } else { - // character is part of the (quoted) value - cookie_value.push_back(*string_iterator); - } - } - break; - - case COOKIE_PARSE_IGNORE: - // ignore everything until we reach a comma "," or semicolon ";" - if (*string_iterator == ';' || *string_iterator == ',') - parse_state = COOKIE_PARSE_NAME; - break; - } + } else if (*string_iterator != ' ') { // ignore whitespace + // check if control character detected, or max sized exceeded + if (is_control(*string_iterator) || cookie_name.size() >= ParserTraits::COOKIE_NAME_MAX) + return false; + // character is part of the name + // cookie names are case insensitive -> convert to lowercase + cookie_name.push_back( tolower(*string_iterator) ); + } + break; + + case COOKIE_PARSE_VALUE: + // parsing cookie value + if (value_quote_character == '\0') { + // value is not (yet) quoted + if (*string_iterator == ';' || *string_iterator == ',') { + // end of value found (OK if empty) + if (cookie_name[0] != '$') + params.insert( std::make_pair(cookie_name, cookie_value) ); + cookie_name.erase(); + cookie_value.erase(); + parse_state = COOKIE_PARSE_NAME; + } else if (*string_iterator == '\'' || *string_iterator == '"') { + if (cookie_value.empty()) { + // begin quoted value + value_quote_character = *string_iterator; + } else if (cookie_value.size() >= ParserTraits::COOKIE_VALUE_MAX) { + // max size exceeded + return false; + } else { + // assume character is part of the (unquoted) value + cookie_value.push_back(*string_iterator); + } + } else if (*string_iterator != ' ') { // ignore unquoted whitespace + // check if control character detected, or max sized exceeded + if (is_control(*string_iterator) || cookie_value.size() >= ParserTraits::COOKIE_VALUE_MAX) + return false; + // character is part of the (unquoted) value + cookie_value.push_back(*string_iterator); } - - // handle last cookie in string - if (! cookie_name.empty() && cookie_name[0] != '$') + } else { + // value is quoted + if (*string_iterator == value_quote_character) { + // end of value found (OK if empty) + if (cookie_name[0] != '$') params.insert( std::make_pair(cookie_name, cookie_value) ); - - return true; + cookie_name.erase(); + cookie_value.erase(); + parse_state = COOKIE_PARSE_IGNORE; + } else if (cookie_value.size() >= ParserTraits::COOKIE_VALUE_MAX) { + // max size exceeded + return false; + } else { + // character is part of the (quoted) value + cookie_value.push_back(*string_iterator); + } + } + break; + + case COOKIE_PARSE_IGNORE: + // ignore everything until we reach a comma "," or semicolon ";" + if (*string_iterator == ';' || *string_iterator == ',') + parse_state = COOKIE_PARSE_NAME; + break; } + } + + // handle last cookie in string + if (! cookie_name.empty() && cookie_name[0] != '$') + params.insert( std::make_pair(cookie_name, cookie_value) ); + + return true; +} -}; // namespace http - -}; // namespace network - -}; // namespace boost +} // namespace http +} // namespace network #endif // BOOST_NETWORK_PROTOCOL_HTTP_PARSER_IPP diff --git a/include/network/protocol/http/impl/request.hpp b/include/network/protocol/http/impl/request.hpp index a257d0a39..0859a602c 100644 --- a/include/network/protocol/http/impl/request.hpp +++ b/include/network/protocol/http/impl/request.hpp @@ -1,13 +1,12 @@ - -// Copyright Dean Michael Berris 2007,2009,2010. -// Copyright Michael Dickey 2008. +// Copyright Dean Michael Berris 2007,2009,2010. +// Copyright Michael Dickey 2008. // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) -#ifndef __NETWORK_PROTOCOL_HTTP_REQUEST_IMPL_20070908_1_HPP__ -#define __NETWORK_PROTOCOL_HTTP_REQUEST_IMPL_20070908_1_HPP__ +#ifndef NETWORK_PROTOCOL_HTTP_REQUEST_IMPL_20070908_1_HPP +#define NETWORK_PROTOCOL_HTTP_REQUEST_IMPL_20070908_1_HPP #include #include @@ -26,233 +25,231 @@ #include -namespace boost { namespace network { +namespace network { - /** Specialize the traits for the http_server tag. */ - template <> - struct headers_container : - vector::apply::type> - {}; +/** Specialize the traits for the http_server tag. */ +template <> +struct headers_container : + vector::apply::type> +{}; - template <> - struct headers_container : - vector::apply::type> - {}; +template <> +struct headers_container : + vector::apply::type> +{}; namespace http { - /** request.hpp - * - * This file implements the basic request object required - * by the HTTP client implementation. The basic_request - * object encapsulates a URI which is parsed at runtime. - */ - - template - struct basic_request : public basic_message +/** request.hpp + * + * This file implements the basic request object required + * by the HTTP client implementation. The basic_request + * object encapsulates a URI which is parsed at runtime. + */ + +template +struct basic_request : public basic_message +{ + + mutable network::uri uri_; + typedef basic_message base_type; + +public: + typedef typename sync_only::type tag; + typedef typename string::type string_type; + typedef boost::uint16_t port_type; + + explicit basic_request(string_type const & uri_) + : uri_(uri_) + { } + + explicit basic_request(network::uri const & uri_) + : uri_(uri_) + { } + + void uri(string_type const & new_uri) { + uri_ = new_uri; + } + + void uri(network::uri const & new_uri) { + uri_ = new_uri; + } + + basic_request() + : base_type() + { } + + basic_request(basic_request const & other) + : base_type(other), uri_(other.uri_) + { } + + basic_request & operator=(basic_request rhs) { + rhs.swap(*this); + return *this; + } + + void swap(basic_request & other) { + base_type & base_ref(other); + basic_request & this_ref(*this); + base_ref.swap(this_ref); + boost::swap(other.uri_, this->uri_); + } + + string_type const host() const { + return uri_.host(); + } + + port_type port() const { + boost::optional port = uri::port_us(uri_); + if (!port) { - - mutable network::uri uri_; - typedef basic_message base_type; - - public: - typedef typename sync_only::type tag; - typedef typename string::type string_type; - typedef boost::uint16_t port_type; - - explicit basic_request(string_type const & uri_) - : uri_(uri_) - { } - - explicit basic_request(network::uri const & uri_) - : uri_(uri_) - { } - - void uri(string_type const & new_uri) { - uri_ = new_uri; - } - - void uri(network::uri const & new_uri) { - uri_ = new_uri; - } - - basic_request() - : base_type() - { } - - basic_request(basic_request const & other) - : base_type(other), uri_(other.uri_) - { } - - basic_request & operator=(basic_request rhs) { - rhs.swap(*this); - return *this; - } - - void swap(basic_request & other) { - base_type & base_ref(other); - basic_request & this_ref(*this); - base_ref.swap(this_ref); - boost::swap(other.uri_, this->uri_); - } - - string_type const host() const { - return uri_.host(); - } - - port_type port() const { - boost::optional port = uri::port_us(uri_); - if (!port) - { - typedef constants consts; - return boost::iequals(uri_.scheme(), - string_type(consts::https()))? 443 : 80; - } - return *port; - } - - string_type const path() const { - return uri_.path(); - } - - string_type const query() const { - return uri_.query(); - } - - string_type const anchor() const { - return uri_.fragment(); - } - - string_type const protocol() const { - return uri_.scheme(); - } - - void uri(string_type const & new_uri) const { - uri_ = new_uri; - } - - network::uri const & uri() const { - return uri_; - } - - }; - - /** This is the implementation of a POD request type - * that is specificially used by the HTTP server - * implementation. This fully specializes the - * basic_request template above to be - * primarily and be solely a POD for performance - * reasons. - * - * Reality check: This is not a POD because it contains a non-POD - * member, the headers vector. :( - */ - template - struct not_quite_pod_request_base { - typedef Tag tag; - typedef typename string::type string_type; - typedef typename request_header::type header_type; - typedef typename vector:: - template apply::type - vector_type; - typedef vector_type headers_container_type; - typedef boost::uint16_t port_type; - mutable string_type source; - mutable string_type method; - mutable string_type destination; - mutable boost::uint8_t http_version_major; - mutable boost::uint8_t http_version_minor; - mutable vector_type headers; - mutable string_type body; - - void swap(not_quite_pod_request_base & r) const { - using std::swap; - swap(method, r.method); - swap(source, r.source); - swap(destination, r.destination); - swap(http_version_major, r.http_version_major); - swap(http_version_minor, r.http_version_minor); - swap(headers, r.headers); - swap(body, r.body); - } - }; - - template <> - struct basic_request - : not_quite_pod_request_base - {}; - - template <> - struct basic_request - : not_quite_pod_request_base - {}; - - template - struct ServerRequest; - - BOOST_CONCEPT_ASSERT((ServerRequest >)); - BOOST_CONCEPT_ASSERT((ServerRequest >)); - - template - inline void swap(basic_request & lhs, basic_request & rhs) { - lhs.swap(rhs); + typedef constants consts; + return boost::iequals(uri_.scheme(), + string_type(consts::https()))? 443 : 80; } + return *port; + } + + string_type const path() const { + return uri_.path(); + } + + string_type const query() const { + return uri_.query(); + } + + string_type const anchor() const { + return uri_.fragment(); + } + + string_type const protocol() const { + return uri_.scheme(); + } + + void uri(string_type const & new_uri) const { + uri_ = new_uri; + } + + network::uri const & uri() const { + return uri_; + } + +}; + +/** This is the implementation of a POD request type + * that is specificially used by the HTTP server + * implementation. This fully specializes the + * basic_request template above to be + * primarily and be solely a POD for performance + * reasons. + * + * Reality check: This is not a POD because it contains a non-POD + * member, the headers vector. :( + */ +template +struct not_quite_pod_request_base { + typedef Tag tag; + typedef typename string::type string_type; + typedef typename request_header::type header_type; + typedef typename vector:: + template apply::type + vector_type; + typedef vector_type headers_container_type; + typedef boost::uint16_t port_type; + mutable string_type source; + mutable string_type method; + mutable string_type destination; + mutable boost::uint8_t http_version_major; + mutable boost::uint8_t http_version_minor; + mutable vector_type headers; + mutable string_type body; + + void swap(not_quite_pod_request_base & r) const { + using std::swap; + swap(method, r.method); + swap(source, r.source); + swap(destination, r.destination); + swap(http_version_major, r.http_version_major); + swap(http_version_minor, r.http_version_minor); + swap(headers, r.headers); + swap(body, r.body); + } +}; + +template <> +struct basic_request +: not_quite_pod_request_base +{}; + +template <> +struct basic_request +: not_quite_pod_request_base +{}; + +template +struct ServerRequest; + +BOOST_CONCEPT_ASSERT((ServerRequest >)); +BOOST_CONCEPT_ASSERT((ServerRequest >)); + +template +inline void swap(basic_request & lhs, basic_request & rhs) { + lhs.swap(rhs); +} } // namespace http - namespace http { namespace impl { - - template <> - struct request_headers_wrapper { - basic_request const & request_; - request_headers_wrapper(basic_request const & request_) - : request_(request_) {} - typedef headers_container::type headers_container_type; - operator headers_container_type () { - return request_.headers; - } - }; - - template <> - struct body_wrapper > { - typedef string::type string_type; - basic_request const & request_; - body_wrapper(basic_request const & request_) - : request_(request_) {} - operator string_type () { - return request_.body; - } - }; - - template <> - struct request_headers_wrapper { - basic_request const & request_; - request_headers_wrapper(basic_request const & request_) - : request_(request_) {} - typedef headers_container::type headers_container_type; - operator headers_container_type () { - return request_.headers; - } - }; - - template <> - struct body_wrapper > { - typedef string::type string_type; - basic_request const & request_; - body_wrapper(basic_request const & request_) - : request_(request_) {} - operator string_type () { - return request_.body; - } - }; - - } // namespace impl +namespace http { namespace impl { + + template <> + struct request_headers_wrapper { + basic_request const & request_; + request_headers_wrapper(basic_request const & request_) + : request_(request_) {} + typedef headers_container::type headers_container_type; + operator headers_container_type () { + return request_.headers; + } + }; + + template <> + struct body_wrapper > { + typedef string::type string_type; + basic_request const & request_; + body_wrapper(basic_request const & request_) + : request_(request_) {} + operator string_type () { + return request_.body; + } + }; + + template <> + struct request_headers_wrapper { + basic_request const & request_; + request_headers_wrapper(basic_request const & request_) + : request_(request_) {} + typedef headers_container::type headers_container_type; + operator headers_container_type () { + return request_.headers; + } + }; + + template <> + struct body_wrapper > { + typedef string::type string_type; + basic_request const & request_; + body_wrapper(basic_request const & request_) + : request_(request_) {} + operator string_type () { + return request_.body; + } + }; + +} // namespace impl } // namespace http } // namespace network -} // namespace boost - -#endif // __NETWORK_PROTOCOL_HTTP_REQUEST_IMPL_20070908_1_HPP__ +#endif // NETWORK_PROTOCOL_HTTP_REQUEST_IMPL_20070908_1_HPP diff --git a/include/network/protocol/http/impl/request_parser.ipp b/include/network/protocol/http/impl/request_parser.ipp index 885f91f2d..be3f123bd 100644 --- a/include/network/protocol/http/impl/request_parser.ipp +++ b/include/network/protocol/http/impl/request_parser.ipp @@ -13,12 +13,12 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef BOOST_NETWORK_HTTP_REQUEST_PARSER_IPP -#define BOOST_NETWORK_HTTP_REQUEST_PARSER_IPP +#ifndef NETWORK_HTTP_REQUEST_PARSER_IPP +#define NETWORK_HTTP_REQUEST_PARSER_IPP #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { template boost::tribool basic_request_parser::consume(basic_request & req, char input) @@ -323,11 +323,8 @@ bool basic_request_parser::is_digit(int c) return c >= '0' && c <= '9'; } -} // namespace http +} // namespace http +} // namespace network -} // namespace network - -} // namespace boost - -#endif //BOOST_NETWORK_HTTP_REQUEST_PARSER_IPP +#endif //NETWORK_HTTP_REQUEST_PARSER_IPP diff --git a/include/network/protocol/http/impl/response.ipp b/include/network/protocol/http/impl/response.ipp index 7513b2169..ca91e5012 100644 --- a/include/network/protocol/http/impl/response.ipp +++ b/include/network/protocol/http/impl/response.ipp @@ -1,4 +1,3 @@ -// // Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com) // Copyright (c) 2009 Dean Michael Berris (dberris@google.com) // Copyright (c) 2009 Tarroo, Inc. @@ -12,315 +11,310 @@ // to reduce the dependence on building an external library. // -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_IMPL_RESPONSE_RESPONSE_IPP -#define BOOST_NETWORK_PROTOCOL_HTTP_IMPL_RESPONSE_RESPONSE_IPP +#ifndef NETWORK_PROTOCOL_HTTP_IMPL_RESPONSE_RESPONSE_IPP +#define NETWORK_PROTOCOL_HTTP_IMPL_RESPONSE_RESPONSE_IPP #include #include #include -namespace boost { namespace network { namespace http { - +namespace network { namespace http { + /// A reply to be sent to a client. template class Vector = std::vector> struct basic_response : response_base { - /// The status of the reply. - enum status_type { - ok = 200, - created = 201, - accepted = 202, - no_content = 204, - multiple_choices = 300, - moved_permanently = 301, - moved_temporarily = 302, - not_modified = 304, - bad_request = 400, - unauthorized = 401, - forbidden = 403, - not_found = 404, - not_supported = 405, - not_acceptable = 406, - internal_server_error = 500, - not_implemented = 501, - bad_gateway = 502, - service_unavailable = 503 - } status; - - /// The headers to be included in the reply. - typedef Vector > headers_vector; - headers_vector headers; + /// The status of the reply. + enum status_type { + ok = 200, + created = 201, + accepted = 202, + no_content = 204, + multiple_choices = 300, + moved_permanently = 301, + moved_temporarily = 302, + not_modified = 304, + bad_request = 400, + unauthorized = 401, + forbidden = 403, + not_found = 404, + not_supported = 405, + not_acceptable = 406, + internal_server_error = 500, + not_implemented = 501, + bad_gateway = 502, + service_unavailable = 503 + } status; + + /// The headers to be included in the reply. + typedef Vector > headers_vector; + headers_vector headers; - /// Convert the reply into a vector of buffers. The buffers do not own the - /// underlying memory blocks, therefore the reply object must remain valid and - /// not be changed until the write operation has completed. - std::vector to_buffers() { - // FIXME: Rethink this and do this asynchronously. - using boost::asio::const_buffer; - using boost::asio::buffer; - static const char name_value_separator[] = { ':', ' ' }; - static const char crlf[] = { '\r', '\n' }; - std::vector buffers; - buffers.push_back(to_buffer(status)); - for (std::size_t i = 0; i < headers.size(); ++i) { - response_header & h = headers[i]; - buffers.push_back(buffer(h.name)); - buffers.push_back(buffer(name_value_separator)); - buffers.push_back(buffer(h.value)); - buffers.push_back(buffer(crlf)); - } - buffers.push_back(buffer(crlf)); - return buffers; + /// Convert the reply into a vector of buffers. The buffers do not own the + /// underlying memory blocks, therefore the reply object must remain valid and + /// not be changed until the write operation has completed. + std::vector to_buffers() { + // FIXME: Rethink this and do this asynchronously. + using boost::asio::const_buffer; + using boost::asio::buffer; + static const char name_value_separator[] = { ':', ' ' }; + static const char crlf[] = { '\r', '\n' }; + std::vector buffers; + buffers.push_back(to_buffer(status)); + for (std::size_t i = 0; i < headers.size(); ++i) { + response_header & h = headers[i]; + buffers.push_back(buffer(h.name)); + buffers.push_back(buffer(name_value_separator)); + buffers.push_back(buffer(h.value)); + buffers.push_back(buffer(crlf)); } + buffers.push_back(buffer(crlf)); + return buffers; + } - /// Get a stock reply. - static basic_response stock_reply(status_type status) { - return stock_reply(status, to_string(status)); - } + /// Get a stock reply. + static basic_response stock_reply(status_type status) { + return stock_reply(status, to_string(status)); + } - /// Get a stock reply with custom plain text data. - static basic_response stock_reply(status_type status, String const & content) { - using boost::lexical_cast; - basic_response rep; - rep.status = status; - rep.content = content; - rep.headers.resize(2); - rep.headers[0].name = "Content-Length"; - rep.headers[0].value = lexical_cast(rep.content.size()); - rep.headers[1].name = "Content-Type"; - rep.headers[1].value = "text/html"; - return rep; - } + /// Get a stock reply with custom plain text data. + static basic_response stock_reply(status_type status, String const & content) { + using boost::lexical_cast; + basic_response rep; + rep.status = status; + rep.content = content; + rep.headers.resize(2); + rep.headers[0].name = "Content-Length"; + rep.headers[0].value = lexical_cast(rep.content.size()); + rep.headers[1].name = "Content-Type"; + rep.headers[1].value = "text/html"; + return rep; + } - /// Swap response objects - void swap(basic_response &r) { - using std::swap; - swap(headers, r.headers); - // swap(content, r.content); - } + /// Swap response objects + void swap(basic_response &r) { + using std::swap; + swap(headers, r.headers); + // swap(content, r.content); + } - private: - - static String to_string(status_type status) { - static const char ok[] = ""; - static const char created[] = - "" - "Created" - "

201 Created

" - ""; - static const char accepted[] = - "" - "Accepted" - "

202 Accepted

" - ""; - static const char no_content[] = - "" - "No Content" - "

204 Content

" - ""; - static const char multiple_choices[] = - "" - "Multiple Choices" - "

300 Multiple Choices

" - ""; - static const char moved_permanently[] = - "" - "Moved Permanently" - "

301 Moved Permanently

" - ""; - static const char moved_temporarily[] = - "" - "Moved Temporarily" - "

302 Moved Temporarily

" - ""; - static const char not_modified[] = - "" - "Not Modified" - "

304 Not Modified

" - ""; - static const char bad_request[] = - "" - "Bad Request" - "

400 Bad Request

" - ""; - static const char unauthorized[] = - "" - "Unauthorized" - "

401 Unauthorized

" - ""; - static const char forbidden[] = - "" - "Forbidden" - "

403 Forbidden

" - ""; - static const char not_found[] = - "" - "Not Found" - "

404 Not Found

" - ""; - static const char not_supported[] = - "" - "Method Not Supported" - "

Method Not Supported

" - ""; - static const char not_acceptable[] = - "" - "Request Not Acceptable" - "

Request Not Acceptable

" - ""; - static const char internal_server_error[] = - "" - "Internal Server Error" - "

500 Internal Server Error

" - ""; - static const char not_implemented[] = - "" - "Not Implemented" - "

501 Not Implemented

" - ""; - static const char bad_gateway[] = - "" - "Bad Gateway" - "

502 Bad Gateway

" - ""; - static const char service_unavailable[] = - "" - "Service Unavailable" - "

503 Service Unavailable

" - ""; + private: + + static String to_string(status_type status) { + static const char ok[] = ""; + static const char created[] = + "" + "Created" + "

201 Created

" + ""; + static const char accepted[] = + "" + "Accepted" + "

202 Accepted

" + ""; + static const char no_content[] = + "" + "No Content" + "

204 Content

" + ""; + static const char multiple_choices[] = + "" + "Multiple Choices" + "

300 Multiple Choices

" + ""; + static const char moved_permanently[] = + "" + "Moved Permanently" + "

301 Moved Permanently

" + ""; + static const char moved_temporarily[] = + "" + "Moved Temporarily" + "

302 Moved Temporarily

" + ""; + static const char not_modified[] = + "" + "Not Modified" + "

304 Not Modified

" + ""; + static const char bad_request[] = + "" + "Bad Request" + "

400 Bad Request

" + ""; + static const char unauthorized[] = + "" + "Unauthorized" + "

401 Unauthorized

" + ""; + static const char forbidden[] = + "" + "Forbidden" + "

403 Forbidden

" + ""; + static const char not_found[] = + "" + "Not Found" + "

404 Not Found

" + ""; + static const char not_supported[] = + "" + "Method Not Supported" + "

Method Not Supported

" + ""; + static const char not_acceptable[] = + "" + "Request Not Acceptable" + "

Request Not Acceptable

" + ""; + static const char internal_server_error[] = + "" + "Internal Server Error" + "

500 Internal Server Error

" + ""; + static const char not_implemented[] = + "" + "Not Implemented" + "

501 Not Implemented

" + ""; + static const char bad_gateway[] = + "" + "Bad Gateway" + "

502 Bad Gateway

" + ""; + static const char service_unavailable[] = + "" + "Service Unavailable" + "

503 Service Unavailable

" + ""; - switch (status) - { - case basic_response::ok: - return ok; - case basic_response::created: - return created; - case basic_response::accepted: - return accepted; - case basic_response::no_content: - return no_content; - case basic_response::multiple_choices: - return multiple_choices; - case basic_response::moved_permanently: - return moved_permanently; - case basic_response::moved_temporarily: - return moved_temporarily; - case basic_response::not_modified: - return not_modified; - case basic_response::bad_request: - return bad_request; - case basic_response::unauthorized: - return unauthorized; - case basic_response::forbidden: - return forbidden; - case basic_response::not_found: - return not_found; - case basic_response::not_supported: - return not_supported; - case basic_response::not_acceptable: - return not_acceptable; - case basic_response::internal_server_error: - return internal_server_error; - case basic_response::not_implemented: - return not_implemented; - case basic_response::bad_gateway: - return bad_gateway; - case basic_response::service_unavailable: - return service_unavailable; - default: - return internal_server_error; - } - } + switch (status) + { + case basic_response::ok: + return ok; + case basic_response::created: + return created; + case basic_response::accepted: + return accepted; + case basic_response::no_content: + return no_content; + case basic_response::multiple_choices: + return multiple_choices; + case basic_response::moved_permanently: + return moved_permanently; + case basic_response::moved_temporarily: + return moved_temporarily; + case basic_response::not_modified: + return not_modified; + case basic_response::bad_request: + return bad_request; + case basic_response::unauthorized: + return unauthorized; + case basic_response::forbidden: + return forbidden; + case basic_response::not_found: + return not_found; + case basic_response::not_supported: + return not_supported; + case basic_response::not_acceptable: + return not_acceptable; + case basic_response::internal_server_error: + return internal_server_error; + case basic_response::not_implemented: + return not_implemented; + case basic_response::bad_gateway: + return bad_gateway; + case basic_response::service_unavailable: + return service_unavailable; + default: + return internal_server_error; + } + } - boost::asio::const_buffer to_buffer(status_type status) { - using boost::asio::buffer; - static const String ok = - "HTTP/1.0 200 OK\r\n"; - static const String created = - "HTTP/1.0 201 Created\r\n"; - static const String accepted = - "HTTP/1.0 202 Accepted\r\n"; - static const String no_content = - "HTTP/1.0 204 No Content\r\n"; - static const String multiple_choices = - "HTTP/1.0 300 Multiple Choices\r\n"; - static const String moved_permanently = - "HTTP/1.0 301 Moved Permanently\r\n"; - static const String moved_temporarily = - "HTTP/1.0 302 Moved Temporarily\r\n"; - static const String not_modified = - "HTTP/1.0 304 Not Modified\r\n"; - static const String bad_request = - "HTTP/1.0 400 Bad Request\r\n"; - static const String unauthorized = - "HTTP/1.0 401 Unauthorized\r\n"; - static const String forbidden = - "HTTP/1.0 403 Forbidden\r\n"; - static const String not_found = - "HTTP/1.0 404 Not Found\r\n"; - static const String not_supported = - "HTTP/1.0 405 Method Not Supported\r\n"; - static const String not_acceptable = - "HTTP/1.0 406 Method Not Acceptable\r\n"; - static const String internal_server_error = - "HTTP/1.0 500 Internal Server Error\r\n"; - static const String not_implemented = - "HTTP/1.0 501 Not Implemented\r\n"; - static const String bad_gateway = - "HTTP/1.0 502 Bad Gateway\r\n"; - static const String service_unavailable = - "HTTP/1.0 503 Service Unavailable\r\n"; + boost::asio::const_buffer to_buffer(status_type status) { + using boost::asio::buffer; + static const String ok = + "HTTP/1.0 200 OK\r\n"; + static const String created = + "HTTP/1.0 201 Created\r\n"; + static const String accepted = + "HTTP/1.0 202 Accepted\r\n"; + static const String no_content = + "HTTP/1.0 204 No Content\r\n"; + static const String multiple_choices = + "HTTP/1.0 300 Multiple Choices\r\n"; + static const String moved_permanently = + "HTTP/1.0 301 Moved Permanently\r\n"; + static const String moved_temporarily = + "HTTP/1.0 302 Moved Temporarily\r\n"; + static const String not_modified = + "HTTP/1.0 304 Not Modified\r\n"; + static const String bad_request = + "HTTP/1.0 400 Bad Request\r\n"; + static const String unauthorized = + "HTTP/1.0 401 Unauthorized\r\n"; + static const String forbidden = + "HTTP/1.0 403 Forbidden\r\n"; + static const String not_found = + "HTTP/1.0 404 Not Found\r\n"; + static const String not_supported = + "HTTP/1.0 405 Method Not Supported\r\n"; + static const String not_acceptable = + "HTTP/1.0 406 Method Not Acceptable\r\n"; + static const String internal_server_error = + "HTTP/1.0 500 Internal Server Error\r\n"; + static const String not_implemented = + "HTTP/1.0 501 Not Implemented\r\n"; + static const String bad_gateway = + "HTTP/1.0 502 Bad Gateway\r\n"; + static const String service_unavailable = + "HTTP/1.0 503 Service Unavailable\r\n"; - switch (status) { - case basic_response::ok: - return buffer(ok); - case basic_response::created: - return buffer(created); - case basic_response::accepted: - return buffer(accepted); - case basic_response::no_content: - return buffer(no_content); - case basic_response::multiple_choices: - return buffer(multiple_choices); - case basic_response::moved_permanently: - return buffer(moved_permanently); - case basic_response::moved_temporarily: - return buffer(moved_temporarily); - case basic_response::not_modified: - return buffer(not_modified); - case basic_response::bad_request: - return buffer(bad_request); - case basic_response::unauthorized: - return buffer(unauthorized); - case basic_response::forbidden: - return buffer(forbidden); - case basic_response::not_found: - return buffer(not_found); - case basic_response::not_supported: - return buffer(not_supported); - case basic_response::not_acceptable: - return buffer(not_acceptable); - case basic_response::internal_server_error: - return buffer(internal_server_error); - case basic_response::not_implemented: - return buffer(not_implemented); - case basic_response::bad_gateway: - return buffer(bad_gateway); - case basic_response::service_unavailable: - return buffer(service_unavailable); - default: - return buffer(internal_server_error); - } + switch (status) { + case basic_response::ok: + return buffer(ok); + case basic_response::created: + return buffer(created); + case basic_response::accepted: + return buffer(accepted); + case basic_response::no_content: + return buffer(no_content); + case basic_response::multiple_choices: + return buffer(multiple_choices); + case basic_response::moved_permanently: + return buffer(moved_permanently); + case basic_response::moved_temporarily: + return buffer(moved_temporarily); + case basic_response::not_modified: + return buffer(not_modified); + case basic_response::bad_request: + return buffer(bad_request); + case basic_response::unauthorized: + return buffer(unauthorized); + case basic_response::forbidden: + return buffer(forbidden); + case basic_response::not_found: + return buffer(not_found); + case basic_response::not_supported: + return buffer(not_supported); + case basic_response::not_acceptable: + return buffer(not_acceptable); + case basic_response::internal_server_error: + return buffer(internal_server_error); + case basic_response::not_implemented: + return buffer(not_implemented); + case basic_response::bad_gateway: + return buffer(bad_gateway); + case basic_response::service_unavailable: + return buffer(service_unavailable); + default: + return buffer(internal_server_error); } - + } }; } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_IMPL_RESPONSE_RESPONSE_IPP - +#endif // NETWORK_PROTOCOL_HTTP_IMPL_RESPONSE_RESPONSE_IPP diff --git a/include/network/protocol/http/message/async_message.hpp b/include/network/protocol/http/message/async_message.hpp index 9b0e01ed3..b161887cf 100644 --- a/include/network/protocol/http/message/async_message.hpp +++ b/include/network/protocol/http/message/async_message.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_ASYNC_MESSAGE_HPP_20100622 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_ASYNC_MESSAGE_HPP_20100622 - // Copyright 2010 (c) Dean Michael Berris // Copyright 2010 (c) Sinefunc, Inc. // Copyright 2011 Dean Michael Berris (dberris@google.com). @@ -9,6 +6,9 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_PROTOCOL_HTTP_MESSAGE_ASYNC_MESSAGE_HPP_20100622 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_ASYNC_MESSAGE_HPP_20100622 + #include #include #include @@ -18,151 +18,146 @@ #include #include -namespace boost { namespace network { namespace http { - - namespace impl { - - template - struct ready_wrapper; - - } /* impl */ - - template - struct async_message { - - typedef typename string::type string_type; - typedef typename headers_container::type headers_container_type; - typedef typename headers_container_type::value_type header_type; - - async_message() - : status_message_(), - version_(), - source_(), - destination_(), - status_(), - headers_(), - body_() - {} - - async_message(async_message const & other) - : status_message_(other.status_message_), - version_(other.version_), - source_(other.source_), - destination_(other.destination_), - status_(other.status_), - headers_(other.headers_), - body_(other.body_) - {} - - string_type const status_message() const { - return status_message_.get(); - } - - void status_message(boost::shared_future const & future) const { - status_message_ = future; - } - - string_type const version() const { - return version_.get(); - } - - void version(boost::shared_future const & future) const { - version_ = future; - } - - boost::uint16_t status() const { - return status_.get(); - } - - void status(boost::shared_future const & future) const { - status_ = future; - } - - string_type const source() const { - return source_.get(); - } - - void source(boost::shared_future const & future) const { - source_ = future; - } - - string_type const destination() const { - return destination_.get(); - } - - void destination(boost::shared_future const & future) const { - destination_ = future; - } - - headers_container_type const & headers() const { - if (retrieved_headers_) return *retrieved_headers_; - headers_container_type raw_headers = headers_.get(); - raw_headers.insert(added_headers.begin(), added_headers.end()); - BOOST_FOREACH(string_type const & key, removed_headers) { - raw_headers.erase(key); - } - retrieved_headers_ = raw_headers; - return *retrieved_headers_; - } - - void headers(boost::shared_future const & future) const { - headers_ = future; - } - - void add_header(typename headers_container_type::value_type const & pair_) const { - added_headers.insert(added_headers.end(), pair_); - } - - void remove_header(typename headers_container_type::key_type const & key_) const { - removed_headers.insert(key_); - } - - string_type const body() const { - return body_.get(); - } - - void body(boost::shared_future const & future) const { - body_ = future; - } - - void swap(async_message & other) { - std::swap(status_message_, other.status_message_); - std::swap(status_, other.status_); - std::swap(version_, other.version_); - std::swap(source_, other.source_); - std::swap(destination_, other.destination_); - std::swap(headers_, other.headers_); - std::swap(body_, other.body_); - } - - async_message & operator=(async_message other) { - other.swap(*this); - return *this; - } - - private: - - mutable boost::shared_future status_message_, - version_, source_, destination_; - mutable boost::shared_future status_; - mutable boost::shared_future headers_; - mutable headers_container_type added_headers; - mutable std::set removed_headers; - mutable boost::shared_future body_; - mutable boost::optional retrieved_headers_; - - friend struct boost::network::http::impl::ready_wrapper; - }; - - template - inline void swap(async_message & lhs, async_message & rhs) { - lhs.swap(rhs); +namespace network { +namespace http { +namespace impl { +template +struct ready_wrapper; +} // namespace impl + +template +struct async_message { + + typedef typename string::type string_type; + typedef typename headers_container::type headers_container_type; + typedef typename headers_container_type::value_type header_type; + + async_message() + : status_message_(), + version_(), + source_(), + destination_(), + status_(), + headers_(), + body_() + {} + + async_message(async_message const & other) + : status_message_(other.status_message_), + version_(other.version_), + source_(other.source_), + destination_(other.destination_), + status_(other.status_), + headers_(other.headers_), + body_(other.body_) + {} + + string_type const status_message() const { + return status_message_.get(); + } + + void status_message(boost::shared_future const & future) const { + status_message_ = future; + } + + string_type const version() const { + return version_.get(); + } + + void version(boost::shared_future const & future) const { + version_ = future; + } + + boost::uint16_t status() const { + return status_.get(); + } + + void status(boost::shared_future const & future) const { + status_ = future; + } + + string_type const source() const { + return source_.get(); + } + + void source(boost::shared_future const & future) const { + source_ = future; + } + + string_type const destination() const { + return destination_.get(); + } + + void destination(boost::shared_future const & future) const { + destination_ = future; + } + + headers_container_type const & headers() const { + if (retrieved_headers_) return *retrieved_headers_; + headers_container_type raw_headers = headers_.get(); + raw_headers.insert(added_headers.begin(), added_headers.end()); + FOREACH(string_type const & key, removed_headers) { + raw_headers.erase(key); } - -} // namespace http - -} // namespace network - -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_ASYNC_MESSAGE_HPP_20100622 + retrieved_headers_ = raw_headers; + return *retrieved_headers_; + } + + void headers(boost::shared_future const & future) const { + headers_ = future; + } + + void add_header(typename headers_container_type::value_type const & pair_) const { + added_headers.insert(added_headers.end(), pair_); + } + + void remove_header(typename headers_container_type::key_type const & key_) const { + removed_headers.insert(key_); + } + + string_type const body() const { + return body_.get(); + } + + void body(boost::shared_future const & future) const { + body_ = future; + } + + void swap(async_message & other) { + std::swap(status_message_, other.status_message_); + std::swap(status_, other.status_); + std::swap(version_, other.version_); + std::swap(source_, other.source_); + std::swap(destination_, other.destination_); + std::swap(headers_, other.headers_); + std::swap(body_, other.body_); + } + + async_message & operator=(async_message other) { + other.swap(*this); + return *this; + } + +private: + + mutable boost::shared_future status_message_, + version_, source_, destination_; + mutable boost::shared_future status_; + mutable boost::shared_future headers_; + mutable headers_container_type added_headers; + mutable std::set removed_headers; + mutable boost::shared_future body_; + mutable boost::optional retrieved_headers_; + + friend struct boost::network::http::impl::ready_wrapper; +}; + +template +inline void swap(async_message & lhs, async_message & rhs) { + lhs.swap(rhs); +} + +} // namespace http +} // namespace network + +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_ASYNC_MESSAGE_HPP_20100622 diff --git a/include/network/protocol/http/message/directives.hpp b/include/network/protocol/http/message/directives.hpp index f247f915c..dbdc49413 100644 --- a/include/network/protocol/http/message/directives.hpp +++ b/include/network/protocol/http/message/directives.hpp @@ -1,16 +1,16 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_HPP_20111201 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_HPP_20111201 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_HPP_20111201 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_HPP_20111201 + #include #include #include #include #include -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_HPP_20111201 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_HPP_20111201 diff --git a/include/network/protocol/http/message/directives/major_version.hpp b/include/network/protocol/http/message/directives/major_version.hpp index 231ff3dc3..7a158c120 100644 --- a/include/network/protocol/http/message/directives/major_version.hpp +++ b/include/network/protocol/http/message/directives/major_version.hpp @@ -1,15 +1,15 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_MAJOR_VERSION_HPP_20101120 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_MAJOR_VERSION_HPP_20101120 - // Copyright 2010 Dean Michael Berris. // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_MAJOR_VERSION_HPP_20101120 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_MAJOR_VERSION_HPP_20101120 + #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { struct major_version_directive { boost::uint8_t major_version; @@ -22,10 +22,7 @@ major_version(boost::uint8_t major_version_) { return major_version_directive(major_version_); } -} /* http */ - -} /* network */ - -} /* boost */ +} // namespace http +} // namespace network -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_MAJOR_VERSION_HPP_20101120 */ +#endif /* NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_MAJOR_VERSION_HPP_20101120 */ diff --git a/include/network/protocol/http/message/directives/method.hpp b/include/network/protocol/http/message/directives/method.hpp index 5e6af91c9..6d3f914d2 100644 --- a/include/network/protocol/http/message/directives/method.hpp +++ b/include/network/protocol/http/message/directives/method.hpp @@ -1,20 +1,18 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_METHOD_HPP_20101120 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_METHOD_HPP_20101120 - // Copyright 2010 Dean Michael Berris. // Copyright 2012 Google, Inc. // 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) -namespace boost { namespace network { namespace http { - - BOOST_NETWORK_STRING_DIRECTIVE(method); +#ifndef NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_METHOD_HPP_20101120 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_METHOD_HPP_20101120 -} /* http */ +namespace network { +namespace http { -} /* network */ - -} /* booet */ +NETWORK_STRING_DIRECTIVE(method); -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_METHOD_HPP_20101120 */ +} // namespace http +} // namespace network + +#endif /* NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_METHOD_HPP_20101120 */ diff --git a/include/network/protocol/http/message/directives/minor_version.hpp b/include/network/protocol/http/message/directives/minor_version.hpp index 5fbfc3a10..90c2c48e3 100644 --- a/include/network/protocol/http/message/directives/minor_version.hpp +++ b/include/network/protocol/http/message/directives/minor_version.hpp @@ -1,41 +1,39 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_MINOR_VERSION_HPP_20101120 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_MINOR_VERSION_HPP_20101120 - // Copyright 2010 Dean Michael Berris. // Copyright 2012 Google, Inc. // 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 BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_MINOR_VERSION_HPP_20101120 +#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_MINOR_VERSION_HPP_20101120 + #include #include #include -namespace boost { namespace network { namespace http { - - template - struct basic_request; - - struct minor_version_directive { - boost::uint8_t minor_version; - explicit minor_version_directive(boost::uint8_t minor_version) - : minor_version(minor_version) {} - template - void operator()(basic_request & request) const { - request.http_version_minor = minor_version; - } - }; - - inline minor_version_directive - minor_version(boost::uint8_t minor_version_) { - return minor_version_directive(minor_version_); - } - -} /* http */ - -} /* network */ - -} /* boost */ - +namespace network { +namespace http { + +template +struct basic_request; + +struct minor_version_directive { + boost::uint8_t minor_version; + explicit minor_version_directive(boost::uint8_t minor_version) + : minor_version(minor_version) {} + template + void operator()(basic_request & request) const { + request.http_version_minor = minor_version; + } +}; + +inline minor_version_directive +minor_version(boost::uint8_t minor_version_) { + return minor_version_directive(minor_version_); +} + +} // namespace http +} // namespace network + #endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_MINOR_VERSION_HPP_20101120 */ diff --git a/include/network/protocol/http/message/directives/status.hpp b/include/network/protocol/http/message/directives/status.hpp index bd7ecb91f..4afc7e438 100644 --- a/include/network/protocol/http/message/directives/status.hpp +++ b/include/network/protocol/http/message/directives/status.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_STATUS_HPP_20100603 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_STATUS_HPP_20100603 - // Copyright 2010 (c) Sinefunc, Inc. // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. @@ -8,12 +5,16 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_STATUS_HPP_20100603 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_STATUS_HPP_20100603 + #include #include #include #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { struct status_directive { explicit status_directive(std::string const & s); @@ -27,10 +28,7 @@ inline status_directive status(std::string const & response) { return status_directive(response); } -} // namespace http - -} // namespace network - -} // namespace boost +} // namespace http +} // namespace network -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_STATUS_HPP_20100603 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_STATUS_HPP_20100603 diff --git a/include/network/protocol/http/message/directives/status_message.hpp b/include/network/protocol/http/message/directives/status_message.hpp index f2890be85..35c3c192f 100644 --- a/include/network/protocol/http/message/directives/status_message.hpp +++ b/include/network/protocol/http/message/directives/status_message.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_STATUS_MESSAGE_HPP_20100603 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_STATUS_MESSAGE_HPP_20100603 - // Copyright 2010 (c) Dean Michael Berris // Copyright 2010 (c) Sinefunc, Inc. // Copyright 2012 Google, Inc. @@ -8,16 +5,17 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include - -namespace boost { namespace network { namespace http { +#ifndef NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_STATUS_MESSAGE_HPP_20100603 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_STATUS_MESSAGE_HPP_20100603 - BOOST_NETWORK_STRING_DIRECTIVE(status_message); +#include -} // namespace http +namespace network { +namespace http { -} // namespace network +NETWORK_STRING_DIRECTIVE(status_message); -} // namespace boost +} // namespace http +} // namespace network -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_STATUS_MESSAGE_HPP_20100603 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_STATUS_MESSAGE_HPP_20100603 diff --git a/include/network/protocol/http/message/directives/uri.hpp b/include/network/protocol/http/message/directives/uri.hpp index bf1058e60..66567673e 100644 --- a/include/network/protocol/http/message/directives/uri.hpp +++ b/include/network/protocol/http/message/directives/uri.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_URI_HPP_20100620 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_URI_HPP_20100620 - // Copyright 2010 (c) Dean Michael Berris // Copyright 2010 (c) Sinefunc, Inc. // Copyright 2012 Google, Inc. @@ -8,16 +5,17 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_URI_HPP_20100620 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_URI_HPP_20100620 + #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { - BOOST_NETWORK_STRING_DIRECTIVE(uri); +NETWORK_STRING_DIRECTIVE(uri); } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_URI_HPP_20100620 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_URI_HPP_20100620 diff --git a/include/network/protocol/http/message/directives/version.hpp b/include/network/protocol/http/message/directives/version.hpp index 13ba37d12..b8f9d7b60 100644 --- a/include/network/protocol/http/message/directives/version.hpp +++ b/include/network/protocol/http/message/directives/version.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_VERSION_HPP_20100603 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_VERSION_HPP_20100603 - // Copyright 2010 (c) Dean Michael Berris // Copyright 2010 (c) Sinefunc, Inc. // Copyright 2012 Google, Inc. @@ -8,17 +5,17 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_VERSION_HPP_20100603 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_VERSION_HPP_20100603 + #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { - BOOST_NETWORK_STRING_DIRECTIVE(version); +NETWORK_STRING_DIRECTIVE(version); } // namespace http - } // namespace network -} // namespace boost - - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_VERSION_HPP_20100603 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_VERSION_HPP_20100603 diff --git a/include/network/protocol/http/message/header.hpp b/include/network/protocol/http/message/header.hpp index 5d5579ecb..404cc3f02 100644 --- a/include/network/protocol/http/message/header.hpp +++ b/include/network/protocol/http/message/header.hpp @@ -11,8 +11,8 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_HPP_20101122 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_HPP_20101122 +#ifndef NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_HPP_20101122 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_HPP_20101122 #include #include @@ -20,42 +20,40 @@ #include #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { - struct request_header { - std::string name, value; - }; +struct request_header { + std::string name, value; +}; - inline void swap(request_header & l, request_header & r) { - swap(l.name, r.name); - swap(l.value, r.value); - } +inline void swap(request_header & l, request_header & r) { + swap(l.name, r.name); + swap(l.value, r.value); +} - struct response_header { - std::string name, value; - }; +struct response_header { + std::string name, value; +}; - inline void swap(response_header & l, response_header & r) { - std::swap(l.name, r.name); - std::swap(l.value, r.value); - } +inline void swap(response_header & l, response_header & r) { + std::swap(l.name, r.name); + std::swap(l.value, r.value); +} -} // namespace http +} // namespace http +} // namespace network -} // namespace network +FUSION_ADAPT_STRUCT( + boost::network::http::request_header, + (std::string, name) + (std::string, value) + ) -} // namespace boost +FUSION_ADAPT_STRUCT( + boost::network::http::response_header, + (std::string, name) + (std::string, value) + ) -BOOST_FUSION_ADAPT_STRUCT( - boost::network::http::request_header, - (std::string, name) - (std::string, value) - ) - -BOOST_FUSION_ADAPT_STRUCT( - boost::network::http::response_header, - (std::string, name) - (std::string, value) - ) - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_HPP_20101122 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_HPP_20101122 diff --git a/include/network/protocol/http/message/header/name.hpp b/include/network/protocol/http/message/header/name.hpp index 55c6210d8..4676608cd 100644 --- a/include/network/protocol/http/message/header/name.hpp +++ b/include/network/protocol/http/message/header/name.hpp @@ -1,37 +1,35 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_NAME_HPP_20101028 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_NAME_HPP_20101028 - // Copyright 2010 Dean Michael Berris. // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_NAME_HPP_20101028 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_NAME_HPP_20101028 + #include #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { - template - T1 & - name(std::pair const & p) { - return p.first; - } +template +T1 & +name(std::pair const & p) { + return p.first; +} - inline std::string const & - name(request_header const & h) { - return h.name; - } +inline std::string const & +name(request_header const & h) { + return h.name; +} - inline std::string const & - name(response_header const & h) { - return h.name; - } +inline std::string const & +name(response_header const & h) { + return h.name; +} -} /* http */ - -} /* network */ - -} /* boost */ +} // namespace http +} // namespace network -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_NAME_HPP_20101028 */ +#endif /* NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_NAME_HPP_20101028 */ diff --git a/include/network/protocol/http/message/header/value.hpp b/include/network/protocol/http/message/header/value.hpp index 6aa2c35b1..96feabab6 100644 --- a/include/network/protocol/http/message/header/value.hpp +++ b/include/network/protocol/http/message/header/value.hpp @@ -1,40 +1,37 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_VALUE_HPP_20101028 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_VALUE_HPP_20101028 - // Copyright 2010 Dean Michael Berris. // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_VALUE_HPP_20101028 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_VALUE_HPP_20101028 + #include #include -namespace boost { namespace network { namespace http { - - struct request_header; - struct response_header; +namespace network { namespace http { - template - T1 & value(std::pair const & p) { - return p.second; - } +struct request_header; +struct response_header; - inline std::string const & - value(request_header const & h) { - return h.value; - } +template +T1 & value(std::pair const & p) { + return p.second; +} - inline std::string const & - value(response_header const & h) { - return h.value; - } +inline std::string const & +value(request_header const & h) { + return h.value; +} -} /* http */ - -} /* network */ - -} /* boost */ +inline std::string const & +value(response_header const & h) { + return h.value; +} -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_VALUE_HPP_20101028 */ +} // namespace http +} // namespace network + +#endif /* NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_VALUE_HPP_20101028 */ diff --git a/include/network/protocol/http/message/header_concept.hpp b/include/network/protocol/http/message/header_concept.hpp index cd44d9016..95be4b557 100644 --- a/include/network/protocol/http/message/header_concept.hpp +++ b/include/network/protocol/http/message/header_concept.hpp @@ -1,39 +1,36 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_CONCEPT_HPP_20101028 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_CONCEPT_HPP_20101028 - // Copyright 2010 Dean Michael Berris. // Copyright 2012 Google, Inc. // 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) -namespace boost { namespace network { namespace http { - - template - struct Header - : DefaultConstructible - , Assignable - , CopyConstructible - { +#ifndef NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_CONCEPT_HPP_20101028 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_CONCEPT_HPP_20101028 + +namespace network { namespace http { - BOOST_CONCEPT_USAGE(Header) { - typedef typename H::string_type string_type; - string_type name_ = name(header); - string_type value_ = value(header); - H h1, h2; - swap(h1,h2); // ADL Swap! - (void)name_; - (void)value_; - } +template +struct Header + : DefaultConstructible + , Assignable + , CopyConstructible +{ - private: - H header; - }; + BOOST_CONCEPT_USAGE(Header) { + typedef typename H::string_type string_type; + string_type name_ = name(header); + string_type value_ = value(header); + H h1, h2; + swap(h1,h2); // ADL Swap! + (void)name_; + (void)value_; + } -} /* http */ - -} /* network */ - -} /* boost */ +private: + H header; +}; -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_CONCEPT_HPP_20101028 */ +} // namespace http +} // namespace network + +#endif /* NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_CONCEPT_HPP_20101028 */ diff --git a/include/network/protocol/http/message/modifiers.hpp b/include/network/protocol/http/message/modifiers.hpp index 9529d6312..dad29a25c 100644 --- a/include/network/protocol/http/message/modifiers.hpp +++ b/include/network/protocol/http/message/modifiers.hpp @@ -1,16 +1,16 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_HPP_20111201 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_HPP_20111201 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_HPP_20111201 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_HPP_20111201 + #include #include #include #include #include -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_HPP_20111201 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_HPP_20111201 diff --git a/include/network/protocol/http/message/modifiers/major_version.hpp b/include/network/protocol/http/message/modifiers/major_version.hpp index 7b25d7b24..cac881bae 100644 --- a/include/network/protocol/http/message/modifiers/major_version.hpp +++ b/include/network/protocol/http/message/modifiers/major_version.hpp @@ -1,31 +1,29 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_MAJOR_VERSION_HPP_20101120 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_MAJOR_VERSION_HPP_20101120 - // Copyright 2010 Dean Michael Berris. // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_MAJOR_VERSION_HPP_20101120 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_MAJOR_VERSION_HPP_20101120 + #include #include #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { - template - struct basic_request; +template +struct basic_request; - template - inline typename enable_if, void>::type - major_version(basic_request & request, boost::uint8_t major_version_) { - request.http_version_major = major_version_; - } +template +inline typename enable_if, void>::type +major_version(basic_request & request, boost::uint8_t major_version_) { + request.http_version_major = major_version_; +} -} /* http */ +} // namespace http +} // namespace network -} /* network */ - -} /* boost */ - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_MAJOR_VERSION_HPP_20101120 */ +#endif /* NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_MAJOR_VERSION_HPP_20101120 */ diff --git a/include/network/protocol/http/message/modifiers/method.hpp b/include/network/protocol/http/message/modifiers/method.hpp index 7865af698..a8a6d3439 100644 --- a/include/network/protocol/http/message/modifiers/method.hpp +++ b/include/network/protocol/http/message/modifiers/method.hpp @@ -1,24 +1,21 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_METHOD_HPP_20101118 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_METHOD_HPP_20101118 - // Copyright 2010 Dean Michael Berris. // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_METHOD_HPP_20101118 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_METHOD_HPP_20101118 + #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { inline void method(request_base & request, std::string const & method_) { request.set_method(method_); } -} /* http */ +} // namespace http +} // namespace network -} /* network */ - -} /* boost */ - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_METHOD_HPP_20101118 */ +#endif /* NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_METHOD_HPP_20101118 */ diff --git a/include/network/protocol/http/message/modifiers/minor_version.hpp b/include/network/protocol/http/message/modifiers/minor_version.hpp index ad7a60b8a..92a1a46d5 100644 --- a/include/network/protocol/http/message/modifiers/minor_version.hpp +++ b/include/network/protocol/http/message/modifiers/minor_version.hpp @@ -1,32 +1,29 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_MINOR_VERSION_HPP_20101120 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_MINOR_VERSION_HPP_20101120 - // Copyright 2010 Dean Michael Berris. // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_MINOR_VERSION_HPP_20101120 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_MINOR_VERSION_HPP_20101120 + #include #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { + +template +struct basic_request; - template - struct basic_request; +template +inline typename enable_if, void>::type +minor_version(basic_request & request, boost::uint8_t minor_version_) { + request.http_version_minor = minor_version_; +} - template - inline typename enable_if, void>::type - minor_version(basic_request & request, boost::uint8_t minor_version_) { - request.http_version_minor = minor_version_; - } - -} /* http */ - -} /* network */ - -} /* boost */ +} // namespace http +} // namespace network -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_MINOR_VERSION_HPP_20101120 */ +#endif /* NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_MINOR_VERSION_HPP_20101120 */ diff --git a/include/network/protocol/http/message/modifiers/status.hpp b/include/network/protocol/http/message/modifiers/status.hpp index 44e06c5ba..880950ec8 100644 --- a/include/network/protocol/http/message/modifiers/status.hpp +++ b/include/network/protocol/http/message/modifiers/status.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_STATUS_HPP_20100608 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_STATUS_HPP_20100608 - // Copyright 2010 (c) Dean Michael Berris // Copyright 2010 (c) Sinefunc, Inc. // Copyright 2012 Google, Inc. @@ -8,18 +5,18 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_STATUS_HPP_20100608 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_STATUS_HPP_20100608 + #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { inline void status(response_base & response, boost::uint16_t value) { response.set_status(value); } } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_STATUS_HPP_20100608 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_STATUS_HPP_20100608 diff --git a/include/network/protocol/http/message/modifiers/status_message.hpp b/include/network/protocol/http/message/modifiers/status_message.hpp index 6ea3e509d..b591ab8f2 100644 --- a/include/network/protocol/http/message/modifiers/status_message.hpp +++ b/include/network/protocol/http/message/modifiers/status_message.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_STATUS_MESSAGE_HPP_20100608 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_STATUS_MESSAGE_HPP_20100608 - // Copyright 2010 (c) Dean Michael Berris // Copyright 2010 (c) Sinefunc, Inc. // Copyright 2012 Google, Inc. @@ -8,18 +5,19 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_STATUS_MESSAGE_HPP_20100608 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_STATUS_MESSAGE_HPP_20100608 + #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { inline void status_message(response_base & response, std::string const & value) { response.set_status_message(value); } } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_STATUS_MESSAGE_HPP_20100608 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_STATUS_MESSAGE_HPP_20100608 diff --git a/include/network/protocol/http/message/modifiers/uri.hpp b/include/network/protocol/http/message/modifiers/uri.hpp index f00093c71..51d2952ce 100644 --- a/include/network/protocol/http/message/modifiers/uri.hpp +++ b/include/network/protocol/http/message/modifiers/uri.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_URI_HPP_20100621 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_URI_HPP_20100621 - // Copyright 2010 (c) Dean Michael Berris // Copyright 2010 (c) Sinefunc, Inc. // Copyright 2011 Google, Inc. @@ -8,9 +5,12 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_URI_HPP_20100621 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_URI_HPP_20100621 + #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { inline void uri(request_base & request, std::string const & value) { request.set_uri(value); @@ -21,9 +21,6 @@ inline void uri(request_base & request, ::network::uri const & value) { } } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_URI_HPP_20100621 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_URI_HPP_20100621 diff --git a/include/network/protocol/http/message/modifiers/version.hpp b/include/network/protocol/http/message/modifiers/version.hpp index 54f9151ac..8042e2aa3 100644 --- a/include/network/protocol/http/message/modifiers/version.hpp +++ b/include/network/protocol/http/message/modifiers/version.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_VERSION_HPP_20100608 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_VERSION_HPP_20100608 - // Copyright 2010 (c) Dean Michael Berris // Copyright 2010 (c) Sinefunc, Inc. // Copyright 2012 Google, Inc. @@ -8,18 +5,19 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_VERSION_HPP_20100608 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_VERSION_HPP_20100608 + #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { inline void version(response_base & response, std::string const & value) { response.set_version(value); } } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_VERSION_HPP_20100608 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_VERSION_HPP_20100608 diff --git a/include/network/protocol/http/message/wrappers.hpp b/include/network/protocol/http/message/wrappers.hpp index 9186965ab..1a2db7471 100644 --- a/include/network/protocol/http/message/wrappers.hpp +++ b/include/network/protocol/http/message/wrappers.hpp @@ -1,12 +1,12 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_HPP_20111201 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_HPP_20111201 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_HPP_20111201 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_HPP_20111201 + #include #include #include @@ -21,4 +21,4 @@ #include #include -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_HPP_20111201 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_HPP_20111201 diff --git a/include/network/protocol/http/message/wrappers/anchor.hpp b/include/network/protocol/http/message/wrappers/anchor.hpp index d7b1716b7..abdb479ee 100644 --- a/include/network/protocol/http/message/wrappers/anchor.hpp +++ b/include/network/protocol/http/message/wrappers/anchor.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_ANCHOR_HPP_20100618 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_ANCHOR_HPP_20100618 - // Copyright 2010 (c) Dean Michael Berris. // Copyright 2010 (c) Sinefunc, Inc. // Copyright 2011 Google, Inc. @@ -8,9 +5,13 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_ANCHOR_HPP_20100618 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_ANCHOR_HPP_20100618 + #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { struct anchor_wrapper { explicit anchor_wrapper(request_base const & request); @@ -25,9 +26,6 @@ anchor(request_base const & request) { } } // namespace http - } // namespace network -} // nmaespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_ANCHOR_HPP_20100618 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_ANCHOR_HPP_20100618 diff --git a/include/network/protocol/http/message/wrappers/anchor.ipp b/include/network/protocol/http/message/wrappers/anchor.ipp index 792b62668..fef5cc3e7 100644 --- a/include/network/protocol/http/message/wrappers/anchor.ipp +++ b/include/network/protocol/http/message/wrappers/anchor.ipp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_ANCHOR_IPP_20111204 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_ANCHOR_IPP_20111204 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Googl,Inc. // Copyright 2012 Google, Inc. @@ -8,10 +5,14 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_ANCHOR_IPP_20111204 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_ANCHOR_IPP_20111204 + #include #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { anchor_wrapper::anchor_wrapper(request_base const & request) : request_(request) {} @@ -23,9 +24,6 @@ anchor_wrapper::operator std::string () const { } } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_ANCHOR_IPP_20111204 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_ANCHOR_IPP_20111204 diff --git a/include/network/protocol/http/message/wrappers/helper.hpp b/include/network/protocol/http/message/wrappers/helper.hpp index 1085da505..6ba958a2e 100644 --- a/include/network/protocol/http/message/wrappers/helper.hpp +++ b/include/network/protocol/http/message/wrappers/helper.hpp @@ -1,16 +1,16 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_HELPER_20101013 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_HELPER_20101013 - // Copyright 2010 (c) Dean Michael Berris // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_HELPER_20101013 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_HELPER_20101013 + #include -#ifndef BOOST_NETWORK_DEFINE_HTTP_WRAPPER -#define BOOST_NETWORK_DEFINE_HTTP_WRAPPER(name, accessor, pod_field) \ +#ifndef NETWORK_DEFINE_HTTP_WRAPPER +#define NETWORK_DEFINE_HTTP_WRAPPER(name, accessor, pod_field) \ struct name##_pod_accessor { \ protected: \ template \ @@ -67,7 +67,7 @@ return name##_wrapper >(message); \ } -#endif /* BOOST_NETWORK_DEFINE_HTTP_WRAPPER */ +#endif /* NETWORK_DEFINE_HTTP_WRAPPER */ -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_HELPER_20101013 */ +#endif /* NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_HELPER_20101013 */ diff --git a/include/network/protocol/http/message/wrappers/host.hpp b/include/network/protocol/http/message/wrappers/host.hpp index af4e0bff2..cfd9e83fb 100644 --- a/include/network/protocol/http/message/wrappers/host.hpp +++ b/include/network/protocol/http/message/wrappers/host.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HOST_HPP_20100618 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HOST_HPP_20100618 - // Copyright 2010 (c) Dean Michael Berris. // Copyright 2010 (c) Sinefunc, Inc. // Copyright 2011 Google, Inc. @@ -8,9 +5,13 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_PROTOCOL_HTTP_MESSAGE_HOST_HPP_20100618 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_HOST_HPP_20100618 + #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { struct host_wrapper { explicit host_wrapper(request_base const & request); @@ -25,9 +26,6 @@ host(request_base const & request) { } } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HOST_HPP_20100618 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_HOST_HPP_20100618 diff --git a/include/network/protocol/http/message/wrappers/host.ipp b/include/network/protocol/http/message/wrappers/host.ipp index a90a7cecc..9b074790c 100644 --- a/include/network/protocol/http/message/wrappers/host.ipp +++ b/include/network/protocol/http/message/wrappers/host.ipp @@ -1,16 +1,16 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_IPP_20111204 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_IPP_20111204 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_IPP_20111204 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_IPP_20111204 + #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { host_wrapper::host_wrapper(request_base const & request) : request_(request) {} @@ -22,9 +22,6 @@ host_wrapper::operator std::string () const { } } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_IPP_20111204 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_IPP_20111204 diff --git a/include/network/protocol/http/message/wrappers/major_version.hpp b/include/network/protocol/http/message/wrappers/major_version.hpp index a884aaa0f..50205c206 100644 --- a/include/network/protocol/http/message/wrappers/major_version.hpp +++ b/include/network/protocol/http/message/wrappers/major_version.hpp @@ -1,41 +1,39 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_MAJOR_VERSION_HPP_20101120 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_MAJOR_VERSION_HPP_20101120 - // Copyright 2010 Dean Michael Berris. // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_MAJOR_VERSION_HPP_20101120 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_MAJOR_VERSION_HPP_20101120 + #include #include #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { - template - struct basic_request; +template +struct basic_request; - template - struct major_version_wrapper { - basic_request const & request; - explicit major_version_wrapper(basic_request const & request) - : request(request) {} - operator boost::uint8_t () { - return request.http_version_major; - } - }; - - template - inline typename enable_if, major_version_wrapper >::type - major_version(basic_request const & request) { - return major_version_wrapper(request); +template +struct major_version_wrapper { + basic_request const & request; + explicit major_version_wrapper(basic_request const & request) + : request(request) {} + operator boost::uint8_t () { + return request.http_version_major; } - -} /* http */ - -} /* network */ - -} /* boost */ +}; -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_MAJOR_VERSION_HPP_20101120 */ +template +inline typename enable_if, major_version_wrapper >::type +major_version(basic_request const & request) { + return major_version_wrapper(request); +} + +} // namespace http +} // namespace network + +#endif /* NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_MAJOR_VERSION_HPP_20101120 */ diff --git a/include/network/protocol/http/message/wrappers/method.hpp b/include/network/protocol/http/message/wrappers/method.hpp index e3e46adc8..19139fbf6 100644 --- a/include/network/protocol/http/message/wrappers/method.hpp +++ b/include/network/protocol/http/message/wrappers/method.hpp @@ -1,15 +1,16 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_METHOD_HPP_20101118 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_METHOD_HPP_20101118 - // Copyright 2010 Dean Michael Berris. // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_METHOD_HPP_20101118 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_METHOD_HPP_20101118 + #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { struct method_wrapper { explicit method_wrapper(request_base & message); @@ -23,10 +24,7 @@ method(request_base & message) { return method_wrapper(message); } -} /* http */ - -} /* network */ - -} /* boost */ +} // namespace http +} // namespace network -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_METHOD_HPP_20101118 */ +#endif /* NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_METHOD_HPP_20101118 */ diff --git a/include/network/protocol/http/message/wrappers/minor_version.hpp b/include/network/protocol/http/message/wrappers/minor_version.hpp index 313e7c1f0..774fe4ed1 100644 --- a/include/network/protocol/http/message/wrappers/minor_version.hpp +++ b/include/network/protocol/http/message/wrappers/minor_version.hpp @@ -1,17 +1,17 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_MINOR_VERSION_HPP_20101120 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_MINOR_VERSION_HPP_20101120 - // Copyright 2010 Dean Michael Berris. // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_MINOR_VERSION_HPP_20101120 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_MINOR_VERSION_HPP_20101120 + #include #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { template struct basic_request; @@ -32,11 +32,8 @@ namespace boost { namespace network { namespace http { return minor_version_wrapper(request); } -} /* http */ +} // namespace http +} // namespace network -} /* network */ - -} /* boost */ - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_MINOR_VERSION_HPP_20101120 */ +#endif /* NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_MINOR_VERSION_HPP_20101120 */ diff --git a/include/network/protocol/http/message/wrappers/path.hpp b/include/network/protocol/http/message/wrappers/path.hpp index 0e0b8f173..9ac0bc24b 100644 --- a/include/network/protocol/http/message/wrappers/path.hpp +++ b/include/network/protocol/http/message/wrappers/path.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_PATH_HPP_20100618 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_PATH_HPP_20100618 - // Copyright 2010 (c) Dean Michael Berris. // Copyright 2010 (c) Sinefunc, Inc. // Copyright 2011 Google, Inc. @@ -8,9 +5,13 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_PROTOCOL_HTTP_MESSAGE_PATH_HPP_20100618 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_PATH_HPP_20100618 + #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { struct path_wrapper { explicit path_wrapper(request_base const & request); @@ -25,9 +26,6 @@ path(request_base const & request) { } } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_PATH_HPP_20100618 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_PATH_HPP_20100618 diff --git a/include/network/protocol/http/message/wrappers/path.ipp b/include/network/protocol/http/message/wrappers/path.ipp index b95669963..c238c32e8 100644 --- a/include/network/protocol/http/message/wrappers/path.ipp +++ b/include/network/protocol/http/message/wrappers/path.ipp @@ -1,16 +1,16 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PATH_IPP_20111204 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PATH_IPP_20111204 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PATH_IPP_20111204 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PATH_IPP_20111204 + #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { path_wrapper::path_wrapper(request_base const & request) : request_(request) {} @@ -22,9 +22,6 @@ path_wrapper::operator std::string () const { } } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PATH_IPP_20111204 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PATH_IPP_20111204 diff --git a/include/network/protocol/http/message/wrappers/port.hpp b/include/network/protocol/http/message/wrappers/port.hpp index 8ba29b121..5697551bb 100644 --- a/include/network/protocol/http/message/wrappers/port.hpp +++ b/include/network/protocol/http/message/wrappers/port.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_PORT_HPP_20100618 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_PORT_HPP_20100618 - // Copyright 2010 (c) Dean Michael Berris. // Copyright 2010 (c) Sinefunc, Inc. // Copyright 2011 Google, Inc. @@ -8,10 +5,13 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_PORT_HPP_20100618 +#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_PORT_HPP_20100618 + #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { struct port_wrapper { port_wrapper(request_base const & request); @@ -27,9 +27,6 @@ port(request_base const & request) { } } // namespace http - } // namespace network -} // namespace boost - #endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_PORT_HPP_20100618 diff --git a/include/network/protocol/http/message/wrappers/port.ipp b/include/network/protocol/http/message/wrappers/port.ipp index c9a5c1f1c..eee076832 100644 --- a/include/network/protocol/http/message/wrappers/port.ipp +++ b/include/network/protocol/http/message/wrappers/port.ipp @@ -1,16 +1,17 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PORT_IPP_20111204 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PORT_IPP_20111204 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PORT_IPP_20111204 +#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PORT_IPP_20111204 + #include #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { port_wrapper::port_wrapper(request_base const & request) : request_(request) {} @@ -37,9 +38,6 @@ port_wrapper::operator optional () const { } } // namespace http - } // namespace network -} // namespace boost - #endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PORT_IPP_20111204 diff --git a/include/network/protocol/http/message/wrappers/protocol.hpp b/include/network/protocol/http/message/wrappers/protocol.hpp index be12836a4..c947f22a6 100644 --- a/include/network/protocol/http/message/wrappers/protocol.hpp +++ b/include/network/protocol/http/message/wrappers/protocol.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PROTOCOL_HPP_20100619 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PROTOCOL_HPP_20100619 - // Copyright 2010 (c) Dean Michael Berris. // Copyright 2010 (c) Sinefunc, Inc. // Copyright 2011 Google, Inc. @@ -8,9 +5,13 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PROTOCOL_HPP_20100619 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PROTOCOL_HPP_20100619 + #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { struct protocol_wrapper { explicit protocol_wrapper(request_base const & request); @@ -25,9 +26,6 @@ protocol(request_base const & request) { } } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PROTOCOL_HPP_20100619 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PROTOCOL_HPP_20100619 diff --git a/include/network/protocol/http/message/wrappers/query.hpp b/include/network/protocol/http/message/wrappers/query.hpp index c95477214..c83faba63 100644 --- a/include/network/protocol/http/message/wrappers/query.hpp +++ b/include/network/protocol/http/message/wrappers/query.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_QUERY_HPP_20100618 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_QUERY_HPP_20100618 - // Copyright 2010 (c) Dean Michael Berris. // Copyright 2010 (c) Sinefunc, Inc. // Copyright 2011 Google, Inc. @@ -8,9 +5,13 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_QUERY_HPP_20100618 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_QUERY_HPP_20100618 + #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { struct query_wrapper { explicit query_wrapper(request_base const & request); @@ -25,9 +26,6 @@ query(request_base const & request) { } } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_QUERY_HPP_20100618 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_QUERY_HPP_20100618 diff --git a/include/network/protocol/http/message/wrappers/query.ipp b/include/network/protocol/http/message/wrappers/query.ipp index 260f712f3..1bbda8740 100644 --- a/include/network/protocol/http/message/wrappers/query.ipp +++ b/include/network/protocol/http/message/wrappers/query.ipp @@ -1,16 +1,16 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_QUERY_IPP_20111204 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_QUERY_IPP_20111204 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_QUERY_IPP_20111204 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_QUERY_IPP_20111204 + #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { query_wrapper::query_wrapper(request_base const & request) : request_(request) {} @@ -22,9 +22,6 @@ query_wrapper::operator std::string () const { } } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_QUERY_IPP_20111204 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_QUERY_IPP_20111204 diff --git a/include/network/protocol/http/message/wrappers/ready.hpp b/include/network/protocol/http/message/wrappers/ready.hpp index 08a068d18..726902b7f 100644 --- a/include/network/protocol/http/message/wrappers/ready.hpp +++ b/include/network/protocol/http/message/wrappers/ready.hpp @@ -1,15 +1,15 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_READY_HPP_20100618 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_READY_HPP_20100618 - // Copyright 2010 Dean Michael Berris. // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_READY_HPP_20100618 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_READY_HPP_20100618 + #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { template struct async_message; @@ -37,10 +37,7 @@ namespace boost { namespace network { namespace http { return impl::ready_wrapper(message); } -} /* http */ - -} /* network */ - -} /* boost */ +} // namespace http +} // namespace network -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_READY_HPP_20100618 */ +#endif /* NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_READY_HPP_20100618 */ diff --git a/include/network/protocol/http/message/wrappers/status.hpp b/include/network/protocol/http/message/wrappers/status.hpp index a2dbe7ca5..59b570fb7 100644 --- a/include/network/protocol/http/message/wrappers/status.hpp +++ b/include/network/protocol/http/message/wrappers/status.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_HPP_20100603 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_HPP_20100603 - // Copyright 2010 (c) Dean Michael Berris // Copyright 2010 (c) Sinefunc, Inc. // Copyright 2012 Google, Inc. @@ -8,9 +5,12 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_HPP_20100603 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_HPP_20100603 + #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { struct status_wrapper { explicit status_wrapper(response_base & response); @@ -26,9 +26,6 @@ status(response_base & response) { } } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_HPP_20100603 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_HPP_20100603 diff --git a/include/network/protocol/http/message/wrappers/status.ipp b/include/network/protocol/http/message/wrappers/status.ipp index b42c71a35..0064f0656 100644 --- a/include/network/protocol/http/message/wrappers/status.ipp +++ b/include/network/protocol/http/message/wrappers/status.ipp @@ -1,15 +1,15 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_IPP_20120311 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_IPP_20120311 - // Copyright 2012 Dean Michael Berris . // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_IPP_20120311 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_IPP_20120311 + #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { status_wrapper::status_wrapper(response_base &response) : response_(response) @@ -22,9 +22,6 @@ status_wrapper::operator uint16_t () const { } } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_IPP_20120311 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_IPP_20120311 diff --git a/include/network/protocol/http/message/wrappers/status_message.hpp b/include/network/protocol/http/message/wrappers/status_message.hpp index 85e55a484..5d04d40d6 100644 --- a/include/network/protocol/http/message/wrappers/status_message.hpp +++ b/include/network/protocol/http/message/wrappers/status_message.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_MESSAGE_HPP_20100603 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_MESSAGE_HPP_20100603 - // Copyright 2010 (c) Dean Michael Berris // Copyright 2010 (c) Sinefunc, Inc. // Copyright 2012 Google, Inc. @@ -8,11 +5,15 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_MESSAGE_HPP_20100603 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_MESSAGE_HPP_20100603 + #include #include #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { struct status_message_wrapper { explicit status_message_wrapper(response_base & response); @@ -33,9 +34,6 @@ status_message(response_base & response) { } } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPER_STATUS_MESSAGE_HPP_20100603 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPER_STATUS_MESSAGE_HPP_20100603 diff --git a/include/network/protocol/http/message/wrappers/status_message.ipp b/include/network/protocol/http/message/wrappers/status_message.ipp index 5690407e5..7f42a8204 100644 --- a/include/network/protocol/http/message/wrappers/status_message.ipp +++ b/include/network/protocol/http/message/wrappers/status_message.ipp @@ -1,15 +1,15 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_MESSAGE_IPP_20120311 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_MESSAGE_IPP_20120311 - // Copyright 2012 Dean Michael Berris . // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_MESSAGE_IPP_20120311 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_MESSAGE_IPP_20120311 + #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { status_message_wrapper::status_message_wrapper(response_base &response) : response_(response) @@ -24,9 +24,6 @@ status_message_wrapper::operator std::string () const { } } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_MESSAGE_IPP_20120311 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_MESSAGE_IPP_20120311 diff --git a/include/network/protocol/http/message/wrappers/uri.hpp b/include/network/protocol/http/message/wrappers/uri.hpp index 3ec2f9864..78dde18be 100644 --- a/include/network/protocol/http/message/wrappers/uri.hpp +++ b/include/network/protocol/http/message/wrappers/uri.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_URI_HPP_20100620 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_URI_HPP_20100620 - // Copyright 2010 (c) Dean Michael Berris. // Copyright 2010 (c) Sinefunc, Inc. // Copyright 2012 Google, Inc. @@ -8,10 +5,14 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_URI_HPP_20100620 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_URI_HPP_20100620 + #include #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { struct uri_wrapper { explicit uri_wrapper(request_base const & request_); @@ -28,9 +29,6 @@ uri(request_base const & request) { } } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_URI_HPP_20100620 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_URI_HPP_20100620 diff --git a/include/network/protocol/http/message/wrappers/uri.ipp b/include/network/protocol/http/message/wrappers/uri.ipp index 6ecb92111..20d6988bf 100644 --- a/include/network/protocol/http/message/wrappers/uri.ipp +++ b/include/network/protocol/http/message/wrappers/uri.ipp @@ -1,15 +1,16 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_URI_IPP_20120315 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_URI_IPP_20120315 - // Copyright 2012 Dean Michael Berris . // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_URI_IPP_20120315 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_URI_IPP_20120315 + #include -namespace boost { namespace network { namespace http { +namespace network { +namespace http { uri_wrapper::uri_wrapper(request_base const & request_) : request_(request_) { @@ -29,10 +30,6 @@ uri_wrapper::operator ::network::uri() const { } } // namespace http - } // namespace network -} // namespace boost - - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_URI_IPP_20120315 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_URI_IPP_20120315 diff --git a/include/network/protocol/http/message/wrappers/version.hpp b/include/network/protocol/http/message/wrappers/version.hpp index c3a9d8404..907d09a4c 100644 --- a/include/network/protocol/http/message/wrappers/version.hpp +++ b/include/network/protocol/http/message/wrappers/version.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_VERSION_HPP_20100603 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_VERSION_HPP_20100603 - // Copyright 2010-2012 (c) Dean Michael Berris // Copyright 2010 (c) Sinefunc, Inc. // Copyright 2012 Google, Inc. @@ -8,11 +5,14 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_VERSION_HPP_20100603 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_VERSION_HPP_20100603 + #include #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { struct version_wrapper { explicit version_wrapper(response_base & response_); @@ -32,10 +32,7 @@ version(response_base & response) { return version_wrapper(response); } -} // namespace http - -} // namespace network - -} // namespace boost +} // namespace http +} // namespace network -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_VERSION_HPP_20100603 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_VERSION_HPP_20100603 diff --git a/include/network/protocol/http/message/wrappers/version.ipp b/include/network/protocol/http/message/wrappers/version.ipp index 85ff99deb..6387ab378 100644 --- a/include/network/protocol/http/message/wrappers/version.ipp +++ b/include/network/protocol/http/message/wrappers/version.ipp @@ -1,15 +1,15 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_VERSION_IPP_20120311 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_VERSION_IPP_20120311 - // Copyright 2012 Dean Michael Berris . // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_VERSION_IPP_20120311 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_VERSION_IPP_20120311 + #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { version_wrapper::version_wrapper(response_base & response) : response_(response) @@ -24,9 +24,6 @@ version_wrapper::operator std::string() const { } } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_VERSION_IPP_20120311 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_VERSION_IPP_20120311 diff --git a/include/network/protocol/http/parser.hpp b/include/network/protocol/http/parser.hpp index 79a252272..5a58f694c 100644 --- a/include/network/protocol/http/parser.hpp +++ b/include/network/protocol/http/parser.hpp @@ -5,11 +5,11 @@ // // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_PARSER_HPP -#define BOOST_NETWORK_PROTOCOL_HTTP_PARSER_HPP +#ifndef NETWORK_PROTOCOL_HTTP_PARSER_HPP +#define NETWORK_PROTOCOL_HTTP_PARSER_HPP #include #include @@ -19,7 +19,7 @@ #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { // forward declarations used to finish HTTP requests template @@ -303,13 +303,10 @@ namespace boost { namespace network { namespace http { /// typedef for the default HTTP protocol parser implementation typedef basic_parser parser; -}; // namespace http - -}; // namespace network - -}; // namespace boost +} // namespace http +} // namespace network // import implementation file #include -#endif // BOOST_NETWORK_PROTOCOL_HTTP_PARSER_HPP +#endif // NETWORK_PROTOCOL_HTTP_PARSER_HPP diff --git a/include/network/protocol/http/parser/incremental.hpp b/include/network/protocol/http/parser/incremental.hpp index ca07db0b7..ca0e17168 100644 --- a/include/network/protocol/http/parser/incremental.hpp +++ b/include/network/protocol/http/parser/incremental.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_PARSER_INCREMENTAL_HPP_20100909 -#define BOOST_NETWORK_PROTOCOL_HTTP_PARSER_INCREMENTAL_HPP_20100909 - // Copyright Dean Michael Berris 2010. // Copyright 2011 Dean Michael Berris (dberris@google.com). // Copyright 2011 Google, Inc. @@ -8,13 +5,16 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_PROTOCOL_HTTP_PARSER_INCREMENTAL_HPP_20100909 +#define NETWORK_PROTOCOL_HTTP_PARSER_INCREMENTAL_HPP_20100909 + #include #include #include #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { struct response_parser { @@ -279,10 +279,7 @@ struct response_parser { }; -} /* http */ - -} /* network */ - -} /* boost */ +} // namespace http +} // namespace network #endif diff --git a/include/network/protocol/http/policies/async_connection.hpp b/include/network/protocol/http/policies/async_connection.hpp index 394172aae..bb507a63c 100644 --- a/include/network/protocol/http/policies/async_connection.hpp +++ b/include/network/protocol/http/policies/async_connection.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_POLICY_ASYNC_CONNECTION_HPP_20100529 -#define BOOST_NETWORK_POLICY_ASYNC_CONNECTION_HPP_20100529 - // Copyright 2010 (C) Dean Michael Berris // Copyright 2010 (C) Sinefunc, Inc. // Copyright 2011 Dean Michael Berris (dberris@google.com). @@ -9,6 +6,9 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_POLICY_ASYNC_CONNECTION_HPP_20100529 +#define NETWORK_POLICY_ASYNC_CONNECTION_HPP_20100529 + #include #include #include @@ -21,7 +21,7 @@ #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { struct simple_async_connection_manager : connection_manager { simple_async_connection_manager(bool cache_resolved, @@ -71,9 +71,6 @@ struct http_1_1_async_connection_manager : connection_manager, enable_shared_fro }; } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_POLICY_ASYNC_CONNECTION_HPP_ +#endif // NETWORK_POLICY_ASYNC_CONNECTION_HPP_ diff --git a/include/network/protocol/http/policies/async_connection.ipp b/include/network/protocol/http/policies/async_connection.ipp index 2fbc15f31..afcab52c2 100644 --- a/include/network/protocol/http/policies/async_connection.ipp +++ b/include/network/protocol/http/policies/async_connection.ipp @@ -1,13 +1,13 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_POLICIES_ASYNC_CONNECTION_IPP_20110930 -#define BOOST_NETWORK_PROTOCOL_HTTP_POLICIES_ASYNC_CONNECTION_IPP_20110930 - // Copyright 2011 Dean Michael Berris (dberris@google.com). // Copyright 2011 Google, Inc. // 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) -namespace boost { namespace network { namespace http { +#ifndef NETWORK_PROTOCOL_HTTP_POLICIES_ASYNC_CONNECTION_IPP_20110930 +#define NETWORK_PROTOCOL_HTTP_POLICIES_ASYNC_CONNECTION_IPP_20110930 + +namespace network { namespace http { struct simple_async_client_connection : client_connection { simple_async_client_connection(bool follow_redirects, @@ -57,11 +57,10 @@ void simple_async_client_connection::reset() { simple_async_client_connection::~simple_async_client_connection() {} -} /* http */ -} /* network */ -} /* boost */ +} // namespace http +} // namespace network -boost::network::http::simple_async_connection_manager(bool cache_resolved, +network::http::simple_async_connection_manager(bool cache_resolved, bool follow_redirects, boost::optional openssl_certificate, boost::optional openssl_verify_path) @@ -71,8 +70,8 @@ boost::network::http::simple_async_connection_manager(bool cache_resolved, openssl_verify_path_(openssl_verify_path), {} -boost::shared_ptr -boost::network::http::simple_async_connection_manager::get_connection( +boost::shared_ptr +network::http::simple_async_connection_manager::get_connection( boost::asio::io_service & service, request_base const & request) { // TODO move out calls to new to a factory, taken as a parameter at @@ -107,14 +106,14 @@ boost::network::http::simple_async_connection_manager::get_connection( return connection; } -void boost::network::http::simple_async_connection_manager::reset() { +void network::http::simple_async_connection_manager::reset() { if (cache_resolved_) { scoped_lock delegate_lock(this->resolver_mutex); this->shared_resolver_delegate.reset(); } } -namespace boost { namespace network { namespace http { +namespace network { namespace http { struct http_1_1_async_connection : client_connection { http_1_1_async_connection(bool follow_redirects, @@ -165,8 +164,7 @@ void http_1_1_async_connection::reset() { http_1_1_async_connection::~http_1_1_async_connection() {} -} /* http */ -} /* network */ -} /* boost */ +} // namespace http +} // namespace network -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_POLICIES_ASYNC_CONNECTION_IPP_20110930 */ +#endif /* NETWORK_PROTOCOL_HTTP_POLICIES_ASYNC_CONNECTION_IPP_20110930 */ diff --git a/include/network/protocol/http/request.hpp b/include/network/protocol/http/request.hpp index 527ee00dc..0e302cc26 100644 --- a/include/network/protocol/http/request.hpp +++ b/include/network/protocol/http/request.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_HPP_20111021 -#define BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_HPP_20111021 - // Copyright Dean Michael Berris 2007. // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. @@ -8,6 +5,9 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_PROTOCOL_HTTP_REQUEST_HPP_20111021 +#define NETWORK_PROTOCOL_HTTP_REQUEST_HPP_20111021 + #include -#endif // BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_HPP_20111021 +#endif // NETWORK_PROTOCOL_HTTP_REQUEST_HPP_20111021 diff --git a/include/network/protocol/http/request/request.hpp b/include/network/protocol/http/request/request.hpp index afe4d1ad2..b005e5060 100644 --- a/include/network/protocol/http/request/request.hpp +++ b/include/network/protocol/http/request/request.hpp @@ -1,19 +1,19 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_REQUEST_HPP_20111021 -#define BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_REQUEST_HPP_20111021 - // Copyright 2011 Dean Michael Berris (dberris@google.com). // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_REQUEST_REQUEST_HPP_20111021 +#define NETWORK_PROTOCOL_HTTP_REQUEST_REQUEST_HPP_20111021 + #include #include #include #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { struct request_pimpl; @@ -94,11 +94,8 @@ inline bool operator!=(request const &l, request const &r) { } } // namespace http - } // namespace network -} // namespace boost - #include #include #include @@ -106,4 +103,4 @@ inline bool operator!=(request const &l, request const &r) { #include #include -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_REQUEST_HPP_20111021 */ +#endif /* NETWORK_PROTOCOL_HTTP_REQUEST_REQUEST_HPP_20111021 */ diff --git a/include/network/protocol/http/request/request.ipp b/include/network/protocol/http/request/request.ipp index 7cff8fa62..5f0a1e574 100644 --- a/include/network/protocol/http/request/request.ipp +++ b/include/network/protocol/http/request/request.ipp @@ -1,21 +1,21 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_IPP_20110910 -#define BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_IPP_20110910 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_REQUEST_IPP_20110910 +#define NETWORK_PROTOCOL_HTTP_REQUEST_IPP_20110910 + #include #include #include -#ifdef BOOST_NETWORK_DEBUG +#ifdef NETWORK_DEBUG BOOST_CONCEPT_ASSERT((boost::network::http::ClientRequest)); #endif -namespace boost { namespace network { namespace http { +namespace network { namespace http { struct request_pimpl { request_pimpl() @@ -326,6 +326,4 @@ void request::get_body(std::string const & body) const { } // namespace network -} // namespace boost - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_IPP_20110910 */ +#endif /* NETWORK_PROTOCOL_HTTP_REQUEST_IPP_20110910 */ diff --git a/include/network/protocol/http/request/request_base.hpp b/include/network/protocol/http/request/request_base.hpp index 815735c14..d8fbde70c 100644 --- a/include/network/protocol/http/request/request_base.hpp +++ b/include/network/protocol/http/request/request_base.hpp @@ -1,12 +1,12 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_BASE_HPP_20111008 -#define BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_BASE_HPP_20111008 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_BASE_HPP_20111008 +#define BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_BASE_HPP_20111008 + #ifndef BOOST_NETWORK_BUFFER_CHUNK #define BOOST_NETWORK_BUFFER_CHUNK 1024 // We want 1KiB worth of data at least. #endif @@ -14,7 +14,7 @@ #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { struct body_source : iostreams::source { virtual std::streamsize read(char * buffer, std::streamsize size); @@ -59,10 +59,7 @@ struct request_base : message_base, request_storage_base { virtual ~request_base() = 0; }; -} /* http */ - -} /* network */ - -} /* boost */ +} // namespace http +} // namespace network #endif /* BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_BASE_HPP_20111008 */ diff --git a/include/network/protocol/http/request/request_base.ipp b/include/network/protocol/http/request/request_base.ipp index b819e139b..1c7a311e1 100644 --- a/include/network/protocol/http/request/request_base.ipp +++ b/include/network/protocol/http/request/request_base.ipp @@ -1,17 +1,17 @@ -#ifndef BOOST_NETWORK_RPTOCOL_HTTP_REQUEST_BASE_IPP_20111102 -#define BOOST_NETWORK_RPTOCOL_HTTP_REQUEST_BASE_IPP_20111102 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_RPTOCOL_HTTP_REQUEST_BASE_IPP_20111102 +#define NETWORK_RPTOCOL_HTTP_REQUEST_BASE_IPP_20111102 + #include #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { request_base::~request_base() { // default implementation, only required for linking. @@ -205,10 +205,7 @@ request_storage_base_pimpl::~request_storage_base_pimpl() { } -} /* http */ - -} /* network */ - -} /* boost */ +} // namespace http +} // namespace network -#endif /* BOOST_NETWORK_RPTOCOL_HTTP_REQUEST_BASE_IPP_20111102 */ +#endif /* NETWORK_RPTOCOL_HTTP_REQUEST_BASE_IPP_20111102 */ diff --git a/include/network/protocol/http/request/request_concept.hpp b/include/network/protocol/http/request/request_concept.hpp index 3d1e5225c..909ec39e5 100644 --- a/include/network/protocol/http/request/request_concept.hpp +++ b/include/network/protocol/http/request/request_concept.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_CONCEPT_HPP_20100603 -#define BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_CONCEPT_HPP_20100603 - // Copyright 2010 (c) Dean Michael Berris. // Copyright 2010 (c) Sinefunc, Inc. // Copyright 2012 Google, Inc. @@ -8,6 +5,9 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_PROTOCOL_HTTP_REQUEST_CONCEPT_HPP_20100603 +#define NETWORK_PROTOCOL_HTTP_REQUEST_CONCEPT_HPP_20100603 + #include #include #include @@ -16,7 +16,7 @@ #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { template struct ServerRequest @@ -101,6 +101,4 @@ namespace boost { namespace network { namespace http { } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_CONCEPT_HPP_20100603 +#endif // NETWORK_PROTOCOL_HTTP_REQUEST_CONCEPT_HPP_20100603 diff --git a/include/network/protocol/http/request_parser.hpp b/include/network/protocol/http/request_parser.hpp index 02f2a22bd..d9d76a977 100644 --- a/include/network/protocol/http/request_parser.hpp +++ b/include/network/protocol/http/request_parser.hpp @@ -20,7 +20,7 @@ #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { namespace tag { struct default_; @@ -98,11 +98,8 @@ class request_parser }; } // namespace http - } // namespace network -} // namespace boost - #include #endif // HTTP_SERVER3_REQUEST_PARSER_HPP diff --git a/include/network/protocol/http/response.hpp b/include/network/protocol/http/response.hpp index 568a57f38..65e9c3323 100644 --- a/include/network/protocol/http/response.hpp +++ b/include/network/protocol/http/response.hpp @@ -1,12 +1,12 @@ -// Copyright Dean Michael Berris 2007. -// Copyright Michael Dickey 2008. +// Copyright Dean Michael Berris 2007. +// Copyright Michael Dickey 2008. // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_HPP -#define BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_HPP +#ifndef NETWORK_PROTOCOL_HTTP_RESPONSE_HPP +#define NETWORK_PROTOCOL_HTTP_RESPONSE_HPP #include @@ -29,4 +29,4 @@ #include #include -#endif // BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_HPP +#endif // NETWORK_PROTOCOL_HTTP_RESPONSE_HPP diff --git a/include/network/protocol/http/response/response.hpp b/include/network/protocol/http/response/response.hpp index 8786da87d..9c7174dc9 100644 --- a/include/network/protocol/http/response/response.hpp +++ b/include/network/protocol/http/response/response.hpp @@ -1,16 +1,16 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_RESPONSE_HPP_20111021 -#define BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_RESPONSE_HPP_20111021 - // Copyright 2011 Dean Michael Berris (dberris@google.com). // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_RESPONSE_RESPONSE_HPP_20111021 +#define NETWORK_PROTOCOL_HTTP_RESPONSE_RESPONSE_HPP_20111021 + #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { struct response_pimpl; @@ -95,9 +95,6 @@ response & operator<<( } } // namespace http - } // namespace network -} // namespace boost - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_RESPONSE_HPP_20111021 */ +#endif /* NETWORK_PROTOCOL_HTTP_RESPONSE_RESPONSE_HPP_20111021 */ diff --git a/include/network/protocol/http/response/response.ipp b/include/network/protocol/http/response/response.ipp index 884678af3..9f9129dce 100644 --- a/include/network/protocol/http/response/response.ipp +++ b/include/network/protocol/http/response/response.ipp @@ -1,16 +1,16 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_RESPONSE_IPP_20111206 -#define BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_RESPONSE_IPP_20111206 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_RESPONSE_RESPONSE_IPP_20111206 +#define NETWORK_PROTOCOL_HTTP_RESPONSE_RESPONSE_IPP_20111206 + #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { struct response_pimpl { response_pimpl() {} @@ -434,6 +434,4 @@ void response::set_body_promise(promise &promise) { } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_RESPONSE_IPP_20111206 +#endif // NETWORK_PROTOCOL_HTTP_RESPONSE_RESPONSE_IPP_20111206 diff --git a/include/network/protocol/http/response/response_base.hpp b/include/network/protocol/http/response/response_base.hpp index fbe4364c9..6a5591149 100644 --- a/include/network/protocol/http/response/response_base.hpp +++ b/include/network/protocol/http/response/response_base.hpp @@ -1,15 +1,15 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_BASE_HPP_20110930 -#define BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_BASE_HPP_20110930 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_RESPONSE_BASE_HPP_20110930 +#define NETWORK_PROTOCOL_HTTP_RESPONSE_BASE_HPP_20110930 + #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { struct response_base : message_base { virtual void set_status(boost::uint16_t new_status) = 0; @@ -21,14 +21,7 @@ struct response_base : message_base { virtual ~response_base() = 0; }; -} /* http */ - -} /* network */ - -} /* boost */ - -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif +} // namespace http +} // namespace network -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_BASE_HPP_20110930 */ +#endif /* NETWORK_PROTOCOL_HTTP_RESPONSE_BASE_HPP_20110930 */ diff --git a/include/network/protocol/http/response/response_base.ipp b/include/network/protocol/http/response/response_base.ipp index a7e54d357..4bebd6280 100644 --- a/include/network/protocol/http/response/response_base.ipp +++ b/include/network/protocol/http/response/response_base.ipp @@ -1,23 +1,21 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_RESPONSE_BASE_IPP_20111102 -#define BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_RESPONSE_BASE_IPP_20111102 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_RESPONSE_RESPONSE_BASE_IPP_20111102 +#define NETWORK_PROTOCOL_HTTP_RESPONSE_RESPONSE_BASE_IPP_20111102 + #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { response_base::~response_base() { // default implementation, required only for linking. } -} /* http */ -} /* network */ +} // namespace http +} // namespace network -} /* boost */ - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_RESPONSE_BASE_IPP_20111102 */ +#endif /* NETWORK_PROTOCOL_HTTP_RESPONSE_RESPONSE_BASE_IPP_20111102 */ diff --git a/include/network/protocol/http/response/response_concept.hpp b/include/network/protocol/http/response/response_concept.hpp index b79d3db82..b55ce026e 100644 --- a/include/network/protocol/http/response/response_concept.hpp +++ b/include/network/protocol/http/response/response_concept.hpp @@ -1,6 +1,3 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_CONCEPT_HPP_20100603 -#define BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_CONCEPT_HPP_20100603 - // Copyright 2010 (c) Dean Michael Berris. // Copyright 2010 (c) Sinefunc, Inc. // Copyright 2012 Google, Inc. @@ -8,11 +5,14 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_PROTOCOL_HTTP_RESPONSE_CONCEPT_HPP_20100603 +#define NETWORK_PROTOCOL_HTTP_RESPONSE_CONCEPT_HPP_20100603 + #include #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { template struct Response @@ -51,9 +51,6 @@ namespace boost { namespace network { namespace http { }; } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_CONCEPT_HPP_20100603 +#endif // NETWORK_PROTOCOL_HTTP_RESPONSE_CONCEPT_HPP_20100603 diff --git a/include/network/protocol/http/server.hpp b/include/network/protocol/http/server.hpp index e4553f69b..91ec0a035 100644 --- a/include/network/protocol/http/server.hpp +++ b/include/network/protocol/http/server.hpp @@ -7,12 +7,12 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_NETWORK_HTTP_SERVER_HPP_ -#define BOOST_NETWORK_HTTP_SERVER_HPP_ +#ifndef NETWORK_HTTP_SERVER_HPP_ +#define NETWORK_HTTP_SERVER_HPP_ #include -namespace boost { namespace network { namespace utils { +namespace network { namespace utils { struct thread_pool; @@ -20,9 +20,7 @@ struct thread_pool; } // namespace network -} // namespace boost - -namespace boost { namespace network { namespace http { +namespace network { namespace http { class server_options; class sync_server_impl; @@ -70,11 +68,9 @@ class async_server { } // namespace network -} // namespace boost - // We're hiding the implementation from here, but still explicitly including // it here. This is mostly a style point, to keep this header clean. #include -#endif // BOOST_NETWORK_HTTP_SERVER_HPP_ +#endif // NETWORK_HTTP_SERVER_HPP_ diff --git a/include/network/protocol/http/server/async_impl.hpp b/include/network/protocol/http/server/async_impl.hpp index 4b2f7edc2..ebe41927f 100644 --- a/include/network/protocol/http/server/async_impl.hpp +++ b/include/network/protocol/http/server/async_impl.hpp @@ -1,12 +1,12 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_IMPL_20120318 -#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_IMPL_20120318 - // Copyright 2012 Dean Michael Berris . // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_IMPL_20120318 +#define NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_IMPL_20120318 + #include #include #include @@ -14,7 +14,7 @@ #include #include -namespace boost { namespace network { namespace utils { +namespace network { namespace utils { struct thread_pool; @@ -22,9 +22,7 @@ struct thread_pool; } // namespace network -} // namespace boost - -namespace boost { namespace network { namespace http { +namespace network { namespace http { struct request; @@ -61,6 +59,4 @@ class async_server_impl : protected socket_options_setter { } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_IMPL_20120318 +#endif // NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_IMPL_20120318 diff --git a/include/network/protocol/http/server/async_impl.ipp b/include/network/protocol/http/server/async_impl.ipp index b7fcf8311..626ed81b6 100644 --- a/include/network/protocol/http/server/async_impl.ipp +++ b/include/network/protocol/http/server/async_impl.ipp @@ -1,12 +1,12 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_IMPL_IPP_20120318 -#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_IMPL_IPP_20120318 - // Copyright 2012 Dean Michael Berris . // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_IMPL_IPP_20120318 +#define NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_IMPL_IPP_20120318 + #include #include #include @@ -15,7 +15,7 @@ #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { async_server_impl::async_server_impl(server_options const &options, function handler, @@ -67,10 +67,10 @@ void async_server_impl::stop() { void async_server_impl::listen() { lock_guard listening_lock(listening_mutex_); - BOOST_NETWORK_MESSAGE("listening on " << address_ << ':' << port_); + NETWORK_MESSAGE("listening on " << address_ << ':' << port_); if (!listening_) start_listening(); if (!listening_) { - BOOST_NETWORK_MESSAGE("error listening on " << address_ << ':' << port_); + NETWORK_MESSAGE("error listening on " << address_ << ':' << port_); BOOST_THROW_EXCEPTION(std::runtime_error("Error listening on provided address:port.")); } } @@ -101,7 +101,7 @@ void async_server_impl::handle_accept(boost::system::error_code const & ec) { this, asio::placeholders::error)); } else { - BOOST_NETWORK_MESSAGE("Error accepting connection, reason: " << ec); + NETWORK_MESSAGE("Error accepting connection, reason: " << ec); } } @@ -113,24 +113,24 @@ void async_server_impl::start_listening() { tcp::resolver::query query(address_, port_); tcp::resolver::iterator endpoint_iterator = resolver.resolve(query, error); if (error) { - BOOST_NETWORK_MESSAGE("error resolving '" << address_ << ':' << port_); + NETWORK_MESSAGE("error resolving '" << address_ << ':' << port_); BOOST_THROW_EXCEPTION(std::runtime_error("Error resolving address:port combination.")); } tcp::endpoint endpoint = *endpoint_iterator; acceptor_->open(endpoint.protocol(), error); if (error) { - BOOST_NETWORK_MESSAGE("error opening socket: " << address_ << ":" << port_); + NETWORK_MESSAGE("error opening socket: " << address_ << ":" << port_); BOOST_THROW_EXCEPTION(std::runtime_error("Error opening socket.")); } set_acceptor_options(options_, *acceptor_); acceptor_->bind(endpoint, error); if (error) { - BOOST_NETWORK_MESSAGE("error binding socket: " << address_ << ":" << port_); + NETWORK_MESSAGE("error binding socket: " << address_ << ":" << port_); BOOST_THROW_EXCEPTION(std::runtime_error("Error binding socket.")); } acceptor_->listen(asio::socket_base::max_connections, error); if (error) { - BOOST_NETWORK_MESSAGE("error listening on socket: '" << error << "' on " << address_ << ":" << port_); + NETWORK_MESSAGE("error listening on socket: '" << error << "' on " << address_ << ":" << port_); BOOST_THROW_EXCEPTION(std::runtime_error("Error listening on socket.")); } new_connection_.reset(new async_server_connection(*service_, handler_, pool_)); @@ -143,13 +143,11 @@ void async_server_impl::start_listening() { listening_ = true; lock_guard stopping_lock(stopping_mutex_); stopping_ = false; // if we were in the process of stopping, we revoke that command and continue listening - BOOST_NETWORK_MESSAGE("now listening on '" << address_ << ":" << port_ << "'"); + NETWORK_MESSAGE("now listening on '" << address_ << ":" << port_ << "'"); } } // namespace http } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_IMPL_IPP_20120318 +#endif // NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_IMPL_IPP_20120318 diff --git a/include/network/protocol/http/server/async_server.hpp b/include/network/protocol/http/server/async_server.hpp index c5c4eefb0..b87896804 100644 --- a/include/network/protocol/http/server/async_server.hpp +++ b/include/network/protocol/http/server/async_server.hpp @@ -1,12 +1,12 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_SERVER_HPP_20101025 -#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_SERVER_HPP_20101025 - // Copyright 2010 Dean Michael Berris. // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_SERVER_HPP_20101025 +#define NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_SERVER_HPP_20101025 + #include #include #include @@ -14,7 +14,7 @@ #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { template struct async_server_base : server_storage_base, socket_options_base { @@ -71,10 +71,10 @@ namespace boost { namespace network { namespace http { void listen() { scoped_mutex_lock listening_lock(listening_mutex_); - BOOST_NETWORK_MESSAGE("Listening on " << address_ << ':' << port_); + NETWORK_MESSAGE("Listening on " << address_ << ':' << port_); if (!listening) start_listening(); // we only initialize our acceptor/sockets if we arent already listening if (!listening) { - BOOST_NETWORK_MESSAGE("Error listening on " << address_ << ':' << port_); + NETWORK_MESSAGE("Error listening on " << address_ << ':' << port_); boost::throw_exception(std::runtime_error("Error listening on provided port.")); } } @@ -118,7 +118,7 @@ namespace boost { namespace network { namespace http { ) ); } else { - BOOST_NETWORK_MESSAGE("Error accepting connection, reason: " << ec); + NETWORK_MESSAGE("Error accepting connection, reason: " << ec); } } @@ -133,24 +133,24 @@ namespace boost { namespace network { namespace http { tcp::resolver::query query(address_, port_); tcp::resolver::iterator endpoint_iterator = resolver.resolve(query, error); if (error) { - BOOST_NETWORK_MESSAGE("Error resolving '" << address_ << ':' << port_); + NETWORK_MESSAGE("Error resolving '" << address_ << ':' << port_); return; } tcp::endpoint endpoint = *endpoint_iterator; acceptor.open(endpoint.protocol(), error); if (error) { - BOOST_NETWORK_MESSAGE("Error opening socket: " << address_ << ":" << port_); + NETWORK_MESSAGE("Error opening socket: " << address_ << ":" << port_); return; } socket_options_base::acceptor_options(acceptor); acceptor.bind(endpoint, error); if (error) { - BOOST_NETWORK_MESSAGE("Error binding socket: " << address_ << ":" << port_); + NETWORK_MESSAGE("Error binding socket: " << address_ << ":" << port_); return; } acceptor.listen(asio::socket_base::max_connections, error); if (error) { - BOOST_NETWORK_MESSAGE("Error listening on socket: '" << error << "' on " << address_ << ":" << port_); + NETWORK_MESSAGE("Error listening on socket: '" << error << "' on " << address_ << ":" << port_); return; } new_connection.reset(new connection(service_, handler, thread_pool)); @@ -162,14 +162,11 @@ namespace boost { namespace network { namespace http { listening = true; scoped_mutex_lock stopping_lock(stopping_mutex_); stopping = false; // if we were in the process of stopping, we revoke that command and continue listening - BOOST_NETWORK_MESSAGE("Now listening on socket: '" << address_ << ":" << port_ << "'"); + NETWORK_MESSAGE("Now listening on socket: '" << address_ << ":" << port_ << "'"); } }; -} /* http */ +} // namespace http +} // namespace network -} /* network */ - -} /* boost */ - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_SERVER_HPP_20101025 */ +#endif /* NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_SERVER_HPP_20101025 */ diff --git a/include/network/protocol/http/server/connection/async.hpp b/include/network/protocol/http/server/connection/async.hpp index ba26febc2..af12708fc 100644 --- a/include/network/protocol/http/server/connection/async.hpp +++ b/include/network/protocol/http/server/connection/async.hpp @@ -1,12 +1,12 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_CONNECTION_ASYNC_HPP_20101027 -#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_CONNECTION_ASYNC_HPP_20101027 - // Copyright 2010-2012 Dean Michael Berris // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_SERVER_CONNECTION_ASYNC_HPP_20101027 +#define NETWORK_PROTOCOL_HTTP_SERVER_CONNECTION_ASYNC_HPP_20101027 + #include #include #include @@ -33,12 +33,9 @@ #include #include #include -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif #include -#ifndef BOOST_NETWORK_HTTP_SERVER_CONNECTION_HEADER_BUFFER_MAX_SIZE +#ifndef NETWORK_HTTP_SERVER_CONNECTION_HEADER_BUFFER_MAX_SIZE /** Here we define a page's worth of header connection buffer data. * This can be tuned to reduce the memory cost of connections, but this * default size is set to be friendly to typical service applications. @@ -50,23 +47,21 @@ * the default allocator with the static buffers, it's not guaranteed that * the static buffers will be page-aligned when they are allocated. */ -#define BOOST_NETWORK_HTTP_SERVER_CONNECTION_HEADER_BUFFER_MAX_SIZE 4096 -#endif /* BOOST_NETWORK_HTTP_SERVER_CONNECTION_HEADER_BUFFER_MAX_SIZE */ +#define NETWORK_HTTP_SERVER_CONNECTION_HEADER_BUFFER_MAX_SIZE 4096 +#endif /* NETWORK_HTTP_SERVER_CONNECTION_HEADER_BUFFER_MAX_SIZE */ -#ifndef BOOST_NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE +#ifndef NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE /** Here we're making the assumption again that the page size of the system * is 4096 and that it's better to have page-aligned chunks when creating * buffers for memory use efficiency. */ -#define BOOST_NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE 4096uL +#define NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE 4096uL #endif -namespace boost { namespace network { namespace http { +namespace network { namespace http { -#ifndef BOOST_NETWORK_NO_LIB extern void parse_version(std::string const & partial_parsed, fusion::tuple & version_pair); extern void parse_headers(std::string const & input, std::vector > & container); -#endif class async_server_connection : public boost::enable_shared_from_this { public: @@ -153,7 +148,7 @@ namespace boost { namespace network { namespace http { , thread_pool_(thread_pool) , headers_already_sent(false) , headers_in_progress(false) - , headers_buffer(BOOST_NETWORK_HTTP_SERVER_CONNECTION_HEADER_BUFFER_MAX_SIZE) + , headers_buffer(NETWORK_HTTP_SERVER_CONNECTION_HEADER_BUFFER_MAX_SIZE) { new_start = read_buffer_.begin(); } @@ -247,7 +242,7 @@ namespace boost { namespace network { namespace http { } private: - typedef boost::array buffer_type; + typedef boost::array buffer_type; public: typedef iterator_range input_range; @@ -306,7 +301,7 @@ namespace boost { namespace network { namespace http { error_encountered = in_place(ec); } - typedef boost::array array; + typedef boost::array array; typedef std::list > array_list; typedef boost::shared_ptr shared_array_list; typedef boost::shared_ptr > shared_buffers; @@ -570,7 +565,7 @@ namespace boost { namespace network { namespace http { // static std::size_t const connection_buffer_size = - BOOST_NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE; + NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE; shared_array_list temporaries = boost::make_shared(); shared_buffers buffers = @@ -648,11 +643,7 @@ namespace boost { namespace network { namespace http { } }; -} /* http */ +} // namespace http +} // namespace network -} /* network */ - -} /* boost */ - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_SERVER_CONNECTION_HPP_20101027 */ - +#endif /* NETWORK_PROTOCOL_HTTP_SERVER_CONNECTION_HPP_20101027 */ diff --git a/include/network/protocol/http/server/connection/sync.hpp b/include/network/protocol/http/server/connection/sync.hpp index 1d13f0538..75e643957 100644 --- a/include/network/protocol/http/server/connection/sync.hpp +++ b/include/network/protocol/http/server/connection/sync.hpp @@ -5,11 +5,11 @@ // or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef BOOST_NETWORK_HTTP_SERVER_SYNC_CONNECTION_HPP_ -#define BOOST_NETWORK_HTTP_SERVER_SYNC_CONNECTION_HPP_ +#ifndef NETWORK_HTTP_SERVER_SYNC_CONNECTION_HPP_ +#define NETWORK_HTTP_SERVER_SYNC_CONNECTION_HPP_ -#ifndef BOOST_NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE -#define BOOST_NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE 4096uL +#ifndef NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE +#define NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE 4096uL #endif #include @@ -30,9 +30,9 @@ #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { -#ifndef BOOST_NETWORK_NO_LIB +#ifndef NETWORK_NO_LIB extern void parse_version(std::string const & partial_parsed, fusion::tuple & version_pair); extern void parse_headers(std::string const & input, std::vector > & container); #endif @@ -316,7 +316,7 @@ class sync_server_connection : public boost::enable_shared_from_this buffer_type; + typedef boost::array buffer_type; buffer_type read_buffer_; buffer_type::iterator new_start, data_end; request_parser parser_; @@ -330,10 +330,7 @@ class sync_server_connection : public boost::enable_shared_from_this - // Copyright 2010 Dean Michael Berris. // Copyright 2012 Google, Inc. // 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 SERVER_REQUEST_PARSERS_IMPL_UW3PM6V6 +#define SERVER_REQUEST_PARSERS_IMPL_UW3PM6V6 + +#include + #include #include #include -#ifdef BOOST_NETWORK_NO_LIB -# ifndef BOOST_NETWORK_INLINE -# define BOOST_NETWORK_INLINE inline +#ifdef NETWORK_NO_LIB +# ifndef NETWORK_INLINE +# define NETWORK_INLINE inline # endif #else -# define BOOST_NETWORK_INLINE +# define NETWORK_INLINE #endif #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { - BOOST_NETWORK_INLINE void parse_version(std::string const & partial_parsed, fusion::tuple & version_pair) { + NETWORK_INLINE void parse_version(std::string const & partial_parsed, fusion::tuple & version_pair) { using namespace boost::spirit::qi; parse( partial_parsed.begin(), partial_parsed.end(), @@ -37,7 +37,7 @@ namespace boost { namespace network { namespace http { , version_pair); } - BOOST_NETWORK_INLINE void parse_headers(std::string const & input, std::vector > & container) { + NETWORK_INLINE void parse_headers(std::string const & input, std::vector > & container) { using namespace boost::spirit::qi; parse( input.begin(), input.end(), @@ -52,10 +52,7 @@ namespace boost { namespace network { namespace http { ); } -} /* http */ - -} /* network */ +} // namespace http +} // namespace network -} /* boost */ - #endif /* SERVER_REQUEST_PARSERS_IMPL_UW3PM6V6 */ diff --git a/include/network/protocol/http/server/impl/socket_options_setter.hpp b/include/network/protocol/http/server/impl/socket_options_setter.hpp index db88d0d2e..2906f3b0c 100644 --- a/include/network/protocol/http/server/impl/socket_options_setter.hpp +++ b/include/network/protocol/http/server/impl/socket_options_setter.hpp @@ -1,15 +1,15 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_IMPL_SOCKET_OPIONS_SETTER_20120319 -#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_IMPL_SOCKET_OPIONS_SETTER_20120319 - // Copyright 2012 Dean Michael Berris . // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_SERVER_IMPL_SOCKET_OPIONS_SETTER_20120319 +#define NETWORK_PROTOCOL_HTTP_SERVER_IMPL_SOCKET_OPIONS_SETTER_20120319 + #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { class server_options; @@ -20,9 +20,6 @@ class socket_options_setter { }; } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_SERVER_IMPL_SOCKET_OPIONS_SETTER_20120319 +#endif // NETWORK_PROTOCOL_HTTP_SERVER_IMPL_SOCKET_OPIONS_SETTER_20120319 diff --git a/include/network/protocol/http/server/impl/socket_options_setter.ipp b/include/network/protocol/http/server/impl/socket_options_setter.ipp index 7622cc03d..34465aad7 100644 --- a/include/network/protocol/http/server/impl/socket_options_setter.ipp +++ b/include/network/protocol/http/server/impl/socket_options_setter.ipp @@ -1,16 +1,16 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_IMPL_SOCKET_OPTIONS_SETTER_IPP_20120319 -#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_IMPL_SOCKET_OPTIONS_SETTER_IPP_20120319 - // Copyright 2012 Dean Michael Berris . // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_SERVER_IMPL_SOCKET_OPTIONS_SETTER_IPP_20120319 +#define NETWORK_PROTOCOL_HTTP_SERVER_IMPL_SOCKET_OPTIONS_SETTER_IPP_20120319 + #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { void socket_options_setter::set_socket_options(server_options const & options, asio::ip::tcp::socket &socket) { system::error_code ignored; @@ -48,9 +48,6 @@ void socket_options_setter::set_acceptor_options(server_options const &options, } } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_SERVER_IMPL_SOCKET_OPTIONS_SETTER_IPP_20120319 +#endif // NETWORK_PROTOCOL_HTTP_SERVER_IMPL_SOCKET_OPTIONS_SETTER_IPP_20120319 diff --git a/include/network/protocol/http/server/options.hpp b/include/network/protocol/http/server/options.hpp index 97a727ca9..add43eaca 100644 --- a/include/network/protocol/http/server/options.hpp +++ b/include/network/protocol/http/server/options.hpp @@ -1,12 +1,12 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_HPP_20120318 -#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_HPP_20120318 - // Copyright 2012 Dean Michael Berris . // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_HPP_20120318 +#define NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_HPP_20120318 + #include namespace boost { namespace asio { @@ -17,7 +17,7 @@ class io_service; } // namespace boost -namespace boost { namespace network { namespace http { +namespace network { namespace http { class server_options_pimpl; @@ -79,6 +79,4 @@ class server_options { } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_HPP_20120318 +#endif // NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_HPP_20120318 diff --git a/include/network/protocol/http/server/options.ipp b/include/network/protocol/http/server/options.ipp index 87a10b64f..8b2b13fc9 100644 --- a/include/network/protocol/http/server/options.ipp +++ b/include/network/protocol/http/server/options.ipp @@ -1,16 +1,16 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_IPP_20120318 -#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_IPP_20120318 - // Copyright 2012 Dean Michael Berris . // Copyright 2012 Google, Inc. // 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 BOOST_NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_IPP_20120318 +#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_IPP_20120318 + #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { class server_options_pimpl { public: @@ -287,6 +287,4 @@ int server_options::linger_timeout() const { } // namespace network -} // namespace boost - #endif // BOOST_NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_IPP_20120318 diff --git a/include/network/protocol/http/server/parameters.hpp b/include/network/protocol/http/server/parameters.hpp index 73051e554..1400e743e 100644 --- a/include/network/protocol/http/server/parameters.hpp +++ b/include/network/protocol/http/server/parameters.hpp @@ -1,15 +1,15 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_PARAMETERS_HPP_20101210 -#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_PARAMETERS_HPP_20101210 - // Copyright 2010 Dean Michael Berris. // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_SERVER_PARAMETERS_HPP_20101210 +#define NETWORK_PROTOCOL_HTTP_SERVER_PARAMETERS_HPP_20101210 + #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { BOOST_PARAMETER_NAME(address) BOOST_PARAMETER_NAME(port) @@ -26,10 +26,7 @@ namespace boost { namespace network { namespace http { BOOST_PARAMETER_NAME(linger) BOOST_PARAMETER_NAME(linger_timeout) -} /* http */ +} // namespace http +} // namespace network -} /* network */ - -} /* boost */ - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_SERVER_PARAMETERS_HPP_20101210 */ +#endif /* NETWORK_PROTOCOL_HTTP_SERVER_PARAMETERS_HPP_20101210 */ diff --git a/include/network/protocol/http/server/request.hpp b/include/network/protocol/http/server/request.hpp index 907d0b458..e07910140 100644 --- a/include/network/protocol/http/server/request.hpp +++ b/include/network/protocol/http/server/request.hpp @@ -11,15 +11,15 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef BOOST_NETWORK_HTTP_REQUEST_HPP -#define BOOST_NETWORK_HTTP_REQUEST_HPP +#ifndef NETWORK_HTTP_REQUEST_HPP +#define NETWORK_HTTP_REQUEST_HPP #include #include #include #include "header.hpp" -namespace boost { namespace network { namespace http { +namespace network { namespace http { /// A request received from a client. struct request @@ -43,10 +43,7 @@ namespace boost { namespace network { namespace http { } } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_HTTP_REQUEST_HPP +#endif // NETWORK_HTTP_REQUEST_HPP diff --git a/include/network/protocol/http/server/request_parser.hpp b/include/network/protocol/http/server/request_parser.hpp index 24df5d6aa..cce648e88 100644 --- a/include/network/protocol/http/server/request_parser.hpp +++ b/include/network/protocol/http/server/request_parser.hpp @@ -1,19 +1,19 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_REQUEST_PARSER_HPP_20101005 -#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_REQUEST_PARSER_HPP_20101005 - // Copyright 2010 Dean Michael Berris. // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_SERVER_REQUEST_PARSER_HPP_20101005 +#define NETWORK_PROTOCOL_HTTP_SERVER_REQUEST_PARSER_HPP_20101005 + #include #include #include #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { struct request_parser { @@ -181,10 +181,7 @@ namespace boost { namespace network { namespace http { }; -} /* http */ +} // namespace http +} // namespace network -} /* network */ - -} /* boost */ - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_SERVER_REQUEST_PARSER_HPP_20101005 */ +#endif /* NETWORK_PROTOCOL_HTTP_SERVER_REQUEST_PARSER_HPP_20101005 */ diff --git a/include/network/protocol/http/server/server.ipp b/include/network/protocol/http/server/server.ipp index 3247d6f7a..d4c8ece06 100644 --- a/include/network/protocol/http/server/server.ipp +++ b/include/network/protocol/http/server/server.ipp @@ -1,17 +1,17 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_SERVER_IPP_20120318 -#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_SERVER_IPP_20120318 - // Copyright 2012 Dean Michael Berris . // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_SERVER_SERVER_IPP_20120318 +#define NETWORK_PROTOCOL_HTTP_SERVER_SERVER_IPP_20120318 + #include #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { template sync_server::sync_server(server_options const &options, SyncHandler &handler) @@ -67,6 +67,4 @@ async_server::~async_server() { } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_SERVER_SERVER_IPP_20120318 +#endif // NETWORK_PROTOCOL_HTTP_SERVER_SERVER_IPP_20120318 diff --git a/include/network/protocol/http/server/socket_options_base.hpp b/include/network/protocol/http/server/socket_options_base.hpp index 9f4a34751..25601b090 100644 --- a/include/network/protocol/http/server/socket_options_base.hpp +++ b/include/network/protocol/http/server/socket_options_base.hpp @@ -1,17 +1,17 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_SOCKET_OPTIONS_BASE_HPP_20101210 -#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_SOCKET_OPTIONS_BASE_HPP_20101210 - // Copyright 2010 Dean Michael Berris. // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_SERVER_SOCKET_OPTIONS_BASE_HPP_20101210 +#define NETWORK_PROTOCOL_HTTP_SERVER_SOCKET_OPTIONS_BASE_HPP_20101210 + #include #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { struct socket_options_base { protected: @@ -82,10 +82,8 @@ namespace boost { namespace network { namespace http { }; -} /* http */ +} // namespace http -} /* network */ +} // namespace network -} /* boost */ - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_SERVER_SOCKET_OPTIONS_BASE_HPP_20101210 */ +#endif /* NETWORK_PROTOCOL_HTTP_SERVER_SOCKET_OPTIONS_BASE_HPP_20101210 */ diff --git a/include/network/protocol/http/server/storage_base.hpp b/include/network/protocol/http/server/storage_base.hpp index 23ad10863..faf90676f 100644 --- a/include/network/protocol/http/server/storage_base.hpp +++ b/include/network/protocol/http/server/storage_base.hpp @@ -1,15 +1,15 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_STORAGE_BASE_HPP_20101210 -#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_STORAGE_BASE_HPP_20101210 - // Copyright 2010 Dean Michael Berris. // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_SERVER_STORAGE_BASE_HPP_20101210 +#define NETWORK_PROTOCOL_HTTP_SERVER_STORAGE_BASE_HPP_20101210 + #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { struct server_storage_base { struct no_io_service {}; @@ -37,10 +37,8 @@ namespace boost { namespace network { namespace http { }; -} /* http */ +} // namespace http -} /* network */ +} // namespace network -} /* boost */ - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_SERVER_STORAGE_BASE_HPP_20101210 */ +#endif /* NETWORK_PROTOCOL_HTTP_SERVER_STORAGE_BASE_HPP_20101210 */ diff --git a/include/network/protocol/http/server/sync_impl.hpp b/include/network/protocol/http/server/sync_impl.hpp index e5ff76a0d..be1a800b8 100644 --- a/include/network/protocol/http/server/sync_impl.hpp +++ b/include/network/protocol/http/server/sync_impl.hpp @@ -1,12 +1,12 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_IMPL_HPP_20120318 -#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_IMPL_HPP_20120318 - // Copyright 2012 Dean Michael Berris . // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_SERVER_IMPL_HPP_20120318 +#define NETWORK_PROTOCOL_HTTP_SERVER_IMPL_HPP_20120318 + #include #include #include @@ -14,7 +14,7 @@ #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { class sync_server_connection; struct request; @@ -43,9 +43,6 @@ class sync_server_impl : protected socket_options_setter { }; } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_SERVER_IMPL_HPP_20120318 +#endif // NETWORK_PROTOCOL_HTTP_SERVER_IMPL_HPP_20120318 diff --git a/include/network/protocol/http/server/sync_impl.ipp b/include/network/protocol/http/server/sync_impl.ipp index dce2e7353..ae0702f0e 100644 --- a/include/network/protocol/http/server/sync_impl.ipp +++ b/include/network/protocol/http/server/sync_impl.ipp @@ -1,17 +1,17 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_SYNC_IMPL_IPP_20120319 -#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_SYNC_IMPL_IPP_20120319 - // Copyright 2012 Dean Michael Berris . // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_SERVER_SYNC_IMPL_IPP_20120319 +#define NETWORK_PROTOCOL_HTTP_SERVER_SYNC_IMPL_IPP_20120319 + #include #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { sync_server_impl::sync_server_impl(server_options const &options, function handler) @@ -59,7 +59,7 @@ void sync_server_impl::handle_accept(system::error_code const &ec) { this, asio::placeholders::error)); } else { - BOOST_NETWORK_MESSAGE("error accepting connection: " << ec); + NETWORK_MESSAGE("error accepting connection: " << ec); this->stop(); } } @@ -71,24 +71,24 @@ void sync_server_impl::start_listening() { tcp::resolver::query query(address_, port_); tcp::resolver::iterator endpoint_ = resolver.resolve(query, error); if (error) { - BOOST_NETWORK_MESSAGE("error resolving address: " << address_ << ':' << port_ << " -- reason: '" << error << '\''); + NETWORK_MESSAGE("error resolving address: " << address_ << ':' << port_ << " -- reason: '" << error << '\''); BOOST_THROW_EXCEPTION(std::runtime_error("Error resolving provided address:port combination.")); } tcp::endpoint endpoint = *endpoint_; acceptor_->open(endpoint.protocol(), error); if (error) { - BOOST_NETWORK_MESSAGE("error opening socket: " << address_ << ':' << port_ << " -- reason: '" << error << '\''); + NETWORK_MESSAGE("error opening socket: " << address_ << ':' << port_ << " -- reason: '" << error << '\''); BOOST_THROW_EXCEPTION(std::runtime_error("Error opening socket for acceptor.")); } set_acceptor_options(options_, *acceptor_); acceptor_->bind(endpoint, error); if (error) { - BOOST_NETWORK_MESSAGE("error binding to socket: " << address_ << ':' << port_ << " -- reason: '" << error << '\''); + NETWORK_MESSAGE("error binding to socket: " << address_ << ':' << port_ << " -- reason: '" << error << '\''); BOOST_THROW_EXCEPTION(std::runtime_error("Error binding to socket for acceptor.")); } acceptor_->listen(tcp::socket::max_connections, error); if (error) { - BOOST_NETWORK_MESSAGE("error listening on socket: " << address_ << ':' << port_ << " -- reason: '" << error << '\''); + NETWORK_MESSAGE("error listening on socket: " << address_ << ':' << port_ << " -- reason: '" << error << '\''); BOOST_THROW_EXCEPTION(std::runtime_error("Error listening on socket for acceptor.")); } new_connection_.reset(new sync_server_connection(*service_, handler_)); @@ -100,9 +100,6 @@ void sync_server_impl::start_listening() { } } // namespace http - } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_PROTOCOL_HTTP_SERVER_SYNC_IMPL_IPP_20120319 +#endif // NETWORK_PROTOCOL_HTTP_SERVER_SYNC_IMPL_IPP_20120319 diff --git a/include/network/protocol/http/server/sync_server.hpp b/include/network/protocol/http/server/sync_server.hpp index 27b68fd5f..dcb03f5d5 100644 --- a/include/network/protocol/http/server/sync_server.hpp +++ b/include/network/protocol/http/server/sync_server.hpp @@ -1,4 +1,3 @@ - // Copyright 2010 Dean Michael Berris. // Copyright 2010 Glyn Matthews. // Copyright 2012 Google, Inc. @@ -6,8 +5,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_SYNC_SERVER_HPP_20101025 -#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_SYNC_SERVER_HPP_20101025 +#ifndef NETWORK_PROTOCOL_HTTP_SERVER_SYNC_SERVER_HPP_20101025 +#define NETWORK_PROTOCOL_HTTP_SERVER_SYNC_SERVER_HPP_20101025 #include #include @@ -22,7 +21,7 @@ #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { template struct sync_server_base : server_storage_base, socket_options_base { @@ -96,24 +95,24 @@ namespace boost { namespace network { namespace http { tcp::resolver::query query(address_, port_); tcp::resolver::iterator endpoint_iterator = resolver.resolve(query, error); if (error) { - BOOST_NETWORK_MESSAGE("Error resolving address: " << address_ << ':' << port_); + NETWORK_MESSAGE("Error resolving address: " << address_ << ':' << port_); return; } tcp::endpoint endpoint = *endpoint_iterator; acceptor_.open(endpoint.protocol(), error); if (error) { - BOOST_NETWORK_MESSAGE("Error opening socket: " << address_ << ':' << port_ << " -- reason: '" << error << '\''); + NETWORK_MESSAGE("Error opening socket: " << address_ << ':' << port_ << " -- reason: '" << error << '\''); return; } socket_options_base::acceptor_options(acceptor_); acceptor_.bind(endpoint, error); if (error) { - BOOST_NETWORK_MESSAGE("Error binding to socket: " << address_ << ':' << port_ << " -- reason: '" << error << '\''); + NETWORK_MESSAGE("Error binding to socket: " << address_ << ':' << port_ << " -- reason: '" << error << '\''); return; } acceptor_.listen(tcp::socket::max_connections, error); if (error) { - BOOST_NETWORK_MESSAGE("Error listening on socket: " << address_ << ':' << port_ << " -- reason: '" << error << '\''); + NETWORK_MESSAGE("Error listening on socket: " << address_ << ':' << port_ << " -- reason: '" << error << '\''); return; } new_connection.reset(new sync_connection(service_, handler_)); @@ -124,10 +123,7 @@ namespace boost { namespace network { namespace http { } }; -} /* http */ - -} /* network */ +} // namespace http +} // namespace network -} /* boost */ - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_SERVER_SYNC_SERVER_HPP_20101025 */ +#endif /* NETWORK_PROTOCOL_HTTP_SERVER_SYNC_SERVER_HPP_20101025 */ diff --git a/include/network/protocol/http/support/client_or_server.hpp b/include/network/protocol/http/support/client_or_server.hpp index 90f5ab900..83596167d 100644 --- a/include/network/protocol/http/support/client_or_server.hpp +++ b/include/network/protocol/http/support/client_or_server.hpp @@ -1,17 +1,17 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SUPPORT_CLIENT_OR_SERVER_HPP_20101127 -#define BOOST_NETWORK_PROTOCOL_HTTP_SUPPORT_CLIENT_OR_SERVER_HPP_20101127 - // Copyright 2010 Dean Michael Berris. // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_HTTP_SUPPORT_CLIENT_OR_SERVER_HPP_20101127 +#define NETWORK_PROTOCOL_HTTP_SUPPORT_CLIENT_OR_SERVER_HPP_20101127 + #include #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { template struct unsupported_tag; @@ -34,10 +34,7 @@ namespace boost { namespace network { namespace http { typedef tags::client type; }; -} /* http */ +} // namespace http +} // namespace network -} /* network */ - -} /* boost */ - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_SUPPORT_CLIENT_OR_SERVER_HPP_20101127 */ +#endif /* NETWORK_PROTOCOL_HTTP_SUPPORT_CLIENT_OR_SERVER_HPP_20101127 */ diff --git a/include/network/protocol/http/support/is_client.hpp b/include/network/protocol/http/support/is_client.hpp index 20d275e01..003dfc946 100644 --- a/include/network/protocol/http/support/is_client.hpp +++ b/include/network/protocol/http/support/is_client.hpp @@ -1,15 +1,15 @@ -#ifndef BOOST_NETWORK_PROTOCOL_SUPPORT_IS_CLIENT_HPP_20101118 -#define BOOST_NETWORK_PROTOCOL_SUPPORT_IS_CLIENT_HPP_20101118 - // Copyright 2010 Dean Michael Berris. // Copyright 2012 Google, Inc. // 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 BOOST_NETWORK_PROTOCOL_SUPPORT_IS_CLIENT_HPP_20101118 +#define BOOST_NETWORK_PROTOCOL_SUPPORT_IS_CLIENT_HPP_20101118 + #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { template struct is_client : mpl::false_ {}; @@ -17,11 +17,8 @@ namespace boost { namespace network { namespace http { template struct is_client::type> : mpl::true_ {}; -} /* http */ +} // namespace http +} // namespace network -} /* network */ - -} /* boost */ - #endif /* BOOST_NETWORK_PROTOCOL_SUPPORT_IS_CLIENT_HPP_20101118 */ diff --git a/include/network/protocol/http/support/is_http.hpp b/include/network/protocol/http/support/is_http.hpp index 31fb5e4fb..78f6d77ee 100644 --- a/include/network/protocol/http/support/is_http.hpp +++ b/include/network/protocol/http/support/is_http.hpp @@ -1,16 +1,16 @@ -#ifndef BOOST_NETWORK_SUPPORT_IS_HTTP_HPP_20100622 -#define BOOST_NETWORK_SUPPORT_IS_HTTP_HPP_20100622 - // Copyright 2010 (c) Dean Michael Berris // Copyright 2012 Google, Inc. // 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 NETWORK_SUPPORT_IS_HTTP_HPP_20100622 +#define NETWORK_SUPPORT_IS_HTTP_HPP_20100622 + #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { template struct is_http : mpl::false_ {}; @@ -22,6 +22,4 @@ namespace boost { namespace network { namespace http { } // namespace network -} // namespace boost - -#endif // BOOST_NETWORK_SUPPORT_IS_HTTP_HPP_20100622 +#endif // NETWORK_SUPPORT_IS_HTTP_HPP_20100622 diff --git a/include/network/protocol/http/support/is_keepalive.hpp b/include/network/protocol/http/support/is_keepalive.hpp index 4331eae1d..ce27abb51 100644 --- a/include/network/protocol/http/support/is_keepalive.hpp +++ b/include/network/protocol/http/support/is_keepalive.hpp @@ -1,16 +1,16 @@ -#ifndef BOOST_NETWORK_SUPPORT_IS_KEEPALIVE_HPP_20100927 -#define BOOST_NETWORK_SUPPORT_IS_KEEPALIVE_HPP_20100927 - // Copyright 2010 (c) Dean Michael Berris // Copyright 2012 Google, Inc. // 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 NETWORK_SUPPORT_IS_KEEPALIVE_HPP_20100927 +#define NETWORK_SUPPORT_IS_KEEPALIVE_HPP_20100927 + #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { template struct unsupported_tag; @@ -21,10 +21,8 @@ namespace boost { namespace network { namespace http { template struct is_keepalive::type> : mpl::true_ {}; -} /* http */ +} // namespace http -} /* network */ +} // namespace network -} /* boost */ - -#endif /* BOOST_NETWORK_SUPPORT_IS_KEEPALIVE_HPP_20100927 */ +#endif /* NETWORK_SUPPORT_IS_KEEPALIVE_HPP_20100927 */ diff --git a/include/network/protocol/http/support/is_server.hpp b/include/network/protocol/http/support/is_server.hpp index 4baee3e20..cc1259064 100644 --- a/include/network/protocol/http/support/is_server.hpp +++ b/include/network/protocol/http/support/is_server.hpp @@ -1,15 +1,15 @@ -#ifndef BOOST_NETWORK_PROTOCOL_SUPPORT_IS_SERVER_HPP_20101118 -#define BOOST_NETWORK_PROTOCOL_SUPPORT_IS_SERVER_HPP_20101118 - // Copyright 2010 Dean Michael Berris. // Copyright 2012 Google, Inc. // 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 NETWORK_PROTOCOL_SUPPORT_IS_SERVER_HPP_20101118 +#define NETWORK_PROTOCOL_SUPPORT_IS_SERVER_HPP_20101118 + #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { template struct is_server : mpl::false_ {}; @@ -17,10 +17,8 @@ namespace boost { namespace network { namespace http { template struct is_server::type> : mpl::true_ {}; -} /* http */ +} // namespace http -} /* network */ +} // namespace network -} /* boost */ - -#endif /* BOOST_NETWORK_PROTOCOL_SUPPORT_IS_SERVER_HPP_20101118 */ +#endif /* NETWORK_PROTOCOL_SUPPORT_IS_SERVER_HPP_20101118 */ diff --git a/include/network/protocol/http/support/is_simple.hpp b/include/network/protocol/http/support/is_simple.hpp index b2b35006d..e27f3c110 100644 --- a/include/network/protocol/http/support/is_simple.hpp +++ b/include/network/protocol/http/support/is_simple.hpp @@ -1,16 +1,16 @@ -#ifndef BOOST_NETWORK_SUPPORT_IS_SIMPLE_HPP_20100927 -#define BOOST_NETWORK_SUPPORT_IS_SIMPLE_HPP_20100927 - // Copyright 2010 (c) Dean Michael Berris // Copyright 2012 Google, Inc. // 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 NETWORK_SUPPORT_IS_SIMPLE_HPP_20100927 +#define NETWORK_SUPPORT_IS_SIMPLE_HPP_20100927 + #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { template struct is_simple : mpl::false_ {}; @@ -18,10 +18,8 @@ namespace boost { namespace network { namespace http { template struct is_simple::type> : mpl::true_ {}; -} /* http */ +} // namespace http -} /* network */ +} // namespace network -} /* boost */ - -#endif /* BOOST_NETWORK_SUPPORT_IS_SIMPLE_HPP_20100927 */ +#endif /* NETWORK_SUPPORT_IS_SIMPLE_HPP_20100927 */ diff --git a/include/network/protocol/http/support/sync_only.hpp b/include/network/protocol/http/support/sync_only.hpp index 940948318..275cc0ab8 100644 --- a/include/network/protocol/http/support/sync_only.hpp +++ b/include/network/protocol/http/support/sync_only.hpp @@ -1,16 +1,16 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SUPPORT_SYNC_ONLY_HPP_20100927 -#define BOOST_NETWORK_PROTOCOL_HTTP_SUPPORT_SYNC_ONLY_HPP_20100927 - -// Copyright Dean Michael Berris 2010. +// Copyright Dean Michael Berris 2010. // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef NETWORK_PROTOCOL_HTTP_SUPPORT_SYNC_ONLY_HPP_20100927 +#define NETWORK_PROTOCOL_HTTP_SUPPORT_SYNC_ONLY_HPP_20100927 #include #include -namespace boost { namespace network { namespace http { +namespace network { namespace http { template struct sync_only : @@ -24,10 +24,8 @@ namespace boost { namespace network { namespace http { > {}; -} /* http */ +} // namespace http -} /* network */ +} // namespace network -} /* boost */ - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_SUPPORT_SYNC_ONLY_HPP_20100927 */ +#endif /* NETWORK_PROTOCOL_HTTP_SUPPORT_SYNC_ONLY_HPP_20100927 */ diff --git a/include/network/uri.hpp b/include/network/uri.hpp index 4819cbce0..ce0735739 100644 --- a/include/network/uri.hpp +++ b/include/network/uri.hpp @@ -1,14 +1,14 @@ -// Copyright (c) Glyn Matthews 2012. +// Copyright (c) Glyn Matthews 2012. +// Copyright 2012 Dean Michael Berris // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef __NETWORK_URI_INC__ -# define __NETWORK_URI_INC__ +#ifndef NETWORK_URI_INC +# define NETWORK_URI_INC #include #include -#endif // __NETWORK_URI_INC__ +#endif // NETWORK_URI_INC diff --git a/include/network/uri/accessors.hpp b/include/network/uri/accessors.hpp index 1afecf471..d15b506be 100644 --- a/include/network/uri/accessors.hpp +++ b/include/network/uri/accessors.hpp @@ -1,20 +1,19 @@ -// Copyright (c) Glyn Matthews 2011, 2012. +// Copyright (c) Glyn Matthews 2011, 2012. // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) -#ifndef __BOOST_NETWORK_URI_URI_ACCESSORS_INC__ -# define __BOOST_NETWORK_URI_URI_ACCESSORS_INC__ +#ifndef NETWORK_URI_URI_ACCESSORS_INC +#define NETWORK_URI_URI_ACCESSORS_INC -# include -# include -# include -# include -# include - +#include +#include +#include +#include +#include namespace network { namespace details { @@ -105,5 +104,4 @@ uri::string_type decoded_fragment(const uri &uri_) { } } // namespace network - -#endif // __BOOST_NETWORK_URI_URI_ACCESSORS_INC__ +#endif // NETWORK_URI_URI_ACCESSORS_INC diff --git a/include/network/uri/builder.hpp b/include/network/uri/builder.hpp index e8881926e..0ddd1db7c 100644 --- a/include/network/uri/builder.hpp +++ b/include/network/uri/builder.hpp @@ -1,16 +1,15 @@ -// Copyright (c) Glyn Matthews 2012. +// Copyright (c) Glyn Matthews 2012. +// Copyright 2012 Dean Michael Berris // Copyright 2012 Google, Inc. // 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 __BOOST_NETWORK_URI_BUILDER_INC__ -# define __BOOST_NETWORK_URI_BUILDER_INC__ - - -# include +#ifndef NETWORK_URI_BUILDER_INC +#define NETWORK_URI_BUILDER_INC +#include namespace network { class builder { @@ -130,4 +129,4 @@ class builder { } // namespace network -#endif // __BOOST_NETWORK_URI_BUILDER_INC__ +#endif // NETWORK_URI_BUILDER_INC diff --git a/include/network/uri/config.hpp b/include/network/uri/config.hpp index 9b395c9cb..876a7bb62 100644 --- a/include/network/uri/config.hpp +++ b/include/network/uri/config.hpp @@ -1,22 +1,23 @@ -// Copyright (c) Glyn Matthews 2012. +// Copyright (c) Glyn Matthews 2012. +// Copyright 2012 Dean Michael Berris // Copyright 2012 Google, Inc. // 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 __BOOST_NETWORK_URI_CONFIG_INC__ -# define __BOOST_NETWORK_URI_CONFIG_INC__ +#ifndef NETWORK_URI_CONFIG_INC +#define NETWORK_URI_CONFIG_INC -# include -# include +#include +#include -# if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_URI_DYN_LINK) -# define BOOST_URI_DECL -# else -# define BOOST_URI_DECL -# endif // defined(BOOST_ALL_DYN_LINK) || defined(BOOST_URI_DYN_LINK) +#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_URI_DYN_LINK) +#define BOOST_URI_DECL +#else +#define BOOST_URI_DECL +#endif // defined(BOOST_ALL_DYN_LINK) || defined(BOOST_URI_DYN_LINK) -#endif // __BOOST_NETWORK_URI_CONFIG_INC__ +#endif // NETWORK_URI_CONFIG_INC diff --git a/include/network/uri/decode.hpp b/include/network/uri/decode.hpp index d0d2ce5af..c49e95755 100644 --- a/include/network/uri/decode.hpp +++ b/include/network/uri/decode.hpp @@ -1,19 +1,17 @@ -// Copyright (c) Glyn Matthews 2011, 2012. +// Copyright (c) Glyn Matthews 2011, 2012. +// Copyright 2012 Dean Michael Berris // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_URI_DECODE_INC +#define NETWORK_URI_DECODE_INC -#ifndef __BOOST_NETWORK_URI_DECODE_INC__ -# define __BOOST_NETWORK_URI_DECODE_INC__ - - -# include -# include -# include -# include - +#include +#include +#include +#include namespace network { namespace detail { @@ -101,5 +99,4 @@ std::string decoded(const std::string &input) { } } // namespace network - -#endif // __BOOST_NETWORK_URI_DECODE_INC__ +#endif // NETWORK_URI_DECODE_INC diff --git a/include/network/uri/detail/uri_parts.hpp b/include/network/uri/detail/uri_parts.hpp index c012f1de3..58f155bf8 100644 --- a/include/network/uri/detail/uri_parts.hpp +++ b/include/network/uri/detail/uri_parts.hpp @@ -1,15 +1,15 @@ // Copyright 2009-2012 Dean Michael Berris, Jeroen Habraken, Glyn Matthews. // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_NETWORK_URL_DETAIL_URL_PARTS_HPP_ -# define BOOST_NETWORK_URL_DETAIL_URL_PARTS_HPP_ +#ifndef NETWORK_URL_DETAIL_URL_PARTS_HPP_ +#define NETWORK_URL_DETAIL_URL_PARTS_HPP_ -# include -# include +#include +#include namespace network { namespace detail { @@ -96,4 +96,4 @@ boost::iterator_range scheme; } // namespace network -#endif // BOOST_NETWORK_URL_DETAIL_URL_PARTS_HPP_ +#endif // NETWORK_URL_DETAIL_URL_PARTS_HPP_ diff --git a/include/network/uri/directives.hpp b/include/network/uri/directives.hpp index 9a6a82c3c..b7fa86a7c 100644 --- a/include/network/uri/directives.hpp +++ b/include/network/uri/directives.hpp @@ -1,16 +1,14 @@ -// Copyright (c) Glyn Matthews 2011, 2012. +// Copyright (c) Glyn Matthews 2011, 2012. +// Copyright 2012 Dean Michael Berris // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_URI_DIRECTIVES_INC +#define NETWORK_URI_DIRECTIVES_INC -#ifndef __BOOST_NETWORK_URI_DIRECTIVES_INC__ -# define __BOOST_NETWORK_URI_DIRECTIVES_INC__ - - -# include - +#include namespace network { inline @@ -31,15 +29,13 @@ uri &operator << (uri &uri_, const Directive &directive) { } } // namespace network +#include +#include +#include +#include +#include +#include +#include +#include -# include -# include -# include -# include -# include -# include -# include -# include - - -#endif // __BOOST_NETWORK_URI_DIRECTIVES_INC__ +#endif // NETWORK_URI_DIRECTIVES_INC diff --git a/include/network/uri/directives/authority.hpp b/include/network/uri/directives/authority.hpp index f6b9110dc..1148653bd 100644 --- a/include/network/uri/directives/authority.hpp +++ b/include/network/uri/directives/authority.hpp @@ -1,12 +1,12 @@ -// Copyright (c) Glyn Matthews 2011, 2012. +// Copyright (c) Glyn Matthews 2011, 2012. +// Copyright 2012 Dean Michael Berris // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef __BOOST_NETWORK_URI_DIRECTIVES_AUTHORITY_INC__ -# define __BOOST_NETWORK_URI_DIRECTIVES_AUTHORITY_INC__ +#ifndef NETWORK_URI_DIRECTIVES_AUTHORITY_INC +#define NETWORK_URI_DIRECTIVES_AUTHORITY_INC namespace network { struct authority_directive { @@ -32,5 +32,4 @@ authority_directive authority(const std::string &authority) { } } // namespace network - -#endif // __BOOST_NETWORK_URI_DIRECTIVES_AUTHORITY_INC__ +#endif // NETWORK_URI_DIRECTIVES_AUTHORITY_INC diff --git a/include/network/uri/directives/fragment.hpp b/include/network/uri/directives/fragment.hpp index 54981eef2..1bc21c037 100644 --- a/include/network/uri/directives/fragment.hpp +++ b/include/network/uri/directives/fragment.hpp @@ -1,16 +1,15 @@ -// Copyright (c) Glyn Matthews 2011, 2012. +// Copyright (c) Glyn Matthews 2011, 2012. +// Copyright 2012 Dean Michael Berris // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_URI_DIRECTIVES_FRAGMENT_INC__ +#define NETWORK_URI_DIRECTIVES_FRAGMENT_INC__ -#ifndef __BOOST_NETWORK_URI_DIRECTIVES_FRAGMENT_INC__ -# define __BOOST_NETWORK_URI_DIRECTIVES_FRAGMENT_INC__ - - -# include -# include +#include +#include namespace network { struct fragment_directive { @@ -37,5 +36,4 @@ fragment_directive fragment(const std::string &fragment) { } } // namespace network - -#endif // __BOOST_NETWORK_URI_DIRECTIVES_FRAGMENT_INC__ +#endif // NETWORK_URI_DIRECTIVES_FRAGMENT_INC__ diff --git a/include/network/uri/directives/host.hpp b/include/network/uri/directives/host.hpp index 531b290c1..e56f21d79 100644 --- a/include/network/uri/directives/host.hpp +++ b/include/network/uri/directives/host.hpp @@ -1,17 +1,16 @@ -// Copyright (c) Glyn Matthews 2011, 2012. +// Copyright (c) Glyn Matthews 2011, 2012. +// Copyright 2012 Dean Michael Berris // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) -#ifndef __BOOST_NETWORK_URI_DIRECTIVES_HOST_INC__ -# define __BOOST_NETWORK_URI_DIRECTIVES_HOST_INC__ - - -# include -# include +#ifndef NETWORK_URI_DIRECTIVES_HOST_INC +#define NETWORK_URI_DIRECTIVES_HOST_INC +#include +#include namespace network { struct host_directive { @@ -37,5 +36,4 @@ host_directive host(const std::string &host) { } } // namespace network - -#endif // __BOOST_NETWORK_URI_DIRECTIVES_HOST_INC__ +#endif // NETWORK_URI_DIRECTIVES_HOST_INC diff --git a/include/network/uri/directives/path.hpp b/include/network/uri/directives/path.hpp index e09eda4f4..3f40f414d 100644 --- a/include/network/uri/directives/path.hpp +++ b/include/network/uri/directives/path.hpp @@ -1,17 +1,15 @@ -// Copyright (c) Glyn Matthews 2011, 2012. +// Copyright (c) Glyn Matthews 2011, 2012. +// Copyright 2012 Dean Michael Berris // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_URI_DIRECTIVES_PATH_INC +#define NETWORK_URI_DIRECTIVES_PATH_INC -#ifndef __BOOST_NETWORK_URI_DIRECTIVES_PATH_INC__ -# define __BOOST_NETWORK_URI_DIRECTIVES_PATH_INC__ - - -# include -# include - +#include +#include namespace network { struct path_directive { @@ -58,5 +56,4 @@ encoded_path_directive encoded_path(const std::string &path) { } } // namespace network - -#endif // __BOOST_NETWORK_URI_DIRECTIVES_PATH_INC__ +#endif // NETWORK_URI_DIRECTIVES_PATH_INC diff --git a/include/network/uri/directives/port.hpp b/include/network/uri/directives/port.hpp index c5e26a406..13e805243 100644 --- a/include/network/uri/directives/port.hpp +++ b/include/network/uri/directives/port.hpp @@ -1,19 +1,18 @@ -// Copyright (c) Glyn Matthews 2011, 2012. +// Copyright (c) Glyn Matthews 2011, 2012. +// Copyright 2012 Dean Michael Berris // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_URI_DIRECTIVES_PORT_INC +#define NETWORK_URI_DIRECTIVES_PORT_INC -#ifndef __BOOST_NETWORK_URI_DIRECTIVES_PORT_INC__ -# define __BOOST_NETWORK_URI_DIRECTIVES_PORT_INC__ - - -# include -# include -# include -# include +#include +#include +#include +#include namespace network { struct port_directive { @@ -49,5 +48,4 @@ port_directive port(boost::uint16_t port) { } } // namespace network - -#endif // __BOOST_NETWORK_URI_DIRECTIVES_PORT_INC__ +#endif // NETWORK_URI_DIRECTIVES_PORT_INC diff --git a/include/network/uri/directives/query.hpp b/include/network/uri/directives/query.hpp index 5f107723d..982067967 100644 --- a/include/network/uri/directives/query.hpp +++ b/include/network/uri/directives/query.hpp @@ -1,17 +1,15 @@ -// Copyright (c) Glyn Matthews 2011, 2012. +// Copyright (c) Glyn Matthews 2011, 2012. +// Copyright 2012 Dean Michael Berris // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_URI_DIRECTIVES_QUERY_INC +#define NETWORK_URI_DIRECTIVES_QUERY_INC -#ifndef __BOOST_NETWORK_URI_DIRECTIVES_QUERY_INC__ -# define __BOOST_NETWORK_URI_DIRECTIVES_QUERY_INC__ - - -# include -# include - +#include +#include namespace network { struct query_directive { @@ -72,5 +70,4 @@ query_key_query_directive query(const std::string &key, const std::string &query } } // namespace network - -#endif // __BOOST_NETWORK_URI_DIRECTIVES_QUERY_INC__ +#endif // NETWORK_URI_DIRECTIVES_QUERY_INC diff --git a/include/network/uri/directives/scheme.hpp b/include/network/uri/directives/scheme.hpp index 7446cd0fd..2437e9d31 100644 --- a/include/network/uri/directives/scheme.hpp +++ b/include/network/uri/directives/scheme.hpp @@ -1,18 +1,16 @@ -// Copyright (c) Glyn Matthews 2011, 2012. +// Copyright (c) Glyn Matthews 2011, 2012. +// Copyright 2012 Dean Michael Berris // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_URI_DIRECTIVES_SCHEME_INC +#define NETWORK_URI_DIRECTIVES_SCHEME_INC -#ifndef __BOOST_NETWORK_URI_DIRECTIVES_SCHEME_INC__ -# define __BOOST_NETWORK_URI_DIRECTIVES_SCHEME_INC__ - - -# include -# include -# include - +#include +#include +#include namespace network { struct scheme_directive { @@ -61,5 +59,4 @@ uri &file(uri &uri_) { } // namespace schemes } // namespace network - -#endif // __BOOST_NETWORK_URI_DIRECTIVES_SCHEME_INC__ +#endif // NETWORK_URI_DIRECTIVES_SCHEME_INC diff --git a/include/network/uri/directives/user_info.hpp b/include/network/uri/directives/user_info.hpp index af33e45f3..8f609dbae 100644 --- a/include/network/uri/directives/user_info.hpp +++ b/include/network/uri/directives/user_info.hpp @@ -1,17 +1,15 @@ -// Copyright (c) Glyn Matthews 2011, 2012. +// Copyright (c) Glyn Matthews 2011, 2012. +// Copyright 2012 Dean Michael Berris // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_URI_DIRECTIVES_USER_INFO_INC +#define NETWORK_URI_DIRECTIVES_USER_INFO_INC -#ifndef __BOOST_NETWORK_URI_DIRECTIVES_USER_INFO_INC__ -# define __BOOST_NETWORK_URI_DIRECTIVES_USER_INFO_INC__ - - -# include -# include - +#include +#include namespace network { struct user_info_directive { @@ -38,5 +36,4 @@ user_info_directive user_info(const std::string &user_info) { } } // namespace network - -#endif // __BOOST_NETWORK_URI_DIRECTIVES_USER_INFO_INC__ +#endif // NETWORK_URI_DIRECTIVES_USER_INFO_INC diff --git a/include/network/uri/encode.hpp b/include/network/uri/encode.hpp index 5c79cda6e..b54939408 100644 --- a/include/network/uri/encode.hpp +++ b/include/network/uri/encode.hpp @@ -1,20 +1,18 @@ -// Copyright (c) Glyn Matthews 2011, 2012. +// Copyright (c) Glyn Matthews 2011, 2012. +// Copyright 2012 Dean Michael Berris // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_URI_ENCODE_INC +#define NETWORK_URI_ENCODE_INC -#ifndef __BOOST_NETWORK_URI_ENCODE_INC__ -# define __BOOST_NETWORK_URI_ENCODE_INC__ - - -# include -# include -# include -# include -# include - +#include +#include +#include +#include +#include namespace network { namespace detail { @@ -169,5 +167,4 @@ std::string encoded(const std::string &input) { } } // namespace network - -#endif // __BOOST_NETWORK_URI_ENCODE_INC__ +#endif // NETWORK_URI_ENCODE_INC diff --git a/include/network/uri/normalize.hpp b/include/network/uri/normalize.hpp index bfe098d8f..df85cfc02 100644 --- a/include/network/uri/normalize.hpp +++ b/include/network/uri/normalize.hpp @@ -1,13 +1,14 @@ -// Copyright (c) Glyn Matthews 2012. +// Copyright (c) Glyn Matthews 2012. +// Copyright 2012 Dean Michael Berris +// Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_URI_NORMALIZE_INC +#define NETWORK_URI_NORMALIZE_INC -#ifndef __BOOST_NETWORK_URI_NORMALIZE_INC__ -# define __BOOST_NETWORK_URI_NORMALIZE_INC__ - -# include +#include namespace network { uri::string_type normalize_path(const uri::const_range_type &path); @@ -29,4 +30,4 @@ uri::string_type normalize_path(const uri::const_range_type &path); //uri::string_type normalize_query(const uri &uri_); } // namespace network -#endif // __BOOST_NETWORK_URI_NORMALIZE_INC__ +#endif // NETWORK_URI_NORMALIZE_INC diff --git a/include/network/uri/schemes.hpp b/include/network/uri/schemes.hpp index 4cc16ff10..16669137d 100644 --- a/include/network/uri/schemes.hpp +++ b/include/network/uri/schemes.hpp @@ -1,12 +1,12 @@ -// Copyright 2012 Glyn Matthews. +// Copyright 2012 Glyn Matthews. +// Copyright 2012 Dean Michael Berris // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef __BOOST_NETWORK_URI_SCHEMES_INC__ -# define __BOOST_NETWORK_URI_SCHEMES_INC__ +#ifndef NETWORK_URI_SCHEMES_INC +#define NETWORK_URI_SCHEMES_INC #include #include @@ -31,5 +31,4 @@ class opaque_schemes { boost::optional default_port(const std::string &scheme); } // namespace network - -#endif // __BOOST_NETWORK_URI_SCHEMES_INC__ +#endif // NETWORK_URI_SCHEMES_INC diff --git a/include/network/uri/uri.hpp b/include/network/uri/uri.hpp index aaf3b8caa..2f2a33df7 100644 --- a/include/network/uri/uri.hpp +++ b/include/network/uri/uri.hpp @@ -1,26 +1,24 @@ // Copyright 2009-2012 Dean Michael Berris, Jeroen Habraken, Glyn Matthews. // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) -#ifndef __BOOST_NETWORK_URI_INC__ -# define __BOOST_NETWORK_URI_INC__ +#ifndef NETWORK_URI_INC +#define NETWORK_URI_INC -# pragma once - -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace network { namespace detail { @@ -351,9 +349,9 @@ bool operator < (const uri &lhs, const uri &rhs) { } } // namespace network -# include -# include -# include +#include +#include +#include namespace network { @@ -406,7 +404,7 @@ uri from_parts(const uri::string_type &base_uri, } } // namespace network -# include +#include namespace network { inline @@ -418,4 +416,4 @@ uri from_file(const boost::filesystem::path &path_) { } // namespace network -#endif // __BOOST_NETWORK_URI_INC__ +#endif // NETWORK_URI_INC diff --git a/include/network/uri/uri.ipp b/include/network/uri/uri.ipp index cf3a49ccf..9140c1f20 100644 --- a/include/network/uri/uri.ipp +++ b/include/network/uri/uri.ipp @@ -1,8 +1,8 @@ // Copyright 2009-2012 Dean Michael Berris, Jeroen Habraken, Glyn Matthews. // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) #include diff --git a/include/network/uri/uri_io.hpp b/include/network/uri/uri_io.hpp index c71ff898f..27be91509 100644 --- a/include/network/uri/uri_io.hpp +++ b/include/network/uri/uri_io.hpp @@ -1,16 +1,14 @@ -// Copyright (c) Glyn Matthews 2011, 2012. +// Copyright (c) Glyn Matthews 2011, 2012. +// Copyright 2012 Dean Michael Berris // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +#ifndef NETWORK_URI_URI_IO_INC +#define NETWORK_URI_URI_IO_INC -#ifndef __BOOST_NETWORK_URI_URI_IO_INC__ -# define __BOOST_NETWORK_URI_URI_IO_INC__ - - -# include - +#include namespace network { inline @@ -19,5 +17,4 @@ std::ostream &operator << (std::ostream &os, const uri &uri_) { } } // namespace network - -#endif // __BOOST_NETWORK_URI_URI_IO_INC__ +#endif // NETWORK_URI_URI_IO_INC diff --git a/include/network/utils/thread_pool.hpp b/include/network/utils/thread_pool.hpp index 375e4acc7..5b6e59611 100644 --- a/include/network/utils/thread_pool.hpp +++ b/include/network/utils/thread_pool.hpp @@ -1,12 +1,12 @@ -#ifndef BOOST_NETWORK_UTILS_THREAD_POOL_HPP_20101020 -#define BOOST_NETWORK_UTILS_THREAD_POOL_HPP_20101020 - // Copyright 2010 Dean Michael Berris. // Copyright 2012 Google, Inc. // 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 NETWORK_UTILS_THREAD_POOL_HPP_20101020 +#define NETWORK_UTILS_THREAD_POOL_HPP_20101020 + #include #include #include @@ -14,7 +14,7 @@ #include #include -namespace boost { namespace network { namespace utils { +namespace network { namespace utils { typedef boost::shared_ptr io_service_ptr; typedef boost::shared_ptr worker_threads_ptr; @@ -38,9 +38,7 @@ inline void swap(thread_pool & l, thread_pool & r) { l.swap(r); } -} // utils - -} // network +} // namespace utils +} // namespace network -} // boost -#endif /* BOOST_NETWORK_UTILS_THREAD_POOL_HPP_20101020 */ +#endif /* NETWORK_UTILS_THREAD_POOL_HPP_20101020 */ diff --git a/include/network/utils/thread_pool.ipp b/include/network/utils/thread_pool.ipp index 96ded564c..d3c8ac2ec 100644 --- a/include/network/utils/thread_pool.ipp +++ b/include/network/utils/thread_pool.ipp @@ -1,15 +1,15 @@ -#ifndef BOOST_NETWORK_UTILS_THREAD_POOL_IPP_20111021 -#define BOOST_NETWORK_UTILS_THREAD_POOL_IPP_20111021 - // Copyright 2011 Dean Michael Berris . // Copyright 2011 Google, Inc. // 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 NETWORK_UTILS_THREAD_POOL_IPP_20111021 +#define NETWORK_UTILS_THREAD_POOL_IPP_20111021 + #include -namespace boost { namespace network { namespace utils { +namespace network { namespace utils { struct thread_pool_pimpl { thread_pool_pimpl( @@ -115,10 +115,7 @@ thread_pool::~thread_pool() { delete pimpl; } -} /* utils */ +} // namespace utils +} // namespace network -} /* network */ - -} /* boost */ - -#endif /* BOOST_NETWORK_UTILS_THREAD_POOL_IPP_20111021 */ +#endif /* NETWORK_UTILS_THREAD_POOL_IPP_20111021 */ diff --git a/include/network/version.hpp b/include/network/version.hpp index 3046c7f3e..55f256501 100644 --- a/include/network/version.hpp +++ b/include/network/version.hpp @@ -1,24 +1,23 @@ -#ifndef BOOST_NETWORK_VERSION_HPP_20091214 -#define BOOST_NETWORK_VERSION_HPP_20091214 - -// Copyright Dean Michael Berris 2009. -// Copyright Glyn Matthews 2010. +// Copyright Dean Michael Berris 2009. +// Copyright Glyn Matthews 2010. // Copyright 2012 Google, Inc. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) -#include +#ifndef NETWORK_VERSION_HPP_20091214 +#define NETWORK_VERSION_HPP_20091214 -#define BOOST_NETLIB_VERSION_MAJOR 0 -#define BOOST_NETLIB_VERSION_MINOR 10 -#define BOOST_NETLIB_VERSION_INCREMENT 0a +#include -#ifndef BOOST_NETLIB_VERSION -# define BOOST_NETLIB_VERSION \ - BOOST_STRINGIZE(BOOST_NETLIB_VERSION_MAJOR) "." \ - BOOST_STRINGIZE(BOOST_NETLIB_VERSION_MINOR) "." \ - BOOST_STRINGIZE(BOOST_NETLIB_VERSION_INCREMENT) -#endif // BOOST_NETLIB_VERSION +#define NETLIB_VERSION_MAJOR 1 +#define NETLIB_VERSION_MINOR 0 +#define NETLIB_VERSION_INCREMENT 0a -#endif // BOOST_NETWORK_VERSION_HPP_20091214 +#ifndef NETLIB_VERSION +#define NETLIB_VERSION \ + BOOST_STRINGIZE(NETLIB_VERSION_MAJOR) "." \ + BOOST_STRINGIZE(NETLIB_VERSION_MINOR) "." \ + BOOST_STRINGIZE(NETLIB_VERSION_INCREMENT) +#endif // NETLIB_VERSION +#endif // NETWORK_VERSION_HPP_20091214 From 91d0a73156d3906a4c66a90ac96a1a1f91a65953 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Fri, 21 Sep 2012 00:17:00 +1000 Subject: [PATCH 111/196] Fully Qualify Boost Libraries Batch 1 of changes to fully qualify boost:: namespaces now that we don't live in boost:: anymore. --- include/network/message/directives.hpp | 6 +-- include/network/message/message_base.hpp | 8 ++-- include/network/message/message_concept.hpp | 6 ++- .../message/transformers/selectors.hpp | 4 +- .../network/message/transformers/to_lower.hpp | 2 +- .../network/message/transformers/to_upper.hpp | 2 +- include/network/message/wrappers/body.hpp | 4 +- .../network/message/wrappers/destination.hpp | 2 +- .../http/client/client_connection.hpp | 7 ++-- .../http/client/client_connection.ipp | 2 +- .../http/client/connection/async_normal.hpp | 12 +++--- .../http/client/connection/async_resolver.hpp | 4 +- .../client/connection/connection_delegate.hpp | 12 +++--- .../connection_delegate_factory.hpp | 4 +- .../connection_delegate_factory.ipp | 4 +- .../client/connection/connection_factory.hpp | 7 ++-- .../client/connection/normal_delegate.hpp | 18 ++++----- .../client/connection/normal_delegate.ipp | 18 ++++----- .../client/connection/resolver_delegate.hpp | 4 +- .../connection/resolver_delegate_factory.hpp | 4 +- .../connection/resolver_delegate_factory.ipp | 6 +-- .../connection/simple_connection_factory.hpp | 8 ++-- .../connection/simple_connection_factory.ipp | 28 +++++++------- .../http/client/connection/ssl_delegate.hpp | 27 +++++++------ .../http/client/connection/ssl_delegate.ipp | 38 +++++++++---------- .../http/client/connection_manager.hpp | 4 +- .../network/protocol/http/client/options.hpp | 12 +++--- .../http/client/simple_connection_manager.hpp | 6 +-- .../http/client/simple_connection_manager.ipp | 10 ++--- include/network/protocol/http/impl/access.hpp | 14 +++---- include/network/protocol/http/impl/access.ipp | 14 +++---- .../protocol/http/message/wrappers.hpp | 1 - .../protocol/http/message/wrappers/ready.hpp | 4 +- .../http/message/wrappers/status_message.hpp | 2 +- .../http/message/wrappers/version.hpp | 2 +- .../protocol/http/parser/incremental.hpp | 28 +++++++------- .../network/protocol/http/request/request.hpp | 12 +++--- .../protocol/http/request/request_base.hpp | 6 +-- include/network/protocol/http/response.hpp | 1 - .../protocol/http/response/response.hpp | 24 ++++++------ .../http/response/response_concept.hpp | 2 +- .../protocol/http/support/is_server.hpp | 4 +- include/network/uri.hpp | 6 +-- include/network/uri/config.hpp | 1 - include/network/uri/uri.hpp | 2 +- 45 files changed, 196 insertions(+), 196 deletions(-) diff --git a/include/network/message/directives.hpp b/include/network/message/directives.hpp index 8c6fad509..971226ad0 100644 --- a/include/network/message/directives.hpp +++ b/include/network/message/directives.hpp @@ -13,9 +13,9 @@ namespace network { -BOOST_NETWORK_STRING_DIRECTIVE(source); -BOOST_NETWORK_STRING_DIRECTIVE(destination); -BOOST_NETWORK_STRING_DIRECTIVE(body); +NETWORK_STRING_DIRECTIVE(source); +NETWORK_STRING_DIRECTIVE(destination); +NETWORK_STRING_DIRECTIVE(body); } // namespace network diff --git a/include/network/message/message_base.hpp b/include/network/message/message_base.hpp index a2b14bfed..c3ddcb320 100644 --- a/include/network/message/message_base.hpp +++ b/include/network/message/message_base.hpp @@ -26,11 +26,11 @@ struct message_base { // Retrievers virtual void get_destination(std::string & destination) const = 0; virtual void get_source(std::string & source) const = 0; - virtual void get_headers(function inserter) const = 0; - virtual void get_headers(std::string const & name, function inserter) const = 0; - virtual void get_headers(function predicate, function inserter) const = 0; + virtual void get_headers(boost::function inserter) const = 0; + virtual void get_headers(std::string const & name, boost::function inserter) const = 0; + virtual void get_headers(boost::function predicate, boost::function inserter) const = 0; virtual void get_body(std::string & body) const = 0; - virtual void get_body(function)> chunk_reader, size_t size) const = 0; + virtual void get_body(boost::function)> chunk_reader, size_t size) const = 0; // Destructor virtual ~message_base() = 0; // pure virtual diff --git a/include/network/message/message_concept.hpp b/include/network/message/message_concept.hpp index 28c2cdbad..6f06d4d94 100644 --- a/include/network/message/message_concept.hpp +++ b/include/network/message/message_concept.hpp @@ -19,9 +19,11 @@ namespace network { template struct Message - : DefaultConstructible, CopyConstructible, Assignable { + : boost::DefaultConstructible, + boost::CopyConstructible, + boost::Assignable { - CONCEPT_USAGE(Message) { + BOOST_CONCEPT_USAGE(Message) { M message_; swap(message, message_); typedef std::string source_type; diff --git a/include/network/message/transformers/selectors.hpp b/include/network/message/transformers/selectors.hpp index 092f6e82b..46cf657cd 100644 --- a/include/network/message/transformers/selectors.hpp +++ b/include/network/message/transformers/selectors.hpp @@ -22,14 +22,14 @@ struct source_selector { private: source_selector() {}; source_selector(source_selector const &) {}; - friend source_selector boost::network::source_(source_selector); + friend source_selector network::source_(source_selector); }; struct destination_selector { private: destination_selector() {}; destination_selector(destination_selector const &) {}; - friend destination_selector boost::network::destination_(destination_selector); + friend destination_selector network::destination_(destination_selector); }; } // namespace selectors diff --git a/include/network/message/transformers/to_lower.hpp b/include/network/message/transformers/to_lower.hpp index f2e075d17..717776510 100644 --- a/include/network/message/transformers/to_lower.hpp +++ b/include/network/message/transformers/to_lower.hpp @@ -68,7 +68,7 @@ struct to_lower_placeholder_helper { private: to_lower_placeholder_helper() {} to_lower_placeholder_helper(to_lower_placeholder_helper const &) {} - friend to_lower_placeholder_helper boost::network::to_lower_(to_lower_placeholder_helper); + friend to_lower_placeholder_helper network::to_lower_(to_lower_placeholder_helper); }; } // namespace detail diff --git a/include/network/message/transformers/to_upper.hpp b/include/network/message/transformers/to_upper.hpp index b322652d7..a5698653c 100644 --- a/include/network/message/transformers/to_upper.hpp +++ b/include/network/message/transformers/to_upper.hpp @@ -69,7 +69,7 @@ struct to_upper_placeholder_helper { private: to_upper_placeholder_helper() {} to_upper_placeholder_helper(to_upper_placeholder_helper const &) {} - friend to_upper_placeholder_helper boost::network::to_upper_(to_upper_placeholder_helper); + friend to_upper_placeholder_helper network::to_upper_(to_upper_placeholder_helper); }; } // namespace detail diff --git a/include/network/message/wrappers/body.hpp b/include/network/message/wrappers/body.hpp index af9223013..d074ada1d 100644 --- a/include/network/message/wrappers/body.hpp +++ b/include/network/message/wrappers/body.hpp @@ -17,12 +17,12 @@ struct body_wrapper { explicit body_wrapper(message_base const & message); operator std::string () const; std::size_t size() const; - operator iterator_range () const; + operator boost::iterator_range () const; std::string::const_iterator begin() const; std::string::const_iterator end() const; private: message_base const & message_; - mutable optional cache_; + mutable boost::optional cache_; }; inline std::ostream & operator<<(std::ostream & os, body_wrapper const & body) { diff --git a/include/network/message/wrappers/destination.hpp b/include/network/message/wrappers/destination.hpp index c4dcb6862..464fd546d 100644 --- a/include/network/message/wrappers/destination.hpp +++ b/include/network/message/wrappers/destination.hpp @@ -16,7 +16,7 @@ struct destination_wrapper { operator std::string () const; private: message_base const & message_; - mutable optional cache_; + mutable boost::optional cache_; }; inline destination_wrapper const diff --git a/include/network/protocol/http/client/client_connection.hpp b/include/network/protocol/http/client/client_connection.hpp index 1fa392348..71ed6b24c 100644 --- a/include/network/protocol/http/client/client_connection.hpp +++ b/include/network/protocol/http/client/client_connection.hpp @@ -19,9 +19,10 @@ struct response; class request_options; struct client_connection { - typedef function const &, - system::error_code const &)> - callback_type; + typedef boost::function< + void(boost::iterator_range const &, + boost::system::error_code const &)> + callback_type; virtual response send_request(std::string const & method, request const & request, bool get_body, diff --git a/include/network/protocol/http/client/client_connection.ipp b/include/network/protocol/http/client/client_connection.ipp index 18e2da53d..e734d1076 100644 --- a/include/network/protocol/http/client/client_connection.ipp +++ b/include/network/protocol/http/client/client_connection.ipp @@ -21,7 +21,7 @@ client_connection::~client_connection() { client_connection * client_connection::clone() const { NETWORK_MESSAGE("client_connection::clone()"); // For exposition only. - ASSERT(false && "This should not ever be called."); + BOOST_ASSERT(false && "This should not ever be called."); return 0; } diff --git a/include/network/protocol/http/client/connection/async_normal.hpp b/include/network/protocol/http/client/connection/async_normal.hpp index ede0d81fe..468735b1d 100644 --- a/include/network/protocol/http/client/connection/async_normal.hpp +++ b/include/network/protocol/http/client/connection/async_normal.hpp @@ -32,11 +32,11 @@ struct connection_delegate; struct http_async_connection_pimpl; struct http_async_connection : client_connection - , enable_shared_from_this { + , boost::enable_shared_from_this { using client_connection::callback_type; - http_async_connection(shared_ptr resolver_delegate, - shared_ptr connection_delegate, - asio::io_service & io_service, + http_async_connection(boost::shared_ptr resolver_delegate, + boost::shared_ptr connection_delegate, + boost::asio::io_service & io_service, bool follow_redirects); http_async_connection * clone() const; virtual response send_request(std::string const & method, @@ -47,8 +47,8 @@ struct http_async_connection : client_connection virtual void reset(); // override virtual ~http_async_connection(); private: - explicit http_async_connection(shared_ptr); - shared_ptr pimpl; + explicit http_async_connection(boost::shared_ptr); + boost::shared_ptr pimpl; }; } // namespace http diff --git a/include/network/protocol/http/client/connection/async_resolver.hpp b/include/network/protocol/http/client/connection/async_resolver.hpp index e55bd8efb..a8ff87026 100644 --- a/include/network/protocol/http/client/connection/async_resolver.hpp +++ b/include/network/protocol/http/client/connection/async_resolver.hpp @@ -18,7 +18,7 @@ struct async_resolver_pimpl; struct async_resolver : resolver_delegate { using resolver_delegate::resolve_completion_function; - async_resolver(asio::io_service & service, bool cache_resolved); + async_resolver(boost::asio::io_service & service, bool cache_resolved); virtual void resolve(std::string const & host, uint16_t port, resolve_completion_function once_resolved); // override @@ -28,7 +28,7 @@ struct async_resolver : resolver_delegate { protected: // We need a shared_ptr because the pimpl may live on long after the resolver // delegate (instances of this type) is actually destroyed. - shared_ptr pimpl; + boost::shared_ptr pimpl; }; } // namespace http diff --git a/include/network/protocol/http/client/connection/connection_delegate.hpp b/include/network/protocol/http/client/connection/connection_delegate.hpp index 6c2a39c57..cfe3a06ce 100644 --- a/include/network/protocol/http/client/connection/connection_delegate.hpp +++ b/include/network/protocol/http/client/connection/connection_delegate.hpp @@ -15,13 +15,13 @@ namespace network { namespace http { struct connection_delegate { - virtual void connect(asio::ip::tcp::endpoint & endpoint, + virtual void connect(boost::asio::ip::tcp::endpoint & endpoint, std::string const & host, - function handler) = 0; - virtual void write(asio::streambuf & command_streambuf, - function handler) = 0; - virtual void read_some(asio::mutable_buffers_1 const & read_buffer, - function handler) = 0; + boost::function handler) = 0; + virtual void write(boost::asio::streambuf & command_streambuf, + boost::function handler) = 0; + virtual void read_some(boost::asio::mutable_buffers_1 const & read_buffer, + boost::function handler) = 0; virtual ~connection_delegate() {} }; diff --git a/include/network/protocol/http/client/connection/connection_delegate_factory.hpp b/include/network/protocol/http/client/connection/connection_delegate_factory.hpp index fc5af848c..b3a997081 100644 --- a/include/network/protocol/http/client/connection/connection_delegate_factory.hpp +++ b/include/network/protocol/http/client/connection/connection_delegate_factory.hpp @@ -16,13 +16,13 @@ namespace http { class client_options; struct connection_delegate_factory { - typedef shared_ptr connection_delegate_ptr; + typedef boost::shared_ptr connection_delegate_ptr; connection_delegate_factory(); // This is the factory method that actually returns the delegate instance. virtual connection_delegate_ptr create_connection_delegate( - asio::io_service & service, + boost::asio::io_service & service, bool https, client_options const &options); diff --git a/include/network/protocol/http/client/connection/connection_delegate_factory.ipp b/include/network/protocol/http/client/connection/connection_delegate_factory.ipp index 83a5d58e0..63725e3a2 100644 --- a/include/network/protocol/http/client/connection/connection_delegate_factory.ipp +++ b/include/network/protocol/http/client/connection/connection_delegate_factory.ipp @@ -24,7 +24,7 @@ connection_delegate_factory::connection_delegate_factory() { connection_delegate_factory::connection_delegate_ptr connection_delegate_factory::create_connection_delegate( - asio::io_service & service, + boost::asio::io_service & service, bool https, client_options const &options) { NETWORK_MESSAGE("connection_delegate_factory::create_connection_delegate(...)"); @@ -36,7 +36,7 @@ connection_delegate_factory::create_connection_delegate( options)); #else NETWORK_MESSAGE("creating an SSL delegate, but not supported"); - THROW_EXCEPTION(std::runtime_error("HTTPS not supported.")); + BOOST_THROW_EXCEPTION(std::runtime_error("HTTPS not supported.")); #endif /* NETWORK_ENABLE_HTTPS */ } else { NETWORK_MESSAGE("creating a normal delegate"); diff --git a/include/network/protocol/http/client/connection/connection_factory.hpp b/include/network/protocol/http/client/connection/connection_factory.hpp index 10cb744a1..e323b8372 100644 --- a/include/network/protocol/http/client/connection/connection_factory.hpp +++ b/include/network/protocol/http/client/connection/connection_factory.hpp @@ -24,9 +24,10 @@ struct client_connection; struct request_base; struct connection_factory { - virtual shared_ptr create_connection(asio::io_service &service, - request_base const & request, - client_options const &options) = 0; + virtual boost::shared_ptr create_connection( + boost::asio::io_service &service, + request_base const & request, + client_options const &options) = 0; virtual ~connection_factory() = 0; // pure virtual, interface only. }; diff --git a/include/network/protocol/http/client/connection/normal_delegate.hpp b/include/network/protocol/http/client/connection/normal_delegate.hpp index 255c8db66..a4bf08860 100644 --- a/include/network/protocol/http/client/connection/normal_delegate.hpp +++ b/include/network/protocol/http/client/connection/normal_delegate.hpp @@ -22,20 +22,20 @@ namespace network { namespace http { struct normal_delegate : connection_delegate { - normal_delegate(asio::io_service & service); + normal_delegate(boost::asio::io_service & service); - virtual void connect(asio::ip::tcp::endpoint & endpoint, + virtual void connect(boost::asio::ip::tcp::endpoint & endpoint, std::string const &host, - function handler); - virtual void write(asio::streambuf & command_streambuf, - function handler); - virtual void read_some(asio::mutable_buffers_1 const & read_buffer, - function handler); + boost::function handler); + virtual void write(boost::asio::streambuf & command_streambuf, + boost::function handler); + virtual void read_some(boost::asio::mutable_buffers_1 const & read_buffer, + boost::function handler); ~normal_delegate(); private: - asio::io_service & service_; - scoped_ptr socket_; + boost::asio::io_service & service_; + boost::scoped_ptr socket_; normal_delegate(normal_delegate const &); // = delete normal_delegate& operator=(normal_delegate); // = delete diff --git a/include/network/protocol/http/client/connection/normal_delegate.ipp b/include/network/protocol/http/client/connection/normal_delegate.ipp index be469a65e..81ae0c95b 100644 --- a/include/network/protocol/http/client/connection/normal_delegate.ipp +++ b/include/network/protocol/http/client/connection/normal_delegate.ipp @@ -15,29 +15,29 @@ #include #include -network::http::normal_delegate::normal_delegate(asio::io_service & service) +network::http::normal_delegate::normal_delegate(boost::asio::io_service & service) : service_(service) {} void network::http::normal_delegate::connect( - asio::ip::tcp::endpoint & endpoint, + boost::asio::ip::tcp::endpoint & endpoint, std::string const &host, - function handler) { - socket_.reset(new asio::ip::tcp::socket(service_)); + boost::function handler) { + socket_.reset(new boost::asio::ip::tcp::socket(service_)); socket_->async_connect(endpoint, handler); } void network::http::normal_delegate::write( - asio::streambuf & command_streambuf, - function handler) { + boost::asio::streambuf & command_streambuf, + boost::function handler) { NETWORK_MESSAGE("normal_delegate::write(...)"); NETWORK_MESSAGE("scheduling asynchronous write..."); - asio::async_write(*socket_, command_streambuf, handler); + boost::asio::async_write(*socket_, command_streambuf, handler); } void network::http::normal_delegate::read_some( - asio::mutable_buffers_1 const & read_buffer, - function handler) { + boost::asio::mutable_buffers_1 const & read_buffer, + boost::function handler) { NETWORK_MESSAGE("normal_delegate::read_some(...)"); NETWORK_MESSAGE("scheduling asynchronous read some..."); socket_->async_read_some(read_buffer, handler); diff --git a/include/network/protocol/http/client/connection/resolver_delegate.hpp b/include/network/protocol/http/client/connection/resolver_delegate.hpp index 55b973e00..a83cc04cf 100644 --- a/include/network/protocol/http/client/connection/resolver_delegate.hpp +++ b/include/network/protocol/http/client/connection/resolver_delegate.hpp @@ -15,10 +15,10 @@ namespace network { namespace http { struct resolver_delegate { - typedef asio::ip::udp::resolver::iterator resolver_iterator; + typedef boost::asio::ip::udp::resolver::iterator resolver_iterator; typedef std::pair iterator_pair; - typedef function + typedef boost::function resolve_completion_function; virtual void resolve(std::string const & host, uint16_t port, diff --git a/include/network/protocol/http/client/connection/resolver_delegate_factory.hpp b/include/network/protocol/http/client/connection/resolver_delegate_factory.hpp index 2b7c3780c..6a9776050 100644 --- a/include/network/protocol/http/client/connection/resolver_delegate_factory.hpp +++ b/include/network/protocol/http/client/connection/resolver_delegate_factory.hpp @@ -15,8 +15,8 @@ namespace network { namespace http { struct resolver_delegate_factory { resolver_delegate_factory(); - virtual shared_ptr create_resolver_delegate( - asio::io_service & service, + virtual boost::shared_ptr create_resolver_delegate( + boost::asio::io_service & service, bool cache_resolved); virtual ~resolver_delegate_factory(); private: diff --git a/include/network/protocol/http/client/connection/resolver_delegate_factory.ipp b/include/network/protocol/http/client/connection/resolver_delegate_factory.ipp index 4cf4d9839..72828db60 100644 --- a/include/network/protocol/http/client/connection/resolver_delegate_factory.ipp +++ b/include/network/protocol/http/client/connection/resolver_delegate_factory.ipp @@ -18,11 +18,11 @@ resolver_delegate_factory::resolver_delegate_factory() { NETWORK_MESSAGE("resolver_delegate_factory::resolver_delegate_factory()"); } -shared_ptr -resolver_delegate_factory::create_resolver_delegate(asio::io_service & service, +boost::shared_ptr +resolver_delegate_factory::create_resolver_delegate(boost::asio::io_service & service, bool cache_resolved) { NETWORK_MESSAGE("resolver_delegate_factory::create_resolver_delegate(...)"); - shared_ptr resolver_( + boost::shared_ptr resolver_( new (std::nothrow) async_resolver(service, cache_resolved)); return resolver_; } diff --git a/include/network/protocol/http/client/connection/simple_connection_factory.hpp b/include/network/protocol/http/client/connection/simple_connection_factory.hpp index 6057dfb9a..c22fcd511 100644 --- a/include/network/protocol/http/client/connection/simple_connection_factory.hpp +++ b/include/network/protocol/http/client/connection/simple_connection_factory.hpp @@ -20,14 +20,14 @@ struct simple_connection_factory_pimpl; struct simple_connection_factory : connection_factory { simple_connection_factory(); - simple_connection_factory(shared_ptr conn_delegate_factory, - shared_ptr res_delegate_factory); - virtual shared_ptr create_connection(asio::io_service & service, + simple_connection_factory(boost::shared_ptr conn_delegate_factory, + boost::shared_ptr res_delegate_factory); + virtual boost::shared_ptr create_connection(boost::asio::io_service & service, request_base const & request, client_options const & options); // override virtual ~simple_connection_factory(); private: - scoped_ptr pimpl; + boost::scoped_ptr pimpl; simple_connection_factory(simple_connection_factory const &); // = delete simple_connection_factory& operator=(simple_connection_factory); // = delete }; diff --git a/include/network/protocol/http/client/connection/simple_connection_factory.ipp b/include/network/protocol/http/client/connection/simple_connection_factory.ipp index 04e5f3750..4c206ed87 100644 --- a/include/network/protocol/http/client/connection/simple_connection_factory.ipp +++ b/include/network/protocol/http/client/connection/simple_connection_factory.ipp @@ -24,22 +24,22 @@ namespace network { namespace http { struct simple_connection_factory_pimpl { - simple_connection_factory_pimpl(shared_ptr conn_delegate_factory, - shared_ptr res_delegate_factory) + simple_connection_factory_pimpl(boost::shared_ptr conn_delegate_factory, + boost::shared_ptr res_delegate_factory) : conn_delegate_factory_(conn_delegate_factory) , res_delegate_factory_(res_delegate_factory) { NETWORK_MESSAGE("simple_connection_factory_pimpl::simple_connection_factory_pimpl(...)"); } - shared_ptr create_connection( - asio::io_service & service, + boost::shared_ptr create_connection( + boost::asio::io_service & service, request_base const & request, client_options const & options) { NETWORK_MESSAGE("simple_connection_factory_pimpl::create_connection(...)"); ::network::uri uri_ = http::uri(request); NETWORK_MESSAGE("destination: " << uri_); - bool https = to_lower_copy(::network::scheme(uri_)) == "https"; - shared_ptr conn_; + bool https = boost::algorithm::to_lower_copy(::network::scheme(uri_)) == "https"; + boost::shared_ptr conn_; conn_.reset(new (std::nothrow) http_async_connection( res_delegate_factory_->create_resolver_delegate(service, options.cache_resolved()), conn_delegate_factory_->create_connection_delegate(service, https, options), @@ -49,29 +49,29 @@ struct simple_connection_factory_pimpl { } private: - shared_ptr conn_delegate_factory_; - shared_ptr res_delegate_factory_; + boost::shared_ptr conn_delegate_factory_; + boost::shared_ptr res_delegate_factory_; }; simple_connection_factory::simple_connection_factory() { NETWORK_MESSAGE("simple_connection_factory::simple_connection_factory()"); - shared_ptr connection_delegate_factory_; + boost::shared_ptr connection_delegate_factory_; connection_delegate_factory_.reset(new (std::nothrow) connection_delegate_factory()); - shared_ptr resolver_delegate_factory_; + boost::shared_ptr resolver_delegate_factory_; resolver_delegate_factory_.reset(new (std::nothrow) resolver_delegate_factory()); pimpl.reset(new (std::nothrow) simple_connection_factory_pimpl( connection_delegate_factory_, resolver_delegate_factory_)); } -simple_connection_factory::simple_connection_factory(shared_ptr conn_delegate_factory, - shared_ptr res_delegate_factory) +simple_connection_factory::simple_connection_factory(boost::shared_ptr conn_delegate_factory, + boost::shared_ptr res_delegate_factory) : pimpl(new (std::nothrow) simple_connection_factory_pimpl(conn_delegate_factory, res_delegate_factory)) { NETWORK_MESSAGE("simple_connection_factory::simple_connection_factory(...)"); } -shared_ptr -simple_connection_factory::create_connection(asio::io_service & service, +boost::shared_ptr +simple_connection_factory::create_connection(boost::asio::io_service & service, request_base const & request, client_options const &options) { NETWORK_MESSAGE("simple_connection_factory::create_connection(...)"); diff --git a/include/network/protocol/http/client/connection/ssl_delegate.hpp b/include/network/protocol/http/client/connection/ssl_delegate.hpp index e04083393..1c3e2ff3e 100644 --- a/include/network/protocol/http/client/connection/ssl_delegate.hpp +++ b/include/network/protocol/http/client/connection/ssl_delegate.hpp @@ -21,34 +21,33 @@ class io_service; namespace network { namespace http { -struct ssl_delegate : connection_delegate, enable_shared_from_this { - ssl_delegate(asio::io_service & service, +struct ssl_delegate : connection_delegate, boost::enable_shared_from_this { + ssl_delegate(boost::asio::io_service & service, client_options const &options); - virtual void connect(asio::ip::tcp::endpoint & endpoint, + virtual void connect(boost::asio::ip::tcp::endpoint & endpoint, std::string const &host, - function handler); - virtual void write(asio::streambuf & command_streambuf, - function handler); - virtual void read_some(asio::mutable_buffers_1 const & read_buffer, - function handler); + boost::function handler); + virtual void write(boost::asio::streambuf & command_streambuf, + boost::function handler); + virtual void read_some(boost::asio::mutable_buffers_1 const & read_buffer, + boost::function handler); ~ssl_delegate(); private: - asio::io_service & service_; + boost::asio::io_service & service_; client_options options_; - scoped_ptr context_; - scoped_ptr > socket_; + boost::scoped_ptr context_; + boost::scoped_ptr > socket_; ssl_delegate(ssl_delegate const &); // = delete ssl_delegate& operator=(ssl_delegate); // = delete - void handle_connected(system::error_code const & ec, - function handler); + void handle_connected(boost::system::error_code const & ec, + boost::function handler); }; } // namespace http } // namespace network -} // namespace boost #endif /* NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SSL_DELEGATE_20110819 */ diff --git a/include/network/protocol/http/client/connection/ssl_delegate.ipp b/include/network/protocol/http/client/connection/ssl_delegate.ipp index 18bbce6c7..912c2c91b 100755 --- a/include/network/protocol/http/client/connection/ssl_delegate.ipp +++ b/include/network/protocol/http/client/connection/ssl_delegate.ipp @@ -13,7 +13,7 @@ #include #include -network::http::ssl_delegate::ssl_delegate(asio::io_service & service, +network::http::ssl_delegate::ssl_delegate(boost::asio::io_service & service, client_options const &options) : service_(service), options_(options) { @@ -21,12 +21,12 @@ network::http::ssl_delegate::ssl_delegate(asio::io_service & service, } void network::http::ssl_delegate::connect( - asio::ip::tcp::endpoint & endpoint, + boost::asio::ip::tcp::endpoint & endpoint, std::string const &host, - function handler) { + boost::function handler) { NETWORK_MESSAGE("ssl_delegate::connect(...)"); - context_.reset(new asio::ssl::context( - asio::ssl::context::sslv23)); + context_.reset(new boost::asio::ssl::context( + boost::asio::ssl::context::sslv23)); std::list const & certificate_paths = options_.openssl_certificate_paths(); std::list const & verifier_paths = @@ -42,28 +42,28 @@ void network::http::ssl_delegate::connect( context_->add_verify_path(*it); } NETWORK_MESSAGE("verifying peer: " << host); - context_->set_verify_mode(asio::ssl::context::verify_peer); - context_->set_verify_callback(asio::ssl::rfc2818_verification(host)); + context_->set_verify_mode(boost::asio::ssl::context::verify_peer); + context_->set_verify_callback(boost::asio::ssl::rfc2818_verification(host)); } else { NETWORK_MESSAGE("not verifying peer"); context_->set_default_verify_paths(); - context_->set_verify_mode(asio::ssl::context::verify_peer); - context_->set_verify_callback(asio::ssl::rfc2818_verification(host)); + context_->set_verify_mode(boost::asio::ssl::context::verify_peer); + context_->set_verify_callback(boost::asio::ssl::rfc2818_verification(host)); } - socket_.reset(new asio::ssl::stream(service_, *context_)); + socket_.reset(new boost::asio::ssl::stream(service_, *context_)); NETWORK_MESSAGE("scheduling asynchronous connection..."); socket_->lowest_layer().async_connect( endpoint, ::boost::bind(&network::http::ssl_delegate::handle_connected, network::http::ssl_delegate::shared_from_this(), - asio::placeholders::error, + boost::asio::placeholders::error, handler)); } void network::http::ssl_delegate::handle_connected( - system::error_code const & ec, - function handler) { + boost::system::error_code const & ec, + boost::function handler) { NETWORK_MESSAGE("ssl_delegate::handle_connected(...)"); if (!ec) { NETWORK_MESSAGE("connected to endpoint."); @@ -71,7 +71,7 @@ void network::http::ssl_delegate::handle_connected( SSL_SESSION *existing_session = SSL_get1_session(socket_->impl()->ssl); if (existing_session == NULL) { NETWORK_MESSAGE("found no existing session, performing handshake."); - socket_->async_handshake(asio::ssl::stream_base::client, handler); + socket_->async_handshake(boost::asio::ssl::stream_base::client, handler); } else { NETWORK_MESSAGE("found existing session, bypassing handshake."); SSL_set_session(socket_->impl()->ssl, existing_session); @@ -85,16 +85,16 @@ void network::http::ssl_delegate::handle_connected( } void network::http::ssl_delegate::write( - asio::streambuf & command_streambuf, - function handler) { + boost::asio::streambuf & command_streambuf, + boost::function handler) { NETWORK_MESSAGE("ssl_delegate::write(...)"); NETWORK_MESSAGE("scheduling asynchronous write..."); - asio::async_write(*socket_, command_streambuf, handler); + boost::asio::async_write(*socket_, command_streambuf, handler); } void network::http::ssl_delegate::read_some( - asio::mutable_buffers_1 const & read_buffer, - function handler) { + boost::asio::mutable_buffers_1 const & read_buffer, + boost::function handler) { NETWORK_MESSAGE("ssl_delegate::read_some(...)"); NETWORK_MESSAGE("scheduling asynchronous read_some..."); socket_->async_read_some(read_buffer, handler); diff --git a/include/network/protocol/http/client/connection_manager.hpp b/include/network/protocol/http/client/connection_manager.hpp index ed8552fff..c1f89e556 100644 --- a/include/network/protocol/http/client/connection_manager.hpp +++ b/include/network/protocol/http/client/connection_manager.hpp @@ -25,8 +25,8 @@ struct request_base; class client_options; struct connection_manager { - virtual shared_ptr get_connection( - asio::io_service & service, + virtual boost::shared_ptr get_connection( + boost::asio::io_service & service, request_base const & request, client_options const & options) = 0; virtual void clear_resolved_cache() = 0; diff --git a/include/network/protocol/http/client/options.hpp b/include/network/protocol/http/client/options.hpp index 724debbc6..4605710ae 100644 --- a/include/network/protocol/http/client/options.hpp +++ b/include/network/protocol/http/client/options.hpp @@ -51,8 +51,8 @@ namespace http { // The default setting when un-set is nullptr, meaning it signals the client // implementation that the user doesn't want to use his own io_service // instance. - client_options& io_service(asio::io_service *io_service); - asio::io_service* io_service() const; + client_options& io_service(boost::asio::io_service *io_service); + boost::asio::io_service* io_service() const; // The following option determines whether the client should follow // HTTP redirects when the implementation encounters them. The default @@ -83,13 +83,13 @@ namespace http { // The following options provide the connection manager shared pointer that // is what the client will use to manage connections. - client_options& connection_manager(shared_ptr manager); - shared_ptr connection_manager() const; + client_options& connection_manager(boost::shared_ptr manager); + boost::shared_ptr connection_manager() const; // The following supports providing the connection factory instance responsible // for creating the correct instances of the appropriate connection. - client_options& connection_factory(shared_ptr factory); - shared_ptr connection_factory() const; + client_options& connection_factory(boost::shared_ptr factory); + boost::shared_ptr connection_factory() const; // More options go here... diff --git a/include/network/protocol/http/client/simple_connection_manager.hpp b/include/network/protocol/http/client/simple_connection_manager.hpp index e264fa288..d25f0f5bd 100644 --- a/include/network/protocol/http/client/simple_connection_manager.hpp +++ b/include/network/protocol/http/client/simple_connection_manager.hpp @@ -49,8 +49,8 @@ struct simple_connection_manager : connection_manager { * shared_ptr -- either an already-generated object * or a newly constructed connection configured to perform the request. */ - virtual shared_ptr get_connection( - asio::io_service & service, + virtual boost::shared_ptr get_connection( + boost::asio::io_service & service, request_base const & request, client_options const & options); // override @@ -73,7 +73,7 @@ struct simple_connection_manager : connection_manager { virtual ~simple_connection_manager(); // override protected: - scoped_ptr pimpl; + boost::scoped_ptr pimpl; private: /// Disabled copy constructor. diff --git a/include/network/protocol/http/client/simple_connection_manager.ipp b/include/network/protocol/http/client/simple_connection_manager.ipp index a6e6a6a26..90929264e 100644 --- a/include/network/protocol/http/client/simple_connection_manager.ipp +++ b/include/network/protocol/http/client/simple_connection_manager.ipp @@ -29,8 +29,8 @@ struct simple_connection_manager_pimpl { } } - shared_ptr get_connection(asio::io_service & service, - request_base const & request, + boost::shared_ptr get_connection(boost::asio::io_service & service, + request_base const & request, client_options const &options) { NETWORK_MESSAGE("simple_connection_manager_pimpl::get_connection(...)"); return connection_factory_->create_connection(service, request, options_); @@ -51,7 +51,7 @@ struct simple_connection_manager_pimpl { private: client_options options_; - shared_ptr connection_factory_; + boost::shared_ptr connection_factory_; }; simple_connection_manager::simple_connection_manager(client_options const &options) @@ -61,8 +61,8 @@ simple_connection_manager::simple_connection_manager(client_options const &optio "client_options const &)"); } -shared_ptr simple_connection_manager::get_connection( - asio::io_service & service, +boost::shared_ptr simple_connection_manager::get_connection( + boost::asio::io_service & service, request_base const & request, client_options const &options) { NETWORK_MESSAGE("simple_connection_manager::get_connection(...)"); diff --git a/include/network/protocol/http/impl/access.hpp b/include/network/protocol/http/impl/access.hpp index 373683ed8..76c6e5407 100644 --- a/include/network/protocol/http/impl/access.hpp +++ b/include/network/protocol/http/impl/access.hpp @@ -17,13 +17,13 @@ struct response; namespace impl { struct setter_access { - void set_version_promise(response &r, promise &p); - void set_status_promise(response &r, promise &p); - void set_status_message_promise(response &r, promise&p); - void set_headers_promise(response &r, promise > &p); - void set_source_promise(response &r, promise &p); - void set_destination_promise(response &r, promise &p); - void set_body_promise(response &r, promise &p); + void set_version_promise(response &r, boost::promise &p); + void set_status_promise(response &r, boost::promise &p); + void set_status_message_promise(response &r, boost::promise&p); + void set_headers_promise(response &r, boost::promise > &p); + void set_source_promise(response &r, boost::promise &p); + void set_destination_promise(response &r, boost::promise &p); + void set_body_promise(response &r, boost::promise &p); }; } // namespace impl diff --git a/include/network/protocol/http/impl/access.ipp b/include/network/protocol/http/impl/access.ipp index 93af540b2..0199fcb83 100644 --- a/include/network/protocol/http/impl/access.ipp +++ b/include/network/protocol/http/impl/access.ipp @@ -10,32 +10,32 @@ namespace network { namespace http { namespace impl { -void setter_access::set_version_promise(response &r, promise &p) { +void setter_access::set_version_promise(response &r, boost::promise &p) { return r.set_version_promise(p); } -void setter_access::set_status_promise(response &r, promise &p) { +void setter_access::set_status_promise(response &r, boost::promise &p) { return r.set_status_promise(p); } -void setter_access::set_status_message_promise(response &r, promise &p) { +void setter_access::set_status_message_promise(response &r, boost::promise &p) { return r.set_status_message_promise(p); } void -setter_access::set_headers_promise(response &r, promise > &p) { +setter_access::set_headers_promise(response &r, boost::promise > &p) { return r.set_headers_promise(p); } -void setter_access::set_source_promise(response &r, promise &p) { +void setter_access::set_source_promise(response &r, boost::promise &p) { return r.set_source_promise(p); } -void setter_access::set_destination_promise(response &r, promise &p) { +void setter_access::set_destination_promise(response &r, boost::promise &p) { return r.set_destination_promise(p); } -void setter_access::set_body_promise(response &r, promise &p) { +void setter_access::set_body_promise(response &r, boost::promise &p) { return r.set_body_promise(p); } diff --git a/include/network/protocol/http/message/wrappers.hpp b/include/network/protocol/http/message/wrappers.hpp index 1a2db7471..176224e4e 100644 --- a/include/network/protocol/http/message/wrappers.hpp +++ b/include/network/protocol/http/message/wrappers.hpp @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include diff --git a/include/network/protocol/http/message/wrappers/ready.hpp b/include/network/protocol/http/message/wrappers/ready.hpp index 726902b7f..ca1a53108 100644 --- a/include/network/protocol/http/message/wrappers/ready.hpp +++ b/include/network/protocol/http/message/wrappers/ready.hpp @@ -16,8 +16,8 @@ namespace network { namespace http { namespace impl { template - struct ready_wrapper : boost::network::detail::wrapper_base_const > { - typedef boost::network::detail::wrapper_base_const > + struct ready_wrapper : network::detail::wrapper_base_const > { + typedef network::detail::wrapper_base_const > wrapper_base; explicit ready_wrapper(async_message const & message) : wrapper_base(message) {} diff --git a/include/network/protocol/http/message/wrappers/status_message.hpp b/include/network/protocol/http/message/wrappers/status_message.hpp index 5d04d40d6..940f218db 100644 --- a/include/network/protocol/http/message/wrappers/status_message.hpp +++ b/include/network/protocol/http/message/wrappers/status_message.hpp @@ -20,7 +20,7 @@ struct status_message_wrapper { operator std::string () const; private: response_base & response_; - mutable optional cache_; + mutable boost::optional cache_; }; inline std::ostream & operator<<(std::ostream & os, status_message_wrapper const & status_message) { diff --git a/include/network/protocol/http/message/wrappers/version.hpp b/include/network/protocol/http/message/wrappers/version.hpp index 907d09a4c..fcfdb97b2 100644 --- a/include/network/protocol/http/message/wrappers/version.hpp +++ b/include/network/protocol/http/message/wrappers/version.hpp @@ -19,7 +19,7 @@ struct version_wrapper { operator std::string() const; private: response_base & response_; - mutable optional cache_; + mutable boost::optional cache_; }; inline std::ostream & operator<< (std::ostream & os, version_wrapper const & version) { diff --git a/include/network/protocol/http/parser/incremental.hpp b/include/network/protocol/http/parser/incremental.hpp index ca0e17168..537197eab 100644 --- a/include/network/protocol/http/parser/incremental.hpp +++ b/include/network/protocol/http/parser/incremental.hpp @@ -61,8 +61,8 @@ struct response_parser { } template - fusion::tuple > parse_until(state_t stop_state, Range & range_) { - logic::tribool parsed_ok(logic::indeterminate); + boost::fusion::tuple > parse_until(state_t stop_state, Range & range_) { + boost::logic::tribool parsed_ok(boost::logic::indeterminate); typename Range::const_iterator start = boost::begin(range_), current = start, end = boost::end(range_); @@ -121,7 +121,7 @@ struct response_parser { } break; case http_version_slash: - if (algorithm::is_digit()(*current)) { + if (boost::algorithm::is_digit()(*current)) { state_ = http_version_major; ++current; } else { @@ -137,7 +137,7 @@ struct response_parser { } break; case http_version_dot: - if (algorithm::is_digit()(*current)) { + if (boost::algorithm::is_digit()(*current)) { state_ = http_version_minor; ++current; } else { @@ -153,7 +153,7 @@ struct response_parser { } break; case http_version_done: - if (algorithm::is_digit()(*current)) { + if (boost::algorithm::is_digit()(*current)) { state_ = http_status_digit; ++current; } else { @@ -161,7 +161,7 @@ struct response_parser { } break; case http_status_digit: - if (algorithm::is_digit()(*current)) { + if (boost::algorithm::is_digit()(*current)) { ++current; } else if (*current == ' ') { state_ = http_status_done; @@ -171,7 +171,7 @@ struct response_parser { } break; case http_status_done: - if (algorithm::is_alnum()(*current)) { + if (boost::algorithm::is_alnum()(*current)) { state_ = http_status_message_char; ++current; } else { @@ -179,7 +179,7 @@ struct response_parser { } break; case http_status_message_char: - if (algorithm::is_alnum()(*current) || algorithm::is_punct()(*current) || (*current == ' ')) { + if (boost::algorithm::is_alnum()(*current) || boost::algorithm::is_punct()(*current) || (*current == ' ')) { ++current; } else if (*current == '\r') { state_ = http_status_message_cr; @@ -198,7 +198,7 @@ struct response_parser { break; case http_status_message_done: case http_header_line_done: - if (algorithm::is_alnum()(*current)) { + if (boost::algorithm::is_alnum()(*current)) { state_ = http_header_name_char; ++current; } else if (*current == '\r') { @@ -212,16 +212,16 @@ struct response_parser { if (*current == ':') { state_ = http_header_colon; ++current; - } else if (algorithm::is_alnum()(*current) || algorithm::is_space()(*current) || algorithm::is_punct()(*current)) { + } else if (boost::algorithm::is_alnum()(*current) || boost::algorithm::is_space()(*current) || boost::algorithm::is_punct()(*current)) { ++current; } else { parsed_ok = false; } break; case http_header_colon: - if (algorithm::is_space()(*current)) { + if (boost::algorithm::is_space()(*current)) { ++current; - } else if (algorithm::is_alnum()(*current) || algorithm::is_punct()(*current)) { + } else if (boost::algorithm::is_alnum()(*current) || boost::algorithm::is_punct()(*current)) { state_ = http_header_value_char; ++current; } else { @@ -232,7 +232,7 @@ struct response_parser { if (*current == '\r') { state_ = http_header_line_cr; ++current; - } else if (algorithm::is_cntrl()(*current)) { + } else if (boost::algorithm::is_cntrl()(*current)) { parsed_ok = false; } else { ++current; @@ -262,7 +262,7 @@ struct response_parser { local_range = boost::make_iterator_range(current, end); } if (state_ == stop_state) parsed_ok = true; - return fusion::make_tuple(parsed_ok,boost::make_iterator_range(start, current)); + return boost::fusion::make_tuple(parsed_ok,boost::make_iterator_range(start, current)); } state_t state() { diff --git a/include/network/protocol/http/request/request.hpp b/include/network/protocol/http/request/request.hpp index b005e5060..6d5b3ef42 100644 --- a/include/network/protocol/http/request/request.hpp +++ b/include/network/protocol/http/request/request.hpp @@ -41,18 +41,18 @@ struct request : request_base { // Retrievers virtual void get_destination(std::string & destination) const; virtual void get_source(std::string & source) const; - virtual void get_headers(function inserter) const; - virtual void get_headers(std::string const & name, function inserter) const; - virtual void get_headers(function predicate, function inserter) const; + virtual void get_headers(boost::function inserter) const; + virtual void get_headers(std::string const & name, boost::function inserter) const; + virtual void get_headers(boost::function predicate, boost::function inserter) const; virtual void get_body(std::string & body) const; - virtual void get_body(function)> chunk_reader, size_t size) const; + virtual void get_body(boost::function)> chunk_reader, size_t size) const; // From request_base... // Setters virtual void set_method(std::string const & method); virtual void set_status(std::string const & status); virtual void set_status_message(std::string const & status_message); - virtual void set_body_writer(function writer); + virtual void set_body_writer(boost::function writer); virtual void set_uri(std::string const &uri); virtual void set_uri(::network::uri const &uri); virtual void set_version_major(unsigned short major_version); @@ -64,7 +64,7 @@ struct request : request_base { virtual void get_method(std::string & method) const; virtual void get_status(std::string & status) const; virtual void get_status_message(std::string & status_message) const; - virtual void get_body(function chunk_reader) const; + virtual void get_body(boost::function chunk_reader) const; virtual void get_body(std::string const & body) const; virtual void get_version_major(unsigned short &major_version); virtual void get_version_minor(unsigned short &minor_version); diff --git a/include/network/protocol/http/request/request_base.hpp b/include/network/protocol/http/request/request_base.hpp index d8fbde70c..fee870e21 100644 --- a/include/network/protocol/http/request/request_base.hpp +++ b/include/network/protocol/http/request/request_base.hpp @@ -16,7 +16,7 @@ namespace network { namespace http { -struct body_source : iostreams::source { +struct body_source { virtual std::streamsize read(char * buffer, std::streamsize size); virtual ~body_source(); }; @@ -44,7 +44,7 @@ struct request_base : message_base, request_storage_base { virtual void set_method(std::string const & method) = 0; virtual void set_status(std::string const & status) = 0; virtual void set_status_message(std::string const & status_message) = 0; - virtual void set_body_writer(function writer) = 0; + virtual void set_body_writer(boost::function writer) = 0; virtual void set_uri(std::string const &uri) = 0; virtual void set_uri(::network::uri const &uri) = 0; @@ -54,7 +54,7 @@ struct request_base : message_base, request_storage_base { virtual void get_method(std::string & method) const = 0; virtual void get_status(std::string & status) const = 0; virtual void get_status_message(std::string & status_message) const = 0; - virtual void get_body(function chunk_reader) const = 0; + virtual void get_body(boost::function chunk_reader) const = 0; virtual void get_body(std::string const & body) const = 0; virtual ~request_base() = 0; }; diff --git a/include/network/protocol/http/response.hpp b/include/network/protocol/http/response.hpp index 65e9c3323..e8634878f 100644 --- a/include/network/protocol/http/response.hpp +++ b/include/network/protocol/http/response.hpp @@ -24,7 +24,6 @@ #include #include #include -#include #include #include diff --git a/include/network/protocol/http/response/response.hpp b/include/network/protocol/http/response/response.hpp index 9c7174dc9..3254fa8c6 100644 --- a/include/network/protocol/http/response/response.hpp +++ b/include/network/protocol/http/response/response.hpp @@ -36,16 +36,16 @@ struct response : response_base { virtual void get_destination(std::string & destination) const; virtual void get_source(std::string & source) const; virtual void get_headers( - function inserter) const; + boost::function inserter) const; virtual void get_headers( std::string const & name, - function inserter) const; + boost::function inserter) const; virtual void get_headers( - function predicate, - function inserter) const; + boost::function predicate, + boost::function inserter) const; virtual void get_body(std::string & body) const; virtual void get_body( - function)> chunk_reader, + boost::function)> chunk_reader, size_t size) const; // From response_base... @@ -61,13 +61,13 @@ struct response : response_base { friend struct impl::setter_access; // Hide access through accessor class. // These methods are unique to the response type which will allow for creating // promises that can be set appropriately. - void set_version_promise(promise&); - void set_status_promise(promise&); - void set_status_message_promise(promise&); - void set_headers_promise(promise >&); - void set_source_promise(promise&); - void set_destination_promise(promise&); - void set_body_promise(promise&); + void set_version_promise(boost::promise&); + void set_status_promise(boost::promise&); + void set_status_message_promise(boost::promise&); + void set_headers_promise(boost::promise >&); + void set_source_promise(boost::promise&); + void set_destination_promise(boost::promise&); + void set_body_promise(boost::promise&); response_pimpl *pimpl_; }; diff --git a/include/network/protocol/http/response/response_concept.hpp b/include/network/protocol/http/response/response_concept.hpp index b55ce026e..9b09ced54 100644 --- a/include/network/protocol/http/response/response_concept.hpp +++ b/include/network/protocol/http/response/response_concept.hpp @@ -16,7 +16,7 @@ namespace network { namespace http { template struct Response - : boost::network::Message + : network::Message { typedef typename R::string_type string_type; diff --git a/include/network/protocol/http/support/is_server.hpp b/include/network/protocol/http/support/is_server.hpp index cc1259064..519dd53c2 100644 --- a/include/network/protocol/http/support/is_server.hpp +++ b/include/network/protocol/http/support/is_server.hpp @@ -12,10 +12,10 @@ namespace network { namespace http { template - struct is_server : mpl::false_ {}; + struct is_server : boost::mpl::false_ {}; template - struct is_server::type> : mpl::true_ {}; + struct is_server::type> : boost::mpl::true_ {}; } // namespace http diff --git a/include/network/uri.hpp b/include/network/uri.hpp index ce0735739..83e752e77 100644 --- a/include/network/uri.hpp +++ b/include/network/uri.hpp @@ -5,10 +5,10 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef NETWORK_URI_INC -# define NETWORK_URI_INC +#ifndef NETWORK_URI_HPP +#define NETWORK_URI_HPP #include #include -#endif // NETWORK_URI_INC +#endif // NETWORK_URI_HPP diff --git a/include/network/uri/config.hpp b/include/network/uri/config.hpp index 876a7bb62..b35b14732 100644 --- a/include/network/uri/config.hpp +++ b/include/network/uri/config.hpp @@ -9,7 +9,6 @@ #ifndef NETWORK_URI_CONFIG_INC #define NETWORK_URI_CONFIG_INC - #include #include diff --git a/include/network/uri/uri.hpp b/include/network/uri/uri.hpp index 2f2a33df7..5d30adf48 100644 --- a/include/network/uri/uri.hpp +++ b/include/network/uri/uri.hpp @@ -28,7 +28,7 @@ bool parse(std::string::const_iterator first, } // namespace detail -class BOOST_URI_DECL uri { +class uri { friend class builder; From 7a2979ca8df76010ef67dffb03a497d907194248 Mon Sep 17 00:00:00 2001 From: Vikas Kumar Date: Sun, 23 Sep 2012 19:29:03 +0530 Subject: [PATCH 112/196] Fixed linker errors in OSX under macports 1. Added cmake module to find ICU 2. Added link instructions to include icu libs 3. mime roundtrip tests doesn't need to be linked with boost libs. It throws multiple defn errors. Fixed. --- .gitignore | 1 - CMakeLists.txt | 4 ++ FindICU.cmake | 97 +++++++++++++++++++++++++++ libs/mime/test/CMakeLists.txt | 2 +- libs/network/test/http/CMakeLists.txt | 3 + libs/network/test/uri/CMakeLists.txt | 2 +- 6 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 FindICU.cmake diff --git a/.gitignore b/.gitignore index f6311e130..833df9eea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -*.cmake *.swp *.pyc CMakeCache.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c956cc36..bd24b0681 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,10 @@ cmake_minimum_required(VERSION 2.8) project(CPP-NETLIB) + +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +find_package( ICU ) + set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_MULTITHREADED ON) find_package( Boost 1.45.0 REQUIRED unit_test_framework system regex date_time thread chrono filesystem program_options ) diff --git a/FindICU.cmake b/FindICU.cmake new file mode 100644 index 000000000..6cb91a073 --- /dev/null +++ b/FindICU.cmake @@ -0,0 +1,97 @@ +# Finds the International Components for Unicode (ICU) Library +# +# ICU_FOUND - True if ICU found. +# ICU_I18N_FOUND - True if ICU's internationalization library found. +# ICU_INCLUDE_DIRS - Directory to include to get ICU headers +# Note: always include ICU headers as, e.g., +# unicode/utypes.h +# ICU_LIBRARIES - Libraries to link against for the common ICU +# ICU_I18N_LIBRARIES - Libraries to link against for ICU internationaliation +# (note: in addition to ICU_LIBRARIES) + +# Look for the header file. +find_path( + ICU_INCLUDE_DIR + NAMES unicode/utypes.h + DOC "Include directory for the ICU library") +mark_as_advanced(ICU_INCLUDE_DIR) + +# Look for the library. +find_library( + ICU_LIBRARY + NAMES icuuc cygicuuc cygicuuc32 + DOC "Libraries to link against for the common parts of ICU") +mark_as_advanced(ICU_LIBRARY) + +# Copy the results to the output variables. +if(ICU_INCLUDE_DIR AND ICU_LIBRARY) + set(ICU_FOUND 1) + set(ICU_LIBRARIES ${ICU_LIBRARY}) + set(ICU_INCLUDE_DIRS ${ICU_INCLUDE_DIR}) + + set(ICU_VERSION 0) + set(ICU_MAJOR_VERSION 0) + set(ICU_MINOR_VERSION 0) + if (EXISTS "${ICU_INCLUDE_DIR}/unicode/uvernum.h") + FILE(READ "${ICU_INCLUDE_DIR}/unicode/uvernum.h" _ICU_VERSION_CONENTS) + else() + FILE(READ "${ICU_INCLUDE_DIR}/unicode/uversion.h" _ICU_VERSION_CONENTS) + endif() + + STRING(REGEX REPLACE ".*#define U_ICU_VERSION_MAJOR_NUM ([0-9]+).*" "\\1" ICU_MAJOR_VERSION "${_ICU_VERSION_CONENTS}") + STRING(REGEX REPLACE ".*#define U_ICU_VERSION_MINOR_NUM ([0-9]+).*" "\\1" ICU_MINOR_VERSION "${_ICU_VERSION_CONENTS}") + + set(ICU_VERSION "${ICU_MAJOR_VERSION}.${ICU_MINOR_VERSION}") + + # Look for the ICU internationalization libraries + find_library( + ICU_I18N_LIBRARY + NAMES icuin icui18n cygicuin cygicuin32 + DOC "Libraries to link against for ICU internationalization") + mark_as_advanced(ICU_I18N_LIBRARY) + if (ICU_I18N_LIBRARY) + set(ICU_I18N_FOUND 1) + set(ICU_I18N_LIBRARIES ${ICU_I18N_LIBRARY}) + else (ICU_I18N_LIBRARY) + set(ICU_I18N_FOUND 0) + set(ICU_I18N_LIBRARIES) + endif (ICU_I18N_LIBRARY) + + # Look for the ICU data libraries + find_library( + ICU_DATA_LIBRARY + NAMES icudata cygicudata cygicudata32 + DOC "Libraries to link against for ICU data") + mark_as_advanced(ICU_DATA_LIBRARY) + if (ICU_DATA_LIBRARY) + set(ICU_DATA_FOUND 1) + set(ICU_DATA_LIBRARIES ${ICU_DATA_LIBRARY}) + else (ICU_DATA_LIBRARY) + set(ICU_DATA_FOUND 0) + set(ICU_DATA_LIBRARIES) + endif (ICU_DATA_LIBRARY) +else(ICU_INCLUDE_DIR AND ICU_LIBRARY) + set(ICU_FOUND 0) + set(ICU_I18N_FOUND 0) + set(ICU_DATA_FOUND 0) + set(ICU_LIBRARIES) + set(ICU_I18N_LIBRARIES) + set(ICU_DATA_LIBRARIES) + set(ICU_INCLUDE_DIRS) + set(ICU_VERSION) + set(ICU_MAJOR_VERSION) + set(ICU_MINOR_VERSION) +endif(ICU_INCLUDE_DIR AND ICU_LIBRARY) + +IF(ICU_FOUND) + IF( NOT ICU_FIND_QUIETLY ) + MESSAGE( STATUS "Found ICU header files in ${ICU_INCLUDE_DIRS}") + MESSAGE( STATUS "Found ICU libraries: ${ICU_LIBRARIES}") + ENDIF( NOT ICU_FIND_QUIETLY ) +ELSE(ICU_FOUND) + IF(ICU_FIND_REQUIRED) + MESSAGE( FATAL_ERROR "Could not find ICU" ) + ELSE(ICU_FIND_REQUIRED) + MESSAGE( STATUS "Optional package ICU was not found" ) + ENDIF(ICU_FIND_REQUIRED) +ENDIF(ICU_FOUND) diff --git a/libs/mime/test/CMakeLists.txt b/libs/mime/test/CMakeLists.txt index 006a3f0b1..141b077ee 100644 --- a/libs/mime/test/CMakeLists.txt +++ b/libs/mime/test/CMakeLists.txt @@ -5,7 +5,7 @@ set ( Boost_USE_MULTITHREADED ON ) if ( Boost_FOUND ) add_executable ( mime-roundtrip mime-roundtrip.cpp ) - target_link_libraries ( mime-roundtrip ${Boost_LIBRARIES} ) + target_link_libraries ( mime-roundtrip ) add_test ( mime-roundtrip mime-roundtrip ) endif () diff --git a/libs/network/test/http/CMakeLists.txt b/libs/network/test/http/CMakeLists.txt index 135c7d0ab..c7b752a9a 100644 --- a/libs/network/test/http/CMakeLists.txt +++ b/libs/network/test/http/CMakeLists.txt @@ -36,6 +36,7 @@ if (Boost_FOUND) ) target_link_libraries(cpp-netlib-http-${test} ${Boost_LIBRARIES} + ${ICU_LIBRARIES} ${ICU_I18N_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-message cppnetlib-message-wrappers @@ -65,6 +66,7 @@ if (Boost_FOUND) add_executable(cpp-netlib-http-${test} ${test}.cpp) target_link_libraries(cpp-netlib-http-${test} ${Boost_LIBRARIES} + ${ICU_LIBRARIES} ${ICU_I18N_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-constants cppnetlib-uri @@ -96,6 +98,7 @@ if (Boost_FOUND) add_executable(cpp-netlib-http-${test} ${test}.cpp) target_link_libraries(cpp-netlib-http-${test} ${Boost_LIBRARIES} + ${ICU_LIBRARIES} ${ICU_I18N_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-constants cppnetlib-uri diff --git a/libs/network/test/uri/CMakeLists.txt b/libs/network/test/uri/CMakeLists.txt index 02e96e7c7..99557597a 100644 --- a/libs/network/test/uri/CMakeLists.txt +++ b/libs/network/test/uri/CMakeLists.txt @@ -25,7 +25,7 @@ if (Boost_FOUND) add_executable(cpp-netlib-${test} ${test}.cpp) add_dependencies(cpp-netlib-${test} cppnetlib-uri) target_link_libraries(cpp-netlib-${test} - ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri) + ${Boost_LIBRARIES} ${ICU_LIBRARIES} ${ICU_I18N_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri) if (OPENSSL_FOUND) target_link_libraries(cpp-netlib-${test} ${OPENSSL_LIBRARIES}) endif() From ffaa80e10abcb84b29a61856d0d20354b7044af3 Mon Sep 17 00:00:00 2001 From: Vikas Kumar Date: Mon, 24 Sep 2012 12:53:05 +0530 Subject: [PATCH 113/196] uri fails to parse compact ipv6 representation 1. Hangs on ::1. The rule that matches anything before '::' should match 0 or 1 occurance. 2. qi::repeat(min, max) is greedy in nature. Workaround to use qi::repeat(n) multiple times with varying n. --- include/network/uri/uri.ipp | 39 ++++++--- libs/network/test/uri/uri_test.cpp | 126 +++++++++++++++++++++++++++-- 2 files changed, 149 insertions(+), 16 deletions(-) diff --git a/include/network/uri/uri.ipp b/include/network/uri/uri.ipp index cf3a49ccf..2e71b8a78 100644 --- a/include/network/uri/uri.ipp +++ b/include/network/uri/uri.ipp @@ -108,15 +108,36 @@ struct uri_grammar : qi::grammar< ; ipv6address %= qi::raw[ - qi::repeat(6)[h16 >> ':'] >> ls32 - | "::" >> qi::repeat(5)[h16 >> ':'] >> ls32 - | qi::raw[ h16] >> "::" >> qi::repeat(4)[h16 >> ':'] >> ls32 - | qi::raw[ +(*(h16 >> ':')) >> h16] >> "::" >> qi::repeat(3)[h16 >> ':'] >> ls32 - | qi::raw[qi::repeat(2)[*(h16 >> ':')] >> h16] >> "::" >> qi::repeat(2)[h16 >> ':'] >> ls32 - | qi::raw[qi::repeat(3)[*(h16 >> ':')] >> h16] >> "::" >> h16 >> ':' >> ls32 - | qi::raw[qi::repeat(4)[*(h16 >> ':')] >> h16] >> "::" >> ls32 - | qi::raw[qi::repeat(5)[*(h16 >> ':')] >> h16] >> "::" >> h16 - | qi::raw[qi::repeat(6)[*(h16 >> ':')] >> h16] >> "::" + qi::repeat(6)[h16 >> ':'] >> ls32 + | "::" >> qi::repeat(5)[h16 >> ':'] >> ls32 + | - qi::raw[ h16] >> "::" >> qi::repeat(4)[h16 >> ':'] >> ls32 + | - qi::raw[ h16] >> "::" >> qi::repeat(3)[h16 >> ':'] >> ls32 + | - qi::raw[ h16] >> "::" >> qi::repeat(2)[h16 >> ':'] >> ls32 + | - qi::raw[ h16] >> "::" >> h16 >> ':' >> ls32 + | - qi::raw[ h16] >> "::" >> ls32 + | - qi::raw[ h16] >> "::" >> h16 + | - qi::raw[ h16] >> "::" + | - qi::raw[qi::repeat(1)[(h16 >> ':')] >> h16] >> "::" >> qi::repeat(3)[h16 >> ':'] >> ls32 + | - qi::raw[qi::repeat(1)[(h16 >> ':')] >> h16] >> "::" >> qi::repeat(2)[h16 >> ':'] >> ls32 + | - qi::raw[qi::repeat(1)[(h16 >> ':')] >> h16] >> "::" >> h16 >> ':' >> ls32 + | - qi::raw[qi::repeat(1)[(h16 >> ':')] >> h16] >> "::" >> ls32 + | - qi::raw[qi::repeat(1)[(h16 >> ':')] >> h16] >> "::" >> h16 + | - qi::raw[qi::repeat(1)[(h16 >> ':')] >> h16] >> "::" + | - qi::raw[qi::repeat(2)[(h16 >> ':')] >> h16] >> "::" >> qi::repeat(2)[h16 >> ':'] >> ls32 + | - qi::raw[qi::repeat(2)[(h16 >> ':')] >> h16] >> "::" >> h16 >> ':' >> ls32 + | - qi::raw[qi::repeat(2)[(h16 >> ':')] >> h16] >> "::" >> ls32 + | - qi::raw[qi::repeat(2)[(h16 >> ':')] >> h16] >> "::" >> h16 + | - qi::raw[qi::repeat(2)[(h16 >> ':')] >> h16] >> "::" + | - qi::raw[qi::repeat(3)[(h16 >> ':')] >> h16] >> "::" >> h16 >> ':' >> ls32 + | - qi::raw[qi::repeat(3)[(h16 >> ':')] >> h16] >> "::" >> ls32 + | - qi::raw[qi::repeat(3)[(h16 >> ':')] >> h16] >> "::" >> h16 + | - qi::raw[qi::repeat(3)[(h16 >> ':')] >> h16] >> "::" + | - qi::raw[qi::repeat(4)[(h16 >> ':')] >> h16] >> "::" >> ls32 + | - qi::raw[qi::repeat(4)[(h16 >> ':')] >> h16] >> "::" >> h16 + | - qi::raw[qi::repeat(4)[(h16 >> ':')] >> h16] >> "::" + | - qi::raw[qi::repeat(5)[(h16 >> ':')] >> h16] >> "::" >> h16 + | - qi::raw[qi::repeat(5)[(h16 >> ':')] >> h16] >> "::" + | - qi::raw[qi::repeat(6)[(h16 >> ':')] >> h16] >> "::" ]; // ls32 = ( h16 ":" h16 ) / IPv4address diff --git a/libs/network/test/uri/uri_test.cpp b/libs/network/test/uri/uri_test.cpp index bbb1662f7..360ee0be0 100644 --- a/libs/network/test/uri/uri_test.cpp +++ b/libs/network/test/uri/uri_test.cpp @@ -273,13 +273,125 @@ BOOST_AUTO_TEST_CASE(ipv6_address_test_2) { BOOST_CHECK_EQUAL(network::path(instance), "/"); } -//BOOST_AUTO_TEST_CASE(ipv6_loopback_test) { -// network::uri instance("http://[::1]/"); -// BOOST_REQUIRE(network::valid(instance)); -// BOOST_CHECK_EQUAL(network::scheme(instance), "http"); -// BOOST_CHECK_EQUAL(network::host(instance), "[::1]"); -// BOOST_CHECK_EQUAL(network::path(instance), "/"); -//} +BOOST_AUTO_TEST_CASE(ipv6_address_test_3) { + network::uri instance("http://[2001:db8:85a3::8a2e:370:7334]/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::scheme(instance), "http"); + BOOST_CHECK_EQUAL(network::host(instance), "[2001:db8:85a3:0:0:8a2e:370:7334]"); + BOOST_CHECK_EQUAL(network::path(instance), "/"); +} + +BOOST_AUTO_TEST_CASE(ipv6_address_test_4) { + network::uri instance("http://[2001:db8:85a3::8a2e:370:7334]/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::scheme(instance), "http"); + BOOST_CHECK_EQUAL(network::host(instance), "[2001:db8:85a3::8a2e:370:7334]"); + BOOST_CHECK_EQUAL(network::path(instance), "/"); +} + +BOOST_AUTO_TEST_CASE(ipv6_address_test_5) { + network::uri instance("http://[2001:db8::1428:57ab]/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::scheme(instance), "http"); + BOOST_CHECK_EQUAL(network::host(instance), "[2001:0db8:0000:0000:0000:0000:1428:57ab]"); + BOOST_CHECK_EQUAL(network::path(instance), "/"); +} + +BOOST_AUTO_TEST_CASE(ipv6_address_test_6) { + network::uri instance("http://[2001:db8::1428:57ab]/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::scheme(instance), "http"); + BOOST_CHECK_EQUAL(network::host(instance), "[2001:0db8:0000:0000:0000::1428:57ab]"); + BOOST_CHECK_EQUAL(network::path(instance), "/"); +} + +BOOST_AUTO_TEST_CASE(ipv6_address_test_7) { + network::uri instance("http://[2001:db8::1428:57ab]/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::scheme(instance), "http"); + BOOST_CHECK_EQUAL(network::host(instance), "[2001:0db8:0:0:0:0:1428:57ab]"); + BOOST_CHECK_EQUAL(network::path(instance), "/"); +} + +BOOST_AUTO_TEST_CASE(ipv6_address_test_8) { + network::uri instance("http://[2001:db8::1428:57ab]/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::scheme(instance), "http"); + BOOST_CHECK_EQUAL(network::host(instance), "[2001:0db8:0:0::1428:57ab]"); + BOOST_CHECK_EQUAL(network::path(instance), "/"); +} + +BOOST_AUTO_TEST_CASE(ipv6_address_test_9) { + network::uri instance("http://[2001:db8::1428:57ab]/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::scheme(instance), "http"); + BOOST_CHECK_EQUAL(network::host(instance), "[2001:0db8::1428:57ab]"); + BOOST_CHECK_EQUAL(network::path(instance), "/"); +} + +BOOST_AUTO_TEST_CASE(ipv6_address_test_10) { + network::uri instance("http://[2001:db8::1428:57ab]/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::scheme(instance), "http"); + BOOST_CHECK_EQUAL(network::host(instance), "[2001:db8::1428:57ab]"); + BOOST_CHECK_EQUAL(network::path(instance), "/"); +} + +BOOST_AUTO_TEST_CASE(ipv6_address_test_11) { + network::uri instance("http://[::ffff:c22:384e]/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::scheme(instance), "http"); + BOOST_CHECK_EQUAL(network::host(instance), "[::ffff:0c22:384e]"); + BOOST_CHECK_EQUAL(network::path(instance), "/"); +} + +BOOST_AUTO_TEST_CASE(ipv6_address_test_12) { + network::uri instance("http://[fe80::]/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::scheme(instance), "http"); + BOOST_CHECK_EQUAL(network::host(instance), "[fe80::]"); + BOOST_CHECK_EQUAL(network::path(instance), "/"); +} + +BOOST_AUTO_TEST_CASE(ipv6_address_test_13) { + network::uri instance("http://[::ffff:c000:280]/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::scheme(instance), "http"); + BOOST_CHECK_EQUAL(network::host(instance), "[::ffff:c000:280]"); + BOOST_CHECK_EQUAL(network::path(instance), "/"); +} + +BOOST_AUTO_TEST_CASE(ipv6_loopback_test) { + network::uri instance("http://[::1]/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::scheme(instance), "http"); + BOOST_CHECK_EQUAL(network::host(instance), "[::1]"); + BOOST_CHECK_EQUAL(network::path(instance), "/"); +} + +BOOST_AUTO_TEST_CASE(ipv6_loopback_test_1) { + network::uri instance("http://[::1]/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::scheme(instance), "http"); + BOOST_CHECK_EQUAL(network::host(instance), "[0000:0000:0000:0000:0000:0000:0000:0001]"); + BOOST_CHECK_EQUAL(network::path(instance), "/"); +} + +BOOST_AUTO_TEST_CASE(ipv6_v4inv6_test_1) { + network::uri instance("http://[::ffff:c22:384e]/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::scheme(instance), "http"); + BOOST_CHECK_EQUAL(network::host(instance), "[::ffff:12.34.56.78]"); + BOOST_CHECK_EQUAL(network::path(instance), "/"); +} + +BOOST_AUTO_TEST_CASE(ipv6_v4inv6_test_2) { + network::uri instance("http://[::ffff:c000:280]/"); + BOOST_REQUIRE(network::valid(instance)); + BOOST_CHECK_EQUAL(network::scheme(instance), "http"); + BOOST_CHECK_EQUAL(network::host(instance), "[::ffff:192.0.2.128]"); + BOOST_CHECK_EQUAL(network::path(instance), "/"); +} BOOST_AUTO_TEST_CASE(ftp_test) { network::uri instance("ftp://john.doe@ftp.example.com/"); From 7007308f8098bba78853ba2170181be98750af36 Mon Sep 17 00:00:00 2001 From: Matthew Clark Date: Tue, 25 Sep 2012 20:11:33 -0500 Subject: [PATCH 114/196] *added c++ flags for clang --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd24b0681..806348bd4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,10 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) else() message(FATAL_ERROR "No advanced standard C++ support (-std=c++0x and -std=c++11 not defined).") endif() +elseif(${CMAKE_CXX_COMPILER_ID} MATCHES Clang) + set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++") + set(CMAKE_CXX_LINK_FLAGS "-std=c++11 -stdlib=libc++") + message("C++ Flags: ${CMAKE_CXX_FLAGS} link flags: ${CMAKE_CXX_LINK_FLAGS}") endif() if (Boost_FOUND) From 3513c16cc6a0f38bb0da523c9920dfa65ea8a4be Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Wed, 26 Sep 2012 11:16:02 +1000 Subject: [PATCH 115/196] Fix some borked uses of Boost. --- .../protocol/http/algorithms/linearize.hpp | 8 +-- .../http/client/connection/async_normal.ipp | 72 +++++++++---------- .../http/client/connection/async_resolver.ipp | 30 ++++---- .../network/protocol/http/message/header.hpp | 8 +-- .../protocol/http/message/header_concept.hpp | 6 +- .../protocol/http/request/request_concept.hpp | 18 ++--- 6 files changed, 71 insertions(+), 71 deletions(-) diff --git a/include/network/protocol/http/algorithms/linearize.hpp b/include/network/protocol/http/algorithms/linearize.hpp index f70f2ac87..f675667f5 100644 --- a/include/network/protocol/http/algorithms/linearize.hpp +++ b/include/network/protocol/http/algorithms/linearize.hpp @@ -31,7 +31,7 @@ struct linearize_header { }; template - CONCEPT_REQUIRES( + BOOST_CONCEPT_REQUIRES( ((Header)), (string_type) ) operator()(ValueType & header) { @@ -46,7 +46,7 @@ struct linearize_header { }; template -CONCEPT_REQUIRES( +BOOST_CONCEPT_REQUIRES( ((ClientRequest)), (OutputIterator) ) linearize( @@ -130,7 +130,7 @@ CONCEPT_REQUIRES( } typedef headers_wrapper::container_type headers_container; typedef headers_container::const_iterator headers_iterator; - headers_container const & request_headers = boost::network::headers(request); + headers_container const & request_headers = network::headers(request); headers_iterator iterator = boost::begin(request_headers), end = boost::end(request_headers); bool has_user_agent = false; @@ -153,7 +153,7 @@ CONCEPT_REQUIRES( boost::copy(crlf, oi); } boost::copy(crlf, oi); - auto body_data = boost::network::body(request); + auto body_data = network::body(request); return std::copy(body_data.begin(), body_data.end(), oi); } diff --git a/include/network/protocol/http/client/connection/async_normal.ipp b/include/network/protocol/http/client/connection/async_normal.ipp index 9c57678e5..bff8430bf 100644 --- a/include/network/protocol/http/client/connection/async_normal.ipp +++ b/include/network/protocol/http/client/connection/async_normal.ipp @@ -33,9 +33,9 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this resolver_delegate, - shared_ptr connection_delegate, - asio::io_service & io_service, + boost::shared_ptr resolver_delegate, + boost::shared_ptr connection_delegate, + boost::asio::io_service & io_service, bool follow_redirect) : follow_redirect_(follow_redirect), @@ -137,7 +137,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisendpoint().address() << ":" << port); - asio::ip::tcp::endpoint endpoint(iter->endpoint().address(), port); + boost::asio::ip::tcp::endpoint endpoint(iter->endpoint().address(), port); connection_delegate_->connect( endpoint, this->host_, @@ -181,7 +181,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisendpoint().address() << ":" << port); - asio::ip::tcp::endpoint endpoint(iter->endpoint().address(), port); + boost::asio::ip::tcp::endpoint endpoint(iter->endpoint().address(), port); connection_delegate_->connect(endpoint, this->host_, request_strand_.wrap( @@ -235,7 +235,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisparse_headers( request_strand_.wrap( boost::bind( @@ -511,17 +511,17 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this callback, + boost::logic::tribool parse_version( + boost::function callback, size_t bytes) { - logic::tribool parsed_ok; + boost::logic::tribool parsed_ok; part_begin = part.begin(); buffer_type::const_iterator part_end = part.begin(); std::advance(part_end, bytes); boost::iterator_range result_range, input_range = boost::make_iterator_range(part_begin, part_end); - fusion::tie(parsed_ok, result_range) = response_parser_.parse_until( + boost::fusion::tie(parsed_ok, result_range) = response_parser_.parse_until( response_parser::http_version_done, input_range); if (parsed_ok == true) { @@ -566,16 +566,16 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this callback, + boost::logic::tribool parse_status( + boost::function callback, size_t bytes) { - logic::tribool parsed_ok; + boost::logic::tribool parsed_ok; buffer_type::const_iterator part_end = part.begin(); std::advance(part_end, bytes); boost::iterator_range< buffer_type::const_iterator> result_range, input_range = boost::make_iterator_range(part_begin, part_end); - fusion::tie(parsed_ok, result_range) = response_parser_.parse_until( + boost::fusion::tie(parsed_ok, result_range) = response_parser_.parse_until( response_parser::http_status_done, input_range); if (parsed_ok == true) { @@ -621,16 +621,16 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this callback, + boost::logic::tribool parse_status_message( + boost::function callback, size_t bytes) { - logic::tribool parsed_ok; + boost::logic::tribool parsed_ok; buffer_type::const_iterator part_end = part.begin(); std::advance(part_end, bytes); boost::iterator_range< buffer_type::const_iterator> result_range, input_range = boost::make_iterator_range(part_begin, part_end); - fusion::tie(parsed_ok, result_range) = response_parser_.parse_until( + boost::fusion::tie(parsed_ok, result_range) = response_parser_.parse_until( response_parser::http_status_message_done, input_range); if (parsed_ok == true) { @@ -676,13 +676,13 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this input_range = boost::make_iterator_range(headers_part) , result_range; - logic::tribool parsed_ok; + boost::logic::tribool parsed_ok; response_parser headers_parser( response_parser::http_header_line_done); std::multimap headers; std::pair header_pair; while (!boost::empty(input_range)) { - fusion::tie(parsed_ok, result_range) = + boost::fusion::tie(parsed_ok, result_range) = headers_parser.parse_until( response_parser::http_header_colon, input_range); @@ -692,7 +692,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this parse_headers( - function callback, + boost::fusion::tuple parse_headers( + boost::function callback, size_t bytes) { - logic::tribool parsed_ok; + boost::logic::tribool parsed_ok; buffer_type::const_iterator part_end = part.begin(); std::advance(part_end, bytes); boost::iterator_range result_range, input_range = boost::make_iterator_range(part_begin, part_end); - fusion::tie(parsed_ok, result_range) = response_parser_.parse_until( + boost::fusion::tie(parsed_ok, result_range) = response_parser_.parse_until( response_parser::http_headers_done, input_range); if (parsed_ok == true) { @@ -759,7 +759,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this callback, size_t bytes) { + void parse_body(boost::function callback, size_t bytes) { // TODO: we should really not use a string for the partial body // buffer. partial_parsed.append(part_begin, bytes); @@ -781,8 +781,8 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this resolver_delegate_; - shared_ptr connection_delegate_; + boost::shared_ptr resolver_delegate_; + boost::shared_ptr connection_delegate_; boost::asio::streambuf command_streambuf; std::string method; response_parser response_parser_; @@ -802,22 +802,22 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this resolver_delegate, - shared_ptr connection_delegate, - asio::io_service & io_service, +http_async_connection::http_async_connection(boost::shared_ptr resolver_delegate, + boost::shared_ptr connection_delegate, + boost::asio::io_service & io_service, bool follow_redirects) : pimpl(new (std::nothrow) http_async_connection_pimpl(resolver_delegate, connection_delegate, io_service, follow_redirects)) {} -http_async_connection::http_async_connection(shared_ptr new_pimpl) +http_async_connection::http_async_connection(boost::shared_ptr new_pimpl) : pimpl(new_pimpl) {} http_async_connection::~http_async_connection() {} http_async_connection * http_async_connection::clone() const { - shared_ptr new_pimpl(pimpl->clone()); + boost::shared_ptr new_pimpl(pimpl->clone()); return new (std::nothrow) http_async_connection(new_pimpl); } diff --git a/include/network/protocol/http/client/connection/async_resolver.ipp b/include/network/protocol/http/client/connection/async_resolver.ipp index e5eb15e8c..e3efce841 100644 --- a/include/network/protocol/http/client/connection/async_resolver.ipp +++ b/include/network/protocol/http/client/connection/async_resolver.ipp @@ -24,34 +24,34 @@ #include namespace network { namespace http { -struct async_resolver_pimpl : enable_shared_from_this { +struct async_resolver_pimpl : boost::enable_shared_from_this { typedef resolver_delegate::resolve_completion_function resolve_completion_function; - async_resolver_pimpl(asio::io_service & service, bool cache_resolved); + async_resolver_pimpl(boost::asio::io_service & service, bool cache_resolved); void resolve(std::string const & host, uint16_t port, resolve_completion_function once_resolved); void clear_resolved_cache(); private: - asio::ip::udp::resolver resolver_; + boost::asio::ip::udp::resolver resolver_; bool cache_resolved_; - typedef asio::ip::udp::resolver::iterator + typedef boost::asio::ip::udp::resolver::iterator resolver_iterator; - typedef unordered_map > + typedef boost::unordered_map > endpoint_cache; endpoint_cache endpoint_cache_; - scoped_ptr resolver_strand_; + boost::scoped_ptr resolver_strand_; void handle_resolve(std::string const & host, resolve_completion_function once_resolved, - system::error_code const & ec, + boost::system::error_code const & ec, resolver_iterator endpoint_iterator); }; -async_resolver_pimpl::async_resolver_pimpl(asio::io_service & service, bool cache_resolved) +async_resolver_pimpl::async_resolver_pimpl(boost::asio::io_service & service, bool cache_resolved) : resolver_(service), cache_resolved_(cache_resolved), endpoint_cache_(), - resolver_strand_(new(std::nothrow) asio::io_service::strand(service)) + resolver_strand_(new(std::nothrow) boost::asio::io_service::strand(service)) { // Do nothing } @@ -65,7 +65,7 @@ void async_resolver_pimpl::resolve(std::string const & host, boost::uint16_t port, resolve_completion_function once_resolved) { if (!resolver_strand_.get()) - THROW_EXCEPTION(std::runtime_error( + BOOST_THROW_EXCEPTION(std::runtime_error( "Uninitialized resolver strand, ran out of memory.")); if (cache_resolved_) { @@ -78,8 +78,8 @@ void async_resolver_pimpl::resolve(std::string const & host, } } - std::string port_str = lexical_cast(port); - asio::ip::udp::resolver::query query(host, port_str); + std::string port_str = boost::lexical_cast(port); + boost::asio::ip::udp::resolver::query query(host, port_str); resolver_.async_resolve( query, resolver_strand_->wrap( @@ -110,19 +110,19 @@ void async_resolver_pimpl::handle_resolve(std::string const & host, } } -async_resolver::async_resolver(asio::io_service & service, bool cache_resolved) +async_resolver::async_resolver(boost::asio::io_service & service, bool cache_resolved) : pimpl(new (std::nothrow) async_resolver_pimpl(service, cache_resolved)) {} void async_resolver::resolve(std::string const & host, uint16_t port, resolve_completion_function once_resolved) { - ASSERT(pimpl.get() && "Uninitialized pimpl, probably ran out of memory."); + BOOST_ASSERT(pimpl.get() && "Uninitialized pimpl, probably ran out of memory."); pimpl->resolve(host, port, once_resolved); } void async_resolver::clear_resolved_cache() { - ASSERT(pimpl.get() && "Uninitialized pimpl, probably ran out of memory."); + BOOST_ASSERT(pimpl.get() && "Uninitialized pimpl, probably ran out of memory."); pimpl->clear_resolved_cache(); } diff --git a/include/network/protocol/http/message/header.hpp b/include/network/protocol/http/message/header.hpp index 404cc3f02..86dc791dd 100644 --- a/include/network/protocol/http/message/header.hpp +++ b/include/network/protocol/http/message/header.hpp @@ -44,14 +44,14 @@ inline void swap(response_header & l, response_header & r) { } // namespace http } // namespace network -FUSION_ADAPT_STRUCT( - boost::network::http::request_header, +BOOST_FUSION_ADAPT_STRUCT( + network::http::request_header, (std::string, name) (std::string, value) ) -FUSION_ADAPT_STRUCT( - boost::network::http::response_header, +BOOST_FUSION_ADAPT_STRUCT( + network::http::response_header, (std::string, name) (std::string, value) ) diff --git a/include/network/protocol/http/message/header_concept.hpp b/include/network/protocol/http/message/header_concept.hpp index 95be4b557..cca90d313 100644 --- a/include/network/protocol/http/message/header_concept.hpp +++ b/include/network/protocol/http/message/header_concept.hpp @@ -11,9 +11,9 @@ namespace network { namespace http { template struct Header - : DefaultConstructible - , Assignable - , CopyConstructible + : boost::DefaultConstructible + , boost::Assignable + , boost::CopyConstructible { BOOST_CONCEPT_USAGE(Header) { diff --git a/include/network/protocol/http/request/request_concept.hpp b/include/network/protocol/http/request/request_concept.hpp index 909ec39e5..d78ff8829 100644 --- a/include/network/protocol/http/request/request_concept.hpp +++ b/include/network/protocol/http/request/request_concept.hpp @@ -48,13 +48,13 @@ namespace network { namespace http { std::string name, value; - request << ::boost::network::source(source_) - << ::boost::network::destination(destination_) - << ::boost::network::http::method(method_) - << ::boost::network::http::major_version(major_version_) - << ::boost::network::http::minor_version(minor_version_) - << ::boost::network::header(name, value) - << ::boost::network::body(body_); + request << network::source(source_) + << network::destination(destination_) + << network::http::method(method_) + << network::http::major_version(major_version_) + << network::http::minor_version(minor_version_) + << network::header(name, value) + << network::body(body_); (void)source_;(void)method_;(void)destination_; (void)major_version_;(void)minor_version_;(void)headers_; @@ -67,7 +67,7 @@ namespace network { namespace http { template struct ClientRequest - : boost::network::Message + : network::Message { BOOST_CONCEPT_USAGE(ClientRequest) { std::string tmp; @@ -83,7 +83,7 @@ namespace network { namespace http { request << uri(std::string()); - boost::network::http::uri(request, std::string()); + network::http::uri(request, std::string()); (void)host_; (void)port_; From 0eb17fcbf228b95e86914833e0d3c69b5876482a Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Fri, 28 Sep 2012 22:05:13 +1000 Subject: [PATCH 116/196] Completed move out of Boost. --- include/network/message/message.hpp | 12 +- include/network/message/message.ipp | 20 +-- include/network/message_fwd.hpp | 6 +- include/network/protocol/http/client.hpp | 4 +- include/network/protocol/http/client/base.hpp | 2 +- include/network/protocol/http/client/base.ipp | 10 +- .../http/client/connection/async_normal.ipp | 26 +-- .../network/protocol/http/client/facade.hpp | 8 +- .../network/protocol/http/client/facade.ipp | 12 +- .../network/protocol/http/client/options.ipp | 30 ++-- .../protocol/http/message/wrappers/port.ipp | 4 +- .../network/protocol/http/request/request.ipp | 24 +-- .../protocol/http/request/request_base.hpp | 12 +- .../protocol/http/request/request_base.ipp | 12 +- .../protocol/http/response/response.ipp | 162 +++++++++--------- include/network/protocol/http/server.hpp | 2 +- .../protocol/http/server/async_impl.hpp | 16 +- .../protocol/http/server/async_impl.ipp | 30 ++-- .../protocol/http/server/connection/async.hpp | 102 +++++------ .../protocol/http/server/connection/sync.hpp | 54 +++--- .../protocol/http/server/impl/parsers.ipp | 2 +- .../server/impl/socket_options_setter.hpp | 4 +- .../server/impl/socket_options_setter.ipp | 22 +-- .../network/protocol/http/server/options.hpp | 4 +- .../network/protocol/http/server/options.ipp | 10 +- .../protocol/http/server/request_parser.hpp | 36 ++-- .../protocol/http/server/sync_impl.hpp | 14 +- .../protocol/http/server/sync_impl.ipp | 20 +-- include/network/utils/thread_pool.hpp | 2 +- include/network/utils/thread_pool.ipp | 2 +- .../example/http/hello_world_client.cpp | 2 +- .../example/http/hello_world_server.cpp | 2 +- .../test/http/client_constructor_test.cpp | 2 +- .../http/client_get_different_port_test.cpp | 4 +- .../test/http/client_get_streaming_test.cpp | 6 +- libs/network/test/http/client_get_test.cpp | 4 +- .../test/http/client_get_timeout_test.cpp | 2 +- libs/network/test/http/request_base_test.cpp | 2 +- .../test/http/request_linearize_test.cpp | 4 +- libs/network/test/http/request_test.cpp | 4 +- libs/network/test/http/response_test.cpp | 2 +- .../server_async_run_stop_concurrency.cpp | 16 +- .../test/http/server_constructor_test.cpp | 4 +- libs/network/test/message_test.cpp | 6 +- libs/network/test/message_transform_test.cpp | 4 +- libs/network/test/utils_thread_pool.cpp | 2 +- 46 files changed, 365 insertions(+), 365 deletions(-) diff --git a/include/network/message/message.hpp b/include/network/message/message.hpp index e691059cd..67567e8c3 100644 --- a/include/network/message/message.hpp +++ b/include/network/message/message.hpp @@ -20,7 +20,7 @@ struct message_pimpl; // The common message type. struct message : message_base { // Nested types - typedef iterator_range< + typedef boost::iterator_range< std::multimap::const_iterator> headers_range; @@ -45,16 +45,16 @@ struct message : message_base { virtual void get_destination(std::string & destination) const; virtual void get_source(std::string & source) const; virtual void get_headers( - function inserter) const; + boost::function inserter) const; virtual void get_headers( std::string const & name, - function inserter) const; + boost::function inserter) const; virtual void get_headers( - function predicate, - function inserter) const; + boost::function predicate, + boost::function inserter) const; virtual void get_body(std::string & body) const; virtual void get_body( - function)> chunk_reader, + boost::function)> chunk_reader, size_t size) const; void swap(message & other); diff --git a/include/network/message/message.ipp b/include/network/message/message.ipp index f7b2c905b..4822c72d8 100644 --- a/include/network/message/message.ipp +++ b/include/network/message/message.ipp @@ -61,14 +61,14 @@ struct message_pimpl { source = source_; } - void get_headers(function inserter) const { + void get_headers(boost::function inserter) const { std::multimap::const_iterator it = headers_.begin(), end = headers_.end(); for (; it != end; ++it) inserter(it->first, it->second); } void get_headers(std::string const & name, - function inserter) const { + boost::function inserter) const { std::multimap::const_iterator it = headers_.find(name), end= headers_.end(); while (it != end) { @@ -77,8 +77,8 @@ struct message_pimpl { } } - void get_headers(function predicate, - function inserter) const { + void get_headers(boost::function predicate, + boost::function inserter) const { std::multimap::const_iterator it = headers_.begin(), end = headers_.end(); while (it != end) { @@ -92,7 +92,7 @@ struct message_pimpl { body = body_; } - void get_body(function)> chunk_reader, size_t size) const { + void get_body(boost::function)> chunk_reader, size_t size) const { static char const * nullptr_ = 0; if (body_read_pos == body_.size()) chunk_reader(boost::make_iterator_range(nullptr_, nullptr_)); @@ -179,17 +179,17 @@ void message::get_source(std::string & source) const { pimpl->get_source(source); } -void message::get_headers(function inserter) const { +void message::get_headers(boost::function inserter) const { pimpl->get_headers(inserter); } void message::get_headers(std::string const & name, - function inserter) const { + boost::function inserter) const { pimpl->get_headers(name, inserter); } -void message::get_headers(function predicate, - function inserter) const { +void message::get_headers(boost::function predicate, + boost::function inserter) const { pimpl->get_headers(predicate, inserter); } @@ -197,7 +197,7 @@ void message::get_body(std::string & body) const { pimpl->get_body(body); } -void message::get_body(function)> chunk_reader, size_t size) const { +void message::get_body(boost::function)> chunk_reader, size_t size) const { pimpl->get_body(chunk_reader, size); } diff --git a/include/network/message_fwd.hpp b/include/network/message_fwd.hpp index 4115cf0ec..62430d325 100644 --- a/include/network/message_fwd.hpp +++ b/include/network/message_fwd.hpp @@ -4,8 +4,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef 2008817MESSAGE_FWD_INC -#define 2008817MESSAGE_FWD_INC +#ifndef MESSAGE_FWS_INC_20120928 +#define MESSAGE_FWS_INC_20120928 namespace network { @@ -14,4 +14,4 @@ struct basic_message; } // namespace network -#endif // 2008817MESSAGE_FWD_INC +#endif // MESSAGE_FWS_INC_20120928 diff --git a/include/network/protocol/http/client.hpp b/include/network/protocol/http/client.hpp index 4cce99248..d6832919c 100644 --- a/include/network/protocol/http/client.hpp +++ b/include/network/protocol/http/client.hpp @@ -24,8 +24,8 @@ struct client : basic_client_facade { typedef basic_client_facade base_facade_type; public: - typedef ::boost::network::http::request request; - typedef ::boost::network::http::response response; + typedef network::http::request request; + typedef network::http::response response; // Constructor // ================================================================= diff --git a/include/network/protocol/http/client/base.hpp b/include/network/protocol/http/client/base.hpp index e792020f8..bdd71543a 100644 --- a/include/network/protocol/http/client/base.hpp +++ b/include/network/protocol/http/client/base.hpp @@ -28,7 +28,7 @@ class client_options; struct client_base { typedef - function const &, system::error_code const &)> + boost::function const &, boost::system::error_code const &)> body_callback_function_type; client_base(); diff --git a/include/network/protocol/http/client/base.ipp b/include/network/protocol/http/client/base.ipp index 8736e984f..3a6a5097c 100644 --- a/include/network/protocol/http/client/base.ipp +++ b/include/network/protocol/http/client/base.ipp @@ -22,7 +22,7 @@ namespace network { namespace http { struct client_base_pimpl { typedef - function const &, system::error_code const &)> + boost::function const &, boost::system::error_code const &)> body_callback_function_type; client_base_pimpl(client_options const &options); response const request_skeleton(request const & request_, @@ -37,7 +37,7 @@ struct client_base_pimpl { boost::asio::io_service * service_ptr; boost::shared_ptr sentinel_; boost::shared_ptr lifetime_thread_; - shared_ptr connection_manager_; + boost::shared_ptr connection_manager_; bool owned_service_; }; @@ -78,7 +78,7 @@ client_base_pimpl::client_base_pimpl(client_options const &options) NETWORK_MESSAGE("client_base_pimpl::client_base_pimpl(client_options const &)"); if (service_ptr == 0) { NETWORK_MESSAGE("creating owned io_service."); - service_ptr = new(std::nothrow) asio::io_service; + service_ptr = new(std::nothrow) boost::asio::io_service; owned_service_ = true; } if (!connection_manager_.get()) { @@ -93,7 +93,7 @@ client_base_pimpl::client_base_pimpl(client_options const &options) service_ptr ))); if (!lifetime_thread_.get()) - THROW_EXCEPTION(std::runtime_error("Cannot allocate client lifetime thread; not enough memory.")); + BOOST_THROW_EXCEPTION(std::runtime_error("Cannot allocate client lifetime thread; not enough memory.")); } client_base_pimpl::~client_base_pimpl() @@ -117,7 +117,7 @@ response const client_base_pimpl::request_skeleton( ) { NETWORK_MESSAGE("client_base_pimpl::request_skeleton(...)"); - shared_ptr connection_; + boost::shared_ptr connection_; connection_ = connection_manager_->get_connection(*service_ptr, request_, options_); return connection_->send_request(method, request_, get_body, callback, options); } diff --git a/include/network/protocol/http/client/connection/async_normal.ipp b/include/network/protocol/http/client/connection/async_normal.ipp index bff8430bf..a99680632 100644 --- a/include/network/protocol/http/client/connection/async_normal.ipp +++ b/include/network/protocol/http/client/connection/async_normal.ipp @@ -165,7 +165,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thiswrite(command_streambuf, request_strand_.wrap( @@ -339,7 +339,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisread_some( boost::asio::mutable_buffers_1(this->part.c_array(), @@ -386,7 +386,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thispart.begin(); buffer_type::const_iterator end = begin; std::advance(end, bytes_transferred); - callback(make_iterator_range(begin, end), ec); + callback(boost::make_iterator_range(begin, end), ec); connection_delegate_->read_some( boost::asio::mutable_buffers_1( this->part.c_array(), @@ -448,7 +448,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisbody_promise.set_exception(boost::copy_exception(error)); break; default: - ASSERT(false && "Bug, report this to the developers!"); + BOOST_ASSERT(false && "Bug, report this to the developers!"); } } } @@ -481,7 +481,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this(status); + boost::lexical_cast(status); status_promise.set_value(status_int); part_begin = boost::end(result_range); } else if (parsed_ok == false) { @@ -638,7 +638,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this 1) { header_pair.first.erase( header_pair.first.size() - 1 ); } - trim(header_pair.second); + boost::trim(header_pair.second); headers.insert(header_pair); } headers_promise.set_value(headers); diff --git a/include/network/protocol/http/client/facade.hpp b/include/network/protocol/http/client/facade.hpp index c6220d442..69e52b221 100644 --- a/include/network/protocol/http/client/facade.hpp +++ b/include/network/protocol/http/client/facade.hpp @@ -26,13 +26,13 @@ struct basic_client_facade { body_callback_function_type body_handler = body_callback_function_type(), request_options const &options=request_options()); response const post(request request, - optional body = optional(), - optional content_type = optional(), + boost::optional body = boost::optional(), + boost::optional content_type = boost::optional(), body_callback_function_type body_handler = body_callback_function_type(), request_options const&options = request_options()); response const put(request request, - optional body = optional(), - optional content_type = optional(), + boost::optional body = boost::optional(), + boost::optional content_type = boost::optional(), body_callback_function_type body_handler = body_callback_function_type(), request_options const & options = request_options()); response const delete_(request const & request, diff --git a/include/network/protocol/http/client/facade.ipp b/include/network/protocol/http/client/facade.ipp index a113c10bf..f4cec6427 100644 --- a/include/network/protocol/http/client/facade.ipp +++ b/include/network/protocol/http/client/facade.ipp @@ -41,8 +41,8 @@ response const basic_client_facade::get(request const &request, } response const basic_client_facade::post(request request, - optional body, - optional content_type, + boost::optional body, + boost::optional content_type, body_callback_function_type body_handler, request_options const &options) { NETWORK_MESSAGE("basic_client_facade::post(...)"); @@ -50,7 +50,7 @@ response const basic_client_facade::post(request request, NETWORK_MESSAGE("using body provided."); request << remove_header("Content-Length") << header("Content-Length", boost::lexical_cast(body->size())) - << boost::network::body(*body); + << network::body(*body); } headers_wrapper::container_type const & headers_ = @@ -70,8 +70,8 @@ response const basic_client_facade::post(request request, } response const basic_client_facade::put(request request, - optional body, - optional content_type, + boost::optional body, + boost::optional content_type, body_callback_function_type body_handler, request_options const & options) { NETWORK_MESSAGE("basic_client_facade::put(...)"); @@ -79,7 +79,7 @@ response const basic_client_facade::put(request request, NETWORK_MESSAGE("using body provided."); request << remove_header("Content-Length") << header("Content-Length", boost::lexical_cast(body->size())) - << boost::network::body(*body); + << network::body(*body); } headers_wrapper::container_type const & headers_ = diff --git a/include/network/protocol/http/client/options.ipp b/include/network/protocol/http/client/options.ipp index dfb4fa139..ae84dafbb 100644 --- a/include/network/protocol/http/client/options.ipp +++ b/include/network/protocol/http/client/options.ipp @@ -31,11 +31,11 @@ public: return new (std::nothrow) client_options_pimpl(*this); } - void io_service(asio::io_service *io_service) { + void io_service(boost::asio::io_service *io_service) { io_service_ = io_service_; } - asio::io_service* io_service() const { + boost::asio::io_service* io_service() const { return io_service_; } @@ -71,19 +71,19 @@ public: return openssl_verify_paths_; } - void connection_manager(shared_ptr manager) { + void connection_manager(boost::shared_ptr manager) { connection_manager_ = manager; } - shared_ptr connection_manager() const { + boost::shared_ptr connection_manager() const { return connection_manager_; } - void connection_factory(shared_ptr factory) { + void connection_factory(boost::shared_ptr factory) { connection_factory_ = factory; } - shared_ptr connection_factory() const { + boost::shared_ptr connection_factory() const { return connection_factory_; } @@ -101,11 +101,11 @@ private: client_options_pimpl& operator=(client_options_pimpl); // cannot assign // Here's the list of members. - asio::io_service *io_service_; + boost::asio::io_service *io_service_; bool follow_redirects_, cache_resolved_; std::list openssl_certificate_paths_, openssl_verify_paths_; - shared_ptr connection_manager_; - shared_ptr connection_factory_; + boost::shared_ptr connection_manager_; + boost::shared_ptr connection_factory_; }; client_options::client_options() @@ -130,12 +130,12 @@ client_options::~client_options() { pimpl = 0; } -client_options& client_options::io_service(asio::io_service *io_service) { +client_options& client_options::io_service(boost::asio::io_service *io_service) { pimpl->io_service(io_service); return *this; } -asio::io_service* client_options::io_service() const { +boost::asio::io_service* client_options::io_service() const { return pimpl->io_service(); } @@ -175,21 +175,21 @@ std::list const & client_options::openssl_verify_paths() const { return pimpl->openssl_verify_paths(); } -client_options& client_options::connection_manager(shared_ptr manager) { +client_options& client_options::connection_manager(boost::shared_ptr manager) { pimpl->connection_manager(manager); return *this; } -shared_ptr client_options::connection_manager() const { +boost::shared_ptr client_options::connection_manager() const { return pimpl->connection_manager(); } -client_options& client_options::connection_factory(shared_ptr factory) { +client_options& client_options::connection_factory(boost::shared_ptr factory) { pimpl->connection_factory(factory); return *this; } -shared_ptr client_options::connection_factory() const { +boost::shared_ptr client_options::connection_factory() const { return pimpl->connection_factory(); } diff --git a/include/network/protocol/http/message/wrappers/port.ipp b/include/network/protocol/http/message/wrappers/port.ipp index eee076832..c2962be7b 100644 --- a/include/network/protocol/http/message/wrappers/port.ipp +++ b/include/network/protocol/http/message/wrappers/port.ipp @@ -19,7 +19,7 @@ port_wrapper::port_wrapper(request_base const & request) port_wrapper::operator boost::uint16_t () const { ::network::uri uri_; request_.get_uri(uri_); - optional optional_port = port_us(uri_); + boost::optional optional_port = port_us(uri_); if (!optional_port) { std::string scheme_ = scheme(uri_); if (scheme_ == "http") { @@ -31,7 +31,7 @@ port_wrapper::operator boost::uint16_t () const { return optional_port ? *optional_port : 80u; } -port_wrapper::operator optional () const { +port_wrapper::operator boost::optional () const { ::network::uri uri_; request_.get_uri(uri_); return port_us(uri_); diff --git a/include/network/protocol/http/request/request.ipp b/include/network/protocol/http/request/request.ipp index 5f0a1e574..639db3624 100644 --- a/include/network/protocol/http/request/request.ipp +++ b/include/network/protocol/http/request/request.ipp @@ -66,8 +66,8 @@ struct request_pimpl { headers_.insert(std::make_pair(name, value)); } - void get_headers(function predicate, - function inserter) const { + void get_headers(boost::function predicate, + boost::function inserter) const { headers_type::const_iterator it = headers_.begin(); for (; it != headers_.end(); ++it) { if (predicate(it->first, it->second)) { @@ -76,7 +76,7 @@ struct request_pimpl { } } - void get_headers(function inserter) const { + void get_headers(boost::function inserter) const { headers_type::const_iterator it = headers_.begin(); for (; it != headers_.end(); ++it) { inserter(it->first, it->second); @@ -84,7 +84,7 @@ struct request_pimpl { } void get_headers(std::string const &name, - function inserter) const { + boost::function inserter) const { headers_type::const_iterator it = headers_.begin(); for (; it != headers_.end(); ++it) { if (it->first == name) { @@ -233,15 +233,15 @@ void request::get_source(std::string & source) const { pimpl_->get_source(source); } -void request::get_headers(function inserter) const { +void request::get_headers(boost::function inserter) const { pimpl_->get_headers(inserter); } -void request::get_headers(std::string const & name, function inserter) const { +void request::get_headers(std::string const & name, boost::function inserter) const { pimpl_->get_headers(name, inserter); } -void request::get_headers(function predicate, function inserter) const { +void request::get_headers(boost::function predicate, boost::function inserter) const { pimpl_->get_headers(predicate, inserter); } @@ -249,15 +249,15 @@ void request::get_body(std::string & body) const { this->flatten(body); } -void request::get_body(function)> chunk_reader, size_t size) const { - scoped_array local_buffer(new (std::nothrow) char[size]); +void request::get_body(boost::function)> chunk_reader, size_t size) const { + boost::scoped_array local_buffer(new (std::nothrow) char[size]); size_t bytes_read = this->read(local_buffer.get(), pimpl_->read_offset(), size); pimpl_->advance_read_offset(bytes_read); char const * begin = local_buffer.get(); char const * end = local_buffer.get() + bytes_read; - chunk_reader(make_iterator_range(begin, end)); + chunk_reader(boost::make_iterator_range(begin, end)); } // From request_base... @@ -271,7 +271,7 @@ void request::set_status(std::string const & status) { void request::set_status_message(std::string const & status_message) { } -void request::set_body_writer(function writer) { +void request::set_body_writer(boost::function writer) { } void request::set_uri(std::string const &uri) { @@ -316,7 +316,7 @@ void request::get_status(std::string & status) const { void request::get_status_message(std::string & status_message) const { } -void request::get_body(function chunk_reader) const { +void request::get_body(boost::function chunk_reader) const { } void request::get_body(std::string const & body) const { diff --git a/include/network/protocol/http/request/request_base.hpp b/include/network/protocol/http/request/request_base.hpp index fee870e21..c0e1f68e4 100644 --- a/include/network/protocol/http/request/request_base.hpp +++ b/include/network/protocol/http/request/request_base.hpp @@ -4,11 +4,11 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_BASE_HPP_20111008 -#define BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_BASE_HPP_20111008 +#ifndef NETWORK_PROTOCOL_HTTP_REQUEST_BASE_HPP_20111008 +#define NETWORK_PROTOCOL_HTTP_REQUEST_BASE_HPP_20111008 -#ifndef BOOST_NETWORK_BUFFER_CHUNK -#define BOOST_NETWORK_BUFFER_CHUNK 1024 // We want 1KiB worth of data at least. +#ifndef NETWORK_BUFFER_CHUNK +#define NETWORK_BUFFER_CHUNK 1024 // We want 1KiB worth of data at least. #endif #include @@ -25,7 +25,7 @@ struct request_storage_base_pimpl; struct request_storage_base { protected: - request_storage_base(size_t chunk_size = BOOST_NETWORK_BUFFER_CHUNK); + request_storage_base(size_t chunk_size = NETWORK_BUFFER_CHUNK); request_storage_base(request_storage_base const &other); virtual void append(char const *data, size_t size); virtual size_t read(char *destination, size_t offset, size_t size) const; @@ -62,4 +62,4 @@ struct request_base : message_base, request_storage_base { } // namespace http } // namespace network -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_BASE_HPP_20111008 */ +#endif /* NETWORK_PROTOCOL_HTTP_REQUEST_BASE_HPP_20111008 */ diff --git a/include/network/protocol/http/request/request_base.ipp b/include/network/protocol/http/request/request_base.ipp index 1c7a311e1..6e4ccadf7 100644 --- a/include/network/protocol/http/request/request_base.ipp +++ b/include/network/protocol/http/request/request_base.ipp @@ -32,7 +32,7 @@ struct request_storage_base_pimpl { size_t chunk_size_; typedef std::vector > chunks_vector; chunks_vector chunks_; - mutable mutex chunk_mutex_; + mutable boost::mutex chunk_mutex_; request_storage_base_pimpl(request_storage_base_pimpl const &other); }; @@ -83,7 +83,7 @@ request_storage_base_pimpl::request_storage_base_pimpl(size_t chunk_size) request_storage_base_pimpl::request_storage_base_pimpl(request_storage_base_pimpl const &other) : chunk_size_(other.chunk_size_) , chunks_(0) { - lock_guard scoped_lock(other.chunk_mutex_); + boost::lock_guard scoped_lock(other.chunk_mutex_); chunks_.reserve(other.chunks_.size()); chunks_vector::const_iterator it = other.chunks_.begin(); for (; it != other.chunks_.end(); ++it) { @@ -101,7 +101,7 @@ request_storage_base_pimpl * request_storage_base_pimpl::clone() const { } void request_storage_base_pimpl::append(char const *data, size_t size) { - lock_guard scoped_lock(chunk_mutex_); + boost::lock_guard scoped_lock(chunk_mutex_); if (chunks_.empty()) { chunks_.push_back(std::make_pair( new (std::nothrow) char[chunk_size_], 0)); @@ -128,7 +128,7 @@ void request_storage_base_pimpl::append(char const *data, size_t size) { } size_t request_storage_base_pimpl::read(char *destination, size_t offset, size_t size) const { - lock_guard scoped_lock(chunk_mutex_); + boost::lock_guard scoped_lock(chunk_mutex_); if (chunks_.empty()) return 0; // First we find which chunk we're going to read from using the provided // offset and some arithmetic to determine the correct one. @@ -153,7 +153,7 @@ size_t request_storage_base_pimpl::read(char *destination, size_t offset, size_t } void request_storage_base_pimpl::flatten(std::string &destination) const { - lock_guard scpoped_lock(chunk_mutex_); + boost::lock_guard scpoped_lock(chunk_mutex_); chunks_vector::const_iterator chunk_iterator = chunks_.begin(); for (; chunk_iterator != chunks_.end(); ++chunk_iterator) { destination.append(chunk_iterator->first, chunk_iterator->second); @@ -161,7 +161,7 @@ void request_storage_base_pimpl::flatten(std::string &destination) const { } void request_storage_base_pimpl::clear() { - lock_guard scoped_lock(chunk_mutex_); + boost::lock_guard scoped_lock(chunk_mutex_); chunks_vector::const_iterator chunk_iterator = chunks_.begin(); for (; chunk_iterator != chunks_.end(); ++chunk_iterator) { delete [] chunk_iterator->first; diff --git a/include/network/protocol/http/response/response.ipp b/include/network/protocol/http/response/response.ipp index 9f9129dce..0c8d7c519 100644 --- a/include/network/protocol/http/response/response.ipp +++ b/include/network/protocol/http/response/response.ipp @@ -20,14 +20,14 @@ struct response_pimpl { } void set_destination(std::string const &destination) { - promise destination_promise; + boost::promise destination_promise; destination_promise.set_value(destination); - unique_future tmp_future = destination_promise.get_future(); + boost::unique_future tmp_future = destination_promise.get_future(); destination_future_ = boost::move(tmp_future); } void get_destination(std::string &destination) { - if (destination_future_.get_state() == future_state::uninitialized) { + if (destination_future_.get_state() == boost::future_state::uninitialized) { destination = ""; } else { destination = destination_future_.get(); @@ -35,14 +35,14 @@ struct response_pimpl { } void set_source(std::string const &source) { - promise source_promise; + boost::promise source_promise; source_promise.set_value(source); - unique_future tmp_future = source_promise.get_future(); + boost::unique_future tmp_future = source_promise.get_future(); source_future_ = boost::move(tmp_future); } void get_source(std::string &source) { - if (source_future_.get_state() == future_state::uninitialized) { + if (source_future_.get_state() == boost::future_state::uninitialized) { source = ""; } else { source = source_future_.get(); @@ -59,10 +59,10 @@ struct response_pimpl { } void remove_headers() { - if (headers_future_.get_state() == future_state::uninitialized) { - promise > headers_promise; + if (headers_future_.get_state() == boost::future_state::uninitialized) { + boost::promise > headers_promise; headers_promise.set_value(std::multimap()); - unique_future > tmp = + boost::unique_future > tmp = headers_promise.get_future(); std::multimap().swap(added_headers_); std::set().swap(removed_headers_); @@ -71,9 +71,9 @@ struct response_pimpl { } void get_headers( - function inserter) { + boost::function inserter) { std::multimap::const_iterator it; - if (headers_future_.get_state() == future_state::uninitialized) { + if (headers_future_.get_state() == boost::future_state::uninitialized) { it = added_headers_.begin(); for (;it != added_headers_.end(); ++it) { if (removed_headers_.find(it->first) == removed_headers_.end()) { @@ -93,22 +93,22 @@ struct response_pimpl { } void get_headers( std::string const & name, - function inserter) { /* FIXME: Do something! */ } + boost::function inserter) { /* FIXME: Do something! */ } void get_headers( - function predicate, - function inserter) { /* FIXME: Do something! */ } + boost::function predicate, + boost::function inserter) { /* FIXME: Do something! */ } void set_body(std::string const &body) { - promise body_promise; + boost::promise body_promise; body_promise.set_value(body); - unique_future tmp_future = body_promise.get_future(); + boost::unique_future tmp_future = body_promise.get_future(); body_future_ = boost::move(tmp_future); } void append_body(std::string const & data) { /* FIXME: Do something! */ } void get_body(std::string &body) { - if (body_future_.get_state() == future_state::uninitialized) { + if (body_future_.get_state() == boost::future_state::uninitialized) { body = ""; } else { body = body_future_.get(); @@ -116,18 +116,18 @@ struct response_pimpl { } void get_body( - function)> chunk_reader, + boost::function)> chunk_reader, size_t size) { /* FIXME: Do something! */ } void set_status(boost::uint16_t status) { - promise status_promise; + boost::promise status_promise; status_promise.set_value(status); - unique_future tmp_future = status_promise.get_future(); + boost::unique_future tmp_future = status_promise.get_future(); status_future_ = boost::move(tmp_future); } void get_status(boost::uint16_t &status) { - if (status_future_.get_state() == future_state::uninitialized) { + if (status_future_.get_state() == boost::future_state::uninitialized) { status = 0u; } else { status = status_future_.get(); @@ -135,14 +135,14 @@ struct response_pimpl { } void set_status_message(std::string const &status_message) { - promise status_message_promise_; + boost::promise status_message_promise_; status_message_promise_.set_value(status_message); - unique_future tmp_future = status_message_promise_.get_future(); + boost::unique_future tmp_future = status_message_promise_.get_future(); status_message_future_ = boost::move(tmp_future); } void get_status_message(std::string &status_message) { - if (status_message_future_.get_state() == future_state::uninitialized) { + if (status_message_future_.get_state() == boost::future_state::uninitialized) { status_message = ""; } else { status_message = status_message_future_.get(); @@ -150,117 +150,117 @@ struct response_pimpl { } void set_version(std::string const &version) { - promise version_promise; + boost::promise version_promise; version_promise.set_value(version); - unique_future tmp_future = version_promise.get_future(); + boost::unique_future tmp_future = version_promise.get_future(); version_future_ = boost::move(tmp_future); } void get_version(std::string &version) { - if (version_future_.get_state() == future_state::uninitialized) { + if (version_future_.get_state() == boost::future_state::uninitialized) { version = ""; } else { version = version_future_.get(); } } - void set_source_promise(promise &promise_) { - unique_future tmp_future = promise_.get_future(); + void set_source_promise(boost::promise &promise_) { + boost::unique_future tmp_future = promise_.get_future(); source_future_ = boost::move(tmp_future); } - void set_destination_promise(promise &promise_) { - unique_future tmp_future = promise_.get_future(); + void set_destination_promise(boost::promise &promise_) { + boost::unique_future tmp_future = promise_.get_future(); destination_future_ = boost::move(tmp_future); } - void set_headers_promise(promise > &promise_) { - unique_future > tmp_future = promise_.get_future(); + void set_headers_promise(boost::promise > &promise_) { + boost::unique_future > tmp_future = promise_.get_future(); headers_future_ = boost::move(tmp_future); } - void set_status_promise(promise &promise_) { - unique_future tmp_future = promise_.get_future(); + void set_status_promise(boost::promise &promise_) { + boost::unique_future tmp_future = promise_.get_future(); status_future_ = boost::move(tmp_future); } - void set_status_message_promise(promise &promise_) { - unique_future tmp_future = promise_.get_future(); + void set_status_message_promise(boost::promise &promise_) { + boost::unique_future tmp_future = promise_.get_future(); status_message_future_ = boost::move(tmp_future); } - void set_version_promise(promise &promise_) { - unique_future tmp_future = promise_.get_future(); + void set_version_promise(boost::promise &promise_) { + boost::unique_future tmp_future = promise_.get_future(); version_future_ = boost::move(tmp_future); } - void set_body_promise(promise &promise_) { - unique_future tmp_future = promise_.get_future(); + void set_body_promise(boost::promise &promise_) { + boost::unique_future tmp_future = promise_.get_future(); body_future_ = boost::move(tmp_future); } bool equals(response_pimpl const &other) { - if (source_future_.get_state() != future_state::uninitialized) { - if (other.source_future_.get_state() == future_state::uninitialized) + if (source_future_.get_state() != boost::future_state::uninitialized) { + if (other.source_future_.get_state() == boost::future_state::uninitialized) return false; if (source_future_.get() != other.source_future_.get()) return false; } else { - if (other.source_future_.get_state() != future_state::uninitialized) + if (other.source_future_.get_state() != boost::future_state::uninitialized) return false; } - if (destination_future_.get_state() != future_state::uninitialized) { - if (other.destination_future_.get_state() == future_state::uninitialized) + if (destination_future_.get_state() != boost::future_state::uninitialized) { + if (other.destination_future_.get_state() == boost::future_state::uninitialized) return false; if (destination_future_.get() != other.destination_future_.get()) return false; } else { - if (other.destination_future_.get_state() != future_state::uninitialized) + if (other.destination_future_.get_state() != boost::future_state::uninitialized) return false; } - if (headers_future_.get_state() != future_state::uninitialized) { - if (other.headers_future_.get_state() == future_state::uninitialized) + if (headers_future_.get_state() != boost::future_state::uninitialized) { + if (other.headers_future_.get_state() == boost::future_state::uninitialized) return false; if (headers_future_.get() != other.headers_future_.get()) return false; } else { - if (other.headers_future_.get_state() != future_state::uninitialized) + if (other.headers_future_.get_state() != boost::future_state::uninitialized) return false; } - if (status_future_.get_state() != future_state::uninitialized) { - if (other.status_future_.get_state() == future_state::uninitialized) + if (status_future_.get_state() != boost::future_state::uninitialized) { + if (other.status_future_.get_state() == boost::future_state::uninitialized) return false; if (status_future_.get() != other.status_future_.get()) return false; } else { - if (other.status_future_.get_state() != future_state::uninitialized) + if (other.status_future_.get_state() != boost::future_state::uninitialized) return false; } - if (status_message_future_.get_state() != future_state::uninitialized) { - if (other.status_message_future_.get_state() == future_state::uninitialized) + if (status_message_future_.get_state() != boost::future_state::uninitialized) { + if (other.status_message_future_.get_state() == boost::future_state::uninitialized) return false; if (status_message_future_.get() != other.status_message_future_.get()) return false; } else { - if (other.status_message_future_.get_state() != future_state::uninitialized) + if (other.status_message_future_.get_state() != boost::future_state::uninitialized) return false; } - if (version_future_.get_state() != future_state::uninitialized) { - if (other.version_future_.get_state() == future_state::uninitialized) + if (version_future_.get_state() != boost::future_state::uninitialized) { + if (other.version_future_.get_state() == boost::future_state::uninitialized) return false; if (version_future_.get() != other.version_future_.get()) return false; } else { - if (other.version_future_.get_state() != future_state::uninitialized) + if (other.version_future_.get_state() != boost::future_state::uninitialized) return false; } - if (body_future_.get_state() != future_state::uninitialized) { - if (other.body_future_.get_state() == future_state::uninitialized) + if (body_future_.get_state() != boost::future_state::uninitialized) { + if (other.body_future_.get_state() == boost::future_state::uninitialized) return false; if (body_future_.get() != other.body_future_.get()) return false; } else { - if (other.body_future_.get_state() != future_state::uninitialized) + if (other.body_future_.get_state() != boost::future_state::uninitialized) return false; } if (other.added_headers_ != added_headers_ || other.removed_headers_ != removed_headers_) @@ -269,14 +269,14 @@ struct response_pimpl { } private: - mutable shared_future source_future_; - mutable shared_future destination_future_; - mutable shared_future > + mutable boost::shared_future source_future_; + mutable boost::shared_future destination_future_; + mutable boost::shared_future > headers_future_; - mutable shared_future status_future_; - mutable shared_future status_message_future_; - mutable shared_future version_future_; - mutable shared_future body_future_; + mutable boost::shared_future status_future_; + mutable boost::shared_future status_message_future_; + mutable boost::shared_future version_future_; + mutable boost::shared_future body_future_; // TODO: use unordered_map and unordered_set here. std::multimap added_headers_; std::set removed_headers_; @@ -352,17 +352,17 @@ void response::get_source(std::string &source) const { pimpl_->get_source(source); } -void response::get_headers(function inserter) const { +void response::get_headers(boost::function inserter) const { pimpl_->get_headers(inserter); } void response::get_headers(std::string const &name, - function inserter) const { + boost::function inserter) const { pimpl_->get_headers(name, inserter); } -void response::get_headers(function predicate, - function inserter) const { +void response::get_headers(boost::function predicate, + boost::function inserter) const { pimpl_->get_headers(predicate, inserter); } @@ -370,7 +370,7 @@ void response::get_body(std::string &body) const { pimpl_->get_body(body); } -void response::get_body(function)> chunk_reader, size_t size) const { +void response::get_body(boost::function)> chunk_reader, size_t size) const { pimpl_->get_body(chunk_reader, size); } @@ -402,31 +402,31 @@ response::~response() { delete pimpl_; } -void response::set_version_promise(promise &promise) { +void response::set_version_promise(boost::promise &promise) { return pimpl_->set_version_promise(promise); } -void response::set_status_promise(promise &promise) { +void response::set_status_promise(boost::promise &promise) { return pimpl_->set_status_promise(promise); } -void response::set_status_message_promise(promise &promise) { +void response::set_status_message_promise(boost::promise &promise) { return pimpl_->set_status_message_promise(promise); } -void response::set_headers_promise(promise > &promise) { +void response::set_headers_promise(boost::promise > &promise) { return pimpl_->set_headers_promise(promise); } -void response::set_source_promise(promise &promise) { +void response::set_source_promise(boost::promise &promise) { return pimpl_->set_source_promise(promise); } -void response::set_destination_promise(promise &promise) { +void response::set_destination_promise(boost::promise &promise) { return pimpl_->set_destination_promise(promise); } -void response::set_body_promise(promise &promise) { +void response::set_body_promise(boost::promise &promise) { return pimpl_->set_body_promise(promise); } diff --git a/include/network/protocol/http/server.hpp b/include/network/protocol/http/server.hpp index 91ec0a035..6027dfbe2 100644 --- a/include/network/protocol/http/server.hpp +++ b/include/network/protocol/http/server.hpp @@ -57,7 +57,7 @@ class async_server { ~async_server(); typedef http::request request; - typedef shared_ptr connection_ptr; + typedef boost::shared_ptr connection_ptr; private: async_server_impl *pimpl_; async_server(async_server const &other); // = delete diff --git a/include/network/protocol/http/server/async_impl.hpp b/include/network/protocol/http/server/async_impl.hpp index ebe41927f..32f139cb3 100644 --- a/include/network/protocol/http/server/async_impl.hpp +++ b/include/network/protocol/http/server/async_impl.hpp @@ -30,9 +30,9 @@ class async_server_connection; class async_server_impl : protected socket_options_setter { public: - typedef shared_ptr connection_ptr; + typedef boost::shared_ptr connection_ptr; async_server_impl(server_options const &options, - function handler, + boost::function handler, utils::thread_pool &thread_pool); ~async_server_impl(); void run(); @@ -42,17 +42,17 @@ class async_server_impl : protected socket_options_setter { private: server_options options_; std::string address_, port_; - asio::io_service *service_; - asio::ip::tcp::acceptor *acceptor_; - shared_ptr new_connection_; - mutex listening_mutex_, stopping_mutex_; - function handler_; + boost::asio::io_service *service_; + boost::asio::ip::tcp::acceptor *acceptor_; + boost::shared_ptr new_connection_; + boost::mutex listening_mutex_, stopping_mutex_; + boost::function handler_; utils::thread_pool &pool_; bool listening_, owned_service_, stopping_; void handle_stop(); void start_listening(); - void handle_accept(system::error_code const &ec); + void handle_accept(boost::system::error_code const &ec); }; } // namespace http diff --git a/include/network/protocol/http/server/async_impl.ipp b/include/network/protocol/http/server/async_impl.ipp index 626ed81b6..d6b462e4f 100644 --- a/include/network/protocol/http/server/async_impl.ipp +++ b/include/network/protocol/http/server/async_impl.ipp @@ -18,7 +18,7 @@ namespace network { namespace http { async_server_impl::async_server_impl(server_options const &options, - function handler, + boost::function handler, utils::thread_pool &thread_pool) : options_(options) , address_(options.address()) @@ -34,11 +34,11 @@ async_server_impl::async_server_impl(server_options const &options, , owned_service_(false) , stopping_(false) { if (service_ == 0) { - service_ = new (std::nothrow) asio::io_service; + service_ = new (std::nothrow) boost::asio::io_service; owned_service_ = true; } BOOST_ASSERT(service_ != 0); - acceptor_ = new (std::nothrow) asio::ip::tcp::acceptor(*service_); + acceptor_ = new (std::nothrow) boost::asio::ip::tcp::acceptor(*service_); BOOST_ASSERT(acceptor_ != 0); } @@ -53,11 +53,11 @@ void async_server_impl::run() { } void async_server_impl::stop() { - lock_guard listening_lock(listening_mutex_); + boost::lock_guard listening_lock(listening_mutex_); if (listening_) { - lock_guard stopping_lock(stopping_mutex_); + boost::lock_guard stopping_lock(stopping_mutex_); stopping_ = true; - system::error_code ignored; + boost::system::error_code ignored; acceptor_->close(ignored); listening_ = false; service_->post( @@ -66,7 +66,7 @@ void async_server_impl::stop() { } void async_server_impl::listen() { - lock_guard listening_lock(listening_mutex_); + boost::lock_guard listening_lock(listening_mutex_); NETWORK_MESSAGE("listening on " << address_ << ':' << port_); if (!listening_) start_listening(); if (!listening_) { @@ -76,7 +76,7 @@ void async_server_impl::listen() { } void async_server_impl::handle_stop() { - lock_guard stopping_lock(stopping_mutex_); + boost::lock_guard stopping_lock(stopping_mutex_); // A user may have stopped listening again before the stop command is // reached. if (stopping_) service_->stop(); @@ -84,7 +84,7 @@ void async_server_impl::handle_stop() { void async_server_impl::handle_accept(boost::system::error_code const & ec) { { - lock_guard stopping_lock(stopping_mutex_); + boost::lock_guard stopping_lock(stopping_mutex_); // We dont want to add another handler instance, and we dont want to know // about errors for a socket we dont need anymore. if (stopping_) return; @@ -99,15 +99,15 @@ void async_server_impl::handle_accept(boost::system::error_code const & ec) { boost::bind( &async_server_impl::handle_accept, this, - asio::placeholders::error)); + boost::asio::placeholders::error)); } else { NETWORK_MESSAGE("Error accepting connection, reason: " << ec); } } void async_server_impl::start_listening() { - using asio::ip::tcp; - system::error_code error; + using boost::asio::ip::tcp; + boost::system::error_code error; service_->reset(); // allows repeated cycles of run->stop->run tcp::resolver resolver(*service_); tcp::resolver::query query(address_, port_); @@ -128,7 +128,7 @@ void async_server_impl::start_listening() { NETWORK_MESSAGE("error binding socket: " << address_ << ":" << port_); BOOST_THROW_EXCEPTION(std::runtime_error("Error binding socket.")); } - acceptor_->listen(asio::socket_base::max_connections, error); + acceptor_->listen(boost::asio::socket_base::max_connections, error); if (error) { NETWORK_MESSAGE("error listening on socket: '" << error << "' on " << address_ << ":" << port_); BOOST_THROW_EXCEPTION(std::runtime_error("Error listening on socket.")); @@ -139,9 +139,9 @@ void async_server_impl::start_listening() { boost::bind( &async_server_impl::handle_accept, this, - asio::placeholders::error)); + boost::asio::placeholders::error)); listening_ = true; - lock_guard stopping_lock(stopping_mutex_); + boost::lock_guard stopping_lock(stopping_mutex_); stopping_ = false; // if we were in the process of stopping, we revoke that command and continue listening NETWORK_MESSAGE("now listening on '" << address_ << ":" << port_ << "'"); } diff --git a/include/network/protocol/http/server/connection/async.hpp b/include/network/protocol/http/server/connection/async.hpp index af12708fc..63dc90f1b 100644 --- a/include/network/protocol/http/server/connection/async.hpp +++ b/include/network/protocol/http/server/connection/async.hpp @@ -60,7 +60,7 @@ namespace network { namespace http { - extern void parse_version(std::string const & partial_parsed, fusion::tuple & version_pair); + extern void parse_version(std::string const & partial_parsed, boost::fusion::tuple & version_pair); extern void parse_headers(std::string const & input, std::vector > & container); class async_server_connection : public boost::enable_shared_from_this { @@ -87,7 +87,7 @@ namespace network { namespace http { }; typedef std::string string_type; - typedef shared_ptr connection_ptr; + typedef boost::shared_ptr connection_ptr; private: static char const * status_message(status_t status) { @@ -138,8 +138,8 @@ namespace network { namespace http { public: async_server_connection( - asio::io_service & io_service - , function handler + boost::asio::io_service & io_service + , boost::function handler , utils::thread_pool & thread_pool ) : socket_(io_service) @@ -155,7 +155,7 @@ namespace network { namespace http { ~async_server_connection() throw () { boost::system::error_code ignored; - socket_.shutdown(asio::ip::tcp::socket::shutdown_receive, ignored); + socket_.shutdown(boost::asio::ip::tcp::socket::shutdown_receive, ignored); } /** Function: template set_headers(Range headers) @@ -227,7 +227,7 @@ namespace network { namespace http { } template - typename disable_if, void>::type + typename boost::disable_if, void>::type write(Range const & range, Callback const & callback) { lock_guard lock(headers_mutex); if (error_encountered) boost::throw_exception(boost::system::system_error(*error_encountered)); @@ -235,7 +235,7 @@ namespace network { namespace http { } template - typename enable_if, void>::type + typename boost::enable_if, void>::type write(ConstBufferSeq const & seq, Callback const & callback) { write_vec_impl(seq, callback, shared_array_list(), shared_buffers()); @@ -245,7 +245,7 @@ namespace network { namespace http { typedef boost::array buffer_type; public: - typedef iterator_range input_range; + typedef boost::iterator_range input_range; typedef boost::function read_callback_function; void read(read_callback_function callback) { @@ -266,25 +266,25 @@ namespace network { namespace http { } socket().async_read_some( - asio::buffer(read_buffer_) + boost::asio::buffer(read_buffer_) , strand.wrap( boost::bind( &async_server_connection::wrap_read_handler , async_server_connection::shared_from_this() , callback - , asio::placeholders::error, asio::placeholders::bytes_transferred))); + , boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred))); } - asio::ip::tcp::socket & socket() { return socket_; } + boost::asio::ip::tcp::socket & socket() { return socket_; } utils::thread_pool & thread_pool() { return thread_pool_; } bool has_error() { return (!!error_encountered); } - optional error() + boost::optional error() { return error_encountered; } private: void wrap_read_handler(read_callback_function callback, boost::system::error_code const & ec, std::size_t bytes_transferred) { - if (ec) error_encountered = in_place(ec); + if (ec) error_encountered = boost::in_place(ec); buffer_type::const_iterator data_start = read_buffer_.begin() ,data_end = read_buffer_.begin(); std::advance(data_end, bytes_transferred); @@ -298,22 +298,22 @@ namespace network { namespace http { } void default_error(boost::system::error_code const & ec) { - error_encountered = in_place(ec); + error_encountered = boost::in_place(ec); } typedef boost::array array; - typedef std::list > array_list; + typedef std::list > array_list; typedef boost::shared_ptr shared_array_list; - typedef boost::shared_ptr > shared_buffers; + typedef boost::shared_ptr > shared_buffers; typedef boost::lock_guard lock_guard; typedef std::list > pending_actions_list; - asio::ip::tcp::socket socket_; - asio::io_service::strand strand; - function handler; + boost::asio::ip::tcp::socket socket_; + boost::asio::io_service::strand strand; + boost::function handler; utils::thread_pool & thread_pool_; volatile bool headers_already_sent, headers_in_progress; - asio::streambuf headers_buffer; + boost::asio::streambuf headers_buffer; boost::recursive_mutex headers_mutex; buffer_type read_buffer_; @@ -322,7 +322,7 @@ namespace network { namespace http { request request_; buffer_type::iterator new_start, data_end; std::string partial_parsed; - optional error_encountered; + boost::optional error_encountered; pending_actions_list pending_actions; friend class async_server_impl; @@ -341,7 +341,7 @@ namespace network { namespace http { void read_more(state_t state) { socket_.async_read_some( - asio::buffer(read_buffer_) + boost::asio::buffer(read_buffer_) , strand.wrap( boost::bind( &async_server_connection::handle_read_data, @@ -356,15 +356,15 @@ namespace network { namespace http { void handle_read_data(state_t state, boost::system::error_code const & ec, std::size_t bytes_transferred) { if (!ec) { - logic::tribool parsed_ok; - iterator_range result_range, input_range; + boost::logic::tribool parsed_ok; + boost::iterator_range result_range, input_range; data_end = read_buffer_.begin(); std::advance(data_end, bytes_transferred); switch (state) { case method: input_range = boost::make_iterator_range( new_start, data_end); - fusion::tie(parsed_ok, result_range) = parser.parse_until( + boost::fusion::tie(parsed_ok, result_range) = parser.parse_until( request_parser::method_done, input_range); if (!parsed_ok) { client_error(); @@ -374,7 +374,7 @@ namespace network { namespace http { swap(partial_parsed, method); method.append(boost::begin(result_range), boost::end(result_range)); - trim(method); + boost::trim(method); request_.set_method(method); new_start = boost::end(result_range); } else { @@ -388,7 +388,7 @@ namespace network { namespace http { case uri: input_range = boost::make_iterator_range( new_start, data_end); - fusion::tie(parsed_ok, result_range) = parser.parse_until( + boost::fusion::tie(parsed_ok, result_range) = parser.parse_until( request_parser::uri_done, input_range); if (!parsed_ok) { @@ -399,7 +399,7 @@ namespace network { namespace http { swap(partial_parsed, destination); destination.append(boost::begin(result_range), boost::end(result_range)); - trim(destination); + boost::trim(destination); request_.set_destination(destination); new_start = boost::end(result_range); } else { @@ -413,18 +413,18 @@ namespace network { namespace http { case version: input_range = boost::make_iterator_range( new_start, data_end); - fusion::tie(parsed_ok, result_range) = parser.parse_until( + boost::fusion::tie(parsed_ok, result_range) = parser.parse_until( request_parser::version_done, input_range); if (!parsed_ok) { client_error(); break; } else if (parsed_ok == true) { - fusion::tuple version_pair; + boost::fusion::tuple version_pair; partial_parsed.append(boost::begin(result_range), boost::end(result_range)); parse_version(partial_parsed, version_pair); - request_.set_version_major(fusion::get<0>(version_pair)); - request_.set_version_minor(fusion::get<1>(version_pair)); + request_.set_version_major(boost::fusion::get<0>(version_pair)); + request_.set_version_minor(boost::fusion::get<1>(version_pair)); new_start = boost::end(result_range); partial_parsed.clear(); } else { @@ -438,7 +438,7 @@ namespace network { namespace http { case headers: input_range = boost::make_iterator_range( new_start, data_end); - fusion::tie(parsed_ok, result_range) = parser.parse_until( + boost::fusion::tie(parsed_ok, result_range) = parser.parse_until( request_parser::headers_done, input_range); if (!parsed_ok) { @@ -459,7 +459,7 @@ namespace network { namespace http { thread_pool().post( boost::bind( handler, - cref(request_), + boost::cref(request_), async_server_connection::shared_from_this())); return; } else { @@ -475,7 +475,7 @@ namespace network { namespace http { std::abort(); } } else { - error_encountered = in_place(ec); + error_encountered = boost::in_place(ec); } } @@ -483,24 +483,24 @@ namespace network { namespace http { static char const * bad_request = "HTTP/1.0 400 Bad Request\r\nConnection: close\r\nContent-Type: text/plain\r\nContent-Length: 12\r\n\r\nBad Request."; - asio::async_write( + boost::asio::async_write( socket() - , asio::buffer(bad_request, strlen(bad_request)) + , boost::asio::buffer(bad_request, strlen(bad_request)) , strand.wrap( boost::bind( &async_server_connection::client_error_sent , async_server_connection::shared_from_this() - , asio::placeholders::error - , asio::placeholders::bytes_transferred))); + , boost::asio::placeholders::error + , boost::asio::placeholders::bytes_transferred))); } void client_error_sent(boost::system::error_code const & ec, std::size_t bytes_transferred) { if (!ec) { boost::system::error_code ignored; - socket().shutdown(asio::ip::tcp::socket::shutdown_both, ignored); + socket().shutdown(boost::asio::ip::tcp::socket::shutdown_both, ignored); socket().close(ignored); } else { - error_encountered = in_place(ec); + error_encountered = boost::in_place(ec); } } @@ -509,7 +509,7 @@ namespace network { namespace http { void write_headers_only(boost::function callback) { if (headers_in_progress) return; headers_in_progress = true; - asio::async_write( + boost::asio::async_write( socket() , headers_buffer , strand.wrap( @@ -517,8 +517,8 @@ namespace network { namespace http { &async_server_connection::handle_write_headers , async_server_connection::shared_from_this() , callback - , asio::placeholders::error - , asio::placeholders::bytes_transferred))); + , boost::asio::placeholders::error + , boost::asio::placeholders::bytes_transferred))); } void handle_write_headers(boost::function callback, boost::system::error_code const & ec, std::size_t bytes_transferred) { @@ -534,7 +534,7 @@ namespace network { namespace http { } pending_actions_list().swap(pending_actions); } else { - error_encountered = in_place(ec); + error_encountered = boost::in_place(ec); } } @@ -569,7 +569,7 @@ namespace network { namespace http { shared_array_list temporaries = boost::make_shared(); shared_buffers buffers = - boost::make_shared >(0); + boost::make_shared >(0); std::size_t range_size = boost::distance(range); buffers->reserve( @@ -583,13 +583,13 @@ namespace network { namespace http { , end = boost::end(range); while (slice_size != 0) { using boost::adaptors::sliced; - shared_ptr new_array = make_shared(); + boost::shared_ptr new_array = boost::make_shared(); boost::copy( range | sliced(0,slice_size) , new_array->begin() ); temporaries->push_back(new_array); - buffers->push_back(asio::buffer(new_array->data(), slice_size)); + buffers->push_back(boost::asio::buffer(new_array->data(), slice_size)); std::advance(start, slice_size); range = boost::make_iterator_range(start, end); range_size = boost::distance(range); @@ -628,7 +628,7 @@ namespace network { namespace http { return; } - asio::async_write( + boost::asio::async_write( socket_ ,seq ,boost::bind( @@ -637,8 +637,8 @@ namespace network { namespace http { ,callback_function ,temporaries ,buffers - ,asio::placeholders::error - ,asio::placeholders::bytes_transferred) + ,boost::asio::placeholders::error + ,boost::asio::placeholders::bytes_transferred) ); } }; diff --git a/include/network/protocol/http/server/connection/sync.hpp b/include/network/protocol/http/server/connection/sync.hpp index 75e643957..7a4e02798 100644 --- a/include/network/protocol/http/server/connection/sync.hpp +++ b/include/network/protocol/http/server/connection/sync.hpp @@ -33,14 +33,14 @@ namespace network { namespace http { #ifndef NETWORK_NO_LIB - extern void parse_version(std::string const & partial_parsed, fusion::tuple & version_pair); + extern void parse_version(std::string const & partial_parsed, boost::fusion::tuple & version_pair); extern void parse_headers(std::string const & input, std::vector > & container); #endif class sync_server_connection : public boost::enable_shared_from_this { public: sync_server_connection(boost::asio::io_service & service, - function handler) + boost::function handler) : service_(service) , handler_(handler) , socket_(service_) @@ -81,15 +81,15 @@ class sync_server_connection : public boost::enable_shared_from_this result_range, input_range; + boost::logic::tribool parsed_ok; + boost::iterator_range result_range, input_range; data_end = read_buffer_.begin(); std::advance(data_end, bytes_transferred); switch (state) { case method: input_range = boost::make_iterator_range( new_start, data_end); - fusion::tie(parsed_ok, result_range) = parser_.parse_until( + boost::fusion::tie(parsed_ok, result_range) = parser_.parse_until( request_parser::method_done, input_range); if (!parsed_ok) { client_error(); @@ -99,7 +99,7 @@ class sync_server_connection : public boost::enable_shared_from_this version_pair; + boost::fusion::tuple version_pair; partial_parsed.append(boost::begin(result_range), boost::end(result_range)); parse_version(partial_parsed, version_pair); - request_.set_version_major(fusion::get<0>(version_pair)); - request_.set_version_minor(fusion::get<1>(version_pair)); + request_.set_version_major(boost::fusion::get<0>(version_pair)); + request_.set_version_minor(boost::fusion::get<1>(version_pair)); new_start = boost::end(result_range); partial_parsed.clear(); } else { @@ -167,7 +167,7 @@ class sync_server_connection : public boost::enable_shared_from_this response_buffers(output_buffers_.size()); + std::vector response_buffers(output_buffers_.size()); std::transform(output_buffers_.begin(), output_buffers_.end(), response_buffers.begin(), [](buffer_type const &buffer) { - return asio::const_buffer(buffer.data(), buffer.size()); + return boost::asio::const_buffer(buffer.data(), buffer.size()); }); boost::asio::async_write( socket_, @@ -219,11 +219,11 @@ class sync_server_connection : public boost::enable_shared_from_this(ec); + error_encountered = boost::in_place(ec); } } - void handle_write(system::error_code const &ec) { + void handle_write(boost::system::error_code const &ec) { // First thing we do is clear out the output buffers. output_buffers_.clear(); if (ec) { @@ -235,30 +235,30 @@ class sync_server_connection : public boost::enable_shared_from_this(ec); + error_encountered = boost::in_place(ec); } } void read_more(state_t state) { socket_.async_read_some( - asio::buffer(read_buffer_) + boost::asio::buffer(read_buffer_) , wrapper_.wrap( boost::bind( &sync_server_connection::handle_read_data, @@ -294,7 +294,7 @@ class sync_server_connection : public boost::enable_shared_from_this data) { + response_.get_body([&done, &buffer](boost::iterator_range data) { if (boost::empty(data)) done = true; else std::copy(std::begin(data), std::end(data), buffer.begin()); }, buffer.size()); @@ -312,7 +312,7 @@ class sync_server_connection : public boost::enable_shared_from_this handler_; + boost::function handler_; boost::asio::ip::tcp::socket socket_; boost::asio::io_service::strand wrapper_; @@ -324,7 +324,7 @@ class sync_server_connection : public boost::enable_shared_from_this output_buffers_; std::string partial_parsed; - optional error_encountered; + boost::optional error_encountered; bool read_body_; }; diff --git a/include/network/protocol/http/server/impl/parsers.ipp b/include/network/protocol/http/server/impl/parsers.ipp index 5a104a760..0bbf358d7 100644 --- a/include/network/protocol/http/server/impl/parsers.ipp +++ b/include/network/protocol/http/server/impl/parsers.ipp @@ -24,7 +24,7 @@ namespace network { namespace http { - NETWORK_INLINE void parse_version(std::string const & partial_parsed, fusion::tuple & version_pair) { + NETWORK_INLINE void parse_version(std::string const & partial_parsed, boost::fusion::tuple & version_pair) { using namespace boost::spirit::qi; parse( partial_parsed.begin(), partial_parsed.end(), diff --git a/include/network/protocol/http/server/impl/socket_options_setter.hpp b/include/network/protocol/http/server/impl/socket_options_setter.hpp index 2906f3b0c..05121cf08 100644 --- a/include/network/protocol/http/server/impl/socket_options_setter.hpp +++ b/include/network/protocol/http/server/impl/socket_options_setter.hpp @@ -15,8 +15,8 @@ class server_options; class socket_options_setter { protected: - void set_socket_options(server_options const &options, asio::ip::tcp::socket &socket); - void set_acceptor_options(server_options const &options, asio::ip::tcp::acceptor &acceptor); + void set_socket_options(server_options const &options, boost::asio::ip::tcp::socket &socket); + void set_acceptor_options(server_options const &options, boost::asio::ip::tcp::acceptor &acceptor); }; } // namespace http diff --git a/include/network/protocol/http/server/impl/socket_options_setter.ipp b/include/network/protocol/http/server/impl/socket_options_setter.ipp index 34465aad7..6f0010726 100644 --- a/include/network/protocol/http/server/impl/socket_options_setter.ipp +++ b/include/network/protocol/http/server/impl/socket_options_setter.ipp @@ -12,38 +12,38 @@ namespace network { namespace http { -void socket_options_setter::set_socket_options(server_options const & options, asio::ip::tcp::socket &socket) { - system::error_code ignored; +void socket_options_setter::set_socket_options(server_options const & options, boost::asio::ip::tcp::socket &socket) { + boost::system::error_code ignored; socket.non_blocking(options.non_blocking_io(), ignored); if (options.linger()) { - asio::ip::tcp::socket::linger linger(true, options.linger_timeout()); + boost::asio::ip::tcp::socket::linger linger(true, options.linger_timeout()); socket.set_option(linger, ignored); } if (int buf_size = options.receive_buffer_size() >= 0) { - asio::ip::tcp::socket::receive_buffer_size receive_buffer_size(buf_size); + boost::asio::ip::tcp::socket::receive_buffer_size receive_buffer_size(buf_size); socket.set_option(receive_buffer_size, ignored); } if (int buf_size = options.send_buffer_size() >= 0) { - asio::ip::tcp::socket::send_buffer_size send_buffer_size(buf_size); + boost::asio::ip::tcp::socket::send_buffer_size send_buffer_size(buf_size); socket.set_option(send_buffer_size, ignored); } if (int buf_size = options.receive_low_watermark() >= 0) { - asio::ip::tcp::socket::receive_low_watermark receive_low_watermark(buf_size); + boost::asio::ip::tcp::socket::receive_low_watermark receive_low_watermark(buf_size); socket.set_option(receive_low_watermark, ignored); } if (int buf_size = options.send_low_watermark() >= 0) { - asio::ip::tcp::socket::send_low_watermark send_low_watermark(buf_size); + boost::asio::ip::tcp::socket::send_low_watermark send_low_watermark(buf_size); socket.set_option(send_low_watermark, ignored); } } -void socket_options_setter::set_acceptor_options(server_options const &options, asio::ip::tcp::acceptor &acceptor) { - system::error_code ignored; +void socket_options_setter::set_acceptor_options(server_options const &options, boost::asio::ip::tcp::acceptor &acceptor) { + boost::system::error_code ignored; acceptor.set_option( - asio::ip::tcp::acceptor::reuse_address(options.reuse_address()), + boost::asio::ip::tcp::acceptor::reuse_address(options.reuse_address()), ignored); acceptor.set_option( - asio::ip::tcp::acceptor::enable_connection_aborted(options.report_aborted()), + boost::asio::ip::tcp::acceptor::enable_connection_aborted(options.report_aborted()), ignored); } diff --git a/include/network/protocol/http/server/options.hpp b/include/network/protocol/http/server/options.hpp index add43eaca..9cdc3499d 100644 --- a/include/network/protocol/http/server/options.hpp +++ b/include/network/protocol/http/server/options.hpp @@ -35,8 +35,8 @@ class server_options { server_options& port(std::string const &port); std::string const port() const; - server_options& io_service(asio::io_service *service); - asio::io_service *io_service() const; + server_options& io_service(boost::asio::io_service *service); + boost::asio::io_service *io_service() const; server_options& reuse_address(bool setting); bool reuse_address() const; diff --git a/include/network/protocol/http/server/options.ipp b/include/network/protocol/http/server/options.ipp index 8b2b13fc9..90c290f44 100644 --- a/include/network/protocol/http/server/options.ipp +++ b/include/network/protocol/http/server/options.ipp @@ -49,11 +49,11 @@ class server_options_pimpl { return port_; } - void io_service(asio::io_service *service) { + void io_service(boost::asio::io_service *service) { io_service_ = service; } - asio::io_service *io_service() const { + boost::asio::io_service *io_service() const { return io_service_; } @@ -131,7 +131,7 @@ class server_options_pimpl { private: std::string address_, port_; - asio::io_service *io_service_; + boost::asio::io_service *io_service_; int receive_buffer_size_, send_buffer_size_, receive_low_watermark_, send_low_watermark_, linger_timeout_; @@ -193,12 +193,12 @@ std::string const server_options::port() const { return pimpl_->port(); } -server_options& server_options::io_service(asio::io_service *io_service) { +server_options& server_options::io_service(boost::asio::io_service *io_service) { pimpl_->io_service(io_service); return *this; } -asio::io_service* server_options::io_service() const { +boost::asio::io_service* server_options::io_service() const { return pimpl_->io_service(); } diff --git a/include/network/protocol/http/server/request_parser.hpp b/include/network/protocol/http/server/request_parser.hpp index cce648e88..34093e265 100644 --- a/include/network/protocol/http/server/request_parser.hpp +++ b/include/network/protocol/http/server/request_parser.hpp @@ -53,14 +53,14 @@ namespace network { namespace http { state_t state() const { return internal_state; } template - fusion::tuple > + boost::fusion::tuple > parse_until(state_t stop_state, Range & range) { - logic::tribool parsed_ok = logic::indeterminate; - typedef typename range_iterator::type iterator; + boost::logic::tribool parsed_ok = boost::logic::indeterminate; + typedef typename boost::range_iterator::type iterator; iterator start = boost::begin(range) , end = boost::end(range) , current_iterator = start; - iterator_range local_range = + boost::iterator_range local_range = boost::make_iterator_range(start, end); while ( !boost::empty(local_range) @@ -70,22 +70,22 @@ namespace network { namespace http { current_iterator = boost::begin(local_range); switch(internal_state) { case method_start: - if (algorithm::is_upper()(*current_iterator)) internal_state = method_char; + if (boost::algorithm::is_upper()(*current_iterator)) internal_state = method_char; else parsed_ok = false; break; case method_char: - if (algorithm::is_upper()(*current_iterator)) break; - else if (algorithm::is_space()(*current_iterator)) internal_state = method_done; + if (boost::algorithm::is_upper()(*current_iterator)) break; + else if (boost::algorithm::is_space()(*current_iterator)) internal_state = method_done; else parsed_ok = false; break; case method_done: - if (algorithm::is_cntrl()(*current_iterator)) parsed_ok = false; - else if (algorithm::is_space()(*current_iterator)) parsed_ok = false; + if (boost::algorithm::is_cntrl()(*current_iterator)) parsed_ok = false; + else if (boost::algorithm::is_space()(*current_iterator)) parsed_ok = false; else internal_state = uri_char; break; case uri_char: - if (algorithm::is_cntrl()(*current_iterator)) parsed_ok = false; - else if (algorithm::is_space()(*current_iterator)) internal_state = uri_done; + if (boost::algorithm::is_cntrl()(*current_iterator)) parsed_ok = false; + else if (boost::algorithm::is_space()(*current_iterator)) internal_state = uri_done; break; case uri_done: if (*current_iterator == 'H') internal_state = version_h; @@ -108,7 +108,7 @@ namespace network { namespace http { else parsed_ok = false; break; case version_slash: - if (algorithm::is_digit()(*current_iterator)) internal_state = version_d1; + if (boost::algorithm::is_digit()(*current_iterator)) internal_state = version_d1; else parsed_ok = false; break; case version_d1: @@ -116,7 +116,7 @@ namespace network { namespace http { else parsed_ok = false; break; case version_dot: - if (algorithm::is_digit()(*current_iterator)) internal_state = version_d2; + if (boost::algorithm::is_digit()(*current_iterator)) internal_state = version_d2; else parsed_ok = false; break; case version_d2: @@ -128,13 +128,13 @@ namespace network { namespace http { else parsed_ok = false; break; case version_done: - if (algorithm::is_alnum()(*current_iterator)) internal_state = header_name; + if (boost::algorithm::is_alnum()(*current_iterator)) internal_state = header_name; else if (*current_iterator == '\r') internal_state = headers_cr; else parsed_ok = false; break; case header_name: if (*current_iterator == ':') internal_state = header_colon; - else if (algorithm::is_alnum()(*current_iterator) || algorithm::is_punct()(*current_iterator)) break; + else if (boost::algorithm::is_alnum()(*current_iterator) || boost::algorithm::is_punct()(*current_iterator)) break; else parsed_ok = false; break; case header_colon: @@ -143,7 +143,7 @@ namespace network { namespace http { break; case header_value: if (*current_iterator == '\r') internal_state = header_cr; - else if (algorithm::is_cntrl()(*current_iterator)) parsed_ok = false; + else if (boost::algorithm::is_cntrl()(*current_iterator)) parsed_ok = false; break; case header_cr: if (*current_iterator == '\n') internal_state = header_line_done; @@ -151,7 +151,7 @@ namespace network { namespace http { break; case header_line_done: if (*current_iterator == '\r') internal_state = headers_cr; - else if (algorithm::is_alnum()(*current_iterator)) internal_state = header_name; + else if (boost::algorithm::is_alnum()(*current_iterator)) internal_state = header_name; else parsed_ok = false; break; case headers_cr: @@ -168,7 +168,7 @@ namespace network { namespace http { local_range = boost::make_iterator_range( ++current_iterator, end); } - return fusion::make_tuple( + return boost::fusion::make_tuple( parsed_ok, boost::make_iterator_range( start, current_iterator diff --git a/include/network/protocol/http/server/sync_impl.hpp b/include/network/protocol/http/server/sync_impl.hpp index be1a800b8..8a78dfabc 100644 --- a/include/network/protocol/http/server/sync_impl.hpp +++ b/include/network/protocol/http/server/sync_impl.hpp @@ -23,7 +23,7 @@ struct response; class sync_server_impl : protected socket_options_setter { public: sync_server_impl(server_options const &options, - function handler); + boost::function handler); void run(); void stop(); void listen(); @@ -31,15 +31,15 @@ class sync_server_impl : protected socket_options_setter { private: server_options options_; std::string address_, port_; - asio::io_service *service_; - asio::ip::tcp::acceptor *acceptor_; - shared_ptr new_connection_; - mutex listening_mutex_; + boost::asio::io_service *service_; + boost::asio::ip::tcp::acceptor *acceptor_; + boost::shared_ptr new_connection_; + boost::mutex listening_mutex_; bool listening_, owned_service_; - function handler_; + boost::function handler_; void start_listening(); - void handle_accept(system::error_code const &ec); + void handle_accept(boost::system::error_code const &ec); }; } // namespace http diff --git a/include/network/protocol/http/server/sync_impl.ipp b/include/network/protocol/http/server/sync_impl.ipp index ae0702f0e..dd883ac13 100644 --- a/include/network/protocol/http/server/sync_impl.ipp +++ b/include/network/protocol/http/server/sync_impl.ipp @@ -14,7 +14,7 @@ namespace network { namespace http { sync_server_impl::sync_server_impl(server_options const &options, - function handler) + boost::function handler) : options_(options) , address_(options.address()) , port_(options.port()) @@ -25,11 +25,11 @@ sync_server_impl::sync_server_impl(server_options const &options, , listening_(false) , owned_service_(false) { if (service_ == 0) { - service_ = new (std::nothrow) asio::io_service; + service_ = new (std::nothrow) boost::asio::io_service; owned_service_ = true; BOOST_ASSERT(service_ != 0); } - acceptor_ = new (std::nothrow) asio::ip::tcp::acceptor(*service_); + acceptor_ = new (std::nothrow) boost::asio::ip::tcp::acceptor(*service_); BOOST_ASSERT(acceptor_ != 0); } @@ -39,17 +39,17 @@ void sync_server_impl::run() { } void sync_server_impl::stop() { - system::error_code ignored; + boost::system::error_code ignored; acceptor_->close(ignored); service_->stop(); } void sync_server_impl::listen() { - lock_guard listening_lock(listening_mutex_); + boost::lock_guard listening_lock(listening_mutex_); if (!listening_) start_listening(); } -void sync_server_impl::handle_accept(system::error_code const &ec) { +void sync_server_impl::handle_accept(boost::system::error_code const &ec) { if (!ec) { set_socket_options(options_, new_connection_->socket()); new_connection_->start(); @@ -57,7 +57,7 @@ void sync_server_impl::handle_accept(system::error_code const &ec) { acceptor_->async_accept(new_connection_->socket(), bind(&sync_server_impl::handle_accept, this, - asio::placeholders::error)); + boost::asio::placeholders::error)); } else { NETWORK_MESSAGE("error accepting connection: " << ec); this->stop(); @@ -65,8 +65,8 @@ void sync_server_impl::handle_accept(system::error_code const &ec) { } void sync_server_impl::start_listening() { - using asio::ip::tcp; - system::error_code error; + using boost::asio::ip::tcp; + boost::system::error_code error; tcp::resolver resolver(*service_); tcp::resolver::query query(address_, port_); tcp::resolver::iterator endpoint_ = resolver.resolve(query, error); @@ -95,7 +95,7 @@ void sync_server_impl::start_listening() { acceptor_->async_accept(new_connection_->socket(), bind(&sync_server_impl::handle_accept, this, - asio::placeholders::error)); + boost::asio::placeholders::error)); listening_ = true; } diff --git a/include/network/utils/thread_pool.hpp b/include/network/utils/thread_pool.hpp index 5b6e59611..4477f7a74 100644 --- a/include/network/utils/thread_pool.hpp +++ b/include/network/utils/thread_pool.hpp @@ -27,7 +27,7 @@ struct thread_pool { io_service_ptr io_service = io_service_ptr(), worker_threads_ptr worker_threads = worker_threads_ptr()); std::size_t const thread_count() const; - void post(function f); + void post(boost::function f); ~thread_pool(); void swap(thread_pool & other); protected: diff --git a/include/network/utils/thread_pool.ipp b/include/network/utils/thread_pool.ipp index d3c8ac2ec..3cf14b226 100644 --- a/include/network/utils/thread_pool.ipp +++ b/include/network/utils/thread_pool.ipp @@ -103,7 +103,7 @@ std::size_t const thread_pool::thread_count() const { return pimpl->thread_count(); } -void thread_pool::post(function f) { +void thread_pool::post(boost::function f) { pimpl->post(f); } diff --git a/libs/network/example/http/hello_world_client.cpp b/libs/network/example/http/hello_world_client.cpp index 27b0215e3..53d9eef55 100644 --- a/libs/network/example/http/hello_world_client.cpp +++ b/libs/network/example/http/hello_world_client.cpp @@ -16,7 +16,7 @@ #include -namespace http = boost::network::http; +namespace http = network::http; int diff --git a/libs/network/example/http/hello_world_server.cpp b/libs/network/example/http/hello_world_server.cpp index 95880b367..5e950e43f 100644 --- a/libs/network/example/http/hello_world_server.cpp +++ b/libs/network/example/http/hello_world_server.cpp @@ -16,7 +16,7 @@ #include -namespace http = boost::network::http; +namespace http = network::http; /*<< Defines the server. >>*/ diff --git a/libs/network/test/http/client_constructor_test.cpp b/libs/network/test/http/client_constructor_test.cpp index 6448c2eeb..327e7f5a2 100644 --- a/libs/network/test/http/client_constructor_test.cpp +++ b/libs/network/test/http/client_constructor_test.cpp @@ -9,7 +9,7 @@ #include #include -namespace http = boost::network::http; +namespace http = network::http; BOOST_AUTO_TEST_CASE(http_client_constructor_test) { // Here's the simplest way to construct a client. diff --git a/libs/network/test/http/client_get_different_port_test.cpp b/libs/network/test/http/client_get_different_port_test.cpp index 8c3a0dbf2..f2f7ef9ed 100644 --- a/libs/network/test/http/client_get_different_port_test.cpp +++ b/libs/network/test/http/client_get_different_port_test.cpp @@ -9,8 +9,8 @@ #include #include -namespace http = boost::network::http; -namespace net = boost::network; +namespace http = network::http; +namespace net = network; BOOST_AUTO_TEST_CASE(http_get_test_different_port) { http::request request_("http://www.boost.org/"); diff --git a/libs/network/test/http/client_get_streaming_test.cpp b/libs/network/test/http/client_get_streaming_test.cpp index 4db77c9cb..fba0d83d1 100644 --- a/libs/network/test/http/client_get_streaming_test.cpp +++ b/libs/network/test/http/client_get_streaming_test.cpp @@ -9,15 +9,15 @@ #include #include -namespace net = boost::network; -namespace http = boost::network::http; +namespace net = network; +namespace http = network::http; struct body_handler { explicit body_handler(std::string & body) : body(body) {} - BOOST_NETWORK_HTTP_BODY_CALLBACK(operator(), range, error) { + NETWORK_HTTP_BODY_CALLBACK(operator(), range, error) { body.append(boost::begin(range), boost::end(range)); } diff --git a/libs/network/test/http/client_get_test.cpp b/libs/network/test/http/client_get_test.cpp index 901055730..e16ec3089 100644 --- a/libs/network/test/http/client_get_test.cpp +++ b/libs/network/test/http/client_get_test.cpp @@ -8,8 +8,8 @@ #include #include -namespace net = boost::network; -namespace http = boost::network::http; +namespace net = network; +namespace http = network::http; BOOST_AUTO_TEST_CASE(http_client_get_test) { http::client::request request("http://www.google.com/"); diff --git a/libs/network/test/http/client_get_timeout_test.cpp b/libs/network/test/http/client_get_timeout_test.cpp index 370684b86..7529b4491 100644 --- a/libs/network/test/http/client_get_timeout_test.cpp +++ b/libs/network/test/http/client_get_timeout_test.cpp @@ -9,7 +9,7 @@ #include #include -namespace http = boost::network::http; +namespace http = network::http; BOOST_AUTO_TEST_CASE(http_get_test_timeout_1_0) { http::client::request request("http://localhost:12121/"); diff --git a/libs/network/test/http/request_base_test.cpp b/libs/network/test/http/request_base_test.cpp index d916e851f..fd8ebbf7a 100644 --- a/libs/network/test/http/request_base_test.cpp +++ b/libs/network/test/http/request_base_test.cpp @@ -8,7 +8,7 @@ #include #include -namespace http = boost::network::http; +namespace http = network::http; // In this test we make sure that the implementation of the default request // storage base actually doesn't have bugs and works as advertised. Although we diff --git a/libs/network/test/http/request_linearize_test.cpp b/libs/network/test/http/request_linearize_test.cpp index 0b54a5d2a..4aa93ade0 100644 --- a/libs/network/test/http/request_linearize_test.cpp +++ b/libs/network/test/http/request_linearize_test.cpp @@ -11,8 +11,8 @@ #include #include -namespace http = boost::network::http; -namespace net = boost::network; +namespace http = network::http; +namespace net = network; BOOST_AUTO_TEST_CASE(linearize_request) { http::request request("http://www.boost.org/"); diff --git a/libs/network/test/http/request_test.cpp b/libs/network/test/http/request_test.cpp index 88395157a..59763e3f9 100644 --- a/libs/network/test/http/request_test.cpp +++ b/libs/network/test/http/request_test.cpp @@ -11,8 +11,8 @@ #include #include -namespace http = boost::network::http; -namespace net = boost::network; +namespace http = network::http; +namespace net = network; BOOST_AUTO_TEST_CASE(request_construction) { http::request request; diff --git a/libs/network/test/http/response_test.cpp b/libs/network/test/http/response_test.cpp index d80cbbbc2..bd2c176a6 100644 --- a/libs/network/test/http/response_test.cpp +++ b/libs/network/test/http/response_test.cpp @@ -8,7 +8,7 @@ #include #include -namespace http = boost::network::http; +namespace http = network::http; BOOST_AUTO_TEST_CASE(response_constructor_test) { http::response created; diff --git a/libs/network/test/http/server_async_run_stop_concurrency.cpp b/libs/network/test/http/server_async_run_stop_concurrency.cpp index 918703b5d..d602ad94d 100644 --- a/libs/network/test/http/server_async_run_stop_concurrency.cpp +++ b/libs/network/test/http/server_async_run_stop_concurrency.cpp @@ -4,8 +4,8 @@ #include #include -namespace http = boost::network::http; -namespace util = boost::network::utils; +namespace http = network::http; +namespace util = network::utils; struct dummy_async_handler; typedef http::async_server async_server; @@ -34,7 +34,7 @@ int main(int argc, char * argv[]) { // stop from main thread { - BOOST_NETWORK_MESSAGE("TEST: stop without running"); + NETWORK_MESSAGE("TEST: stop without running"); util::thread_pool pool; async_server server_instance(ASYNC_SERVER_TEST_CONFIG); server_instance.stop(); @@ -42,7 +42,7 @@ int main(int argc, char * argv[]) { // run-stop from main thread { - BOOST_NETWORK_MESSAGE("TEST: stop from main thread"); + NETWORK_MESSAGE("TEST: stop from main thread"); util::thread_pool pool; async_server server_instance(ASYNC_SERVER_TEST_CONFIG); @@ -55,7 +55,7 @@ int main(int argc, char * argv[]) { // run-stop from another thread { - BOOST_NETWORK_MESSAGE("TEST: stop from another thread"); + NETWORK_MESSAGE("TEST: stop from another thread"); util::thread_pool pool; async_server server_instance(ASYNC_SERVER_TEST_CONFIG); @@ -71,7 +71,7 @@ int main(int argc, char * argv[]) { // run-stop-run-stop from another thread { - BOOST_NETWORK_MESSAGE("TEST: run-stop-run-stop from another thread"); + NETWORK_MESSAGE("TEST: run-stop-run-stop from another thread"); util::thread_pool pool; async_server server_instance(ASYNC_SERVER_TEST_CONFIG); @@ -95,7 +95,7 @@ int main(int argc, char * argv[]) { // run-run-stop from another thread { - BOOST_NETWORK_MESSAGE("TEST: run-run-stop from another thread"); + NETWORK_MESSAGE("TEST: run-run-stop from another thread"); util::thread_pool pool; async_server server_instance(ASYNC_SERVER_TEST_CONFIG); @@ -115,7 +115,7 @@ int main(int argc, char * argv[]) { // run-stop-stop from another thread { - BOOST_NETWORK_MESSAGE("TEST: run-stop-stop from another thread"); + NETWORK_MESSAGE("TEST: run-stop-stop from another thread"); util::thread_pool pool; async_server server_instance(ASYNC_SERVER_TEST_CONFIG); diff --git a/libs/network/test/http/server_constructor_test.cpp b/libs/network/test/http/server_constructor_test.cpp index 179f98698..a45179ba5 100644 --- a/libs/network/test/http/server_constructor_test.cpp +++ b/libs/network/test/http/server_constructor_test.cpp @@ -10,8 +10,8 @@ #include #include -namespace http = boost::network::http; -namespace util = boost::network::utils; +namespace http = network::http; +namespace util = network::utils; struct dummy_sync_handler; struct dummy_async_handler; diff --git a/libs/network/test/message_test.cpp b/libs/network/test/message_test.cpp index 7114dcb7e..3ec45e1d4 100644 --- a/libs/network/test/message_test.cpp +++ b/libs/network/test/message_test.cpp @@ -11,7 +11,7 @@ #include #include -using namespace boost::network; +using namespace network; /** * Defines a set of template functions that can be used to test @@ -50,14 +50,14 @@ BOOST_AUTO_TEST_CASE(headers_directive_test) { BOOST_AUTO_TEST_CASE(body_directive_test) { message instance; - instance << ::boost::network::body("body"); + instance << ::network::body("body"); std::string body_string = body(instance); BOOST_CHECK ( body_string == "body" ); } BOOST_AUTO_TEST_CASE(source_directive_test) { message instance; - instance << ::boost::network::source("source"); + instance << ::network::source("source"); std::string source_string = source(instance); BOOST_CHECK ( source_string == "source" ); } diff --git a/libs/network/test/message_transform_test.cpp b/libs/network/test/message_transform_test.cpp index a70341aec..3a5d21e71 100644 --- a/libs/network/test/message_transform_test.cpp +++ b/libs/network/test/message_transform_test.cpp @@ -12,7 +12,7 @@ #include BOOST_AUTO_TEST_CASE ( message_transform_toupper ) { - using namespace boost::network; + using namespace network; message msg; msg << source("me"); @@ -30,7 +30,7 @@ BOOST_AUTO_TEST_CASE ( message_transform_toupper ) { } BOOST_AUTO_TEST_CASE ( message_transform_tolower ) { - using namespace boost::network; + using namespace network; message msg; msg << source("ME"); diff --git a/libs/network/test/utils_thread_pool.cpp b/libs/network/test/utils_thread_pool.cpp index ca7fc11cd..7bbb75ef5 100644 --- a/libs/network/test/utils_thread_pool.cpp +++ b/libs/network/test/utils_thread_pool.cpp @@ -11,7 +11,7 @@ #include #include -using namespace boost::network; +using namespace network; // This test specifies the requirements for a thread pool interface. At the // very least any thread pool implementation should be able to pass the simple From 579adb8da17c7e7305da105ec9f2119a09e28956 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Fri, 28 Sep 2012 22:25:28 +1000 Subject: [PATCH 117/196] Build Green! Now we're at a state where: - We live in namespace network:: - We rely on Boost mostly - We have dropped the BOOST_ prefix for macros --- CMakeLists.txt | 4 ++-- .../http/client/connection/connection_factory.hpp | 6 +++--- include/network/protocol/http/impl/parser.ipp | 6 +++--- .../protocol/http/message/directives/minor_version.hpp | 6 +++--- include/network/protocol/http/message/wrappers/port.hpp | 6 +++--- include/network/protocol/http/message/wrappers/port.ipp | 6 +++--- include/network/protocol/http/request/request.ipp | 2 +- include/network/protocol/http/server/options.ipp | 6 +++--- include/network/protocol/http/support/is_client.hpp | 6 +++--- libs/network/src/client.cpp | 8 ++++---- libs/network/src/constants.cpp | 4 ++-- libs/network/src/http/client.cpp | 4 ++-- libs/network/src/http/client_async_resolver.cpp | 4 ++-- libs/network/src/http/client_connection_delegates.cpp | 6 +++--- libs/network/src/http/client_connection_factory.cpp | 4 ++-- libs/network/src/http/client_connection_normal.cpp | 4 ++-- libs/network/src/http/client_connections.cpp | 4 ++-- libs/network/src/http/client_resolver_delegate.cpp | 4 ++-- .../network/src/http/client_resolver_delegate_factory.cpp | 4 ++-- libs/network/src/http/connection_delegate_factory.cpp | 4 ++-- libs/network/src/http/request.cpp | 4 ++-- libs/network/src/http/response.cpp | 4 ++-- libs/network/src/http/simple_connection_factory.cpp | 4 ++-- libs/network/src/http/simple_connection_manager.cpp | 4 ++-- libs/network/src/message/directives.cpp | 4 ++-- libs/network/src/message/message.cpp | 4 ++-- libs/network/src/server_request_parsers_impl.cpp | 4 ++-- libs/network/test/http/client_get_test.cpp | 2 +- libs/network/test/http/client_include_inlined.cpp | 2 +- libs/network/test/http/server_include_inlined.cpp | 2 +- 30 files changed, 66 insertions(+), 66 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c956cc36..0e68c457b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,11 +14,11 @@ find_package( Threads ) set(CMAKE_VERBOSE_MAKEFILE true) if (CMAKE_BUILD_TYPE MATCHES Debug) - add_definitions(-DBOOST_NETWORK_DEBUG) + add_definitions(-DNETWORK_DEBUG) endif() if (OPENSSL_FOUND) - add_definitions(-DBOOST_NETWORK_ENABLE_HTTPS) + add_definitions(-DNETWORK_ENABLE_HTTPS) endif() if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) diff --git a/include/network/protocol/http/client/connection/connection_factory.hpp b/include/network/protocol/http/client/connection/connection_factory.hpp index e323b8372..660df9a77 100644 --- a/include/network/protocol/http/client/connection/connection_factory.hpp +++ b/include/network/protocol/http/client/connection/connection_factory.hpp @@ -4,8 +4,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_FACTORY_HPP_20111112 -#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_FACTORY_HPP_20111112 +#ifndef NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_FACTORY_HPP_20111112 +#define NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_FACTORY_HPP_20111112 #include @@ -34,4 +34,4 @@ struct connection_factory { } // namespace http } // namespace network -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_FACTORY_HPP_20111112 */ +#endif /* NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_FACTORY_HPP_20111112 */ diff --git a/include/network/protocol/http/impl/parser.ipp b/include/network/protocol/http/impl/parser.ipp index d79db56aa..462fffc49 100644 --- a/include/network/protocol/http/impl/parser.ipp +++ b/include/network/protocol/http/impl/parser.ipp @@ -8,8 +8,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_PARSER_IPP -#define BOOST_NETWORK_PROTOCOL_HTTP_PARSER_IPP +#ifndef NETWORK_PROTOCOL_HTTP_PARSER_IPP +#define NETWORK_PROTOCOL_HTTP_PARSER_IPP #include @@ -777,4 +777,4 @@ static bool basic_parser::parse_cookie_header(types::cookie_params& } // namespace http } // namespace network -#endif // BOOST_NETWORK_PROTOCOL_HTTP_PARSER_IPP +#endif // NETWORK_PROTOCOL_HTTP_PARSER_IPP diff --git a/include/network/protocol/http/message/directives/minor_version.hpp b/include/network/protocol/http/message/directives/minor_version.hpp index 90c2c48e3..ac872461f 100644 --- a/include/network/protocol/http/message/directives/minor_version.hpp +++ b/include/network/protocol/http/message/directives/minor_version.hpp @@ -4,8 +4,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_MINOR_VERSION_HPP_20101120 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_MINOR_VERSION_HPP_20101120 +#ifndef NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_MINOR_VERSION_HPP_20101120 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_MINOR_VERSION_HPP_20101120 #include #include @@ -35,5 +35,5 @@ minor_version(boost::uint8_t minor_version_) { } // namespace http } // namespace network -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_MINOR_VERSION_HPP_20101120 */ +#endif /* NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_MINOR_VERSION_HPP_20101120 */ diff --git a/include/network/protocol/http/message/wrappers/port.hpp b/include/network/protocol/http/message/wrappers/port.hpp index 5697551bb..b6bce41bb 100644 --- a/include/network/protocol/http/message/wrappers/port.hpp +++ b/include/network/protocol/http/message/wrappers/port.hpp @@ -5,8 +5,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_PORT_HPP_20100618 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_PORT_HPP_20100618 +#ifndef NETWORK_PROTOCOL_HTTP_MESSAGE_PORT_HPP_20100618 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_PORT_HPP_20100618 #include #include @@ -29,4 +29,4 @@ port(request_base const & request) { } // namespace http } // namespace network -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_PORT_HPP_20100618 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_PORT_HPP_20100618 diff --git a/include/network/protocol/http/message/wrappers/port.ipp b/include/network/protocol/http/message/wrappers/port.ipp index c2962be7b..0598763d2 100644 --- a/include/network/protocol/http/message/wrappers/port.ipp +++ b/include/network/protocol/http/message/wrappers/port.ipp @@ -4,8 +4,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PORT_IPP_20111204 -#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PORT_IPP_20111204 +#ifndef NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PORT_IPP_20111204 +#define NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PORT_IPP_20111204 #include #include @@ -40,4 +40,4 @@ port_wrapper::operator boost::optional () const { } // namespace http } // namespace network -#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PORT_IPP_20111204 +#endif // NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PORT_IPP_20111204 diff --git a/include/network/protocol/http/request/request.ipp b/include/network/protocol/http/request/request.ipp index 639db3624..5cf5a558a 100644 --- a/include/network/protocol/http/request/request.ipp +++ b/include/network/protocol/http/request/request.ipp @@ -12,7 +12,7 @@ #include #ifdef NETWORK_DEBUG -BOOST_CONCEPT_ASSERT((boost::network::http::ClientRequest)); +BOOST_CONCEPT_ASSERT((network::http::ClientRequest)); #endif namespace network { namespace http { diff --git a/include/network/protocol/http/server/options.ipp b/include/network/protocol/http/server/options.ipp index 90c290f44..bccba3983 100644 --- a/include/network/protocol/http/server/options.ipp +++ b/include/network/protocol/http/server/options.ipp @@ -4,8 +4,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_IPP_20120318 -#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_IPP_20120318 +#ifndef NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_IPP_20120318 +#define NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_IPP_20120318 #include #include @@ -287,4 +287,4 @@ int server_options::linger_timeout() const { } // namespace network -#endif // BOOST_NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_IPP_20120318 +#endif // NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_IPP_20120318 diff --git a/include/network/protocol/http/support/is_client.hpp b/include/network/protocol/http/support/is_client.hpp index 003dfc946..d31f147b1 100644 --- a/include/network/protocol/http/support/is_client.hpp +++ b/include/network/protocol/http/support/is_client.hpp @@ -4,8 +4,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_NETWORK_PROTOCOL_SUPPORT_IS_CLIENT_HPP_20101118 -#define BOOST_NETWORK_PROTOCOL_SUPPORT_IS_CLIENT_HPP_20101118 +#ifndef NETWORK_PROTOCOL_SUPPORT_IS_CLIENT_HPP_20101118 +#define NETWORK_PROTOCOL_SUPPORT_IS_CLIENT_HPP_20101118 #include @@ -20,5 +20,5 @@ namespace network { namespace http { } // namespace http } // namespace network -#endif /* BOOST_NETWORK_PROTOCOL_SUPPORT_IS_CLIENT_HPP_20101118 */ +#endif /* NETWORK_PROTOCOL_SUPPORT_IS_CLIENT_HPP_20101118 */ diff --git a/libs/network/src/client.cpp b/libs/network/src/client.cpp index c85c3e368..2616a1da6 100644 --- a/libs/network/src/client.cpp +++ b/libs/network/src/client.cpp @@ -5,13 +5,13 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifdef BOOST_NETWORK_NO_LIB -#warn Building the library even with BOOST_NETWORK_NO_LIB defined. -#undef BOOST_NETWORK_NO_LIB +#ifdef NETWORK_NO_LIB +#warn Building the library even with NETWORK_NO_LIB defined. +#undef NETWORK_NO_LIB #endif #include -#ifdef BOOST_NETWORK_ENABLE_HTTPS +#ifdef NETWORK_ENABLE_HTTPS #include #endif diff --git a/libs/network/src/constants.cpp b/libs/network/src/constants.cpp index 810500b23..54a3642f4 100644 --- a/libs/network/src/constants.cpp +++ b/libs/network/src/constants.cpp @@ -4,8 +4,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifdef BOOST_NETWORK_NO_LIB -#undef BOOST_NETWORK_NO_LIB +#ifdef NETWORK_NO_LIB +#undef NETWORK_NO_LIB #endif #include diff --git a/libs/network/src/http/client.cpp b/libs/network/src/http/client.cpp index 50fc0e5d1..5773e8733 100644 --- a/libs/network/src/http/client.cpp +++ b/libs/network/src/http/client.cpp @@ -4,8 +4,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifdef BOOST_NETWORK_NO_LIB -#undef BOOST_NETWORK_NO_LIB +#ifdef NETWORK_NO_LIB +#undef NETWORK_NO_LIB #endif #include diff --git a/libs/network/src/http/client_async_resolver.cpp b/libs/network/src/http/client_async_resolver.cpp index f0597f00c..48b47bf14 100644 --- a/libs/network/src/http/client_async_resolver.cpp +++ b/libs/network/src/http/client_async_resolver.cpp @@ -4,8 +4,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifdef BOOST_NETWORK_NO_LIB -#undef BOOST_NETWORK_NO_LIB +#ifdef NETWORK_NO_LIB +#undef NETWORK_NO_LIB #endif #include diff --git a/libs/network/src/http/client_connection_delegates.cpp b/libs/network/src/http/client_connection_delegates.cpp index 3ef3f6c0a..337c6307f 100644 --- a/libs/network/src/http/client_connection_delegates.cpp +++ b/libs/network/src/http/client_connection_delegates.cpp @@ -4,11 +4,11 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifdef BOOST_NETWORK_NO_LIB -#undef BOOST_NETWORK_NO_LIB +#ifdef NETWORK_NO_LIB +#undef NETWORK_NO_LIB #endif #include -#ifdef BOOST_NETWORK_ENABLE_HTTPS +#ifdef NETWORK_ENABLE_HTTPS #include #endif diff --git a/libs/network/src/http/client_connection_factory.cpp b/libs/network/src/http/client_connection_factory.cpp index 6bfa0e88c..cdab4271b 100644 --- a/libs/network/src/http/client_connection_factory.cpp +++ b/libs/network/src/http/client_connection_factory.cpp @@ -4,8 +4,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifdef BOOST_NETWORK_NO_LIB -#undef BOOST_NETWORK_NO_LIB +#ifdef NETWORK_NO_LIB +#undef NETWORK_NO_LIB #endif #include diff --git a/libs/network/src/http/client_connection_normal.cpp b/libs/network/src/http/client_connection_normal.cpp index 42caed650..c576528a3 100644 --- a/libs/network/src/http/client_connection_normal.cpp +++ b/libs/network/src/http/client_connection_normal.cpp @@ -4,8 +4,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifdef BOOST_NETWORK_NO_LIB -#undef BOOST_NETWORK_NO_LIB +#ifdef NETWORK_NO_LIB +#undef NETWORK_NO_LIB #endif #include diff --git a/libs/network/src/http/client_connections.cpp b/libs/network/src/http/client_connections.cpp index 416222fa2..5060504d7 100644 --- a/libs/network/src/http/client_connections.cpp +++ b/libs/network/src/http/client_connections.cpp @@ -4,8 +4,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifdef BOOST_NETWORK_NO_LIB -#undef BOOST_NETWORK_NO_LIB +#ifdef NETWORK_NO_LIB +#undef NETWORK_NO_LIB #endif #include diff --git a/libs/network/src/http/client_resolver_delegate.cpp b/libs/network/src/http/client_resolver_delegate.cpp index 97ba5d48b..7c942e59f 100644 --- a/libs/network/src/http/client_resolver_delegate.cpp +++ b/libs/network/src/http/client_resolver_delegate.cpp @@ -4,8 +4,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifdef BOOST_NETWORK_NO_LIB -#undef BOOST_NETWORK_NO_LIB +#ifdef NETWORK_NO_LIB +#undef NETWORK_NO_LIB #endif #include diff --git a/libs/network/src/http/client_resolver_delegate_factory.cpp b/libs/network/src/http/client_resolver_delegate_factory.cpp index fed466bc3..cc6b58ea0 100644 --- a/libs/network/src/http/client_resolver_delegate_factory.cpp +++ b/libs/network/src/http/client_resolver_delegate_factory.cpp @@ -4,8 +4,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifdef BOOST_NETWORK_NO_LIB -#undef BOOST_NETWORK_NO_LIB +#ifdef NETWORK_NO_LIB +#undef NETWORK_NO_LIB #endif #include diff --git a/libs/network/src/http/connection_delegate_factory.cpp b/libs/network/src/http/connection_delegate_factory.cpp index 27ec21611..20a81a235 100644 --- a/libs/network/src/http/connection_delegate_factory.cpp +++ b/libs/network/src/http/connection_delegate_factory.cpp @@ -4,8 +4,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifdef BOOST_NETWORK_NO_LIB -#undef BOOST_NETWORK_NO_LIB +#ifdef NETWORK_NO_LIB +#undef NETWORK_NO_LIB #endif #include diff --git a/libs/network/src/http/request.cpp b/libs/network/src/http/request.cpp index 72321e4a2..f458eb415 100644 --- a/libs/network/src/http/request.cpp +++ b/libs/network/src/http/request.cpp @@ -4,8 +4,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifdef BOOST_NETWORK_NO_LIB -#undef BOOST_NETWORK_NO_LIB +#ifdef NETWORK_NO_LIB +#undef NETWORK_NO_LIB #endif #include diff --git a/libs/network/src/http/response.cpp b/libs/network/src/http/response.cpp index 4b1c4cf8f..f6c0d65d6 100644 --- a/libs/network/src/http/response.cpp +++ b/libs/network/src/http/response.cpp @@ -4,8 +4,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifdef BOOST_NETWORK_NO_LIB -#undef BOOST_NETWORK_NO_LIB +#ifdef NETWORK_NO_LIB +#undef NETWORK_NO_LIB #endif #include diff --git a/libs/network/src/http/simple_connection_factory.cpp b/libs/network/src/http/simple_connection_factory.cpp index f9720c59e..58cad8222 100644 --- a/libs/network/src/http/simple_connection_factory.cpp +++ b/libs/network/src/http/simple_connection_factory.cpp @@ -4,8 +4,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifdef BOOST_NETWORK_NO_LIB -#undef BOOST_NETWORK_NO_LIB +#ifdef NETWORK_NO_LIB +#undef NETWORK_NO_LIB #endif #include diff --git a/libs/network/src/http/simple_connection_manager.cpp b/libs/network/src/http/simple_connection_manager.cpp index d2246cf64..ac74804b0 100644 --- a/libs/network/src/http/simple_connection_manager.cpp +++ b/libs/network/src/http/simple_connection_manager.cpp @@ -4,8 +4,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifdef BOOST_NETWORK_NO_LIB -#undef BOOST_NETWORK_NO_LIB +#ifdef NETWORK_NO_LIB +#undef NETWORK_NO_LIB #endif #include diff --git a/libs/network/src/message/directives.cpp b/libs/network/src/message/directives.cpp index 9cc85fe6f..d2c9400ca 100644 --- a/libs/network/src/message/directives.cpp +++ b/libs/network/src/message/directives.cpp @@ -7,8 +7,8 @@ // This is the directives file where all standard directives on messages are // pulled in and compiled into a library. -#ifdef BOOST_NETWORK_NO_LIB -#undef BOOST_NETWORK_NO_LIB +#ifdef NETWORK_NO_LIB +#undef NETWORK_NO_LIB #endif #include diff --git a/libs/network/src/message/message.cpp b/libs/network/src/message/message.cpp index 232a788e8..9e9058baf 100644 --- a/libs/network/src/message/message.cpp +++ b/libs/network/src/message/message.cpp @@ -7,8 +7,8 @@ // This is the conglomeration of all message-related implementation files. All // we're doing is including all the .ipp files that are relevant. -#ifdef BOOST_NETWORK_NO_LIB -#undef BOOST_NETWORK_NO_LIB +#ifdef NETWORK_NO_LIB +#undef NETWORK_NO_LIB #endif #include diff --git a/libs/network/src/server_request_parsers_impl.cpp b/libs/network/src/server_request_parsers_impl.cpp index 061b5b838..b694aea6e 100644 --- a/libs/network/src/server_request_parsers_impl.cpp +++ b/libs/network/src/server_request_parsers_impl.cpp @@ -4,8 +4,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifdef BOOST_NETWORK_NO_LIB -#undef BOOST_NETWORK_NO_LIB +#ifdef NETWORK_NO_LIB +#undef NETWORK_NO_LIB #endif #include diff --git a/libs/network/test/http/client_get_test.cpp b/libs/network/test/http/client_get_test.cpp index e16ec3089..7a95019fb 100644 --- a/libs/network/test/http/client_get_test.cpp +++ b/libs/network/test/http/client_get_test.cpp @@ -30,7 +30,7 @@ BOOST_AUTO_TEST_CASE(http_client_get_test) { BOOST_CHECK_EQUAL ( status_message_, std::string("Found") ); } -#ifdef BOOST_NETWORK_ENABLE_HTTPS +#ifdef NETWORK_ENABLE_HTTPS BOOST_AUTO_TEST_CASE(https_client_get_test) { http::client::request request("https://www.google.com/"); diff --git a/libs/network/test/http/client_include_inlined.cpp b/libs/network/test/http/client_include_inlined.cpp index cb0c0a20d..f7f1d4def 100644 --- a/libs/network/test/http/client_include_inlined.cpp +++ b/libs/network/test/http/client_include_inlined.cpp @@ -4,7 +4,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#define BOOST_NETWORK_NO_LIB +#define NETWORK_NO_LIB #include int main(int argc, char * argv[]) { diff --git a/libs/network/test/http/server_include_inlined.cpp b/libs/network/test/http/server_include_inlined.cpp index e27802fcd..6eef71412 100644 --- a/libs/network/test/http/server_include_inlined.cpp +++ b/libs/network/test/http/server_include_inlined.cpp @@ -8,7 +8,7 @@ #include #include -#define BOOST_NETWORK_NO_LIB +#define NETWORK_NO_LIB #include #include #include From 463a0ea8b75a50ba29a9dbecdeb3c1ab0fa836b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AF=D0=BD=D0=B8=D1=87=D0=BA=D0=B8=D0=BD=20=D0=90=D0=BB?= =?UTF-8?q?=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80?= Date: Tue, 2 Oct 2012 15:52:39 +0600 Subject: [PATCH 118/196] Fix missing const qualifier in function source() --- include/network/message/wrappers/source.hpp | 6 +++--- include/network/message/wrappers/source.ipp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/network/message/wrappers/source.hpp b/include/network/message/wrappers/source.hpp index 4a3feb698..7f26b61ba 100644 --- a/include/network/message/wrappers/source.hpp +++ b/include/network/message/wrappers/source.hpp @@ -12,15 +12,15 @@ namespace network { struct source_wrapper { - explicit source_wrapper(message_base & message); + explicit source_wrapper(message_base const & message); operator std::string () const; private: - message_base & message_; + message_base const & message_; mutable boost::optional cache_; }; inline source_wrapper const -source(message_base & message_) { +source(message_base const & message_) { return source_wrapper(message_); } diff --git a/include/network/message/wrappers/source.ipp b/include/network/message/wrappers/source.ipp index 1e85695b7..f32c0e507 100644 --- a/include/network/message/wrappers/source.ipp +++ b/include/network/message/wrappers/source.ipp @@ -11,7 +11,7 @@ namespace network { -source_wrapper::source_wrapper(message_base & message): +source_wrapper::source_wrapper(message_base const & message): message_(message) {} source_wrapper::operator std::string () const { From cc6d3767d7f21cc1701a497d0ae9cfba90cf3aab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AF=D0=BD=D0=B8=D1=87=D0=BA=D0=B8=D0=BD=20=D0=90=D0=BB?= =?UTF-8?q?=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80?= Date: Wed, 3 Oct 2012 10:38:49 +0600 Subject: [PATCH 119/196] Fix missing const qualifier in return value of functions name(const pair&) and value(const pair&) --- include/network/protocol/http/message/header/name.hpp | 2 +- include/network/protocol/http/message/header/value.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/network/protocol/http/message/header/name.hpp b/include/network/protocol/http/message/header/name.hpp index 4676608cd..bab4c2653 100644 --- a/include/network/protocol/http/message/header/name.hpp +++ b/include/network/protocol/http/message/header/name.hpp @@ -14,7 +14,7 @@ namespace network { namespace http { template -T1 & +inline T1 const & name(std::pair const & p) { return p.first; } diff --git a/include/network/protocol/http/message/header/value.hpp b/include/network/protocol/http/message/header/value.hpp index 96feabab6..1112a2430 100644 --- a/include/network/protocol/http/message/header/value.hpp +++ b/include/network/protocol/http/message/header/value.hpp @@ -16,7 +16,7 @@ struct request_header; struct response_header; template -T1 & value(std::pair const & p) { +inline T1 const & value(std::pair const & p) { return p.second; } From 9a52e173943fa5d003031a9761ecb1edadb49c1a Mon Sep 17 00:00:00 2001 From: Mikhail Kulinich Date: Sun, 7 Oct 2012 23:15:44 +0400 Subject: [PATCH 120/196] Make it possible to build cpp-netlib using Boost.Build. - Include '*~' pattern into .gitignore - Build libraries in accordance with CMake script - Build tests in accordance with CMake script --- .gitignore | 1 + Jamroot | 2 +- libs/network/build/Jamfile.v2 | 68 ++++++++++++--- libs/network/test/Jamfile.v2 | 25 +++--- libs/network/test/http/Jamfile.v2 | 139 ++++++++++++++++++++++++------ libs/network/test/uri/Jamfile.v2 | 10 ++- 6 files changed, 196 insertions(+), 49 deletions(-) diff --git a/.gitignore b/.gitignore index 833df9eea..127d9be8e 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ libs/mime/test/mime-roundtrip bin/ tests/ _build +*~ diff --git a/Jamroot b/Jamroot index 965e8d30e..ce0ebf032 100644 --- a/Jamroot +++ b/Jamroot @@ -6,7 +6,7 @@ import os ; -local BOOST_ROOT = [ os.environ BOOST_ROOT ] ; +path-constant BOOST_ROOT : [ os.environ BOOST_ROOT ] ; use-project /boost : $(BOOST_ROOT) ; use-project /cpp-netlib : libs/network/build ; diff --git a/libs/network/build/Jamfile.v2 b/libs/network/build/Jamfile.v2 index 2d1a33b89..9ccd706e4 100644 --- a/libs/network/build/Jamfile.v2 +++ b/libs/network/build/Jamfile.v2 @@ -4,27 +4,75 @@ # (See accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) -import os ; - -local BOOST_ROOT = [ os.environ BOOST_ROOT ] ; +import pch ; project cpp-netlib : requirements - ../../../ + debug:NETWORK_DEBUG + gcc:NETWORK_ENABLE_HTTPS + gcc:-std=c++0x + ../../../include $(BOOST_ROOT) 256 + static : source-location ../../../ ; -cpp-pch client : boost/network/include/http/client.hpp ; -cpp-pch server : boost/network/include/http/server.hpp ; -lib cppnetlib-uri : libs/network/src/uri/parse.cpp ; -lib cppnetlib-server-parsers : libs/network/src/server_request_parsers_impl.cpp ; -lib cppnetlib-client-connections : libs/network/src/client.cpp ; +cpp-pch client : include/network/include/http/client.hpp ; +cpp-pch server : include/network/include/http/server.hpp ; +lib cppnetlib-uri : libs/network/src/uri/normalize.cpp + libs/network/src/uri/schemes.cpp + libs/network/src/uri/uri.cpp ; + +lib cppnetlib-message : libs/network/src/message/message.cpp cppnetlib-uri ; +lib cppnetlib-message-directives : libs/network/src/message/directives.cpp ; +lib cppnetlib-message-wrappers : libs/network/src/message/wrappers.cpp ; +lib cppnetlib-http-message : libs/network/src/http/request.cpp + libs/network/src/http/response.cpp + cppnetlib-message ; + +lib cppnetlib-http-message-wrappers : libs/network/src/http/message/wrappers.cpp ; +lib cppnetlib-http-server-parsers : libs/network/src/server_request_parsers_impl.cpp ; +lib cppnetlib-http-server : libs/network/src/http/server_async_impl.cpp + libs/network/src/http/server_options.cpp + libs/network/src/http/server_socket_options_setter.cpp + libs/network/src/http/server_sync_impl.cpp + cppnetlib-constants + cppnetlib-uri + cppnetlib-message + cppnetlib-message-wrappers + cppnetlib-message-directives + cppnetlib-http-message + cppnetlib-http-message-wrappers + cppnetlib-http-server-parsers ; + +lib cppnetlib-http-client-connections : libs/network/src/http/client_connections.cpp + libs/network/src/http/simple_connection_manager.cpp + libs/network/src/http/simple_connection_factory.cpp + libs/network/src/http/connection_delegate_factory.cpp + libs/network/src/http/client_resolver_delegate.cpp + libs/network/src/http/client_resolver_delegate_factory.cpp + libs/network/src/http/client_connection_delegates.cpp + libs/network/src/http/client_connection_factory.cpp + libs/network/src/http/client_async_resolver.cpp + libs/network/src/http/client_connection_normal.cpp ; + +lib cppnetlib-http-client : libs/network/src/http/client.cpp + cppnetlib-constants + cppnetlib-uri + cppnetlib-message + cppnetlib-message-wrappers + cppnetlib-message-directives + cppnetlib-http-message + cppnetlib-http-message-wrappers + cppnetlib-http-client-connections ; + +lib cppnetlib-utils-thread_pool : libs/network/src/utils/thread_pool.cpp ; +lib cppnetlib-constants : libs/network/src/constants.cpp ; install headers : client server : ../../../boost/network/include/http ; -install libraries : cppnetlib-uri cppnetlib-server-parsers cppnetlib-client-connections ; +install libraries : cppnetlib-uri ; alias all : headers ; diff --git a/libs/network/test/Jamfile.v2 b/libs/network/test/Jamfile.v2 index 3375ac148..5e4ec206e 100644 --- a/libs/network/test/Jamfile.v2 +++ b/libs/network/test/Jamfile.v2 @@ -1,4 +1,4 @@ - + # Copyright Dean Michael Berris 2007. # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or copy at @@ -15,24 +15,23 @@ if [ os.name ] = CYGWIN project network_test : requirements - ../../../ - . + ../../../include /boost//unit_test_framework /boost//system /boost//date_time /boost//regex /boost//thread /boost//filesystem - debug:BOOST_NETWORK_DEBUG - gcc:BOOST_NETWORK_ENABLE_HTTPS + debug:NETWORK_DEBUG + gcc:NETWORK_ENABLE_HTTPS gcc:-lpthread gcc:-lssl gcc:-lcrypto - darwin:BOOST_NETWORK_ENABLE_HTTPS + darwin:NETWORK_ENABLE_HTTPS darwin:-lpthread darwin:-lssl darwin:-lcrypto - clang:BOOST_NETWORK_ENABLE_HTTPS + clang:NETWORK_ENABLE_HTTPS clang:-lpthread clang:-lssl clang:-lcrypto @@ -43,7 +42,7 @@ project network_test : msvc:BOOST_ASIO_NO_WIN32_LEAN_AND_MEAN msvc:WIN32_LEAN_AND_MEAN msvc:_SCL_SECURE_NO_WARNINGS - msvc:_WIN32_WINNT=0x0501 + msvc:_WIN32_WINNT=0x0501 256 static ; @@ -51,5 +50,11 @@ project network_test : build-project http ; build-project uri ; -run message_test.cpp ; -run message_transform_test.cpp ; +run message_test.cpp /cpp-netlib//cppnetlib-message + /cpp-netlib//cppnetlib-message-directives + /cpp-netlib//cppnetlib-message-wrappers ; + +run message_transform_test.cpp /cpp-netlib//cppnetlib-message + /cpp-netlib//cppnetlib-message-directives + /cpp-netlib//cppnetlib-message-wrappers ; + diff --git a/libs/network/test/http/Jamfile.v2 b/libs/network/test/http/Jamfile.v2 index 9f587c50b..c299afce5 100644 --- a/libs/network/test/http/Jamfile.v2 +++ b/libs/network/test/http/Jamfile.v2 @@ -10,35 +10,125 @@ import feature ; project network_test/http : requirements - ../../../../ - ../ - debug:BOOST_NETWORK_DEBUG + debug:NETWORK_DEBUG + gcc:-std=c++0x ; -run client_constructor_test.cpp /cpp-netlib//cppnetlib-uri /cpp-netlib//cppnetlib-client-connections ; -run client_get_test.cpp /cpp-netlib//cppnetlib-uri /cpp-netlib//cppnetlib-client-connections ; -run client_get_different_port_test.cpp /cpp-netlib//cppnetlib-uri /cpp-netlib//cppnetlib-client-connections ; -run client_get_timeout_test.cpp /cpp-netlib//cppnetlib-uri /cpp-netlib//cppnetlib-client-connections ; -#run client_include_inlined.cpp : BOOST_NETWORK_NO_LIB ; -run client_localhost_normal_test.cpp /cpp-netlib//cppnetlib-uri /cpp-netlib//cppnetlib-client-connections ; -run client_localhost_ssl_test.cpp /cpp-netlib//cppnetlib-uri /cpp-netlib//cppnetlib-client-connections ; -run message_async_ready_test.cpp ; -run message_test.cpp /cpp-netlib//cppnetlib-uri ; -run request_incremental_parser_test.cpp ; -run request_linearize_test.cpp /cpp-netlib//cppnetlib-uri ; -run response_incremental_parser_test.cpp /cpp-netlib//cppnetlib-server-parsers ; -run server_constructor_test.cpp /cpp-netlib//cppnetlib-server-parsers ; +run request_base_test.cpp /cpp-netlib//cppnetlib-message + /cpp-netlib//cppnetlib-message-wrappers + /cpp-netlib//cppnetlib-http-message + /cpp-netlib//cppnetlib-http-message-wrappers + /cpp-netlib//cppnetlib-uri + /cpp-netlib//cppnetlib-constants ; + +run request_test.cpp /cpp-netlib//cppnetlib-message + /cpp-netlib//cppnetlib-message-wrappers + /cpp-netlib//cppnetlib-http-message + /cpp-netlib//cppnetlib-http-message-wrappers + /cpp-netlib//cppnetlib-uri + /cpp-netlib//cppnetlib-constants ; + +run request_linearize_test.cpp /cpp-netlib//cppnetlib-message + /cpp-netlib//cppnetlib-message-wrappers + /cpp-netlib//cppnetlib-http-message + /cpp-netlib//cppnetlib-http-message-wrappers + /cpp-netlib//cppnetlib-uri + /cpp-netlib//cppnetlib-constants ; + +run response_test.cpp /cpp-netlib//cppnetlib-message + /cpp-netlib//cppnetlib-message-wrappers + /cpp-netlib//cppnetlib-http-message + /cpp-netlib//cppnetlib-http-message-wrappers + /cpp-netlib//cppnetlib-uri + /cpp-netlib//cppnetlib-constants ; + +run client_constructor_test.cpp /cpp-netlib//cppnetlib-constants + /cpp-netlib//cppnetlib-uri + /cpp-netlib//cppnetlib-message + /cpp-netlib//cppnetlib-message-wrappers + /cpp-netlib//cppnetlib-message-directives + /cpp-netlib//cppnetlib-http-message + /cpp-netlib//cppnetlib-http-message-wrappers + /cpp-netlib//cppnetlib-http-client + /cpp-netlib//cppnetlib-http-client-connections ; + +run client_get_test.cpp /cpp-netlib//cppnetlib-constants + /cpp-netlib//cppnetlib-uri + /cpp-netlib//cppnetlib-message + /cpp-netlib//cppnetlib-message-wrappers + /cpp-netlib//cppnetlib-message-directives + /cpp-netlib//cppnetlib-http-message + /cpp-netlib//cppnetlib-http-message-wrappers + /cpp-netlib//cppnetlib-http-client + /cpp-netlib//cppnetlib-http-client-connections ; + +run client_get_different_port_test.cpp /cpp-netlib//cppnetlib-constants + /cpp-netlib//cppnetlib-uri + /cpp-netlib//cppnetlib-message + /cpp-netlib//cppnetlib-message-wrappers + /cpp-netlib//cppnetlib-message-directives + /cpp-netlib//cppnetlib-http-message + /cpp-netlib//cppnetlib-http-message-wrappers + /cpp-netlib//cppnetlib-http-client + /cpp-netlib//cppnetlib-http-client-connections ; + +run client_get_timeout_test.cpp /cpp-netlib//cppnetlib-constants + /cpp-netlib//cppnetlib-uri + /cpp-netlib//cppnetlib-message + /cpp-netlib//cppnetlib-message-wrappers + /cpp-netlib//cppnetlib-message-directives + /cpp-netlib//cppnetlib-http-message + /cpp-netlib//cppnetlib-http-message-wrappers + /cpp-netlib//cppnetlib-http-client + /cpp-netlib//cppnetlib-http-client-connections ; + +run client_get_streaming_test.cpp /cpp-netlib//cppnetlib-constants + /cpp-netlib//cppnetlib-uri + /cpp-netlib//cppnetlib-message + /cpp-netlib//cppnetlib-message-wrappers + /cpp-netlib//cppnetlib-message-directives + /cpp-netlib//cppnetlib-http-message + /cpp-netlib//cppnetlib-http-message-wrappers + /cpp-netlib//cppnetlib-http-client + /cpp-netlib//cppnetlib-http-client-connections ; + +run server_constructor_test.cpp /cpp-netlib//cppnetlib-constants + /cpp-netlib//cppnetlib-uri + /cpp-netlib//cppnetlib-message + /cpp-netlib//cppnetlib-message-wrappers + /cpp-netlib//cppnetlib-http-message + /cpp-netlib//cppnetlib-http-server + /cpp-netlib//cppnetlib-http-server-parsers + /cpp-netlib//cppnetlib-utils-thread_pool ; + +run server_async_run_stop_concurrency.cpp /cpp-netlib//cppnetlib-constants + /cpp-netlib//cppnetlib-uri + /cpp-netlib//cppnetlib-message + /cpp-netlib//cppnetlib-message-wrappers + /cpp-netlib//cppnetlib-http-message + /cpp-netlib//cppnetlib-http-server + /cpp-netlib//cppnetlib-http-server-parsers + /cpp-netlib//cppnetlib-utils-thread_pool ; + +#run client_localhost_normal_test.cpp /cpp-netlib//cppnetlib-uri /cpp-netlib//cppnetlib-http-client-connections ; +#run client_localhost_ssl_test.cpp /cpp-netlib//cppnetlib-uri /cpp-netlib//cppnetlib-http-client-connections ; +#run message_async_ready_test.cpp ; +#run message_test.cpp /cpp-netlib//cppnetlib-uri ; +#run request_incremental_parser_test.cpp ; +#run request_linearize_test.cpp /cpp-netlib//cppnetlib-uri ; +#run response_incremental_parser_test.cpp /cpp-netlib//cppnetlib-http-server-parsers ; +#run server_constructor_test.cpp /cpp-netlib//cppnetlib-http-server-parsers ; #run server_include_inlined.cpp : BOOST_NETWORK_NO_LIB ; -exe http_async_server : server_async.cpp /cpp-netlib//cppnetlib-server-parsers ; -exe hello_world : server_hello_world.cpp /cpp-netlib//cppnetlib-server-parsers ; -exe http_async_less_copy_server : server_async_less_copy.cpp /cpp-netlib//cppnetlib-server-parsers ; -exe http_async_run_stop_concurrency_server : server_async_run_stop_concurrency.cpp /cpp-netlib//cppnetlib-server-parsers ; +#exe http_async_server : server_async.cpp /cpp-netlib//cppnetlib-http-server-parsers ; +#exe hello_world : server_hello_world.cpp /cpp-netlib//cppnetlib-http-server-parsers ; +#exe http_async_less_copy_server : server_async_less_copy.cpp /cpp-netlib//cppnetlib-http-server-parsers ; +#exe http_async_run_stop_concurrency_server : server_async_run_stop_concurrency.cpp /cpp-netlib//cppnetlib-http-server-parsers ; -make httplib_acceptance.passed : ../httplib_acceptance.py hello_world : @httplib_acceptance ; -make httplib_async_acceptance.passed : ../httplib_acceptance.py http_async_server : @httplib_acceptance ; -make httplib_async_less_copy_acceptance.passed : ../httplib_acceptance.py http_async_less_copy_server : @httplib_acceptance ; -make httplib_async_run_stop_concurrency_acceptance.passed : ../httplib_acceptance.py http_async_run_stop_concurrency_server : @httplib_acceptance ; +#make httplib_acceptance.passed : ../httplib_acceptance.py hello_world : @httplib_acceptance ; +#make httplib_async_acceptance.passed : ../httplib_acceptance.py http_async_server : @httplib_acceptance ; +#make httplib_async_less_copy_acceptance.passed : ../httplib_acceptance.py http_async_less_copy_server : @httplib_acceptance ; +#make httplib_async_run_stop_concurrency_acceptance.passed : ../httplib_acceptance.py http_async_run_stop_concurrency_server : @httplib_acceptance ; actions httplib_acceptance { export TEST_SCRIPT=`echo "$(>)" | awk '{print $1}'` @@ -46,4 +136,3 @@ actions httplib_acceptance { export PORT=`echo "import random; print random.randint(8000, 8010)" | python` python $TEST_SCRIPT $EXECUTABLE $PORT $(<) } - diff --git a/libs/network/test/uri/Jamfile.v2 b/libs/network/test/uri/Jamfile.v2 index aacbd1ac6..44e99160d 100644 --- a/libs/network/test/uri/Jamfile.v2 +++ b/libs/network/test/uri/Jamfile.v2 @@ -10,8 +10,12 @@ project network_test/uri : requirements ../../../../ ../ + gcc:-std=c++0x ; -run url_test.cpp /cpp-netlib//cppnetlib-uri ; -run url_builder_test.cpp /cpp-netlib//cppnetlib-uri ; -run url_encoding_test.cpp /cpp-netlib//cppnetlib-uri ; +run uri_test.cpp /cpp-netlib//cppnetlib-uri ; +run uri_builder_test.cpp /cpp-netlib//cppnetlib-uri ; +run uri_builder_stream_test.cpp /cpp-netlib//cppnetlib-uri ; +run uri_encoding_test.cpp /cpp-netlib//cppnetlib-uri ; +run relative_uri_test.cpp /cpp-netlib//cppnetlib-uri ; +run scheme_tests.cpp /cpp-netlib//cppnetlib-uri ; From 9dca1542d25f4646eba873c6481f93d4e6b1e016 Mon Sep 17 00:00:00 2001 From: Matthew Clark Date: Wed, 17 Oct 2012 01:07:16 -0500 Subject: [PATCH 121/196] *changed http-get-test to pass if it was successfully redirected or simply succeeds --- libs/network/test/http/client_get_test.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/network/test/http/client_get_test.cpp b/libs/network/test/http/client_get_test.cpp index 7a95019fb..f60bc1ba3 100644 --- a/libs/network/test/http/client_get_test.cpp +++ b/libs/network/test/http/client_get_test.cpp @@ -26,8 +26,8 @@ BOOST_AUTO_TEST_CASE(http_client_get_test) { response.get_status(status_); response.get_status_message(status_message_); BOOST_CHECK_EQUAL ( version_.substr(0,7), "HTTP/1."); - BOOST_CHECK_EQUAL ( status_, 302u ); - BOOST_CHECK_EQUAL ( status_message_, std::string("Found") ); + BOOST_CHECK ( status_ == 302u || status_ == 200u ); + BOOST_CHECK ( status_message_ == std::string("Found") || status_message_ == std::string("OK") ); } #ifdef NETWORK_ENABLE_HTTPS @@ -47,8 +47,8 @@ BOOST_AUTO_TEST_CASE(https_client_get_test) { response.get_status(status_); response.get_status_message(status_message_); BOOST_CHECK_EQUAL ( version_.substr(0,7), "HTTP/1."); - BOOST_CHECK_EQUAL ( status_, 302u ); - BOOST_CHECK_EQUAL ( status_message_, std::string("Found") ); + BOOST_CHECK ( status_ == 302u || status_ == 200u ); + BOOST_CHECK ( status_message_ == std::string("Found") || status_message_ == std::string("OK") ); } #endif From b78f68a433a2cab1f9d356a1886952ba3d8b2319 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Tue, 23 Oct 2012 15:03:50 +1100 Subject: [PATCH 122/196] WIP: Using stand-alone Asio with C++11 Removing dependency on Boost.Asio and using the standalone Asio version. --- CMakeLists.txt | 5 + include/network/include/http/server.hpp | 2 +- .../directives/detail/string_value.hpp | 2 +- include/network/message/message.hpp | 12 +- include/network/message/message.ipp | 20 +- include/network/message/message_base.hpp | 10 +- include/network/message/wrappers/headers.ipp | 2 +- include/network/protocol/http/client.hpp | 2 +- include/network/protocol/http/client/base.hpp | 9 +- include/network/protocol/http/client/base.ipp | 27 +-- .../http/client/client_connection.hpp | 8 +- .../http/client/connection/async_normal.hpp | 8 +- .../http/client/connection/async_normal.ipp | 227 +++++++++--------- .../connection/async_protocol_handler.hpp | 68 +++--- .../http/client/connection/async_resolver.hpp | 2 +- .../http/client/connection/async_resolver.ipp | 39 +-- .../client/connection/connection_delegate.hpp | 18 +- .../connection_delegate_factory.hpp | 2 +- .../connection_delegate_factory.ipp | 2 +- .../client/connection/connection_factory.hpp | 8 +- .../client/connection/normal_delegate.hpp | 18 +- .../client/connection/normal_delegate.ipp | 28 +-- .../client/connection/resolver_delegate.hpp | 8 +- .../connection/resolver_delegate_factory.hpp | 2 +- .../connection/resolver_delegate_factory.ipp | 2 +- .../connection/simple_connection_factory.hpp | 2 +- .../connection/simple_connection_factory.ipp | 4 +- .../http/client/connection/ssl_delegate.hpp | 26 +- .../http/client/connection/ssl_delegate.ipp | 45 ++-- .../http/client/connection/sync_base.hpp | 54 ++--- .../http/client/connection/sync_normal.hpp | 14 +- .../http/client/connection/sync_ssl.hpp | 26 +- .../http/client/connection_manager.hpp | 6 +- .../network/protocol/http/client/macros.hpp | 4 +- .../network/protocol/http/client/options.hpp | 6 +- .../network/protocol/http/client/options.ipp | 10 +- .../network/protocol/http/client/pimpl.hpp | 2 +- .../http/client/simple_connection_manager.hpp | 2 +- .../http/client/simple_connection_manager.ipp | 4 +- .../protocol/http/client/sync_impl.hpp | 8 +- include/network/protocol/http/impl/access.hpp | 18 +- include/network/protocol/http/impl/access.ipp | 14 +- .../network/protocol/http/impl/response.ipp | 12 +- .../protocol/http/message/async_message.hpp | 2 +- .../http/message/directives/status.hpp | 2 +- .../http/policies/async_connection.hpp | 4 +- .../http/policies/async_connection.ipp | 2 +- .../network/protocol/http/request/request.hpp | 12 +- .../network/protocol/http/request/request.ipp | 20 +- .../protocol/http/request/request_base.hpp | 4 +- .../protocol/http/response/response.hpp | 24 +- .../protocol/http/response/response.ipp | 189 ++++++++------- .../protocol/http/response/response_base.hpp | 4 +- .../protocol/http/server/async_impl.hpp | 14 +- .../protocol/http/server/async_impl.ipp | 34 +-- .../protocol/http/server/async_server.hpp | 14 +- .../protocol/http/server/connection/async.hpp | 185 +++++++------- .../protocol/http/server/connection/sync.hpp | 84 +++---- .../server/impl/socket_options_setter.hpp | 6 +- .../server/impl/socket_options_setter.ipp | 22 +- .../network/protocol/http/server/options.hpp | 4 +- .../network/protocol/http/server/options.ipp | 12 +- .../http/server/socket_options_base.hpp | 6 +- .../protocol/http/server/storage_base.hpp | 2 +- .../protocol/http/server/sync_impl.hpp | 14 +- .../protocol/http/server/sync_impl.ipp | 18 +- .../protocol/http/server/sync_server.hpp | 18 +- include/network/uri/builder.hpp | 8 +- include/network/utils/thread_pool.hpp | 18 +- include/network/utils/thread_pool.ipp | 16 +- 70 files changed, 758 insertions(+), 768 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9785c2e7a..b5fe13fe7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,11 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) elseif(${CMAKE_CXX_COMPILER_ID} MATCHES Clang) set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++") set(CMAKE_CXX_LINK_FLAGS "-std=c++11 -stdlib=libc++") + add_definitions( + -DASIO_HAS_MOVE -DASIO_HAS_VARIADIC_TEMPLATES -DASIO_HAS_STD_SYSTEM_ERROR + -DASIO_ERROR_CATEGORY_NOEXCEPT=noexcept -DASIO_HAS_STD_ARRAY + -DASIO_HAS_STD_SHARED_PTR -DASIO_HAS_STD_ATOMIC -DASIO_HAS_STD_CHRONO + -DASIO_HAS_STD_ADDRESSOFF -DASIO_HAS_STD_FUNCTION -DASIO_HAS_STD_TYPE_TRAITS) message("C++ Flags: ${CMAKE_CXX_FLAGS} link flags: ${CMAKE_CXX_LINK_FLAGS}") endif() diff --git a/include/network/include/http/server.hpp b/include/network/include/http/server.hpp index 8f8a9f9c6..ccbd69a1d 100644 --- a/include/network/include/http/server.hpp +++ b/include/network/include/http/server.hpp @@ -9,7 +9,7 @@ #ifndef NETWORK_INCLUDE_HTTP_SERVER_HPP_ #define NETWORK_INCLUDE_HTTP_SERVER_HPP_ -#include +#include #include #include #include diff --git a/include/network/message/directives/detail/string_value.hpp b/include/network/message/directives/detail/string_value.hpp index b686e6ab6..3dc48561b 100644 --- a/include/network/message/directives/detail/string_value.hpp +++ b/include/network/message/directives/detail/string_value.hpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/network/message/message.hpp b/include/network/message/message.hpp index 67567e8c3..e3625a35c 100644 --- a/include/network/message/message.hpp +++ b/include/network/message/message.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include @@ -45,16 +45,16 @@ struct message : message_base { virtual void get_destination(std::string & destination) const; virtual void get_source(std::string & source) const; virtual void get_headers( - boost::function inserter) const; + std::function inserter) const; virtual void get_headers( std::string const & name, - boost::function inserter) const; + std::function inserter) const; virtual void get_headers( - boost::function predicate, - boost::function inserter) const; + std::function predicate, + std::function inserter) const; virtual void get_body(std::string & body) const; virtual void get_body( - boost::function)> chunk_reader, + std::function)> chunk_reader, size_t size) const; void swap(message & other); diff --git a/include/network/message/message.ipp b/include/network/message/message.ipp index 4822c72d8..b4d3c00da 100644 --- a/include/network/message/message.ipp +++ b/include/network/message/message.ipp @@ -61,14 +61,14 @@ struct message_pimpl { source = source_; } - void get_headers(boost::function inserter) const { + void get_headers(std::function inserter) const { std::multimap::const_iterator it = headers_.begin(), end = headers_.end(); for (; it != end; ++it) inserter(it->first, it->second); } void get_headers(std::string const & name, - boost::function inserter) const { + std::function inserter) const { std::multimap::const_iterator it = headers_.find(name), end= headers_.end(); while (it != end) { @@ -77,8 +77,8 @@ struct message_pimpl { } } - void get_headers(boost::function predicate, - boost::function inserter) const { + void get_headers(std::function predicate, + std::function inserter) const { std::multimap::const_iterator it = headers_.begin(), end = headers_.end(); while (it != end) { @@ -92,7 +92,7 @@ struct message_pimpl { body = body_; } - void get_body(boost::function)> chunk_reader, size_t size) const { + void get_body(std::function)> chunk_reader, size_t size) const { static char const * nullptr_ = 0; if (body_read_pos == body_.size()) chunk_reader(boost::make_iterator_range(nullptr_, nullptr_)); @@ -179,17 +179,17 @@ void message::get_source(std::string & source) const { pimpl->get_source(source); } -void message::get_headers(boost::function inserter) const { +void message::get_headers(std::function inserter) const { pimpl->get_headers(inserter); } void message::get_headers(std::string const & name, - boost::function inserter) const { + std::function inserter) const { pimpl->get_headers(name, inserter); } -void message::get_headers(boost::function predicate, - boost::function inserter) const { +void message::get_headers(std::function predicate, + std::function inserter) const { pimpl->get_headers(predicate, inserter); } @@ -197,7 +197,7 @@ void message::get_body(std::string & body) const { pimpl->get_body(body); } -void message::get_body(boost::function)> chunk_reader, size_t size) const { +void message::get_body(std::function)> chunk_reader, size_t size) const { pimpl->get_body(chunk_reader, size); } diff --git a/include/network/message/message_base.hpp b/include/network/message/message_base.hpp index c3ddcb320..3061c4d1a 100644 --- a/include/network/message/message_base.hpp +++ b/include/network/message/message_base.hpp @@ -7,7 +7,7 @@ #ifndef NETWORK_MESSAGE_BASE_HPP_20110910 #define NETWORK_MESSAGE_BASE_HPP_20110910 -#include +#include #include namespace network { @@ -26,11 +26,11 @@ struct message_base { // Retrievers virtual void get_destination(std::string & destination) const = 0; virtual void get_source(std::string & source) const = 0; - virtual void get_headers(boost::function inserter) const = 0; - virtual void get_headers(std::string const & name, boost::function inserter) const = 0; - virtual void get_headers(boost::function predicate, boost::function inserter) const = 0; + virtual void get_headers(std::function inserter) const = 0; + virtual void get_headers(std::string const & name, std::function inserter) const = 0; + virtual void get_headers(std::function predicate, std::function inserter) const = 0; virtual void get_body(std::string & body) const = 0; - virtual void get_body(boost::function)> chunk_reader, size_t size) const = 0; + virtual void get_body(std::function)> chunk_reader, size_t size) const = 0; // Destructor virtual ~message_base() = 0; // pure virtual diff --git a/include/network/message/wrappers/headers.ipp b/include/network/message/wrappers/headers.ipp index f172e5fe2..812b0966f 100644 --- a/include/network/message/wrappers/headers.ipp +++ b/include/network/message/wrappers/headers.ipp @@ -9,7 +9,7 @@ #include #include -#include +#include namespace network { diff --git a/include/network/protocol/http/client.hpp b/include/network/protocol/http/client.hpp index d6832919c..91c76fd20 100644 --- a/include/network/protocol/http/client.hpp +++ b/include/network/protocol/http/client.hpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include diff --git a/include/network/protocol/http/client/base.hpp b/include/network/protocol/http/client/base.hpp index bdd71543a..a0aa4124a 100644 --- a/include/network/protocol/http/client/base.hpp +++ b/include/network/protocol/http/client/base.hpp @@ -7,14 +7,9 @@ #ifndef NETWORK_PROTOCOL_HTTP_CLIENT_BASE_HPP_20111008 #define NETWORK_PROTOCOL_HTTP_CLIENT_BASE_HPP_20111008 -#include +#include #include -namespace boost { namespace asio { -class io_service; -} // namespace asio -} // namespace boost - namespace network { namespace http { @@ -28,7 +23,7 @@ class client_options; struct client_base { typedef - boost::function const &, boost::system::error_code const &)> + std::function const &, asio::error_code const &)> body_callback_function_type; client_base(); diff --git a/include/network/protocol/http/client/base.ipp b/include/network/protocol/http/client/base.ipp index 3a6a5097c..467a30d36 100644 --- a/include/network/protocol/http/client/base.ipp +++ b/include/network/protocol/http/client/base.ipp @@ -7,12 +7,12 @@ #ifndef NETWORK_PROTOCOL_HTTP_CLIENT_ASYNC_IMPL_HPP_20100623 #define NETWORK_PROTOCOL_HTTP_CLIENT_ASYNC_IMPL_HPP_20100623 +#include +#include #include #include -#include -#include -#include -#include +#include +#include #include #include #include @@ -22,7 +22,7 @@ namespace network { namespace http { struct client_base_pimpl { typedef - boost::function const &, boost::system::error_code const &)> + std::function const &, asio::error_code const &)> body_callback_function_type; client_base_pimpl(client_options const &options); response const request_skeleton(request const & request_, @@ -34,9 +34,9 @@ struct client_base_pimpl { ~client_base_pimpl(); private: client_options options_; - boost::asio::io_service * service_ptr; - boost::shared_ptr sentinel_; - boost::shared_ptr lifetime_thread_; + asio::io_service * service_ptr; + boost::shared_ptr sentinel_; + boost::shared_ptr lifetime_thread_; boost::shared_ptr connection_manager_; bool owned_service_; }; @@ -78,7 +78,7 @@ client_base_pimpl::client_base_pimpl(client_options const &options) NETWORK_MESSAGE("client_base_pimpl::client_base_pimpl(client_options const &)"); if (service_ptr == 0) { NETWORK_MESSAGE("creating owned io_service."); - service_ptr = new(std::nothrow) boost::asio::io_service; + service_ptr = new(std::nothrow) asio::io_service; owned_service_ = true; } if (!connection_manager_.get()) { @@ -86,12 +86,9 @@ client_base_pimpl::client_base_pimpl(client_options const &options) connection_manager_.reset( new (std::nothrow) simple_connection_manager(options)); } - sentinel_.reset(new (std::nothrow) boost::asio::io_service::work(*service_ptr)); - lifetime_thread_.reset(new (std::nothrow) boost::thread( - boost::bind( - &boost::asio::io_service::run, - service_ptr - ))); + sentinel_.reset(new (std::nothrow) asio::io_service::work(*service_ptr)); + auto local_ptr = service_ptr; + lifetime_thread_.reset(new (std::nothrow) std::thread([local_ptr]() { local_ptr->run(); })); if (!lifetime_thread_.get()) BOOST_THROW_EXCEPTION(std::runtime_error("Cannot allocate client lifetime thread; not enough memory.")); } diff --git a/include/network/protocol/http/client/client_connection.hpp b/include/network/protocol/http/client/client_connection.hpp index 71ed6b24c..f73e25da3 100644 --- a/include/network/protocol/http/client/client_connection.hpp +++ b/include/network/protocol/http/client/client_connection.hpp @@ -7,9 +7,9 @@ #ifndef NETWORK_PROTOCOL_HTTP_CLIENT_CLIENT_CONNECTION_HPP_20111103 #define NETWORK_PROTOCOL_HTTP_CLIENT_CLIENT_CONNECTION_HPP_20111103 -#include +#include #include -#include +#include namespace network { namespace http { @@ -19,9 +19,9 @@ struct response; class request_options; struct client_connection { - typedef boost::function< + typedef std::function< void(boost::iterator_range const &, - boost::system::error_code const &)> + asio::error_code const &)> callback_type; virtual response send_request(std::string const & method, request const & request, diff --git a/include/network/protocol/http/client/connection/async_normal.hpp b/include/network/protocol/http/client/connection/async_normal.hpp index 468735b1d..12347f836 100644 --- a/include/network/protocol/http/client/connection/async_normal.hpp +++ b/include/network/protocol/http/client/connection/async_normal.hpp @@ -14,14 +14,10 @@ #include #include -namespace boost { namespace asio { - +namespace asio { class io_service; - } // namespace asio -} // namespace boost - namespace network { namespace http { struct request; @@ -36,7 +32,7 @@ struct http_async_connection : client_connection using client_connection::callback_type; http_async_connection(boost::shared_ptr resolver_delegate, boost::shared_ptr connection_delegate, - boost::asio::io_service & io_service, + asio::io_service & io_service, bool follow_redirects); http_async_connection * clone() const; virtual response send_request(std::string const & method, diff --git a/include/network/protocol/http/client/connection/async_normal.ipp b/include/network/protocol/http/client/connection/async_normal.ipp index a99680632..572a48891 100644 --- a/include/network/protocol/http/client/connection/async_normal.ipp +++ b/include/network/protocol/http/client/connection/async_normal.ipp @@ -7,7 +7,8 @@ #ifndef NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_NORMAL_IPP_20111123 #define NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_ASYNC_NORMAL_IPP_20111123 -#include +#include +#include #include #include #include @@ -15,16 +16,14 @@ #include #include #include -#include +#include #include #ifdef NETWORK_ENABLE_HTTPS -#include +#include #endif namespace network { namespace http { -namespace placeholders = boost::asio::placeholders; - struct http_async_connection_pimpl : boost::enable_shared_from_this { typedef http_async_connection::callback_type body_callback_function_type; @@ -35,7 +34,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this resolver_delegate, boost::shared_ptr connection_delegate, - boost::asio::io_service & io_service, + asio::io_service & io_service, bool follow_redirect) : follow_redirect_(follow_redirect), @@ -66,11 +65,12 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thishost_ = host(request); + using namespace std::placeholders; resolver_delegate_->resolve( this->host_, port_, request_strand_.wrap( - boost::bind( + std::bind( &this_type::handle_resolved, this_type::shared_from_this(), port_, @@ -111,24 +111,24 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisversion_promise.set_exception(boost::copy_exception(error)); - this->status_promise.set_exception(boost::copy_exception(error)); - this->status_message_promise.set_exception(boost::copy_exception(error)); - this->headers_promise.set_exception(boost::copy_exception(error)); - this->source_promise.set_exception(boost::copy_exception(error)); - this->destination_promise.set_exception(boost::copy_exception(error)); - this->body_promise.set_exception(boost::copy_exception(error)); + std::system_error error(ec); + this->version_promise.set_exception(std::make_exception_ptr(error)); + this->status_promise.set_exception(std::make_exception_ptr(error)); + this->status_message_promise.set_exception(std::make_exception_ptr(error)); + this->headers_promise.set_exception(std::make_exception_ptr(error)); + this->source_promise.set_exception(std::make_exception_ptr(error)); + this->destination_promise.set_exception(std::make_exception_ptr(error)); + this->body_promise.set_exception(std::make_exception_ptr(error)); NETWORK_MESSAGE("promise+future exceptions set."); } void handle_resolved(boost::uint16_t port, bool get_body, body_callback_function_type callback, - boost::system::error_code const & ec, + asio::error_code const & ec, resolver_iterator_pair endpoint_range) { NETWORK_MESSAGE("http_async_connection_pimpl::handle_resolved(...)"); if (!ec && !boost::empty(endpoint_range)) { @@ -137,12 +137,13 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisendpoint().address() << ":" << port); - boost::asio::ip::tcp::endpoint endpoint(iter->endpoint().address(), port); + asio::ip::tcp::endpoint endpoint(iter->endpoint().address(), port); + using namespace std::placeholders; connection_delegate_->connect( endpoint, this->host_, request_strand_.wrap( - boost::bind( + std::bind( &this_type::handle_connected, this_type::shared_from_this(), port, @@ -150,10 +151,10 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thiswrite(command_streambuf, request_strand_.wrap( - boost::bind( + std::bind( &this_type::handle_sent_request, this_type::shared_from_this(), get_body, callback, - placeholders::error, - placeholders::bytes_transferred))); + _1, + _2))); } else { NETWORK_MESSAGE("connection unsuccessful"); if (!boost::empty(endpoint_range)) { resolver_iterator iter = boost::begin(endpoint_range); NETWORK_MESSAGE("trying: " << iter->endpoint().address() << ":" << port); - boost::asio::ip::tcp::endpoint endpoint(iter->endpoint().address(), port); + asio::ip::tcp::endpoint endpoint(iter->endpoint().address(), port); + using namespace std::placeholders; connection_delegate_->connect(endpoint, this->host_, request_strand_.wrap( - boost::bind( + std::bind( &this_type::handle_connected, this_type::shared_from_this(), port, @@ -193,9 +196,9 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisread_some( - boost::asio::mutable_buffers_1(this->part.c_array(), + asio::mutable_buffers_1(this->part.c_array(), this->part.size()), request_strand_.wrap( - boost::bind(&this_type::handle_received_data, + std::bind(&this_type::handle_received_data, this_type::shared_from_this(), version, get_body, callback, - placeholders::error, - placeholders::bytes_transferred))); + _1, + _2))); } else { NETWORK_MESSAGE("request sent unsuccessfully; setting errors"); set_errors(ec); } } - void handle_received_data(state_t state, bool get_body, body_callback_function_type callback, boost::system::error_code const & ec, std::size_t bytes_transferred) { + void handle_received_data(state_t state, bool get_body, body_callback_function_type callback, asio::error_code const & ec, std::size_t bytes_transferred) { NETWORK_MESSAGE("http_async_connection_pimpl::handle_received_data(...)"); // Okay, there's some weirdness with Boost.Asio's handling of SSL errors // so we need to do some acrobatics to make sure that we're handling the @@ -235,39 +239,40 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisparse_version(request_strand_.wrap( - boost::bind( + std::bind( &this_type::handle_received_data, this_type::shared_from_this(), version, get_body, callback, - placeholders::error, - placeholders::bytes_transferred)), + _1, + _2)), bytes_transferred); if (!parsed_ok || indeterminate(parsed_ok)) return; case status: NETWORK_MESSAGE("parsing status..."); parsed_ok = this->parse_status(request_strand_.wrap( - boost::bind( + std::bind( &this_type::handle_received_data, this_type::shared_from_this(), status, get_body, callback, - placeholders::error, - placeholders::bytes_transferred)), + _1, + _2)), bytes_transferred); if (!parsed_ok || indeterminate(parsed_ok)) return; case status_message: @@ -275,11 +280,11 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisparse_status_message( request_strand_.wrap( - boost::bind( + std::bind( &this_type::handle_received_data, this_type::shared_from_this(), status_message, get_body, callback, - placeholders::error, placeholders::bytes_transferred + _1, _2 ) ), bytes_transferred @@ -294,11 +299,11 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisparse_headers( request_strand_.wrap( - boost::bind( + std::bind( &this_type::handle_received_data, this_type::shared_from_this(), headers, get_body, callback, - placeholders::error, placeholders::bytes_transferred + _1, _2 ) ), bytes_transferred @@ -342,27 +347,27 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisread_some( - boost::asio::mutable_buffers_1(this->part.c_array(), + asio::mutable_buffers_1(this->part.c_array(), this->part.size()), request_strand_.wrap( - boost::bind(&this_type::handle_received_data, + std::bind(&this_type::handle_received_data, this_type::shared_from_this(), body, get_body, callback, - placeholders::error, - placeholders::bytes_transferred))); + _1, + _2))); } else { NETWORK_MESSAGE("no callback provided, appending to body..."); // Here we handle the body data ourself and append to an // ever-growing string buffer. this->parse_body( request_strand_.wrap( - boost::bind( + std::bind( &this_type::handle_received_data, this_type::shared_from_this(), body, get_body, callback, - placeholders::error, placeholders::bytes_transferred + _1, _2 ) ), remainder); @@ -370,7 +375,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisread_some( - boost::asio::mutable_buffers_1( + asio::mutable_buffers_1( this->part.c_array(), this->part.size()), request_strand_.wrap( - boost::bind( + std::bind( &this_type::handle_received_data, this_type::shared_from_this(), body, get_body, callback, - placeholders::error, - placeholders::bytes_transferred))); + _1, + _2))); } else { NETWORK_MESSAGE("no callback provided, appending to body..."); // Here we don't have a body callback. Let's @@ -435,14 +440,14 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisparse_body(request_strand_.wrap( - boost::bind( + std::bind( &this_type::handle_received_data, this_type::shared_from_this(), body, get_body, callback, - placeholders::error, - placeholders::bytes_transferred)), + _1, + _2)), bytes_transferred); } } @@ -451,21 +456,21 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thissource_promise.set_exception(boost::copy_exception(error)); - this->destination_promise.set_exception(boost::copy_exception(error)); + this->source_promise.set_exception(std::make_exception_ptr(error)); + this->destination_promise.set_exception(std::make_exception_ptr(error)); switch (state) { case version: - this->version_promise.set_exception(boost::copy_exception(error)); + this->version_promise.set_exception(std::make_exception_ptr(error)); case status: - this->status_promise.set_exception(boost::copy_exception(error)); + this->status_promise.set_exception(std::make_exception_ptr(error)); case status_message: - this->status_message_promise.set_exception(boost::copy_exception(error)); + this->status_message_promise.set_exception(std::make_exception_ptr(error)); case headers: - this->headers_promise.set_exception(boost::copy_exception(error)); + this->headers_promise.set_exception(std::make_exception_ptr(error)); case body: - this->body_promise.set_exception(boost::copy_exception(error)); + this->body_promise.set_exception(std::make_exception_ptr(error)); break; default: BOOST_ASSERT(false && "Bug, report this to the developers!"); @@ -512,7 +517,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this callback, + std::function callback, size_t bytes) { boost::logic::tribool parsed_ok; part_begin = part.begin(); @@ -544,14 +549,14 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisread_some( - boost::asio::mutable_buffers_1(part.c_array(), part.size()), + asio::mutable_buffers_1(part.c_array(), part.size()), callback ); } @@ -567,7 +572,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this callback, + std::function callback, size_t bytes) { boost::logic::tribool parsed_ok; buffer_type::const_iterator part_end = part.begin(); @@ -600,13 +605,13 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisread_some( - boost::asio::mutable_buffers_1(part.c_array(), part.size()), + asio::mutable_buffers_1(part.c_array(), part.size()), callback ); } @@ -622,7 +627,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this callback, + std::function callback, size_t bytes) { boost::logic::tribool parsed_ok; buffer_type::const_iterator part_end = part.begin(); @@ -654,18 +659,18 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisread_some( - boost::asio::mutable_buffers_1(part.c_array(), part.size()), + asio::mutable_buffers_1(part.c_array(), part.size()), callback ); } @@ -713,7 +718,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this parse_headers( - boost::function callback, + std::function callback, size_t bytes) { boost::logic::tribool parsed_ok; buffer_type::const_iterator part_end = part.begin(); @@ -746,16 +751,16 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisread_some( - boost::asio::mutable_buffers_1(part.c_array(), part.size()), + asio::mutable_buffers_1(part.c_array(), part.size()), callback ); } @@ -768,31 +773,31 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this callback, size_t bytes) { + void parse_body(std::function callback, size_t bytes) { // TODO: we should really not use a string for the partial body // buffer. partial_parsed.append(part_begin, bytes); part_begin = part.begin(); connection_delegate_->read_some( - boost::asio::mutable_buffers_1(part.c_array(), part.size()), + asio::mutable_buffers_1(part.c_array(), part.size()), callback ); } bool follow_redirect_; - boost::asio::io_service::strand request_strand_; + asio::io_service::strand request_strand_; boost::shared_ptr resolver_delegate_; boost::shared_ptr connection_delegate_; - boost::asio::streambuf command_streambuf; + asio::streambuf command_streambuf; std::string method; response_parser response_parser_; - boost::promise version_promise; - boost::promise status_promise; - boost::promise status_message_promise; - boost::promise > headers_promise; - boost::promise source_promise; - boost::promise destination_promise; - boost::promise body_promise; + std::promise version_promise; + std::promise status_promise; + std::promise status_message_promise; + std::promise > headers_promise; + std::promise source_promise; + std::promise destination_promise; + std::promise body_promise; typedef boost::array buffer_type; buffer_type part; buffer_type::const_iterator part_begin; @@ -804,7 +809,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this resolver_delegate, boost::shared_ptr connection_delegate, - boost::asio::io_service & io_service, + asio::io_service & io_service, bool follow_redirects) : pimpl(new (std::nothrow) http_async_connection_pimpl(resolver_delegate, connection_delegate, diff --git a/include/network/protocol/http/client/connection/async_protocol_handler.hpp b/include/network/protocol/http/client/connection/async_protocol_handler.hpp index f436a11b0..b6a85849b 100644 --- a/include/network/protocol/http/client/connection/async_protocol_handler.hpp +++ b/include/network/protocol/http/client/connection/async_protocol_handler.hpp @@ -114,14 +114,14 @@ namespace impl { << "\""); #endif std::runtime_error error("Invalid Version Part."); - version_promise.set_exception(boost::copy_exception(error)); - status_promise.set_exception(boost::copy_exception(error)); + version_promise.set_exception(std::make_exception_ptr(error)); + status_promise.set_exception(std::make_exception_ptr(error)); status_message_promise.set_exception( - boost::copy_exception(error)); - headers_promise.set_exception(boost::copy_exception(error)); - source_promise.set_exception(boost::copy_exception(error)); - destination_promise.set_exception(boost::copy_exception(error)); - body_promise.set_exception(boost::copy_exception(error)); + std::make_exception_ptr(error)); + headers_promise.set_exception(std::make_exception_ptr(error)); + source_promise.set_exception(std::make_exception_ptr(error)); + destination_promise.set_exception(std::make_exception_ptr(error)); + body_promise.set_exception(std::make_exception_ptr(error)); } else { partial_parsed.append( boost::begin(result_range), @@ -129,7 +129,7 @@ namespace impl { ); part_begin = part.begin(); delegate_->read_some( - boost::asio::mutable_buffers_1(part.c_array(), part.size()), + asio::mutable_buffers_1(part.c_array(), part.size()), callback ); } @@ -171,13 +171,13 @@ namespace impl { << "\""); #endif std::runtime_error error("Invalid status part."); - status_promise.set_exception(boost::copy_exception(error)); + status_promise.set_exception(std::make_exception_ptr(error)); status_message_promise.set_exception( - boost::copy_exception(error)); - headers_promise.set_exception(boost::copy_exception(error)); - source_promise.set_exception(boost::copy_exception(error)); - destination_promise.set_exception(boost::copy_exception(error)); - body_promise.set_exception(boost::copy_exception(error)); + std::make_exception_ptr(error)); + headers_promise.set_exception(std::make_exception_ptr(error)); + source_promise.set_exception(std::make_exception_ptr(error)); + destination_promise.set_exception(std::make_exception_ptr(error)); + body_promise.set_exception(std::make_exception_ptr(error)); } else { partial_parsed.append( boost::begin(result_range), @@ -185,7 +185,7 @@ namespace impl { ); part_begin = part.begin(); delegate_->read_some( - boost::asio::mutable_buffers_1(part.c_array(), part.size()), + asio::mutable_buffers_1(part.c_array(), part.size()), callback ); } @@ -226,18 +226,18 @@ namespace impl { #endif std::runtime_error error("Invalid status message part."); status_message_promise.set_exception( - boost::copy_exception(error)); - headers_promise.set_exception(boost::copy_exception(error)); - source_promise.set_exception(boost::copy_exception(error)); - destination_promise.set_exception(boost::copy_exception(error)); - body_promise.set_exception(boost::copy_exception(error)); + std::make_exception_ptr(error)); + headers_promise.set_exception(std::make_exception_ptr(error)); + source_promise.set_exception(std::make_exception_ptr(error)); + destination_promise.set_exception(std::make_exception_ptr(error)); + body_promise.set_exception(std::make_exception_ptr(error)); } else { partial_parsed.append( boost::begin(result_range), boost::end(result_range)); part_begin = part.begin(); delegate_->read_some( - boost::asio::mutable_buffers_1(part.c_array(), part.size()), + asio::mutable_buffers_1(part.c_array(), part.size()), callback ); } @@ -319,16 +319,16 @@ namespace impl { << boost::distance(result_range)); #endif std::runtime_error error("Invalid header part."); - headers_promise.set_exception(boost::copy_exception(error)); - body_promise.set_exception(boost::copy_exception(error)); - source_promise.set_exception(boost::copy_exception(error)); - destination_promise.set_exception(boost::copy_exception(error)); + headers_promise.set_exception(std::make_exception_ptr(error)); + body_promise.set_exception(std::make_exception_ptr(error)); + source_promise.set_exception(std::make_exception_ptr(error)); + destination_promise.set_exception(std::make_exception_ptr(error)); } else { partial_parsed.append(boost::begin(result_range), boost::end(result_range)); part_begin = part.begin(); delegate_->read_some( - boost::asio::mutable_buffers_1(part.c_array(), part.size()), + asio::mutable_buffers_1(part.c_array(), part.size()), callback ); } @@ -348,19 +348,19 @@ namespace impl { partial_parsed.append(part_begin, bytes); part_begin = part.begin(); delegate_->read_some( - boost::asio::mutable_buffers_1(part.c_array(), part.size()), + asio::mutable_buffers_1(part.c_array(), part.size()), callback ); } response_parser response_parser_; - boost::promise version_promise; - boost::promise status_promise; - boost::promise status_message_promise; - boost::promise > headers_promise; - boost::promise source_promise; - boost::promise destination_promise; - boost::promise body_promise; + std::promise version_promise; + std::promise status_promise; + std::promise status_message_promise; + std::promise > headers_promise; + std::promise source_promise; + std::promise destination_promise; + std::promise body_promise; typedef boost::array buffer_type; buffer_type part; buffer_type::const_iterator part_begin; diff --git a/include/network/protocol/http/client/connection/async_resolver.hpp b/include/network/protocol/http/client/connection/async_resolver.hpp index a8ff87026..62a9de1b6 100644 --- a/include/network/protocol/http/client/connection/async_resolver.hpp +++ b/include/network/protocol/http/client/connection/async_resolver.hpp @@ -18,7 +18,7 @@ struct async_resolver_pimpl; struct async_resolver : resolver_delegate { using resolver_delegate::resolve_completion_function; - async_resolver(boost::asio::io_service & service, bool cache_resolved); + async_resolver(asio::io_service & service, bool cache_resolved); virtual void resolve(std::string const & host, uint16_t port, resolve_completion_function once_resolved); // override diff --git a/include/network/protocol/http/client/connection/async_resolver.ipp b/include/network/protocol/http/client/connection/async_resolver.ipp index e3efce841..c00106187 100644 --- a/include/network/protocol/http/client/connection/async_resolver.ipp +++ b/include/network/protocol/http/client/connection/async_resolver.ipp @@ -9,11 +9,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include @@ -26,32 +26,32 @@ namespace network { namespace http { struct async_resolver_pimpl : boost::enable_shared_from_this { typedef resolver_delegate::resolve_completion_function resolve_completion_function; - async_resolver_pimpl(boost::asio::io_service & service, bool cache_resolved); + async_resolver_pimpl(asio::io_service & service, bool cache_resolved); void resolve(std::string const & host, uint16_t port, resolve_completion_function once_resolved); void clear_resolved_cache(); private: - boost::asio::ip::udp::resolver resolver_; + asio::ip::udp::resolver resolver_; bool cache_resolved_; - typedef boost::asio::ip::udp::resolver::iterator + typedef asio::ip::udp::resolver::iterator resolver_iterator; typedef boost::unordered_map > endpoint_cache; endpoint_cache endpoint_cache_; - boost::scoped_ptr resolver_strand_; + boost::scoped_ptr resolver_strand_; void handle_resolve(std::string const & host, resolve_completion_function once_resolved, - boost::system::error_code const & ec, + asio::error_code const & ec, resolver_iterator endpoint_iterator); }; -async_resolver_pimpl::async_resolver_pimpl(boost::asio::io_service & service, bool cache_resolved) +async_resolver_pimpl::async_resolver_pimpl(asio::io_service & service, bool cache_resolved) : resolver_(service), cache_resolved_(cache_resolved), endpoint_cache_(), - resolver_strand_(new(std::nothrow) boost::asio::io_service::strand(service)) + resolver_strand_(new(std::nothrow) asio::io_service::strand(service)) { // Do nothing } @@ -72,29 +72,30 @@ void async_resolver_pimpl::resolve(std::string const & host, endpoint_cache::iterator iter = endpoint_cache_.find(boost::to_lower_copy(host)); if (iter != endpoint_cache_.end()) { - boost::system::error_code ignored; + asio::error_code ignored; once_resolved(ignored, iter->second); return; } } std::string port_str = boost::lexical_cast(port); - boost::asio::ip::udp::resolver::query query(host, port_str); + asio::ip::udp::resolver::query query(host, port_str); + using namespace std::placeholders; resolver_.async_resolve( query, resolver_strand_->wrap( - boost::bind( + std::bind( &async_resolver_pimpl::handle_resolve, async_resolver_pimpl::shared_from_this(), boost::to_lower_copy(host), once_resolved, - boost::asio::placeholders::error, - boost::asio::placeholders::iterator))); + _1, + _2))); } void async_resolver_pimpl::handle_resolve(std::string const & host, resolve_completion_function once_resolved, - boost::system::error_code const & ec, + asio::error_code const & ec, resolver_iterator endpoint_iterator) { endpoint_cache::iterator iter; bool inserted = false; @@ -110,7 +111,7 @@ void async_resolver_pimpl::handle_resolve(std::string const & host, } } -async_resolver::async_resolver(boost::asio::io_service & service, bool cache_resolved) +async_resolver::async_resolver(asio::io_service & service, bool cache_resolved) : pimpl(new (std::nothrow) async_resolver_pimpl(service, cache_resolved)) {} diff --git a/include/network/protocol/http/client/connection/connection_delegate.hpp b/include/network/protocol/http/client/connection/connection_delegate.hpp index cfe3a06ce..f250185f1 100644 --- a/include/network/protocol/http/client/connection/connection_delegate.hpp +++ b/include/network/protocol/http/client/connection/connection_delegate.hpp @@ -7,21 +7,21 @@ #ifndef NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_DELEGATE_HPP_ #define NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_DELEGATE_HPP_ -#include -#include -#include +#include +#include +#include namespace network { namespace http { struct connection_delegate { - virtual void connect(boost::asio::ip::tcp::endpoint & endpoint, + virtual void connect(asio::ip::tcp::endpoint & endpoint, std::string const & host, - boost::function handler) = 0; - virtual void write(boost::asio::streambuf & command_streambuf, - boost::function handler) = 0; - virtual void read_some(boost::asio::mutable_buffers_1 const & read_buffer, - boost::function handler) = 0; + std::function handler) = 0; + virtual void write(asio::streambuf & command_streambuf, + std::function handler) = 0; + virtual void read_some(asio::mutable_buffers_1 const & read_buffer, + std::function handler) = 0; virtual ~connection_delegate() {} }; diff --git a/include/network/protocol/http/client/connection/connection_delegate_factory.hpp b/include/network/protocol/http/client/connection/connection_delegate_factory.hpp index b3a997081..7a03b6c08 100644 --- a/include/network/protocol/http/client/connection/connection_delegate_factory.hpp +++ b/include/network/protocol/http/client/connection/connection_delegate_factory.hpp @@ -22,7 +22,7 @@ struct connection_delegate_factory { // This is the factory method that actually returns the delegate instance. virtual connection_delegate_ptr create_connection_delegate( - boost::asio::io_service & service, + asio::io_service & service, bool https, client_options const &options); diff --git a/include/network/protocol/http/client/connection/connection_delegate_factory.ipp b/include/network/protocol/http/client/connection/connection_delegate_factory.ipp index 63725e3a2..a8eddaa1c 100644 --- a/include/network/protocol/http/client/connection/connection_delegate_factory.ipp +++ b/include/network/protocol/http/client/connection/connection_delegate_factory.ipp @@ -24,7 +24,7 @@ connection_delegate_factory::connection_delegate_factory() { connection_delegate_factory::connection_delegate_ptr connection_delegate_factory::create_connection_delegate( - boost::asio::io_service & service, + asio::io_service & service, bool https, client_options const &options) { NETWORK_MESSAGE("connection_delegate_factory::create_connection_delegate(...)"); diff --git a/include/network/protocol/http/client/connection/connection_factory.hpp b/include/network/protocol/http/client/connection/connection_factory.hpp index 660df9a77..789402948 100644 --- a/include/network/protocol/http/client/connection/connection_factory.hpp +++ b/include/network/protocol/http/client/connection/connection_factory.hpp @@ -9,14 +9,10 @@ #include -namespace boost { namespace asio { - +namespace asio { class io_service; - } // namespace asio -} // namespace boost - namespace network { namespace http { class client_options; @@ -25,7 +21,7 @@ struct request_base; struct connection_factory { virtual boost::shared_ptr create_connection( - boost::asio::io_service &service, + asio::io_service &service, request_base const & request, client_options const &options) = 0; virtual ~connection_factory() = 0; // pure virtual, interface only. diff --git a/include/network/protocol/http/client/connection/normal_delegate.hpp b/include/network/protocol/http/client/connection/normal_delegate.hpp index a4bf08860..07e840bb4 100644 --- a/include/network/protocol/http/client/connection/normal_delegate.hpp +++ b/include/network/protocol/http/client/connection/normal_delegate.hpp @@ -22,20 +22,20 @@ namespace network { namespace http { struct normal_delegate : connection_delegate { - normal_delegate(boost::asio::io_service & service); + normal_delegate(asio::io_service & service); - virtual void connect(boost::asio::ip::tcp::endpoint & endpoint, + virtual void connect(asio::ip::tcp::endpoint & endpoint, std::string const &host, - boost::function handler); - virtual void write(boost::asio::streambuf & command_streambuf, - boost::function handler); - virtual void read_some(boost::asio::mutable_buffers_1 const & read_buffer, - boost::function handler); + std::function handler); + virtual void write(asio::streambuf & command_streambuf, + std::function handler); + virtual void read_some(asio::mutable_buffers_1 const & read_buffer, + std::function handler); ~normal_delegate(); private: - boost::asio::io_service & service_; - boost::scoped_ptr socket_; + asio::io_service & service_; + boost::scoped_ptr socket_; normal_delegate(normal_delegate const &); // = delete normal_delegate& operator=(normal_delegate); // = delete diff --git a/include/network/protocol/http/client/connection/normal_delegate.ipp b/include/network/protocol/http/client/connection/normal_delegate.ipp index 81ae0c95b..ef4726c3b 100644 --- a/include/network/protocol/http/client/connection/normal_delegate.ipp +++ b/include/network/protocol/http/client/connection/normal_delegate.ipp @@ -7,37 +7,37 @@ #ifndef NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_NORMAL_DELEGATE_IPP_20110819 #define NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_NORMAL_DELEGATE_IPP_20110819 -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include -network::http::normal_delegate::normal_delegate(boost::asio::io_service & service) +network::http::normal_delegate::normal_delegate(asio::io_service & service) : service_(service) {} void network::http::normal_delegate::connect( - boost::asio::ip::tcp::endpoint & endpoint, + asio::ip::tcp::endpoint & endpoint, std::string const &host, - boost::function handler) { - socket_.reset(new boost::asio::ip::tcp::socket(service_)); + std::function handler) { + socket_.reset(new asio::ip::tcp::socket(service_)); socket_->async_connect(endpoint, handler); } void network::http::normal_delegate::write( - boost::asio::streambuf & command_streambuf, - boost::function handler) { + asio::streambuf & command_streambuf, + std::function handler) { NETWORK_MESSAGE("normal_delegate::write(...)"); NETWORK_MESSAGE("scheduling asynchronous write..."); - boost::asio::async_write(*socket_, command_streambuf, handler); + asio::async_write(*socket_, command_streambuf, handler); } void network::http::normal_delegate::read_some( - boost::asio::mutable_buffers_1 const & read_buffer, - boost::function handler) { + asio::mutable_buffers_1 const & read_buffer, + std::function handler) { NETWORK_MESSAGE("normal_delegate::read_some(...)"); NETWORK_MESSAGE("scheduling asynchronous read some..."); socket_->async_read_some(read_buffer, handler); diff --git a/include/network/protocol/http/client/connection/resolver_delegate.hpp b/include/network/protocol/http/client/connection/resolver_delegate.hpp index a83cc04cf..643275e95 100644 --- a/include/network/protocol/http/client/connection/resolver_delegate.hpp +++ b/include/network/protocol/http/client/connection/resolver_delegate.hpp @@ -8,17 +8,17 @@ #define NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_HPP_20111016 #include -#include -#include +#include +#include namespace network { namespace http { struct resolver_delegate { - typedef boost::asio::ip::udp::resolver::iterator resolver_iterator; + typedef asio::ip::udp::resolver::iterator resolver_iterator; typedef std::pair iterator_pair; - typedef boost::function + typedef std::function resolve_completion_function; virtual void resolve(std::string const & host, uint16_t port, diff --git a/include/network/protocol/http/client/connection/resolver_delegate_factory.hpp b/include/network/protocol/http/client/connection/resolver_delegate_factory.hpp index 6a9776050..e9cc70ce1 100644 --- a/include/network/protocol/http/client/connection/resolver_delegate_factory.hpp +++ b/include/network/protocol/http/client/connection/resolver_delegate_factory.hpp @@ -16,7 +16,7 @@ namespace network { namespace http { struct resolver_delegate_factory { resolver_delegate_factory(); virtual boost::shared_ptr create_resolver_delegate( - boost::asio::io_service & service, + asio::io_service & service, bool cache_resolved); virtual ~resolver_delegate_factory(); private: diff --git a/include/network/protocol/http/client/connection/resolver_delegate_factory.ipp b/include/network/protocol/http/client/connection/resolver_delegate_factory.ipp index 72828db60..dfb6b499b 100644 --- a/include/network/protocol/http/client/connection/resolver_delegate_factory.ipp +++ b/include/network/protocol/http/client/connection/resolver_delegate_factory.ipp @@ -19,7 +19,7 @@ resolver_delegate_factory::resolver_delegate_factory() { } boost::shared_ptr -resolver_delegate_factory::create_resolver_delegate(boost::asio::io_service & service, +resolver_delegate_factory::create_resolver_delegate(asio::io_service & service, bool cache_resolved) { NETWORK_MESSAGE("resolver_delegate_factory::create_resolver_delegate(...)"); boost::shared_ptr resolver_( diff --git a/include/network/protocol/http/client/connection/simple_connection_factory.hpp b/include/network/protocol/http/client/connection/simple_connection_factory.hpp index c22fcd511..01583b27e 100644 --- a/include/network/protocol/http/client/connection/simple_connection_factory.hpp +++ b/include/network/protocol/http/client/connection/simple_connection_factory.hpp @@ -22,7 +22,7 @@ struct simple_connection_factory : connection_factory { simple_connection_factory(); simple_connection_factory(boost::shared_ptr conn_delegate_factory, boost::shared_ptr res_delegate_factory); - virtual boost::shared_ptr create_connection(boost::asio::io_service & service, + virtual boost::shared_ptr create_connection(asio::io_service & service, request_base const & request, client_options const & options); // override virtual ~simple_connection_factory(); diff --git a/include/network/protocol/http/client/connection/simple_connection_factory.ipp b/include/network/protocol/http/client/connection/simple_connection_factory.ipp index 4c206ed87..c757dbae3 100644 --- a/include/network/protocol/http/client/connection/simple_connection_factory.ipp +++ b/include/network/protocol/http/client/connection/simple_connection_factory.ipp @@ -32,7 +32,7 @@ struct simple_connection_factory_pimpl { } boost::shared_ptr create_connection( - boost::asio::io_service & service, + asio::io_service & service, request_base const & request, client_options const & options) { NETWORK_MESSAGE("simple_connection_factory_pimpl::create_connection(...)"); @@ -71,7 +71,7 @@ simple_connection_factory::simple_connection_factory(boost::shared_ptr -simple_connection_factory::create_connection(boost::asio::io_service & service, +simple_connection_factory::create_connection(asio::io_service & service, request_base const & request, client_options const &options) { NETWORK_MESSAGE("simple_connection_factory::create_connection(...)"); diff --git a/include/network/protocol/http/client/connection/ssl_delegate.hpp b/include/network/protocol/http/client/connection/ssl_delegate.hpp index 1c3e2ff3e..6d1ade81c 100644 --- a/include/network/protocol/http/client/connection/ssl_delegate.hpp +++ b/include/network/protocol/http/client/connection/ssl_delegate.hpp @@ -7,7 +7,7 @@ #ifndef NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SSL_DELEGATE_20110819 #define NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_SSL_DELEGATE_20110819 -#include +#include #include #include #include @@ -22,29 +22,29 @@ namespace network { namespace http { struct ssl_delegate : connection_delegate, boost::enable_shared_from_this { - ssl_delegate(boost::asio::io_service & service, + ssl_delegate(asio::io_service & service, client_options const &options); - virtual void connect(boost::asio::ip::tcp::endpoint & endpoint, + virtual void connect(asio::ip::tcp::endpoint & endpoint, std::string const &host, - boost::function handler); - virtual void write(boost::asio::streambuf & command_streambuf, - boost::function handler); - virtual void read_some(boost::asio::mutable_buffers_1 const & read_buffer, - boost::function handler); + std::function handler); + virtual void write(asio::streambuf & command_streambuf, + std::function handler); + virtual void read_some(asio::mutable_buffers_1 const & read_buffer, + std::function handler); ~ssl_delegate(); private: - boost::asio::io_service & service_; + asio::io_service & service_; client_options options_; - boost::scoped_ptr context_; - boost::scoped_ptr > socket_; + boost::scoped_ptr context_; + boost::scoped_ptr > socket_; ssl_delegate(ssl_delegate const &); // = delete ssl_delegate& operator=(ssl_delegate); // = delete - void handle_connected(boost::system::error_code const & ec, - boost::function handler); + void handle_connected(asio::error_code const & ec, + std::function handler); }; } // namespace http diff --git a/include/network/protocol/http/client/connection/ssl_delegate.ipp b/include/network/protocol/http/client/connection/ssl_delegate.ipp index 912c2c91b..d2efba500 100755 --- a/include/network/protocol/http/client/connection/ssl_delegate.ipp +++ b/include/network/protocol/http/client/connection/ssl_delegate.ipp @@ -9,11 +9,11 @@ #include #include -#include -#include +#include +#include #include -network::http::ssl_delegate::ssl_delegate(boost::asio::io_service & service, +network::http::ssl_delegate::ssl_delegate(asio::io_service & service, client_options const &options) : service_(service), options_(options) { @@ -21,12 +21,12 @@ network::http::ssl_delegate::ssl_delegate(boost::asio::io_service & service, } void network::http::ssl_delegate::connect( - boost::asio::ip::tcp::endpoint & endpoint, + asio::ip::tcp::endpoint & endpoint, std::string const &host, - boost::function handler) { + std::function handler) { NETWORK_MESSAGE("ssl_delegate::connect(...)"); - context_.reset(new boost::asio::ssl::context( - boost::asio::ssl::context::sslv23)); + context_.reset(new asio::ssl::context( + asio::ssl::context::sslv23)); std::list const & certificate_paths = options_.openssl_certificate_paths(); std::list const & verifier_paths = @@ -42,28 +42,29 @@ void network::http::ssl_delegate::connect( context_->add_verify_path(*it); } NETWORK_MESSAGE("verifying peer: " << host); - context_->set_verify_mode(boost::asio::ssl::context::verify_peer); - context_->set_verify_callback(boost::asio::ssl::rfc2818_verification(host)); + context_->set_verify_mode(asio::ssl::context::verify_peer); + context_->set_verify_callback(asio::ssl::rfc2818_verification(host)); } else { NETWORK_MESSAGE("not verifying peer"); context_->set_default_verify_paths(); - context_->set_verify_mode(boost::asio::ssl::context::verify_peer); - context_->set_verify_callback(boost::asio::ssl::rfc2818_verification(host)); + context_->set_verify_mode(asio::ssl::context::verify_peer); + context_->set_verify_callback(asio::ssl::rfc2818_verification(host)); } - socket_.reset(new boost::asio::ssl::stream(service_, *context_)); + socket_.reset(new asio::ssl::stream(service_, *context_)); NETWORK_MESSAGE("scheduling asynchronous connection..."); + using namespace std::placeholders; socket_->lowest_layer().async_connect( endpoint, - ::boost::bind(&network::http::ssl_delegate::handle_connected, + ::std::bind(&network::http::ssl_delegate::handle_connected, network::http::ssl_delegate::shared_from_this(), - boost::asio::placeholders::error, + _1, handler)); } void network::http::ssl_delegate::handle_connected( - boost::system::error_code const & ec, - boost::function handler) { + asio::error_code const & ec, + std::function handler) { NETWORK_MESSAGE("ssl_delegate::handle_connected(...)"); if (!ec) { NETWORK_MESSAGE("connected to endpoint."); @@ -71,7 +72,7 @@ void network::http::ssl_delegate::handle_connected( SSL_SESSION *existing_session = SSL_get1_session(socket_->impl()->ssl); if (existing_session == NULL) { NETWORK_MESSAGE("found no existing session, performing handshake."); - socket_->async_handshake(boost::asio::ssl::stream_base::client, handler); + socket_->async_handshake(asio::ssl::stream_base::client, handler); } else { NETWORK_MESSAGE("found existing session, bypassing handshake."); SSL_set_session(socket_->impl()->ssl, existing_session); @@ -85,16 +86,16 @@ void network::http::ssl_delegate::handle_connected( } void network::http::ssl_delegate::write( - boost::asio::streambuf & command_streambuf, - boost::function handler) { + asio::streambuf & command_streambuf, + std::function handler) { NETWORK_MESSAGE("ssl_delegate::write(...)"); NETWORK_MESSAGE("scheduling asynchronous write..."); - boost::asio::async_write(*socket_, command_streambuf, handler); + asio::async_write(*socket_, command_streambuf, handler); } void network::http::ssl_delegate::read_some( - boost::asio::mutable_buffers_1 const & read_buffer, - boost::function handler) { + asio::mutable_buffers_1 const & read_buffer, + std::function handler) { NETWORK_MESSAGE("ssl_delegate::read_some(...)"); NETWORK_MESSAGE("scheduling asynchronous read_some..."); socket_->async_read_some(read_buffer, handler); diff --git a/include/network/protocol/http/client/connection/sync_base.hpp b/include/network/protocol/http/client/connection/sync_base.hpp index 9d5719c92..3d1ff1cf1 100644 --- a/include/network/protocol/http/client/connection/sync_base.hpp +++ b/include/network/protocol/http/client/connection/sync_base.hpp @@ -10,10 +10,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include @@ -34,8 +34,8 @@ namespace network { namespace http { namespace impl { template void init_socket(Socket & socket_, resolver_type & resolver_, string_type const & hostname, string_type const & port, resolver_function_type resolve_) { - using boost::asio::ip::tcp; - boost::system::error_code error = boost::asio::error::host_not_found; + using asio::ip::tcp; + asio::error_code error = asio::error::host_not_found; typename resolver_type::iterator endpoint_iterator, end; boost::tie(endpoint_iterator, end) = resolve_(resolver_, hostname, port); while (error && endpoint_iterator != end) { @@ -51,12 +51,12 @@ namespace network { namespace http { namespace impl { } if (error) - throw boost::system::system_error(error); + throw std::system_error(error); } template - void read_status(Socket & socket_, basic_response & response_, boost::asio::streambuf & response_buffer) { - boost::asio::read_until(socket_, response_buffer, "\r\n"); + void read_status(Socket & socket_, basic_response & response_, asio::streambuf & response_buffer) { + asio::read_until(socket_, response_buffer, "\r\n"); std::istream response_stream(&response_buffer); string_type http_version; unsigned int status_code; @@ -76,8 +76,8 @@ namespace network { namespace http { namespace impl { } template - void read_headers(Socket & socket_, basic_response & response_, boost::asio::streambuf & response_buffer) { - boost::asio::read_until(socket_, response_buffer, "\r\n\r\n"); + void read_headers(Socket & socket_, basic_response & response_, asio::streambuf & response_buffer) { + asio::read_until(socket_, response_buffer, "\r\n\r\n"); std::istream response_stream(&response_buffer); string_type header_line, name; while (std::getline(response_stream, header_line) && header_line != "\r") { @@ -101,24 +101,24 @@ namespace network { namespace http { namespace impl { } template - void send_request_impl(Socket & socket_, string_type const & method, boost::asio::streambuf & request_buffer) { + void send_request_impl(Socket & socket_, string_type const & method, asio::streambuf & request_buffer) { write(socket_, request_buffer); } template - void read_body_normal(Socket & socket_, basic_response & response_, boost::asio::streambuf & response_buffer, typename ostringstream::type & body_stream) { - boost::system::error_code error; + void read_body_normal(Socket & socket_, basic_response & response_, asio::streambuf & response_buffer, typename ostringstream::type & body_stream) { + asio::error_code error; if (response_buffer.size() > 0) body_stream << &response_buffer; - while (boost::asio::read(socket_, response_buffer, boost::asio::transfer_at_least(1), error)) { + while (asio::read(socket_, response_buffer, asio::transfer_at_least(1), error)) { body_stream << &response_buffer; } } template - void read_body_transfer_chunk_encoding(Socket & socket_, basic_response & response_, boost::asio::streambuf & response_buffer, typename ostringstream::type & body_stream) { - boost::system::error_code error; + void read_body_transfer_chunk_encoding(Socket & socket_, basic_response & response_, asio::streambuf & response_buffer, typename ostringstream::type & body_stream) { + asio::error_code error; // look for the content-length header typename headers_range >::type content_length_range = headers(response_)["Content-Length"]; @@ -133,7 +133,7 @@ namespace network { namespace http { namespace impl { bool stopping = false; do { std::size_t chunk_size_line = read_until(socket_, response_buffer, "\r\n", error); - if ((chunk_size_line == 0) && (error != boost::asio::error::eof)) throw boost::system::system_error(error); + if ((chunk_size_line == 0) && (error != asio::error::eof)) throw std::system_error(error); std::size_t chunk_size = 0; string_type data; { @@ -144,8 +144,8 @@ namespace network { namespace http { namespace impl { } if (chunk_size == 0) { stopping = true; - if (!read_until(socket_, response_buffer, "\r\n", error) && (error != boost::asio::error::eof)) - throw boost::system::system_error(error); + if (!read_until(socket_, response_buffer, "\r\n", error) && (error != asio::error::eof)) + throw std::system_error(error); } else { bool stopping_inner = false; std::istreambuf_iterator eos; @@ -155,9 +155,9 @@ namespace network { namespace http { namespace impl { do { if (chunk_size != 0) { - std::size_t chunk_bytes_read = read(socket_, response_buffer, boost::asio::transfer_at_least(chunk_size), error); + std::size_t chunk_bytes_read = read(socket_, response_buffer, asio::transfer_at_least(chunk_size), error); if (chunk_bytes_read == 0) { - if (error != boost::asio::error::eof) throw boost::system::system_error(error); + if (error != asio::error::eof) throw std::system_error(error); stopping_inner = true; } } @@ -181,7 +181,7 @@ namespace network { namespace http { namespace impl { if ( length == 0 ) return; size_t bytes_read = 0; - while ((bytes_read = boost::asio::read(socket_, response_buffer, boost::asio::transfer_at_least(1), error))) { + while ((bytes_read = asio::read(socket_, response_buffer, asio::transfer_at_least(1), error))) { body_stream << &response_buffer; length -= bytes_read; if ((length <= 0) || error) @@ -191,7 +191,7 @@ namespace network { namespace http { namespace impl { } template - void read_body(Socket & socket_, basic_response & response_, boost::asio::streambuf & response_buffer) { + void read_body(Socket & socket_, basic_response & response_, asio::streambuf & response_buffer) { typename ostringstream::type body_stream; // TODO tag dispatch based on whether it's HTTP 1.0 or HTTP 1.1 if (version_major == 1 && version_minor == 0) { @@ -231,9 +231,9 @@ namespace network { namespace http { namespace impl { virtual void init_socket(string_type const & hostname, string_type const & port) = 0; virtual void send_request_impl(string_type const & method, basic_request const & request_) = 0; - virtual void read_status(basic_response & response_, boost::asio::streambuf & response_buffer) = 0; - virtual void read_headers(basic_response & response_, boost::asio::streambuf & response_buffer) = 0; - virtual void read_body(basic_response & response_, boost::asio::streambuf & response_buffer) = 0; + virtual void read_status(basic_response & response_, asio::streambuf & response_buffer) = 0; + virtual void read_headers(basic_response & response_, asio::streambuf & response_buffer) = 0; + virtual void read_body(basic_response & response_, asio::streambuf & response_buffer) = 0; virtual bool is_open() = 0; virtual void close_socket() = 0; virtual ~sync_connection_base() {} diff --git a/include/network/protocol/http/client/connection/sync_normal.hpp b/include/network/protocol/http/client/connection/sync_normal.hpp index 36538aa21..366a0adda 100644 --- a/include/network/protocol/http/client/connection/sync_normal.hpp +++ b/include/network/protocol/http/client/connection/sync_normal.hpp @@ -37,21 +37,21 @@ struct http_sync_connection : public virtual sync_connection_base const & request_) { - boost::asio::streambuf request_buffer; + asio::streambuf request_buffer; linearize(request_, method, version_major, version_minor, std::ostreambuf_iterator::type>(&request_buffer)); connection_base::send_request_impl(socket_, method, request_buffer); } - void read_status(basic_response & response_, boost::asio::streambuf & response_buffer) { + void read_status(basic_response & response_, asio::streambuf & response_buffer) { connection_base::read_status(socket_, response_, response_buffer); } - void read_headers(basic_response & response, boost::asio::streambuf & response_buffer) { + void read_headers(basic_response & response, asio::streambuf & response_buffer) { connection_base::read_headers(socket_, response, response_buffer); } - void read_body(basic_response & response_, boost::asio::streambuf & response_buffer) { + void read_body(basic_response & response_, asio::streambuf & response_buffer) { connection_base::read_body(socket_, response_, response_buffer); typename headers_range >::type connection_range = headers(response_)["Connection"]; @@ -66,8 +66,8 @@ struct http_sync_connection : public virtual sync_connection_base +#include namespace network { namespace http { @@ -33,39 +33,39 @@ struct https_sync_connection : public virtual sync_connection_base const & request_) { - boost::asio::streambuf request_buffer; + asio::streambuf request_buffer; linearize(request_, method, version_major, version_minor, std::ostreambuf_iterator::type>(&request_buffer)); connection_base::send_request_impl(socket_, method, request_buffer); } - void read_status(basic_response & response_, boost::asio::streambuf & response_buffer) { + void read_status(basic_response & response_, asio::streambuf & response_buffer) { connection_base::read_status(socket_, response_, response_buffer); } - void read_headers(basic_response & response_, boost::asio::streambuf & response_buffer) { + void read_headers(basic_response & response_, asio::streambuf & response_buffer) { connection_base::read_headers(socket_, response_, response_buffer); } - void read_body(basic_response & response_, boost::asio::streambuf & response_buffer) { + void read_body(basic_response & response_, asio::streambuf & response_buffer) { connection_base::read_body(socket_, response_, response_buffer); typename headers_range >::type connection_range = headers(response_)["Connection"]; @@ -81,8 +81,8 @@ struct https_sync_connection : public virtual sync_connection_base socket_; + asio::ssl::context context_; + asio::ssl::stream socket_; }; diff --git a/include/network/protocol/http/client/connection_manager.hpp b/include/network/protocol/http/client/connection_manager.hpp index c1f89e556..99d71b573 100644 --- a/include/network/protocol/http/client/connection_manager.hpp +++ b/include/network/protocol/http/client/connection_manager.hpp @@ -9,14 +9,12 @@ #include -namespace boost { namespace asio { +namespace asio { class io_service; } // namespace asio -} // namespace boost - namespace network { namespace http { @@ -26,7 +24,7 @@ class client_options; struct connection_manager { virtual boost::shared_ptr get_connection( - boost::asio::io_service & service, + asio::io_service & service, request_base const & request, client_options const & options) = 0; virtual void clear_resolved_cache() = 0; diff --git a/include/network/protocol/http/client/macros.hpp b/include/network/protocol/http/client/macros.hpp index beee2a827..83ee0ef1e 100644 --- a/include/network/protocol/http/client/macros.hpp +++ b/include/network/protocol/http/client/macros.hpp @@ -8,11 +8,11 @@ #define NETWORK_PROTOCOL_HTTP_CLIENT_MACROS_HPP_20110430 #include -#include +#include #ifndef NETWORK_HTTP_BODY_CALLBACK #define NETWORK_HTTP_BODY_CALLBACK(function_name, range_name, error_name) \ - void function_name (boost::iterator_range const & range_name, boost::system::error_code const & error_name) + void function_name (boost::iterator_range const & range_name, asio::error_code const & error_name) #endif #endif /* NETWORK_PROTOCOL_HTTP_CLIENT_MACROS_HPP_20110430 */ diff --git a/include/network/protocol/http/client/options.hpp b/include/network/protocol/http/client/options.hpp index 4605710ae..59aade63d 100644 --- a/include/network/protocol/http/client/options.hpp +++ b/include/network/protocol/http/client/options.hpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include @@ -51,8 +51,8 @@ namespace http { // The default setting when un-set is nullptr, meaning it signals the client // implementation that the user doesn't want to use his own io_service // instance. - client_options& io_service(boost::asio::io_service *io_service); - boost::asio::io_service* io_service() const; + client_options& io_service(asio::io_service *io_service); + asio::io_service* io_service() const; // The following option determines whether the client should follow // HTTP redirects when the implementation encounters them. The default diff --git a/include/network/protocol/http/client/options.ipp b/include/network/protocol/http/client/options.ipp index ae84dafbb..162e928cb 100644 --- a/include/network/protocol/http/client/options.ipp +++ b/include/network/protocol/http/client/options.ipp @@ -31,11 +31,11 @@ public: return new (std::nothrow) client_options_pimpl(*this); } - void io_service(boost::asio::io_service *io_service) { + void io_service(asio::io_service *io_service) { io_service_ = io_service_; } - boost::asio::io_service* io_service() const { + asio::io_service* io_service() const { return io_service_; } @@ -101,7 +101,7 @@ private: client_options_pimpl& operator=(client_options_pimpl); // cannot assign // Here's the list of members. - boost::asio::io_service *io_service_; + asio::io_service *io_service_; bool follow_redirects_, cache_resolved_; std::list openssl_certificate_paths_, openssl_verify_paths_; boost::shared_ptr connection_manager_; @@ -130,12 +130,12 @@ client_options::~client_options() { pimpl = 0; } -client_options& client_options::io_service(boost::asio::io_service *io_service) { +client_options& client_options::io_service(asio::io_service *io_service) { pimpl->io_service(io_service); return *this; } -boost::asio::io_service* client_options::io_service() const { +asio::io_service* client_options::io_service() const { return pimpl->io_service(); } diff --git a/include/network/protocol/http/client/pimpl.hpp b/include/network/protocol/http/client/pimpl.hpp index 624e07698..589464ffc 100644 --- a/include/network/protocol/http/client/pimpl.hpp +++ b/include/network/protocol/http/client/pimpl.hpp @@ -70,7 +70,7 @@ struct basic_client_impl : base_type(cache_resolved, follow_redirect, certificate_filename, verify_path) {} - basic_client_impl(bool cache_resolved, bool follow_redirect, boost::asio::io_service & service, optional const & certificate_filename, optional const & verify_path) + basic_client_impl(bool cache_resolved, bool follow_redirect, asio::io_service & service, optional const & certificate_filename, optional const & verify_path) : base_type(cache_resolved, follow_redirect, service, certificate_filename, verify_path) {} diff --git a/include/network/protocol/http/client/simple_connection_manager.hpp b/include/network/protocol/http/client/simple_connection_manager.hpp index d25f0f5bd..919aada71 100644 --- a/include/network/protocol/http/client/simple_connection_manager.hpp +++ b/include/network/protocol/http/client/simple_connection_manager.hpp @@ -50,7 +50,7 @@ struct simple_connection_manager : connection_manager { * or a newly constructed connection configured to perform the request. */ virtual boost::shared_ptr get_connection( - boost::asio::io_service & service, + asio::io_service & service, request_base const & request, client_options const & options); // override diff --git a/include/network/protocol/http/client/simple_connection_manager.ipp b/include/network/protocol/http/client/simple_connection_manager.ipp index 90929264e..3bdd2c481 100644 --- a/include/network/protocol/http/client/simple_connection_manager.ipp +++ b/include/network/protocol/http/client/simple_connection_manager.ipp @@ -29,7 +29,7 @@ struct simple_connection_manager_pimpl { } } - boost::shared_ptr get_connection(boost::asio::io_service & service, + boost::shared_ptr get_connection(asio::io_service & service, request_base const & request, client_options const &options) { NETWORK_MESSAGE("simple_connection_manager_pimpl::get_connection(...)"); @@ -62,7 +62,7 @@ simple_connection_manager::simple_connection_manager(client_options const &optio } boost::shared_ptr simple_connection_manager::get_connection( - boost::asio::io_service & service, + asio::io_service & service, request_base const & request, client_options const &options) { NETWORK_MESSAGE("simple_connection_manager::get_connection(...)"); diff --git a/include/network/protocol/http/client/sync_impl.hpp b/include/network/protocol/http/client/sync_impl.hpp index d95122e88..2472103fe 100644 --- a/include/network/protocol/http/client/sync_impl.hpp +++ b/include/network/protocol/http/client/sync_impl.hpp @@ -24,8 +24,8 @@ struct sync_client : typedef function const &, system::error_code const &)> body_callback_function_type; friend struct basic_client_impl; - boost::asio::io_service * service_ptr; - boost::asio::io_service & service_; + asio::io_service * service_ptr; + asio::io_service & service_; resolver_type resolver_; optional certificate_file, verify_path; @@ -34,14 +34,14 @@ struct sync_client : , optional const & verify_path = optional() ) : connection_base(cache_resolved, follow_redirect), - service_ptr(new boost::asio::io_service), + service_ptr(new asio::io_service), service_(*service_ptr), resolver_(service_) , certificate_file(certificate_file) , verify_path(verify_path) {} - sync_client(bool cache_resolved, bool follow_redirect, boost::asio::io_service & service + sync_client(bool cache_resolved, bool follow_redirect, asio::io_service & service , optional const & certificate_file = optional() , optional const & verify_path = optional() ) diff --git a/include/network/protocol/http/impl/access.hpp b/include/network/protocol/http/impl/access.hpp index 76c6e5407..8a8001f62 100644 --- a/include/network/protocol/http/impl/access.hpp +++ b/include/network/protocol/http/impl/access.hpp @@ -7,7 +7,9 @@ #ifndef NETWORK_PROTOCOL_HTTP_IMPL_ACCESS_HPP_20111202 #define NETWORK_PROTOCOL_HTTP_IMPL_ACCESS_HPP_20111202 -#include +#include +#include +#include namespace network { namespace http { @@ -17,13 +19,13 @@ struct response; namespace impl { struct setter_access { - void set_version_promise(response &r, boost::promise &p); - void set_status_promise(response &r, boost::promise &p); - void set_status_message_promise(response &r, boost::promise&p); - void set_headers_promise(response &r, boost::promise > &p); - void set_source_promise(response &r, boost::promise &p); - void set_destination_promise(response &r, boost::promise &p); - void set_body_promise(response &r, boost::promise &p); + void set_version_promise(response &r, std::promise &p); + void set_status_promise(response &r, std::promise &p); + void set_status_message_promise(response &r, std::promise&p); + void set_headers_promise(response &r, std::promise > &p); + void set_source_promise(response &r, std::promise &p); + void set_destination_promise(response &r, std::promise &p); + void set_body_promise(response &r, std::promise &p); }; } // namespace impl diff --git a/include/network/protocol/http/impl/access.ipp b/include/network/protocol/http/impl/access.ipp index 0199fcb83..2e12c4a14 100644 --- a/include/network/protocol/http/impl/access.ipp +++ b/include/network/protocol/http/impl/access.ipp @@ -10,32 +10,32 @@ namespace network { namespace http { namespace impl { -void setter_access::set_version_promise(response &r, boost::promise &p) { +void setter_access::set_version_promise(response &r, std::promise &p) { return r.set_version_promise(p); } -void setter_access::set_status_promise(response &r, boost::promise &p) { +void setter_access::set_status_promise(response &r, std::promise &p) { return r.set_status_promise(p); } -void setter_access::set_status_message_promise(response &r, boost::promise &p) { +void setter_access::set_status_message_promise(response &r, std::promise &p) { return r.set_status_message_promise(p); } void -setter_access::set_headers_promise(response &r, boost::promise > &p) { +setter_access::set_headers_promise(response &r, std::promise > &p) { return r.set_headers_promise(p); } -void setter_access::set_source_promise(response &r, boost::promise &p) { +void setter_access::set_source_promise(response &r, std::promise &p) { return r.set_source_promise(p); } -void setter_access::set_destination_promise(response &r, boost::promise &p) { +void setter_access::set_destination_promise(response &r, std::promise &p) { return r.set_destination_promise(p); } -void setter_access::set_body_promise(response &r, boost::promise &p) { +void setter_access::set_body_promise(response &r, std::promise &p) { return r.set_body_promise(p); } diff --git a/include/network/protocol/http/impl/response.ipp b/include/network/protocol/http/impl/response.ipp index ca91e5012..194640689 100644 --- a/include/network/protocol/http/impl/response.ipp +++ b/include/network/protocol/http/impl/response.ipp @@ -14,7 +14,7 @@ #ifndef NETWORK_PROTOCOL_HTTP_IMPL_RESPONSE_RESPONSE_IPP #define NETWORK_PROTOCOL_HTTP_IMPL_RESPONSE_RESPONSE_IPP -#include +#include #include #include @@ -53,10 +53,10 @@ struct basic_response : response_base { /// Convert the reply into a vector of buffers. The buffers do not own the /// underlying memory blocks, therefore the reply object must remain valid and /// not be changed until the write operation has completed. - std::vector to_buffers() { + std::vector to_buffers() { // FIXME: Rethink this and do this asynchronously. - using boost::asio::const_buffer; - using boost::asio::buffer; + using asio::const_buffer; + using asio::buffer; static const char name_value_separator[] = { ':', ' ' }; static const char crlf[] = { '\r', '\n' }; std::vector buffers; @@ -231,8 +231,8 @@ struct basic_response : response_base { } } - boost::asio::const_buffer to_buffer(status_type status) { - using boost::asio::buffer; + asio::const_buffer to_buffer(status_type status) { + using asio::buffer; static const String ok = "HTTP/1.0 200 OK\r\n"; static const String created = diff --git a/include/network/protocol/http/message/async_message.hpp b/include/network/protocol/http/message/async_message.hpp index b161887cf..bd7d81ed7 100644 --- a/include/network/protocol/http/message/async_message.hpp +++ b/include/network/protocol/http/message/async_message.hpp @@ -9,7 +9,7 @@ #ifndef NETWORK_PROTOCOL_HTTP_MESSAGE_ASYNC_MESSAGE_HPP_20100622 #define NETWORK_PROTOCOL_HTTP_MESSAGE_ASYNC_MESSAGE_HPP_20100622 -#include +#include #include #include diff --git a/include/network/protocol/http/message/directives/status.hpp b/include/network/protocol/http/message/directives/status.hpp index 4afc7e438..9b163c962 100644 --- a/include/network/protocol/http/message/directives/status.hpp +++ b/include/network/protocol/http/message/directives/status.hpp @@ -8,7 +8,7 @@ #ifndef NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_STATUS_HPP_20100603 #define NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_STATUS_HPP_20100603 -#include +#include #include #include #include diff --git a/include/network/protocol/http/policies/async_connection.hpp b/include/network/protocol/http/policies/async_connection.hpp index bb507a63c..4df97bfe0 100644 --- a/include/network/protocol/http/policies/async_connection.hpp +++ b/include/network/protocol/http/policies/async_connection.hpp @@ -15,8 +15,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/include/network/protocol/http/policies/async_connection.ipp b/include/network/protocol/http/policies/async_connection.ipp index afcab52c2..973648f4d 100644 --- a/include/network/protocol/http/policies/async_connection.ipp +++ b/include/network/protocol/http/policies/async_connection.ipp @@ -72,7 +72,7 @@ network::http::simple_async_connection_manager(bool cache_resolved, boost::shared_ptr network::http::simple_async_connection_manager::get_connection( - boost::asio::io_service & service, + asio::io_service & service, request_base const & request) { // TODO move out calls to new to a factory, taken as a parameter at // construction time so that we are not tied to actual hard-coded diff --git a/include/network/protocol/http/request/request.hpp b/include/network/protocol/http/request/request.hpp index 6d5b3ef42..60758f960 100644 --- a/include/network/protocol/http/request/request.hpp +++ b/include/network/protocol/http/request/request.hpp @@ -41,18 +41,18 @@ struct request : request_base { // Retrievers virtual void get_destination(std::string & destination) const; virtual void get_source(std::string & source) const; - virtual void get_headers(boost::function inserter) const; - virtual void get_headers(std::string const & name, boost::function inserter) const; - virtual void get_headers(boost::function predicate, boost::function inserter) const; + virtual void get_headers(std::function inserter) const; + virtual void get_headers(std::string const & name, std::function inserter) const; + virtual void get_headers(std::function predicate, std::function inserter) const; virtual void get_body(std::string & body) const; - virtual void get_body(boost::function)> chunk_reader, size_t size) const; + virtual void get_body(std::function)> chunk_reader, size_t size) const; // From request_base... // Setters virtual void set_method(std::string const & method); virtual void set_status(std::string const & status); virtual void set_status_message(std::string const & status_message); - virtual void set_body_writer(boost::function writer); + virtual void set_body_writer(std::function writer); virtual void set_uri(std::string const &uri); virtual void set_uri(::network::uri const &uri); virtual void set_version_major(unsigned short major_version); @@ -64,7 +64,7 @@ struct request : request_base { virtual void get_method(std::string & method) const; virtual void get_status(std::string & status) const; virtual void get_status_message(std::string & status_message) const; - virtual void get_body(boost::function chunk_reader) const; + virtual void get_body(std::function chunk_reader) const; virtual void get_body(std::string const & body) const; virtual void get_version_major(unsigned short &major_version); virtual void get_version_minor(unsigned short &minor_version); diff --git a/include/network/protocol/http/request/request.ipp b/include/network/protocol/http/request/request.ipp index 5cf5a558a..f50a65d0a 100644 --- a/include/network/protocol/http/request/request.ipp +++ b/include/network/protocol/http/request/request.ipp @@ -66,8 +66,8 @@ struct request_pimpl { headers_.insert(std::make_pair(name, value)); } - void get_headers(boost::function predicate, - boost::function inserter) const { + void get_headers(std::function predicate, + std::function inserter) const { headers_type::const_iterator it = headers_.begin(); for (; it != headers_.end(); ++it) { if (predicate(it->first, it->second)) { @@ -76,7 +76,7 @@ struct request_pimpl { } } - void get_headers(boost::function inserter) const { + void get_headers(std::function inserter) const { headers_type::const_iterator it = headers_.begin(); for (; it != headers_.end(); ++it) { inserter(it->first, it->second); @@ -84,7 +84,7 @@ struct request_pimpl { } void get_headers(std::string const &name, - boost::function inserter) const { + std::function inserter) const { headers_type::const_iterator it = headers_.begin(); for (; it != headers_.end(); ++it) { if (it->first == name) { @@ -233,15 +233,15 @@ void request::get_source(std::string & source) const { pimpl_->get_source(source); } -void request::get_headers(boost::function inserter) const { +void request::get_headers(std::function inserter) const { pimpl_->get_headers(inserter); } -void request::get_headers(std::string const & name, boost::function inserter) const { +void request::get_headers(std::string const & name, std::function inserter) const { pimpl_->get_headers(name, inserter); } -void request::get_headers(boost::function predicate, boost::function inserter) const { +void request::get_headers(std::function predicate, std::function inserter) const { pimpl_->get_headers(predicate, inserter); } @@ -249,7 +249,7 @@ void request::get_body(std::string & body) const { this->flatten(body); } -void request::get_body(boost::function)> chunk_reader, size_t size) const { +void request::get_body(std::function)> chunk_reader, size_t size) const { boost::scoped_array local_buffer(new (std::nothrow) char[size]); size_t bytes_read = this->read(local_buffer.get(), pimpl_->read_offset(), @@ -271,7 +271,7 @@ void request::set_status(std::string const & status) { void request::set_status_message(std::string const & status_message) { } -void request::set_body_writer(boost::function writer) { +void request::set_body_writer(std::function writer) { } void request::set_uri(std::string const &uri) { @@ -316,7 +316,7 @@ void request::get_status(std::string & status) const { void request::get_status_message(std::string & status_message) const { } -void request::get_body(boost::function chunk_reader) const { +void request::get_body(std::function chunk_reader) const { } void request::get_body(std::string const & body) const { diff --git a/include/network/protocol/http/request/request_base.hpp b/include/network/protocol/http/request/request_base.hpp index c0e1f68e4..0b0b0ebc1 100644 --- a/include/network/protocol/http/request/request_base.hpp +++ b/include/network/protocol/http/request/request_base.hpp @@ -44,7 +44,7 @@ struct request_base : message_base, request_storage_base { virtual void set_method(std::string const & method) = 0; virtual void set_status(std::string const & status) = 0; virtual void set_status_message(std::string const & status_message) = 0; - virtual void set_body_writer(boost::function writer) = 0; + virtual void set_body_writer(std::function writer) = 0; virtual void set_uri(std::string const &uri) = 0; virtual void set_uri(::network::uri const &uri) = 0; @@ -54,7 +54,7 @@ struct request_base : message_base, request_storage_base { virtual void get_method(std::string & method) const = 0; virtual void get_status(std::string & status) const = 0; virtual void get_status_message(std::string & status_message) const = 0; - virtual void get_body(boost::function chunk_reader) const = 0; + virtual void get_body(std::function chunk_reader) const = 0; virtual void get_body(std::string const & body) const = 0; virtual ~request_base() = 0; }; diff --git a/include/network/protocol/http/response/response.hpp b/include/network/protocol/http/response/response.hpp index 3254fa8c6..370662020 100644 --- a/include/network/protocol/http/response/response.hpp +++ b/include/network/protocol/http/response/response.hpp @@ -36,16 +36,16 @@ struct response : response_base { virtual void get_destination(std::string & destination) const; virtual void get_source(std::string & source) const; virtual void get_headers( - boost::function inserter) const; + std::function inserter) const; virtual void get_headers( std::string const & name, - boost::function inserter) const; + std::function inserter) const; virtual void get_headers( - boost::function predicate, - boost::function inserter) const; + std::function predicate, + std::function inserter) const; virtual void get_body(std::string & body) const; virtual void get_body( - boost::function)> chunk_reader, + std::function)> chunk_reader, size_t size) const; // From response_base... @@ -61,13 +61,13 @@ struct response : response_base { friend struct impl::setter_access; // Hide access through accessor class. // These methods are unique to the response type which will allow for creating // promises that can be set appropriately. - void set_version_promise(boost::promise&); - void set_status_promise(boost::promise&); - void set_status_message_promise(boost::promise&); - void set_headers_promise(boost::promise >&); - void set_source_promise(boost::promise&); - void set_destination_promise(boost::promise&); - void set_body_promise(boost::promise&); + void set_version_promise(std::promise&); + void set_status_promise(std::promise&); + void set_status_message_promise(std::promise&); + void set_headers_promise(std::promise >&); + void set_source_promise(std::promise&); + void set_destination_promise(std::promise&); + void set_body_promise(std::promise&); response_pimpl *pimpl_; }; diff --git a/include/network/protocol/http/response/response.ipp b/include/network/protocol/http/response/response.ipp index 0c8d7c519..f85e23df7 100644 --- a/include/network/protocol/http/response/response.ipp +++ b/include/network/protocol/http/response/response.ipp @@ -20,14 +20,14 @@ struct response_pimpl { } void set_destination(std::string const &destination) { - boost::promise destination_promise; + std::promise destination_promise; destination_promise.set_value(destination); - boost::unique_future tmp_future = destination_promise.get_future(); - destination_future_ = boost::move(tmp_future); + std::future tmp_future = destination_promise.get_future(); + destination_future_ = std::move(tmp_future); } void get_destination(std::string &destination) { - if (destination_future_.get_state() == boost::future_state::uninitialized) { + if (!destination_future_.valid()) { destination = ""; } else { destination = destination_future_.get(); @@ -35,14 +35,13 @@ struct response_pimpl { } void set_source(std::string const &source) { - boost::promise source_promise; + std::promise source_promise; source_promise.set_value(source); - boost::unique_future tmp_future = source_promise.get_future(); - source_future_ = boost::move(tmp_future); + source_future_ = source_promise.get_future().share(); } void get_source(std::string &source) { - if (source_future_.get_state() == boost::future_state::uninitialized) { + if (!source_future_.valid()) { source = ""; } else { source = source_future_.get(); @@ -59,21 +58,21 @@ struct response_pimpl { } void remove_headers() { - if (headers_future_.get_state() == boost::future_state::uninitialized) { - boost::promise > headers_promise; + if (!headers_future_.valid()) { + std::promise > headers_promise; headers_promise.set_value(std::multimap()); - boost::unique_future > tmp = + std::future > tmp = headers_promise.get_future(); std::multimap().swap(added_headers_); std::set().swap(removed_headers_); - headers_future_ = boost::move(tmp); + headers_future_ = std::move(tmp); } } void get_headers( - boost::function inserter) { + std::function inserter) { std::multimap::const_iterator it; - if (headers_future_.get_state() == boost::future_state::uninitialized) { + if (!headers_future_.valid()) { it = added_headers_.begin(); for (;it != added_headers_.end(); ++it) { if (removed_headers_.find(it->first) == removed_headers_.end()) { @@ -93,22 +92,22 @@ struct response_pimpl { } void get_headers( std::string const & name, - boost::function inserter) { /* FIXME: Do something! */ } + std::function inserter) { /* FIXME: Do something! */ } void get_headers( - boost::function predicate, - boost::function inserter) { /* FIXME: Do something! */ } + std::function predicate, + std::function inserter) { /* FIXME: Do something! */ } void set_body(std::string const &body) { - boost::promise body_promise; + std::promise body_promise; body_promise.set_value(body); - boost::unique_future tmp_future = body_promise.get_future(); - body_future_ = boost::move(tmp_future); + std::future tmp_future = body_promise.get_future(); + body_future_ = std::move(tmp_future); } void append_body(std::string const & data) { /* FIXME: Do something! */ } void get_body(std::string &body) { - if (body_future_.get_state() == boost::future_state::uninitialized) { + if (!body_future_.valid()) { body = ""; } else { body = body_future_.get(); @@ -116,18 +115,18 @@ struct response_pimpl { } void get_body( - boost::function)> chunk_reader, + std::function)> chunk_reader, size_t size) { /* FIXME: Do something! */ } void set_status(boost::uint16_t status) { - boost::promise status_promise; + std::promise status_promise; status_promise.set_value(status); - boost::unique_future tmp_future = status_promise.get_future(); - status_future_ = boost::move(tmp_future); + std::future tmp_future = status_promise.get_future(); + status_future_ = std::move(tmp_future); } void get_status(boost::uint16_t &status) { - if (status_future_.get_state() == boost::future_state::uninitialized) { + if (!status_future_.valid()) { status = 0u; } else { status = status_future_.get(); @@ -135,14 +134,14 @@ struct response_pimpl { } void set_status_message(std::string const &status_message) { - boost::promise status_message_promise_; + std::promise status_message_promise_; status_message_promise_.set_value(status_message); - boost::unique_future tmp_future = status_message_promise_.get_future(); - status_message_future_ = boost::move(tmp_future); + std::future tmp_future = status_message_promise_.get_future(); + status_message_future_ = std::move(tmp_future); } void get_status_message(std::string &status_message) { - if (status_message_future_.get_state() == boost::future_state::uninitialized) { + if (!status_message_future_.valid()) { status_message = ""; } else { status_message = status_message_future_.get(); @@ -150,117 +149,117 @@ struct response_pimpl { } void set_version(std::string const &version) { - boost::promise version_promise; + std::promise version_promise; version_promise.set_value(version); - boost::unique_future tmp_future = version_promise.get_future(); - version_future_ = boost::move(tmp_future); + std::future tmp_future = version_promise.get_future(); + version_future_ = std::move(tmp_future); } void get_version(std::string &version) { - if (version_future_.get_state() == boost::future_state::uninitialized) { + if (!version_future_.valid()) { version = ""; } else { version = version_future_.get(); } } - void set_source_promise(boost::promise &promise_) { - boost::unique_future tmp_future = promise_.get_future(); - source_future_ = boost::move(tmp_future); + void set_source_promise(std::promise &promise_) { + std::future tmp_future = promise_.get_future(); + source_future_ = std::move(tmp_future); } - void set_destination_promise(boost::promise &promise_) { - boost::unique_future tmp_future = promise_.get_future(); - destination_future_ = boost::move(tmp_future); + void set_destination_promise(std::promise &promise_) { + std::future tmp_future = promise_.get_future(); + destination_future_ = std::move(tmp_future); } - void set_headers_promise(boost::promise > &promise_) { - boost::unique_future > tmp_future = promise_.get_future(); - headers_future_ = boost::move(tmp_future); + void set_headers_promise(std::promise > &promise_) { + std::future > tmp_future = promise_.get_future(); + headers_future_ = std::move(tmp_future); } - void set_status_promise(boost::promise &promise_) { - boost::unique_future tmp_future = promise_.get_future(); - status_future_ = boost::move(tmp_future); + void set_status_promise(std::promise &promise_) { + std::future tmp_future = promise_.get_future(); + status_future_ = std::move(tmp_future); } - void set_status_message_promise(boost::promise &promise_) { - boost::unique_future tmp_future = promise_.get_future(); - status_message_future_ = boost::move(tmp_future); + void set_status_message_promise(std::promise &promise_) { + std::future tmp_future = promise_.get_future(); + status_message_future_ = std::move(tmp_future); } - void set_version_promise(boost::promise &promise_) { - boost::unique_future tmp_future = promise_.get_future(); - version_future_ = boost::move(tmp_future); + void set_version_promise(std::promise &promise_) { + std::future tmp_future = promise_.get_future(); + version_future_ = std::move(tmp_future); } - void set_body_promise(boost::promise &promise_) { - boost::unique_future tmp_future = promise_.get_future(); - body_future_ = boost::move(tmp_future); + void set_body_promise(std::promise &promise_) { + std::future tmp_future = promise_.get_future(); + body_future_ = std::move(tmp_future); } bool equals(response_pimpl const &other) { - if (source_future_.get_state() != boost::future_state::uninitialized) { - if (other.source_future_.get_state() == boost::future_state::uninitialized) + if (source_future_.valid()) { + if (!other.source_future_.valid()) return false; if (source_future_.get() != other.source_future_.get()) return false; } else { - if (other.source_future_.get_state() != boost::future_state::uninitialized) + if (other.source_future_.valid()) return false; } - if (destination_future_.get_state() != boost::future_state::uninitialized) { - if (other.destination_future_.get_state() == boost::future_state::uninitialized) + if (destination_future_.valid()) { + if (!other.destination_future_.valid()) return false; if (destination_future_.get() != other.destination_future_.get()) return false; } else { - if (other.destination_future_.get_state() != boost::future_state::uninitialized) + if (other.destination_future_.valid()) return false; } - if (headers_future_.get_state() != boost::future_state::uninitialized) { - if (other.headers_future_.get_state() == boost::future_state::uninitialized) + if (headers_future_.valid()) { + if (!other.headers_future_.valid()) return false; if (headers_future_.get() != other.headers_future_.get()) return false; } else { - if (other.headers_future_.get_state() != boost::future_state::uninitialized) + if (other.headers_future_.valid()) return false; } - if (status_future_.get_state() != boost::future_state::uninitialized) { - if (other.status_future_.get_state() == boost::future_state::uninitialized) + if (status_future_.valid()) { + if (!other.status_future_.valid()) return false; if (status_future_.get() != other.status_future_.get()) return false; } else { - if (other.status_future_.get_state() != boost::future_state::uninitialized) + if (other.status_future_.valid()) return false; } - if (status_message_future_.get_state() != boost::future_state::uninitialized) { - if (other.status_message_future_.get_state() == boost::future_state::uninitialized) + if (status_message_future_.valid()) { + if (!other.status_message_future_.valid()) return false; if (status_message_future_.get() != other.status_message_future_.get()) return false; } else { - if (other.status_message_future_.get_state() != boost::future_state::uninitialized) + if (other.status_message_future_.valid()) return false; } - if (version_future_.get_state() != boost::future_state::uninitialized) { - if (other.version_future_.get_state() == boost::future_state::uninitialized) + if (version_future_.valid()) { + if (!other.version_future_.valid()) return false; if (version_future_.get() != other.version_future_.get()) return false; } else { - if (other.version_future_.get_state() != boost::future_state::uninitialized) + if (other.version_future_.valid()) return false; } - if (body_future_.get_state() != boost::future_state::uninitialized) { - if (other.body_future_.get_state() == boost::future_state::uninitialized) + if (body_future_.valid()) { + if (!other.body_future_.valid()) return false; if (body_future_.get() != other.body_future_.get()) return false; } else { - if (other.body_future_.get_state() != boost::future_state::uninitialized) + if (other.body_future_.valid()) return false; } if (other.added_headers_ != added_headers_ || other.removed_headers_ != removed_headers_) @@ -269,14 +268,14 @@ struct response_pimpl { } private: - mutable boost::shared_future source_future_; - mutable boost::shared_future destination_future_; - mutable boost::shared_future > + mutable std::shared_future source_future_; + mutable std::shared_future destination_future_; + mutable std::shared_future > headers_future_; - mutable boost::shared_future status_future_; - mutable boost::shared_future status_message_future_; - mutable boost::shared_future version_future_; - mutable boost::shared_future body_future_; + mutable std::shared_future status_future_; + mutable std::shared_future status_message_future_; + mutable std::shared_future version_future_; + mutable std::shared_future body_future_; // TODO: use unordered_map and unordered_set here. std::multimap added_headers_; std::set removed_headers_; @@ -352,17 +351,17 @@ void response::get_source(std::string &source) const { pimpl_->get_source(source); } -void response::get_headers(boost::function inserter) const { +void response::get_headers(std::function inserter) const { pimpl_->get_headers(inserter); } void response::get_headers(std::string const &name, - boost::function inserter) const { + std::function inserter) const { pimpl_->get_headers(name, inserter); } -void response::get_headers(boost::function predicate, - boost::function inserter) const { +void response::get_headers(std::function predicate, + std::function inserter) const { pimpl_->get_headers(predicate, inserter); } @@ -370,7 +369,7 @@ void response::get_body(std::string &body) const { pimpl_->get_body(body); } -void response::get_body(boost::function)> chunk_reader, size_t size) const { +void response::get_body(std::function)> chunk_reader, size_t size) const { pimpl_->get_body(chunk_reader, size); } @@ -402,31 +401,31 @@ response::~response() { delete pimpl_; } -void response::set_version_promise(boost::promise &promise) { +void response::set_version_promise(std::promise &promise) { return pimpl_->set_version_promise(promise); } -void response::set_status_promise(boost::promise &promise) { +void response::set_status_promise(std::promise &promise) { return pimpl_->set_status_promise(promise); } -void response::set_status_message_promise(boost::promise &promise) { +void response::set_status_message_promise(std::promise &promise) { return pimpl_->set_status_message_promise(promise); } -void response::set_headers_promise(boost::promise > &promise) { +void response::set_headers_promise(std::promise > &promise) { return pimpl_->set_headers_promise(promise); } -void response::set_source_promise(boost::promise &promise) { +void response::set_source_promise(std::promise &promise) { return pimpl_->set_source_promise(promise); } -void response::set_destination_promise(boost::promise &promise) { +void response::set_destination_promise(std::promise &promise) { return pimpl_->set_destination_promise(promise); } -void response::set_body_promise(boost::promise &promise) { +void response::set_body_promise(std::promise &promise) { return pimpl_->set_body_promise(promise); } diff --git a/include/network/protocol/http/response/response_base.hpp b/include/network/protocol/http/response/response_base.hpp index 6a5591149..f34c34028 100644 --- a/include/network/protocol/http/response/response_base.hpp +++ b/include/network/protocol/http/response/response_base.hpp @@ -12,10 +12,10 @@ namespace network { namespace http { struct response_base : message_base { - virtual void set_status(boost::uint16_t new_status) = 0; + virtual void set_status(std::uint16_t new_status) = 0; virtual void set_status_message(std::string const & new_status_message) = 0; virtual void set_version(std::string const & new_version) = 0; - virtual void get_status(boost::uint16_t &status) const = 0; + virtual void get_status(std::uint16_t &status) const = 0; virtual void get_status_message(std::string &status_message) const = 0; virtual void get_version(std::string &version) const = 0; virtual ~response_base() = 0; diff --git a/include/network/protocol/http/server/async_impl.hpp b/include/network/protocol/http/server/async_impl.hpp index 32f139cb3..334711a92 100644 --- a/include/network/protocol/http/server/async_impl.hpp +++ b/include/network/protocol/http/server/async_impl.hpp @@ -7,9 +7,9 @@ #ifndef NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_IMPL_20120318 #define NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_IMPL_20120318 -#include +#include #include -#include +#include #include #include #include @@ -32,7 +32,7 @@ class async_server_impl : protected socket_options_setter { public: typedef boost::shared_ptr connection_ptr; async_server_impl(server_options const &options, - boost::function handler, + std::function handler, utils::thread_pool &thread_pool); ~async_server_impl(); void run(); @@ -42,17 +42,17 @@ class async_server_impl : protected socket_options_setter { private: server_options options_; std::string address_, port_; - boost::asio::io_service *service_; - boost::asio::ip::tcp::acceptor *acceptor_; + asio::io_service *service_; + asio::ip::tcp::acceptor *acceptor_; boost::shared_ptr new_connection_; boost::mutex listening_mutex_, stopping_mutex_; - boost::function handler_; + std::function handler_; utils::thread_pool &pool_; bool listening_, owned_service_, stopping_; void handle_stop(); void start_listening(); - void handle_accept(boost::system::error_code const &ec); + void handle_accept(asio::error_code const &ec); }; } // namespace http diff --git a/include/network/protocol/http/server/async_impl.ipp b/include/network/protocol/http/server/async_impl.ipp index d6b462e4f..0eae8f567 100644 --- a/include/network/protocol/http/server/async_impl.ipp +++ b/include/network/protocol/http/server/async_impl.ipp @@ -9,16 +9,16 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include namespace network { namespace http { async_server_impl::async_server_impl(server_options const &options, - boost::function handler, + std::function handler, utils::thread_pool &thread_pool) : options_(options) , address_(options.address()) @@ -34,11 +34,11 @@ async_server_impl::async_server_impl(server_options const &options, , owned_service_(false) , stopping_(false) { if (service_ == 0) { - service_ = new (std::nothrow) boost::asio::io_service; + service_ = new (std::nothrow) asio::io_service; owned_service_ = true; } BOOST_ASSERT(service_ != 0); - acceptor_ = new (std::nothrow) boost::asio::ip::tcp::acceptor(*service_); + acceptor_ = new (std::nothrow) asio::ip::tcp::acceptor(*service_); BOOST_ASSERT(acceptor_ != 0); } @@ -57,11 +57,11 @@ void async_server_impl::stop() { if (listening_) { boost::lock_guard stopping_lock(stopping_mutex_); stopping_ = true; - boost::system::error_code ignored; + asio::error_code ignored; acceptor_->close(ignored); listening_ = false; service_->post( - boost::bind(&async_server_impl::handle_stop, this)); + std::bind(&async_server_impl::handle_stop, this)); } } @@ -82,7 +82,7 @@ void async_server_impl::handle_stop() { if (stopping_) service_->stop(); } -void async_server_impl::handle_accept(boost::system::error_code const & ec) { +void async_server_impl::handle_accept(asio::error_code const & ec) { { boost::lock_guard stopping_lock(stopping_mutex_); // We dont want to add another handler instance, and we dont want to know @@ -96,18 +96,18 @@ void async_server_impl::handle_accept(boost::system::error_code const & ec) { new async_server_connection(*service_, handler_, pool_)); acceptor_->async_accept( new_connection_->socket(), - boost::bind( + std::bind( &async_server_impl::handle_accept, this, - boost::asio::placeholders::error)); + asio::placeholders::error)); } else { NETWORK_MESSAGE("Error accepting connection, reason: " << ec); } } void async_server_impl::start_listening() { - using boost::asio::ip::tcp; - boost::system::error_code error; + using asio::ip::tcp; + asio::error_code error; service_->reset(); // allows repeated cycles of run->stop->run tcp::resolver resolver(*service_); tcp::resolver::query query(address_, port_); @@ -128,7 +128,7 @@ void async_server_impl::start_listening() { NETWORK_MESSAGE("error binding socket: " << address_ << ":" << port_); BOOST_THROW_EXCEPTION(std::runtime_error("Error binding socket.")); } - acceptor_->listen(boost::asio::socket_base::max_connections, error); + acceptor_->listen(asio::socket_base::max_connections, error); if (error) { NETWORK_MESSAGE("error listening on socket: '" << error << "' on " << address_ << ":" << port_); BOOST_THROW_EXCEPTION(std::runtime_error("Error listening on socket.")); @@ -136,10 +136,10 @@ void async_server_impl::start_listening() { new_connection_.reset(new async_server_connection(*service_, handler_, pool_)); acceptor_->async_accept( new_connection_->socket(), - boost::bind( + std::bind( &async_server_impl::handle_accept, this, - boost::asio::placeholders::error)); + asio::placeholders::error)); listening_ = true; boost::lock_guard stopping_lock(stopping_mutex_); stopping_ = false; // if we were in the process of stopping, we revoke that command and continue listening diff --git a/include/network/protocol/http/server/async_server.hpp b/include/network/protocol/http/server/async_server.hpp index b87896804..d0bb4eb86 100644 --- a/include/network/protocol/http/server/async_server.hpp +++ b/include/network/protocol/http/server/async_server.hpp @@ -65,7 +65,7 @@ namespace network { namespace http { system::error_code ignored; acceptor.close(ignored); listening = false; - service_.post(boost::bind(&async_server_base::handle_stop, this)); + service_.post(std::bind(&async_server_base::handle_stop, this)); } } @@ -95,7 +95,7 @@ namespace network { namespace http { if (stopping) service_.stop(); // a user may have started listening again before the stop command is reached } - void handle_accept(boost::system::error_code const & ec) { + void handle_accept(asio::error_code const & ec) { { scoped_mutex_lock stopping_lock(stopping_mutex_); if (stopping) return; // we dont want to add another handler instance, and we dont want to know about errors for a socket we dont need anymore @@ -111,10 +111,10 @@ namespace network { namespace http { ) ); acceptor.async_accept(new_connection->socket(), - boost::bind( + std::bind( &async_server_base::handle_accept , this - , boost::asio::placeholders::error + , asio::placeholders::error ) ); } else { @@ -123,7 +123,7 @@ namespace network { namespace http { } void start_listening() { - using boost::asio::ip::tcp; + using asio::ip::tcp; system::error_code error; @@ -155,10 +155,10 @@ namespace network { namespace http { } new_connection.reset(new connection(service_, handler, thread_pool)); acceptor.async_accept(new_connection->socket(), - boost::bind( + std::bind( &async_server_base::handle_accept , this - , boost::asio::placeholders::error)); + , asio::placeholders::error)); listening = true; scoped_mutex_lock stopping_lock(stopping_mutex_); stopping = false; // if we were in the process of stopping, we revoke that command and continue listening diff --git a/include/network/protocol/http/server/connection/async.hpp b/include/network/protocol/http/server/connection/async.hpp index 63dc90f1b..c5ada55e4 100644 --- a/include/network/protocol/http/server/connection/async.hpp +++ b/include/network/protocol/http/server/connection/async.hpp @@ -15,24 +15,23 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include #include #include #include -#include -#include -#include -#include +#include +#include #include #include #include +#include #include #ifndef NETWORK_HTTP_SERVER_CONNECTION_HEADER_BUFFER_MAX_SIZE @@ -63,7 +62,7 @@ namespace network { namespace http { extern void parse_version(std::string const & partial_parsed, boost::fusion::tuple & version_pair); extern void parse_headers(std::string const & input, std::vector > & container); - class async_server_connection : public boost::enable_shared_from_this { + class async_server_connection : public std::enable_shared_from_this { public: enum status_t { ok = 200 @@ -87,7 +86,7 @@ namespace network { namespace http { }; typedef std::string string_type; - typedef boost::shared_ptr connection_ptr; + typedef std::shared_ptr connection_ptr; private: static char const * status_message(status_t status) { @@ -138,8 +137,8 @@ namespace network { namespace http { public: async_server_connection( - boost::asio::io_service & io_service - , boost::function handler + asio::io_service & io_service + , std::function handler , utils::thread_pool & thread_pool ) : socket_(io_service) @@ -154,8 +153,8 @@ namespace network { namespace http { } ~async_server_connection() throw () { - boost::system::error_code ignored; - socket_.shutdown(boost::asio::ip::tcp::socket::shutdown_receive, ignored); + asio::error_code ignored; + socket_.shutdown(asio::ip::tcp::socket::shutdown_receive, ignored); } /** Function: template set_headers(Range headers) @@ -175,7 +174,7 @@ namespace network { namespace http { boost::throw_exception(std::logic_error("Headers have already been sent.")); if (error_encountered) - boost::throw_exception(boost::system::system_error(*error_encountered)); + boost::throw_exception(std::system_error(*error_encountered)); { std::ostream stream(&headers_buffer); @@ -195,7 +194,7 @@ namespace network { namespace http { } write_headers_only( - boost::bind( + std::bind( &async_server_connection::do_nothing , async_server_connection::shared_from_this() )); @@ -204,7 +203,7 @@ namespace network { namespace http { void set_status(status_t new_status) { lock_guard lock(headers_mutex); if (headers_already_sent) boost::throw_exception(std::logic_error("Headers have already been sent, cannot reset status.")); - if (error_encountered) boost::throw_exception(boost::system::system_error(*error_encountered)); + if (error_encountered) boost::throw_exception(std::system_error(*error_encountered)); status = new_status; } @@ -212,10 +211,10 @@ namespace network { namespace http { template void write(Range const & range) { lock_guard lock(headers_mutex); - if (error_encountered) boost::throw_exception(boost::system::system_error(*error_encountered)); - - boost::function f = - boost::bind( + if (error_encountered) boost::throw_exception(std::system_error(*error_encountered)); + using namespace std::placeholders; + std::function f = + std::bind( &async_server_connection::default_error , async_server_connection::shared_from_this() , _1); @@ -227,37 +226,37 @@ namespace network { namespace http { } template - typename boost::disable_if, void>::type + typename std::disable_if>::type write(Range const & range, Callback const & callback) { lock_guard lock(headers_mutex); - if (error_encountered) boost::throw_exception(boost::system::system_error(*error_encountered)); + if (error_encountered) boost::throw_exception(std::system_error(*error_encountered)); write_impl(boost::make_iterator_range(range), callback); } template - typename boost::enable_if, void>::type + typename std::enable_if>::type write(ConstBufferSeq const & seq, Callback const & callback) { write_vec_impl(seq, callback, shared_array_list(), shared_buffers()); } private: - typedef boost::array buffer_type; + typedef std::array buffer_type; public: typedef boost::iterator_range input_range; - typedef boost::function read_callback_function; + typedef std::function read_callback_function; void read(read_callback_function callback) { - if (error_encountered) boost::throw_exception(boost::system::system_error(*error_encountered)); + if (error_encountered) boost::throw_exception(std::system_error(*error_encountered)); if (new_start != read_buffer_.begin()) { input_range input = boost::make_iterator_range(new_start, read_buffer_.end()); thread_pool().post( - boost::bind( + std::bind( callback , input - , boost::system::error_code() + , asio::error_code() , std::distance(new_start, data_end) , async_server_connection::shared_from_this()) ); @@ -266,30 +265,30 @@ namespace network { namespace http { } socket().async_read_some( - boost::asio::buffer(read_buffer_) + asio::buffer(read_buffer_) , strand.wrap( - boost::bind( + std::bind( &async_server_connection::wrap_read_handler , async_server_connection::shared_from_this() , callback - , boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred))); + , asio::placeholders::error, asio::placeholders::bytes_transferred))); } - boost::asio::ip::tcp::socket & socket() { return socket_; } + asio::ip::tcp::socket & socket() { return socket_; } utils::thread_pool & thread_pool() { return thread_pool_; } bool has_error() { return (!!error_encountered); } - boost::optional error() + boost::optional error() { return error_encountered; } private: - void wrap_read_handler(read_callback_function callback, boost::system::error_code const & ec, std::size_t bytes_transferred) { - if (ec) error_encountered = boost::in_place(ec); + void wrap_read_handler(read_callback_function callback, asio::error_code const & ec, std::size_t bytes_transferred) { + if (ec) error_encountered = boost::in_place(ec); buffer_type::const_iterator data_start = read_buffer_.begin() ,data_end = read_buffer_.begin(); std::advance(data_end, bytes_transferred); thread_pool().post( - boost::bind( + std::bind( callback , boost::make_iterator_range(data_start, data_end) , ec @@ -297,32 +296,32 @@ namespace network { namespace http { , async_server_connection::shared_from_this())); } - void default_error(boost::system::error_code const & ec) { - error_encountered = boost::in_place(ec); + void default_error(asio::error_code const & ec) { + error_encountered = boost::in_place(ec); } - typedef boost::array array; - typedef std::list > array_list; - typedef boost::shared_ptr shared_array_list; - typedef boost::shared_ptr > shared_buffers; - typedef boost::lock_guard lock_guard; - typedef std::list > pending_actions_list; + typedef std::array array; + typedef std::list > array_list; + typedef std::shared_ptr shared_array_list; + typedef std::shared_ptr > shared_buffers; + typedef std::lock_guard lock_guard; + typedef std::list > pending_actions_list; - boost::asio::ip::tcp::socket socket_; - boost::asio::io_service::strand strand; - boost::function handler; + asio::ip::tcp::socket socket_; + asio::io_service::strand strand; + std::function handler; utils::thread_pool & thread_pool_; volatile bool headers_already_sent, headers_in_progress; - boost::asio::streambuf headers_buffer; + asio::streambuf headers_buffer; - boost::recursive_mutex headers_mutex; + std::recursive_mutex headers_mutex; buffer_type read_buffer_; status_t status; request_parser parser; request request_; buffer_type::iterator new_start, data_end; std::string partial_parsed; - boost::optional error_encountered; + boost::optional error_encountered; pending_actions_list pending_actions; friend class async_server_impl; @@ -341,20 +340,20 @@ namespace network { namespace http { void read_more(state_t state) { socket_.async_read_some( - boost::asio::buffer(read_buffer_) + asio::buffer(read_buffer_) , strand.wrap( - boost::bind( + std::bind( &async_server_connection::handle_read_data, async_server_connection::shared_from_this(), state, - boost::asio::placeholders::error, - boost::asio::placeholders::bytes_transferred + asio::placeholders::error, + asio::placeholders::bytes_transferred ) ) ); } - void handle_read_data(state_t state, boost::system::error_code const & ec, std::size_t bytes_transferred) { + void handle_read_data(state_t state, asio::error_code const & ec, std::size_t bytes_transferred) { if (!ec) { boost::logic::tribool parsed_ok; boost::iterator_range result_range, input_range; @@ -457,7 +456,7 @@ namespace network { namespace http { } new_start = boost::end(result_range); thread_pool().post( - boost::bind( + std::bind( handler, boost::cref(request_), async_server_connection::shared_from_this())); @@ -475,7 +474,7 @@ namespace network { namespace http { std::abort(); } } else { - error_encountered = boost::in_place(ec); + error_encountered = boost::in_place(ec); } } @@ -483,45 +482,45 @@ namespace network { namespace http { static char const * bad_request = "HTTP/1.0 400 Bad Request\r\nConnection: close\r\nContent-Type: text/plain\r\nContent-Length: 12\r\n\r\nBad Request."; - boost::asio::async_write( + asio::async_write( socket() - , boost::asio::buffer(bad_request, strlen(bad_request)) + , asio::buffer(bad_request, strlen(bad_request)) , strand.wrap( - boost::bind( + std::bind( &async_server_connection::client_error_sent , async_server_connection::shared_from_this() - , boost::asio::placeholders::error - , boost::asio::placeholders::bytes_transferred))); + , asio::placeholders::error + , asio::placeholders::bytes_transferred))); } - void client_error_sent(boost::system::error_code const & ec, std::size_t bytes_transferred) { + void client_error_sent(asio::error_code const & ec, std::size_t bytes_transferred) { if (!ec) { - boost::system::error_code ignored; - socket().shutdown(boost::asio::ip::tcp::socket::shutdown_both, ignored); + asio::error_code ignored; + socket().shutdown(asio::ip::tcp::socket::shutdown_both, ignored); socket().close(ignored); } else { - error_encountered = boost::in_place(ec); + error_encountered = boost::in_place(ec); } } void do_nothing() {} - void write_headers_only(boost::function callback) { + void write_headers_only(std::function callback) { if (headers_in_progress) return; headers_in_progress = true; - boost::asio::async_write( + asio::async_write( socket() , headers_buffer , strand.wrap( - boost::bind( + std::bind( &async_server_connection::handle_write_headers , async_server_connection::shared_from_this() , callback - , boost::asio::placeholders::error - , boost::asio::placeholders::bytes_transferred))); + , asio::placeholders::error + , asio::placeholders::bytes_transferred))); } - void handle_write_headers(boost::function callback, boost::system::error_code const & ec, std::size_t bytes_transferred) { + void handle_write_headers(std::function callback, asio::error_code const & ec, std::size_t bytes_transferred) { lock_guard lock(headers_mutex); if (!ec) { headers_buffer.consume(headers_buffer.size()); @@ -534,23 +533,23 @@ namespace network { namespace http { } pending_actions_list().swap(pending_actions); } else { - error_encountered = boost::in_place(ec); + error_encountered = boost::in_place(ec); } } void handle_write( - boost::function callback + std::function callback , shared_array_list temporaries , shared_buffers buffers - , boost::system::error_code const & ec + , asio::error_code const & ec , std::size_t bytes_transferred ) { // we want to forget the temporaries and buffers - thread_pool().post(boost::bind(callback, ec)); + thread_pool().post(std::bind(callback, ec)); } template - void write_impl(Range range, boost::function callback) { + void write_impl(Range range, std::function callback) { // linearize the whole range into a vector // of fixed-sized buffers, then schedule an asynchronous // write of these buffers -- make sure they are live @@ -567,9 +566,9 @@ namespace network { namespace http { static std::size_t const connection_buffer_size = NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE; shared_array_list temporaries = - boost::make_shared(); + std::make_shared(); shared_buffers buffers = - boost::make_shared >(0); + std::make_shared >(0); std::size_t range_size = boost::distance(range); buffers->reserve( @@ -583,13 +582,13 @@ namespace network { namespace http { , end = boost::end(range); while (slice_size != 0) { using boost::adaptors::sliced; - boost::shared_ptr new_array = boost::make_shared(); + std::shared_ptr new_array = std::make_shared(); boost::copy( range | sliced(0,slice_size) , new_array->begin() ); temporaries->push_back(new_array); - buffers->push_back(boost::asio::buffer(new_array->data(), slice_size)); + buffers->push_back(asio::buffer(new_array->data(), slice_size)); std::advance(start, slice_size); range = boost::make_iterator_range(start, end); range_size = boost::distance(range); @@ -609,13 +608,13 @@ namespace network { namespace http { { lock_guard lock(headers_mutex); if (error_encountered) - boost::throw_exception(boost::system::system_error(*error_encountered)); + boost::throw_exception(std::system_error(*error_encountered)); - boost::function callback_function = + std::function callback_function = callback; - boost::function continuation = boost::bind( - &async_server_connection::template write_vec_impl > + std::function continuation = std::bind( + &async_server_connection::template write_vec_impl > ,async_server_connection::shared_from_this() ,seq, callback_function, temporaries, buffers ); @@ -628,17 +627,17 @@ namespace network { namespace http { return; } - boost::asio::async_write( + asio::async_write( socket_ ,seq - ,boost::bind( + ,std::bind( &async_server_connection::handle_write ,async_server_connection::shared_from_this() ,callback_function ,temporaries ,buffers - ,boost::asio::placeholders::error - ,boost::asio::placeholders::bytes_transferred) + ,asio::placeholders::error + ,asio::placeholders::bytes_transferred) ); } }; diff --git a/include/network/protocol/http/server/connection/sync.hpp b/include/network/protocol/http/server/connection/sync.hpp index 7a4e02798..3b90fcab1 100644 --- a/include/network/protocol/http/server/connection/sync.hpp +++ b/include/network/protocol/http/server/connection/sync.hpp @@ -19,16 +19,16 @@ #include #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include -#include +#include namespace network { namespace http { @@ -39,8 +39,8 @@ namespace network { namespace http { class sync_server_connection : public boost::enable_shared_from_this { public: - sync_server_connection(boost::asio::io_service & service, - boost::function handler) + sync_server_connection(asio::io_service & service, + std::function handler) : service_(service) , handler_(handler) , socket_(service_) @@ -48,13 +48,13 @@ class sync_server_connection : public boost::enable_shared_from_this result_range, input_range; @@ -190,20 +190,20 @@ class sync_server_connection : public boost::enable_shared_from_this response_buffers(output_buffers_.size()); + std::vector response_buffers(output_buffers_.size()); std::transform(output_buffers_.begin(), output_buffers_.end(), response_buffers.begin(), [](buffer_type const &buffer) { - return boost::asio::const_buffer(buffer.data(), buffer.size()); + return asio::const_buffer(buffer.data(), buffer.size()); }); - boost::asio::async_write( + asio::async_write( socket_, response_buffers, wrapper_.wrap( - boost::bind( + std::bind( &sync_server_connection::handle_write, sync_server_connection::shared_from_this(), - boost::asio::placeholders::error))); + asio::placeholders::error))); } return; } else { @@ -219,11 +219,11 @@ class sync_server_connection : public boost::enable_shared_from_this(ec); + error_encountered = boost::in_place(ec); } } - void handle_write(boost::system::error_code const &ec) { + void handle_write(asio::error_code const &ec) { // First thing we do is clear out the output buffers. output_buffers_.clear(); if (ec) { @@ -235,37 +235,37 @@ class sync_server_connection : public boost::enable_shared_from_this(ec); + error_encountered = boost::in_place(ec); } } void read_more(state_t state) { socket_.async_read_some( - boost::asio::buffer(read_buffer_) + asio::buffer(read_buffer_) , wrapper_.wrap( - boost::bind( + std::bind( &sync_server_connection::handle_read_data, sync_server_connection::shared_from_this(), state, - boost::asio::placeholders::error, - boost::asio::placeholders::bytes_transferred + asio::placeholders::error, + asio::placeholders::bytes_transferred ) ) ); @@ -311,10 +311,10 @@ class sync_server_connection : public boost::enable_shared_from_this handler_; - boost::asio::ip::tcp::socket socket_; - boost::asio::io_service::strand wrapper_; + asio::io_service & service_; + std::function handler_; + asio::ip::tcp::socket socket_; + asio::io_service::strand wrapper_; typedef boost::array buffer_type; buffer_type read_buffer_; @@ -324,7 +324,7 @@ class sync_server_connection : public boost::enable_shared_from_this output_buffers_; std::string partial_parsed; - boost::optional error_encountered; + boost::optional error_encountered; bool read_body_; }; diff --git a/include/network/protocol/http/server/impl/socket_options_setter.hpp b/include/network/protocol/http/server/impl/socket_options_setter.hpp index 05121cf08..3746ade1f 100644 --- a/include/network/protocol/http/server/impl/socket_options_setter.hpp +++ b/include/network/protocol/http/server/impl/socket_options_setter.hpp @@ -7,7 +7,7 @@ #ifndef NETWORK_PROTOCOL_HTTP_SERVER_IMPL_SOCKET_OPIONS_SETTER_20120319 #define NETWORK_PROTOCOL_HTTP_SERVER_IMPL_SOCKET_OPIONS_SETTER_20120319 -#include +#include namespace network { namespace http { @@ -15,8 +15,8 @@ class server_options; class socket_options_setter { protected: - void set_socket_options(server_options const &options, boost::asio::ip::tcp::socket &socket); - void set_acceptor_options(server_options const &options, boost::asio::ip::tcp::acceptor &acceptor); + void set_socket_options(server_options const &options, asio::ip::tcp::socket &socket); + void set_acceptor_options(server_options const &options, asio::ip::tcp::acceptor &acceptor); }; } // namespace http diff --git a/include/network/protocol/http/server/impl/socket_options_setter.ipp b/include/network/protocol/http/server/impl/socket_options_setter.ipp index 6f0010726..f8dfd63c0 100644 --- a/include/network/protocol/http/server/impl/socket_options_setter.ipp +++ b/include/network/protocol/http/server/impl/socket_options_setter.ipp @@ -12,38 +12,38 @@ namespace network { namespace http { -void socket_options_setter::set_socket_options(server_options const & options, boost::asio::ip::tcp::socket &socket) { - boost::system::error_code ignored; +void socket_options_setter::set_socket_options(server_options const & options, asio::ip::tcp::socket &socket) { + asio::error_code ignored; socket.non_blocking(options.non_blocking_io(), ignored); if (options.linger()) { - boost::asio::ip::tcp::socket::linger linger(true, options.linger_timeout()); + asio::ip::tcp::socket::linger linger(true, options.linger_timeout()); socket.set_option(linger, ignored); } if (int buf_size = options.receive_buffer_size() >= 0) { - boost::asio::ip::tcp::socket::receive_buffer_size receive_buffer_size(buf_size); + asio::ip::tcp::socket::receive_buffer_size receive_buffer_size(buf_size); socket.set_option(receive_buffer_size, ignored); } if (int buf_size = options.send_buffer_size() >= 0) { - boost::asio::ip::tcp::socket::send_buffer_size send_buffer_size(buf_size); + asio::ip::tcp::socket::send_buffer_size send_buffer_size(buf_size); socket.set_option(send_buffer_size, ignored); } if (int buf_size = options.receive_low_watermark() >= 0) { - boost::asio::ip::tcp::socket::receive_low_watermark receive_low_watermark(buf_size); + asio::ip::tcp::socket::receive_low_watermark receive_low_watermark(buf_size); socket.set_option(receive_low_watermark, ignored); } if (int buf_size = options.send_low_watermark() >= 0) { - boost::asio::ip::tcp::socket::send_low_watermark send_low_watermark(buf_size); + asio::ip::tcp::socket::send_low_watermark send_low_watermark(buf_size); socket.set_option(send_low_watermark, ignored); } } -void socket_options_setter::set_acceptor_options(server_options const &options, boost::asio::ip::tcp::acceptor &acceptor) { - boost::system::error_code ignored; +void socket_options_setter::set_acceptor_options(server_options const &options, asio::ip::tcp::acceptor &acceptor) { + asio::error_code ignored; acceptor.set_option( - boost::asio::ip::tcp::acceptor::reuse_address(options.reuse_address()), + asio::ip::tcp::acceptor::reuse_address(options.reuse_address()), ignored); acceptor.set_option( - boost::asio::ip::tcp::acceptor::enable_connection_aborted(options.report_aborted()), + asio::ip::tcp::acceptor::enable_connection_aborted(options.report_aborted()), ignored); } diff --git a/include/network/protocol/http/server/options.hpp b/include/network/protocol/http/server/options.hpp index 9cdc3499d..add43eaca 100644 --- a/include/network/protocol/http/server/options.hpp +++ b/include/network/protocol/http/server/options.hpp @@ -35,8 +35,8 @@ class server_options { server_options& port(std::string const &port); std::string const port() const; - server_options& io_service(boost::asio::io_service *service); - boost::asio::io_service *io_service() const; + server_options& io_service(asio::io_service *service); + asio::io_service *io_service() const; server_options& reuse_address(bool setting); bool reuse_address() const; diff --git a/include/network/protocol/http/server/options.ipp b/include/network/protocol/http/server/options.ipp index bccba3983..44c63e567 100644 --- a/include/network/protocol/http/server/options.ipp +++ b/include/network/protocol/http/server/options.ipp @@ -8,7 +8,7 @@ #define NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_IPP_20120318 #include -#include +#include namespace network { namespace http { @@ -49,11 +49,11 @@ class server_options_pimpl { return port_; } - void io_service(boost::asio::io_service *service) { + void io_service(asio::io_service *service) { io_service_ = service; } - boost::asio::io_service *io_service() const { + asio::io_service *io_service() const { return io_service_; } @@ -131,7 +131,7 @@ class server_options_pimpl { private: std::string address_, port_; - boost::asio::io_service *io_service_; + asio::io_service *io_service_; int receive_buffer_size_, send_buffer_size_, receive_low_watermark_, send_low_watermark_, linger_timeout_; @@ -193,12 +193,12 @@ std::string const server_options::port() const { return pimpl_->port(); } -server_options& server_options::io_service(boost::asio::io_service *io_service) { +server_options& server_options::io_service(asio::io_service *io_service) { pimpl_->io_service(io_service); return *this; } -boost::asio::io_service* server_options::io_service() const { +asio::io_service* server_options::io_service() const { return pimpl_->io_service(); } diff --git a/include/network/protocol/http/server/socket_options_base.hpp b/include/network/protocol/http/server/socket_options_base.hpp index 25601b090..82c5309f6 100644 --- a/include/network/protocol/http/server/socket_options_base.hpp +++ b/include/network/protocol/http/server/socket_options_base.hpp @@ -37,13 +37,13 @@ namespace network { namespace http { set_optional(send_low_watermark, args, _send_low_watermark); } - void acceptor_options(boost::asio::ip::tcp::acceptor & acceptor) { + void acceptor_options(asio::ip::tcp::acceptor & acceptor) { acceptor.set_option(acceptor_reuse_address); acceptor.set_option(acceptor_report_aborted); } - void socket_options(boost::asio::ip::tcp::socket & socket) { - boost::system::error_code ignored; + void socket_options(asio::ip::tcp::socket & socket) { + asio::error_code ignored; socket.io_control(non_blocking_io, ignored); socket.set_option(linger, ignored); if (receive_buffer_size) socket.set_option(*receive_buffer_size, ignored); diff --git a/include/network/protocol/http/server/storage_base.hpp b/include/network/protocol/http/server/storage_base.hpp index faf90676f..6151070f8 100644 --- a/include/network/protocol/http/server/storage_base.hpp +++ b/include/network/protocol/http/server/storage_base.hpp @@ -17,7 +17,7 @@ namespace network { namespace http { protected: template server_storage_base(ArgPack const & /* args */, no_io_service) - : self_service_(new boost::asio::io_service()) + : self_service_(new asio::io_service()) , service_(*self_service_) {} diff --git a/include/network/protocol/http/server/sync_impl.hpp b/include/network/protocol/http/server/sync_impl.hpp index 8a78dfabc..7eacb41b2 100644 --- a/include/network/protocol/http/server/sync_impl.hpp +++ b/include/network/protocol/http/server/sync_impl.hpp @@ -7,10 +7,10 @@ #ifndef NETWORK_PROTOCOL_HTTP_SERVER_IMPL_HPP_20120318 #define NETWORK_PROTOCOL_HTTP_SERVER_IMPL_HPP_20120318 -#include +#include #include #include -#include +#include #include #include @@ -23,7 +23,7 @@ struct response; class sync_server_impl : protected socket_options_setter { public: sync_server_impl(server_options const &options, - boost::function handler); + std::function handler); void run(); void stop(); void listen(); @@ -31,15 +31,15 @@ class sync_server_impl : protected socket_options_setter { private: server_options options_; std::string address_, port_; - boost::asio::io_service *service_; - boost::asio::ip::tcp::acceptor *acceptor_; + asio::io_service *service_; + asio::ip::tcp::acceptor *acceptor_; boost::shared_ptr new_connection_; boost::mutex listening_mutex_; bool listening_, owned_service_; - boost::function handler_; + std::function handler_; void start_listening(); - void handle_accept(boost::system::error_code const &ec); + void handle_accept(asio::error_code const &ec); }; } // namespace http diff --git a/include/network/protocol/http/server/sync_impl.ipp b/include/network/protocol/http/server/sync_impl.ipp index dd883ac13..82e084269 100644 --- a/include/network/protocol/http/server/sync_impl.ipp +++ b/include/network/protocol/http/server/sync_impl.ipp @@ -14,7 +14,7 @@ namespace network { namespace http { sync_server_impl::sync_server_impl(server_options const &options, - boost::function handler) + std::function handler) : options_(options) , address_(options.address()) , port_(options.port()) @@ -25,11 +25,11 @@ sync_server_impl::sync_server_impl(server_options const &options, , listening_(false) , owned_service_(false) { if (service_ == 0) { - service_ = new (std::nothrow) boost::asio::io_service; + service_ = new (std::nothrow) asio::io_service; owned_service_ = true; BOOST_ASSERT(service_ != 0); } - acceptor_ = new (std::nothrow) boost::asio::ip::tcp::acceptor(*service_); + acceptor_ = new (std::nothrow) asio::ip::tcp::acceptor(*service_); BOOST_ASSERT(acceptor_ != 0); } @@ -39,7 +39,7 @@ void sync_server_impl::run() { } void sync_server_impl::stop() { - boost::system::error_code ignored; + asio::error_code ignored; acceptor_->close(ignored); service_->stop(); } @@ -49,7 +49,7 @@ void sync_server_impl::listen() { if (!listening_) start_listening(); } -void sync_server_impl::handle_accept(boost::system::error_code const &ec) { +void sync_server_impl::handle_accept(asio::error_code const &ec) { if (!ec) { set_socket_options(options_, new_connection_->socket()); new_connection_->start(); @@ -57,7 +57,7 @@ void sync_server_impl::handle_accept(boost::system::error_code const &ec) { acceptor_->async_accept(new_connection_->socket(), bind(&sync_server_impl::handle_accept, this, - boost::asio::placeholders::error)); + asio::placeholders::error)); } else { NETWORK_MESSAGE("error accepting connection: " << ec); this->stop(); @@ -65,8 +65,8 @@ void sync_server_impl::handle_accept(boost::system::error_code const &ec) { } void sync_server_impl::start_listening() { - using boost::asio::ip::tcp; - boost::system::error_code error; + using asio::ip::tcp; + asio::error_code error; tcp::resolver resolver(*service_); tcp::resolver::query query(address_, port_); tcp::resolver::iterator endpoint_ = resolver.resolve(query, error); @@ -95,7 +95,7 @@ void sync_server_impl::start_listening() { acceptor_->async_accept(new_connection_->socket(), bind(&sync_server_impl::handle_accept, this, - boost::asio::placeholders::error)); + asio::placeholders::error)); listening_ = true; } diff --git a/include/network/protocol/http/server/sync_server.hpp b/include/network/protocol/http/server/sync_server.hpp index dcb03f5d5..6aeb83cac 100644 --- a/include/network/protocol/http/server/sync_server.hpp +++ b/include/network/protocol/http/server/sync_server.hpp @@ -10,8 +10,8 @@ #include #include -#include -#include +#include +#include #include #include #include @@ -72,24 +72,24 @@ namespace network { namespace http { Handler & handler_; string_type address_, port_; - boost::asio::ip::tcp::acceptor acceptor_; + asio::ip::tcp::acceptor acceptor_; boost::shared_ptr > new_connection; boost::mutex listening_mutex_; bool listening_; - void handle_accept(boost::system::error_code const & ec) { + void handle_accept(asio::error_code const & ec) { if (!ec) { socket_options_base::socket_options(new_connection->socket()); new_connection->start(); new_connection.reset(new sync_connection(service_, handler_)); acceptor_.async_accept(new_connection->socket(), - boost::bind(&sync_server_base::handle_accept, - this, boost::asio::placeholders::error)); + std::bind(&sync_server_base::handle_accept, + this, asio::placeholders::error)); } } void start_listening() { - using boost::asio::ip::tcp; + using asio::ip::tcp; system::error_code error; tcp::resolver resolver(service_); tcp::resolver::query query(address_, port_); @@ -117,8 +117,8 @@ namespace network { namespace http { } new_connection.reset(new sync_connection(service_, handler_)); acceptor_.async_accept(new_connection->socket(), - boost::bind(&sync_server_base::handle_accept, - this, boost::asio::placeholders::error)); + std::bind(&sync_server_base::handle_accept, + this, asio::placeholders::error)); listening_ = true; } }; diff --git a/include/network/uri/builder.hpp b/include/network/uri/builder.hpp index 0ddd1db7c..91757a1b3 100644 --- a/include/network/uri/builder.hpp +++ b/include/network/uri/builder.hpp @@ -9,7 +9,7 @@ #ifndef NETWORK_URI_BUILDER_INC #define NETWORK_URI_BUILDER_INC -#include +#include namespace network { class builder { @@ -48,19 +48,19 @@ class builder { return *this; } - builder &host(const boost::asio::ip::address &host) { + builder &host(const asio::ip::address &host) { uri_.uri_.append(host.to_string()); uri_.parse(); return *this; } - builder &host(const boost::asio::ip::address_v4 &host) { + builder &host(const asio::ip::address_v4 &host) { uri_.uri_.append(host.to_string()); uri_.parse(); return *this; } - builder &host(const boost::asio::ip::address_v6 &host) { + builder &host(const asio::ip::address_v6 &host) { uri_.uri_.append("["); uri_.uri_.append(host.to_string()); uri_.uri_.append("]"); diff --git a/include/network/utils/thread_pool.hpp b/include/network/utils/thread_pool.hpp index 4477f7a74..de9a7fc18 100644 --- a/include/network/utils/thread_pool.hpp +++ b/include/network/utils/thread_pool.hpp @@ -8,17 +8,17 @@ #define NETWORK_UTILS_THREAD_POOL_HPP_20101020 #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace network { namespace utils { -typedef boost::shared_ptr io_service_ptr; -typedef boost::shared_ptr worker_threads_ptr; -typedef boost::shared_ptr sentinel_ptr; +typedef std::shared_ptr io_service_ptr; +typedef std::shared_ptr> worker_threads_ptr; +typedef std::shared_ptr sentinel_ptr; struct thread_pool_pimpl; @@ -27,7 +27,7 @@ struct thread_pool { io_service_ptr io_service = io_service_ptr(), worker_threads_ptr worker_threads = worker_threads_ptr()); std::size_t const thread_count() const; - void post(boost::function f); + void post(std::function f); ~thread_pool(); void swap(thread_pool & other); protected: diff --git a/include/network/utils/thread_pool.ipp b/include/network/utils/thread_pool.ipp index 3cf14b226..faba0b11a 100644 --- a/include/network/utils/thread_pool.ipp +++ b/include/network/utils/thread_pool.ipp @@ -36,7 +36,7 @@ struct thread_pool_pimpl { } BOOST_SCOPE_EXIT_END if (!io_service_.get()) { - io_service_.reset(new boost::asio::io_service); + io_service_.reset(new asio::io_service); } if (!worker_threads_.get()) { @@ -44,16 +44,12 @@ struct thread_pool_pimpl { } if (!sentinel_.get()) { - sentinel_.reset(new boost::asio::io_service::work(*io_service_)); + sentinel_.reset(new asio::io_service::work(*io_service_)); } + auto io_service_local = io_service_; for (std::size_t counter = 0; counter < threads_; ++counter) - worker_threads_->create_thread( - boost::bind( - &boost::asio::io_service::run, - io_service_ - ) - ); + worker_threads_->emplace_back([=io_service_local]() { io_service_local->run() }); commit = true; } @@ -62,7 +58,7 @@ struct thread_pool_pimpl { return threads_; } - void post(boost::function f) { + void post(std::function f) { io_service_->post(f); } @@ -103,7 +99,7 @@ std::size_t const thread_pool::thread_count() const { return pimpl->thread_count(); } -void thread_pool::post(boost::function f) { +void thread_pool::post(std::function f) { pimpl->post(f); } From 8626a22de6fea8722c5bb70ce365072adff6a276 Mon Sep 17 00:00:00 2001 From: Mikhail Kulinich Date: Sun, 28 Oct 2012 20:36:14 +0400 Subject: [PATCH 123/196] Address comments regarding installation of other libraries --- libs/network/build/Jamfile.v2 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/network/build/Jamfile.v2 b/libs/network/build/Jamfile.v2 index 9ccd706e4..d36e3708e 100644 --- a/libs/network/build/Jamfile.v2 +++ b/libs/network/build/Jamfile.v2 @@ -73,6 +73,8 @@ lib cppnetlib-constants : libs/network/src/constants.cpp ; install headers : client server : ../../../boost/network/include/http ; -install libraries : cppnetlib-uri ; +install libraries : cppnetlib-uri cppnetlib-message cppnetlib-message-directives cppnetlib-message-wrappers + cppnetlib-http-message cppnetlib-http-message-wrappers cppnetlib-http-server-parsers cppnetlib-http-server + cppnetlib-http-client-connections cppnetlib-http-client cppnetlib-utils-thread_pool cppnetlib-constants ; alias all : headers ; From b1555de21cf5c660b9b23e56fc9ab793071b2a9f Mon Sep 17 00:00:00 2001 From: ky Date: Tue, 30 Oct 2012 18:25:30 +0400 Subject: [PATCH 124/196] fix uri decoding and query string parsing --- include/network/uri/accessors.hpp | 4 ++-- include/network/uri/decode.hpp | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/network/uri/accessors.hpp b/include/network/uri/accessors.hpp index d15b506be..1c0b68432 100644 --- a/include/network/uri/accessors.hpp +++ b/include/network/uri/accessors.hpp @@ -32,8 +32,8 @@ struct key_value_sequence { query = pair >> *((boost::spirit::qi::lit(';') | '&') >> pair); pair = key >> -('=' >> value); - key = boost::spirit::qi::char_("a-zA-Z_") >> *boost::spirit::qi::char_("a-zA-Z_0-9/%"); - value = +boost::spirit::qi::char_("a-zA-Z_0-9/%"); + key = spirit::qi::char_("a-zA-Z_") >> *spirit::qi::char_("a-zA-Z_0-9/%\\-_~\\."); + value = *spirit::qi::char_("a-zA-Z_0-9/%\\-_~\\.+"); } boost::spirit::qi::rule query; diff --git a/include/network/uri/decode.hpp b/include/network/uri/decode.hpp index c49e95755..40c50acaa 100644 --- a/include/network/uri/decode.hpp +++ b/include/network/uri/decode.hpp @@ -74,6 +74,12 @@ OutputIterator decode(const InputIterator &in_begin, *out++ = 0x10 * v0 + v1; } else + if (*it == '+') + { + *out++ = ' '; + ++ it; + } + else { *out++ = *it++; } From d00836dfe281a59af8dacbb6864fe0bcae2d39a0 Mon Sep 17 00:00:00 2001 From: Joel Reymont Date: Tue, 30 Oct 2012 18:27:12 +0000 Subject: [PATCH 125/196] Take content length into account when reading body --- .../http/client/connection/async_normal.ipp | 55 +++++++++++++++---- 1 file changed, 45 insertions(+), 10 deletions(-) diff --git a/include/network/protocol/http/client/connection/async_normal.ipp b/include/network/protocol/http/client/connection/async_normal.ipp index a99680632..5e30db45f 100644 --- a/include/network/protocol/http/client/connection/async_normal.ipp +++ b/include/network/protocol/http/client/connection/async_normal.ipp @@ -430,20 +430,53 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thispart.begin(); + buffer_type::const_iterator end = begin; + std::advance(end, bytes_transferred); + // check the content length header + //auto headers_future = headers_promise.get_future(); + auto it = headers_.find("Content-Length"); + if (it != headers_.end()) { + try { + unsigned content_length = stoi(it->second); + get_more = (end - begin) < content_length; + NETWORK_MESSAGE("Content-Length: " << content_length + << ", disconnect: " << !get_more); + } catch(...) { + } + } // Here we don't have a body callback. Let's // make sure that we deal with the remainder // from the headers part in case we do have data // that's still in the buffer. - this->parse_body(request_strand_.wrap( - boost::bind( - &this_type::handle_received_data, - this_type::shared_from_this(), - body, - get_body, - callback, - placeholders::error, - placeholders::bytes_transferred)), - bytes_transferred); + if (get_more) { + this->parse_body(request_strand_.wrap( + boost::bind( + &this_type::handle_received_data, + this_type::shared_from_this(), + body, + get_body, + callback, + placeholders::error, + placeholders::bytes_transferred)), + bytes_transferred); + } else { + std::string body_string; + std::swap(body_string, this->partial_parsed); + body_string.append( + this->part.begin() + , bytes_transferred + ); + this->body_promise.set_value(body_string); + // TODO set the destination value somewhere! + this->destination_promise.set_value(""); + this->source_promise.set_value(""); + this->part.assign('\0'); + this->response_parser_.reset(); + //NETWORK_MESSAGE("forcing socket disconnect on content length"); + //connection_delegate_->disconnect(); + } } } return; @@ -709,6 +742,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisheaders_ = headers; headers_promise.set_value(headers); } @@ -790,6 +824,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this status_promise; boost::promise status_message_promise; boost::promise > headers_promise; + std::multimap headers_; boost::promise source_promise; boost::promise destination_promise; boost::promise body_promise; From 78afee4adb9f3f70372a3a118851485b582b3bc2 Mon Sep 17 00:00:00 2001 From: Joel Reymont Date: Wed, 31 Oct 2012 12:42:57 +0000 Subject: [PATCH 126/196] Qualify stoi and only catch exceptions thrown by it. --- .../protocol/http/client/connection/async_normal.ipp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/network/protocol/http/client/connection/async_normal.ipp b/include/network/protocol/http/client/connection/async_normal.ipp index 5e30db45f..d0645e8f9 100644 --- a/include/network/protocol/http/client/connection/async_normal.ipp +++ b/include/network/protocol/http/client/connection/async_normal.ipp @@ -439,11 +439,11 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thissecond); + unsigned content_length = std::stoi(it->second); get_more = (end - begin) < content_length; - NETWORK_MESSAGE("Content-Length: " << content_length - << ", disconnect: " << !get_more); - } catch(...) { + NETWORK_MESSAGE("Content-Length: " << content_length); + } catch(const std::invalid_argument&) { + } catch(const std::out_of_range&) { } } // Here we don't have a body callback. Let's From a941fb1c05230bad3a8c4ca1d1e4cdfa28a9aa42 Mon Sep 17 00:00:00 2001 From: Joel Reymont Date: Wed, 31 Oct 2012 13:38:48 +0000 Subject: [PATCH 127/196] Use optional member variable to keep track of content length. --- .../http/client/connection/async_normal.ipp | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/include/network/protocol/http/client/connection/async_normal.ipp b/include/network/protocol/http/client/connection/async_normal.ipp index d0645e8f9..0b8b4ef89 100644 --- a/include/network/protocol/http/client/connection/async_normal.ipp +++ b/include/network/protocol/http/client/connection/async_normal.ipp @@ -431,20 +431,13 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thispart.begin(); - buffer_type::const_iterator end = begin; - std::advance(end, bytes_transferred); - // check the content length header - //auto headers_future = headers_promise.get_future(); - auto it = headers_.find("Content-Length"); - if (it != headers_.end()) { - try { - unsigned content_length = std::stoi(it->second); - get_more = (end - begin) < content_length; - NETWORK_MESSAGE("Content-Length: " << content_length); - } catch(const std::invalid_argument&) { - } catch(const std::out_of_range&) { - } + if (content_length_) { + buffer_type::const_iterator begin = this->part.begin(); + buffer_type::const_iterator end = begin; + std::advance(end, bytes_transferred); + get_more = (end - begin) < *content_length_; + NETWORK_MESSAGE("content_length = " << * content_length_ + << ", bytes read = " << (end - begin) << ", read more = " << get_more); } // Here we don't have a body callback. Let's // make sure that we deal with the remainder @@ -474,8 +467,6 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thissource_promise.set_value(""); this->part.assign('\0'); this->response_parser_.reset(); - //NETWORK_MESSAGE("forcing socket disconnect on content length"); - //connection_delegate_->disconnect(); } } } @@ -742,7 +733,17 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thisheaders_ = headers; + // Set content length + content_length_ = boost::none; + auto it = headers.find("Content-Length"); + if (it != headers.end()) { + try { + content_length_ = std::stoi(it->second); + NETWORK_MESSAGE("Content-Length: " << *content_length_); + } catch(const std::invalid_argument&) { + } catch(const std::out_of_range&) { + } + } headers_promise.set_value(headers); } @@ -824,7 +825,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this status_promise; boost::promise status_message_promise; boost::promise > headers_promise; - std::multimap headers_; + boost::optional content_length_; boost::promise source_promise; boost::promise destination_promise; boost::promise body_promise; From 3079bdae66d116e61ff19c5d856cf6e05bf83db4 Mon Sep 17 00:00:00 2001 From: Joel Reymont Date: Wed, 31 Oct 2012 14:00:46 +0000 Subject: [PATCH 128/196] Use size_t to store content length. --- .../network/protocol/http/client/connection/async_normal.ipp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/network/protocol/http/client/connection/async_normal.ipp b/include/network/protocol/http/client/connection/async_normal.ipp index 0b8b4ef89..62506dfc5 100644 --- a/include/network/protocol/http/client/connection/async_normal.ipp +++ b/include/network/protocol/http/client/connection/async_normal.ipp @@ -738,7 +738,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thissecond); + content_length_ = std::stoul(it->second); NETWORK_MESSAGE("Content-Length: " << *content_length_); } catch(const std::invalid_argument&) { } catch(const std::out_of_range&) { @@ -825,7 +825,7 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this status_promise; boost::promise status_message_promise; boost::promise > headers_promise; - boost::optional content_length_; + boost::optional content_length_; boost::promise source_promise; boost::promise destination_promise; boost::promise body_promise; From 4054936d0b0d8e9b775759e9bdd7f27cf1a47dde Mon Sep 17 00:00:00 2001 From: Joel Reymont Date: Wed, 31 Oct 2012 14:04:22 +0000 Subject: [PATCH 129/196] Print a debug message if content length conversion to size_t fails. --- .../network/protocol/http/client/connection/async_normal.ipp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/network/protocol/http/client/connection/async_normal.ipp b/include/network/protocol/http/client/connection/async_normal.ipp index 62506dfc5..5366532df 100644 --- a/include/network/protocol/http/client/connection/async_normal.ipp +++ b/include/network/protocol/http/client/connection/async_normal.ipp @@ -741,7 +741,11 @@ struct http_async_connection_pimpl : boost::enable_shared_from_thissecond); NETWORK_MESSAGE("Content-Length: " << *content_length_); } catch(const std::invalid_argument&) { + NETWORK_MESSAGE("invalid argument exception while interpreting " + << it->second << " as content length"); } catch(const std::out_of_range&) { + NETWORK_MESSAGE("out of range exception while interpreting " + << it->second << " as content length"); } } headers_promise.set_value(headers); From c20b57e436c2190dad4fcd7898f8e80a6068fccf Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sun, 4 Nov 2012 00:56:46 +1100 Subject: [PATCH 130/196] Allow co-located Xcode builds. I'm adding the generated CMake artefacts to .gitignore so that Xcode users who choose to self-host on the same development directory can do so. --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 833df9eea..7648c4477 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,6 @@ libs/mime/test/mime-roundtrip bin/ tests/ _build +CPP-NETLIB.* +CMakeScripts/ +*.cmake From 38fcd3a64432c870a0812e0515114256d2a626ea Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sun, 4 Nov 2012 02:21:34 +1100 Subject: [PATCH 131/196] Lining up message's get_body Clang found some hidden virtual functions in message_base. This commit fixes the warnings. --- include/network/message/message.hpp | 91 ++++----- include/network/message/message.ipp | 305 ++++++++++++++-------------- 2 files changed, 198 insertions(+), 198 deletions(-) diff --git a/include/network/message/message.hpp b/include/network/message/message.hpp index 67567e8c3..1601e581d 100644 --- a/include/network/message/message.hpp +++ b/include/network/message/message.hpp @@ -15,65 +15,62 @@ namespace network { -struct message_pimpl; + struct message_pimpl; -// The common message type. -struct message : message_base { - // Nested types - typedef boost::iterator_range< + // The common message type. + struct message : message_base { + // Nested types + typedef boost::iterator_range< std::multimap::const_iterator> headers_range; - // Constructors - message(); - message(message const & other); + // Constructors + message(); + message(message const & other); + message(message && other) = default; - // Assignment - message & operator=(message other); + // Assignment + message& operator=(message const &other); + message& operator=(message &&other); - // Mutators - virtual void set_destination(std::string const & destination); - virtual void set_source(std::string const & source); - virtual void append_header(std::string const & name, - std::string const & value); - virtual void remove_headers(std::string const & name); - virtual void remove_headers(); - virtual void set_body(std::string const & body); - virtual void append_body(std::string const & data); + // Mutators + virtual void set_destination(std::string const & destination); + virtual void set_source(std::string const & source); + virtual void append_header(std::string const & name, + std::string const & value); + virtual void remove_headers(std::string const & name); + virtual void remove_headers(); + virtual void set_body(std::string const & body); + virtual void append_body(std::string const & data); - // Retrievers - virtual void get_destination(std::string & destination) const; - virtual void get_source(std::string & source) const; - virtual void get_headers( - boost::function inserter) const; - virtual void get_headers( - std::string const & name, - boost::function inserter) const; - virtual void get_headers( - boost::function predicate, - boost::function inserter) const; - virtual void get_body(std::string & body) const; - virtual void get_body( - boost::function)> chunk_reader, - size_t size) const; + // Retrievers + virtual void get_destination(std::string & destination) const; + virtual void get_source(std::string & source) const; + virtual void get_headers(boost::function inserter) const; + virtual void get_headers(std::string const & name, + boost::function inserter) const; + virtual void get_headers(boost::function predicate, + boost::function inserter) const; + virtual void get_body(std::string & body) const; + virtual void get_body(boost::function chunk_reader, size_t size) const; - void swap(message & other); + void swap(message & other); - // Destructor - virtual ~message(); - private: - message_pimpl * pimpl; -}; + // Destructor + virtual ~message(); + private: + message_pimpl * pimpl; + }; -inline void swap(message & left, message & right) { + inline void swap(message & left, message & right) { left.swap(right); -} + } -template -message_base & operator<< (message_base & msg, Directive directive) { - directive(msg); - return msg; -} + template + message_base & operator<< (message_base & msg, Directive directive) { + directive(msg); + return msg; + } } // namespace network diff --git a/include/network/message/message.ipp b/include/network/message/message.ipp index 4822c72d8..2ba1b418c 100644 --- a/include/network/message/message.ipp +++ b/include/network/message/message.ipp @@ -14,197 +14,200 @@ namespace network { -struct message_pimpl { - message_pimpl() : + struct message_pimpl { + message_pimpl() : destination_(), source_(), headers_(), body_(), body_read_pos(0) - {} - - void set_destination(std::string const & destination) { - destination_ = destination; - } + {} - void set_source(std::string const & source) { - source_ = source; - } + void set_destination(std::string const & destination) { + destination_ = destination; + } - void append_header(std::string const & name, - std::string const & value) { - headers_.insert(std::make_pair(name, value)); - } + void set_source(std::string const & source) { + source_ = source; + } - void remove_headers(std::string const & name) { - headers_.erase(name); - } + void append_header(std::string const & name, + std::string const & value) { + headers_.insert(std::make_pair(name, value)); + } - void remove_headers() { - std::multimap().swap(headers_); - } + void remove_headers(std::string const & name) { + headers_.erase(name); + } - void set_body(std::string const & body) { - body_ = body; - } + void remove_headers() { + std::multimap().swap(headers_); + } - void append_body(std::string const & data) { - body_.append(data); - } + void set_body(std::string const & body) { + body_ = body; + } - // Retrievers - void get_destination(std::string & destination) const { - destination = destination_; - } + void append_body(std::string const & data) { + body_.append(data); + } - void get_source(std::string & source) const { - source = source_; - } + // Retrievers + void get_destination(std::string & destination) const { + destination = destination_; + } - void get_headers(boost::function inserter) const { - std::multimap::const_iterator it = headers_.begin(), - end = headers_.end(); - for (; it != end; ++it) inserter(it->first, it->second); - } + void get_source(std::string & source) const { + source = source_; + } - void get_headers(std::string const & name, - boost::function inserter) const { - std::multimap::const_iterator it = headers_.find(name), - end= headers_.end(); - while (it != end) { - inserter(it->first, it->second); - ++it; + void get_headers(boost::function inserter) const { + std::multimap::const_iterator it = headers_.begin(), + end = headers_.end(); + for (; it != end; ++it) inserter(it->first, it->second); } - } - void get_headers(boost::function predicate, - boost::function inserter) const { - std::multimap::const_iterator it = headers_.begin(), - end = headers_.end(); - while (it != end) { - if (predicate(it->first, it->second)) + void get_headers(std::string const & name, + boost::function inserter) const { + std::multimap::const_iterator it = headers_.find(name), + end= headers_.end(); + while (it != end) { inserter(it->first, it->second); - ++it; + ++it; + } + } + + void get_headers(boost::function predicate, + boost::function inserter) const { + std::multimap::const_iterator it = headers_.begin(), + end = headers_.end(); + while (it != end) { + if (predicate(it->first, it->second)) + inserter(it->first, it->second); + ++it; + } + } + + void get_body(std::string & body) { + body = body_; } - } - void get_body(std::string & body) { - body = body_; - } - - void get_body(boost::function)> chunk_reader, size_t size) const { - static char const * nullptr_ = 0; - if (body_read_pos == body_.size()) - chunk_reader(boost::make_iterator_range(nullptr_, nullptr_)); - std::string::const_iterator it = body_.begin(), - end = body_.end(); - std::advance(it, body_read_pos); - size_t max_size = std::distance(it, end); - size_t max_read = std::min(max_size, size); - std::string::const_iterator start = it; - end = start; - std::advance(end, max_read); - body_read_pos += max_read; - chunk_reader(boost::make_iterator_range(&(*start), &(*end))); - } - - message_pimpl * clone() { - message_pimpl * other = new(std::nothrow) message_pimpl; - other->destination_ = this->destination_; - other->source_ = this->source_; - other->headers_ = this->headers_; - other->body_ = this->body_; - return other; - } - - private: - std::string destination_, source_; - std::multimap headers_; - // TODO: use Boost.IOStreams here later on. - std::string body_; - mutable size_t body_read_pos; -}; - -message::message() + void get_body(boost::function chunk_reader, size_t size) const { + if (body_read_pos == body_.size()) chunk_reader(body_.end(), 0); + std::string::const_iterator it = body_.begin(), + end = body_.end(); + std::advance(it, body_read_pos); + size_t max_size = std::distance(it, end); + size_t max_read = std::min(max_size, size); + std::string::const_iterator start = it; + end = start; + std::advance(end, max_read); + body_read_pos += max_read; + chunk_reader(start, max_read); + } + + message_pimpl * clone() { + message_pimpl * other = new(std::nothrow) message_pimpl; + other->destination_ = this->destination_; + other->source_ = this->source_; + other->headers_ = this->headers_; + other->body_ = this->body_; + return other; + } + + private: + std::string destination_, source_; + std::multimap headers_; + // TODO: use Boost.IOStreams here later on. + std::string body_; + mutable size_t body_read_pos; + }; + + message::message() : pimpl(new (std::nothrow) message_pimpl) -{} + {} -message::message(message const & other) + message::message(message const & other) : pimpl(other.pimpl->clone()) -{} - -message& message::operator=(message other) { - *pimpl = *other.pimpl; - return *this; -} + {} -message::~message() { - delete pimpl; -} + message& message::operator=(message const &other) { + *pimpl = *other.pimpl; + return *this; + } -void message::set_destination(std::string const & destination) { - pimpl->set_destination(destination); -} + message& message::operator=(message &&other) { + *pimpl = *std::move(other.pimpl); + return *this; + } -void message::set_source(std::string const & source) { - pimpl->set_source(source); -} + message::~message() { + delete pimpl; + } -void message::append_header(std::string const & name, - std::string const & value) { - pimpl->append_header(name, value); -} + void message::set_destination(std::string const & destination) { + pimpl->set_destination(destination); + } -void message::remove_headers(std::string const & name) { - pimpl->remove_headers(name); -} + void message::set_source(std::string const & source) { + pimpl->set_source(source); + } -void message::remove_headers() { - pimpl->remove_headers(); -} + void message::append_header(std::string const & name, + std::string const & value) { + pimpl->append_header(name, value); + } -void message::set_body(std::string const & body) { - pimpl->set_body(body); -} + void message::remove_headers(std::string const & name) { + pimpl->remove_headers(name); + } -void message::append_body(std::string const & data) { - pimpl->append_body(data); -} + void message::remove_headers() { + pimpl->remove_headers(); + } -void message::get_destination(std::string & destination) const { - pimpl->get_destination(destination); -} + void message::set_body(std::string const & body) { + pimpl->set_body(body); + } -void message::get_source(std::string & source) const { - pimpl->get_source(source); -} + void message::append_body(std::string const & data) { + pimpl->append_body(data); + } -void message::get_headers(boost::function inserter) const { - pimpl->get_headers(inserter); -} + void message::get_destination(std::string & destination) const { + pimpl->get_destination(destination); + } -void message::get_headers(std::string const & name, - boost::function inserter) const { - pimpl->get_headers(name, inserter); -} + void message::get_source(std::string & source) const { + pimpl->get_source(source); + } -void message::get_headers(boost::function predicate, - boost::function inserter) const { - pimpl->get_headers(predicate, inserter); -} + void message::get_headers(boost::function inserter) const { + pimpl->get_headers(inserter); + } -void message::get_body(std::string & body) const { - pimpl->get_body(body); -} + void message::get_headers(std::string const & name, + boost::function inserter) const { + pimpl->get_headers(name, inserter); + } -void message::get_body(boost::function)> chunk_reader, size_t size) const { - pimpl->get_body(chunk_reader, size); -} + void message::get_headers(boost::function predicate, + boost::function inserter) const { + pimpl->get_headers(predicate, inserter); + } -void message::swap(message & other) { - std::swap(this->pimpl, other.pimpl); -} + void message::get_body(std::string & body) const { + pimpl->get_body(body); + } + void message::get_body(boost::function chunk_reader, size_t size) const { + pimpl->get_body(chunk_reader, size); + } + + void message::swap(message & other) { + std::swap(this->pimpl, other.pimpl); + } + } /* network */ #endif /* NETWORK_MESSAGE_IPP_20111020 */ From 47bf918071839089d129bea23680b00775356a57 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sun, 4 Nov 2012 02:22:42 +1100 Subject: [PATCH 132/196] Revert "Lining up message's get_body" This reverts commit 38fcd3a64432c870a0812e0515114256d2a626ea. --- include/network/message/message.hpp | 91 +++++---- include/network/message/message.ipp | 305 ++++++++++++++-------------- 2 files changed, 198 insertions(+), 198 deletions(-) diff --git a/include/network/message/message.hpp b/include/network/message/message.hpp index 1601e581d..67567e8c3 100644 --- a/include/network/message/message.hpp +++ b/include/network/message/message.hpp @@ -15,62 +15,65 @@ namespace network { - struct message_pimpl; +struct message_pimpl; - // The common message type. - struct message : message_base { - // Nested types - typedef boost::iterator_range< +// The common message type. +struct message : message_base { + // Nested types + typedef boost::iterator_range< std::multimap::const_iterator> headers_range; - // Constructors - message(); - message(message const & other); - message(message && other) = default; + // Constructors + message(); + message(message const & other); - // Assignment - message& operator=(message const &other); - message& operator=(message &&other); + // Assignment + message & operator=(message other); - // Mutators - virtual void set_destination(std::string const & destination); - virtual void set_source(std::string const & source); - virtual void append_header(std::string const & name, - std::string const & value); - virtual void remove_headers(std::string const & name); - virtual void remove_headers(); - virtual void set_body(std::string const & body); - virtual void append_body(std::string const & data); + // Mutators + virtual void set_destination(std::string const & destination); + virtual void set_source(std::string const & source); + virtual void append_header(std::string const & name, + std::string const & value); + virtual void remove_headers(std::string const & name); + virtual void remove_headers(); + virtual void set_body(std::string const & body); + virtual void append_body(std::string const & data); - // Retrievers - virtual void get_destination(std::string & destination) const; - virtual void get_source(std::string & source) const; - virtual void get_headers(boost::function inserter) const; - virtual void get_headers(std::string const & name, - boost::function inserter) const; - virtual void get_headers(boost::function predicate, - boost::function inserter) const; - virtual void get_body(std::string & body) const; - virtual void get_body(boost::function chunk_reader, size_t size) const; + // Retrievers + virtual void get_destination(std::string & destination) const; + virtual void get_source(std::string & source) const; + virtual void get_headers( + boost::function inserter) const; + virtual void get_headers( + std::string const & name, + boost::function inserter) const; + virtual void get_headers( + boost::function predicate, + boost::function inserter) const; + virtual void get_body(std::string & body) const; + virtual void get_body( + boost::function)> chunk_reader, + size_t size) const; - void swap(message & other); + void swap(message & other); - // Destructor - virtual ~message(); - private: - message_pimpl * pimpl; - }; + // Destructor + virtual ~message(); + private: + message_pimpl * pimpl; +}; - inline void swap(message & left, message & right) { +inline void swap(message & left, message & right) { left.swap(right); - } +} - template - message_base & operator<< (message_base & msg, Directive directive) { - directive(msg); - return msg; - } +template +message_base & operator<< (message_base & msg, Directive directive) { + directive(msg); + return msg; +} } // namespace network diff --git a/include/network/message/message.ipp b/include/network/message/message.ipp index 2ba1b418c..4822c72d8 100644 --- a/include/network/message/message.ipp +++ b/include/network/message/message.ipp @@ -14,200 +14,197 @@ namespace network { - struct message_pimpl { - message_pimpl() : +struct message_pimpl { + message_pimpl() : destination_(), source_(), headers_(), body_(), body_read_pos(0) - {} - - void set_destination(std::string const & destination) { - destination_ = destination; - } - - void set_source(std::string const & source) { - source_ = source; - } - - void append_header(std::string const & name, - std::string const & value) { - headers_.insert(std::make_pair(name, value)); - } + {} - void remove_headers(std::string const & name) { - headers_.erase(name); - } + void set_destination(std::string const & destination) { + destination_ = destination; + } - void remove_headers() { - std::multimap().swap(headers_); - } + void set_source(std::string const & source) { + source_ = source; + } - void set_body(std::string const & body) { - body_ = body; - } + void append_header(std::string const & name, + std::string const & value) { + headers_.insert(std::make_pair(name, value)); + } - void append_body(std::string const & data) { - body_.append(data); - } + void remove_headers(std::string const & name) { + headers_.erase(name); + } - // Retrievers - void get_destination(std::string & destination) const { - destination = destination_; - } + void remove_headers() { + std::multimap().swap(headers_); + } - void get_source(std::string & source) const { - source = source_; - } + void set_body(std::string const & body) { + body_ = body; + } - void get_headers(boost::function inserter) const { - std::multimap::const_iterator it = headers_.begin(), - end = headers_.end(); - for (; it != end; ++it) inserter(it->first, it->second); - } + void append_body(std::string const & data) { + body_.append(data); + } - void get_headers(std::string const & name, - boost::function inserter) const { - std::multimap::const_iterator it = headers_.find(name), - end= headers_.end(); - while (it != end) { - inserter(it->first, it->second); - ++it; - } - } + // Retrievers + void get_destination(std::string & destination) const { + destination = destination_; + } - void get_headers(boost::function predicate, - boost::function inserter) const { - std::multimap::const_iterator it = headers_.begin(), - end = headers_.end(); - while (it != end) { - if (predicate(it->first, it->second)) - inserter(it->first, it->second); - ++it; - } - } + void get_source(std::string & source) const { + source = source_; + } - void get_body(std::string & body) { - body = body_; - } + void get_headers(boost::function inserter) const { + std::multimap::const_iterator it = headers_.begin(), + end = headers_.end(); + for (; it != end; ++it) inserter(it->first, it->second); + } - void get_body(boost::function chunk_reader, size_t size) const { - if (body_read_pos == body_.size()) chunk_reader(body_.end(), 0); - std::string::const_iterator it = body_.begin(), - end = body_.end(); - std::advance(it, body_read_pos); - size_t max_size = std::distance(it, end); - size_t max_read = std::min(max_size, size); - std::string::const_iterator start = it; - end = start; - std::advance(end, max_read); - body_read_pos += max_read; - chunk_reader(start, max_read); + void get_headers(std::string const & name, + boost::function inserter) const { + std::multimap::const_iterator it = headers_.find(name), + end= headers_.end(); + while (it != end) { + inserter(it->first, it->second); + ++it; } + } - message_pimpl * clone() { - message_pimpl * other = new(std::nothrow) message_pimpl; - other->destination_ = this->destination_; - other->source_ = this->source_; - other->headers_ = this->headers_; - other->body_ = this->body_; - return other; + void get_headers(boost::function predicate, + boost::function inserter) const { + std::multimap::const_iterator it = headers_.begin(), + end = headers_.end(); + while (it != end) { + if (predicate(it->first, it->second)) + inserter(it->first, it->second); + ++it; } + } - private: - std::string destination_, source_; - std::multimap headers_; - // TODO: use Boost.IOStreams here later on. - std::string body_; - mutable size_t body_read_pos; - }; - - message::message() + void get_body(std::string & body) { + body = body_; + } + + void get_body(boost::function)> chunk_reader, size_t size) const { + static char const * nullptr_ = 0; + if (body_read_pos == body_.size()) + chunk_reader(boost::make_iterator_range(nullptr_, nullptr_)); + std::string::const_iterator it = body_.begin(), + end = body_.end(); + std::advance(it, body_read_pos); + size_t max_size = std::distance(it, end); + size_t max_read = std::min(max_size, size); + std::string::const_iterator start = it; + end = start; + std::advance(end, max_read); + body_read_pos += max_read; + chunk_reader(boost::make_iterator_range(&(*start), &(*end))); + } + + message_pimpl * clone() { + message_pimpl * other = new(std::nothrow) message_pimpl; + other->destination_ = this->destination_; + other->source_ = this->source_; + other->headers_ = this->headers_; + other->body_ = this->body_; + return other; + } + + private: + std::string destination_, source_; + std::multimap headers_; + // TODO: use Boost.IOStreams here later on. + std::string body_; + mutable size_t body_read_pos; +}; + +message::message() : pimpl(new (std::nothrow) message_pimpl) - {} +{} - message::message(message const & other) +message::message(message const & other) : pimpl(other.pimpl->clone()) - {} +{} - message& message::operator=(message const &other) { - *pimpl = *other.pimpl; - return *this; - } +message& message::operator=(message other) { + *pimpl = *other.pimpl; + return *this; +} - message& message::operator=(message &&other) { - *pimpl = *std::move(other.pimpl); - return *this; - } +message::~message() { + delete pimpl; +} - message::~message() { - delete pimpl; - } +void message::set_destination(std::string const & destination) { + pimpl->set_destination(destination); +} - void message::set_destination(std::string const & destination) { - pimpl->set_destination(destination); - } +void message::set_source(std::string const & source) { + pimpl->set_source(source); +} - void message::set_source(std::string const & source) { - pimpl->set_source(source); - } +void message::append_header(std::string const & name, + std::string const & value) { + pimpl->append_header(name, value); +} - void message::append_header(std::string const & name, - std::string const & value) { - pimpl->append_header(name, value); - } +void message::remove_headers(std::string const & name) { + pimpl->remove_headers(name); +} - void message::remove_headers(std::string const & name) { - pimpl->remove_headers(name); - } +void message::remove_headers() { + pimpl->remove_headers(); +} - void message::remove_headers() { - pimpl->remove_headers(); - } +void message::set_body(std::string const & body) { + pimpl->set_body(body); +} - void message::set_body(std::string const & body) { - pimpl->set_body(body); - } +void message::append_body(std::string const & data) { + pimpl->append_body(data); +} - void message::append_body(std::string const & data) { - pimpl->append_body(data); - } +void message::get_destination(std::string & destination) const { + pimpl->get_destination(destination); +} - void message::get_destination(std::string & destination) const { - pimpl->get_destination(destination); - } +void message::get_source(std::string & source) const { + pimpl->get_source(source); +} - void message::get_source(std::string & source) const { - pimpl->get_source(source); - } +void message::get_headers(boost::function inserter) const { + pimpl->get_headers(inserter); +} - void message::get_headers(boost::function inserter) const { - pimpl->get_headers(inserter); - } +void message::get_headers(std::string const & name, + boost::function inserter) const { + pimpl->get_headers(name, inserter); +} - void message::get_headers(std::string const & name, - boost::function inserter) const { - pimpl->get_headers(name, inserter); - } +void message::get_headers(boost::function predicate, + boost::function inserter) const { + pimpl->get_headers(predicate, inserter); +} - void message::get_headers(boost::function predicate, - boost::function inserter) const { - pimpl->get_headers(predicate, inserter); - } +void message::get_body(std::string & body) const { + pimpl->get_body(body); +} - void message::get_body(std::string & body) const { - pimpl->get_body(body); - } +void message::get_body(boost::function)> chunk_reader, size_t size) const { + pimpl->get_body(chunk_reader, size); +} + +void message::swap(message & other) { + std::swap(this->pimpl, other.pimpl); +} - void message::get_body(boost::function chunk_reader, size_t size) const { - pimpl->get_body(chunk_reader, size); - } - - void message::swap(message & other) { - std::swap(this->pimpl, other.pimpl); - } - } /* network */ #endif /* NETWORK_MESSAGE_IPP_20111020 */ From 3c7c8fae60932a04aedca3098a4cd2e2306f8254 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sun, 4 Nov 2012 02:23:33 +1100 Subject: [PATCH 133/196] Revert "Revert "Lining up message's get_body"" This reverts commit 47bf918071839089d129bea23680b00775356a57. --- include/network/message/message.hpp | 91 ++++----- include/network/message/message.ipp | 305 ++++++++++++++-------------- 2 files changed, 198 insertions(+), 198 deletions(-) diff --git a/include/network/message/message.hpp b/include/network/message/message.hpp index 67567e8c3..1601e581d 100644 --- a/include/network/message/message.hpp +++ b/include/network/message/message.hpp @@ -15,65 +15,62 @@ namespace network { -struct message_pimpl; + struct message_pimpl; -// The common message type. -struct message : message_base { - // Nested types - typedef boost::iterator_range< + // The common message type. + struct message : message_base { + // Nested types + typedef boost::iterator_range< std::multimap::const_iterator> headers_range; - // Constructors - message(); - message(message const & other); + // Constructors + message(); + message(message const & other); + message(message && other) = default; - // Assignment - message & operator=(message other); + // Assignment + message& operator=(message const &other); + message& operator=(message &&other); - // Mutators - virtual void set_destination(std::string const & destination); - virtual void set_source(std::string const & source); - virtual void append_header(std::string const & name, - std::string const & value); - virtual void remove_headers(std::string const & name); - virtual void remove_headers(); - virtual void set_body(std::string const & body); - virtual void append_body(std::string const & data); + // Mutators + virtual void set_destination(std::string const & destination); + virtual void set_source(std::string const & source); + virtual void append_header(std::string const & name, + std::string const & value); + virtual void remove_headers(std::string const & name); + virtual void remove_headers(); + virtual void set_body(std::string const & body); + virtual void append_body(std::string const & data); - // Retrievers - virtual void get_destination(std::string & destination) const; - virtual void get_source(std::string & source) const; - virtual void get_headers( - boost::function inserter) const; - virtual void get_headers( - std::string const & name, - boost::function inserter) const; - virtual void get_headers( - boost::function predicate, - boost::function inserter) const; - virtual void get_body(std::string & body) const; - virtual void get_body( - boost::function)> chunk_reader, - size_t size) const; + // Retrievers + virtual void get_destination(std::string & destination) const; + virtual void get_source(std::string & source) const; + virtual void get_headers(boost::function inserter) const; + virtual void get_headers(std::string const & name, + boost::function inserter) const; + virtual void get_headers(boost::function predicate, + boost::function inserter) const; + virtual void get_body(std::string & body) const; + virtual void get_body(boost::function chunk_reader, size_t size) const; - void swap(message & other); + void swap(message & other); - // Destructor - virtual ~message(); - private: - message_pimpl * pimpl; -}; + // Destructor + virtual ~message(); + private: + message_pimpl * pimpl; + }; -inline void swap(message & left, message & right) { + inline void swap(message & left, message & right) { left.swap(right); -} + } -template -message_base & operator<< (message_base & msg, Directive directive) { - directive(msg); - return msg; -} + template + message_base & operator<< (message_base & msg, Directive directive) { + directive(msg); + return msg; + } } // namespace network diff --git a/include/network/message/message.ipp b/include/network/message/message.ipp index 4822c72d8..2ba1b418c 100644 --- a/include/network/message/message.ipp +++ b/include/network/message/message.ipp @@ -14,197 +14,200 @@ namespace network { -struct message_pimpl { - message_pimpl() : + struct message_pimpl { + message_pimpl() : destination_(), source_(), headers_(), body_(), body_read_pos(0) - {} - - void set_destination(std::string const & destination) { - destination_ = destination; - } + {} - void set_source(std::string const & source) { - source_ = source; - } + void set_destination(std::string const & destination) { + destination_ = destination; + } - void append_header(std::string const & name, - std::string const & value) { - headers_.insert(std::make_pair(name, value)); - } + void set_source(std::string const & source) { + source_ = source; + } - void remove_headers(std::string const & name) { - headers_.erase(name); - } + void append_header(std::string const & name, + std::string const & value) { + headers_.insert(std::make_pair(name, value)); + } - void remove_headers() { - std::multimap().swap(headers_); - } + void remove_headers(std::string const & name) { + headers_.erase(name); + } - void set_body(std::string const & body) { - body_ = body; - } + void remove_headers() { + std::multimap().swap(headers_); + } - void append_body(std::string const & data) { - body_.append(data); - } + void set_body(std::string const & body) { + body_ = body; + } - // Retrievers - void get_destination(std::string & destination) const { - destination = destination_; - } + void append_body(std::string const & data) { + body_.append(data); + } - void get_source(std::string & source) const { - source = source_; - } + // Retrievers + void get_destination(std::string & destination) const { + destination = destination_; + } - void get_headers(boost::function inserter) const { - std::multimap::const_iterator it = headers_.begin(), - end = headers_.end(); - for (; it != end; ++it) inserter(it->first, it->second); - } + void get_source(std::string & source) const { + source = source_; + } - void get_headers(std::string const & name, - boost::function inserter) const { - std::multimap::const_iterator it = headers_.find(name), - end= headers_.end(); - while (it != end) { - inserter(it->first, it->second); - ++it; + void get_headers(boost::function inserter) const { + std::multimap::const_iterator it = headers_.begin(), + end = headers_.end(); + for (; it != end; ++it) inserter(it->first, it->second); } - } - void get_headers(boost::function predicate, - boost::function inserter) const { - std::multimap::const_iterator it = headers_.begin(), - end = headers_.end(); - while (it != end) { - if (predicate(it->first, it->second)) + void get_headers(std::string const & name, + boost::function inserter) const { + std::multimap::const_iterator it = headers_.find(name), + end= headers_.end(); + while (it != end) { inserter(it->first, it->second); - ++it; + ++it; + } + } + + void get_headers(boost::function predicate, + boost::function inserter) const { + std::multimap::const_iterator it = headers_.begin(), + end = headers_.end(); + while (it != end) { + if (predicate(it->first, it->second)) + inserter(it->first, it->second); + ++it; + } + } + + void get_body(std::string & body) { + body = body_; } - } - void get_body(std::string & body) { - body = body_; - } - - void get_body(boost::function)> chunk_reader, size_t size) const { - static char const * nullptr_ = 0; - if (body_read_pos == body_.size()) - chunk_reader(boost::make_iterator_range(nullptr_, nullptr_)); - std::string::const_iterator it = body_.begin(), - end = body_.end(); - std::advance(it, body_read_pos); - size_t max_size = std::distance(it, end); - size_t max_read = std::min(max_size, size); - std::string::const_iterator start = it; - end = start; - std::advance(end, max_read); - body_read_pos += max_read; - chunk_reader(boost::make_iterator_range(&(*start), &(*end))); - } - - message_pimpl * clone() { - message_pimpl * other = new(std::nothrow) message_pimpl; - other->destination_ = this->destination_; - other->source_ = this->source_; - other->headers_ = this->headers_; - other->body_ = this->body_; - return other; - } - - private: - std::string destination_, source_; - std::multimap headers_; - // TODO: use Boost.IOStreams here later on. - std::string body_; - mutable size_t body_read_pos; -}; - -message::message() + void get_body(boost::function chunk_reader, size_t size) const { + if (body_read_pos == body_.size()) chunk_reader(body_.end(), 0); + std::string::const_iterator it = body_.begin(), + end = body_.end(); + std::advance(it, body_read_pos); + size_t max_size = std::distance(it, end); + size_t max_read = std::min(max_size, size); + std::string::const_iterator start = it; + end = start; + std::advance(end, max_read); + body_read_pos += max_read; + chunk_reader(start, max_read); + } + + message_pimpl * clone() { + message_pimpl * other = new(std::nothrow) message_pimpl; + other->destination_ = this->destination_; + other->source_ = this->source_; + other->headers_ = this->headers_; + other->body_ = this->body_; + return other; + } + + private: + std::string destination_, source_; + std::multimap headers_; + // TODO: use Boost.IOStreams here later on. + std::string body_; + mutable size_t body_read_pos; + }; + + message::message() : pimpl(new (std::nothrow) message_pimpl) -{} + {} -message::message(message const & other) + message::message(message const & other) : pimpl(other.pimpl->clone()) -{} - -message& message::operator=(message other) { - *pimpl = *other.pimpl; - return *this; -} + {} -message::~message() { - delete pimpl; -} + message& message::operator=(message const &other) { + *pimpl = *other.pimpl; + return *this; + } -void message::set_destination(std::string const & destination) { - pimpl->set_destination(destination); -} + message& message::operator=(message &&other) { + *pimpl = *std::move(other.pimpl); + return *this; + } -void message::set_source(std::string const & source) { - pimpl->set_source(source); -} + message::~message() { + delete pimpl; + } -void message::append_header(std::string const & name, - std::string const & value) { - pimpl->append_header(name, value); -} + void message::set_destination(std::string const & destination) { + pimpl->set_destination(destination); + } -void message::remove_headers(std::string const & name) { - pimpl->remove_headers(name); -} + void message::set_source(std::string const & source) { + pimpl->set_source(source); + } -void message::remove_headers() { - pimpl->remove_headers(); -} + void message::append_header(std::string const & name, + std::string const & value) { + pimpl->append_header(name, value); + } -void message::set_body(std::string const & body) { - pimpl->set_body(body); -} + void message::remove_headers(std::string const & name) { + pimpl->remove_headers(name); + } -void message::append_body(std::string const & data) { - pimpl->append_body(data); -} + void message::remove_headers() { + pimpl->remove_headers(); + } -void message::get_destination(std::string & destination) const { - pimpl->get_destination(destination); -} + void message::set_body(std::string const & body) { + pimpl->set_body(body); + } -void message::get_source(std::string & source) const { - pimpl->get_source(source); -} + void message::append_body(std::string const & data) { + pimpl->append_body(data); + } -void message::get_headers(boost::function inserter) const { - pimpl->get_headers(inserter); -} + void message::get_destination(std::string & destination) const { + pimpl->get_destination(destination); + } -void message::get_headers(std::string const & name, - boost::function inserter) const { - pimpl->get_headers(name, inserter); -} + void message::get_source(std::string & source) const { + pimpl->get_source(source); + } -void message::get_headers(boost::function predicate, - boost::function inserter) const { - pimpl->get_headers(predicate, inserter); -} + void message::get_headers(boost::function inserter) const { + pimpl->get_headers(inserter); + } -void message::get_body(std::string & body) const { - pimpl->get_body(body); -} + void message::get_headers(std::string const & name, + boost::function inserter) const { + pimpl->get_headers(name, inserter); + } -void message::get_body(boost::function)> chunk_reader, size_t size) const { - pimpl->get_body(chunk_reader, size); -} + void message::get_headers(boost::function predicate, + boost::function inserter) const { + pimpl->get_headers(predicate, inserter); + } -void message::swap(message & other) { - std::swap(this->pimpl, other.pimpl); -} + void message::get_body(std::string & body) const { + pimpl->get_body(body); + } + void message::get_body(boost::function chunk_reader, size_t size) const { + pimpl->get_body(chunk_reader, size); + } + + void message::swap(message & other) { + std::swap(this->pimpl, other.pimpl); + } + } /* network */ #endif /* NETWORK_MESSAGE_IPP_20111020 */ From 84998d49206b2c903be5775c69dad5b8a92f2fae Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sun, 4 Nov 2012 02:23:58 +1100 Subject: [PATCH 134/196] Missed changes to the message_base type. --- include/network/message/message_base.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/network/message/message_base.hpp b/include/network/message/message_base.hpp index c3ddcb320..6d2f74efa 100644 --- a/include/network/message/message_base.hpp +++ b/include/network/message/message_base.hpp @@ -29,8 +29,8 @@ struct message_base { virtual void get_headers(boost::function inserter) const = 0; virtual void get_headers(std::string const & name, boost::function inserter) const = 0; virtual void get_headers(boost::function predicate, boost::function inserter) const = 0; + virtual void get_body(boost::function chunk_reader, size_t size) const = 0; virtual void get_body(std::string & body) const = 0; - virtual void get_body(boost::function)> chunk_reader, size_t size) const = 0; // Destructor virtual ~message_base() = 0; // pure virtual From 5100e6c4f8b8ccdf3abbb83f08367bb93bb6d6e2 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sun, 4 Nov 2012 02:26:14 +1100 Subject: [PATCH 135/196] Add move constructor and assignment for client_options. Untested, but should allow in-place definition of client_options in the client constructor. --- .../network/protocol/http/client/options.hpp | 45 +- .../network/protocol/http/client/options.ipp | 428 +++++++++--------- 2 files changed, 240 insertions(+), 233 deletions(-) diff --git a/include/network/protocol/http/client/options.hpp b/include/network/protocol/http/client/options.hpp index 4605710ae..694897e9e 100644 --- a/include/network/protocol/http/client/options.hpp +++ b/include/network/protocol/http/client/options.hpp @@ -15,22 +15,23 @@ #include #include -namespace network { -namespace http { - +namespace network { namespace http { + // Forward-declare the pimpl. class client_options_pimpl; - + // This file defines all the options supported by the HTTP client // implementation. class client_options { public: client_options(); client_options(client_options const &other); // Copy constructible. - client_options& operator=(client_options rhs); // Assignable. + client_options(client_options &&other); // Move constructible. + client_options& operator=(client_options const &rhs); // Copy assignable. + client_options& operator=(client_options &&rhs); // Move assignable. void swap(client_options &other); // Swappable. ~client_options(); // Non-virtual destructor by design. - + // When adding more supported options, follow the pattern: // // client_options& name_of_option(type variable); @@ -46,33 +47,33 @@ namespace http { // .follow_redirects() // .cache_resolved(); // client client_(options); - + // These are the setter and getter for the Boost.Asio io_service to use. // The default setting when un-set is nullptr, meaning it signals the client // implementation that the user doesn't want to use his own io_service // instance. client_options& io_service(boost::asio::io_service *io_service); boost::asio::io_service* io_service() const; - + // The following option determines whether the client should follow // HTTP redirects when the implementation encounters them. The default // behavior is to return false. client_options& follow_redirects(bool setting=false); bool follow_redirects() const; - + // The following options determines whether the client should cache // resolved endpoints. The default behavior is to not cache resolved // endpoints. client_options& cache_resolved(bool setting=true); bool cache_resolved() const; - + // The following options provide the OpenSSL certificate paths to use. // Setting these options without OpenSSL support is valid, but the client // may throw an exception when attempting to make SSL connections. The // default implementation doesn't define certificate paths. client_options& add_openssl_certificate_path(std::string const &path); std::list const & openssl_certificate_paths() const; - + // The following options provide the OpenSSL certificate authority paths // where the certificates can be found. Setting these options without OpenSSL // support is valid, but the client may throw an exception when attempting @@ -90,19 +91,19 @@ namespace http { // for creating the correct instances of the appropriate connection. client_options& connection_factory(boost::shared_ptr factory); boost::shared_ptr connection_factory() const; - + // More options go here... - + private: // We hide the options in a pimpl, so that when new options get added // we can keep backward binary compatibility and re-link to the new - // supported options without having to break those + // supported options without having to break those client_options_pimpl *pimpl; }; - + // Forward declare the request_options pimpl. class request_options_pimpl; - + // This is the per-request options we allow users to provide. These allow // for defining operational options that control a request's flow. class request_options { @@ -112,7 +113,7 @@ namespace http { request_options& operator=(request_options rhs); // Assignable. void swap(request_options &other); // Swappable. ~request_options(); // Non-virtual destructor by design. - + // We follow the same pattern as the client_options class and use the // chaining call pattern to set the options. When adding new options // to support, they should look roughly like so: @@ -121,27 +122,27 @@ namespace http { // type_of_option name_of_option() const; // // See client_options above for a usage example in the same vein. - + // These determine the timeout when performing requests. The default timeout // is 30,000 milliseconds (30 seconds). request_options& timeout(uint64_t milliseconds = 30 * 1000); uint64_t timeout() const; - + // These determine the maximum number of redirects to follow. The default // implementation uses 10 as the maximum. A negative value means to keep // following redirects until they no longer redirect. request_options& max_redirects(int redirects=10); int max_redirects() const; - + // More options go here... - + private: // For the same reason as the client_options being a pimpl, we do this for // minimizing the need to break ABI compatibility when adding new supported // options. request_options_pimpl *pimpl; }; - + } // namespace http } // namespace network diff --git a/include/network/protocol/http/client/options.ipp b/include/network/protocol/http/client/options.ipp index ae84dafbb..35ad46447 100644 --- a/include/network/protocol/http/client/options.ipp +++ b/include/network/protocol/http/client/options.ipp @@ -11,268 +11,274 @@ #include #include -namespace network { -namespace http { - -class client_options_pimpl { -public: - client_options_pimpl() - : io_service_(0) - , follow_redirects_(false) - , cache_resolved_(false) - , openssl_certificate_paths_() - , openssl_verify_paths_() - , connection_manager_() - , connection_factory_() - { - } +namespace network { namespace http { + + class client_options_pimpl { + public: + client_options_pimpl() + : io_service_(0) + , follow_redirects_(false) + , cache_resolved_(false) + , openssl_certificate_paths_() + , openssl_verify_paths_() + , connection_manager_() + , connection_factory_() + { + } + + client_options_pimpl *clone() const { + return new (std::nothrow) client_options_pimpl(*this); + } + + void io_service(boost::asio::io_service *io_service) { + io_service_ = io_service_; + } + + boost::asio::io_service* io_service() const { + return io_service_; + } + + void follow_redirects(bool setting) { + follow_redirects_ = setting; + } + + bool follow_redirects() const { + return follow_redirects_; + } + + void cache_resolved(bool setting) { + cache_resolved_ = setting; + } + + bool cache_resolved() const { + return cache_resolved_; + } + + void add_openssl_certificate_path(std::string const &path) { + openssl_certificate_paths_.push_back(path); + } + + std::list const & openssl_certificate_paths() const { + return openssl_certificate_paths_; + } + + void add_openssl_verify_path(std::string const &path) { + openssl_verify_paths_.push_back(path); + } + + std::list const & openssl_verify_paths() const { + return openssl_verify_paths_; + } + + void connection_manager(boost::shared_ptr manager) { + connection_manager_ = manager; + } + + boost::shared_ptr connection_manager() const { + return connection_manager_; + } + + void connection_factory(boost::shared_ptr factory) { + connection_factory_ = factory; + } + + boost::shared_ptr connection_factory() const { + return connection_factory_; + } + + private: + client_options_pimpl(client_options_pimpl const &other) + : io_service_(other.io_service_) + , follow_redirects_(other.follow_redirects_) + , cache_resolved_(other.cache_resolved_) + , openssl_certificate_paths_(other.openssl_certificate_paths_) + , openssl_verify_paths_(other.openssl_verify_paths_) + , connection_manager_(other.connection_manager_) + , connection_factory_(other.connection_factory_) + {} + + client_options_pimpl& operator=(client_options_pimpl); // cannot assign + + // Here's the list of members. + boost::asio::io_service *io_service_; + bool follow_redirects_, cache_resolved_; + std::list openssl_certificate_paths_, openssl_verify_paths_; + boost::shared_ptr connection_manager_; + boost::shared_ptr connection_factory_; + }; + + client_options::client_options() + : pimpl(new (std::nothrow) client_options_pimpl()) + {} - client_options_pimpl *clone() const { - return new (std::nothrow) client_options_pimpl(*this); - } + client_options::client_options(client_options const &other) + : pimpl(other.pimpl->clone()) + {} - void io_service(boost::asio::io_service *io_service) { - io_service_ = io_service_; + client_options& client_options::operator=(client_options const &rhs) { + client_options copy(rhs); + copy.swap(*this); + return *this; } - boost::asio::io_service* io_service() const { - return io_service_; + client_options& client_options::operator=(client_options &&rhs) { + rhs.swap(*this); + return *this; } - void follow_redirects(bool setting) { - follow_redirects_ = setting; + void client_options::swap(client_options &other) { + using std::swap; + swap(other.pimpl, this->pimpl); } - bool follow_redirects() const { - return follow_redirects_; + client_options::~client_options() { + delete pimpl; + pimpl = nullptr; } - void cache_resolved(bool setting) { - cache_resolved_ = setting; + client_options& client_options::io_service(boost::asio::io_service *io_service) { + pimpl->io_service(io_service); + return *this; } - bool cache_resolved() const { - return cache_resolved_; + boost::asio::io_service* client_options::io_service() const { + return pimpl->io_service(); } - void add_openssl_certificate_path(std::string const &path) { - openssl_certificate_paths_.push_back(path); + client_options& client_options::follow_redirects(bool follow_redirects) { + pimpl->follow_redirects(follow_redirects); + return *this; } - std::list const & openssl_certificate_paths() const { - return openssl_certificate_paths_; + bool client_options::follow_redirects() const { + return pimpl->follow_redirects(); } - void add_openssl_verify_path(std::string const &path) { - openssl_verify_paths_.push_back(path); + client_options& client_options::cache_resolved(bool cache_resolved) { + pimpl->cache_resolved(cache_resolved); + return *this; } - std::list const & openssl_verify_paths() const { - return openssl_verify_paths_; + bool client_options::cache_resolved() const { + return pimpl->cache_resolved(); } - void connection_manager(boost::shared_ptr manager) { - connection_manager_ = manager; + client_options& client_options::add_openssl_certificate_path(std::string const &path) { + pimpl->add_openssl_certificate_path(path); + return *this; } - boost::shared_ptr connection_manager() const { - return connection_manager_; + std::list const & client_options::openssl_certificate_paths() const { + return pimpl->openssl_certificate_paths(); } - void connection_factory(boost::shared_ptr factory) { - connection_factory_ = factory; + client_options& client_options::add_openssl_verify_path(std::string const &path) { + pimpl->add_openssl_verify_path(path); + return *this; } - boost::shared_ptr connection_factory() const { - return connection_factory_; + std::list const & client_options::openssl_verify_paths() const { + return pimpl->openssl_verify_paths(); } -private: - client_options_pimpl(client_options_pimpl const &other) - : io_service_(other.io_service_) - , follow_redirects_(other.follow_redirects_) - , cache_resolved_(other.cache_resolved_) - , openssl_certificate_paths_(other.openssl_certificate_paths_) - , openssl_verify_paths_(other.openssl_verify_paths_) - , connection_manager_(other.connection_manager_) - , connection_factory_(other.connection_factory_) - {} - - client_options_pimpl& operator=(client_options_pimpl); // cannot assign - - // Here's the list of members. - boost::asio::io_service *io_service_; - bool follow_redirects_, cache_resolved_; - std::list openssl_certificate_paths_, openssl_verify_paths_; - boost::shared_ptr connection_manager_; - boost::shared_ptr connection_factory_; -}; - -client_options::client_options() -: pimpl(new (std::nothrow) client_options_pimpl()) -{} - -client_options::client_options(client_options const &other) -: pimpl(other.pimpl->clone()) -{} - -client_options& client_options::operator=(client_options rhs) { - rhs.swap(*this); - return *this; -} - -void client_options::swap(client_options &other) { - std::swap(other.pimpl, this->pimpl); -} - -client_options::~client_options() { - delete pimpl; - pimpl = 0; -} - -client_options& client_options::io_service(boost::asio::io_service *io_service) { - pimpl->io_service(io_service); - return *this; -} - -boost::asio::io_service* client_options::io_service() const { - return pimpl->io_service(); -} - -client_options& client_options::follow_redirects(bool follow_redirects) { - pimpl->follow_redirects(follow_redirects); - return *this; -} - -bool client_options::follow_redirects() const { - return pimpl->follow_redirects(); -} - -client_options& client_options::cache_resolved(bool cache_resolved) { - pimpl->cache_resolved(cache_resolved); - return *this; -} - -bool client_options::cache_resolved() const { - return pimpl->cache_resolved(); -} - -client_options& client_options::add_openssl_certificate_path(std::string const &path) { - pimpl->add_openssl_certificate_path(path); - return *this; -} - -std::list const & client_options::openssl_certificate_paths() const { - return pimpl->openssl_certificate_paths(); -} - -client_options& client_options::add_openssl_verify_path(std::string const &path) { - pimpl->add_openssl_verify_path(path); - return *this; -} - -std::list const & client_options::openssl_verify_paths() const { - return pimpl->openssl_verify_paths(); -} - -client_options& client_options::connection_manager(boost::shared_ptr manager) { - pimpl->connection_manager(manager); - return *this; -} - -boost::shared_ptr client_options::connection_manager() const { - return pimpl->connection_manager(); -} - -client_options& client_options::connection_factory(boost::shared_ptr factory) { - pimpl->connection_factory(factory); - return *this; -} - -boost::shared_ptr client_options::connection_factory() const { - return pimpl->connection_factory(); -} - -// End of client_options. - -class request_options_pimpl { -public: - request_options_pimpl() - : timeout_ms_(30 * 1000) - , max_redirects_(10) - {} - - request_options_pimpl *clone() const { - return new (std::nothrow) request_options_pimpl(*this); + client_options& client_options::connection_manager(boost::shared_ptr manager) { + pimpl->connection_manager(manager); + return *this; } - void timeout(uint64_t milliseconds) { - timeout_ms_ = milliseconds; + boost::shared_ptr client_options::connection_manager() const { + return pimpl->connection_manager(); } - uint64_t timeout() const { - return timeout_ms_; + client_options& client_options::connection_factory(boost::shared_ptr factory) { + pimpl->connection_factory(factory); + return *this; } - void max_redirects(int redirects) { - max_redirects_ = redirects; + boost::shared_ptr client_options::connection_factory() const { + return pimpl->connection_factory(); } - int max_redirects() const { - return max_redirects_; - } + // End of client_options. -private: - uint64_t timeout_ms_; - int max_redirects_; + class request_options_pimpl { + public: + request_options_pimpl() + : timeout_ms_(30 * 1000) + , max_redirects_(10) + {} - request_options_pimpl(request_options_pimpl const &other) - : timeout_ms_(other.timeout_ms_) - , max_redirects_(other.max_redirects_) - {} + request_options_pimpl *clone() const { + return new (std::nothrow) request_options_pimpl(*this); + } - request_options_pimpl& operator=(request_options_pimpl); // cannot be assigned. -}; + void timeout(uint64_t milliseconds) { + timeout_ms_ = milliseconds; + } -request_options::request_options() -: pimpl(new (std::nothrow) request_options_pimpl) -{} + uint64_t timeout() const { + return timeout_ms_; + } -request_options::request_options(request_options const &other) -: pimpl(other.pimpl->clone()) -{} + void max_redirects(int redirects) { + max_redirects_ = redirects; + } -request_options& request_options::operator=(request_options rhs) { - rhs.swap(*this); - return *this; -} + int max_redirects() const { + return max_redirects_; + } -void request_options::swap(request_options &other) { - std::swap(other.pimpl, this->pimpl); -} + private: + uint64_t timeout_ms_; + int max_redirects_; -request_options::~request_options() { - delete pimpl; -} + request_options_pimpl(request_options_pimpl const &other) + : timeout_ms_(other.timeout_ms_) + , max_redirects_(other.max_redirects_) + {} -request_options& request_options::timeout(uint64_t milliseconds) { - pimpl->timeout(milliseconds); - return *this; -} + request_options_pimpl& operator=(request_options_pimpl); // cannot be assigned. + }; -uint64_t request_options::timeout() const { - return pimpl->timeout(); -} + request_options::request_options() + : pimpl(new (std::nothrow) request_options_pimpl) + {} -request_options& request_options::max_redirects(int redirects) { - pimpl->max_redirects(redirects); - return *this; -} + request_options::request_options(request_options const &other) + : pimpl(other.pimpl->clone()) + {} -int request_options::max_redirects() const { - return pimpl->max_redirects(); -} + request_options& request_options::operator=(request_options rhs) { + rhs.swap(*this); + return *this; + } + void request_options::swap(request_options &other) { + std::swap(other.pimpl, this->pimpl); + } + + request_options::~request_options() { + delete pimpl; + } + + request_options& request_options::timeout(uint64_t milliseconds) { + pimpl->timeout(milliseconds); + return *this; + } + + uint64_t request_options::timeout() const { + return pimpl->timeout(); + } + + request_options& request_options::max_redirects(int redirects) { + pimpl->max_redirects(redirects); + return *this; + } + + int request_options::max_redirects() const { + return pimpl->max_redirects(); + } + } // namespace http } // namespace network From 2b8dfc13e6c79cb019d3e622ef07a87a59e055a1 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sun, 4 Nov 2012 02:27:00 +1100 Subject: [PATCH 136/196] Missed change to request_base.hpp Required follow-up to message_base changes. --- include/network/protocol/http/request/request_base.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/network/protocol/http/request/request_base.hpp b/include/network/protocol/http/request/request_base.hpp index c0e1f68e4..e4d7b446e 100644 --- a/include/network/protocol/http/request/request_base.hpp +++ b/include/network/protocol/http/request/request_base.hpp @@ -55,7 +55,7 @@ struct request_base : message_base, request_storage_base { virtual void get_status(std::string & status) const = 0; virtual void get_status_message(std::string & status_message) const = 0; virtual void get_body(boost::function chunk_reader) const = 0; - virtual void get_body(std::string const & body) const = 0; + virtual void get_body(std::string & body) const = 0; virtual ~request_base() = 0; }; From 2bebdfaa8eaeccc40d73da7be4e78ab6dd303f1d Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sun, 4 Nov 2012 02:53:36 +1100 Subject: [PATCH 137/196] Re-indent with Xcode. Prepare for further changes. --- include/network/utils/thread_pool.ipp | 140 +++++++++++++------------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/include/network/utils/thread_pool.ipp b/include/network/utils/thread_pool.ipp index 3cf14b226..9bebc40c8 100644 --- a/include/network/utils/thread_pool.ipp +++ b/include/network/utils/thread_pool.ipp @@ -11,111 +11,111 @@ namespace network { namespace utils { -struct thread_pool_pimpl { + struct thread_pool_pimpl { thread_pool_pimpl( - std::size_t threads = 1, - io_service_ptr io_service = io_service_ptr(), - worker_threads_ptr worker_threads = worker_threads_ptr() - ) + std::size_t threads = 1, + io_service_ptr io_service = io_service_ptr(), + worker_threads_ptr worker_threads = worker_threads_ptr() + ) : threads_(threads) , io_service_(io_service) , worker_threads_(worker_threads) , sentinel_() { - bool commit = false; - BOOST_SCOPE_EXIT((&commit)(&io_service_)(&worker_threads_)(&sentinel_)) { - if (!commit) { - sentinel_.reset(); - io_service_.reset(); - if (worker_threads_.get()) { - worker_threads_->interrupt_all(); - worker_threads_->join_all(); - } - worker_threads_.reset(); - } - } BOOST_SCOPE_EXIT_END - - if (!io_service_.get()) { - io_service_.reset(new boost::asio::io_service); + bool commit = false; + BOOST_SCOPE_EXIT((&commit)(&io_service_)(&worker_threads_)(&sentinel_)) { + if (!commit) { + sentinel_.reset(); + io_service_.reset(); + if (worker_threads_.get()) { + worker_threads_->interrupt_all(); + worker_threads_->join_all(); + } + worker_threads_.reset(); } + } BOOST_SCOPE_EXIT_END - if (!worker_threads_.get()) { - worker_threads_.reset(new boost::thread_group); - } + if (!io_service_.get()) { + io_service_.reset(new boost::asio::io_service); + } - if (!sentinel_.get()) { - sentinel_.reset(new boost::asio::io_service::work(*io_service_)); - } + if (!worker_threads_.get()) { + worker_threads_.reset(new boost::thread_group); + } - for (std::size_t counter = 0; counter < threads_; ++counter) - worker_threads_->create_thread( - boost::bind( - &boost::asio::io_service::run, - io_service_ - ) - ); + if (!sentinel_.get()) { + sentinel_.reset(new boost::asio::io_service::work(*io_service_)); + } - commit = true; + for (std::size_t counter = 0; counter < threads_; ++counter) + worker_threads_->create_thread( + boost::bind( + &boost::asio::io_service::run, + io_service_ + ) + ); + + commit = true; } std::size_t const thread_count() const { - return threads_; + return threads_; } void post(boost::function f) { - io_service_->post(f); + io_service_->post(f); } ~thread_pool_pimpl() { - sentinel_.reset(); - try { - worker_threads_->join_all(); - } catch (...) { - BOOST_ASSERT(false && "A handler was not supposed to throw, but one did."); - std::abort(); - } + sentinel_.reset(); + try { + worker_threads_->join_all(); + } catch (...) { + BOOST_ASSERT(false && "A handler was not supposed to throw, but one did."); + std::abort(); + } } void swap(thread_pool_pimpl & other) { - std::swap(other.threads_, threads_); - std::swap(other.io_service_, io_service_); - std::swap(other.worker_threads_, worker_threads_); - std::swap(other.sentinel_, sentinel_); + std::swap(other.threads_, threads_); + std::swap(other.io_service_, io_service_); + std::swap(other.worker_threads_, worker_threads_); + std::swap(other.sentinel_, sentinel_); } -protected: + protected: std::size_t threads_; io_service_ptr io_service_; worker_threads_ptr worker_threads_; sentinel_ptr sentinel_; -private: + private: thread_pool_pimpl(thread_pool_pimpl const &); // no copies please thread_pool_pimpl & operator=(thread_pool_pimpl); // no assignment please -}; + }; -thread_pool::thread_pool(std::size_t threads, - io_service_ptr io_service, - worker_threads_ptr worker_threads) -: pimpl(new (std::nothrow) thread_pool_pimpl(threads, io_service, worker_threads)) -{} + thread_pool::thread_pool(std::size_t threads, + io_service_ptr io_service, + worker_threads_ptr worker_threads) + : pimpl(new (std::nothrow) thread_pool_pimpl(threads, io_service, worker_threads)) + {} -std::size_t const thread_pool::thread_count() const { - return pimpl->thread_count(); -} + std::size_t const thread_pool::thread_count() const { + return pimpl->thread_count(); + } -void thread_pool::post(boost::function f) { - pimpl->post(f); -} - -void thread_pool::swap(thread_pool & other) { - std::swap(other.pimpl, this->pimpl); -} - -thread_pool::~thread_pool() { - delete pimpl; -} + void thread_pool::post(boost::function f) { + pimpl->post(f); + } + void thread_pool::swap(thread_pool & other) { + std::swap(other.pimpl, this->pimpl); + } + + thread_pool::~thread_pool() { + delete pimpl; + } + } // namespace utils } // namespace network - + #endif /* NETWORK_UTILS_THREAD_POOL_IPP_20111021 */ From eaa0cacd0657037e25031d0137c735cce9e96a6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B6rn=20Klatt?= Date: Sat, 3 Nov 2012 21:58:09 +0100 Subject: [PATCH 138/196] add CMake options for shared libs, tests, examples Add options to CMake to enable build of cpp-netlib as shared libraries. New options are: BUILD_SHARED_LIBS (default OFF) BUILD_TESTS (default ON) BUILD_EXAMPLES (default ON) As the current (CMakeLists-)setup of the tests and examples does not work with a shared cpp-netlib build, those get not build then. Specify with `cmake -D