From 84f74369a0266d6546a549d78d6d78dfcdaa1102 Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Mon, 8 Oct 2018 18:43:01 -0700 Subject: [PATCH 01/12] Move up bind_impl so that it can be found by non-MSVC. --- Release/include/cpprest/http_headers.h | 62 +++++++++++++------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/Release/include/cpprest/http_headers.h b/Release/include/cpprest/http_headers.h index 077266a7d5..3761940c8b 100644 --- a/Release/include/cpprest/http_headers.h +++ b/Release/include/cpprest/http_headers.h @@ -57,6 +57,37 @@ bool bind(const key_type &text, utility::string_t &ref) //const return true; } +namespace details +{ + template + bool bind_impl(const key_type &text, _t &ref) + { + utility::istringstream_t iss(text); + iss.imbue(std::locale::classic()); + iss >> ref; + if (iss.fail() || !iss.eof()) + { + return false; + } + + return true; + } + + template + bool bind_impl(const key_type &text, utf16string &ref) + { + ref = utility::conversions::to_utf16string(text); + return true; + } + + template + bool bind_impl(const key_type &text, std::string &ref) + { + ref = utility::conversions::to_utf8string(text); + return true; + } +} + /// /// Represents HTTP headers, acts like a map. /// @@ -288,35 +319,4 @@ class http_headers // Headers are stored in a map with case insensitive key. inner_container m_headers; }; - -namespace details -{ - template - bool bind_impl(const key_type &text, _t &ref) - { - utility::istringstream_t iss(text); - iss.imbue(std::locale::classic()); - iss >> ref; - if (iss.fail() || !iss.eof()) - { - return false; - } - - return true; - } - - template - bool bind_impl(const key_type &text, utf16string &ref) - { - ref = utility::conversions::to_utf16string(text); - return true; - } - - template - bool bind_impl(const key_type &text, std::string &ref) - { - ref = utility::conversions::to_utf8string(text); - return true; - } -} }} From ec2826af8349d3e55bdae41213ed43445a955ef7 Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Mon, 8 Oct 2018 18:44:19 -0700 Subject: [PATCH 02/12] Avoid useless qualification making GCC unhappy. --- Release/include/cpprest/http_compression.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Release/include/cpprest/http_compression.h b/Release/include/cpprest/http_compression.h index 13b183af00..2a766d52f2 100644 --- a/Release/include/cpprest/http_compression.h +++ b/Release/include/cpprest/http_compression.h @@ -96,7 +96,7 @@ class decompress_factory { public: virtual const utility::string_t& algorithm() const = 0; - virtual const uint16_t weight() const = 0; + virtual uint16_t weight() const = 0; virtual std::unique_ptr make_decompressor() const = 0; virtual ~decompress_factory() = default; }; From 698025c88532b7c3482e748f7736f4a63c42819a Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Mon, 8 Oct 2018 18:44:39 -0700 Subject: [PATCH 03/12] Make GZIP/DEFLATE/BROTLI constant chars. --- Release/include/cpprest/http_compression.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Release/include/cpprest/http_compression.h b/Release/include/cpprest/http_compression.h index 2a766d52f2..c9e0ce9170 100644 --- a/Release/include/cpprest/http_compression.h +++ b/Release/include/cpprest/http_compression.h @@ -117,9 +117,9 @@ _ASYNCRTIMP bool supported(); /// namespace algorithm { -constexpr utility::char_t *GZIP = _XPLATSTR("gzip"); -constexpr utility::char_t *DEFLATE = _XPLATSTR("deflate"); -constexpr utility::char_t *BROTLI = _XPLATSTR("br"); +constexpr const utility::char_t *GZIP = _XPLATSTR("gzip"); +constexpr const utility::char_t *DEFLATE = _XPLATSTR("deflate"); +constexpr const utility::char_t *BROTLI = _XPLATSTR("br"); /// /// Test whether cpprestsdk was built with built-in compression support and From 68704bd1aa5183409d47c95889a6933551fa9c0a Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Mon, 8 Oct 2018 18:45:25 -0700 Subject: [PATCH 04/12] Remove unneeded ; --- Release/include/cpprest/http_compression.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Release/include/cpprest/http_compression.h b/Release/include/cpprest/http_compression.h index c9e0ce9170..1993e6244c 100644 --- a/Release/include/cpprest/http_compression.h +++ b/Release/include/cpprest/http_compression.h @@ -129,7 +129,7 @@ constexpr const utility::char_t *BROTLI = _XPLATSTR("br"); /// the supplied string matches a supported built-in algorithm, and false if not. /// _ASYNCRTIMP bool supported(const utility::string_t& algorithm); -}; +} /// /// Factory function to instantiate a built-in compression provider with default parameters by compression algorithm From d79b77b7f43c2418bd8533fb80973fd495143e4b Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Mon, 8 Oct 2018 18:46:34 -0700 Subject: [PATCH 05/12] Remove broken qualification attempting to forward declare web::http::compression::decompress_factory. --- Release/src/http/common/internal_http_helpers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Release/src/http/common/internal_http_helpers.h b/Release/src/http/common/internal_http_helpers.h index ef19612270..76b4f4f4da 100644 --- a/Release/src/http/common/internal_http_helpers.h +++ b/Release/src/http/common/internal_http_helpers.h @@ -34,7 +34,7 @@ bool validate_method(const utility::string_t& method); namespace web { namespace http { namespace compression { -class compression::decompress_factory; +class decompress_factory; namespace details { namespace builtin { From 4d1fcde02dc24a08da2f83308c3c73ccdf600c80 Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Mon, 8 Oct 2018 18:48:08 -0700 Subject: [PATCH 06/12] Don't use nonstandard for each. --- Release/src/http/common/http_compression.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Release/src/http/common/http_compression.cpp b/Release/src/http/common/http_compression.cpp index e7e7f9a927..b7dd568aff 100644 --- a/Release/src/http/common/http_compression.cpp +++ b/Release/src/http/common/http_compression.cpp @@ -1084,7 +1084,7 @@ utility::string_t build_supported_header(header_types type, // Add all specified algorithms and their weights to the header start = true; os.imbue(std::locale::classic()); - for each (auto& factory in f) + for (auto& factory : f) { if (factory) { From b7f9a1e379f9e35988368219360ad208ceeb8471 Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Mon, 8 Oct 2018 18:48:36 -0700 Subject: [PATCH 07/12] Remove another unnecessary const. --- Release/src/http/common/http_compression.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Release/src/http/common/http_compression.cpp b/Release/src/http/common/http_compression.cpp index b7dd568aff..2a0f9f30b5 100644 --- a/Release/src/http/common/http_compression.cpp +++ b/Release/src/http/common/http_compression.cpp @@ -620,7 +620,7 @@ class generic_decompress_factory : public decompress_factory const utility::string_t& algorithm() const { return m_algorithm; } - const uint16_t weight() const { return m_weight; } + uint16_t weight() const { return m_weight; } std::unique_ptr make_decompressor() const { return _make_decompressor(); } From f7af4442ffae80f167821c65e68f029b80490a8a Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Mon, 8 Oct 2018 18:50:02 -0700 Subject: [PATCH 08/12] Mark unused parameters with (void). --- Release/src/http/common/http_compression.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Release/src/http/common/http_compression.cpp b/Release/src/http/common/http_compression.cpp index 2a0f9f30b5..7fc229642d 100644 --- a/Release/src/http/common/http_compression.cpp +++ b/Release/src/http/common/http_compression.cpp @@ -753,6 +753,10 @@ std::unique_ptr make_gzip_compressor(int compressionLevel, in #if defined(CPPREST_HTTP_COMPRESSION) return std::move(std::make_unique(compressionLevel, method, strategy, memLevel)); #else // CPPREST_HTTP_COMPRESSION + (void)compressionLevel; + (void)method; + (void)strategy; + (void)memLevel; return std::unique_ptr(); #endif // CPPREST_HTTP_COMPRESSION } @@ -762,6 +766,10 @@ std::unique_ptr make_deflate_compressor(int compressionLevel, #if defined(CPPREST_HTTP_COMPRESSION) return std::move(std::make_unique(compressionLevel, method, strategy, memLevel)); #else // CPPREST_HTTP_COMPRESSION + (void)compressionLevel; + (void)method; + (void)strategy; + (void)memLevel; return std::unique_ptr(); #endif // CPPREST_HTTP_COMPRESSION } @@ -771,6 +779,9 @@ std::unique_ptr make_brotli_compressor(uint32_t window, uint3 #if defined(CPPREST_HTTP_COMPRESSION) && defined(CPPREST_BROTLI_COMPRESSION) return std::move(std::make_unique(window, quality, mode)); #else // CPPREST_BROTLI_COMPRESSION + (void)window; + (void)quality; + (void)mode; return std::unique_ptr(); #endif // CPPREST_BROTLI_COMPRESSION } @@ -800,7 +811,7 @@ const std::vector> get_decompress_factories( } } // namespace builtin -static bool is_http_whitespace(utility::char_t ch) { return ch == _XPLATSTR(' ') || ch == _XPLATSTR('\t'); } +static bool is_http_whitespace(const utility::char_t ch) { return ch == _XPLATSTR(' ') || ch == _XPLATSTR('\t'); } static void remove_surrounding_http_whitespace(const utility::string_t& encoding, size_t& start, size_t& length) { From 5f0f0f27e0f4e55dd27d051a3ee62d63bebbeec3 Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Mon, 8 Oct 2018 18:55:20 -0700 Subject: [PATCH 09/12] Guard -Wno-format-truncation from GCC 5.4. --- Release/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Release/CMakeLists.txt b/Release/CMakeLists.txt index 4a5bdef421..00fa7a7d11 100644 --- a/Release/CMakeLists.txt +++ b/Release/CMakeLists.txt @@ -187,7 +187,11 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR IOS) elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") message("-- Setting gcc options") - set(WARNINGS -Wall -Wextra -Wunused-parameter -Wcast-align -Wcast-qual -Wconversion -Wformat=2 -Winit-self -Winvalid-pch -Wmissing-format-attribute -Wmissing-include-dirs -Wpacked -Wredundant-decls -Wunreachable-code -Wno-format-truncation) + set(WARNINGS -Wall -Wextra -Wunused-parameter -Wcast-align -Wcast-qual -Wconversion -Wformat=2 -Winit-self -Winvalid-pch -Wmissing-format-attribute -Wmissing-include-dirs -Wpacked -Wredundant-decls -Wunreachable-code) + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0") + set(WARNINGS ${WARNINGS} -Wno-format-truncation) + endif() + set(LD_FLAGS "${LD_FLAGS} -Wl,-z,defs") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-strict-aliasing") From 842518247ad3282f67b6f2b457b678c0bc81d7e8 Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Mon, 8 Oct 2018 18:55:49 -0700 Subject: [PATCH 10/12] Fix bogus writtenSize warning from GCC 5.4. --- Release/src/http/client/http_client_asio.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Release/src/http/client/http_client_asio.cpp b/Release/src/http/client/http_client_asio.cpp index 7590497420..72e13f046c 100644 --- a/Release/src/http/client/http_client_asio.cpp +++ b/Release/src/http/client/http_client_asio.cpp @@ -1754,6 +1754,7 @@ class asio_context final : public request_context, public std::enable_shared_fro .then([this_request, read_size, shared_decompressed AND_CAPTURE_MEMBER_FUNCTION_POINTERS]( pplx::task op) { size_t writtenSize = 0; + (void)writtenSize; try { writtenSize = op.get(); From db12ee58020ce083e35874b46a76091b7baa7cbd Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Mon, 8 Oct 2018 19:00:56 -0700 Subject: [PATCH 11/12] Attempt to avoid std::make_unique in compression tests. --- .../http/client/compression_tests.cpp | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/Release/tests/functional/http/client/compression_tests.cpp b/Release/tests/functional/http/client/compression_tests.cpp index e9cc9ef661..242d0ca94a 100644 --- a/Release/tests/functional/http/client/compression_tests.cpp +++ b/Release/tests/functional/http/client/compression_tests.cpp @@ -13,6 +13,8 @@ #include "cpprest/details/http_helpers.h" #include "cpprest/version.h" +#include "cpprest/asyncrt_utils.h" +#include "pplx/pplxinterface.h" #include "stdafx.h" #include @@ -210,8 +212,8 @@ SUITE(compression_tests) if (algorithm == fake_provider::FAKE) { - compressor = std::make_unique(buffer_size); - decompressor = std::make_unique(buffer_size); + compressor = utility::details::make_unique(buffer_size); + decompressor = utility::details::make_unique(buffer_size); } else { @@ -448,28 +450,28 @@ SUITE(compression_tests) std::shared_ptr fcf = web::http::compression::make_compress_factory( fake_provider::FAKE, []() -> std::unique_ptr { - return std::make_unique(); + return utility::details::make_unique(); }); std::vector> fcv; fcv.push_back(fcf); std::shared_ptr fdf = web::http::compression::make_decompress_factory( fake_provider::FAKE, 800, []() -> std::unique_ptr { - return std::make_unique(); + return utility::details::make_unique(); }); std::vector> fdv; fdv.push_back(fdf); std::shared_ptr ncf = web::http::compression::make_compress_factory( _NONE, []() -> std::unique_ptr { - return std::make_unique(); + return utility::details::make_unique(); }); std::vector> ncv; ncv.push_back(ncf); std::shared_ptr ndf = web::http::compression::make_decompress_factory( _NONE, 800, []() -> std::unique_ptr { - return std::make_unique(); + return utility::details::make_unique(); }); std::vector> ndv; ndv.push_back(ndf); @@ -794,7 +796,7 @@ SUITE(compression_tests) { test_http_server* p_server = nullptr; std::unique_ptr scoped = - std::move(std::make_unique(m_uri)); + std::move(utility::details::make_unique(m_uri)); scoped->server()->next_request().then([&skip_transfer_put](pplx::task op) { try { @@ -810,7 +812,7 @@ SUITE(compression_tests) http_client client(m_uri); http_request msg(methods::PUT); - msg.set_compressor(std::make_unique(0)); + msg.set_compressor(utility::details::make_unique(0)); msg.set_body(concurrency::streams::rawptr_stream::open_istream((const uint8_t*)nullptr, 0)); http_response rsp = client.request(msg).get(); rsp.content_ready().wait(); @@ -872,7 +874,7 @@ SUITE(compression_tests) if (encoding.find(fake_provider::FAKE) != utility::string_t::npos) { // This one won't be found in the server's default set... - rsp._get_impl()->set_compressor(std::make_unique(buffer_size)); + rsp._get_impl()->set_compressor(utility::details::make_unique(buffer_size)); } #endif // _WIN32 rsp.set_body( @@ -913,7 +915,7 @@ SUITE(compression_tests) } else { - scoped = std::move(std::make_unique(m_uri)); + scoped = std::move(utility::details::make_unique(m_uri)); p_server = scoped->server(); } @@ -968,12 +970,12 @@ SUITE(compression_tests) fake_provider::FAKE, 1000, [buffer_size]() -> std::unique_ptr { - return std::make_unique(buffer_size); + return utility::details::make_unique(buffer_size); }); dfactories.push_back(dmap[fake_provider::FAKE]); cfactories.push_back(web::http::compression::make_compress_factory( fake_provider::FAKE, [buffer_size]() -> std::unique_ptr { - return std::make_unique(buffer_size); + return utility::details::make_unique(buffer_size); })); v.resize(buffer_size); @@ -1037,7 +1039,7 @@ SUITE(compression_tests) if (algorithm == fake_provider::FAKE) { VERIFY_IS_FALSE((bool)c); - c = std::make_unique(buffer_size); + c = utility::details::make_unique(buffer_size); } VERIFY_IS_TRUE((bool)c); auto got = c->compress(v.data(), @@ -1069,7 +1071,7 @@ SUITE(compression_tests) VERIFY_ARE_EQUAL(boo, algorithm != fake_provider::FAKE); if (algorithm == fake_provider::FAKE) { - msg.set_compressor(std::make_unique(buffer_size)); + msg.set_compressor(utility::details::make_unique(buffer_size)); } } else From 973a1873117d9f27981ca760967963af929419cf Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Mon, 8 Oct 2018 19:05:16 -0700 Subject: [PATCH 12/12] Avoid Concurrency::task_group_status because gcc 5.4 hates it for some reason. --- .../http/client/compression_tests.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Release/tests/functional/http/client/compression_tests.cpp b/Release/tests/functional/http/client/compression_tests.cpp index 242d0ca94a..ca2215afd9 100644 --- a/Release/tests/functional/http/client/compression_tests.cpp +++ b/Release/tests/functional/http/client/compression_tests.cpp @@ -14,7 +14,6 @@ #include "cpprest/details/http_helpers.h" #include "cpprest/version.h" #include "cpprest/asyncrt_utils.h" -#include "pplx/pplxinterface.h" #include "stdafx.h" #include @@ -204,7 +203,7 @@ SUITE(compression_tests) std::vector dcmp_buffer; web::http::compression::operation_result r; std::vector chunk_sizes; - Concurrency::task_group_status result; + pplx::task_status result; size_t csize; size_t dsize; size_t i; @@ -249,7 +248,7 @@ SUITE(compression_tests) web::http::compression::operation_hint::has_more) .then([&r](web::http::compression::operation_result x) { r = x; }) .wait(); - VERIFY_ARE_EQUAL(result, Concurrency::task_group_status::completed); + VERIFY_ARE_EQUAL(result, pplx::task_status::completed); VERIFY_ARE_EQUAL(r.input_bytes_processed, std::min(chunk_size, buffer_size - i)); VERIFY_ARE_EQUAL(r.done, false); chunk_sizes.push_back(r.output_bytes_produced); @@ -274,7 +273,7 @@ SUITE(compression_tests) web::http::compression::operation_hint::is_last) .then([&r](web::http::compression::operation_result x) { r = x; }) .wait(); - VERIFY_ARE_EQUAL(result, Concurrency::task_group_status::completed); + VERIFY_ARE_EQUAL(result, pplx::task_status::completed); VERIFY_ARE_EQUAL(r.input_bytes_processed, 0); chunk_sizes.push_back(r.output_bytes_produced); csize += r.output_bytes_produced; @@ -285,7 +284,7 @@ SUITE(compression_tests) result = compressor->compress(NULL, 0, NULL, 0, web::http::compression::operation_hint::is_last) .then([&r](web::http::compression::operation_result x) { r = x; }) .wait(); - VERIFY_ARE_EQUAL(result, Concurrency::task_group_status::completed); + VERIFY_ARE_EQUAL(result, pplx::task_status::completed); VERIFY_ARE_EQUAL(r.input_bytes_processed, 0); VERIFY_ARE_EQUAL(r.output_bytes_produced, 0); VERIFY_ARE_EQUAL(r.done, true); @@ -313,7 +312,7 @@ SUITE(compression_tests) hint) .then([&r](web::http::compression::operation_result x) { r = x; }) .wait(); - VERIFY_ARE_EQUAL(result, Concurrency::task_group_status::completed); + VERIFY_ARE_EQUAL(result, pplx::task_status::completed); nn += *it; dsize += r.output_bytes_produced; } @@ -341,7 +340,7 @@ SUITE(compression_tests) web::http::compression::operation_hint::has_more) .then([&r](web::http::compression::operation_result x) { r = x; }) .wait(); - VERIFY_ARE_EQUAL(result, Concurrency::task_group_status::completed); + VERIFY_ARE_EQUAL(result, pplx::task_status::completed); dsize += r.output_bytes_produced; nn += r.input_bytes_processed; n -= r.input_bytes_processed; @@ -356,7 +355,7 @@ SUITE(compression_tests) result = decompressor->decompress(NULL, 0, NULL, 0, web::http::compression::operation_hint::has_more) .then([&r](web::http::compression::operation_result x) { r = x; }) .wait(); - VERIFY_ARE_EQUAL(result, Concurrency::task_group_status::completed); + VERIFY_ARE_EQUAL(result, pplx::task_status::completed); VERIFY_ARE_EQUAL(r.input_bytes_processed, 0); VERIFY_ARE_EQUAL(r.output_bytes_produced, 0); VERIFY_IS_TRUE(r.done); @@ -372,7 +371,7 @@ SUITE(compression_tests) web::http::compression::operation_hint::is_last) .then([&r](web::http::compression::operation_result x) { r = x; }) .wait(); - VERIFY_ARE_EQUAL(result, Concurrency::task_group_status::completed); + VERIFY_ARE_EQUAL(result, pplx::task_status::completed); VERIFY_ARE_EQUAL(r.output_bytes_produced, buffer_size); VERIFY_ARE_EQUAL(input_buffer, dcmp_buffer);