From 83691c6e9a253f9b0cd10162f0bdb864443c0137 Mon Sep 17 00:00:00 2001 From: eidheim Date: Sat, 10 Jun 2017 15:03:27 +0200 Subject: [PATCH] Fixes #129: linking issues related to case_insensitive_equal and make_error_code --- client_http.hpp | 4 +++- client_https.hpp | 2 +- server_http.hpp | 10 +++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/client_http.hpp b/client_http.hpp index 7a64840..674c017 100644 --- a/client_http.hpp +++ b/client_http.hpp @@ -16,6 +16,7 @@ namespace SimpleWeb { using error_code = std::error_code; using errc = std::errc; using system_error = std::system_error; + namespace make_error_code = std; } #else #include @@ -27,13 +28,14 @@ namespace SimpleWeb { using error_code = boost::system::error_code; namespace errc = boost::system::errc; using system_error = boost::system::system_error; + namespace make_error_code = boost::system::errc; } #endif # ifndef CASE_INSENSITIVE_EQUAL_AND_HASH # define CASE_INSENSITIVE_EQUAL_AND_HASH namespace SimpleWeb { - bool case_insensitive_equal(const std::string &str1, const std::string &str2) { + inline bool case_insensitive_equal(const std::string &str1, const std::string &str2) { return str1.size() == str2.size() && std::equal(str1.begin(), str1.end(), str2.begin(), [](char a, char b) { return tolower(a) == tolower(b); diff --git a/client_https.hpp b/client_https.hpp index 96053ed..3c6e020 100644 --- a/client_https.hpp +++ b/client_https.hpp @@ -120,7 +120,7 @@ namespace SimpleWeb { if (response->status_code.empty() || response->status_code.compare(0, 3, "200") != 0) { std::lock_guard lock(socket_mutex); socket=nullptr; - throw make_error_code(errc::permission_denied); + throw make_error_code::make_error_code(errc::permission_denied); } } diff --git a/server_http.hpp b/server_http.hpp index ef139c4..45a9a16 100644 --- a/server_http.hpp +++ b/server_http.hpp @@ -14,7 +14,7 @@ namespace SimpleWeb { using error_code = std::error_code; using errc = std::errc; - error_code (&make_error_code)(errc) = std::make_error_code; + namespace make_error_code = std; } #else #include @@ -24,14 +24,14 @@ namespace SimpleWeb { namespace asio = boost::asio; using error_code = boost::system::error_code; namespace errc = boost::system::errc; - error_code (&make_error_code)(boost::system::errc::errc_t) = boost::system::errc::make_error_code; + namespace make_error_code = boost::system::errc; } #endif # ifndef CASE_INSENSITIVE_EQUAL_AND_HASH # define CASE_INSENSITIVE_EQUAL_AND_HASH namespace SimpleWeb { - bool case_insensitive_equal(const std::string &str1, const std::string &str2) { + inline bool case_insensitive_equal(const std::string &str1, const std::string &str2) { return str1.size() == str2.size() && std::equal(str1.begin(), str1.end(), str2.begin(), [](char a, char b) { return tolower(a) == tolower(b); @@ -339,7 +339,7 @@ namespace SimpleWeb { } catch(const std::exception &e) { if(on_error) - on_error(request, make_error_code(errc::protocol_error)); + on_error(request, make_error_code::make_error_code(errc::protocol_error)); return; } if(content_length>num_additional_bytes) { @@ -473,7 +473,7 @@ namespace SimpleWeb { } catch(const std::exception &e) { if(on_error) - on_error(request, make_error_code(errc::operation_canceled)); + on_error(request, make_error_code::make_error_code(errc::operation_canceled)); return; } }