From 59fabb8123c1216ac090accb1b9f9ee9d258af6c Mon Sep 17 00:00:00 2001 From: NancyLi1013 <46708020+NancyLi1013@users.noreply.github.com> Date: Sat, 14 Mar 2020 16:55:58 +0800 Subject: [PATCH 1/5] Add vcpkg installation instructions (#884) --- README.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.rst b/README.rst index 5d351980b..4a19a91d5 100644 --- a/README.rst +++ b/README.rst @@ -81,6 +81,19 @@ you can now build the tests and run them:: $ make $ make test +You can also download and install cpp-netlib using the ` vcpkg`_ dependency manager: + + $ git clone https://github.com/Microsoft/vcpkg.git + $ cd vcpkg + $ ./bootstrap-vcpkg.sh + $ ./vcpkg integrate install + $ vcpkg install cpp-netlib + +The cpp-netlib port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please create an issue or pull request on the ` vcpkg`_ repository. + +.. _`vcpkg`: https://github.com/Microsoft/vcpkg + + If for some reason some of the tests fail, you can send the files in ``Testing/Temporary/`` as attachments to the cpp-netlib `developers mailing list`_. From 69d2c1146862005fb5ecc1b863fd14c4e49f306b Mon Sep 17 00:00:00 2001 From: jinyuqi Date: Sat, 9 May 2020 00:13:11 +0800 Subject: [PATCH 2/5] Fix build failed for cxxopt submodule updating (#886) Co-authored-by: Jin Yuqi (Ricky) --- libs/network/example/CMakeLists.txt | 1 + libs/network/example/http_client.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libs/network/example/CMakeLists.txt b/libs/network/example/CMakeLists.txt index 0031f3a53..e647a8e69 100644 --- a/libs/network/example/CMakeLists.txt +++ b/libs/network/example/CMakeLists.txt @@ -5,6 +5,7 @@ include_directories(${CPP-NETLIB_SOURCE_DIR}) include_directories(${CPP-NETLIB_SOURCE_DIR}/deps/cxxopts/src) +include_directories(${CPP-NETLIB_SOURCE_DIR}/deps/cxxopts/include) if (OPENSSL_FOUND) include_directories(${OPENSSL_INCLUDE_DIR}) endif (OPENSSL_FOUND) diff --git a/libs/network/example/http_client.cpp b/libs/network/example/http_client.cpp index 439176192..1a717805c 100644 --- a/libs/network/example/http_client.cpp +++ b/libs/network/example/http_client.cpp @@ -29,22 +29,22 @@ int main(int argc, char* argv[]) { ; options.parse_positional(std::vector{"source"}); - options.parse(argc, argv); + auto optionsResults = options.parse(argc, argv); - if (options.count("help")) { + if (optionsResults.count("help")) { std::cout << options.help({"", "Group"}) << std::endl; return EXIT_SUCCESS; } - if (options.count("source") < 1) { + if (optionsResults.count("source") < 1) { std::cout << "Error: Source URL required." << std::endl; std::cout << options.help({"", "Group"}) << std::endl; return EXIT_FAILURE; } - std::string source = options["source"].as(); - bool show_headers = options.count("headers") ? true : false; - bool show_status = options.count("status") ? true : false; + std::string source = optionsResults["source"].as(); + bool show_headers = optionsResults.count("headers") ? true : false; + bool show_status = optionsResults.count("status") ? true : false; http::client::request request(source); http::client::string_type destination_ = host(request); From 96a087a1a68d276d9ffa8fc474e78f691ab73bf9 Mon Sep 17 00:00:00 2001 From: gns333 Date: Wed, 27 Jan 2021 19:01:20 +0800 Subject: [PATCH 3/5] Add clear_resolved_cache implementation (#893) --- .../network/protocol/http/policies/async_resolver.hpp | 10 ++++++++-- boost/network/protocol/http/policies/sync_resolver.hpp | 9 ++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/boost/network/protocol/http/policies/async_resolver.hpp b/boost/network/protocol/http/policies/async_resolver.hpp index c03cd5a36..4e508364a 100644 --- a/boost/network/protocol/http/policies/async_resolver.hpp +++ b/boost/network/protocol/http/policies/async_resolver.hpp @@ -36,18 +36,21 @@ struct async_resolver : std::enable_shared_from_this > { typedef std::function resolve_function; + void clear_resolved_cache() { clear_cache_.store(true); } + protected: bool cache_resolved_; + std::atomic clear_cache_; endpoint_cache endpoint_cache_; std::shared_ptr service_; std::shared_ptr resolver_strand_; explicit async_resolver(bool cache_resolved) - : cache_resolved_(cache_resolved), endpoint_cache_() {} + : cache_resolved_(cache_resolved), clear_cache_(false), endpoint_cache_() {} void resolve(resolver_type &resolver_, string_type const &host, std::uint16_t port, resolve_completion_function once_resolved) { - if (cache_resolved_) { + if (cache_resolved_ && !clear_cache_.load()) { typename endpoint_cache::iterator iter = endpoint_cache_.find(boost::to_lower_copy(host)); if (iter != endpoint_cache_.end()) { @@ -74,6 +77,9 @@ struct async_resolver : std::enable_shared_from_this > { typename endpoint_cache::iterator iter; bool inserted = false; if (!ec && cache_resolved_) { + if (clear_cache_.exchange(false)) { + endpoint_cache_.clear(); + } std::tie(iter, inserted) = endpoint_cache_.insert(std::make_pair( host, std::make_pair(endpoint_iterator, resolver_iterator()))); once_resolved(ec, iter->second); diff --git a/boost/network/protocol/http/policies/sync_resolver.hpp b/boost/network/protocol/http/policies/sync_resolver.hpp index 7c9c2c7f4..09d373b87 100644 --- a/boost/network/protocol/http/policies/sync_resolver.hpp +++ b/boost/network/protocol/http/policies/sync_resolver.hpp @@ -27,19 +27,26 @@ struct sync_resolver { typedef std::pair resolver_iterator_pair; + void clear_resolved_cache() { clear_cache_.store(true); } + protected: typedef typename string::type string_type; typedef std::unordered_map resolved_cache; resolved_cache endpoint_cache_; bool cache_resolved_; + std::atomic clear_cache_; - explicit sync_resolver(bool cache_resolved) : cache_resolved_(cache_resolved) {} + explicit sync_resolver(bool cache_resolved) + : cache_resolved_(cache_resolved), clear_cache_(false) {} resolver_iterator_pair resolve(resolver_type& resolver_, string_type /*unused*/const& hostname, string_type const& port) { if (cache_resolved_) { + if (clear_cache_.exchange(false)) { + endpoint_cache_.clear(); + } typename resolved_cache::iterator cached_iterator = endpoint_cache_.find(hostname); if (cached_iterator == endpoint_cache_.end()) { From d42fb59a64a60f8495179b71d88bf32e93448133 Mon Sep 17 00:00:00 2001 From: Randy Li Date: Fri, 1 Sep 2023 12:04:59 +0800 Subject: [PATCH 4/5] Fixup asio old service removed after boost 1.69 (#901) BOOST_ASIO_ENABLE_OLD_SERVICES option and all those header files are removed from boost asio 1.70. Signed-off-by: Hsia-Jun(Randy) Li Co-authored-by: Hsia-Jun(Randy) Li --- boost/network/protocol/stream_handler.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boost/network/protocol/stream_handler.hpp b/boost/network/protocol/stream_handler.hpp index 62c97ec4a..cd98b6875 100644 --- a/boost/network/protocol/stream_handler.hpp +++ b/boost/network/protocol/stream_handler.hpp @@ -13,12 +13,12 @@ #include #include #include +#include #include #include #include #include #include -#include #include #ifdef BOOST_NETWORK_ENABLE_HTTPS From 552ce94bd91c055f11ba524adf0ca0712063d711 Mon Sep 17 00:00:00 2001 From: jalegido Date: Thu, 7 Sep 2023 14:06:56 +0200 Subject: [PATCH 5/5] Compatibility with boost 1.83 (#902) Co-authored-by: jjll --- libs/network/src/server_request_parsers_impl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/network/src/server_request_parsers_impl.cpp b/libs/network/src/server_request_parsers_impl.cpp index 9a539b1ae..d3670e924 100644 --- a/libs/network/src/server_request_parsers_impl.cpp +++ b/libs/network/src/server_request_parsers_impl.cpp @@ -12,6 +12,7 @@ #include #include #include +#include namespace boost { namespace spirit { @@ -22,7 +23,7 @@ typedef std::basic_string u32_string; template <> // struct assign_to_container_from_value { static void call(u32_string const& val, std::string& attr) { - u32_to_u8_iterator begin = val.begin(), + boost::u32_to_u8_iterator begin = val.begin(), end = val.end(); for (; begin != end; ++begin) attr += *begin; }