diff --git a/.gitignore b/.gitignore index 9e4137734..5781679f5 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ libs/mime/test/mime-roundtrip *.a _build /.project +build/ diff --git a/.travis.yml b/.travis.yml index 3a6796d00..e29d9c567 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,55 +1,61 @@ -language: - - cpp - +sudo: false +language: cpp compiler: - - gcc - - clang - +- g++ +- clang env: - - BOOST_VER=1.54.0 BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Release" ENABLE_HTTPS="ON" - - BOOST_VER=1.54.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Release" ENABLE_HTTPS="ON" - - BOOST_VER=1.54.0 BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON" - - BOOST_VER=1.54.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON" - - BOOST_VER=1.55.0 BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Release" ENABLE_HTTPS="ON" - - BOOST_VER=1.55.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Release" ENABLE_HTTPS="ON" - - BOOST_VER=1.55.0 BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON" - - BOOST_VER=1.55.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON" - - BOOST_VER=1.54.0 BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Release" ENABLE_HTTPS="OFF" - - BOOST_VER=1.54.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Release" ENABLE_HTTPS="OFF" - - BOOST_VER=1.54.0 BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="OFF" - - BOOST_VER=1.54.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="OFF" - - BOOST_VER=1.55.0 BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Release" ENABLE_HTTPS="OFF" - - BOOST_VER=1.55.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Release" ENABLE_HTTPS="OFF" - - BOOST_VER=1.55.0 BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="OFF" - - BOOST_VER=1.55.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="OFF" - -before_install: - - if [ "${CXX}" == "g++" ] || [ ${BUILD_SHARED_LIBS} = "OFF" ]; then - sudo add-apt-repository ppa:boost-latest/ppa --yes; - sudo apt-get update; - fi - - if [ "${CXX}" == "clang++" ] && [ ${BUILD_SHARED_LIBS} = "ON" ]; then - svn export http://svn.boost.org/svn/boost/tags/release/Boost_${BOOST_VER//./_} ../boost_${BOOST_VER//./_}; - export BOOST_ROOT=$TRAVIS_BUILD_DIR/../boost_${BOOST_VER//./_}; - fi - +- BOOST_VER=1.59.0 BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Release" ENABLE_HTTPS="ON" +- BOOST_VER=1.59.0 BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Release" ENABLE_HTTPS="OFF" +- BOOST_VER=1.59.0 BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON" +- BOOST_VER=1.59.0 BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="OFF" +- BOOST_VER=1.59.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Release" ENABLE_HTTPS="ON" +- BOOST_VER=1.59.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Release" ENABLE_HTTPS="OFF" +- BOOST_VER=1.59.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON" +- BOOST_VER=1.59.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="OFF" +# Support the sanitizers in clang only +- BOOST_VER=1.59.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON" CMAKE_CXX_FLAGS="-fsanitize=thread" +- BOOST_VER=1.59.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON" CMAKE_CXX_FLAGS="-fsanitize=address" +# TODO(deanberris): It seems Boost is not msan-clean yet; report bugs and maybe fix? +#- BOOST_VER=1.59.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON" CMAKE_CXX_FLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2" +matrix: + exclude: + - compiler: g++ + env: BOOST_VER=1.59.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON" CMAKE_CXX_FLAGS="-fsanitize=thread" + - compiler: g++ + env: BOOST_VER=1.59.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON" CMAKE_CXX_FLAGS="-fsanitize=address" +# TODO(deanberris): It seems Boost is not msan-clean yet; report bugs and maybe fix? +# - compiler: g++ +# env: BOOST_VER=1.59.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON" CMAKE_CXX_FLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2" install: - - if [ "${CXX}" == "g++" ] || [ ${BUILD_SHARED_LIBS} = "OFF" ]; then - sudo apt-get install libboost${BOOST_VER/%.0/}-all-dev; - fi - - if [ "${CXX}" == "clang++" ] && [ ${BUILD_SHARED_LIBS} = "ON" ]; then - cd $BOOST_ROOT; - ./bootstrap.sh --with-toolset=$CC; - ./b2 -j4 --stagedir=.; - cd -; - fi - +- mkdir -p ${HOME}/bin +- if [ "${CC}" = "gcc" ]; then export TOOLSET="gcc"; ln -s `which g++-4.8` ${HOME}/bin/g++; + ln -s `which gcc-4.8` ${HOME}/bin/gcc; fi +- if [ "${CC}" = "clang" ]; then export TOOLSET="clang"; ln -s `which clang-3.6` ${HOME}/bin/clang; + ln -s `which clang++-3.6` ${HOME}/bin/clang++; fi +- export BOOST_VERSION=${BOOST_VER//./_} +- export PATH=${HOME}/bin:${PATH} +- travis_wait ./install-boost.sh +- export BOOST_ROOT=${HOME}/${CC}-boost_${BOOST_VER//./_} +- "${CXX} --version" +cache: + directories: + - "${HOME}/${CC}-boost_${BOOST_VER//./_}" script: - - cmake -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} - -DCPP-NETLIB_ENABLE_HTTPS=${ENABLE_HTTPS} - - make - - make test - +- pwd +- sh -x build.sh after_failure: - - cat Testing/Temporary/LastTest.log +- cat build/Testing/Temporary/LastTest.log +addons: + apt: + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.6 + - kalakris-cmake + packages: + - gcc-4.8 + - g++-4.8 + - clang-3.6 + - cmake +notifications: + slack: + secure: Y7lLjqZ83+b/jaJ5+EKwvgCDeERi4bVbDn9tLp8sieTdu+ENsPI+JmLYSXZXPpe7JrItrXW6uJJXN2wG1h7au4mpVVTghd31HBzuzrqVxDphWPhp16NYzvbAgQQRBXvFVvfSdW/Kb/n2fX6xDApY0t6vNREb/GKg0GyzESb4ZjU= diff --git a/.ycm_extra_conf.py b/.ycm_extra_conf.py index 85cf36ad9..2fca4f841 100644 --- a/.ycm_extra_conf.py +++ b/.ycm_extra_conf.py @@ -17,7 +17,7 @@ '-Wall', '-Wextra', '-Werror', - '-std=c++03', + '-std=c++11', '-isystem', '.', '-isystem', diff --git a/CMakeLists.txt b/CMakeLists.txt index 91bc3e77e..ec04a3a57 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,21 +27,25 @@ if(NOT IS_ABSOLUTE "${INSTALL_CMAKE_DIR}") set(INSTALL_CMAKE_DIR "${CMAKE_INSTALL_PREFIX}/${INSTALL_CMAKE_DIR}") endif() - if(CPP-NETLIB_BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS) message (STATUS "Linking boost testing libs dynamically...") - set(Boost_USE_STATIC_LIBS OFF) set(CPP-NETLIB_BUILD_SHARED_LIBS ON) set(BUILD_SHARED_LIBS ON) - add_definitions(-DBOOST_TEST_DYN_LINK) else() - set(Boost_USE_STATIC_LIBS ON) set(CPP-NETLIB_BUILD_SHARED_LIBS OFF) set(BUILD_SHARED_LIBS OFF) endif() +# Always use Boost's shared libraries. +set(Boost_USE_STATIC_LIBS OFF) + +# We need this for all tests to use the dynamic version. +add_definitions(-DBOOST_TEST_DYN_LINK) + +# Always use multi-threaded Boost libraries. set(Boost_USE_MULTI_THREADED ON) -find_package( Boost 1.54.0 + +find_package( Boost 1.57.0 REQUIRED unit_test_framework system regex date_time thread filesystem program_options chrono atomic ) @@ -67,15 +71,15 @@ if (OPENSSL_FOUND) endif() if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") + # Use C++11 when using GNU compilers. + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11") elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang) + # We want to link in C++11 mode in Clang too, but also set a high enough + # template depth for the template metaprogramming. + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -ftemplate-depth=256 -std=c++11") if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - # We want to link in C++11 mode if we're using Clang and on OS X. - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -ftemplate-depth=256 -std=c++11 -stdlib=libc++") - else() - # We just add the -Wall and a high enough template depth - # flag for Clang in other systems. - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -ftemplate-depth=256") + # Use libc++ only in OS X. + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") endif() endif() diff --git a/boost/mime.hpp b/boost/mime.hpp index e45d59c11..ecc9c160a 100644 --- a/boost/mime.hpp +++ b/boost/mime.hpp @@ -9,21 +9,21 @@ #ifndef _BOOST_MIME_HPP #define _BOOST_MIME_HPP +#include #include #include #include -#include -#include +#include #include #include // pulls in all of Phoenix +#include #include -#include -#include -#include -#include #include +#include +#include +#include // #define DUMP_MIME_DATA 1 @@ -321,7 +321,8 @@ static void read_multipart_body(Iterator &begin, Iterator end, "= %d %s") % mp_body.body_prolog.size() % mp_body.sub_parts.size() % mp_body.body_epilog.size() % - (mp_body.prolog_is_missing ? "(missing)" : "")) << std::endl; + (mp_body.prolog_is_missing ? "(missing)" : "")) + << std::endl; std::cout << std::endl << "****** Multipart Body Prolog *******" << std::endl; std::copy(mp_body.body_prolog.begin(), mp_body.body_prolog.end(), std::ostream_iterator(std::cout)); @@ -381,11 +382,7 @@ static boost::shared_ptr > parse_mime( template class basic_mime { public: - typedef enum { - simple_part, - multi_part, - message_part - } part_kind; + typedef enum { simple_part, multi_part, message_part } part_kind; // Types for headers typedef typename traits::string_type string_type; typedef std::pair headerEntry; @@ -618,8 +615,7 @@ class basic_mime { std::string boundary; try { boundary = detail::get_boundary(get_content_type_header()); - } - catch (std::runtime_error &) { + } catch (std::runtime_error &) { // FIXME: Make boundary strings (more?) unique boundary = str(boost::format("------=_NextPart-%s.%08ld") % detail::k_package_name % std::clock()); @@ -707,9 +703,8 @@ class basic_mime { else if (get_part_kind() == multi_part) { if (idx >= m_subparts.size()) throw std::runtime_error( - str(boost::format( - "Trying to access part %d (of %d) sub-part to a " - "multipart/xxx mime part") % + str(boost::format("Trying to access part %d (of %d) sub-part to a " + "multipart/xxx mime part") % idx % m_subparts.size())); } else { // message-part if (get_part_kind() == message_part) @@ -720,9 +715,8 @@ class basic_mime { if (idx >= m_subparts.size()) throw std::runtime_error( - str(boost::format( - "Trying to access part %d (of %d) sub-part to a " - "message/xxx mime part") % + str(boost::format("Trying to access part %d (of %d) sub-part to a " + "message/xxx mime part") % idx % m_subparts.size())); } } @@ -764,12 +758,14 @@ static boost::shared_ptr > parse_mime( #ifdef DUMP_MIME_DATA std::cout << "Content-Type: " << content_type << std::endl; std::cout << str(boost::format("retVal->get_part_kind () = %d") % - ((int)retVal->get_part_kind())) << std::endl; + ((int)retVal->get_part_kind())) + << std::endl; #endif if (retVal->get_part_kind() == mime_part::simple_part) - retVal->set_body(detail::read_simplepart_body< - typename mime_part::bodyContainer, Iterator>(begin, end)); + retVal->set_body( + detail::read_simplepart_body(begin, end)); else if (retVal->get_part_kind() == mime_part::message_part) { // If we've got a message/xxxx, then there is no body, and we have // a single diff --git a/boost/network.hpp b/boost/network.hpp index 793998941..552cbdc82 100644 --- a/boost/network.hpp +++ b/boost/network.hpp @@ -4,8 +4,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef __NETWORK_HPP__ -#define __NETWORK_HPP__ +#ifndef BOOST_NETWORK_HPP__ +#define BOOST_NETWORK_HPP__ // Include all headers in network/ // Author: Dean Michael Berris @@ -14,4 +14,4 @@ #include // message type implementation #include // protocols implementation -#endif // __NETWORK_HPP__ +#endif // BOOST_NETWORK_HPP__ diff --git a/boost/network/constants.hpp b/boost/network/constants.hpp index 6aa7e45d8..a9ebfe657 100644 --- a/boost/network/constants.hpp +++ b/boost/network/constants.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 namespace boost { namespace network { @@ -124,7 +124,7 @@ struct constants_wide { return https_; } }; -} +} // namespace impl template struct constants diff --git a/boost/network/detail/directive_base.hpp b/boost/network/detail/directive_base.hpp index e405642e3..84472f775 100644 --- a/boost/network/detail/directive_base.hpp +++ b/boost/network/detail/directive_base.hpp @@ -7,6 +7,8 @@ #ifndef __NETWORK_DETAIL_DIRECTIVE_BASE_HPP__ #define __NETWORK_DETAIL_DIRECTIVE_BASE_HPP__ +#include + /** Defines the base type from which all directives inherit * to allow friend access to message and other types' internals. */ @@ -17,12 +19,13 @@ namespace detail { template struct directive_base { typedef Tag tag; - // explicit directive_base(basic_message & message_) - // : _message(message_) + explicit directive_base(basic_message & message) + : message_(message) {} + protected: - ~directive_base() {}; // can only be extended + ~directive_base() = default; // can only be extended - // mutable basic_message & _message; + basic_message & message_; }; } // namespace detail diff --git a/boost/network/detail/wrapper_base.hpp b/boost/network/detail/wrapper_base.hpp index 12793dfee..bbd2e9589 100644 --- a/boost/network/detail/wrapper_base.hpp +++ b/boost/network/detail/wrapper_base.hpp @@ -17,8 +17,7 @@ struct wrapper_base { explicit wrapper_base(Message& message_) : _message(message_) {}; protected: - ~wrapper_base() {}; // for extending only - + ~wrapper_base() = default; // for extending only Message& _message; }; @@ -27,8 +26,7 @@ struct wrapper_base_const { explicit wrapper_base_const(Message const& message_) : _message(message_) {} protected: - ~wrapper_base_const() {}; // for extending only - + ~wrapper_base_const() = default; // for extending only Message const& _message; }; diff --git a/boost/network/message.hpp b/boost/network/message.hpp index f0519d879..9b4f08bf8 100644 --- a/boost/network/message.hpp +++ b/boost/network/message.hpp @@ -3,27 +3,24 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef __NETWORK_MESSAGE_HPP__ -#define __NETWORK_MESSAGE_HPP__ +#ifndef BOOST_NETWORK_MESSAGE_HPP__ +#define BOOST_NETWORK_MESSAGE_HPP__ -#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 /** message.hpp * @@ -47,72 +44,67 @@ struct basic_message { typedef typename headers_container_type::value_type header_type; typedef typename string::type string_type; - basic_message() : _headers(), _body(), _source(), _destination() {} - - basic_message(const basic_message& other) - : _headers(other._headers), - _body(other._body), - _source(other._source), - _destination(other._destination) {} - - basic_message& operator=(basic_message rhs) { - rhs.swap(*this); - return *this; - } + basic_message() = default; + basic_message(const basic_message&) = default; + basic_message(basic_message&&) = default; + basic_message& operator=(basic_message const&) = default; + basic_message& operator=(basic_message&&) = default; + ~basic_message() = default; 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); + using std::swap; + swap(other.headers_, headers_); + swap(other.body_, body_); + swap(other.source_, source_); + swap(other.destination_, destination_); } - headers_container_type& headers() { return _headers; } + headers_container_type& headers() { return headers_; } - void headers(headers_container_type const& headers_) const { - _headers = headers_; + void headers(headers_container_type headers) const { + headers_ = std::move(headers); } - void add_header(typename headers_container_type::value_type const& pair_) - const { - _headers.insert(pair_); + void add_header( + typename headers_container_type::value_type const& pair_) const { + headers_.insert(pair_); } - void remove_header(typename headers_container_type::key_type const& key) - const { - _headers.erase(key); + void remove_header( + typename headers_container_type::key_type const& key) const { + headers_.erase(key); } - headers_container_type const& headers() const { return _headers; } + headers_container_type const& headers() const { return headers_; } - string_type& body() { return _body; } + string_type& body() { return body_; } - void body(string_type const& body_) const { _body = body_; } + void body(string_type body) const { body_ = std::move(body); } - string_type const& body() const { return _body; } + string_type const& body() const { return body_; } - string_type& source() { return _source; } + string_type& source() { return source_; } - void source(string_type const& source_) const { _source = source_; } + void source(string_type source) const { source_ = std::move(source); } - string_type const& source() const { return _source; } + string_type const& source() const { return source_; } - string_type& destination() { return _destination; } + string_type& destination() { return destination_; } - void destination(string_type const& destination_) const { - _destination = destination_; + void destination(string_type destination) const { + destination_ = std::move(destination); } - string_type const& destination() const { return _destination; } + string_type const& destination() const { return 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; + mutable headers_container_type headers_; + mutable string_type body_; + mutable string_type source_; + mutable string_type destination_; }; template @@ -132,4 +124,4 @@ typedef basic_message wmessage; } // namespace network } // namespace boost -#endif // __NETWORK_MESSAGE_HPP__ +#endif // BOOST_NETWORK_MESSAGE_HPP__ diff --git a/boost/network/message/directives/detail/string_directive.hpp b/boost/network/message/directives/detail/string_directive.hpp index 33d288a72..db07eceb4 100644 --- a/boost/network/message/directives/detail/string_directive.hpp +++ b/boost/network/message/directives/detail/string_directive.hpp @@ -6,14 +6,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 /** * @@ -34,7 +34,7 @@ #define BOOST_NETWORK_STRING_DIRECTIVE(name, value, body, pod_body) \ template \ struct name##_directive { \ - ValueType const& value; \ + ValueType const&((value)); \ explicit name##_directive(ValueType const& value_) : value(value_) {} \ name##_directive(name##_directive const& other) : value(other.value) {} \ template class Message> \ @@ -53,7 +53,5 @@ inline name##_directive name(T const& input) { \ return name##_directive(input); \ } -#endif /* BOOST_NETWORK_STRING_DIRECTIVE */ - -#endif /* BOOST_NETWORK_MESSAGE_DIRECTIVES_DETAIL_STRING_DIRECTIVE_HPP_20100915 \ - */ +#endif // BOOST_NETWORK_STRING_DIRECTIVE +#endif // BOOST_NETWORK_MESSAGE_DIRECTIVES_DETAIL_STRING_DIRECTIVE_HPP_20100915 diff --git a/boost/network/message/directives/header.hpp b/boost/network/message/directives/header.hpp index da1f8e2a0..9619b05f1 100644 --- a/boost/network/message/directives/header.hpp +++ b/boost/network/message/directives/header.hpp @@ -4,18 +4,18 @@ // (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__ +#ifndef BOOST_NETWORK_MESSAGE_DIRECTIVES_HEADER_HPP__ +#define BOOST_NETWORK_MESSAGE_DIRECTIVES_HEADER_HPP__ -#include #include -#include +#include +#include #include #include #include -#include #include #include +#include namespace boost { namespace network { @@ -73,4 +73,4 @@ inline impl::header_directive header(T1 const& header_name, } // namespace network } // namespace boost -#endif // __NETWORK_MESSAGE_DIRECTIVES_HEADER_HPP__ +#endif // BOOST_NETWORK_MESSAGE_DIRECTIVES_HEADER_HPP__ diff --git a/boost/network/message/directives/remove_header.hpp b/boost/network/message/directives/remove_header.hpp index 0961436ad..52eb1be81 100644 --- a/boost/network/message/directives/remove_header.hpp +++ b/boost/network/message/directives/remove_header.hpp @@ -8,6 +8,7 @@ #define NETWORK_MESSAGE_DIRECTIVES_REMOVE_HEADER_HPP #include +#include namespace boost { namespace network { @@ -20,7 +21,7 @@ template struct remove_header_directive { explicit remove_header_directive(T header_name) - : header_name_(header_name) {}; + : header_name_(std::move(header_name)) {}; template void operator()(basic_message& msg) const { @@ -34,14 +35,15 @@ struct remove_header_directive { } // namespace impl inline impl::remove_header_directive remove_header( - std::string header_name) { + const std::string& header_name) { return impl::remove_header_directive(header_name); } inline impl::remove_header_directive remove_header( - std::wstring header_name) { + const std::wstring& header_name) { return impl::remove_header_directive(header_name); } + } // namespace network } // namespace boost diff --git a/boost/network/message/message_concept.hpp b/boost/network/message/message_concept.hpp index 6abac8615..e2a1a1275 100644 --- a/boost/network/message/message_concept.hpp +++ b/boost/network/message/message_concept.hpp @@ -14,9 +14,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include namespace boost { namespace network { diff --git a/boost/network/message/modifiers/add_header.hpp b/boost/network/message/modifiers/add_header.hpp index 51889a681..1280004ad 100644 --- a/boost/network/message/modifiers/add_header.hpp +++ b/boost/network/message/modifiers/add_header.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 namespace boost { namespace network { @@ -38,7 +38,7 @@ inline typename enable_if, void>::type add_header( typename Message::header_type header = {key, value}; message.headers.insert(message.headers.end(), header); } -} +} // namespace impl template class Message, class KeyType, class ValueType> diff --git a/boost/network/message/modifiers/body.hpp b/boost/network/message/modifiers/body.hpp index 1fc1d3471..f294edcf8 100644 --- a/boost/network/message/modifiers/body.hpp +++ b/boost/network/message/modifiers/body.hpp @@ -13,13 +13,13 @@ namespace boost { namespace network { template class Message, class ValueType> -inline void body_impl(Message& message, ValueType const& body, tags::pod) { +inline void body_impl(Message& message, ValueType const& body, tags::pod /*unused*/ /*unused*/) { message.body = body; } template class Message, class ValueType> inline void body_impl(Message& message, ValueType const& body, - tags::normal) { + tags::normal /*unused*/ /*unused*/) { message.body(body); } diff --git a/boost/network/message/modifiers/clear_headers.hpp b/boost/network/message/modifiers/clear_headers.hpp index 74991dc61..ef758073f 100644 --- a/boost/network/message/modifiers/clear_headers.hpp +++ b/boost/network/message/modifiers/clear_headers.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 namespace boost { namespace network { diff --git a/boost/network/message/modifiers/destination.hpp b/boost/network/message/modifiers/destination.hpp index 2d461ee6f..111f05cbc 100644 --- a/boost/network/message/modifiers/destination.hpp +++ b/boost/network/message/modifiers/destination.hpp @@ -17,16 +17,16 @@ namespace impl { template inline void destination(Message const &message, ValueType const &destination_, - Tag const &, mpl::false_ const &) { + Tag const & /*unused*/ /*unused*/, mpl::false_ const & /*unused*/ /*unused*/) { message.destination(destination_); } template inline void destination(Message const &message, ValueType const &destination_, - Tag const &, mpl::true_ const &) { + Tag const & /*unused*/ /*unused*/, mpl::true_ const & /*unused*/ /*unused*/) { message.destination(destination_); } -} +} // namespace impl // namespace impl template class Message, class ValueType> inline void destination(Message const &message, diff --git a/boost/network/message/modifiers/remove_header.hpp b/boost/network/message/modifiers/remove_header.hpp index 57a94fef9..efd793194 100644 --- a/boost/network/message/modifiers/remove_header.hpp +++ b/boost/network/message/modifiers/remove_header.hpp @@ -7,12 +7,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 namespace boost { namespace network { @@ -39,7 +39,7 @@ struct iequals_pred { iequals_pred(KeyType const& key) : key(key) {} template bool operator()(Header& other) const { - return boost::iequals(key, name(other)); + return boost::algorithm::iequals(key, name(other)); } }; diff --git a/boost/network/message/modifiers/source.hpp b/boost/network/message/modifiers/source.hpp index dfaca0512..6e4e39402 100644 --- a/boost/network/message/modifiers/source.hpp +++ b/boost/network/message/modifiers/source.hpp @@ -16,13 +16,13 @@ namespace impl { template inline void source(Message const &message, ValueType const &source_, - Tag const &, mpl::false_ const &) { + Tag const & /*unused*/ /*unused*/, mpl::false_ const & /*unused*/ /*unused*/) { message.source(source_); } template inline void source(Message const &message, ValueType const &source_, - Tag const &, mpl::true_ const &) { + Tag const & /*unused*/ /*unused*/, mpl::true_ const & /*unused*/ /*unused*/) { message.source(source_); } diff --git a/boost/network/message/traits/body.hpp b/boost/network/message/traits/body.hpp index 17f682dbf..8f37bf6f1 100644 --- a/boost/network/message/traits/body.hpp +++ b/boost/network/message/traits/body.hpp @@ -7,12 +7,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 namespace boost { namespace network { @@ -35,9 +35,7 @@ struct body unsupported_tag >::type> {}; } // namespace traits - -} /* network */ - -} /* boost */ +} // namespace network +} // namespace 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 index 1016cdfb8..9baf36ddd 100644 --- a/boost/network/message/traits/destination.hpp +++ b/boost/network/message/traits/destination.hpp @@ -7,11 +7,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 namespace boost { namespace network { @@ -34,9 +35,7 @@ struct destination unsupported_tag >::type> {}; } // namespace traits - -} /* network */ - -} /* boost */ +} // namespace network +} // namespace 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 index 8f6f5549d..0140aa782 100644 --- a/boost/network/message/traits/headers.hpp +++ b/boost/network/message/traits/headers.hpp @@ -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 +#include +#include namespace boost { namespace network { @@ -48,9 +48,7 @@ struct header_value unsupported_tag >::type> {}; } // namespace traits - -} /* network */ - -} /* boost */ +} // namespace network +} // namespace 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 index f1b8c2fbe..1400a1e18 100644 --- a/boost/network/message/traits/source.hpp +++ b/boost/network/message/traits/source.hpp @@ -6,15 +6,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 -#include +#include namespace boost { namespace network { - namespace traits { template @@ -33,9 +33,7 @@ struct source unsupported_tag >::type> {}; } // namespace traits - -} /* network */ - -} /* boost */ +} // namespace network +} // namespace boost #endif // BOOST_NETWORK_MESSAGE_TRAITS_SOURCE_HPP_20100903 diff --git a/boost/network/message/transformers.hpp b/boost/network/message/transformers.hpp index 0b990dfae..0fc23e179 100644 --- a/boost/network/message/transformers.hpp +++ b/boost/network/message/transformers.hpp @@ -30,11 +30,11 @@ struct get_real_algorithm { template struct transform_impl : public get_real_algorithm::type {}; -} // namspace impl +} // namespace impl template -inline impl::transform_impl transform(Algorithm, - Selector) { +inline impl::transform_impl transform(Algorithm /*unused*/ /*unused*/, + Selector /*unused*/ /*unused*/) { return impl::transform_impl(); } diff --git a/boost/network/message/transformers/selectors.hpp b/boost/network/message/transformers/selectors.hpp index 4b7a39632..d04acbd25 100644 --- a/boost/network/message/transformers/selectors.hpp +++ b/boost/network/message/transformers/selectors.hpp @@ -4,8 +4,8 @@ // (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__ +#ifndef BOOST_NETWORK_MESSAGE_TRANSFORMERS_SELECTORS_HPP__ +#define BOOST_NETWORK_MESSAGE_TRANSFORMERS_SELECTORS_HPP__ namespace boost { namespace network { @@ -14,23 +14,24 @@ struct source_selector; struct destination_selector; } // namespace selectors -selectors::source_selector source_(selectors::source_selector); -selectors::destination_selector destination_(selectors::destination_selector); +selectors::source_selector source_(selectors::source_selector /*unused*/); +selectors::destination_selector destination_( + selectors::destination_selector /*unused*/); namespace selectors { struct source_selector { private: - source_selector() {}; - source_selector(source_selector const &) {}; - friend source_selector boost::network::source_(source_selector); + source_selector() = default; + source_selector(source_selector const& /*unused*/) {}; + friend source_selector boost::network::source_(source_selector /*unused*/); }; struct destination_selector { private: - destination_selector() {}; - destination_selector(destination_selector const &) {}; + destination_selector() = default; + destination_selector(destination_selector const& /*unused*/) {}; friend destination_selector boost::network::destination_( - destination_selector); + destination_selector /*unused*/); }; } // namespace selectors @@ -39,12 +40,13 @@ typedef selectors::source_selector (*source_selector_t)( typedef selectors::destination_selector (*destination_selector_t)( selectors::destination_selector); -inline selectors::source_selector source_(selectors::source_selector) { +inline selectors::source_selector source_( + selectors::source_selector /*unused*/) { return selectors::source_selector(); } inline selectors::destination_selector destination_( - selectors::destination_selector) { + selectors::destination_selector /*unused*/) { return selectors::destination_selector(); } @@ -52,4 +54,4 @@ inline selectors::destination_selector destination_( } // namespace boost -#endif // __NETWORK_MESSAGE_TRANSFORMERS_SELECTORS_HPP__ +#endif // BOOST_NETWORK_MESSAGE_TRANSFORMERS_SELECTORS_HPP__ diff --git a/boost/network/message/transformers/to_lower.hpp b/boost/network/message/transformers/to_lower.hpp index 4979f1b15..a5f9abdda 100644 --- a/boost/network/message/transformers/to_lower.hpp +++ b/boost/network/message/transformers/to_lower.hpp @@ -4,10 +4,12 @@ // (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 BOOST_NETWORK_MESSAGE_TRANSFORMERS_TO_LOWER_HPP__ +#define BOOST_NETWORK_MESSAGE_TRANSFORMERS_TO_LOWER_HPP__ #include +#include +#include /** to_lower.hpp * @@ -34,7 +36,7 @@ struct to_lower_transformer { } protected: - ~to_lower_transformer() {} + ~to_lower_transformer() = default; }; template <> @@ -45,17 +47,17 @@ struct to_lower_transformer { } protected: - ~to_lower_transformer() {}; + ~to_lower_transformer() = default; }; } // namespace impl namespace detail { struct to_lower_placeholder_helper; -} +} // namespace detail detail::to_lower_placeholder_helper to_lower_( - detail::to_lower_placeholder_helper); + detail::to_lower_placeholder_helper /*unused*/); namespace detail { @@ -64,23 +66,22 @@ struct to_lower_placeholder_helper { struct type : public impl::to_lower_transformer {}; private: - to_lower_placeholder_helper() {} - to_lower_placeholder_helper(to_lower_placeholder_helper const &) {} + to_lower_placeholder_helper() = default; + to_lower_placeholder_helper(to_lower_placeholder_helper const & /*unused*/) {} friend to_lower_placeholder_helper boost::network::to_lower_( - to_lower_placeholder_helper); + to_lower_placeholder_helper /*unused*/); }; -} +} // namespace detail 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) { + detail::to_lower_placeholder_helper /*unused*/) { return detail::to_lower_placeholder_helper(); } } // namespace network - } // namespace boost -#endif // __NETWORK_MESSAGE_TRANSFORMERS_TO_LOWER_HPP__ +#endif // BOOST_NETWORK_MESSAGE_TRANSFORMERS_TO_LOWER_HPP__ diff --git a/boost/network/message/transformers/to_upper.hpp b/boost/network/message/transformers/to_upper.hpp index 6e41ef7ff..21850caa9 100644 --- a/boost/network/message/transformers/to_upper.hpp +++ b/boost/network/message/transformers/to_upper.hpp @@ -4,10 +4,12 @@ // (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 BOOST_NETWORK_MESSAGE_TRANSFORMERS_TO_UPPER_HPP__ +#define BOOST_NETWORK_MESSAGE_TRANSFORMERS_TO_UPPER_HPP__ #include +#include +#include /** to_upper.hpp * @@ -34,7 +36,7 @@ struct to_upper_transformer { } protected: - ~to_upper_transformer() {}; + ~to_upper_transformer() = default; }; template <> @@ -45,17 +47,17 @@ struct to_upper_transformer { } protected: - ~to_upper_transformer() {}; + ~to_upper_transformer() = default; }; } // namespace impl namespace detail { struct to_upper_placeholder_helper; -} +} // namespace detail detail::to_upper_placeholder_helper to_upper_( - detail::to_upper_placeholder_helper); + detail::to_upper_placeholder_helper /*unused*/); namespace detail { @@ -64,18 +66,18 @@ struct to_upper_placeholder_helper { struct type : public impl::to_upper_transformer {}; private: - to_upper_placeholder_helper() {} - to_upper_placeholder_helper(to_upper_placeholder_helper const &) {} + to_upper_placeholder_helper() = default; + to_upper_placeholder_helper(to_upper_placeholder_helper const & /*unused*/) {} friend to_upper_placeholder_helper boost::network::to_upper_( - to_upper_placeholder_helper); + to_upper_placeholder_helper /*unused*/); }; -} +} // namespace detail 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) { + detail::to_upper_placeholder_helper /*unused*/) { return detail::to_upper_placeholder_helper(); } @@ -83,4 +85,4 @@ inline detail::to_upper_placeholder_helper to_upper_( } // namespace boost -#endif // __NETWORK_MESSAGE_TRANSFORMERS_TO_UPPER_HPP__ +#endif // BOOST_NETWORK_MESSAGE_TRANSFORMERS_TO_UPPER_HPP__ diff --git a/boost/network/message/wrappers/body.hpp b/boost/network/message/wrappers/body.hpp index 4dd1d5eb0..71c706b31 100644 --- a/boost/network/message/wrappers/body.hpp +++ b/boost/network/message/wrappers/body.hpp @@ -4,12 +4,13 @@ // (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__ +#define BOOST_NETWORK_MESSAGE_WRAPPERS_BODY_HPP__ -#include #include -#include +#include +#include +#include namespace boost { namespace network { @@ -102,4 +103,4 @@ inline impl::body_wrapper_const const body( } // namespace boost -#endif // __NETWORK_MESSAGE_WRAPPERS_BODY_HPP__ +#endif // BOOST_NETWORK_MESSAGE_WRAPPERS_BODY_HPP__ diff --git a/boost/network/message/wrappers/headers.hpp b/boost/network/message/wrappers/headers.hpp index 5efeb94e0..a8ae77bfb 100644 --- a/boost/network/message/wrappers/headers.hpp +++ b/boost/network/message/wrappers/headers.hpp @@ -4,14 +4,14 @@ // (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 BOOST_NETWORK_MESSAGE_WRAPPERS_HEADERS_HPP__ +#define BOOST_NETWORK_MESSAGE_WRAPPERS_HEADERS_HPP__ -#include #include -#include +#include #include #include +#include namespace boost { namespace network { @@ -98,4 +98,4 @@ inline impl::headers_wrapper headers(basic_message const& message_) { } // namespace boost -#endif // __NETWORK_MESSAGE_WRAPPERS_HEADERS_HPP__ +#endif // BOOST_NETWORK_MESSAGE_WRAPPERS_HEADERS_HPP__ diff --git a/boost/network/message_fwd.hpp b/boost/network/message_fwd.hpp index 08eaf46cd..713d8f1fc 100644 --- a/boost/network/message_fwd.hpp +++ b/boost/network/message_fwd.hpp @@ -3,8 +3,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 BOST_NETWORK_MESSAGE_FWD_HPP +#define BOST_NETWORK_MESSAGE_FWD_HPP namespace boost { namespace network { @@ -12,7 +12,7 @@ namespace network { template struct basic_message; -} // namespace boost -} // namespace network +} // namespace networkk +} // namespace boost -#endif // __2008817MESSAGE_FWD_INC__ +#endif // BOST_NETWORK_MESSAGE_FWD_HPP diff --git a/boost/network/protocol/http/algorithms/linearize.hpp b/boost/network/protocol/http/algorithms/linearize.hpp index d0347fd04..aae25aa05 100644 --- a/boost/network/protocol/http/algorithms/linearize.hpp +++ b/boost/network/protocol/http/algorithms/linearize.hpp @@ -1,192 +1,193 @@ -#ifndef BOOST_NETWORK_PROTOCOL_HTTP_ALGORITHMS_LINEARIZE_HPP_20101028 -#define BOOST_NETWORK_PROTOCOL_HTTP_ALGORITHMS_LINEARIZE_HPP_20101028 - -// Copyright 2010 Dean Michael Berris. -// Copyright 2014 Jussi Lyytinen -// Distributed under the 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 - -namespace boost { -namespace network { -namespace http { - -template -struct linearize_header { - typedef typename string::type string_type; - - template - struct result; - - template - struct result { - typedef string_type type; - }; - - template - BOOST_CONCEPT_REQUIRES(((Header::type>)), - (string_type)) - operator()(ValueType& header) { - typedef typename ostringstream::type 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, - typename Request::string_type const& method, - unsigned version_major, unsigned version_minor, - OutputIterator oi) { - typedef typename Request::tag Tag; - typedef constants consts; - typedef typename string::type 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(), - crlf = consts::crlf(), host = 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); - } - if (!request.anchor().empty()) { - *oi = consts::hash_char(); - boost::copy(request.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); - - // We need to determine whether we've seen any of the following headers - // before setting the defaults. We use a bitset to keep track of the - // defaulted headers. - enum { - ACCEPT, - ACCEPT_ENCODING, - HOST, - CONNECTION, - MAX - }; - std::bitset found_headers; - static char const* defaulted_headers[][2] = { - {consts::accept(), consts::accept() + std::strlen(consts::accept())}, - {consts::accept_encoding(), - consts::accept_encoding() + std::strlen(consts::accept_encoding())}, - {consts::host(), consts::host() + std::strlen(consts::host())}, - {consts::connection(), - consts::connection() + std::strlen(consts::connection())}}; - - typedef typename headers_range::type headers_range; - typedef typename range_value::type headers_value; - BOOST_FOREACH(const headers_value & header, headers(request)) { - string_type header_name = name(header), header_value = value(header); - // Here we check that we have not seen an override to the defaulted - // headers. - for (int header_index = 0; header_index < MAX; ++header_index) - if (std::distance(header_name.begin(), header_name.end()) == - std::distance(defaulted_headers[header_index][0], - defaulted_headers[header_index][1]) && - std::equal(header_name.begin(), header_name.end(), - defaulted_headers[header_index][0], - algorithm::is_iequal())) - found_headers.set(header_index, true); - - // We ignore empty headers. - if (header_value.empty()) continue; - boost::copy(header_name, oi); - *oi = consts::colon_char(); - *oi = consts::space_char(); - boost::copy(header_value, oi); - boost::copy(crlf, oi); - } - - if (!found_headers[HOST]) { - boost::copy(host, oi); - *oi = consts::colon_char(); - *oi = consts::space_char(); - boost::copy(request.host(), oi); - boost::optional port_ = -#if (_MSC_VER >= 1600 && BOOST_VERSION > 105500) - port(request).as_optional(); -#else - port(request); -#endif - if (port_) { - string_type port_str = boost::lexical_cast(*port_); - *oi = consts::colon_char(); - boost::copy(port_str, oi); - } - boost::copy(crlf, oi); - } - - if (!found_headers[ACCEPT]) { - 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 && - !found_headers[ACCEPT_ENCODING]) { - boost::copy(accept_encoding, oi); - *oi = consts::colon_char(); - *oi = consts::space_char(); - boost::copy(default_accept_encoding, oi); - boost::copy(crlf, oi); - } - - if (!connection_keepalive::value && !found_headers[CONNECTION]) { - 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(); - return boost::copy(body_data, oi); -} - -} /* http */ - -} /* net */ - -} /* boost */ - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_ALGORITHMS_LINEARIZE_HPP_20101028 */ +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_ALGORITHMS_LINEARIZE_HPP_20101028 +#define BOOST_NETWORK_PROTOCOL_HTTP_ALGORITHMS_LINEARIZE_HPP_20101028 + +// Copyright 2010 Dean Michael Berris. +// Copyright 2014 Jussi Lyytinen +// Distributed under the 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 + +namespace boost { +namespace network { +namespace http { + +template +struct linearize_header { + typedef typename string::type string_type; + + template + struct result; + + template + struct result { + typedef string_type type; + }; + + template + BOOST_CONCEPT_REQUIRES(((Header::type>)), + (string_type)) + operator()(ValueType& header) { + typedef typename ostringstream::type 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, + typename Request::string_type const& method, + unsigned version_major, unsigned version_minor, + OutputIterator oi) { + typedef typename Request::tag Tag; + typedef constants consts; + typedef typename string::type 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(), + crlf = consts::crlf(), host = 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); + } + if (!request.anchor().empty()) { + *oi = consts::hash_char(); + boost::copy(request.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); + + // We need to determine whether we've seen any of the following headers + // before setting the defaults. We use a bitset to keep track of the + // defaulted headers. + enum { + ACCEPT, + ACCEPT_ENCODING, + HOST, + CONNECTION, + MAX + }; + std::bitset found_headers; + static char const* defaulted_headers[][2] = { + {consts::accept(), consts::accept() + std::strlen(consts::accept())}, + {consts::accept_encoding(), + consts::accept_encoding() + std::strlen(consts::accept_encoding())}, + {consts::host(), consts::host() + std::strlen(consts::host())}, + {consts::connection(), + consts::connection() + std::strlen(consts::connection())}}; + + typedef typename headers_range::type headers_range; + typedef typename range_value::type headers_value; + for (const headers_value& header : headers(request)) { + string_type header_name = name(header), header_value = value(header); + // Here we check that we have not seen an override to the defaulted + // headers. + for (int header_index = 0; header_index < MAX; ++header_index) + if (std::distance(header_name.begin(), header_name.end()) == + std::distance(defaulted_headers[header_index][0], + defaulted_headers[header_index][1]) && + std::equal(header_name.begin(), header_name.end(), + defaulted_headers[header_index][0], + algorithm::is_iequal())) + found_headers.set(header_index, true); + + // We ignore empty headers. + if (header_value.empty()) continue; + boost::copy(header_name, oi); + *oi = consts::colon_char(); + *oi = consts::space_char(); + boost::copy(header_value, oi); + boost::copy(crlf, oi); + } + + if (!found_headers[HOST]) { + boost::copy(host, oi); + *oi = consts::colon_char(); + *oi = consts::space_char(); + boost::copy(request.host(), oi); + boost::optional port_ = +#if (_MSC_VER >= 1600 && BOOST_VERSION > 105500) + port(request).as_optional(); +#else + port(request); +#endif + if (port_) { + string_type port_str = boost::lexical_cast(*port_); + *oi = consts::colon_char(); + boost::copy(port_str, oi); + } + boost::copy(crlf, oi); + } + + if (!found_headers[ACCEPT]) { + 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 && + !found_headers[ACCEPT_ENCODING]) { + boost::copy(accept_encoding, oi); + *oi = consts::colon_char(); + *oi = consts::space_char(); + boost::copy(default_accept_encoding, oi); + boost::copy(crlf, oi); + } + + if (!connection_keepalive::value && !found_headers[CONNECTION]) { + 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(); + return boost::copy(body_data, oi); +} + +} // namespace http +} // namespace network +} // namespace boost + +#endif /* BOOST_NETWORK_PROTOCOL_HTTP_ALGORITHMS_LINEARIZE_HPP_20101028 */ diff --git a/boost/network/protocol/http/client.hpp b/boost/network/protocol/http/client.hpp index 1e315a8fb..941584ebc 100644 --- a/boost/network/protocol/http/client.hpp +++ b/boost/network/protocol/http/client.hpp @@ -6,22 +6,22 @@ // (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 diff --git a/boost/network/protocol/http/client/async_impl.hpp b/boost/network/protocol/http/client/async_impl.hpp index 1c0eb1fe7..a70a90b36 100644 --- a/boost/network/protocol/http/client/async_impl.hpp +++ b/boost/network/protocol/http/client/async_impl.hpp @@ -10,10 +10,11 @@ #include #include -#include -#include -#include #include +#include +#include +#include +#include namespace boost { namespace network { @@ -39,11 +40,11 @@ struct async_client async_client(bool cache_resolved, bool follow_redirect, bool always_verify_peer, int timeout, boost::shared_ptr service, - optional const& certificate_filename, - optional const& verify_path, - optional const& certificate_file, - optional const& private_key_file, - optional const& ciphers, long ssl_options) + optional certificate_filename, + optional verify_path, + optional certificate_file, + optional private_key_file, + optional ciphers, long ssl_options) : connection_base(cache_resolved, follow_redirect, timeout), service_ptr(service.get() ? service @@ -51,11 +52,11 @@ struct async_client service_(*service_ptr), resolver_(service_), sentinel_(new boost::asio::io_service::work(service_)), - certificate_filename_(certificate_filename), - verify_path_(verify_path), - certificate_file_(certificate_file), - private_key_file_(private_key_file), - ciphers_(ciphers), + certificate_filename_(std::move(certificate_filename)), + verify_path_(std::move(verify_path)), + certificate_file_(std::move(certificate_file)), + private_key_file_(std::move(private_key_file)), + ciphers_(std::move(ciphers)), ssl_options_(ssl_options), always_verify_peer_(always_verify_peer) { connection_base::resolver_strand_.reset( @@ -65,7 +66,7 @@ struct async_client boost::bind(&boost::asio::io_service::run, &service_))); } - ~async_client() throw() { sentinel_.reset(); } + ~async_client() throw() = default; void wait_complete() { sentinel_.reset(); @@ -101,6 +102,7 @@ struct async_client long ssl_options_; bool always_verify_peer_; }; + } // namespace impl } // namespace http } // namespace network diff --git a/boost/network/protocol/http/client/connection/async_base.hpp b/boost/network/protocol/http/client/connection/async_base.hpp index ada856a22..a3fe481d1 100644 --- a/boost/network/protocol/http/client/connection/async_base.hpp +++ b/boost/network/protocol/http/client/connection/async_base.hpp @@ -8,10 +8,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 namespace boost { namespace network { @@ -34,8 +35,7 @@ struct async_connection_base { 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 + // 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, @@ -66,15 +66,12 @@ struct async_connection_base { bool get_body, body_callback_function_type callback, body_generator_function_type generator) = 0; - virtual ~async_connection_base() {} + virtual ~async_connection_base() = default; }; } // namespace impl - } // namespace http - } // namespace network - } // namespace boost #endif // BOOST_NETWORK_PROTOCOL_HTTP_IMPL_ASYNC_CONNECTION_BASE_20100529 diff --git a/boost/network/protocol/http/client/connection/async_normal.hpp b/boost/network/protocol/http/client/connection/async_normal.hpp index f5590d7fc..443d514c2 100644 --- a/boost/network/protocol/http/client/connection/async_normal.hpp +++ b/boost/network/protocol/http/client/connection/async_normal.hpp @@ -9,27 +9,30 @@ // (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 +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include namespace boost { namespace network { @@ -47,6 +50,9 @@ struct http_async_connection protected http_async_protocol_handler, boost::enable_shared_from_this< http_async_connection > { + + http_async_connection(http_async_connection const&) = delete; + typedef async_connection_base base; typedef http_async_protocol_handler protocol_base; @@ -75,9 +81,9 @@ struct http_async_connection is_timedout_(false), follow_redirect_(follow_redirect), resolver_(resolver), - resolve_(resolve), + resolve_(std::move(resolve)), request_strand_(resolver.get_io_service()), - delegate_(delegate) {} + delegate_(std::move(delegate)) {} // This is the main entry point for the connection/request pipeline. // We're @@ -94,14 +100,14 @@ struct http_async_connection &command_streambuf)); this->method = method; boost::uint16_t port_ = port(request); - string_type host_ = host(request); - boost::uint16_t source_port = request.source_port(); + string_type host_ = host(request); + boost::uint16_t source_port = request.source_port(); resolve_(resolver_, host_, port_, request_strand_.wrap(boost::bind( &this_type::handle_resolved, this_type::shared_from_this(), - host_, port_, source_port, get_body, callback, - generator, boost::arg<1>(), boost::arg<2>()))); + host_, port_, source_port, get_body, callback, generator, + boost::arg<1>(), boost::arg<2>()))); if (timeout_ > 0) { timer_.expires_from_now(boost::posix_time::seconds(timeout_)); timer_.async_wait(request_strand_.wrap( @@ -112,7 +118,6 @@ struct http_async_connection } private: - http_async_connection(http_async_connection const&); // = delete void set_errors(boost::system::error_code const& ec) { boost::system::system_error error(ec); @@ -131,14 +136,14 @@ struct http_async_connection is_timedout_ = true; } - void handle_resolved(string_type host, boost::uint16_t port, boost::uint16_t source_port, bool get_body, + void handle_resolved(string_type host, boost::uint16_t port, + boost::uint16_t source_port, bool get_body, body_callback_function_type callback, body_generator_function_type generator, 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 + // 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); @@ -156,7 +161,8 @@ struct http_async_connection } } - void handle_connected(string_type host, boost::uint16_t port, boost::uint16_t source_port, bool get_body, + void handle_connected(string_type host, boost::uint16_t port, + boost::uint16_t source_port, bool get_body, body_callback_function_type callback, body_generator_function_type generator, resolver_iterator_pair endpoint_range, @@ -202,18 +208,13 @@ struct http_async_connection body_generator_function_type generator, boost::system::error_code const& ec, std::size_t bytes_transferred) { - // TODO(dberris): review parameter necessity. - (void)bytes_transferred; - if (!is_timedout_ && !ec) { if (generator) { - // Here we write some more data that the generator provides, - // before - // we wait for data from the server. + // Here we write some more data that the generator provides, before we + // wait for data from the server. string_type chunk; if (generator(chunk)) { - // At this point this means we have more data to write, so we - // write + // At this point this means we have more data to write, so we write // it out. std::copy(chunk.begin(), chunk.end(), std::ostreambuf_iterator::type>( @@ -265,7 +266,9 @@ struct http_async_connection this_type::shared_from_this(), version, get_body, callback, placeholders::error, placeholders::bytes_transferred)), bytes_transferred); - if (!parsed_ok || indeterminate(parsed_ok)) return; + if (!parsed_ok || indeterminate(parsed_ok)) { + return; + } case status: if (ec == boost::asio::error::eof) return; parsed_ok = this->parse_status( @@ -275,7 +278,9 @@ struct http_async_connection this_type::shared_from_this(), status, get_body, callback, placeholders::error, placeholders::bytes_transferred)), bytes_transferred); - if (!parsed_ok || indeterminate(parsed_ok)) return; + if (!parsed_ok || indeterminate(parsed_ok)) { + return; + } case status_message: if (ec == boost::asio::error::eof) return; parsed_ok = this->parse_status_message( @@ -285,15 +290,15 @@ struct http_async_connection get_body, callback, placeholders::error, placeholders::bytes_transferred)), bytes_transferred); - if (!parsed_ok || indeterminate(parsed_ok)) return; + if (!parsed_ok || indeterminate(parsed_ok)) { + return; + } case headers: if (ec == boost::asio::error::eof) return; - // 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. + // 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( @@ -302,12 +307,13 @@ struct http_async_connection placeholders::error, placeholders::bytes_transferred)), bytes_transferred); - if (!parsed_ok || indeterminate(parsed_ok)) return; + 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). + // 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(""); @@ -317,26 +323,23 @@ struct http_async_connection } 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. + // 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. + // 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. + // 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( @@ -347,8 +350,8 @@ struct http_async_connection 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. + // Here we handle the body data ourself and append to an + // ever-growing string buffer. this->parse_body( delegate_, request_strand_.wrap(boost::bind( @@ -360,49 +363,43 @@ struct http_async_connection return; case body: if (ec == boost::asio::error::eof || is_ssl_short_read_error) { - // 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. + // 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. + // 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); - if (this->is_chunk_encoding) + if (this->is_chunk_encoding) { this->body_promise.set_value(parse_chunk_encoding(body_string)); - else + } else { this->body_promise.set_value(body_string); + } } - // TODO set the destination value somewhere! + // TODO(dberris): set the destination value somewhere! this->destination_promise.set_value(""); this->source_promise.set_value(""); this->part.assign('\0'); this->response_parser_.reset(); this->timer_.cancel(); } else { - // This means the connection has not been closed yet and we - // want - // to get more - // data. + // 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. + // 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; @@ -416,10 +413,9 @@ struct http_async_connection 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. + // 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( @@ -450,9 +446,9 @@ struct http_async_connection this->headers_promise.set_exception(boost::copy_exception(error)); case body: if (!callback) { - // N.B. if callback is non-null, then body_promise has - // already been set to value "" to indicate body is - // handled by streaming handler so no exception should be set + // N.B. if callback is non-null, then body_promise has already been + // set to value "" to indicate body is handled by streaming handler + // so no exception should be set this->body_promise.set_exception(boost::copy_exception(error)); } break; @@ -473,12 +469,16 @@ struct http_async_connection iter = std::search(begin, body_string.end(), crlf.begin(), crlf.end())) { string_type line(begin, iter); - if (line.empty()) break; + if (line.empty()) { + break; + } std::stringstream stream(line); int len; stream >> std::hex >> len; std::advance(iter, 2); - if (!len) break; + if (len == 0) { + break; + } if (len <= body_string.end() - iter) { body.insert(body.end(), iter, iter + len); std::advance(iter, len + 2); 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 7c8792ae2..42b99eb4b 100644 --- a/boost/network/protocol/http/client/connection/async_protocol_handler.hpp +++ b/boost/network/protocol/http/client/connection/async_protocol_handler.hpp @@ -8,8 +8,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 namespace boost { namespace network { @@ -23,22 +29,23 @@ struct http_async_protocol_handler { #ifdef BOOST_NETWORK_DEBUG struct debug_escaper { - string_type& string; - explicit debug_escaper(string_type& string_) : string(string_) {} - debug_escaper(debug_escaper const& other) : string(other.string) {} + string_type& string_; + explicit debug_escaper(string_type& string) : string_(string) {} + debug_escaper(debug_escaper const&) = default; + debug_escaper(debug_escaper&&) noexcept = default; void operator()(typename string_type::value_type input) { if (!algorithm::is_print()(input)) { typename ostringstream::type escaped_stream; if (input == '\r') { - string.append("\\r"); + string_.append("\\r"); } else if (input == '\n') { - string.append("\\n"); + string_.append("\\n"); } else { escaped_stream << "\\x" << static_cast(input); - string.append(escaped_stream.str()); + string_.append(escaped_stream.str()); } } else { - string.push_back(input); + string_.push_back(input); } } }; @@ -318,7 +325,7 @@ struct http_async_protocol_handler { template void parse_body(Delegate& delegate_, Callback callback, size_t bytes) { - // TODO: we should really not use a string for the partial body + // TODO(dberris): we should really not use a string for the partial body // buffer. partial_parsed.append(part_begin, bytes); part_begin = part.begin(); @@ -327,7 +334,7 @@ struct http_async_protocol_handler { } typedef response_parser response_parser_type; - // TODO: make 1024 go away and become a configurable value. + // TODO(dberris): make 1024 go away and become a configurable value. typedef boost::array::type, 1024> buffer_type; response_parser_type response_parser_; @@ -344,13 +351,9 @@ struct http_async_protocol_handler { bool is_chunk_encoding; }; -} /* impl */ +} // namespace impl +} // namespace http +} // namespace network +} // namespace boost -} /* http */ - -} /* network */ - -} /* boost */ - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_IMPL_HTTP_ASYNC_PROTOCOL_HANDLER_HPP_20101015 \ - */ +#endif // BOOST_NETWORK_PROTOCOL_HTTP_IMPL_HTTP_ASYNC_PROTOCOL_HANDLER_HPP_20101015 diff --git a/boost/network/protocol/http/client/connection/connection_delegate.hpp b/boost/network/protocol/http/client/connection/connection_delegate.hpp index 79fa1ca4d..c03698867 100644 --- a/boost/network/protocol/http/client/connection/connection_delegate.hpp +++ b/boost/network/protocol/http/client/connection/connection_delegate.hpp @@ -7,13 +7,18 @@ // (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 { struct connection_delegate { - virtual void connect(asio::ip::tcp::endpoint &endpoint, std::string host, boost::uint16_t source_port, + virtual void connect(asio::ip::tcp::endpoint &endpoint, std::string host, + boost::uint16_t source_port, function handler) = 0; virtual void write( asio::streambuf &command_streambuf, @@ -22,16 +27,13 @@ struct connection_delegate { asio::mutable_buffers_1 const &read_buffer, function handler) = 0; virtual void disconnect() = 0; - virtual ~connection_delegate() {} + virtual ~connection_delegate() = default; }; -} /* impl */ - -} /* http */ - -} /* network */ - -} /* boost */ +} // namespace impl +} // namespace http +} // namespace network +} // namespace boost #endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_CONNECTION_DELEGATE_HPP_ \ */ 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 425cc27ef..35f05bcfe 100644 --- a/boost/network/protocol/http/client/connection/connection_delegate_factory.hpp +++ b/boost/network/protocol/http/client/connection/connection_delegate_factory.hpp @@ -7,9 +7,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 + #ifdef BOOST_NETWORK_ENABLE_HTTPS #include #endif /* BOOST_NETWORK_ENABLE_HTTPS */ @@ -30,7 +33,7 @@ struct connection_delegate_factory { // This is the factory method that actually returns the delegate // instance. - // TODO Support passing in proxy settings when crafting connections. + // TODO(dberris): Support passing in proxy settings when crafting connections. static connection_delegate_ptr new_connection_delegate( asio::io_service& service, bool https, bool always_verify_peer, optional certificate_filename, @@ -53,10 +56,14 @@ struct connection_delegate_factory { } }; -} /* impl */ -} /* http */ -} /* network */ -} /* boost */ +} // namespace impl + /* impl */ +} // namespace http + /* http */ +} // namespace network + /* network */ +} // namespace boost + /* boost */ #endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_DELEGATE_FACTORY_HPP_20110819 \ */ diff --git a/boost/network/protocol/http/client/connection/normal_delegate.hpp b/boost/network/protocol/http/client/connection/normal_delegate.hpp index ae6ace333..48c2cd9fd 100644 --- a/boost/network/protocol/http/client/connection/normal_delegate.hpp +++ b/boost/network/protocol/http/client/connection/normal_delegate.hpp @@ -7,9 +7,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 namespace boost { namespace network { @@ -17,38 +20,31 @@ namespace http { namespace impl { struct normal_delegate : connection_delegate { - normal_delegate(asio::io_service &service); - - virtual void connect(asio::ip::tcp::endpoint &endpoint, std::string host, boost::uint16_t source_port, - function handler); - virtual void write( - asio::streambuf &command_streambuf, - function handler); - virtual void read_some( - asio::mutable_buffers_1 const &read_buffer, - function handler); - virtual void disconnect(); - ~normal_delegate(); + explicit normal_delegate(asio::io_service &service); + + void connect(asio::ip::tcp::endpoint &endpoint, std::string host, + boost::uint16_t source_port, + function handler) override; + void write(asio::streambuf &command_streambuf, + function handler) + override; + void read_some(asio::mutable_buffers_1 const &read_buffer, + function handler) + override; + void disconnect() override; + ~normal_delegate() override = default; + + normal_delegate(normal_delegate const &) = delete; + normal_delegate &operator=(normal_delegate) = delete; private: asio::io_service &service_; - scoped_ptr socket_; - - normal_delegate(normal_delegate const &); // = delete - normal_delegate &operator=(normal_delegate); // = delete + std::unique_ptr socket_; }; -} /* impl */ - -} /* http */ - -} /* network */ - -} /* boost */ - -#ifdef BOOST_NETWORK_NO_LIB -#include -#endif /* BOOST_NETWORK_NO_LIB */ +} // namespace impl +} // namespace http +} // namespace network +} // namespace boost -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_NORMAL_DELEGATE_20110819 \ - */ +#endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_NORMAL_DELEGATE_20110819 diff --git a/boost/network/protocol/http/client/connection/normal_delegate.ipp b/boost/network/protocol/http/client/connection/normal_delegate.ipp index ae52fd870..103b059b7 100644 --- a/boost/network/protocol/http/client/connection/normal_delegate.ipp +++ b/boost/network/protocol/http/client/connection/normal_delegate.ipp @@ -19,13 +19,16 @@ boost::network::http::impl::normal_delegate::normal_delegate( : service_(service) {} void boost::network::http::impl::normal_delegate::connect( - asio::ip::tcp::endpoint &endpoint, std::string host, boost::uint16_t source_port, + asio::ip::tcp::endpoint &endpoint, std::string host, + boost::uint16_t source_port, function handler) { // TODO(dberris): review parameter necessity. (void)host; - - socket_.reset(new asio::ip::tcp::socket(service_, asio::ip::tcp::endpoint(asio::ip::tcp::v4(), source_port))); + + socket_.reset(new asio::ip::tcp::socket( + service_, + asio::ip::tcp::endpoint(asio::ip::address(), source_port))); socket_->async_connect(endpoint, handler); } @@ -51,7 +54,4 @@ void boost::network::http::impl::normal_delegate::disconnect() { } } -boost::network::http::impl::normal_delegate::~normal_delegate() {} - -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_NORMAL_DELEGATE_IPP_20110819 \ - */ +#endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_CONNECTION_NORMAL_DELEGATE_IPP_20110819 diff --git a/boost/network/protocol/http/client/connection/ssl_delegate.hpp b/boost/network/protocol/http/client/connection/ssl_delegate.hpp index 712fc5173..d084befb5 100644 --- a/boost/network/protocol/http/client/connection/ssl_delegate.hpp +++ b/boost/network/protocol/http/client/connection/ssl_delegate.hpp @@ -9,11 +9,12 @@ #include #include -#include -#include #include +#include #include #include +#include +#include namespace boost { namespace network { @@ -29,16 +30,17 @@ struct ssl_delegate : connection_delegate, optional private_key_file, optional ciphers, long ssl_options); - virtual void connect(asio::ip::tcp::endpoint &endpoint, std::string host, boost::uint16_t source_port, - function handler); - virtual void write( - asio::streambuf &command_streambuf, - function handler); - virtual void read_some( - asio::mutable_buffers_1 const &read_buffer, - function handler); - virtual void disconnect(); - ~ssl_delegate(); + void connect(asio::ip::tcp::endpoint &endpoint, std::string host, + boost::uint16_t source_port, + function handler) override; + void write(asio::streambuf &command_streambuf, + function handler) + override; + void read_some(asio::mutable_buffers_1 const &read_buffer, + function handler) + override; + void disconnect() override; + ~ssl_delegate() override; private: asio::io_service &service_; @@ -48,9 +50,9 @@ struct ssl_delegate : connection_delegate, optional private_key_file_; optional ciphers_; long ssl_options_; - scoped_ptr context_; - scoped_ptr tcp_socket_; - scoped_ptr > socket_; + std::unique_ptr context_; + std::unique_ptr tcp_socket_; + std::unique_ptr > socket_; bool always_verify_peer_; ssl_delegate(ssl_delegate const &); // = delete @@ -60,13 +62,10 @@ struct ssl_delegate : connection_delegate, function handler); }; -} /* impl */ - -} /* http */ - -} /* network */ - -} /* boost */ +} // namespace impl +} // namespace http +} // namespace network +} // namespace boost #ifdef BOOST_NETWORK_NO_LIB #include diff --git a/boost/network/protocol/http/client/connection/ssl_delegate.ipp b/boost/network/protocol/http/client/connection/ssl_delegate.ipp index 71161ba46..7c4672097 100644 --- a/boost/network/protocol/http/client/connection/ssl_delegate.ipp +++ b/boost/network/protocol/http/client/connection/ssl_delegate.ipp @@ -20,11 +20,11 @@ boost::network::http::impl::ssl_delegate::ssl_delegate( optional ciphers, long ssl_options) : service_(service), - certificate_filename_(certificate_filename), - verify_path_(verify_path), - certificate_file_(certificate_file), - private_key_file_(private_key_file), - ciphers_(ciphers), + certificate_filename_(std::move(certificate_filename)), + verify_path_(std::move(verify_path)), + certificate_file_(std::move(certificate_file)), + private_key_file_(std::move(private_key_file)), + ciphers_(std::move(ciphers)), ssl_options_(ssl_options), always_verify_peer_(always_verify_peer) {} diff --git a/boost/network/protocol/http/client/connection/sync_base.hpp b/boost/network/protocol/http/client/connection/sync_base.hpp index 4b81220fc..afe10baf2 100644 --- a/boost/network/protocol/http/client/connection/sync_base.hpp +++ b/boost/network/protocol/http/client/connection/sync_base.hpp @@ -8,14 +8,14 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include #include +#include #include #include #include #include -#include #include +#include #include #ifdef BOOST_NETWORK_ENABLE_HTTPS @@ -39,7 +39,7 @@ struct sync_connection_base_impl { template void init_socket(Socket& socket_, resolver_type& resolver_, - string_type const& hostname, string_type const& port, + string_type /*unused*/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; @@ -100,7 +100,7 @@ struct sync_connection_base_impl { } template - void send_request_impl(Socket& socket_, string_type const& method, + void send_request_impl(Socket& socket_, string_type /*unused*/const& method, boost::asio::streambuf& request_buffer) { // TODO(dberris): review parameter necessity. (void)method; @@ -198,7 +198,8 @@ struct sync_connection_base_impl { size_t length = lexical_cast(boost::begin(content_length_range)->second) - already_read; - if (length == 0) return; + if (length == 0) { return; +} size_t bytes_read = 0; while ((bytes_read = boost::asio::read(socket_, response_buffer, boost::asio::transfer_at_least(1), @@ -214,15 +215,16 @@ struct sync_connection_base_impl { void read_body(Socket& socket_, basic_response& response_, boost::asio::streambuf& response_buffer) { typename ostringstream::type body_stream; - // TODO tag dispatch based on whether it's HTTP 1.0 or HTTP 1.1 + // TODO(dberris): tag dispatch based on whether it's HTTP 1.0 or HTTP 1.1 if (version_major == 1 && version_minor == 0) { read_body_normal(socket_, response_, response_buffer, body_stream); } else if (version_major == 1 && version_minor == 1) { - if (response_.version() == "HTTP/1.0") + if (response_.version() == "HTTP/1.0") { read_body_normal(socket_, response_, response_buffer, body_stream); - else + } else { read_body_transfer_chunk_encoding(socket_, response_, response_buffer, body_stream); +} } else { throw std::runtime_error("Unsupported HTTP version number."); } @@ -248,7 +250,7 @@ struct sync_connection_base { new_connection( resolver_type& resolver, resolver_function_type resolve, bool https, bool always_verify_peer, int timeout, - optional const& certificate_filename = + optional /*unused*/const& certificate_filename = optional(), optional const& verify_path = optional(), optional const& certificate_file = @@ -288,10 +290,10 @@ struct sync_connection_base { boost::asio::streambuf& response_buffer) = 0; virtual bool is_open() = 0; virtual void close_socket() = 0; - virtual ~sync_connection_base() {} + virtual ~sync_connection_base() = default; protected: - sync_connection_base() {} + sync_connection_base() = default; }; } // namespace impl diff --git a/boost/network/protocol/http/client/connection/sync_normal.hpp b/boost/network/protocol/http/client/connection/sync_normal.hpp index e9d3f3262..5ef295d35 100644 --- a/boost/network/protocol/http/client/connection/sync_normal.hpp +++ b/boost/network/protocol/http/client/connection/sync_normal.hpp @@ -8,11 +8,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 - namespace boost { namespace network { namespace http { @@ -47,7 +50,7 @@ struct http_sync_connection timeout_(timeout), timer_(resolver.get_io_service()), resolver_(resolver), - resolve_(resolve), + resolve_(std::move(resolve)), socket_(resolver.get_io_service()) {} void init_socket(string_type const& hostname, string_type const& port) { @@ -95,7 +98,8 @@ struct http_sync_connection connection_base::read_body(socket_, response_, response_buffer); typename headers_range >::type connection_range = headers(response_)["Connection"]; - if (version_major == 1 && version_minor == 1 && !boost::empty(connection_range) && + if (version_major == 1 && version_minor == 1 && + !boost::empty(connection_range) && boost::iequals(boost::begin(connection_range)->second, "close")) { close_socket(); } else if (version_major == 1 && version_minor == 0) { @@ -107,16 +111,22 @@ struct http_sync_connection void close_socket() { timer_.cancel(); - if (!is_open()) return; + if (!is_open()) { + return; + } boost::system::error_code ignored; socket_.shutdown(boost::asio::ip::tcp::socket::shutdown_both, ignored); - if (ignored) return; + if (ignored != nullptr) { + return; + } socket_.close(ignored); } private: void handle_timeout(boost::system::error_code const& ec) { - if (!ec) close_socket(); + if (!ec) { + close_socket(); + } } int timeout_; @@ -127,8 +137,8 @@ struct http_sync_connection }; } // namespace impl -} // nmaespace http +} // namespace http } // namespace network -} // nmaespace boost +} // namespace boost #endif // BOOST_NETWORK_PROTOCOL_HTTP_IMPL_HTTP_SYNC_CONNECTION_20100 diff --git a/boost/network/protocol/http/client/connection/sync_ssl.hpp b/boost/network/protocol/http/client/connection/sync_ssl.hpp index 7561289de..44dd0eee3 100644 --- a/boost/network/protocol/http/client/connection/sync_ssl.hpp +++ b/boost/network/protocol/http/client/connection/sync_ssl.hpp @@ -13,9 +13,9 @@ #include #include #include +#include +#include #include -#include -#include #include #include @@ -52,7 +52,7 @@ struct https_sync_connection https_sync_connection( resolver_type& resolver, resolver_function_type resolve, bool always_verify_peer, int timeout, - optional const& certificate_filename = + optional /*unused*/const& certificate_filename = optional(), optional const& verify_path = optional(), optional const& certificate_file = optional(), @@ -63,7 +63,7 @@ struct https_sync_connection timeout_(timeout), timer_(resolver.get_io_service()), resolver_(resolver), - resolve_(resolve), + resolve_(std::move(resolve)), context_(resolver.get_io_service(), boost::asio::ssl::context::sslv23_client), socket_(resolver.get_io_service(), context_) { @@ -95,13 +95,13 @@ struct https_sync_connection boost::asio::ssl::context::pem); } - void init_socket(string_type const& hostname, string_type const& port) { + void init_socket(string_type /*unused*/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, + void send_request_impl(string_type /*unused*/const& method, basic_request const& request_, body_generator_function_type generator) { boost::asio::streambuf request_buffer; @@ -157,7 +157,8 @@ struct https_sync_connection boost::system::error_code ignored; socket_.lowest_layer().shutdown(boost::asio::ip::tcp::socket::shutdown_both, ignored); - if (ignored) return; + if (ignored != nullptr) { return; +} socket_.lowest_layer().close(ignored); } @@ -165,7 +166,8 @@ struct https_sync_connection private: void handle_timeout(boost::system::error_code const& ec) { - if (!ec) close_socket(); + if (!ec) { close_socket(); +} } int timeout_; diff --git a/boost/network/protocol/http/client/facade.hpp b/boost/network/protocol/http/client/facade.hpp index 68c02ce18..d59815d6d 100644 --- a/boost/network/protocol/http/client/facade.hpp +++ b/boost/network/protocol/http/client/facade.hpp @@ -7,10 +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 namespace boost { namespace network { diff --git a/boost/network/protocol/http/client/macros.hpp b/boost/network/protocol/http/client/macros.hpp index c64cc7a0f..3ca515e00 100644 --- a/boost/network/protocol/http/client/macros.hpp +++ b/boost/network/protocol/http/client/macros.hpp @@ -12,8 +12,8 @@ #ifndef BOOST_NETWORK_HTTP_BODY_CALLBACK #define BOOST_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), \ + boost::system::error_code const& (error_name)) #endif #endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_MACROS_HPP_20110430 */ diff --git a/boost/network/protocol/http/client/options.hpp b/boost/network/protocol/http/client/options.hpp index 8207dcaa7..c83bc32d7 100644 --- a/boost/network/protocol/http/client/options.hpp +++ b/boost/network/protocol/http/client/options.hpp @@ -1,17 +1,17 @@ #ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_OPTIONS_HPP_20130128 #define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_OPTIONS_HPP_20130128 -#include -#include -#include -#include - // Copyright 2013 Google, Inc. // Copyright 2013 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 { namespace http { @@ -174,8 +174,8 @@ inline void swap(client_options& a, client_options& b) { a.swap(b); } -} /* http */ -} /* network */ -} /* boost */ +} // namespace http +} // namespace network +} // namespace boost -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_OPTIONS_HPP_20130128 */ +#endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_OPTIONS_HPP_20130128 diff --git a/boost/network/protocol/http/client/pimpl.hpp b/boost/network/protocol/http/client/pimpl.hpp index d66aa3874..2ae7ff6a8 100644 --- a/boost/network/protocol/http/client/pimpl.hpp +++ b/boost/network/protocol/http/client/pimpl.hpp @@ -6,16 +6,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 namespace boost { namespace network { @@ -78,13 +80,11 @@ struct basic_client_impl service, certificate_filename, verify_path, certificate_file, private_key_file, ciphers, ssl_options) {} - ~basic_client_impl() {} + ~basic_client_impl() = default; }; } // namespace http - } // namespace network - } // namespace boost #endif // BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_PIMPL_HPP_20100623 diff --git a/boost/network/protocol/http/client/sync_impl.hpp b/boost/network/protocol/http/client/sync_impl.hpp index 5051fbd85..39e90bc1a 100644 --- a/boost/network/protocol/http/client/sync_impl.hpp +++ b/boost/network/protocol/http/client/sync_impl.hpp @@ -1,22 +1,23 @@ #ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_SYNC_IMPL_HPP_20100623 #define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_SYNC_IMPL_HPP_20100623 -#include -#include -#include -#include -#include -#include -#include -#include -#include - // Copyright 2013 Google, Inc. // 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 +#include +#include +#include +#include +#include +#include +#include + namespace boost { namespace network { namespace http { @@ -51,30 +52,27 @@ struct sync_client sync_client( bool cache_resolved, bool follow_redirect, bool always_verify_peer, int timeout, boost::shared_ptr service, - optional const& certificate_filename = + optional certificate_filename = optional(), - optional const& verify_path = optional(), - optional const& certificate_file = optional(), - optional const& private_key_file = optional(), - optional const& ciphers = optional(), + optional verify_path = optional(), + optional certificate_file = optional(), + optional private_key_file = optional(), + optional ciphers = optional(), long ssl_options = 0) : connection_base(cache_resolved, follow_redirect, timeout), service_ptr(service.get() ? service : make_shared()), service_(*service_ptr), resolver_(service_), - certificate_filename_(certificate_filename), - verify_path_(verify_path), - certificate_file_(certificate_file), - private_key_file_(private_key_file), - ciphers_(ciphers), + certificate_filename_(std::move(certificate_filename)), + verify_path_(std::move(verify_path)), + certificate_file_(std::move(certificate_file)), + private_key_file_(std::move(private_key_file)), + ciphers_(std::move(ciphers)), ssl_options_(ssl_options), always_verify_peer_(always_verify_peer) {} - ~sync_client() { - connection_base::cleanup(); - service_ptr.reset(); - } + ~sync_client() = default; void wait_complete() {} diff --git a/boost/network/protocol/http/impl/message.ipp b/boost/network/protocol/http/impl/message.ipp index 5171cdecc..2bb7feefe 100644 --- a/boost/network/protocol/http/impl/message.ipp +++ b/boost/network/protocol/http/impl/message.ipp @@ -10,10 +10,10 @@ #ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_IPP #define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_IPP -#include #include -#include +#include #include +#include namespace boost { namespace network { @@ -41,7 +41,7 @@ typename message_impl::string_type const message_impl::url_decode( decode_buf[0] = str[++pos]; decode_buf[1] = str[++pos]; decode_buf[2] = '\0'; - result += static_cast(strtol(decode_buf, 0, 16)); + result += static_cast(strtol(decode_buf, nullptr, 16)); } else { // recover from error by not decoding character result += '%'; @@ -120,8 +120,9 @@ message_impl::make_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); + if (i != query_params.begin()) { query_string += '&'; + +}query_string += url_encode(i->first); query_string += '='; query_string += url_encode(i->second); } @@ -196,14 +197,17 @@ bool message_impl::base64_decode( char base64code3; base64code0 = decoding_data[static_cast(input_ptr[i])]; - if (base64code0 == nop) // non base64 character + if (base64code0 == nop) { // non base64 character return false; - if (!(++i < input_length)) // we need at least two input bytes for +} + if (!(++i < input_length)) { // we need at least two input bytes for // first byte output return false; +} base64code1 = decoding_data[static_cast(input_ptr[i])]; - if (base64code1 == nop) // non base64 character + if (base64code1 == nop) { // non base64 character return false; +} output += ((base64code0 << 2) | ((base64code1 >> 4) & 0x3)); @@ -214,8 +218,9 @@ bool message_impl::base64_decode( return true; } base64code2 = decoding_data[static_cast(input_ptr[i])]; - if (base64code2 == nop) // non base64 character + if (base64code2 == nop) { // non base64 character return false; +} output += ((base64code1 << 4) & 0xf0) | ((base64code2 >> 2) & 0x0f); } @@ -227,8 +232,9 @@ bool message_impl::base64_decode( return true; } base64code3 = decoding_data[static_cast(input_ptr[i])]; - if (base64code3 == nop) // non base64 character + if (base64code3 == nop) { // non base64 character return false; +} output += (((base64code2 << 6) & 0xc0) | base64code3); } diff --git a/boost/network/protocol/http/impl/request.hpp b/boost/network/protocol/http/impl/request.hpp index 29608f8a7..bd817e7fc 100644 --- a/boost/network/protocol/http/impl/request.hpp +++ b/boost/network/protocol/http/impl/request.hpp @@ -5,25 +5,21 @@ // (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__ - -#include -#include +#ifndef BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_IMPL_20070908_1_HPP__ +#define BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_IMPL_20070908_1_HPP__ +#include #include #include #include - -#include -#include #include - +#include #include -#include +#include #include - -#include +#include +#include +#include namespace boost { namespace network { @@ -63,11 +59,11 @@ struct basic_request : public basic_message { typedef typename string::type string_type; typedef boost::uint16_t port_type; - explicit basic_request(string_type const& uri_) : uri_(uri_), source_port_(0) {} + explicit basic_request(string_type /*unused*/const& uri_) : uri_(uri_), source_port_(0) {} explicit basic_request(boost::network::uri::uri const& uri_) : uri_(uri_), source_port_(0) {} - void uri(string_type const& new_uri) { uri_ = new_uri; } + void uri(string_type /*unused*/const& new_uri) { uri_ = new_uri; } void uri(boost::network::uri::uri const& new_uri) { uri_ = new_uri; } @@ -185,7 +181,7 @@ namespace impl { template <> struct request_headers_wrapper { basic_request const& request_; - request_headers_wrapper(basic_request const& request_) + explicit request_headers_wrapper(basic_request const& request_) : request_(request_) {} typedef headers_container::type headers_container_type; operator headers_container_type() { return request_.headers; } @@ -195,7 +191,7 @@ template <> struct body_wrapper > { typedef string::type string_type; basic_request const& request_; - body_wrapper(basic_request const& request_) + explicit body_wrapper(basic_request const& request_) : request_(request_) {} operator string_type() { return request_.body; } }; @@ -203,7 +199,7 @@ struct body_wrapper > { template <> struct request_headers_wrapper { basic_request const& request_; - request_headers_wrapper( + explicit request_headers_wrapper( basic_request const& request_) : request_(request_) {} typedef headers_container::type @@ -215,7 +211,7 @@ template <> struct body_wrapper > { typedef string::type string_type; basic_request const& request_; - body_wrapper(basic_request const& request_) + explicit body_wrapper(basic_request const& request_) : request_(request_) {} operator string_type() { return request_.body; } }; @@ -228,4 +224,4 @@ struct body_wrapper > { } // namespace boost -#endif // __NETWORK_PROTOCOL_HTTP_REQUEST_IMPL_20070908_1_HPP__ +#endif // BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_IMPL_20070908_1_HPP__ diff --git a/boost/network/protocol/http/impl/response.ipp b/boost/network/protocol/http/impl/response.ipp index f41be41d9..b43a187a1 100644 --- a/boost/network/protocol/http/impl/response.ipp +++ b/boost/network/protocol/http/impl/response.ipp @@ -18,10 +18,10 @@ #include #include +#include +#include #include #include -#include -#include namespace boost { namespace network { @@ -108,8 +108,7 @@ struct basic_response { 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]; + for (auto & h : headers) { buffers.push_back(buffer(h.name)); buffers.push_back(buffer(name_value_separator)); buffers.push_back(buffer(h.value)); diff --git a/boost/network/protocol/http/message.hpp b/boost/network/protocol/http/message.hpp index fa2d44ce2..da89eb98b 100644 --- a/boost/network/protocol/http/message.hpp +++ b/boost/network/protocol/http/message.hpp @@ -90,7 +90,7 @@ struct message_impl : public basic_message { status_(other.status_), status_message_(other.status_message_) {} - void version(string_type const &version) const { version_ = version; } + void version(string_type /*unused*/const &version) const { version_ = version; } string_type const version() const { return version_; } diff --git a/boost/network/protocol/http/message/async_message.hpp b/boost/network/protocol/http/message/async_message.hpp index 854c70756..f39354828 100644 --- a/boost/network/protocol/http/message/async_message.hpp +++ b/boost/network/protocol/http/message/async_message.hpp @@ -9,13 +9,13 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include #include #include +#include // FIXME move this out to a trait -#include #include +#include #include namespace boost { @@ -27,7 +27,8 @@ namespace impl { template struct ready_wrapper; -} /* impl */ +} // namespace impl + /* impl */ template struct async_message { diff --git a/boost/network/protocol/http/message/directives/major_version.hpp b/boost/network/protocol/http/message/directives/major_version.hpp index 7828b04fb..626d84796 100644 --- a/boost/network/protocol/http/message/directives/major_version.hpp +++ b/boost/network/protocol/http/message/directives/major_version.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 namespace boost { namespace network { @@ -31,11 +31,14 @@ inline major_version_directive major_version(boost::uint8_t major_version_) { return major_version_directive(major_version_); } -} /* http */ +} // namespace http + /* http */ -} /* network */ +} // namespace network + /* network */ -} /* boost */ +} // namespace boost + /* boost */ #endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_MAJOR_VERSION_HPP_20101120 \ */ diff --git a/boost/network/protocol/http/message/directives/method.hpp b/boost/network/protocol/http/message/directives/method.hpp index b9e2c1dfb..04f05b268 100644 --- a/boost/network/protocol/http/message/directives/method.hpp +++ b/boost/network/protocol/http/message/directives/method.hpp @@ -13,11 +13,14 @@ namespace http { BOOST_NETWORK_STRING_DIRECTIVE(method, method_, message.method(method_), message.method = method_); -} /* http */ +} // namespace http + /* http */ -} /* network */ +} // namespace network + /* network */ -} /* booet */ +} // namespace boost + /* booet */ #endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_METHOD_HPP_20101120 \ */ diff --git a/boost/network/protocol/http/message/directives/minor_version.hpp b/boost/network/protocol/http/message/directives/minor_version.hpp index 4c44414c9..c1fb2f19c 100644 --- a/boost/network/protocol/http/message/directives/minor_version.hpp +++ b/boost/network/protocol/http/message/directives/minor_version.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 namespace boost { namespace network { @@ -31,11 +31,14 @@ inline minor_version_directive minor_version(boost::uint8_t minor_version_) { return minor_version_directive(minor_version_); } -} /* http */ +} // namespace http + /* http */ -} /* network */ +} // namespace network + /* network */ -} /* boost */ +} // namespace boost + /* boost */ #endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_MINOR_VERSION_HPP_20101120 \ */ diff --git a/boost/network/protocol/http/message/directives/status.hpp b/boost/network/protocol/http/message/directives/status.hpp index 61a41e451..4f5ab9368 100644 --- a/boost/network/protocol/http/message/directives/status.hpp +++ b/boost/network/protocol/http/message/directives/status.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 { @@ -42,14 +42,14 @@ struct status_directive { template struct status_visitor : boost::static_visitor<> { basic_response const &response; - status_visitor(basic_response const &response) : response(response) {} + explicit 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 { + void operator()(T const & /*unused*/) const { // FIXME fail here! } }; diff --git a/boost/network/protocol/http/message/directives/status_message.hpp b/boost/network/protocol/http/message/directives/status_message.hpp index 2e437ec16..d8babadff 100644 --- a/boost/network/protocol/http/message/directives/status_message.hpp +++ b/boost/network/protocol/http/message/directives/status_message.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 namespace boost { namespace network { diff --git a/boost/network/protocol/http/message/directives/uri.hpp b/boost/network/protocol/http/message/directives/uri.hpp index 1a4114269..f4f49846e 100644 --- a/boost/network/protocol/http/message/directives/uri.hpp +++ b/boost/network/protocol/http/message/directives/uri.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 namespace boost { namespace network { diff --git a/boost/network/protocol/http/message/directives/version.hpp b/boost/network/protocol/http/message/directives/version.hpp index 16c3115d5..ddd882b21 100644 --- a/boost/network/protocol/http/message/directives/version.hpp +++ b/boost/network/protocol/http/message/directives/version.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 namespace boost { namespace network { diff --git a/boost/network/protocol/http/message/header.hpp b/boost/network/protocol/http/message/header.hpp index 5be2ad808..a26758350 100644 --- a/boost/network/protocol/http/message/header.hpp +++ b/boost/network/protocol/http/message/header.hpp @@ -13,8 +13,8 @@ #ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_HPP_20101122 #define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_HPP_20101122 -#include #include +#include #include #include #include diff --git a/boost/network/protocol/http/message/header/name.hpp b/boost/network/protocol/http/message/header/name.hpp index a5f6dee2f..c663fced3 100644 --- a/boost/network/protocol/http/message/header/name.hpp +++ b/boost/network/protocol/http/message/header/name.hpp @@ -32,10 +32,13 @@ inline std::wstring const &name(response_header_wide const &h) { return h.name; } -} /* http */ +} // namespace http + /* http */ -} /* network */ +} // namespace network + /* network */ -} /* boost */ +} // namespace boost + /* boost */ #endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_NAME_HPP_20101028 */ diff --git a/boost/network/protocol/http/message/header/value.hpp b/boost/network/protocol/http/message/header/value.hpp index dd581d00d..6766c5d16 100644 --- a/boost/network/protocol/http/message/header/value.hpp +++ b/boost/network/protocol/http/message/header/value.hpp @@ -42,10 +42,13 @@ inline response_header_wide::string_type const& value( return h.value; } -} /* http */ +} // namespace http + /* http */ -} /* network */ +} // namespace network + /* network */ -} /* boost */ +} // namespace boost + /* boost */ #endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_VALUE_HPP_20101028 */ diff --git a/boost/network/protocol/http/message/header_concept.hpp b/boost/network/protocol/http/message/header_concept.hpp index f3134e251..45642376f 100644 --- a/boost/network/protocol/http/message/header_concept.hpp +++ b/boost/network/protocol/http/message/header_concept.hpp @@ -29,10 +29,13 @@ struct Header : DefaultConstructible, Assignable, CopyConstructible { H header; }; -} /* http */ +} // namespace http + /* http */ -} /* network */ +} // namespace network + /* network */ -} /* boost */ +} // namespace boost + /* boost */ #endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_CONCEPT_HPP_20101028 */ diff --git a/boost/network/protocol/http/message/message_base.hpp b/boost/network/protocol/http/message/message_base.hpp index 39376531b..4cb55fb7b 100644 --- a/boost/network/protocol/http/message/message_base.hpp +++ b/boost/network/protocol/http/message/message_base.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 namespace boost { namespace network { diff --git a/boost/network/protocol/http/message/modifiers/body.hpp b/boost/network/protocol/http/message/modifiers/body.hpp index dd1c7430b..7c56903b8 100644 --- a/boost/network/protocol/http/message/modifiers/body.hpp +++ b/boost/network/protocol/http/message/modifiers/body.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 namespace boost { namespace network { @@ -26,15 +26,15 @@ struct basic_request; namespace impl { template -void body(basic_response &response, T const &value, mpl::false_ const &) { +void body(basic_response &response, T const &value, mpl::false_ const & /*unused*/) { response << ::boost::network::body(value); } template -void body(basic_response &response, T const &future, mpl::true_ const &) { +void body(basic_response &response, T const &future, mpl::true_ const & /*unused*/) { response.body(future); } -} +} // namespace impl template inline void body(basic_response &response, T const &value) { @@ -43,13 +43,13 @@ inline void body(basic_response &response, T const &value) { template inline void body_impl(basic_request &request, T const &value, - tags::server) { + tags::server /*unused*/) { request.body = value; } template inline void body_impl(basic_request &request, T const &value, - tags::client) { + tags::client /*unused*/) { request << ::boost::network::body(value); } @@ -64,11 +64,12 @@ namespace impl { template inline void body(Message const &message, ValueType const &body_, - http::tags::http_server, Async) { + http::tags::http_server /*unused*/, Async /*unused*/) { message.body = body_; } -} /* impl */ +} // namespace impl + /* impl */ } // namespace network diff --git a/boost/network/protocol/http/message/modifiers/clear_headers.hpp b/boost/network/protocol/http/message/modifiers/clear_headers.hpp index b723bb046..67b34d3b3 100644 --- a/boost/network/protocol/http/message/modifiers/clear_headers.hpp +++ b/boost/network/protocol/http/message/modifiers/clear_headers.hpp @@ -6,9 +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 namespace boost { @@ -16,23 +18,23 @@ namespace network { namespace http { template -inline void clear_headers_impl(basic_request& request, tags::pod) { +inline void clear_headers_impl(basic_request& request, boost::network::tags::pod /*unused*/) { 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) { +inline void clear_headers_impl(basic_request& request, boost::network::tags::normal /*unused*/) { request.headers(typename basic_request::headers_container_type()); } template -inline void clear_headers_impl(basic_request& request, tags::client) { +inline void clear_headers_impl(basic_request& request, tags::client /*unused*/) { clear_headers_impl(request, typename pod_or_normal::type()); } template -inline void clear_headers_impl(basic_request& request, tags::server) { +inline void clear_headers_impl(basic_request& request, tags::server /*unused*/) { typedef typename basic_request::headers_container_type headers_container; headers_container().swap(request.headers); } @@ -42,11 +44,9 @@ inline void clear_headers(basic_request& request) { clear_headers_impl(request, typename client_or_server::type()); } -} /* http */ - -} /* network */ +} // namespace http -} /* boost */ +} // namespace network +} // namespace boost -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_CLEAR_HEADER_HPP_20101128 \ - */ +#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_CLEAR_HEADER_HPP_20101128 diff --git a/boost/network/protocol/http/message/modifiers/destination.hpp b/boost/network/protocol/http/message/modifiers/destination.hpp index 902d7bd1f..1c29c1b0f 100644 --- a/boost/network/protocol/http/message/modifiers/destination.hpp +++ b/boost/network/protocol/http/message/modifiers/destination.hpp @@ -6,11 +6,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 namespace boost { namespace network { @@ -26,16 +28,16 @@ namespace impl { template void destination(basic_response &response, T const &value, - mpl::false_ const &) { + mpl::false_ const & /*unused*/) { response << ::boost::network::destination(value); } template void destination(basic_response &response, T const &future, - mpl::true_ const &) { + mpl::true_ const & /*unused*/) { response.destination(future); } -} +} // namespace impl template inline void destination(basic_response &response, T const &value) { @@ -47,25 +49,25 @@ struct ServerRequest; template inline void destination_impl(basic_request &request, T const &value, - tags::server) { + tags::server /*unused*/) { request.destination = value; } template inline void destination_impl(basic_request &request, T const &value, - tags::pod) { + boost::network::tags::pod /*unused*/) { request.destination = value; } template inline void destination_impl(basic_request &request, T const &value, - tags::normal) { + boost::network::tags::normal /*unused*/) { request.destination(value); } template inline void destination_impl(basic_request &request, T const &value, - tags::client) { + tags::client /*unused*/) { destination_impl(request, value, typename pod_or_normal::type()); } @@ -80,14 +82,12 @@ namespace impl { template inline void destination(Message const &message, ValueType const &destination_, - http::tags::http_server, Async) { + http::tags::http_server /*unused*/, Async /*unused*/) { message.destination = destination_; } -} /* impl */ - +} // namespace impl } // namespace network - } // namespace boost #include diff --git a/boost/network/protocol/http/message/modifiers/headers.hpp b/boost/network/protocol/http/message/modifiers/headers.hpp index 903549415..826a22ea3 100644 --- a/boost/network/protocol/http/message/modifiers/headers.hpp +++ b/boost/network/protocol/http/message/modifiers/headers.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 namespace boost { namespace network { @@ -24,22 +24,22 @@ namespace impl { template void headers(basic_response &response, T const &value, - mpl::false_ const &) { + mpl::false_ const & /*unused*/) { response << headers(value); } template void headers(basic_response &response, T const &future, - mpl::true_ const &) { + mpl::true_ const & /*unused*/) { response.headers(future); } template void headers(basic_request &request, T const &value, - tags::server const &) { + tags::server const & /*unused*/) { request.headers = value; } -} +} // namespace impl template inline void headers(basic_response &response, T const &value) { diff --git a/boost/network/protocol/http/message/modifiers/major_version.hpp b/boost/network/protocol/http/message/modifiers/major_version.hpp index fbe60eb62..ed6df4e72 100644 --- a/boost/network/protocol/http/message/modifiers/major_version.hpp +++ b/boost/network/protocol/http/message/modifiers/major_version.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 namespace boost { namespace network { @@ -23,11 +23,14 @@ inline typename enable_if, void>::type major_version( request.http_version_major = major_version_; } -} /* http */ +} // namespace http + /* http */ -} /* network */ +} // namespace network + /* network */ -} /* boost */ +} // namespace boost + /* boost */ #endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_MAJOR_VERSION_HPP_20101120 \ */ diff --git a/boost/network/protocol/http/message/modifiers/method.hpp b/boost/network/protocol/http/message/modifiers/method.hpp index 8aeab4ce0..c48e43ba4 100644 --- a/boost/network/protocol/http/message/modifiers/method.hpp +++ b/boost/network/protocol/http/message/modifiers/method.hpp @@ -22,10 +22,13 @@ inline typename enable_if, void>::type method( request.method = method_; } -} /* http */ +} // namespace http + /* http */ -} /* network */ +} // namespace network + /* network */ -} /* boost */ +} // namespace boost + /* boost */ #endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_METHOD_HPP_20101118 */ diff --git a/boost/network/protocol/http/message/modifiers/minor_version.hpp b/boost/network/protocol/http/message/modifiers/minor_version.hpp index 0850ba921..752666d38 100644 --- a/boost/network/protocol/http/message/modifiers/minor_version.hpp +++ b/boost/network/protocol/http/message/modifiers/minor_version.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 namespace boost { namespace network { @@ -23,11 +23,14 @@ inline typename enable_if, void>::type minor_version( request.http_version_minor = minor_version_; } -} /* http */ +} // namespace http + /* http */ -} /* network */ +} // namespace network + /* network */ -} /* boost */ +} // namespace boost + /* boost */ #endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_MINOR_VERSION_HPP_20101120 \ */ diff --git a/boost/network/protocol/http/message/modifiers/source.hpp b/boost/network/protocol/http/message/modifiers/source.hpp index 396b69fa4..989c733a2 100644 --- a/boost/network/protocol/http/message/modifiers/source.hpp +++ b/boost/network/protocol/http/message/modifiers/source.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 namespace boost { namespace network { @@ -24,26 +24,26 @@ namespace impl { template void source(basic_response &response, T const &value, - mpl::false_ const &) { + mpl::false_ const & /*unused*/) { response << ::boost::network::source(value); } template void source(basic_response &response, T const &future, - mpl::true_ const &) { + mpl::true_ const & /*unused*/) { response.source(future); } template -void source(basic_request &request, T const &value, tags::server const &) { +void source(basic_request &request, T const &value, tags::server const & /*unused*/) { request.source = value; } template -void source(basic_request &request, T const &value, tags::client const &) { +void source(basic_request &request, T const &value, tags::client const & /*unused*/) { request << ::boost::network::source(value); } -} +} // namespace impl template inline void source(basic_response &response, T const &value) { @@ -52,13 +52,13 @@ inline void source(basic_response &response, T const &value) { template inline void source_impl(basic_request &request, T const &value, - tags::server) { + tags::server /*unused*/) { impl::source(request, value, Tag()); } template inline void source_impl(basic_request &request, T const &value, - tags::client) { + tags::client /*unused*/) { impl::source(request, value, Tag()); } @@ -73,11 +73,12 @@ namespace impl { template inline void source(Message const &message, ValueType const &source_, - http::tags::http_server const &, Async const &) { + http::tags::http_server const & /*unused*/, Async const & /*unused*/) { message.source = source_; } -} /* impl */ +} // namespace impl + /* impl */ } // namespace network diff --git a/boost/network/protocol/http/message/modifiers/status.hpp b/boost/network/protocol/http/message/modifiers/status.hpp index 27a774bef..811f3eacf 100644 --- a/boost/network/protocol/http/message/modifiers/status.hpp +++ b/boost/network/protocol/http/message/modifiers/status.hpp @@ -21,13 +21,13 @@ namespace impl { template void status(basic_response &response, T const &value, - mpl::false_ const &) { + mpl::false_ const & /*unused*/) { response << boost::network::http::status(value); } template void status(basic_response &response, T const &future, - mpl::true_ const &) { + mpl::true_ const & /*unused*/) { response.status(future); } diff --git a/boost/network/protocol/http/message/modifiers/status_message.hpp b/boost/network/protocol/http/message/modifiers/status_message.hpp index 750163053..3e574e128 100644 --- a/boost/network/protocol/http/message/modifiers/status_message.hpp +++ b/boost/network/protocol/http/message/modifiers/status_message.hpp @@ -21,13 +21,13 @@ namespace impl { template void status_message(basic_response &response, T const &value, - mpl::false_ const &) { + mpl::false_ const & /*unused*/) { response << boost::network::http::status_message(value); } template void status_message(basic_response &response, T const &future, - mpl::true_ const &) { + mpl::true_ const & /*unused*/) { response.status_message(future); } diff --git a/boost/network/protocol/http/message/modifiers/version.hpp b/boost/network/protocol/http/message/modifiers/version.hpp index f237870b2..9ed222aa2 100644 --- a/boost/network/protocol/http/message/modifiers/version.hpp +++ b/boost/network/protocol/http/message/modifiers/version.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 namespace boost { namespace network { @@ -23,13 +23,13 @@ namespace impl { template void version(basic_response &response, T const &value, - mpl::false_ const &) { + mpl::false_ const & /*unused*/) { response << boost::network::http::version(value); } template void version(basic_response &response, T const &future, - mpl::true_ const &) { + mpl::true_ const & /*unused*/) { response.version(future); } diff --git a/boost/network/protocol/http/message/traits/status.hpp b/boost/network/protocol/http/message/traits/status.hpp index 93b66885f..4c04be143 100644 --- a/boost/network/protocol/http/message/traits/status.hpp +++ b/boost/network/protocol/http/message/traits/status.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 { @@ -27,10 +27,14 @@ struct status typename mpl::if_, boost::uint16_t, unsupported_tag >::type> {}; -} /* traits */ +} // namespace traits + /* traits */ -} /* http */ -} /* network */ -} /* boost */ +} // namespace http + /* http */ +} // namespace network + /* network */ +} // namespace boost + /* boost */ #endif diff --git a/boost/network/protocol/http/message/traits/status_message.hpp b/boost/network/protocol/http/message/traits/status_message.hpp index 92487ae78..61b89ec02 100644 --- a/boost/network/protocol/http/message/traits/status_message.hpp +++ b/boost/network/protocol/http/message/traits/status_message.hpp @@ -6,9 +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 namespace boost { namespace network { @@ -26,15 +28,19 @@ struct status_message boost::shared_future::type>, typename mpl::if_< mpl::or_, - is_same, - is_same >, + is_same, + is_same >, typename string::type, unsupported_tag >::type> {}; -} /* traits */ +} // namespace traits + /* traits */ -} /* http */ -} /* network */ -} /* boost */ +} // namespace http + /* http */ +} // namespace network + /* network */ +} // namespace boost + /* boost */ #endif diff --git a/boost/network/protocol/http/message/traits/version.hpp b/boost/network/protocol/http/message/traits/version.hpp index d4b998116..3fbcc7348 100644 --- a/boost/network/protocol/http/message/traits/version.hpp +++ b/boost/network/protocol/http/message/traits/version.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 namespace boost { namespace network { @@ -43,10 +43,14 @@ struct version< typedef typename string::type type; }; -} /* traits */ +} // namespace traits + /* traits */ -} /* http */ -} /* network */ -} /* boost */ +} // namespace http + /* http */ +} // namespace network + /* network */ +} // namespace boost + /* boost */ #endif diff --git a/boost/network/protocol/http/message/wrappers/anchor.hpp b/boost/network/protocol/http/message/wrappers/anchor.hpp index 27c4dd51f..f65bda8c2 100644 --- a/boost/network/protocol/http/message/wrappers/anchor.hpp +++ b/boost/network/protocol/http/message/wrappers/anchor.hpp @@ -18,11 +18,11 @@ namespace impl { template struct anchor_wrapper { basic_request const& message_; - anchor_wrapper(basic_request const& message) : message_(message) {} + explicit anchor_wrapper(basic_request const& message) : message_(message) {} typedef typename basic_request::string_type string_type; operator string_type() { return message_.anchor(); } }; -} +} // namespace impl template inline impl::anchor_wrapper anchor(basic_request const& request) { @@ -33,6 +33,6 @@ inline impl::anchor_wrapper anchor(basic_request const& request) { } // namespace network -} // nmaespace boost +} // namespace boost #endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_ANCHOR_HPP_20100618 diff --git a/boost/network/protocol/http/message/wrappers/destination.hpp b/boost/network/protocol/http/message/wrappers/destination.hpp index 8210ab39a..940f8bbc7 100644 --- a/boost/network/protocol/http/message/wrappers/destination.hpp +++ b/boost/network/protocol/http/message/wrappers/destination.hpp @@ -3,10 +3,11 @@ // 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) +// (See accompanying file LICENSE_1_a.txt or copy at +// http://www.boost.org/LICENSE_1_-1.txt) #include +#include namespace boost { namespace network { diff --git a/boost/network/protocol/http/message/wrappers/headers.hpp b/boost/network/protocol/http/message/wrappers/headers.hpp index a1bcd7103..818989bdb 100644 --- a/boost/network/protocol/http/message/wrappers/headers.hpp +++ b/boost/network/protocol/http/message/wrappers/headers.hpp @@ -41,11 +41,11 @@ struct request_headers_wrapper { explicit request_headers_wrapper(basic_request const& message) : message_(message) {} - range_type operator[](string_type const& key) const { + range_type operator[](string_type /*unused*/const& key) const { return message_.headers().equal_range(key); } - typename headers_container_type::size_type count(string_type const& key) + typename headers_container_type::size_type count(string_type /*unused*/const& key) const { return message_.headers().count(key); } @@ -76,11 +76,11 @@ struct response_headers_wrapper { explicit response_headers_wrapper(basic_response const& message) : message_(message) {} - range_type operator[](string_type const& key) const { + range_type operator[](string_type /*unused*/const& key) const { return message_.headers().equal_range(key); } - typename headers_container_type::size_type count(string_type const& key) + typename headers_container_type::size_type count(string_type /*unused*/const& key) const { return message_.headers().count(key); } @@ -114,7 +114,7 @@ inline impl::response_headers_wrapper headers( return impl::response_headers_wrapper(response_); } -} // namepace http +} // namespace http } // namespace network diff --git a/boost/network/protocol/http/message/wrappers/helper.hpp b/boost/network/protocol/http/message/wrappers/helper.hpp index 2f463414a..deb369884 100644 --- a/boost/network/protocol/http/message/wrappers/helper.hpp +++ b/boost/network/protocol/http/message/wrappers/helper.hpp @@ -7,6 +7,8 @@ // http://www.boost.org/LICENSE_1_0.txt) #include +#include +#include #ifndef BOOST_NETWORK_DEFINE_HTTP_WRAPPER #define BOOST_NETWORK_DEFINE_HTTP_WRAPPER(name, accessor, pod_field) \ @@ -29,8 +31,8 @@ \ template \ struct name##_wrapper_impl \ - : mpl::if_, name##_pod_accessor, \ - name##_member_accessor> {}; \ + : mpl::if_, \ + name##_pod_accessor, name##_member_accessor> {}; \ \ template \ struct name##_wrapper : name##_wrapper_impl::type { \ diff --git a/boost/network/protocol/http/message/wrappers/host.hpp b/boost/network/protocol/http/message/wrappers/host.hpp index 9841674da..20ad90742 100644 --- a/boost/network/protocol/http/message/wrappers/host.hpp +++ b/boost/network/protocol/http/message/wrappers/host.hpp @@ -20,13 +20,13 @@ template struct host_wrapper { basic_request const& message_; - host_wrapper(basic_request const& message) : message_(message) {} + explicit host_wrapper(basic_request const& message) : message_(message) {} typedef typename basic_request::string_type string_type; operator string_type() { return message_.host(); } }; -} +} // namespace impl template inline impl::host_wrapper host(basic_request const& request) { diff --git a/boost/network/protocol/http/message/wrappers/major_version.hpp b/boost/network/protocol/http/message/wrappers/major_version.hpp index 40ad3d527..7e2484848 100644 --- a/boost/network/protocol/http/message/wrappers/major_version.hpp +++ b/boost/network/protocol/http/message/wrappers/major_version.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 namespace boost { namespace network { @@ -31,11 +31,14 @@ major_version(basic_request const& request) { return major_version_wrapper(request); } -} /* http */ +} // namespace http + /* http */ -} /* network */ +} // namespace network + /* network */ -} /* boost */ +} // namespace boost + /* boost */ #endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_MAJOR_VERSION_HPP_20101120 \ */ diff --git a/boost/network/protocol/http/message/wrappers/method.hpp b/boost/network/protocol/http/message/wrappers/method.hpp index 6f194d3f8..2a07189ee 100644 --- a/boost/network/protocol/http/message/wrappers/method.hpp +++ b/boost/network/protocol/http/message/wrappers/method.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 namespace boost { namespace network { @@ -34,10 +34,13 @@ method(basic_request const& message) { return method_wrapper(message); } -} /* http */ +} // namespace http + /* http */ -} /* network */ +} // namespace network + /* network */ -} /* boost */ +} // namespace boost + /* boost */ #endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_METHOD_HPP_20101118 */ diff --git a/boost/network/protocol/http/message/wrappers/minor_version.hpp b/boost/network/protocol/http/message/wrappers/minor_version.hpp index aad54e387..1f179dedf 100644 --- a/boost/network/protocol/http/message/wrappers/minor_version.hpp +++ b/boost/network/protocol/http/message/wrappers/minor_version.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 namespace boost { namespace network { @@ -31,11 +31,14 @@ minor_version(basic_request const& request) { return minor_version_wrapper(request); } -} /* http */ +} // namespace http + /* http */ -} /* network */ +} // namespace network + /* network */ -} /* boost */ +} // namespace boost + /* boost */ #endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_MINOR_VERSION_HPP_20101120 \ */ diff --git a/boost/network/protocol/http/message/wrappers/path.hpp b/boost/network/protocol/http/message/wrappers/path.hpp index 56f67e5c3..75166b1ac 100644 --- a/boost/network/protocol/http/message/wrappers/path.hpp +++ b/boost/network/protocol/http/message/wrappers/path.hpp @@ -20,13 +20,13 @@ template struct path_wrapper { basic_request const& message_; - path_wrapper(basic_request const& message) : message_(message) {} + explicit path_wrapper(basic_request const& message) : message_(message) {} typedef typename basic_request::string_type string_type; operator string_type() { return message_.path(); } }; -} +} // namespace impl template inline impl::path_wrapper path(basic_request const& request) { diff --git a/boost/network/protocol/http/message/wrappers/port.hpp b/boost/network/protocol/http/message/wrappers/port.hpp index f05d9dc81..506cb753c 100644 --- a/boost/network/protocol/http/message/wrappers/port.hpp +++ b/boost/network/protocol/http/message/wrappers/port.hpp @@ -9,9 +9,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 { @@ -27,7 +27,7 @@ template struct port_wrapper { basic_request const& message_; - port_wrapper(basic_request const& message) : message_(message) {} + explicit port_wrapper(basic_request const& message) : message_(message) {} typedef typename basic_request::port_type port_type; diff --git a/boost/network/protocol/http/message/wrappers/protocol.hpp b/boost/network/protocol/http/message/wrappers/protocol.hpp index 0b18fda82..3f8e4999d 100644 --- a/boost/network/protocol/http/message/wrappers/protocol.hpp +++ b/boost/network/protocol/http/message/wrappers/protocol.hpp @@ -18,11 +18,11 @@ namespace impl { template struct protocol_wrapper { basic_request const& message_; - protocol_wrapper(basic_request const& message) : message_(message) {} + explicit protocol_wrapper(basic_request const& message) : message_(message) {} typedef typename basic_request::string_type string_type; operator string_type() { return message_.protocol(); } }; -} +} // namespace impl template inline impl::protocol_wrapper protocol(basic_request const& request) { diff --git a/boost/network/protocol/http/message/wrappers/query.hpp b/boost/network/protocol/http/message/wrappers/query.hpp index 3d3353c65..04998f4c5 100644 --- a/boost/network/protocol/http/message/wrappers/query.hpp +++ b/boost/network/protocol/http/message/wrappers/query.hpp @@ -20,7 +20,7 @@ template struct query_wrapper { basic_request const& message_; - query_wrapper(basic_request const& message) : message_(message) {} + explicit query_wrapper(basic_request const& message) : message_(message) {} typedef typename basic_request::string_type string_type; diff --git a/boost/network/protocol/http/message/wrappers/ready.hpp b/boost/network/protocol/http/message/wrappers/ready.hpp index cb1ab3544..80a965a3b 100644 --- a/boost/network/protocol/http/message/wrappers/ready.hpp +++ b/boost/network/protocol/http/message/wrappers/ready.hpp @@ -38,10 +38,13 @@ inline bool ready(async_message const& message) { return impl::ready_wrapper(message); } -} /* http */ +} // namespace http + /* http */ -} /* network */ +} // namespace network + /* network */ -} /* boost */ +} // namespace boost + /* boost */ #endif /* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_READY_HPP_20100618 */ diff --git a/boost/network/protocol/http/message/wrappers/status_message.hpp b/boost/network/protocol/http/message/wrappers/status_message.hpp index ea4c8fc4d..90bc24268 100644 --- a/boost/network/protocol/http/message/wrappers/status_message.hpp +++ b/boost/network/protocol/http/message/wrappers/status_message.hpp @@ -9,6 +9,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include +#include namespace boost { namespace network { @@ -36,8 +37,8 @@ struct status_message_wrapper { }; template -inline std::ostream& operator<<(std::ostream& os, - const status_message_wrapper& wrapper) { +inline std::ostream& operator<<(std::ostream& os, + const status_message_wrapper& wrapper) { return os << static_cast::type>(wrapper); } diff --git a/boost/network/protocol/http/message/wrappers/uri.hpp b/boost/network/protocol/http/message/wrappers/uri.hpp index 2e80d1c62..67d8745b1 100644 --- a/boost/network/protocol/http/message/wrappers/uri.hpp +++ b/boost/network/protocol/http/message/wrappers/uri.hpp @@ -20,12 +20,12 @@ namespace impl { template struct uri_wrapper { basic_request const& message_; - uri_wrapper(basic_request const& message) : message_(message) {} + explicit 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::uri() { return message_.uri(); } }; -} +} // namespace impl template inline impl::uri_wrapper uri(basic_request const& request) { diff --git a/boost/network/protocol/http/parser/incremental.hpp b/boost/network/protocol/http/parser/incremental.hpp index ba7222a3a..d81b23920 100644 --- a/boost/network/protocol/http/parser/incremental.hpp +++ b/boost/network/protocol/http/parser/incremental.hpp @@ -8,12 +8,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 { @@ -53,7 +53,7 @@ struct response_parser { response_parser(response_parser const& other) : state_(other.state_) {} - ~response_parser() {} + ~response_parser() = default; void swap(response_parser& other) { std::swap(other.state_, this->state_); } @@ -290,7 +290,8 @@ struct response_parser { local_range = boost::make_iterator_range(current, end); } - if (state_ == stop_state) parsed_ok = true; + if (state_ == stop_state) { parsed_ok = true; +} return fusion::make_tuple(parsed_ok, boost::make_iterator_range(start, current)); } @@ -303,10 +304,13 @@ struct response_parser { state_t state_; }; -} /* http */ +} // namespace http + /* http */ -} /* network */ +} // namespace network + /* network */ -} /* boost */ +} // namespace boost + /* boost */ #endif diff --git a/boost/network/protocol/http/policies/async_connection.hpp b/boost/network/protocol/http/policies/async_connection.hpp index 667712b39..8ddb4181a 100644 --- a/boost/network/protocol/http/policies/async_connection.hpp +++ b/boost/network/protocol/http/policies/async_connection.hpp @@ -9,16 +9,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 { @@ -39,7 +39,7 @@ struct async_connection_policy : resolver_policy::type { connection_impl(bool follow_redirect, bool always_verify_peer, resolve_function resolve, resolver_type& resolver, bool https, int timeout, - optional const& certificate_filename, + optional /*unused*/const& certificate_filename, optional const& verify_path, optional const& certificate_file, optional const& private_key_file, @@ -53,7 +53,7 @@ struct async_connection_policy : resolver_policy::type { ciphers, ssl_options); } - basic_response send_request(string_type const& method, + basic_response send_request(string_type /*unused*/const& method, basic_request const& request_, bool get_body, body_callback_function_type callback, @@ -70,7 +70,7 @@ struct async_connection_policy : resolver_policy::type { connection_ptr get_connection( resolver_type& resolver, basic_request const& request_, bool always_verify_peer, - optional const& certificate_filename = + optional /*unused*/const& certificate_filename = optional(), optional const& verify_path = optional(), optional const& certificate_file = optional(), diff --git a/boost/network/protocol/http/policies/async_resolver.hpp b/boost/network/protocol/http/policies/async_resolver.hpp index 61a710147..dcc3bcc50 100644 --- a/boost/network/protocol/http/policies/async_resolver.hpp +++ b/boost/network/protocol/http/policies/async_resolver.hpp @@ -6,9 +6,17 @@ // (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 namespace boost { namespace network { @@ -63,7 +71,7 @@ struct async_resolver : boost::enable_shared_from_this > { boost::asio::placeholders::iterator))); } - void handle_resolve(string_type const &host, + void handle_resolve(string_type /*unused*/const &host, resolve_completion_function once_resolved, boost::system::error_code const &ec, resolver_iterator endpoint_iterator) { @@ -81,11 +89,8 @@ struct async_resolver : boost::enable_shared_from_this > { }; } // namespace policies - } // namespace http - } // namespace network - } // namespace boost #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 index 2ac32845a..21ecc9950 100644 --- a/boost/network/protocol/http/policies/pooled_connection.hpp +++ b/boost/network/protocol/http/policies/pooled_connection.hpp @@ -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 +#include #include #ifndef BOOST_NETWORK_HTTP_MAXIMUM_REDIRECT_COUNT @@ -37,7 +37,7 @@ struct pooled_connection_policy : resolver_policy::type { system::error_code const&)> body_callback_function_type; typedef function body_generator_function_type; - void cleanup() { host_connection_map().swap(host_connections); } + void cleanup() { host_connection_map().swap(host_connections_); } struct connection_impl { typedef function( @@ -47,10 +47,10 @@ struct pooled_connection_policy : resolver_policy::type { 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, - bool always_verify_peer, int timeout, + resolver_type& resolver, bool follow_redirect, + string_type /*unused*/ const& host, string_type const& port, + resolver_function_type resolve, get_connection_function get_connection, + bool https, bool always_verify_peer, int timeout, optional const& certificate_filename = optional(), optional const& verify_path = optional(), @@ -65,7 +65,7 @@ struct pooled_connection_policy : resolver_policy::type { ssl_options)), resolver_(resolver), connection_follow_redirect_(follow_redirect), - get_connection_(get_connection), + get_connection_(std::move(get_connection)), certificate_filename_(certificate_filename), verify_path_(verify_path), certificate_file_(certificate_file), @@ -113,8 +113,7 @@ struct pooled_connection_policy : resolver_policy::type { try { pimpl->read_status(response_, response_buffer); - } - catch (boost::system::system_error& e) { + } catch (boost::system::system_error& e) { if (!retry && e.code() == boost::asio::error::eof) { retry = true; pimpl->init_socket(request_.host(), @@ -182,8 +181,9 @@ struct pooled_connection_policy : resolver_policy::type { typedef shared_ptr connection_ptr; - typedef unordered_map host_connection_map; - host_connection_map host_connections; + typedef unordered_map> host_connection_map; + boost::mutex host_mutex_; + host_connection_map host_connections_; bool follow_redirect_; int timeout_; @@ -198,33 +198,40 @@ struct pooled_connection_policy : resolver_policy::type { optional const& ciphers = 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, boost::arg<1>(), boost::arg<2>(), boost::arg<3>()), - boost::bind(&pooled_connection_policy::get_connection, - this, boost::arg<1>(), boost::arg<2>(), - always_verify_peer, boost::arg<3>(), boost::arg<4>(), - boost::arg<5>(), boost::arg<6>(), boost::arg<7>()), - boost::iequals(request_.protocol(), string_type("https")), - always_verify_peer, timeout_, certificate_filename, verify_path, - certificate_file, private_key_file, ciphers, 0)); - host_connections.insert(std::make_pair(index, connection_)); - return connection_; + boost::mutex::scoped_lock lock(host_mutex_); + auto it = host_connections_.find(index); + if (it != host_connections_.end()) { + // We've found an existing connection; but we should check if that + // connection hasn't been deleted yet. + auto result = it->second.lock(); + if (!result) return result; } - return it->second; + + connection_ptr connection(new connection_impl( + resolver, follow_redirect_, request_.host(), + lexical_cast(request_.port()), + // resolver function + boost::bind(&pooled_connection_policy::resolve, + this, boost::arg<1>(), boost::arg<2>(), boost::arg<3>()), + // connection factory + boost::bind(&pooled_connection_policy::get_connection, + this, boost::arg<1>(), boost::arg<2>(), always_verify_peer, + boost::arg<3>(), boost::arg<4>(), boost::arg<5>(), + boost::arg<6>(), boost::arg<7>()), + boost::iequals(request_.protocol(), string_type("https")), + always_verify_peer, timeout_, certificate_filename, verify_path, + certificate_file, private_key_file, ciphers, 0)); + host_connections_.insert(std::make_pair(index, connection)); + return connection; } pooled_connection_policy(bool cache_resolved, bool follow_redirect, int timeout) : resolver_base(cache_resolved), - host_connections(), + host_mutex_(), + host_connections_(), follow_redirect_(follow_redirect), timeout_(timeout) {} }; diff --git a/boost/network/protocol/http/policies/simple_connection.hpp b/boost/network/protocol/http/policies/simple_connection.hpp index 4e9677ab9..b209e5d1d 100644 --- a/boost/network/protocol/http/policies/simple_connection.hpp +++ b/boost/network/protocol/http/policies/simple_connection.hpp @@ -8,19 +8,18 @@ // 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 namespace boost { namespace network { @@ -42,7 +41,7 @@ struct simple_connection_policy : resolver_policy::type { struct connection_impl { connection_impl( resolver_type& resolver, bool follow_redirect, bool always_verify_peer, - string_type const& hostname, string_type const& port, + string_type /*unused*/const& hostname, string_type const& port, resolver_function_type resolve, bool https, int timeout, optional const& certificate_filename = optional(), @@ -65,7 +64,7 @@ struct simple_connection_policy : resolver_policy::type { ciphers, ssl_options)); } - basic_response send_request(string_type const& method, + basic_response send_request(string_type /*unused*/const& method, basic_request request_, bool get_body, body_callback_function_type callback, body_generator_function_type generator) { @@ -99,10 +98,12 @@ struct simple_connection_policy : resolver_policy::type { } else throw std::runtime_error( "Location header not defined in redirect response."); - } else + } else { break; - } else +} + } else { break; +} } while (true); return response_; } @@ -117,7 +118,7 @@ struct simple_connection_policy : resolver_policy::type { connection_ptr get_connection( resolver_type& resolver, basic_request const& request_, bool always_verify_peer, - optional const& certificate_filename = + optional /*unused*/const& certificate_filename = optional(), optional const& verify_path = optional(), optional const& certificate_file = optional(), diff --git a/boost/network/protocol/http/policies/sync_resolver.hpp b/boost/network/protocol/http/policies/sync_resolver.hpp index 9f93b9852..8aa64d8f3 100644 --- a/boost/network/protocol/http/policies/sync_resolver.hpp +++ b/boost/network/protocol/http/policies/sync_resolver.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 namespace boost { @@ -35,10 +35,10 @@ struct sync_resolver { resolved_cache endpoint_cache_; bool cache_resolved_; - sync_resolver(bool cache_resolved) : cache_resolved_(cache_resolved) {} + explicit sync_resolver(bool cache_resolved) : cache_resolved_(cache_resolved) {} resolver_iterator_pair resolve(resolver_type& resolver_, - string_type const& hostname, + string_type /*unused*/const& hostname, string_type const& port) { if (cache_resolved_) { typename resolved_cache::iterator cached_iterator = diff --git a/boost/network/protocol/http/request.hpp b/boost/network/protocol/http/request.hpp index 8c6881186..7327bb825 100644 --- a/boost/network/protocol/http/request.hpp +++ b/boost/network/protocol/http/request.hpp @@ -9,39 +9,39 @@ // Implement the HTTP Request Object -#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 #include #include +#include +#include +#include #include #include -#include #include +#include #include #include diff --git a/boost/network/protocol/http/request_concept.hpp b/boost/network/protocol/http/request_concept.hpp index 4d843cbb8..09094d86d 100644 --- a/boost/network/protocol/http/request_concept.hpp +++ b/boost/network/protocol/http/request_concept.hpp @@ -8,9 +8,9 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include #include #include +#include #include namespace boost { diff --git a/boost/network/protocol/http/response.hpp b/boost/network/protocol/http/response.hpp index dea1f46e8..fa7a2eefe 100644 --- a/boost/network/protocol/http/response.hpp +++ b/boost/network/protocol/http/response.hpp @@ -25,8 +25,8 @@ #include #include -#include #include +#include #include #include #include diff --git a/boost/network/protocol/http/response_concept.hpp b/boost/network/protocol/http/response_concept.hpp index 631282961..d262b97be 100644 --- a/boost/network/protocol/http/response_concept.hpp +++ b/boost/network/protocol/http/response_concept.hpp @@ -9,8 +9,8 @@ #include #include -#include #include +#include #include #include diff --git a/boost/network/protocol/http/server/async_connection.hpp b/boost/network/protocol/http/server/async_connection.hpp index e8f566d22..835d6f5d9 100644 --- a/boost/network/protocol/http/server/async_connection.hpp +++ b/boost/network/protocol/http/server/async_connection.hpp @@ -559,7 +559,7 @@ struct async_connection headers_buffer.consume(headers_buffer.size()); headers_already_sent = true; thread_pool().post(callback); - pending_actions_list::iterator start = pending_actions.begin(), + auto start = pending_actions.begin(), end = pending_actions.end(); while (start != end) { thread_pool().post(*start++); diff --git a/boost/network/protocol/http/server/async_server.hpp b/boost/network/protocol/http/server/async_server.hpp index b3cdde502..ce3f16340 100644 --- a/boost/network/protocol/http/server/async_server.hpp +++ b/boost/network/protocol/http/server/async_server.hpp @@ -132,8 +132,8 @@ struct async_server_base : server_storage_base, socket_options_base { void start_listening() { using boost::asio::ip::tcp; system::error_code error; - service_.reset(); // this allows repeated cycles of run -> stop -> - // run + // this allows repeated cycles of run -> stop -> run + service_.reset(); tcp::resolver resolver(service_); tcp::resolver::query query(address_, port_); tcp::resolver::iterator endpoint_iterator = resolver.resolve(query, error); diff --git a/boost/network/protocol/http/server/sync_connection.hpp b/boost/network/protocol/http/server/sync_connection.hpp index bfe749699..8b97ed2f1 100644 --- a/boost/network/protocol/http/server/sync_connection.hpp +++ b/boost/network/protocol/http/server/sync_connection.hpp @@ -84,7 +84,7 @@ struct sync_connection if (done) { if (request_.method[0] == 'P') { // look for the content-length header - typename std::vector::type>::iterator + auto it = std::find_if(request_.headers.begin(), request_.headers.end(), is_content_length()); if (it == request_.headers.end()) { diff --git a/boost/network/protocol/http/support/client_or_server.hpp b/boost/network/protocol/http/support/client_or_server.hpp index 434d6f35b..1e23aa0a1 100644 --- a/boost/network/protocol/http/support/client_or_server.hpp +++ b/boost/network/protocol/http/support/client_or_server.hpp @@ -8,7 +8,7 @@ #include #include -#include +#include namespace boost { namespace network { @@ -32,10 +32,13 @@ struct client_or_server >::type> { typedef tags::client type; }; -} /* http */ +} // namespace http + /* http */ -} /* network */ +} // namespace network + /* network */ -} /* boost */ +} // namespace boost + /* boost */ #endif /* BOOST_NETWORK_PROTOCOL_HTTP_SUPPORT_CLIENT_OR_SERVER_HPP_20101127 */ diff --git a/boost/network/protocol/http/support/is_client.hpp b/boost/network/protocol/http/support/is_client.hpp index c4201c1c9..c4447fbd4 100644 --- a/boost/network/protocol/http/support/is_client.hpp +++ b/boost/network/protocol/http/support/is_client.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 namespace boost { namespace network { @@ -20,10 +20,13 @@ template struct is_client< Tag, typename enable_if::type> : mpl::true_ {}; -} /* http */ +} // namespace http + /* http */ -} /* network */ +} // namespace network + /* network */ -} /* boost */ +} // namespace boost + /* boost */ #endif /* BOOST_NETWORK_PROTOCOL_SUPPORT_IS_CLIENT_HPP_20101118 */ diff --git a/boost/network/protocol/http/support/is_keepalive.hpp b/boost/network/protocol/http/support/is_keepalive.hpp index a063167f3..994e5e822 100644 --- a/boost/network/protocol/http/support/is_keepalive.hpp +++ b/boost/network/protocol/http/support/is_keepalive.hpp @@ -23,10 +23,13 @@ template struct is_keepalive< Tag, typename enable_if::type> : mpl::true_ {}; -} /* http */ +} // namespace http + /* http */ -} /* network */ +} // namespace network + /* network */ -} /* boost */ +} // namespace boost + /* boost */ #endif /* BOOST_NETWORK_SUPPORT_IS_KEEPALIVE_HPP_20100927 */ diff --git a/boost/network/protocol/http/support/is_server.hpp b/boost/network/protocol/http/support/is_server.hpp index 365ad6e30..11b845df1 100644 --- a/boost/network/protocol/http/support/is_server.hpp +++ b/boost/network/protocol/http/support/is_server.hpp @@ -20,10 +20,13 @@ template struct is_server< Tag, typename enable_if::type> : mpl::true_ {}; -} /* http */ +} // namespace http + /* http */ -} /* network */ +} // namespace network + /* network */ -} /* boost */ +} // namespace boost + /* boost */ #endif /* BOOST_NETWORK_PROTOCOL_SUPPORT_IS_SERVER_HPP_20101118 */ diff --git a/boost/network/protocol/http/support/is_simple.hpp b/boost/network/protocol/http/support/is_simple.hpp index c329df8fb..d7e7fee5d 100644 --- a/boost/network/protocol/http/support/is_simple.hpp +++ b/boost/network/protocol/http/support/is_simple.hpp @@ -20,10 +20,13 @@ template struct is_simple< Tag, typename enable_if::type> : mpl::true_ {}; -} /* http */ +} // namespace http + /* http */ -} /* network */ +} // namespace network + /* network */ -} /* boost */ +} // namespace boost + /* boost */ #endif /* BOOST_NETWORK_SUPPORT_IS_SIMPLE_HPP_20100927 */ diff --git a/boost/network/protocol/http/support/sync_only.hpp b/boost/network/protocol/http/support/sync_only.hpp index 6a3eb3fe8..c762cf2f1 100644 --- a/boost/network/protocol/http/support/sync_only.hpp +++ b/boost/network/protocol/http/support/sync_only.hpp @@ -6,8 +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 namespace boost { namespace network { @@ -16,15 +20,19 @@ namespace http { template struct sync_only : mpl::inherit_linearly< - typename mpl::replace_if::type, - is_same, - tags::sync>::type, + typename mpl::replace_if< + typename tags::components::type, + is_same, + boost::network::tags::sync>::type, mpl::inherit > {}; -} /* http */ +} // namespace http + /* http */ -} /* network */ +} // namespace network + /* network */ -} /* boost */ +} // namespace boost + /* boost */ #endif /* BOOST_NETWORK_PROTOCOL_HTTP_SUPPORT_SYNC_ONLY_HPP_20100927 */ diff --git a/boost/network/protocol/http/tags.hpp b/boost/network/protocol/http/tags.hpp index bdf8b4439..2517f262c 100644 --- a/boost/network/protocol/http/tags.hpp +++ b/boost/network/protocol/http/tags.hpp @@ -6,6 +6,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#include +#include #include namespace boost { @@ -29,27 +31,37 @@ 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 +typedef mpl::vector< + http, client, simple, boost::network::tags::sync, boost::network::tags::tcp, + boost::network::tags::default_string> http_default_8bit_tcp_resolve_tags; +typedef mpl::vector< + http, client, simple, boost::network::tags::sync, boost::network::tags::udp, + boost::network::tags::default_string> http_default_8bit_udp_resolve_tags; +typedef mpl::vector http_keepalive_8bit_tcp_resolve_tags; -typedef mpl::vector +typedef mpl::vector http_keepalive_8bit_udp_resolve_tags; -typedef mpl::vector +typedef mpl::vector http_async_8bit_udp_resolve_tags; -typedef mpl::vector +typedef mpl::vector http_async_8bit_tcp_resolve_tags; -typedef mpl::vector - http_server_tags; -typedef mpl::vector - http_async_server_tags; +typedef mpl::vector< + http, simple, boost::network::tags::sync, boost::network::tags::pod, + boost::network::tags::default_string, server> http_server_tags; +typedef mpl::vector< + http, simple, boost::network::tags::async, boost::network::tags::pod, + boost::network::tags::default_string, server> http_async_server_tags; BOOST_NETWORK_DEFINE_TAG(http_default_8bit_tcp_resolve); BOOST_NETWORK_DEFINE_TAG(http_default_8bit_udp_resolve); @@ -60,12 +72,9 @@ 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 */ +} // namespace tags +} // namespace http +} // namespace network +} // namespace boost -#endif /* BOOST_NETWORK_PROTOCOL_HTTP_TAGS_HPP_20101019 */ +#endif // BOOST_NETWORK_PROTOCOL_HTTP_TAGS_HPP_20101019 diff --git a/boost/network/protocol/http/traits/connection_keepalive.hpp b/boost/network/protocol/http/traits/connection_keepalive.hpp index 0069b3a36..891367f00 100644 --- a/boost/network/protocol/http/traits/connection_keepalive.hpp +++ b/boost/network/protocol/http/traits/connection_keepalive.hpp @@ -6,8 +6,8 @@ #ifndef BOOST_NETWORK_PROTOCOL_HTTP_TRAITS_CONECTION_KEEPALIVE_20091218 #define BOOST_NETWORK_PROTOCOL_HTTP_TRAITS_CONECTION_KEEPALIVE_20091218 -#include #include +#include namespace boost { namespace network { @@ -16,10 +16,13 @@ namespace http { template struct connection_keepalive : is_keepalive {}; -} /* http */ +} // namespace http + /* http */ -} /* network */ +} // namespace network + /* network */ -} /* boost */ +} // namespace boost + /* 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 index 4ee96eee3..f4b9173c9 100644 --- a/boost/network/protocol/http/traits/connection_policy.hpp +++ b/boost/network/protocol/http/traits/connection_policy.hpp @@ -7,15 +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 -#include -#include #include #include +#include +#include namespace boost { namespace network { diff --git a/boost/network/protocol/http/traits/delegate_factory.hpp b/boost/network/protocol/http/traits/delegate_factory.hpp index cec92c266..2eece8d15 100644 --- a/boost/network/protocol/http/traits/delegate_factory.hpp +++ b/boost/network/protocol/http/traits/delegate_factory.hpp @@ -18,7 +18,8 @@ namespace impl { template struct connection_delegate_factory; -} /* impl */ +} // namespace impl + /* impl */ template struct unsupported_tag; @@ -33,8 +34,11 @@ struct delegate_factory >::type> { typedef impl::connection_delegate_factory type; }; -} /* http */ -} /* network */ -} /* boost */ +} // namespace http + /* http */ +} // namespace network + /* network */ +} // namespace boost + /* 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 index c7ac9c885..f528c6bbf 100644 --- a/boost/network/protocol/http/traits/impl/chunk_cache.ipp +++ b/boost/network/protocol/http/traits/impl/chunk_cache.ipp @@ -19,7 +19,7 @@ namespace http { template struct chunk_cache { - // TODO define the allocator using an allocator_traits? + // TODO(dberris): define the allocator using an allocator_traits? typedef std::list::type> > type; }; diff --git a/boost/network/protocol/http/traits/impl/headers_container.ipp b/boost/network/protocol/http/traits/impl/headers_container.ipp index d06585ef8..8e5bfc80d 100644 --- a/boost/network/protocol/http/traits/impl/headers_container.ipp +++ b/boost/network/protocol/http/traits/impl/headers_container.ipp @@ -8,10 +8,10 @@ #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 +#include +#include #include #include @@ -26,7 +26,7 @@ namespace impl { // returns true if str1 < str2 (ignoring case) struct is_less_ignore_case_impl { inline bool operator()( - string::type const& str1, + string::type /*unused*/const& str1, string::type const& str2) const { return to_lower_copy(str1) < to_lower_copy(str2); diff --git a/boost/network/protocol/http/traits/impl/response_code.ipp b/boost/network/protocol/http/traits/impl/response_code.ipp index db32bcf94..8317b7ad0 100644 --- a/boost/network/protocol/http/traits/impl/response_code.ipp +++ b/boost/network/protocol/http/traits/impl/response_code.ipp @@ -7,8 +7,8 @@ #ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_RESPONSE_CODE_IPP #define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_RESPONSE_CODE_IPP -#include #include +#include namespace boost { namespace network { diff --git a/boost/network/protocol/http/traits/resolver.hpp b/boost/network/protocol/http/traits/resolver.hpp index 45048fd8f..8077d6b12 100644 --- a/boost/network/protocol/http/traits/resolver.hpp +++ b/boost/network/protocol/http/traits/resolver.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 diff --git a/boost/network/protocol/http/traits/resolver_policy.hpp b/boost/network/protocol/http/traits/resolver_policy.hpp index 5c279dd3f..3c4ea0fe8 100644 --- a/boost/network/protocol/http/traits/resolver_policy.hpp +++ b/boost/network/protocol/http/traits/resolver_policy.hpp @@ -6,13 +6,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 { diff --git a/boost/network/protocol/http/traits/vector.hpp b/boost/network/protocol/http/traits/vector.hpp deleted file mode 100644 index bc343de73..000000000 --- a/boost/network/protocol/http/traits/vector.hpp +++ /dev/null @@ -1,37 +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/protocol/stream_handler.hpp b/boost/network/protocol/stream_handler.hpp index 615d85485..8237c2996 100644 --- a/boost/network/protocol/stream_handler.hpp +++ b/boost/network/protocol/stream_handler.hpp @@ -10,22 +10,23 @@ #pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) -#include -#include -#include #include -#ifdef BOOST_NETWORK_ENABLE_HTTPS -#include -#endif -#include +#include +#include +#include +#include #include #include +#include +#include +#include #include -#include #include -#include -#include -#include +#include + +#ifdef BOOST_NETWORK_ENABLE_HTTPS +#include +#endif namespace boost { namespace network { @@ -43,12 +44,12 @@ typedef boost::asio::ssl::context ssl_context; struct stream_handler { public: stream_handler(boost::shared_ptr socket) - : tcp_sock_(socket), ssl_enabled(false) {} + : tcp_sock_(std::move(socket)), ssl_enabled(false) {} - ~stream_handler() {} + ~stream_handler() = default; stream_handler(boost::shared_ptr socket) - : ssl_sock_(socket), ssl_enabled(true) {} + : ssl_sock_(std::move(socket)), ssl_enabled(true) {} stream_handler(boost::asio::io_service& io, boost::shared_ptr ctx = diff --git a/boost/network/support/is_async.hpp b/boost/network/support/is_async.hpp index 74fbab3b2..316af5533 100644 --- a/boost/network/support/is_async.hpp +++ b/boost/network/support/is_async.hpp @@ -7,8 +7,9 @@ // (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 { @@ -21,7 +22,6 @@ struct is_async< Tag, typename enable_if::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 index 78e2a16fe..5c9c42ef2 100644 --- a/boost/network/support/is_default_string.hpp +++ b/boost/network/support/is_default_string.hpp @@ -21,7 +21,6 @@ struct is_default_string< typename enable_if::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 index 02f4db871..d6d0ee8d4 100644 --- a/boost/network/support/is_default_wstring.hpp +++ b/boost/network/support/is_default_wstring.hpp @@ -7,7 +7,6 @@ #define BOOST_NETWORK_SUPPORT_WSTRING_CHECK_20100808 #include -#include namespace boost { namespace network { @@ -21,7 +20,6 @@ struct is_default_wstring< typename enable_if::type> : mpl::true_ {}; } // namespace network - } // namespace boost -#endif // BOOST_NETWORK_SUPPORT_STRING_CHECK_20100808 +#endif // BOOST_NETWORK_SUPPORT_WSTRING_CHECK_20100808 diff --git a/boost/network/support/is_pod.hpp b/boost/network/support/is_pod.hpp index 1778f112b..a2f63f70a 100644 --- a/boost/network/support/is_pod.hpp +++ b/boost/network/support/is_pod.hpp @@ -19,8 +19,12 @@ template struct is_pod::type> : mpl::true_ {}; -} /* network */ +} // namespace network + // namespace network + /* network */ -} /* boost */ +} // namespace boost + // namespace boost + /* boost */ #endif /* BOOST_NETWORK_SUPPORT_IS_POD_HPP_20101120 */ diff --git a/boost/network/support/is_tcp.hpp b/boost/network/support/is_tcp.hpp index 3bbc672e7..7244c87b1 100644 --- a/boost/network/support/is_tcp.hpp +++ b/boost/network/support/is_tcp.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 namespace boost { namespace network { diff --git a/boost/network/support/is_udp.hpp b/boost/network/support/is_udp.hpp index 555b9bf8f..78bdc8afe 100644 --- a/boost/network/support/is_udp.hpp +++ b/boost/network/support/is_udp.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 namespace boost { namespace network { diff --git a/boost/network/support/pod_or_normal.hpp b/boost/network/support/pod_or_normal.hpp index 2d54bbd01..3be2833a3 100644 --- a/boost/network/support/pod_or_normal.hpp +++ b/boost/network/support/pod_or_normal.hpp @@ -8,7 +8,7 @@ #include #include -#include +#include namespace boost { namespace network { @@ -22,8 +22,7 @@ template struct pod_or_normal< Tag, typename enable_if::type> : tags::pod {}; -} /* network */ - -} /* boost */ +} // namespace network +} // namespace 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 index 719737e4e..e68f9ba2b 100644 --- a/boost/network/support/sync_only.hpp +++ b/boost/network/support/sync_only.hpp @@ -7,10 +7,10 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include #include -#include #include +#include +#include namespace boost { namespace network { @@ -23,8 +23,10 @@ struct sync_only tags::sync>::type, mpl::inherit > {}; -} /* network */ +} // namespace network + /* network */ -} /* boost */ +} // namespace boost + /* boost */ #endif /* BOOST_NETWORK_SUPPORT_SYNC_ONLY_HPP_20100927 */ diff --git a/boost/network/traits/headers_container.hpp b/boost/network/traits/headers_container.hpp index 46f633272..3a0e7c231 100644 --- a/boost/network/traits/headers_container.hpp +++ b/boost/network/traits/headers_container.hpp @@ -8,9 +8,9 @@ #ifndef BOOST_NETWORK_TRAITS_HEADERS_CONTAINER_INC #define BOOST_NETWORK_TRAITS_HEADERS_CONTAINER_INC -#include #include #include +#include namespace boost { namespace network { diff --git a/boost/network/traits/istream.hpp b/boost/network/traits/istream.hpp index 4a8a0a861..a4320ddf2 100644 --- a/boost/network/traits/istream.hpp +++ b/boost/network/traits/istream.hpp @@ -33,8 +33,10 @@ struct istream >::type> { typedef std::wistream type; }; -} /* network */ +} // namespace network + /* network */ -} /* boost */ +} // namespace boost + /* boost */ #endif /* BOOST_NETWORK_TRAITS_ISTREAM_HPP_20100924 */ diff --git a/boost/network/traits/istringstream.hpp b/boost/network/traits/istringstream.hpp index 0f5273a30..efb0d501b 100644 --- a/boost/network/traits/istringstream.hpp +++ b/boost/network/traits/istringstream.hpp @@ -7,10 +7,10 @@ #ifndef BOOST_NETWORK_TRAITS_ISTRINGSTREAM_INC #define BOOST_NETWORK_TRAITS_ISTRINGSTREAM_INC -#include -#include #include #include +#include +#include namespace boost { namespace network { diff --git a/boost/network/traits/ostream_iterator.hpp b/boost/network/traits/ostream_iterator.hpp index 9099247d1..b767394aa 100644 --- a/boost/network/traits/ostream_iterator.hpp +++ b/boost/network/traits/ostream_iterator.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 namespace boost { diff --git a/boost/network/traits/ostringstream.hpp b/boost/network/traits/ostringstream.hpp index f6925b2a1..b4a0c10b9 100644 --- a/boost/network/traits/ostringstream.hpp +++ b/boost/network/traits/ostringstream.hpp @@ -7,11 +7,10 @@ #ifndef BOOST_NETWORK_TRAITS_OSTRINGSTREAM_INC #define BOOST_NETWORK_TRAITS_OSTRINGSTREAM_INC -#include -#include #include #include #include +#include namespace boost { namespace network { @@ -35,7 +34,6 @@ struct ostringstream >::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 index 6d9a1a039..178ffb9bb 100644 --- a/boost/network/traits/string.hpp +++ b/boost/network/traits/string.hpp @@ -7,10 +7,9 @@ #ifndef BOOST_NETWORK_TRAITS_STRING_INC #define BOOST_NETWORK_TRAITS_STRING_INC -#include -#include #include #include +#include #ifndef BOOST_NETWORK_DEFAULT_STRING #define BOOST_NETWORK_DEFAULT_STRING std::string @@ -42,7 +41,6 @@ struct string >::type> { }; } // namespace network - } // namespace boost #endif // BOOST_NETWORK_TRAITS_STRING_INC diff --git a/boost/network/uri/accessors.hpp b/boost/network/uri/accessors.hpp index 5248b34d6..b7c766c3c 100644 --- a/boost/network/uri/accessors.hpp +++ b/boost/network/uri/accessors.hpp @@ -3,11 +3,11 @@ // (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 BOOST_NETWORK_URI_URI_ACCESSORS_INC__ +#define BOOST_NETWORK_URI_URI_ACCESSORS_INC__ -#include #include +#include #include #include #include @@ -28,7 +28,7 @@ struct key_value_sequence : spirit::qi::grammar { 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; @@ -92,4 +92,4 @@ inline uri::string_type decoded_fragment(const uri &uri_) { } // namespace network } // namespace boost -#endif // __BOOST_NETWORK_URI_URI_ACCESSORS_INC__ +#endif // BOOST_NETWORK_URI_URI_ACCESSORS_INC__ diff --git a/boost/network/uri/builder.hpp b/boost/network/uri/builder.hpp index 878a3c56b..c6ec56a52 100644 --- a/boost/network/uri/builder.hpp +++ b/boost/network/uri/builder.hpp @@ -6,8 +6,8 @@ #ifndef __BOOST_NETWORK_URI_BUILDER_INC__ #define __BOOST_NETWORK_URI_BUILDER_INC__ -#include #include +#include namespace boost { namespace network { @@ -17,7 +17,7 @@ class builder { typedef uri::string_type string_type; public: - builder(uri &uri_) : uri_(uri_) {} + explicit builder(uri &uri_) : uri_(uri_) {} builder &set_scheme(const string_type &scheme) { uri_.uri_.append(scheme); diff --git a/boost/network/uri/decode.hpp b/boost/network/uri/decode.hpp index 7503d5665..909e7d7d9 100644 --- a/boost/network/uri/decode.hpp +++ b/boost/network/uri/decode.hpp @@ -11,6 +11,7 @@ #include #include #include +#include namespace boost { namespace network { @@ -59,9 +60,9 @@ OutputIterator decode(const InputIterator &in_begin, OutputIterator out = out_begin; while (it != in_end) { if (*it == '%') { - if (++it == in_end) throw std::out_of_range("unexpected end of stream"); + if (++it == in_end) throw std::out_of_range("unexpected end of stream"); value_type v0 = detail::letter_to_hex(*it); - if (++it == in_end) throw std::out_of_range("unexpected end of stream"); + if (++it == in_end) throw std::out_of_range("unexpected end of stream"); value_type v1 = detail::letter_to_hex(*it); ++it; *out++ = 0x10 * v0 + v1; @@ -86,6 +87,7 @@ inline std::string decoded(const std::string &input) { decode(input, std::back_inserter(decoded)); return decoded; } + } // namespace uri } // namespace network } // namespace boost diff --git a/boost/network/uri/detail/uri_parts.hpp b/boost/network/uri/detail/uri_parts.hpp index 2564f43a0..1252c3f39 100644 --- a/boost/network/uri/detail/uri_parts.hpp +++ b/boost/network/uri/detail/uri_parts.hpp @@ -7,8 +7,8 @@ #ifndef BOOST_NETWORK_URL_DETAIL_URL_PARTS_HPP_ #define BOOST_NETWORK_URL_DETAIL_URL_PARTS_HPP_ -#include #include +#include namespace boost { namespace network { diff --git a/boost/network/uri/directives/authority.hpp b/boost/network/uri/directives/authority.hpp index 2f0bbaefe..3206b3916 100644 --- a/boost/network/uri/directives/authority.hpp +++ b/boost/network/uri/directives/authority.hpp @@ -3,23 +3,26 @@ // (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 BOOST_NETWORK_URI_DIRECTIVES_AUTHORITY_INC__ +#define BOOST_NETWORK_URI_DIRECTIVES_AUTHORITY_INC__ + +#include namespace boost { namespace network { namespace uri { + struct authority_directive { - explicit authority_directive(const std::string &authority) - : authority(authority) {} + explicit authority_directive(std::string authority) + : authority_(std::move(authority)) {} template void operator()(Uri &uri) const { - uri.append(authority); + uri.append(authority_); } - std::string authority; + std::string authority_; }; inline authority_directive authority(const std::string &authority) { @@ -29,4 +32,4 @@ inline authority_directive authority(const std::string &authority) { } // namespace network } // namespace boost -#endif // __BOOST_NETWORK_URI_DIRECTIVES_AUTHORITY_INC__ +#endif // BOOST_NETWORK_URI_DIRECTIVES_AUTHORITY_INC__ diff --git a/boost/network/uri/directives/fragment.hpp b/boost/network/uri/directives/fragment.hpp index 6f3291d95..90b9e0ea4 100644 --- a/boost/network/uri/directives/fragment.hpp +++ b/boost/network/uri/directives/fragment.hpp @@ -3,28 +3,29 @@ // (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__ +#ifndef BOOST_NETWORK_URI_DIRECTIVES_FRAGMENT_INC__ +#define BOOST_NETWORK_URI_DIRECTIVES_FRAGMENT_INC__ #include #include #include +#include namespace boost { namespace network { namespace uri { struct fragment_directive { - explicit fragment_directive(const std::string &fragment) - : fragment(fragment) {} + explicit fragment_directive(std::string fragment) + : fragment_(std::move(fragment)) {} template void operator()(Uri &uri) const { uri.append("#"); - uri.append(fragment); + uri.append(fragment_); } - std::string fragment; + std::string fragment_; }; inline fragment_directive fragment(const std::string &fragment) { @@ -34,4 +35,4 @@ inline fragment_directive fragment(const std::string &fragment) { } // namespace network } // namespace boost -#endif // __BOOST_NETWORK_URI_DIRECTIVES_FRAGMENT_INC__ +#endif // BOOST_NETWORK_URI_DIRECTIVES_FRAGMENT_INC__ diff --git a/boost/network/uri/directives/host.hpp b/boost/network/uri/directives/host.hpp index ac1d2ab5f..0ffead99e 100644 --- a/boost/network/uri/directives/host.hpp +++ b/boost/network/uri/directives/host.hpp @@ -3,25 +3,26 @@ // (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__ +#ifndef BOOST_NETWORK_URI_DIRECTIVES_HOST_INC__ +#define BOOST_NETWORK_URI_DIRECTIVES_HOST_INC__ #include #include +#include namespace boost { namespace network { namespace uri { struct host_directive { - explicit host_directive(const std::string &host) : host(host) {} + explicit host_directive(std::string host) : host_(std::move(host)) {} template void operator()(Uri &uri) const { - uri.append(host); + uri.append(host_); } - std::string host; + std::string host_; }; inline host_directive host(const std::string &host) { @@ -31,4 +32,4 @@ inline host_directive host(const std::string &host) { } // namespace network } // namespace boost -#endif // __BOOST_NETWORK_URI_DIRECTIVES_HOST_INC__ +#endif // BOOST_NETWORK_URI_DIRECTIVES_HOST_INC__ diff --git a/boost/network/uri/directives/path.hpp b/boost/network/uri/directives/path.hpp index 21af8ca2b..336912a17 100644 --- a/boost/network/uri/directives/path.hpp +++ b/boost/network/uri/directives/path.hpp @@ -6,35 +6,37 @@ #ifndef __BOOST_NETWORK_URI_DIRECTIVES_PATH_INC__ #define __BOOST_NETWORK_URI_DIRECTIVES_PATH_INC__ +#include #include #include +#include namespace boost { namespace network { namespace uri { struct path_directive { - explicit path_directive(const std::string &path) : path(path) {} + explicit path_directive(std::string path) : path_(std::move(path)) {} template void operator()(Uri &uri) const { - uri.append(path); + uri.append(path_); } - std::string path; + std::string path_; }; struct encoded_path_directive { - explicit encoded_path_directive(const std::string &path) : path(path) {} + explicit encoded_path_directive(std::string path) : path_(std::move(path)) {} void operator()(uri &uri_) const { std::string encoded_path; - encode(path, std::back_inserter(encoded_path)); + encode(path_, std::back_inserter(encoded_path)); uri_.append(encoded_path); } - std::string path; + std::string path_; }; inline path_directive path(const std::string &path) { @@ -44,6 +46,7 @@ inline path_directive path(const std::string &path) { inline encoded_path_directive encoded_path(const std::string &path) { return encoded_path_directive(path); } + } // namespace uri } // namespace network } // namespace boost diff --git a/boost/network/uri/directives/port.hpp b/boost/network/uri/directives/port.hpp index 181bf6b84..76dca2eed 100644 --- a/boost/network/uri/directives/port.hpp +++ b/boost/network/uri/directives/port.hpp @@ -3,8 +3,8 @@ // (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__ +#ifndef BOOST_NETWORK_URI_DIRECTIVES_PORT_INC__ +#define BOOST_NETWORK_URI_DIRECTIVES_PORT_INC__ #include #include @@ -16,18 +16,18 @@ namespace network { namespace uri { struct port_directive { - explicit port_directive(const std::string &port) : port(port) {} + explicit port_directive(std::string port) : port_(std::move(port)) {} explicit port_directive(boost::uint16_t port) - : port(boost::lexical_cast(port)) {} + : port_(boost::lexical_cast(port)) {} template void operator()(Uri &uri) const { uri.append(":"); - uri.append(port); + uri.append(port_); } - std::string port; + std::string port_; }; inline port_directive port(const std::string &port) { @@ -37,8 +37,9 @@ inline port_directive port(const std::string &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__ +#endif // BOOST_NETWORK_URI_DIRECTIVES_PORT_INC__ diff --git a/boost/network/uri/directives/query.hpp b/boost/network/uri/directives/query.hpp index 07987867e..94309273f 100644 --- a/boost/network/uri/directives/query.hpp +++ b/boost/network/uri/directives/query.hpp @@ -3,27 +3,29 @@ // (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__ +#ifndef BOOST_NETWORK_URI_DIRECTIVES_QUERY_INC__ +#define BOOST_NETWORK_URI_DIRECTIVES_QUERY_INC__ #include #include #include +#include +#include namespace boost { namespace network { namespace uri { struct query_directive { - explicit query_directive(const std::string &query) : query(query) {} + explicit query_directive(std::string query) : query_(std::move(query)) {} template void operator()(Uri &uri) const { uri.append("?"); - uri.append(query); + uri.append(query_); } - std::string query; + std::string query_; }; inline query_directive query(const std::string &query) { @@ -32,8 +34,8 @@ inline query_directive query(const std::string &query) { struct query_key_query_directive { - query_key_query_directive(const std::string &key, const std::string &query) - : key(key), query(query) {} + query_key_query_directive(std::string key, std::string query) + : key_(std::move(key)), query_(std::move(query)) {} template void operator()(Uri &uri) const { @@ -43,13 +45,13 @@ struct query_key_query_directive { } else { uri.append("&"); } - uri.append(key); + uri.append(key_); uri.append("="); - uri.append(query); + uri.append(query_); } - std::string key; - std::string query; + std::string key_; + std::string query_; }; inline query_key_query_directive query(const std::string &key, @@ -60,4 +62,4 @@ inline query_key_query_directive query(const std::string &key, } // namespace network } // namespace boost -#endif // __BOOST_NETWORK_URI_DIRECTIVES_QUERY_INC__ +#endif // BOOST_NETWORK_URI_DIRECTIVES_QUERY_INC__ diff --git a/boost/network/uri/directives/scheme.hpp b/boost/network/uri/directives/scheme.hpp index 7787d3509..8e79d85be 100644 --- a/boost/network/uri/directives/scheme.hpp +++ b/boost/network/uri/directives/scheme.hpp @@ -6,16 +6,17 @@ #ifndef __BOOST_NETWORK_URI_DIRECTIVES_SCHEME_INC__ #define __BOOST_NETWORK_URI_DIRECTIVES_SCHEME_INC__ +#include #include #include -#include +#include namespace boost { namespace network { namespace uri { struct scheme_directive { - explicit scheme_directive(const std::string &scheme) : scheme(scheme) {} + explicit scheme_directive(std::string scheme) : scheme(std::move(scheme)) {} template void operator()(Uri &uri) const { diff --git a/boost/network/uri/directives/user_info.hpp b/boost/network/uri/directives/user_info.hpp index 003469aef..ccc92fd2a 100644 --- a/boost/network/uri/directives/user_info.hpp +++ b/boost/network/uri/directives/user_info.hpp @@ -3,27 +3,28 @@ // (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__ +#ifndef BOOST_NETWORK_URI_DIRECTIVES_USER_INFO_INC__ +#define BOOST_NETWORK_URI_DIRECTIVES_USER_INFO_INC__ #include #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) {} + explicit user_info_directive(std::string user_info) + : user_info_(std::move(user_info)) {} template void operator()(Uri &uri) const { - uri.append(user_info); + uri.append(user_info_); uri.append("@"); } - std::string user_info; + std::string user_info_; }; inline user_info_directive user_info(const std::string &user_info) { @@ -33,4 +34,4 @@ inline user_info_directive user_info(const std::string &user_info) { } // namespace network } // namespace boost -#endif // __BOOST_NETWORK_URI_DIRECTIVES_USER_INFO_INC__ +#endif // BOOST_NETWORK_URI_DIRECTIVES_USER_INFO_INC__ diff --git a/boost/network/uri/encode.hpp b/boost/network/uri/encode.hpp index bf6b07689..baf91841c 100644 --- a/boost/network/uri/encode.hpp +++ b/boost/network/uri/encode.hpp @@ -11,11 +11,13 @@ #include #include #include +#include namespace boost { namespace network { namespace uri { namespace detail { + template inline CharT hex_to_letter(CharT in) { switch (in) { @@ -146,6 +148,7 @@ inline std::string encoded(const std::string &input) { encode(input, std::back_inserter(encoded)); return encoded; } + } // namespace uri } // namespace network } // namespace boost diff --git a/boost/network/uri/uri.hpp b/boost/network/uri/uri.hpp index a40771bfb..2124d8e4f 100644 --- a/boost/network/uri/uri.hpp +++ b/boost/network/uri/uri.hpp @@ -4,17 +4,17 @@ // (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 BOOST_NETWORK_URI_INC__ +#define BOOST_NETWORK_URI_INC__ #pragma once #include #include #include -#include -#include #include +#include +#include #include #include #include @@ -46,7 +46,7 @@ class BOOST_URI_DECL uri { // parse(); //} - uri(const string_type &uri) : uri_(uri), is_valid_(false) { parse(); } + uri(string_type str) : uri_(std::move(str)), is_valid_(false) { parse(); } template uri(const FwdIter &first, const FwdIter &last) @@ -66,7 +66,7 @@ class BOOST_URI_DECL uri { return *this; } - ~uri() {} + ~uri() = default; void swap(uri &other) { boost::swap(uri_, other.uri_); @@ -109,8 +109,9 @@ class BOOST_URI_DECL uri { } // hackfix by Simon Haegler, Esri R&D Zurich -// this workaround is needed to avoid running into the "incompatible string iterator" assertion -// triggered by the default-constructed string iterators employed by cpp-netlib (see uri.ipp qi::rule declarations) +// this workaround is needed to avoid running into the "incompatible string +// iterator" assertion triggered by the default-constructed string iterators +// employed by cpp-netlib (see uri.ipp qi::rule declarations) #if defined(_MSC_VER) && defined(_DEBUG) # define CATCH_EMPTY_ITERATOR_RANGE if (range.begin()._Getcont() == 0 || range.end()._Getcont() == 0) { return string_type(); } #else @@ -120,7 +121,7 @@ class BOOST_URI_DECL uri { string_type scheme() const { const_range_type range = scheme_range(); CATCH_EMPTY_ITERATOR_RANGE - return range ? string_type(boost::begin(range), boost::end(range)) + return range ? string_type(boost::begin(range), boost::end(range)) : string_type(); } @@ -166,6 +167,10 @@ class BOOST_URI_DECL uri { : string_type(); } +#ifdef CATCH_EMPTY_ITERATOR_RANGE +#undef CATCH_EMPTY_ITERATOR_RANGE +#endif + string_type string() const { return uri_; } bool is_valid() const { return is_valid_; } @@ -305,7 +310,10 @@ inline bool operator==(const uri::string_type &lhs, const uri &rhs) { } inline bool operator==(const uri &lhs, const uri::value_type *rhs) { - return boost::equal(lhs, boost::as_literal(rhs)); + auto rlen = std::strlen(rhs); + size_t llen = std::labs(std::distance(lhs.begin(), lhs.end())); + if (rlen != llen) return false; + return boost::equal(lhs, boost::make_iterator_range(rhs, rhs + rlen)); } inline bool operator==(const uri::value_type *lhs, const uri &rhs) { @@ -384,4 +392,4 @@ inline uri from_file(const filesystem::path &path_) { } // namespace network } // namespace boost -#endif // __BOOST_NETWORK_URI_INC__ +#endif // BOOST_NETWORK_URI_INC__ diff --git a/boost/network/utils/thread_pool.hpp b/boost/network/utils/thread_pool.hpp index 3f33cf6f9..e50d19282 100644 --- a/boost/network/utils/thread_pool.hpp +++ b/boost/network/utils/thread_pool.hpp @@ -6,13 +6,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 +#include +#include namespace boost { namespace network { @@ -24,12 +24,19 @@ typedef boost::shared_ptr sentinel_ptr; template struct basic_thread_pool { - basic_thread_pool(std::size_t threads = 1, + basic_thread_pool(basic_thread_pool const &) = delete; + basic_thread_pool &operator=(basic_thread_pool) = delete; + basic_thread_pool(basic_thread_pool&&) noexcept = default; + basic_thread_pool &operator=(basic_thread_pool&&) = default; + + basic_thread_pool() : basic_thread_pool(1) {} + + explicit basic_thread_pool(std::size_t threads, 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), + io_service_(std::move(io_service)), + worker_threads_(std::move(worker_threads)), sentinel_() { bool commit = false; BOOST_SCOPE_EXIT_TPL( @@ -81,10 +88,11 @@ struct basic_thread_pool { } 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_); + using std::swap; + swap(other.threads_, threads_); + swap(other.io_service_, io_service_); + swap(other.worker_threads_, worker_threads_); + swap(other.sentinel_, sentinel_); } protected: @@ -93,18 +101,17 @@ struct basic_thread_pool { 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 */ +template +void swap(basic_thread_pool &a, basic_thread_pool &b) { + a.swap(b); +} -} /* network */ +typedef basic_thread_pool thread_pool; -} /* boost */ +} // namespace utils +} // namespace network +} // namespace boost #endif /* BOOST_NETWORK_UTILS_THREAD_POOL_HPP_20101020 */ diff --git a/boost/network/version.hpp b/boost/network/version.hpp index 14d6770ff..1bf416c15 100644 --- a/boost/network/version.hpp +++ b/boost/network/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 #define BOOST_NETLIB_VERSION_MAJOR 0 #define BOOST_NETLIB_VERSION_MINOR 11 diff --git a/build.sh b/build.sh new file mode 100755 index 000000000..63f05de7e --- /dev/null +++ b/build.sh @@ -0,0 +1,15 @@ +#!/bin/sh +set -e + +mkdir -p build +cd build +cmake -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \ + -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS \ + -DCPP-NETLIB_ENABLE_HTTPS=$ENABLE_HTTPS \ + -DBOOST_INCLUDEDIR="${HOME}/${CC}-boost_${BOOST_VERSION}/include" \ + -DBOOST_LIBRARYDIR="${HOME}/${CC}-boost_${BOOST_VERSION}/lib" \ + -DCMAKE_CXX_FLAGS="-std=c++11 ${CMAKE_CXX_FLAGS}" \ + .. +make -j2 +make test +cd .. diff --git a/install-boost.sh b/install-boost.sh new file mode 100755 index 000000000..25607fb06 --- /dev/null +++ b/install-boost.sh @@ -0,0 +1,13 @@ +#!/bin/sh +set -e + +if [ ! -d "${HOME}/${CC}-boost_${BOOST_VERSION}/include" ]; then + wget -O boost_${BOOST_VERSION}.tar.bz2 http://sourceforge.net/projects/boost/files/boost/${BOOST_VER}/boost_${BOOST_VERSION}.tar.bz2/download + tar jxf boost_${BOOST_VERSION}.tar.bz2 + cd boost_${BOOST_VERSION} + ./bootstrap.sh --with-toolset=$TOOLSET --prefix=${HOME}/${CC}-boost_${BOOST_VERSION} + ./b2 --stagedir=. -j4 --layout=tagged variant=debug,release link=shared threading=multi address-model=64 cxxflags='-std=c++11' install >boost-build.log 2>&1 + cd .. + rm -rf boost_${BOOST_VERSION} + rm -rf boost_${BOOST_VERSION}.tar.bz2 +fi diff --git a/libs/mime/test/mime-roundtrip.cpp b/libs/mime/test/mime-roundtrip.cpp index f5bca8acb..f51641187 100644 --- a/libs/mime/test/mime-roundtrip.cpp +++ b/libs/mime/test/mime-roundtrip.cpp @@ -107,7 +107,7 @@ test_suite *init_unit_test_suite(int, char **) #ifdef BOOST_TEST_DYN_LINK true; #else - 0; + nullptr; #endif } diff --git a/libs/network/example/http/fileserver.cpp b/libs/network/example/http/fileserver.cpp index 9951d6957..557d71b01 100644 --- a/libs/network/example/http/fileserver.cpp +++ b/libs/network/example/http/fileserver.cpp @@ -30,7 +30,7 @@ struct file_cache { meta_map file_headers; boost::shared_mutex cache_mutex; - explicit file_cache(std::string const &doc_root) : doc_root_(doc_root) {} + explicit file_cache(std::string doc_root) : doc_root_(std::move(doc_root)) {} ~file_cache() throw() { BOOST_FOREACH(region_map::value_type const & region, regions) { @@ -85,9 +85,9 @@ struct file_cache { std::string const &path) { boost::shared_lock lock(cache_mutex); static std::vector empty_vector; - meta_map::iterator headers = file_headers.find(doc_root_ + path); + auto headers = file_headers.find(doc_root_ + path); if (headers != file_headers.end()) { - std::vector::iterator begin = headers->second + auto begin = headers->second .begin(), end = headers->second.end(); diff --git a/libs/network/example/http/hello_world_async_server_with_work_queue.cpp b/libs/network/example/http/hello_world_async_server_with_work_queue.cpp index dc3c0224b..3607317f1 100644 --- a/libs/network/example/http/hello_world_async_server_with_work_queue.cpp +++ b/libs/network/example/http/hello_world_async_server_with_work_queue.cpp @@ -35,8 +35,8 @@ struct request_data { typedef boost::shared_ptr pointer; - request_data(server::request const& req, const server::connection_ptr& conn) - : req(req), conn(conn) {} + request_data(server::request req, server::connection_ptr conn) + : req(std::move(req)), conn(std::move(conn)) {} }; /** diff --git a/libs/network/test/http/client_get_test.cpp b/libs/network/test/http/client_get_test.cpp index 3cc596367..dcc24cd04 100644 --- a/libs/network/test/http/client_get_test.cpp +++ b/libs/network/test/http/client_get_test.cpp @@ -3,7 +3,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#define BOOST_TEST_MODULE HTTP 1.0 Get Test +#define BOOST_TEST_MODULE HTTP Get Test #include #include #include "client_types.hpp" @@ -12,42 +12,52 @@ 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"); + typename client::request request("http://cpp-netlib.org/"); client client_; typename 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)); - BOOST_REQUIRE_NO_THROW(BOOST_CHECK(body(response).size() != 0)); + try { + auto data = body(response); + std::cout << data; + } catch (...) { + BOOST_ASSERT(false); + } 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")); + BOOST_CHECK(response.status() == 200u || + (response.status() >= 300 && response.status() < 400)); } #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/"); + typename client::request request("https://www.github.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); + typename client::response response = client_.get(request); + BOOST_CHECK(response.status() == 200 || + (response.status() >= 300 && response.status() < 400)); + try { + auto data = body(response); + std::cout << data; + } catch (...) { + BOOST_ASSERT(false); + } } #endif BOOST_AUTO_TEST_CASE_TEMPLATE(http_temp_client_get_test, client, client_types) { - typename client::request request("http://www.google.co.kr"); + typename client::request request("http://cpp-netlib.org/"); typename client::response response; BOOST_REQUIRE_NO_THROW(response = client().get(request)); - typename net::headers_range::type range = - headers(response)["Content-Type"]; + auto range = headers(response); BOOST_CHECK(!boost::empty(range)); - BOOST_REQUIRE_NO_THROW(BOOST_CHECK(body(response).size() != 0)); + try { + auto data = body(response); + std::cout << data; + } catch (...) { + BOOST_ASSERT(false); + } 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")); + BOOST_CHECK(response.status() == 200u || + (response.status() >= 300 && response.status() < 400)); }