From 7f53b0f66c026afc9cab4ddff5d72f11ab655396 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Wed, 6 Mar 2019 05:46:11 -0800 Subject: [PATCH] detect_ssl returns a bool fix #1288 --- CHANGELOG.md | 1 + include/boost/beast/core/basic_stream.hpp | 2 +- include/boost/beast/core/detect_ssl.hpp | 22 +++++++++------------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba330a89..cc2bbeb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ Version 229: * Rename to buffer_bytes * Tidy up examples +* detect_ssl returns a bool -------------------------------------------------------------------------------- diff --git a/include/boost/beast/core/basic_stream.hpp b/include/boost/beast/core/basic_stream.hpp index 2f06f48e..79aa3244 100644 --- a/include/boost/beast/core/basic_stream.hpp +++ b/include/boost/beast/core/basic_stream.hpp @@ -482,7 +482,7 @@ public: /** Close the timed stream. This cancels all of the outstanding asynchronous operations - as if by calling @ref cancel, and closes the file + as if by calling @ref cancel, and closes the underlying socket. */ void close(); diff --git a/include/boost/beast/core/detect_ssl.hpp b/include/boost/beast/core/detect_ssl.hpp index e78d0713..42db689a 100644 --- a/include/boost/beast/core/detect_ssl.hpp +++ b/include/boost/beast/core/detect_ssl.hpp @@ -203,15 +203,13 @@ is_tls_client_hello (ConstBufferSequence const& buffers) @param ec Set to the error if any occurred. - @return `boost::tribool` indicating whether the buffer contains - a TLS client handshake, does not contain a handshake, or needs - additional octets. If an error occurs, the return value is - undefined. + @return `true` if the buffer contains a TLS client handshake and + no error occurred, otherwise `false`. */ template< class SyncReadStream, class DynamicBuffer> -boost::tribool +bool detect_ssl( SyncReadStream& stream, DynamicBuffer& buffer, @@ -241,7 +239,7 @@ detect_ssl( { // A definite answer is a success ec = {}; - return result; + return static_cast(result); } // Try to fill our buffer by reading from the stream. @@ -304,14 +302,12 @@ detect_ssl( this is a completion handler, the implementation takes ownership of the handler by performing a decay-copy, and the equivalent function signature of the handler must be: - @code void handler( error_code const& error, // Set to the error, if any - boost::tribool result // The result of the detector + bool result // The result of the detector ); @endcode - Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a @@ -328,7 +324,7 @@ async_detect_ssl( CompletionToken&& token) -> typename net::async_result< typename std::decay::type, /*< `async_result` customizes the return value based on the completion token >*/ - void(error_code, boost::tribool)>::return_type; /*< This is the signature for the completion handler >*/ + void(error_code, bool)>::return_type; /*< This is the signature for the completion handler >*/ //] //[example_core_detect_ssl_5 @@ -399,7 +395,7 @@ async_detect_ssl( CompletionToken&& token) -> typename net::async_result< typename std::decay::type, - void(error_code, boost::tribool)>::return_type + void(error_code, bool)>::return_type { // Make sure arguments meet the type requirements @@ -429,7 +425,7 @@ async_detect_ssl( return net::async_initiate< CompletionToken, - void(error_code, boost::tribool)>( + void(error_code, bool)>( detail::run_detect_ssl_op{}, token, &stream, // pass the reference by pointer @@ -630,7 +626,7 @@ operator()(error_code ec, std::size_t bytes_transferred, bool cont) // At this point, we are guaranteed that the original initiating // function is no longer on our stack frame. - this->invoke_now(ec, result_); + this->invoke_now(ec, static_cast(result_)); } }