forked from boostorg/beast
Update for Net-TS Asio (API Change):
fix #769 The following classes are removed: * handler_type * async_result * async_completion * is_dynamic_buffer * is_const_buffer_sequence * is_mutable_buffer_sequence * handler_alloc Actions Required: * Use BOOST_ASIO_HANDLER_TYPE instead of handler_type * Use BOOST_ASIO_INITFN_RESULT_TYPE instead of async_result * Use boost::asio::async_completion * Use boost::asio::is_dynamic_buffer * Use boost::asio::is_const_buffer_sequence * Use boost::asio::is_mutable_buffer_sequence * boost::asio::associated_allocator_t replaces handler_alloc
This commit is contained in:
1 parent
9dc9ca13b9
commit
3a28e999af
173 files changed
+3214
-4138
No files matched your search
@@ -12,7 +12,6 @@
|
||||
|
||||
#include <boost/beast/core/detail/config.hpp>
|
||||
|
||||
#include <boost/beast/core/async_result.hpp>
|
||||
#include <boost/beast/core/bind_handler.hpp>
|
||||
#include <boost/beast/core/buffered_read_stream.hpp>
|
||||
#include <boost/beast/core/buffers_adapter.hpp>
|
||||
@@ -28,7 +27,6 @@
|
||||
#include <boost/beast/core/file_win32.hpp>
|
||||
#include <boost/beast/core/flat_buffer.hpp>
|
||||
#include <boost/beast/core/flat_static_buffer.hpp>
|
||||
#include <boost/beast/core/handler_alloc.hpp>
|
||||
#include <boost/beast/core/handler_ptr.hpp>
|
||||
#include <boost/beast/core/multi_buffer.hpp>
|
||||
#include <boost/beast/core/ostream.hpp>
|
||||
|
||||
@@ -1,209 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
// Official repository: https://github.com/boostorg/beast
|
||||
//
|
||||
|
||||
#ifndef BOOST_BEAST_ASYNC_COMPLETION_HPP
|
||||
#define BOOST_BEAST_ASYNC_COMPLETION_HPP
|
||||
|
||||
#include <boost/beast/core/detail/config.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/asio/async_result.hpp>
|
||||
#include <boost/asio/handler_type.hpp>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
/** An interface for customising the behaviour of an asynchronous initiation function.
|
||||
|
||||
This class is used for determining:
|
||||
|
||||
@li The concrete completion handler type to be called at the end of the
|
||||
asynchronous operation;
|
||||
|
||||
@li the initiating function return type; and
|
||||
|
||||
@li how the return value of the initiating function is obtained.
|
||||
|
||||
The trait allows the handler and return types to be determined at the point
|
||||
where the specific completion handler signature is known.
|
||||
|
||||
This template takes advantage of specializations of both
|
||||
`boost::asio::async_result` and `boost::asio::handler_type` for user-defined
|
||||
completion token types. The primary template assumes that the
|
||||
@b CompletionToken is the completion handler.
|
||||
|
||||
@par Example
|
||||
|
||||
The example shows how to define an asynchronous initiation function
|
||||
whose completion handler receives an error code:
|
||||
|
||||
@code
|
||||
template<
|
||||
class AsyncStream, // A stream supporting asynchronous read and write
|
||||
class Handler // The handler to call with signature void(error_code)
|
||||
>
|
||||
async_return_type< // This provides the return type customization
|
||||
Handler, void(error_code)>
|
||||
do_async(
|
||||
AsyncStream& stream, // The stream to work on
|
||||
Handler&& handler) // Could be an rvalue or const reference
|
||||
{
|
||||
// Make sure we have an async stream
|
||||
static_assert(is_async_stream<AsyncWriteStream>::value,
|
||||
"AsyncStream requirements not met");
|
||||
|
||||
// This helper converts the handler into the real handler type
|
||||
async_completion<WriteHandler, void(error_code)> init{handler};
|
||||
|
||||
... // Create and invoke the composed operation
|
||||
|
||||
// This provides the return value and executor customization
|
||||
return init.result.get();
|
||||
}
|
||||
@endcode
|
||||
|
||||
@see @ref async_completion, @ref async_return_type, @ref handler_type
|
||||
*/
|
||||
template<class CompletionToken, class Signature>
|
||||
class async_result
|
||||
{
|
||||
BOOST_STATIC_ASSERT(
|
||||
! std::is_reference<CompletionToken>::value);
|
||||
|
||||
boost::asio::async_result<typename
|
||||
boost::asio::handler_type<CompletionToken,
|
||||
Signature>::type> impl_;
|
||||
|
||||
async_result(async_result const&) = delete;
|
||||
async_result& operator=(async_result const&) = delete;
|
||||
|
||||
public:
|
||||
/// The concrete completion handler type for the specific signature.
|
||||
using completion_handler_type =
|
||||
typename boost::asio::handler_type<
|
||||
CompletionToken, Signature>::type;
|
||||
|
||||
/// The return type of the initiating function.
|
||||
using return_type =
|
||||
typename boost::asio::async_result<
|
||||
completion_handler_type>::type;
|
||||
|
||||
/** Construct an async result from a given handler.
|
||||
|
||||
When using a specalised async_result, the constructor has
|
||||
an opportunity to initialise some state associated with the
|
||||
completion handler, which is then returned from the initiating
|
||||
function.
|
||||
*/
|
||||
explicit
|
||||
async_result(completion_handler_type& h)
|
||||
: impl_(h)
|
||||
{
|
||||
}
|
||||
|
||||
/// Obtain the value to be returned from the initiating function.
|
||||
return_type
|
||||
get()
|
||||
{
|
||||
return impl_.get();
|
||||
}
|
||||
};
|
||||
|
||||
/** Helper for customizing the return type of asynchronous initiation functions.
|
||||
|
||||
This class template is used to transform caller-provided completion
|
||||
handlers in calls to asynchronous initiation functions. The transformation
|
||||
allows customization of the return type of the initiating function, and the
|
||||
function signature of the final handler.
|
||||
|
||||
Example:
|
||||
@code
|
||||
...
|
||||
template<class CompletionToken>
|
||||
typename async_completion<CompletionToken, void(error_code)>::result_type
|
||||
async_initfn(..., CompletionToken&& handler)
|
||||
{
|
||||
async_completion<CompletionToken, void(error_code)> completion{handler};
|
||||
...
|
||||
return completion.result.get();
|
||||
}
|
||||
@endcode
|
||||
|
||||
@tparam CompletionToken Specifies the model used to obtain the result of
|
||||
the asynchronous operation.
|
||||
|
||||
@tparam Signature The call signature for the completion handler type invoked
|
||||
on completion of the asynchronous operation.
|
||||
|
||||
@note See <a href="http://cplusplus.github.io/networking-ts/draft.pdf">
|
||||
Working Draft, C++ Extensions for Networking</a>
|
||||
|
||||
@see @ref async_return_type, @ref handler_type
|
||||
*/
|
||||
template<class CompletionToken, class Signature>
|
||||
struct async_completion
|
||||
{
|
||||
/** The type of the final handler called by the asynchronous initiation function.
|
||||
|
||||
Objects of this type will be callable with the specified signature.
|
||||
*/
|
||||
using completion_handler_type = typename async_result<
|
||||
typename std::decay<CompletionToken>::type,
|
||||
Signature>::completion_handler_type;
|
||||
|
||||
/** Constructor
|
||||
|
||||
The constructor creates the concrete completion handler and
|
||||
makes the link between the handler and the asynchronous
|
||||
result.
|
||||
|
||||
@param token The completion token. If this is a regular completion
|
||||
handler, copies may be made as needed. If the handler is movable,
|
||||
it may also be moved.
|
||||
*/
|
||||
explicit
|
||||
async_completion(CompletionToken& token)
|
||||
: completion_handler(static_cast<typename std::conditional<
|
||||
std::is_same<CompletionToken, completion_handler_type>::value,
|
||||
completion_handler_type&, CompletionToken&&>::type>(token))
|
||||
, result(completion_handler)
|
||||
{
|
||||
// CompletionToken is not invokable with the given signature
|
||||
static_assert(is_completion_handler<
|
||||
completion_handler_type, Signature>::value,
|
||||
"CompletionToken requirements not met: signature mismatch");
|
||||
}
|
||||
|
||||
/// The final completion handler, callable with the specified signature.
|
||||
typename std::conditional<std::is_same<
|
||||
CompletionToken, completion_handler_type>::value,
|
||||
completion_handler_type&,
|
||||
completion_handler_type
|
||||
>::type completion_handler;
|
||||
|
||||
/// The return value of the asynchronous initiation function.
|
||||
async_result<typename std::decay<
|
||||
CompletionToken>::type, Signature> result;
|
||||
};
|
||||
|
||||
template<class CompletionToken, typename Signature>
|
||||
using handler_type = typename beast::async_result<
|
||||
typename std::decay<CompletionToken>::type,
|
||||
Signature>::completion_handler_type;
|
||||
|
||||
template<class CompletionToken, typename Signature>
|
||||
using async_return_type = typename beast::async_result<
|
||||
typename std::decay<CompletionToken>::type,
|
||||
Signature>::return_type;
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
@@ -27,12 +27,12 @@ namespace beast {
|
||||
placeholders present in the list of bound arguments. Parameters
|
||||
which are not matched to placeholders are silently discarded.
|
||||
The passed handler and arguments are forwarded into the returned
|
||||
handler, which provides the same `io_service` execution guarantees
|
||||
handler, which provides the same `io_context` execution guarantees
|
||||
as the original handler.
|
||||
|
||||
Unlike `boost::asio::io_service::wrap`, the returned handler can
|
||||
be used in a subsequent call to `boost::asio::io_service::post`
|
||||
instead of `boost::asio::io_service::dispatch`, to ensure that
|
||||
Unlike `boost::asio::io_context::wrap`, the returned handler can
|
||||
be used in a subsequent call to `boost::asio::io_context::post`
|
||||
instead of `boost::asio::io_context::dispatch`, to ensure that
|
||||
the handler will not be invoked immediately by the calling
|
||||
function.
|
||||
|
||||
@@ -43,7 +43,8 @@ namespace beast {
|
||||
void
|
||||
signal_aborted(AsyncReadStream& stream, ReadHandler&& handler)
|
||||
{
|
||||
stream.get_io_service().post(
|
||||
boost::asio::post(
|
||||
stream.get_executor(),
|
||||
bind_handler(std::forward<ReadHandler>(handler),
|
||||
boost::asio::error::operation_aborted, 0));
|
||||
}
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
#define BOOST_BEAST_BUFFERED_READ_STREAM_HPP
|
||||
|
||||
#include <boost/beast/core/detail/config.hpp>
|
||||
#include <boost/beast/core/async_result.hpp>
|
||||
#include <boost/beast/core/error.hpp>
|
||||
#include <boost/beast/core/multi_buffer.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/asio/async_result.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
#include <cstdint>
|
||||
#include <utility>
|
||||
|
||||
@@ -91,7 +91,8 @@ namespace beast {
|
||||
template<class Stream, class DynamicBuffer>
|
||||
class buffered_read_stream
|
||||
{
|
||||
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
|
||||
template<class Buffers, class Handler>
|
||||
@@ -163,11 +164,29 @@ public:
|
||||
return next_layer_.lowest_layer();
|
||||
}
|
||||
|
||||
/// Get the io_service associated with the object.
|
||||
boost::asio::io_service&
|
||||
get_io_service()
|
||||
/** Get the executor associated with the object.
|
||||
|
||||
This function may be used to obtain the executor object that the stream
|
||||
uses to dispatch handlers for asynchronous operations.
|
||||
|
||||
@return A copy of the executor that stream will use to dispatch handlers.
|
||||
|
||||
@note This function participates in overload resolution only if
|
||||
`NextLayer` has a member function named `get_executor`.
|
||||
*/
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
implementation_defined
|
||||
#else
|
||||
template<
|
||||
class T = next_layer_type,
|
||||
class = typename std::enable_if<
|
||||
has_get_executor<next_layer_type>::value>::type>
|
||||
auto
|
||||
#endif
|
||||
get_executor() noexcept ->
|
||||
decltype(std::declval<T&>().get_executor())
|
||||
{
|
||||
return next_layer_.get_io_service();
|
||||
return next_layer_.get_executor();
|
||||
}
|
||||
|
||||
/** Access the internal buffer.
|
||||
@@ -265,14 +284,11 @@ public:
|
||||
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
|
||||
manner equivalent to using `boost::asio::io_service::post`.
|
||||
manner equivalent to using `boost::asio::io_context::post`.
|
||||
*/
|
||||
template<class MutableBufferSequence, class ReadHandler>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
void_or_deduced
|
||||
#else
|
||||
async_return_type<ReadHandler, void(error_code)>
|
||||
#endif
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
ReadHandler, void(error_code))
|
||||
async_read_some(MutableBufferSequence const& buffers,
|
||||
ReadHandler&& handler);
|
||||
|
||||
@@ -340,14 +356,11 @@ public:
|
||||
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
|
||||
manner equivalent to using `boost::asio::io_service::post`.
|
||||
manner equivalent to using `boost::asio::io_context::post`.
|
||||
*/
|
||||
template<class ConstBufferSequence, class WriteHandler>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
void_or_deduced
|
||||
#else
|
||||
async_return_type<WriteHandler, void(error_code)>
|
||||
#endif
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
WriteHandler, void(error_code))
|
||||
async_write_some(ConstBufferSequence const& buffers,
|
||||
WriteHandler&& handler);
|
||||
};
|
||||
|
||||
@@ -35,10 +35,12 @@ namespace beast {
|
||||
template<class MutableBufferSequence>
|
||||
class buffers_adapter
|
||||
{
|
||||
static_assert(is_mutable_buffer_sequence<MutableBufferSequence>::value,
|
||||
static_assert(boost::asio::is_mutable_buffer_sequence<MutableBufferSequence>::value,
|
||||
"MutableBufferSequence requirements not met");
|
||||
|
||||
using iter_type = typename MutableBufferSequence::const_iterator;
|
||||
using iter_type = typename
|
||||
detail::buffer_sequence_iterator<
|
||||
MutableBufferSequence>::type;
|
||||
|
||||
MutableBufferSequence bs_;
|
||||
iter_type begin_;
|
||||
|
||||
@@ -34,8 +34,8 @@ class buffers_prefix_view
|
||||
using buffers_type = typename
|
||||
std::decay<BufferSequence>::type;
|
||||
|
||||
using iter_type =
|
||||
typename buffers_type::const_iterator;
|
||||
using iter_type = typename
|
||||
detail::buffer_sequence_iterator<buffers_type>::type;
|
||||
|
||||
BufferSequence bs_;
|
||||
std::size_t size_;
|
||||
@@ -141,10 +141,8 @@ boost::asio::const_buffer
|
||||
buffers_prefix(std::size_t size,
|
||||
boost::asio::const_buffer buffer)
|
||||
{
|
||||
using boost::asio::buffer_cast;
|
||||
using boost::asio::buffer_size;
|
||||
return { buffer_cast<void const*>(buffer),
|
||||
(std::min)(size, buffer_size(buffer)) };
|
||||
return {buffer.data(),
|
||||
(std::min)(size, buffer.size())};
|
||||
}
|
||||
|
||||
/** Returns a prefix of a mutable buffer.
|
||||
@@ -166,10 +164,8 @@ boost::asio::mutable_buffer
|
||||
buffers_prefix(std::size_t size,
|
||||
boost::asio::mutable_buffer buffer)
|
||||
{
|
||||
using boost::asio::buffer_cast;
|
||||
using boost::asio::buffer_size;
|
||||
return {buffer_cast<void*>(buffer),
|
||||
(std::min)(size, buffer_size(buffer))};
|
||||
return {buffer.data(),
|
||||
(std::min)(size, buffer.size())};
|
||||
}
|
||||
|
||||
/** Returns a prefix of a buffer sequence.
|
||||
@@ -203,8 +199,8 @@ typename std::enable_if<
|
||||
buffers_prefix(std::size_t size, BufferSequence const& buffers)
|
||||
{
|
||||
static_assert(
|
||||
is_const_buffer_sequence<BufferSequence>::value ||
|
||||
is_mutable_buffer_sequence<BufferSequence>::value,
|
||||
boost::asio::is_const_buffer_sequence<BufferSequence>::value ||
|
||||
boost::asio::is_mutable_buffer_sequence<BufferSequence>::value,
|
||||
"BufferSequence requirements not met");
|
||||
return buffers_prefix_view<BufferSequence>(size, buffers);
|
||||
}
|
||||
@@ -221,13 +217,14 @@ buffers_prefix(std::size_t size, BufferSequence const& buffers)
|
||||
*/
|
||||
template<class BufferSequence>
|
||||
typename std::conditional<
|
||||
is_mutable_buffer_sequence<BufferSequence>::value,
|
||||
boost::asio::is_mutable_buffer_sequence<BufferSequence>::value,
|
||||
boost::asio::mutable_buffer,
|
||||
boost::asio::const_buffer>::type
|
||||
buffers_front(BufferSequence const& buffers)
|
||||
{
|
||||
auto const first = buffers.begin();
|
||||
if(first == buffers.end())
|
||||
auto const first =
|
||||
boost::asio::buffer_sequence_begin(buffers);
|
||||
if(first == boost::asio::buffer_sequence_end(buffers))
|
||||
return {};
|
||||
return *first;
|
||||
}
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
|
||||
#include <boost/beast/core/detail/config.hpp>
|
||||
#include <boost/beast/core/detail/in_place_init.hpp>
|
||||
#include <boost/beast/core/detail/type_traits.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <cstdint>
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace boost {
|
||||
@@ -57,8 +57,8 @@ class buffers_suffix
|
||||
using buffers_type =
|
||||
typename std::decay<BufferSequence>::type;
|
||||
|
||||
using iter_type =
|
||||
typename buffers_type::const_iterator;
|
||||
using iter_type = typename
|
||||
detail::buffer_sequence_iterator<buffers_type>::type;
|
||||
|
||||
BufferSequence bs_;
|
||||
iter_type begin_;
|
||||
@@ -67,7 +67,9 @@ class buffers_suffix
|
||||
template<class Deduced>
|
||||
buffers_suffix(Deduced&& other, std::size_t dist)
|
||||
: bs_(std::forward<Deduced>(other).bs_)
|
||||
, begin_(std::next(bs_.begin(), dist))
|
||||
, begin_(std::next(
|
||||
boost::asio::buffer_sequence_begin(bs_),
|
||||
dist))
|
||||
, skip_(other.skip_)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#define BOOST_BEAST_BUFFERS_TO_STRING_HPP
|
||||
|
||||
#include <boost/beast/core/detail/config.hpp>
|
||||
#include <boost/beast/core/detail/type_traits.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <string>
|
||||
|
||||
@@ -45,10 +46,10 @@ buffers_to_string(ConstBufferSequence const& buffers)
|
||||
{
|
||||
std::string result;
|
||||
result.reserve(boost::asio::buffer_size(buffers));
|
||||
for(boost::asio::const_buffer buffer : buffers)
|
||||
result.append(
|
||||
boost::asio::buffer_cast<char const*>(buffer),
|
||||
boost::asio::buffer_size(buffer));
|
||||
for(boost::asio::const_buffer buffer :
|
||||
detail::buffers_range(buffers))
|
||||
result.append(reinterpret_cast<
|
||||
char const*>(buffer.data()), buffer.size());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
#define BOOST_BEAST_DETAIL_BIND_HANDLER_HPP
|
||||
|
||||
#include <boost/beast/core/detail/integer_sequence.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/associated_allocator.hpp>
|
||||
#include <boost/asio/associated_executor.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/core/ignore_unused.hpp>
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
@@ -24,13 +24,17 @@ namespace detail {
|
||||
|
||||
/* Nullary handler that calls Handler with bound arguments.
|
||||
|
||||
The bound handler provides the same io_service execution
|
||||
The bound handler provides the same io_context execution
|
||||
guarantees as the original handler.
|
||||
*/
|
||||
template<class Handler, class... Args>
|
||||
class bound_handler
|
||||
{
|
||||
private:
|
||||
// Can't friend partial specializations,
|
||||
// so we just friend the whole thing.
|
||||
template<class T, class Executor>
|
||||
friend struct boost::asio::associated_executor;
|
||||
|
||||
using args_type = std::tuple<
|
||||
typename std::decay<Args>::type...>;
|
||||
|
||||
@@ -101,6 +105,9 @@ private:
|
||||
public:
|
||||
using result_type = void;
|
||||
|
||||
using allocator_type =
|
||||
boost::asio::associated_allocator_t<Handler>;
|
||||
|
||||
bound_handler(bound_handler&&) = default;
|
||||
bound_handler(bound_handler const&) = default;
|
||||
|
||||
@@ -113,6 +120,20 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_allocator(h_);
|
||||
}
|
||||
|
||||
friend
|
||||
bool
|
||||
asio_handler_is_continuation(bound_handler* h)
|
||||
{
|
||||
using boost::asio::asio_handler_is_continuation;
|
||||
return asio_handler_is_continuation(std::addressof(h->h_));
|
||||
}
|
||||
|
||||
template<class... Values>
|
||||
void
|
||||
operator()(Values&&... values)
|
||||
@@ -132,48 +153,30 @@ public:
|
||||
std::forward<Values>(values)...),
|
||||
index_sequence_for<Args...>());
|
||||
}
|
||||
|
||||
friend
|
||||
void*
|
||||
asio_handler_allocate(
|
||||
std::size_t size, bound_handler* h)
|
||||
{
|
||||
using boost::asio::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(h->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
void
|
||||
asio_handler_deallocate(
|
||||
void* p, std::size_t size, bound_handler* h)
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(h->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
bool
|
||||
asio_handler_is_continuation(bound_handler* h)
|
||||
{
|
||||
using boost::asio::asio_handler_is_continuation;
|
||||
return asio_handler_is_continuation(std::addressof(h->h_));
|
||||
}
|
||||
|
||||
template<class F>
|
||||
friend
|
||||
void
|
||||
asio_handler_invoke(F&& f, bound_handler* h)
|
||||
{
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(
|
||||
f, std::addressof(h->h_));
|
||||
}
|
||||
};
|
||||
|
||||
} // detail
|
||||
} // beast
|
||||
|
||||
namespace asio {
|
||||
template<class Handler, class... Args, class Executor>
|
||||
struct associated_executor<
|
||||
beast::detail::bound_handler<Handler, Args...>, Executor>
|
||||
{
|
||||
using type = typename
|
||||
associated_executor<Handler, Executor>::type;
|
||||
|
||||
static
|
||||
type
|
||||
get(beast::detail::bound_handler<Handler, Args...> const& h,
|
||||
Executor const& ex = Executor()) noexcept
|
||||
{
|
||||
return associated_executor<
|
||||
Handler, Executor>::get(h.h_, ex);
|
||||
}
|
||||
};
|
||||
} // asio
|
||||
|
||||
} // boost
|
||||
|
||||
namespace std {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#define BOOST_BEAST_DETAIL_BUFFERS_REF_HPP
|
||||
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <iterator>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
@@ -23,11 +24,11 @@ class buffers_ref
|
||||
BufferSequence const* buffers_;
|
||||
|
||||
public:
|
||||
using value_type =
|
||||
typename BufferSequence::value_type;
|
||||
using const_iterator = typename
|
||||
buffer_sequence_iterator<BufferSequence>::type;
|
||||
|
||||
using const_iterator =
|
||||
typename BufferSequence::const_iterator;
|
||||
using value_type = typename std::iterator_traits<
|
||||
const_iterator>::value_type;
|
||||
|
||||
buffers_ref(buffers_ref const&) = default;
|
||||
buffers_ref& operator=(buffers_ref const&) = default;
|
||||
@@ -41,13 +42,13 @@ public:
|
||||
const_iterator
|
||||
begin() const
|
||||
{
|
||||
return buffers_->begin();
|
||||
return boost::asio::buffer_sequence_begin(*buffers_);
|
||||
}
|
||||
|
||||
const_iterator
|
||||
end() const
|
||||
{
|
||||
return buffers_->end();
|
||||
return boost::asio::buffer_sequence_end(*buffers_);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -10,8 +10,10 @@
|
||||
#ifndef BOOST_BEAST_DETAIL_OSTREAM_HPP
|
||||
#define BOOST_BEAST_DETAIL_OSTREAM_HPP
|
||||
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/beast/core/buffers_prefix.hpp>
|
||||
#include <boost/beast/core/read_size.hpp>
|
||||
#include <boost/beast/core/detail/type_traits.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <memory>
|
||||
#include <iosfwd>
|
||||
#include <streambuf>
|
||||
@@ -46,11 +48,10 @@ std::ostream&
|
||||
operator<<(std::ostream& os,
|
||||
buffers_helper<Buffers> const& v)
|
||||
{
|
||||
using boost::asio::buffer_cast;
|
||||
using boost::asio::buffer_size;
|
||||
for(boost::asio::const_buffer b : v.b_)
|
||||
os.write(buffer_cast<char const*>(b),
|
||||
buffer_size(b));
|
||||
for(auto b : buffers_range(v.b_))
|
||||
os.write(
|
||||
reinterpret_cast<char const*>(b.data()),
|
||||
b.size());
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -130,14 +131,12 @@ private:
|
||||
void
|
||||
prepare()
|
||||
{
|
||||
using boost::asio::buffer_cast;
|
||||
using boost::asio::buffer_size;
|
||||
auto mbs = buf_.prepare(
|
||||
auto bs = buf_.prepare(
|
||||
read_size_or_throw(buf_, max_size));
|
||||
auto const mb = *mbs.begin();
|
||||
auto const p = buffer_cast<CharT*>(mb);
|
||||
auto const b = buffers_front(bs);
|
||||
auto const p = reinterpret_cast<CharT*>(b.data());
|
||||
this->setp(p,
|
||||
p + buffer_size(mb) / sizeof(CharT) - 1);
|
||||
p + b.size() / sizeof(CharT) - 1);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -211,14 +210,12 @@ private:
|
||||
void
|
||||
prepare()
|
||||
{
|
||||
using boost::asio::buffer_cast;
|
||||
using boost::asio::buffer_size;
|
||||
auto mbs = buf_.prepare(
|
||||
auto bs = buf_.prepare(
|
||||
read_size_or_throw(buf_, max_size));
|
||||
auto const mb = *mbs.begin();
|
||||
auto const p = buffer_cast<CharT*>(mb);
|
||||
auto const b = buffers_front(bs);
|
||||
auto const p = reinterpret_cast<CharT*>(b.data());
|
||||
this->setp(p,
|
||||
p + buffer_size(mb) / sizeof(CharT) - 1);
|
||||
p + b.size() / sizeof(CharT) - 1);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -12,38 +12,12 @@
|
||||
|
||||
#include <boost/beast/core/error.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <iterator>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
// A few workarounds to keep things working
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
// for has_get_io_service
|
||||
class io_service;
|
||||
|
||||
// for is_dynamic_buffer
|
||||
template<class Allocator>
|
||||
class basic_streambuf;
|
||||
|
||||
namespace detail {
|
||||
|
||||
// for is_buffer_sequence
|
||||
template<class Buffer, class Buffers>
|
||||
class consuming_buffers;
|
||||
|
||||
} // detail
|
||||
|
||||
} // asio
|
||||
} // boost
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace detail {
|
||||
@@ -281,57 +255,17 @@ using ConstBufferSequence =
|
||||
using MutableBufferSequence =
|
||||
BufferSequence<boost::asio::mutable_buffer>;
|
||||
|
||||
template<class T, class B, class = void>
|
||||
struct is_buffer_sequence : std::false_type {};
|
||||
|
||||
template<class T, class B>
|
||||
struct is_buffer_sequence<T, B, void_t<decltype(
|
||||
std::declval<typename T::value_type>(),
|
||||
std::declval<typename T::const_iterator&>() =
|
||||
std::declval<T const&>().begin(),
|
||||
std::declval<typename T::const_iterator&>() =
|
||||
std::declval<T const&>().end(),
|
||||
(void)0)>> : std::integral_constant<bool,
|
||||
std::is_convertible<typename T::value_type, B>::value &&
|
||||
#if 0
|
||||
std::is_base_of<std::bidirectional_iterator_tag,
|
||||
typename std::iterator_traits<
|
||||
typename T::const_iterator>::iterator_category>::value
|
||||
#else
|
||||
// workaround:
|
||||
// boost::asio::detail::consuming_buffers::const_iterator
|
||||
// is not bidirectional
|
||||
std::is_base_of<std::forward_iterator_tag,
|
||||
typename std::iterator_traits<
|
||||
typename T::const_iterator>::iterator_category>::value
|
||||
#endif
|
||||
>
|
||||
{
|
||||
};
|
||||
|
||||
#if 0
|
||||
// workaround:
|
||||
// boost::asio::detail::consuming_buffers::const_iterator
|
||||
// is not bidirectional
|
||||
template<class Buffer, class Buffers, class B>
|
||||
struct is_buffer_sequence<
|
||||
boost::asio::detail::consuming_buffers<Buffer, Buffers>>
|
||||
: std::true_type
|
||||
{
|
||||
};
|
||||
#endif
|
||||
|
||||
template<class B1, class... Bn>
|
||||
struct is_all_const_buffer_sequence
|
||||
: std::integral_constant<bool,
|
||||
is_buffer_sequence<B1, boost::asio::const_buffer>::value &&
|
||||
boost::asio::is_const_buffer_sequence<B1>::value &&
|
||||
is_all_const_buffer_sequence<Bn...>::value>
|
||||
{
|
||||
};
|
||||
|
||||
template<class B1>
|
||||
struct is_all_const_buffer_sequence<B1>
|
||||
: is_buffer_sequence<B1, boost::asio::const_buffer>
|
||||
template<class B>
|
||||
struct is_all_const_buffer_sequence<B>
|
||||
: boost::asio::is_const_buffer_sequence<B>
|
||||
{
|
||||
};
|
||||
|
||||
@@ -346,6 +280,14 @@ struct common_buffers_type
|
||||
boost::asio::const_buffer>::type;
|
||||
};
|
||||
|
||||
template<class B>
|
||||
struct buffer_sequence_iterator
|
||||
{
|
||||
using type = decltype(
|
||||
boost::asio::buffer_sequence_begin(
|
||||
std::declval<B const&>()));
|
||||
};
|
||||
|
||||
// Types that meet the requirements,
|
||||
// for use with std::declval only.
|
||||
struct StreamHandler
|
||||
@@ -356,6 +298,54 @@ struct StreamHandler
|
||||
using ReadHandler = StreamHandler;
|
||||
using WriteHandler = StreamHandler;
|
||||
|
||||
template<class Buffers>
|
||||
class buffers_range_adapter
|
||||
{
|
||||
Buffers const& b_;
|
||||
|
||||
public:
|
||||
using value_type = typename std::conditional<
|
||||
std::is_convertible<typename std::iterator_traits<
|
||||
typename buffer_sequence_iterator<Buffers>::type>::value_type,
|
||||
boost::asio::const_buffer>::value,
|
||||
boost::asio::const_buffer,
|
||||
boost::asio::mutable_buffer>::type;
|
||||
|
||||
/* VFALCO This isn't right, because range-for will pick up the iterator's
|
||||
value_type which might not be const_buffer or mutable_buffer. We
|
||||
need to declare our own iterator wrapper that converts the underlying
|
||||
iterator's value_type to const_buffer or mutable_buffer so that
|
||||
range-for sees one of those types.
|
||||
*/
|
||||
using const_iterator = typename
|
||||
buffer_sequence_iterator<Buffers>::type;
|
||||
|
||||
explicit
|
||||
buffers_range_adapter(Buffers const& b)
|
||||
: b_(b)
|
||||
{
|
||||
}
|
||||
|
||||
const_iterator
|
||||
begin() const noexcept
|
||||
{
|
||||
return boost::asio::buffer_sequence_begin(b_);
|
||||
}
|
||||
|
||||
const_iterator
|
||||
end() const noexcept
|
||||
{
|
||||
return boost::asio::buffer_sequence_end(b_);
|
||||
}
|
||||
};
|
||||
|
||||
template<class Buffers>
|
||||
buffers_range_adapter<Buffers>
|
||||
buffers_range(Buffers const& buffers)
|
||||
{
|
||||
return buffers_range_adapter<Buffers>{buffers};
|
||||
}
|
||||
|
||||
} // detail
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
@@ -84,10 +84,10 @@ public:
|
||||
using allocator_type = Allocator;
|
||||
|
||||
/// The type used to represent the input sequence as a list of buffers.
|
||||
using const_buffers_type = boost::asio::mutable_buffers_1;
|
||||
using const_buffers_type = boost::asio::mutable_buffer;
|
||||
|
||||
/// The type used to represent the output sequence as a list of buffers.
|
||||
using mutable_buffers_type = boost::asio::mutable_buffers_1;
|
||||
using mutable_buffers_type = boost::asio::mutable_buffer;
|
||||
|
||||
/// Destructor
|
||||
~basic_flat_buffer();
|
||||
|
||||
@@ -52,13 +52,13 @@ public:
|
||||
|
||||
This buffer sequence is guaranteed to have length 1.
|
||||
*/
|
||||
using const_buffers_type = boost::asio::mutable_buffers_1;
|
||||
using const_buffers_type = boost::asio::mutable_buffer;
|
||||
|
||||
/** The type used to represent the output sequence as a list of buffers.
|
||||
|
||||
This buffer sequence is guaranteed to have length 1.
|
||||
*/
|
||||
using mutable_buffers_type = boost::asio::mutable_buffers_1;
|
||||
using mutable_buffers_type = boost::asio::mutable_buffer;
|
||||
|
||||
/** Constructor
|
||||
|
||||
|
||||
@@ -1,162 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
// Official repository: https://github.com/boostorg/beast
|
||||
//
|
||||
|
||||
#ifndef BOOST_BEAST_HANDLER_ALLOC_HPP
|
||||
#define BOOST_BEAST_HANDLER_ALLOC_HPP
|
||||
|
||||
#include <boost/beast/core/detail/config.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
// Guidance from
|
||||
// http://howardhinnant.github.io/allocator_boilerplate.html
|
||||
|
||||
/** An allocator that uses handler customizations.
|
||||
|
||||
This allocator uses the handler customizations `asio_handler_allocate`
|
||||
and `asio_handler_deallocate` to manage memory. It meets the requirements
|
||||
of @b Allocator and can be used anywhere a `std::allocator` is
|
||||
accepted.
|
||||
|
||||
@tparam T The type of objects allocated by the allocator.
|
||||
|
||||
@tparam Handler The type of handler.
|
||||
|
||||
@note Memory allocated by this allocator must be freed before
|
||||
the handler is invoked or undefined behavior results. This behavior
|
||||
is described as the "deallocate before invocation" Asio guarantee.
|
||||
*/
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
template<class T, class Handler>
|
||||
class handler_alloc;
|
||||
#else
|
||||
template<class T, class Handler>
|
||||
class handler_alloc
|
||||
{
|
||||
private:
|
||||
// We want a partial template specialization as a friend
|
||||
// but that isn't allowed so we friend all versions. This
|
||||
// should produce a compile error if Handler is not
|
||||
// constructible from H.
|
||||
//
|
||||
template<class U, class H>
|
||||
friend class handler_alloc;
|
||||
|
||||
Handler& h_;
|
||||
|
||||
public:
|
||||
using value_type = T;
|
||||
using is_always_equal = std::true_type;
|
||||
using pointer = T*;
|
||||
using reference = T&;
|
||||
using const_pointer = T const*;
|
||||
using const_reference = T const&;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
|
||||
template<class U>
|
||||
struct rebind
|
||||
{
|
||||
using other = handler_alloc<U, Handler>;
|
||||
};
|
||||
|
||||
handler_alloc() = delete;
|
||||
handler_alloc(handler_alloc&&) = default;
|
||||
handler_alloc(handler_alloc const&) = default;
|
||||
handler_alloc& operator=(handler_alloc&&) = default;
|
||||
handler_alloc& operator=(handler_alloc const&) = default;
|
||||
|
||||
/** Construct the allocator.
|
||||
|
||||
A reference of the handler is stored. The handler must
|
||||
remain valid for at least the lifetime of the allocator.
|
||||
*/
|
||||
explicit
|
||||
handler_alloc(Handler& h)
|
||||
: h_(h)
|
||||
{
|
||||
}
|
||||
|
||||
/// Copy constructor
|
||||
template<class U>
|
||||
handler_alloc(
|
||||
handler_alloc<U, Handler> const& other)
|
||||
: h_(other.h_)
|
||||
{
|
||||
}
|
||||
|
||||
value_type*
|
||||
allocate(size_type n)
|
||||
{
|
||||
auto const size = n * sizeof(T);
|
||||
using boost::asio::asio_handler_allocate;
|
||||
return static_cast<value_type*>(
|
||||
asio_handler_allocate(size, std::addressof(h_)));
|
||||
}
|
||||
|
||||
void
|
||||
deallocate(value_type* p, size_type n)
|
||||
{
|
||||
auto const size = n * sizeof(T);
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(p, size, std::addressof(h_));
|
||||
}
|
||||
|
||||
//#if BOOST_WORKAROUND(BOOST_GCC, < 60000) // Works, but too coarse
|
||||
|
||||
#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000
|
||||
template<class U, class... Args>
|
||||
void
|
||||
construct(U* ptr, Args&&... args)
|
||||
{
|
||||
::new((void*)ptr) U(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<class U>
|
||||
void
|
||||
destroy(U* ptr)
|
||||
{
|
||||
ptr->~U();
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class U>
|
||||
friend
|
||||
bool
|
||||
operator==(
|
||||
handler_alloc const&,
|
||||
handler_alloc<U, Handler> const&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class U>
|
||||
friend
|
||||
bool
|
||||
operator!=(
|
||||
handler_alloc const& lhs,
|
||||
handler_alloc<U, Handler> const& rhs)
|
||||
{
|
||||
return ! (lhs == rhs);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
@@ -16,9 +16,10 @@
|
||||
#include <boost/beast/core/read_size.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/beast/core/detail/config.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/associated_allocator.hpp>
|
||||
#include <boost/asio/associated_executor.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/asio/post.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
namespace boost {
|
||||
@@ -48,28 +49,28 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
using allocator_type =
|
||||
boost::asio::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_allocator(h_);
|
||||
}
|
||||
|
||||
using executor_type = boost::asio::associated_executor_t<
|
||||
Handler, decltype(s_.get_executor())>;
|
||||
|
||||
executor_type get_executor() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_executor(
|
||||
h_, s_.get_executor());
|
||||
}
|
||||
|
||||
void
|
||||
operator()(error_code const& ec,
|
||||
std::size_t bytes_transferred);
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, read_some_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
void asio_handler_deallocate(
|
||||
void* p, std::size_t size, read_some_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(read_some_op* op)
|
||||
{
|
||||
@@ -77,14 +78,6 @@ public:
|
||||
return asio_handler_is_continuation(
|
||||
std::addressof(op->h_));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, read_some_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(f, std::addressof(op->h_));
|
||||
}
|
||||
};
|
||||
|
||||
template<class Stream, class DynamicBuffer>
|
||||
@@ -116,9 +109,9 @@ read_some_op<MutableBufferSequence, Handler>::operator()(
|
||||
|
||||
}
|
||||
step_ = 3;
|
||||
s_.get_io_service().post(
|
||||
return boost::asio::post(
|
||||
s_.get_executor(),
|
||||
bind_handler(std::move(*this), ec, 0));
|
||||
return;
|
||||
|
||||
case 1:
|
||||
// upcall
|
||||
@@ -153,11 +146,11 @@ auto
|
||||
buffered_read_stream<Stream, DynamicBuffer>::
|
||||
async_write_some(ConstBufferSequence const& buffers,
|
||||
WriteHandler&& handler) ->
|
||||
async_return_type<WriteHandler, void(error_code)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler, void(error_code))
|
||||
{
|
||||
static_assert(is_async_write_stream<next_layer_type>::value,
|
||||
"AsyncWriteStream requirements not met");
|
||||
static_assert(is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
static_assert(is_completion_handler<WriteHandler,
|
||||
@@ -176,7 +169,7 @@ read_some(
|
||||
{
|
||||
static_assert(is_sync_read_stream<next_layer_type>::value,
|
||||
"SyncReadStream requirements not met");
|
||||
static_assert(is_mutable_buffer_sequence<
|
||||
static_assert(boost::asio::is_mutable_buffer_sequence<
|
||||
MutableBufferSequence>::value,
|
||||
"MutableBufferSequence requirements not met");
|
||||
error_code ec;
|
||||
@@ -195,7 +188,7 @@ read_some(MutableBufferSequence const& buffers,
|
||||
{
|
||||
static_assert(is_sync_read_stream<next_layer_type>::value,
|
||||
"SyncReadStream requirements not met");
|
||||
static_assert(is_mutable_buffer_sequence<
|
||||
static_assert(boost::asio::is_mutable_buffer_sequence<
|
||||
MutableBufferSequence>::value,
|
||||
"MutableBufferSequence requirements not met");
|
||||
using boost::asio::buffer_size;
|
||||
@@ -226,20 +219,20 @@ auto
|
||||
buffered_read_stream<Stream, DynamicBuffer>::
|
||||
async_read_some(MutableBufferSequence const& buffers,
|
||||
ReadHandler&& handler) ->
|
||||
async_return_type<ReadHandler, void(error_code)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler, void(error_code))
|
||||
{
|
||||
static_assert(is_async_read_stream<next_layer_type>::value,
|
||||
"Stream requirements not met");
|
||||
static_assert(is_mutable_buffer_sequence<
|
||||
"AsyncReadStream requirements not met");
|
||||
static_assert(boost::asio::is_mutable_buffer_sequence<
|
||||
MutableBufferSequence>::value,
|
||||
"MutableBufferSequence requirements not met");
|
||||
if(buffer_.size() == 0 && capacity_ == 0)
|
||||
return next_layer_.async_read_some(buffers,
|
||||
std::forward<ReadHandler>(handler));
|
||||
async_completion<ReadHandler,
|
||||
boost::asio::async_completion<ReadHandler,
|
||||
void(error_code, std::size_t)> init{handler};
|
||||
read_some_op<MutableBufferSequence, handler_type<
|
||||
ReadHandler, void(error_code, std::size_t)>>{
|
||||
read_some_op<MutableBufferSequence, BOOST_ASIO_HANDLER_TYPE(
|
||||
ReadHandler, void(error_code, std::size_t))>{
|
||||
init.completion_handler, *this, buffers}(
|
||||
error_code{}, 0);
|
||||
return init.result.get();
|
||||
|
||||
@@ -90,11 +90,10 @@ public:
|
||||
reference
|
||||
operator*() const
|
||||
{
|
||||
using boost::asio::buffer_cast;
|
||||
using boost::asio::buffer_size;
|
||||
return value_type{buffer_cast<void const*>(*it_),
|
||||
(ba_->out_ == ba_->bs_.end() ||
|
||||
it_ != ba_->out_) ? buffer_size(*it_) : ba_->out_pos_} +
|
||||
value_type const b = *it_;
|
||||
return value_type{b.data(),
|
||||
(ba_->out_ == boost::asio::buffer_sequence_end(ba_->bs_) ||
|
||||
it_ != ba_->out_) ? b.size() : ba_->out_pos_} +
|
||||
(it_ == ba_->begin_ ? ba_->in_pos_ : 0);
|
||||
}
|
||||
|
||||
@@ -233,11 +232,10 @@ public:
|
||||
reference
|
||||
operator*() const
|
||||
{
|
||||
using boost::asio::buffer_cast;
|
||||
using boost::asio::buffer_size;
|
||||
return value_type{buffer_cast<void*>(*it_),
|
||||
value_type const b = *it_;
|
||||
return value_type{b.data(),
|
||||
it_ == std::prev(ba_->end_) ?
|
||||
ba_->out_end_ : buffer_size(*it_)} +
|
||||
ba_->out_end_ : b.size()} +
|
||||
(it_ == ba_->out_ ? ba_->out_pos_ : 0);
|
||||
}
|
||||
|
||||
@@ -288,7 +286,9 @@ private:
|
||||
template<class MutableBufferSequence>
|
||||
inline
|
||||
auto
|
||||
buffers_adapter<MutableBufferSequence>::mutable_buffers_type::begin() const ->
|
||||
buffers_adapter<MutableBufferSequence>::
|
||||
mutable_buffers_type::
|
||||
begin() const ->
|
||||
const_iterator
|
||||
{
|
||||
return const_iterator{*ba_, ba_->out_};
|
||||
@@ -297,7 +297,9 @@ buffers_adapter<MutableBufferSequence>::mutable_buffers_type::begin() const ->
|
||||
template<class MutableBufferSequence>
|
||||
inline
|
||||
auto
|
||||
buffers_adapter<MutableBufferSequence>::mutable_buffers_type::end() const ->
|
||||
buffers_adapter<MutableBufferSequence>::
|
||||
mutable_buffers_type::
|
||||
end() const ->
|
||||
const_iterator
|
||||
{
|
||||
return const_iterator{*ba_, ba_->end_};
|
||||
@@ -309,9 +311,9 @@ template<class MutableBufferSequence>
|
||||
buffers_adapter<MutableBufferSequence>::buffers_adapter(
|
||||
buffers_adapter&& other)
|
||||
: buffers_adapter(std::move(other),
|
||||
std::distance<iter_type>(other.bs_.begin(), other.begin_),
|
||||
std::distance<iter_type>(other.bs_.begin(), other.out_),
|
||||
std::distance<iter_type>(other.bs_.begin(), other.end_))
|
||||
std::distance<iter_type>(boost::asio::buffer_sequence_begin(other.bs_), other.begin_),
|
||||
std::distance<iter_type>(boost::asio::buffer_sequence_begin(other.bs_), other.out_),
|
||||
std::distance<iter_type>(boost::asio::buffer_sequence_begin(other.bs_), other.end_))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -319,9 +321,9 @@ template<class MutableBufferSequence>
|
||||
buffers_adapter<MutableBufferSequence>::buffers_adapter(
|
||||
buffers_adapter const& other)
|
||||
: buffers_adapter(other,
|
||||
std::distance<iter_type>(other.bs_.begin(), other.begin_),
|
||||
std::distance<iter_type>(other.bs_.begin(), other.out_),
|
||||
std::distance<iter_type>(other.bs_.begin(), other.end_))
|
||||
std::distance<iter_type>(boost::asio::buffer_sequence_begin(other.bs_), other.begin_),
|
||||
std::distance<iter_type>(boost::asio::buffer_sequence_begin(other.bs_), other.out_),
|
||||
std::distance<iter_type>(boost::asio::buffer_sequence_begin(other.bs_), other.end_))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -331,15 +333,18 @@ buffers_adapter<MutableBufferSequence>::operator=(
|
||||
buffers_adapter&& other) -> buffers_adapter&
|
||||
{
|
||||
auto const nbegin = std::distance<iter_type>(
|
||||
other.bs_.begin(), other.begin_);
|
||||
boost::asio::buffer_sequence_begin(other.bs_),
|
||||
other.begin_);
|
||||
auto const nout = std::distance<iter_type>(
|
||||
other.bs_.begin(), other.out_);
|
||||
boost::asio::buffer_sequence_begin(other.bs_),
|
||||
other.out_);
|
||||
auto const nend = std::distance<iter_type>(
|
||||
other.bs_.begin(), other.end_);
|
||||
boost::asio::buffer_sequence_begin(other.bs_),
|
||||
other.end_);
|
||||
bs_ = std::move(other.bs_);
|
||||
begin_ = std::next(bs_.begin(), nbegin);
|
||||
out_ = std::next(bs_.begin(), nout);
|
||||
end_ = std::next(bs_.begin(), nend);
|
||||
begin_ = std::next(boost::asio::buffer_sequence_begin(bs_), nbegin);
|
||||
out_ = std::next(boost::asio::buffer_sequence_begin(bs_), nout);
|
||||
end_ = std::next(boost::asio::buffer_sequence_begin(bs_), nend);
|
||||
max_size_ = other.max_size_;
|
||||
in_pos_ = other.in_pos_;
|
||||
in_size_ = other.in_size_;
|
||||
@@ -354,15 +359,18 @@ buffers_adapter<MutableBufferSequence>::operator=(
|
||||
buffers_adapter const& other) -> buffers_adapter&
|
||||
{
|
||||
auto const nbegin = std::distance<iter_type>(
|
||||
other.bs_.begin(), other.begin_);
|
||||
boost::asio::buffer_sequence_begin(other.bs_),
|
||||
other.begin_);
|
||||
auto const nout = std::distance<iter_type>(
|
||||
other.bs_.begin(), other.out_);
|
||||
boost::asio::buffer_sequence_begin(other.bs_),
|
||||
other.out_);
|
||||
auto const nend = std::distance<iter_type>(
|
||||
other.bs_.begin(), other.end_);
|
||||
boost::asio::buffer_sequence_begin(other.bs_),
|
||||
other.end_);
|
||||
bs_ = other.bs_;
|
||||
begin_ = std::next(bs_.begin(), nbegin);
|
||||
out_ = std::next(bs_.begin(), nout);
|
||||
end_ = std::next(bs_.begin(), nend);
|
||||
begin_ = std::next(boost::asio::buffer_sequence_begin(bs_), nbegin);
|
||||
out_ = std::next(boost::asio::buffer_sequence_begin(bs_), nout);
|
||||
end_ = std::next(boost::asio::buffer_sequence_begin(bs_), nend);
|
||||
max_size_ = other.max_size_;
|
||||
in_pos_ = other.in_pos_;
|
||||
in_size_ = other.in_size_;
|
||||
@@ -375,9 +383,9 @@ template<class MutableBufferSequence>
|
||||
buffers_adapter<MutableBufferSequence>::buffers_adapter(
|
||||
MutableBufferSequence const& bs)
|
||||
: bs_(bs)
|
||||
, begin_(bs_.begin())
|
||||
, out_(bs_.begin())
|
||||
, end_(bs_.begin())
|
||||
, begin_(boost::asio::buffer_sequence_begin(bs_))
|
||||
, out_ (boost::asio::buffer_sequence_begin(bs_))
|
||||
, end_ (boost::asio::buffer_sequence_begin(bs_))
|
||||
, max_size_(boost::asio::buffer_size(bs_))
|
||||
{
|
||||
}
|
||||
@@ -389,13 +397,14 @@ buffers_adapter<MutableBufferSequence>::prepare(std::size_t n) ->
|
||||
{
|
||||
using boost::asio::buffer_size;
|
||||
end_ = out_;
|
||||
if(end_ != bs_.end())
|
||||
if(end_ != boost::asio::buffer_sequence_end(bs_))
|
||||
{
|
||||
auto size = buffer_size(*end_) - out_pos_;
|
||||
if(n > size)
|
||||
{
|
||||
n -= size;
|
||||
while(++end_ != bs_.end())
|
||||
while(++end_ !=
|
||||
boost::asio::buffer_sequence_end(bs_))
|
||||
{
|
||||
size = buffer_size(*end_);
|
||||
if(n < size)
|
||||
|
||||
@@ -30,7 +30,7 @@ class buffers_cat_view<Bn...>::const_iterator
|
||||
std::size_t n_;
|
||||
std::tuple<Bn...> const* bn_;
|
||||
std::array<char, detail::max_sizeof<
|
||||
typename Bn::const_iterator...>()> buf_;
|
||||
typename detail::buffer_sequence_iterator<Bn>::type...>()> buf_;
|
||||
|
||||
friend class buffers_cat_view<Bn...>;
|
||||
|
||||
@@ -38,8 +38,8 @@ class buffers_cat_view<Bn...>::const_iterator
|
||||
using C = std::integral_constant<std::size_t, I>;
|
||||
|
||||
template<std::size_t I>
|
||||
using iter_t = typename std::tuple_element<
|
||||
I, std::tuple<Bn...>>::type::const_iterator;
|
||||
using iter_t = typename detail::buffer_sequence_iterator<
|
||||
typename std::tuple_element<I, std::tuple<Bn...>>::type>::type;
|
||||
|
||||
template<std::size_t I>
|
||||
iter_t<I>&
|
||||
@@ -123,7 +123,8 @@ private:
|
||||
{
|
||||
n_ = I;
|
||||
new(&buf_[0]) iter_t<I>{
|
||||
std::get<I>(*bn_).begin()};
|
||||
boost::asio::buffer_sequence_begin(
|
||||
std::get<I>(*bn_))};
|
||||
return;
|
||||
}
|
||||
construct(C<I+1>{});
|
||||
@@ -138,7 +139,8 @@ private:
|
||||
{
|
||||
n_ = I;
|
||||
new(&buf_[0]) iter_t<I>{
|
||||
std::get<I>(*bn_).end()};
|
||||
boost::asio::buffer_sequence_end(
|
||||
std::get<I>(*bn_))};
|
||||
return;
|
||||
}
|
||||
BOOST_THROW_EXCEPTION(std::logic_error{
|
||||
@@ -154,7 +156,8 @@ private:
|
||||
{
|
||||
n_ = I;
|
||||
new(&buf_[0]) iter_t<I>{
|
||||
std::get<I>(*bn_).end()};
|
||||
boost::asio::buffer_sequence_end(
|
||||
std::get<I>(*bn_))};
|
||||
return;
|
||||
}
|
||||
rconstruct(C<I-1>{});
|
||||
@@ -268,7 +271,8 @@ private:
|
||||
if(n_ == I)
|
||||
{
|
||||
if(++iter<I>() !=
|
||||
std::get<I>(*bn_).end())
|
||||
boost::asio::buffer_sequence_end(
|
||||
std::get<I>(*bn_)))
|
||||
return;
|
||||
using Iter = iter_t<I>;
|
||||
iter<I>().~Iter();
|
||||
@@ -292,7 +296,9 @@ private:
|
||||
{
|
||||
if(n_ == I)
|
||||
{
|
||||
if(iter<I>() != std::get<I>(*bn_).begin())
|
||||
if(iter<I>() !=
|
||||
boost::asio::buffer_sequence_begin(
|
||||
std::get<I>(*bn_)))
|
||||
{
|
||||
--iter<I>();
|
||||
return;
|
||||
@@ -309,7 +315,9 @@ private:
|
||||
decrement(C<0> const&)
|
||||
{
|
||||
auto constexpr I = 0;
|
||||
if(iter<I>() != std::get<I>(*bn_).begin())
|
||||
if(iter<I>() !=
|
||||
boost::asio::buffer_sequence_begin(
|
||||
std::get<I>(*bn_)))
|
||||
{
|
||||
--iter<I>();
|
||||
return;
|
||||
|
||||
@@ -27,10 +27,8 @@ boost::asio::const_buffer
|
||||
buffers_prefix(std::size_t size,
|
||||
boost::asio::const_buffer buffer)
|
||||
{
|
||||
using boost::asio::buffer_cast;
|
||||
using boost::asio::buffer_size;
|
||||
return {buffer_cast<void const*>(buffer),
|
||||
(std::min)(size, buffer_size(buffer))};
|
||||
return {buffer.data(),
|
||||
(std::min)(size, buffer.size())};
|
||||
}
|
||||
|
||||
inline
|
||||
@@ -38,10 +36,8 @@ boost::asio::mutable_buffer
|
||||
buffers_prefix(std::size_t size,
|
||||
boost::asio::mutable_buffer buffer)
|
||||
{
|
||||
using boost::asio::buffer_cast;
|
||||
using boost::asio::buffer_size;
|
||||
return {buffer_cast<void*>(buffer),
|
||||
(std::min)(size, buffer_size(buffer))};
|
||||
return {buffer.data(),
|
||||
(std::min)(size, buffer.size())};
|
||||
}
|
||||
|
||||
} // detail
|
||||
@@ -138,7 +134,7 @@ private:
|
||||
std::false_type)
|
||||
: b_(&b)
|
||||
, remain_(b_->size_)
|
||||
, it_(b_->bs_.begin())
|
||||
, it_(boost::asio::buffer_sequence_begin(b_->bs_))
|
||||
{
|
||||
}
|
||||
};
|
||||
@@ -149,7 +145,7 @@ buffers_prefix_view<BufferSequence>::
|
||||
setup(std::size_t size)
|
||||
{
|
||||
size_ = 0;
|
||||
end_ = bs_.begin();
|
||||
end_ = boost::asio::buffer_sequence_begin(bs_);
|
||||
auto const last = bs_.end();
|
||||
while(end_ != last)
|
||||
{
|
||||
@@ -170,7 +166,8 @@ buffers_prefix_view<BufferSequence>::
|
||||
buffers_prefix_view(buffers_prefix_view&& other)
|
||||
: buffers_prefix_view(std::move(other),
|
||||
std::distance<iter_type>(
|
||||
other.bs_.begin(), other.end_))
|
||||
boost::asio::buffer_sequence_begin(other.bs_),
|
||||
other.end_))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -179,7 +176,8 @@ buffers_prefix_view<BufferSequence>::
|
||||
buffers_prefix_view(buffers_prefix_view const& other)
|
||||
: buffers_prefix_view(other,
|
||||
std::distance<iter_type>(
|
||||
other.bs_.begin(), other.end_))
|
||||
boost::asio::buffer_sequence_begin(other.bs_),
|
||||
other.end_))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -190,10 +188,13 @@ operator=(buffers_prefix_view&& other) ->
|
||||
buffers_prefix_view&
|
||||
{
|
||||
auto const dist = std::distance<iter_type>(
|
||||
other.bs_.begin(), other.end_);
|
||||
boost::asio::buffer_sequence_begin(other.bs_),
|
||||
other.end_);
|
||||
bs_ = std::move(other.bs_);
|
||||
size_ = other.size_;
|
||||
end_ = std::next(bs_.begin(), dist);
|
||||
end_ = std::next(
|
||||
boost::asio::buffer_sequence_begin(bs_),
|
||||
dist);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -204,10 +205,13 @@ operator=(buffers_prefix_view const& other) ->
|
||||
buffers_prefix_view&
|
||||
{
|
||||
auto const dist = std::distance<iter_type>(
|
||||
other.bs_.begin(), other.end_);
|
||||
boost::asio::buffer_sequence_begin(other.bs_),
|
||||
other.end_);
|
||||
bs_ = other.bs_;
|
||||
size_ = other.size_;
|
||||
end_ = std::next(bs_.begin(), dist);
|
||||
end_ = std::next(
|
||||
boost::asio::buffer_sequence_begin(bs_),
|
||||
dist);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@ class buffers_suffix<Buffers>::const_iterator
|
||||
{
|
||||
friend class buffers_suffix<Buffers>;
|
||||
|
||||
using iter_type =
|
||||
typename Buffers::const_iterator;
|
||||
using iter_type = typename
|
||||
detail::buffer_sequence_iterator<Buffers>::type;
|
||||
|
||||
iter_type it_;
|
||||
buffers_suffix const* b_ = nullptr;
|
||||
@@ -117,7 +117,7 @@ private:
|
||||
template<class Buffers>
|
||||
buffers_suffix<Buffers>::
|
||||
buffers_suffix()
|
||||
: begin_(bs_.begin())
|
||||
: begin_(boost::asio::buffer_sequence_begin(bs_))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -126,7 +126,8 @@ buffers_suffix<Buffers>::
|
||||
buffers_suffix(buffers_suffix&& other)
|
||||
: buffers_suffix(std::move(other),
|
||||
std::distance<iter_type>(
|
||||
other.bs_.begin(), other.begin_))
|
||||
boost::asio::buffer_sequence_begin(
|
||||
other.bs_), other.begin_))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -135,7 +136,8 @@ buffers_suffix<Buffers>::
|
||||
buffers_suffix(buffers_suffix const& other)
|
||||
: buffers_suffix(other,
|
||||
std::distance<iter_type>(
|
||||
other.bs_.begin(), other.begin_))
|
||||
boost::asio::buffer_sequence_begin(
|
||||
other.bs_), other.begin_))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -143,11 +145,11 @@ template<class Buffers>
|
||||
buffers_suffix<Buffers>::
|
||||
buffers_suffix(Buffers const& bs)
|
||||
: bs_(bs)
|
||||
, begin_(bs_.begin())
|
||||
, begin_(boost::asio::buffer_sequence_begin(bs_))
|
||||
{
|
||||
static_assert(
|
||||
is_const_buffer_sequence<Buffers>::value||
|
||||
is_mutable_buffer_sequence<Buffers>::value,
|
||||
boost::asio::is_const_buffer_sequence<Buffers>::value||
|
||||
boost::asio::is_mutable_buffer_sequence<Buffers>::value,
|
||||
"BufferSequence requirements not met");
|
||||
}
|
||||
|
||||
@@ -156,7 +158,7 @@ template<class... Args>
|
||||
buffers_suffix<Buffers>::
|
||||
buffers_suffix(boost::in_place_init_t, Args&&... args)
|
||||
: bs_(std::forward<Args>(args)...)
|
||||
, begin_(bs_.begin())
|
||||
, begin_(boost::asio::buffer_sequence_begin(bs_))
|
||||
{
|
||||
static_assert(sizeof...(Args) > 0,
|
||||
"Missing constructor arguments");
|
||||
@@ -172,9 +174,12 @@ operator=(buffers_suffix&& other) ->
|
||||
buffers_suffix&
|
||||
{
|
||||
auto const dist = std::distance<iter_type>(
|
||||
other.bs_.begin(), other.begin_);
|
||||
boost::asio::buffer_sequence_begin(other.bs_),
|
||||
other.begin_);
|
||||
bs_ = std::move(other.bs_);
|
||||
begin_ = std::next(bs_.begin(), dist);
|
||||
begin_ = std::next(
|
||||
boost::asio::buffer_sequence_begin(bs_),
|
||||
dist);
|
||||
skip_ = other.skip_;
|
||||
return *this;
|
||||
}
|
||||
@@ -186,9 +191,11 @@ operator=(buffers_suffix const& other) ->
|
||||
buffers_suffix&
|
||||
{
|
||||
auto const dist = std::distance<iter_type>(
|
||||
other.bs_.begin(), other.begin_);
|
||||
boost::asio::buffer_sequence_begin(other.bs_),
|
||||
other.begin_);
|
||||
bs_ = other.bs_;
|
||||
begin_ = std::next(bs_.begin(), dist);
|
||||
begin_ = std::next(
|
||||
boost::asio::buffer_sequence_begin(bs_), dist);
|
||||
skip_ = other.skip_;
|
||||
return *this;
|
||||
}
|
||||
@@ -210,7 +217,8 @@ buffers_suffix<Buffers>::
|
||||
end() const ->
|
||||
const_iterator
|
||||
{
|
||||
return const_iterator{*this, bs_.end()};
|
||||
return const_iterator{*this,
|
||||
boost::asio::buffer_sequence_end(bs_)};
|
||||
}
|
||||
|
||||
template<class Buffers>
|
||||
@@ -219,7 +227,9 @@ buffers_suffix<Buffers>::
|
||||
consume(std::size_t amount)
|
||||
{
|
||||
using boost::asio::buffer_size;
|
||||
for(;amount > 0 && begin_ != bs_.end(); ++begin_)
|
||||
auto const end =
|
||||
boost::asio::buffer_sequence_end(bs_);
|
||||
for(;amount > 0 && begin_ != end; ++begin_)
|
||||
{
|
||||
auto const len =
|
||||
buffer_size(*begin_) - skip_;
|
||||
|
||||
@@ -10,9 +10,7 @@
|
||||
#ifndef BOOST_BEAST_IMPL_HANDLER_PTR_HPP
|
||||
#define BOOST_BEAST_IMPL_HANDLER_PTR_HPP
|
||||
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/asio/associated_allocator.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <memory>
|
||||
|
||||
@@ -27,10 +25,11 @@ P(DeducedHandler&& h, Args&&... args)
|
||||
: n(1)
|
||||
, handler(std::forward<DeducedHandler>(h))
|
||||
{
|
||||
using boost::asio::asio_handler_allocate;
|
||||
t = reinterpret_cast<T*>(
|
||||
asio_handler_allocate(
|
||||
sizeof(T), std::addressof(handler)));
|
||||
typename std::allocator_traits<
|
||||
boost::asio::associated_allocator_t<Handler>>::
|
||||
template rebind_alloc<T> alloc{
|
||||
boost::asio::get_associated_allocator(handler)};
|
||||
t = std::allocator_traits<decltype(alloc)>::allocate(alloc, 1);
|
||||
try
|
||||
{
|
||||
t = new(t) T{handler,
|
||||
@@ -38,9 +37,8 @@ P(DeducedHandler&& h, Args&&... args)
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
t, sizeof(T), std::addressof(handler));
|
||||
std::allocator_traits<
|
||||
decltype(alloc)>::deallocate(alloc, t, 1);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@@ -56,9 +54,13 @@ handler_ptr<T, Handler>::
|
||||
if(p_->t)
|
||||
{
|
||||
p_->t->~T();
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p_->t, sizeof(T), std::addressof(p_->handler));
|
||||
typename std::allocator_traits<
|
||||
boost::asio::associated_allocator_t<Handler>>::
|
||||
template rebind_alloc<T> alloc{
|
||||
boost::asio::get_associated_allocator(
|
||||
p_->handler)};
|
||||
std::allocator_traits<
|
||||
decltype(alloc)>::deallocate(alloc, p_->t, 1);
|
||||
}
|
||||
delete p_;
|
||||
}
|
||||
@@ -108,9 +110,13 @@ release_handler() ->
|
||||
BOOST_ASSERT(p_);
|
||||
BOOST_ASSERT(p_->t);
|
||||
p_->t->~T();
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p_->t, sizeof(T), std::addressof(p_->handler));
|
||||
typename std::allocator_traits<
|
||||
boost::asio::associated_allocator_t<Handler>>::
|
||||
template rebind_alloc<T> alloc{
|
||||
boost::asio::get_associated_allocator(
|
||||
p_->handler)};
|
||||
std::allocator_traits<
|
||||
decltype(alloc)>::deallocate(alloc, p_->t, 1);
|
||||
p_->t = nullptr;
|
||||
return std::move(p_->handler);
|
||||
}
|
||||
@@ -124,9 +130,13 @@ invoke(Args&&... args)
|
||||
BOOST_ASSERT(p_);
|
||||
BOOST_ASSERT(p_->t);
|
||||
p_->t->~T();
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p_->t, sizeof(T), std::addressof(p_->handler));
|
||||
typename std::allocator_traits<
|
||||
boost::asio::associated_allocator_t<Handler>>::
|
||||
template rebind_alloc<T> alloc{
|
||||
boost::asio::get_associated_allocator(
|
||||
p_->handler)};
|
||||
std::allocator_traits<
|
||||
decltype(alloc)>::deallocate(alloc, p_->t, 1);
|
||||
p_->t = nullptr;
|
||||
p_->handler(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,8 @@ std::size_t
|
||||
read_size(DynamicBuffer& buffer,
|
||||
std::size_t max_size, std::false_type)
|
||||
{
|
||||
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
BOOST_ASSERT(max_size >= 1);
|
||||
auto const size = buffer.size();
|
||||
|
||||
@@ -49,7 +49,7 @@ detail::buffers_helper<ConstBufferSequence>
|
||||
#endif
|
||||
buffers(ConstBufferSequence const& b)
|
||||
{
|
||||
static_assert(is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
return detail::buffers_helper<
|
||||
@@ -90,7 +90,8 @@ detail::ostream_helper<
|
||||
#endif
|
||||
ostream(DynamicBuffer& buffer)
|
||||
{
|
||||
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
return detail::ostream_helper<
|
||||
DynamicBuffer, char, std::char_traits<char>,
|
||||
|
||||
@@ -19,153 +19,6 @@
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// Buffer concepts
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** Determine if `T` meets the requirements of @b ConstBufferSequence.
|
||||
|
||||
Metafunctions are used to perform compile time checking of template
|
||||
types. This type will be `std::true_type` if `T` meets the requirements,
|
||||
else the type will be `std::false_type`.
|
||||
|
||||
@par Example
|
||||
|
||||
Use with `static_assert`:
|
||||
|
||||
@code
|
||||
template<class ConstBufferSequence>
|
||||
void f(ConstBufferSequence const& buffers)
|
||||
{
|
||||
static_assert(is_const_buffer_sequence<ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
...
|
||||
@endcode
|
||||
|
||||
Use with `std::enable_if` (SFINAE):
|
||||
|
||||
@code
|
||||
template<class ConstBufferSequence>
|
||||
typename std::enable_if<is_const_buffer_sequence<ConstBufferSequence>::value>::type
|
||||
f(ConstBufferSequence const& buffers);
|
||||
@endcode
|
||||
*/
|
||||
template<class T>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
struct is_const_buffer_sequence : std::integral_constant<bool, ...>
|
||||
#else
|
||||
struct is_const_buffer_sequence :
|
||||
detail::is_buffer_sequence<T, boost::asio::const_buffer>
|
||||
#endif
|
||||
{
|
||||
};
|
||||
|
||||
/** Determine if `T` meets the requirements of @b MutableBufferSequence.
|
||||
|
||||
Metafunctions are used to perform compile time checking of template
|
||||
types. This type will be `std::true_type` if `T` meets the requirements,
|
||||
else the type will be `std::false_type`.
|
||||
|
||||
@par Example
|
||||
|
||||
Use with `static_assert`:
|
||||
|
||||
@code
|
||||
template<class MutableBufferSequence>
|
||||
void f(MutableBufferSequence const& buffers)
|
||||
{
|
||||
static_assert(is_const_buffer_sequence<MutableBufferSequence>::value,
|
||||
"MutableBufferSequence requirements not met");
|
||||
...
|
||||
@endcode
|
||||
|
||||
Use with `std::enable_if` (SFINAE):
|
||||
|
||||
@code
|
||||
template<class MutableBufferSequence>
|
||||
typename std::enable_if<is_mutable_buffer_sequence<MutableBufferSequence>::value>::type
|
||||
f(MutableBufferSequence const& buffers);
|
||||
@endcode
|
||||
*/
|
||||
template<class T>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
struct is_mutable_buffer_sequence : std::integral_constant<bool, ...>
|
||||
#else
|
||||
struct is_mutable_buffer_sequence :
|
||||
detail::is_buffer_sequence<T, boost::asio::mutable_buffer>
|
||||
#endif
|
||||
{
|
||||
};
|
||||
|
||||
/** Determine if `T` meets the requirements of @b DynamicBuffer.
|
||||
|
||||
Metafunctions are used to perform compile time checking of template
|
||||
types. This type will be `std::true_type` if `T` meets the requirements,
|
||||
else the type will be `std::false_type`.
|
||||
|
||||
@par Example
|
||||
|
||||
Use with `static_assert`:
|
||||
|
||||
@code
|
||||
template<class DynamicBuffer>
|
||||
void f(DynamicBuffer& buffer)
|
||||
{
|
||||
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
...
|
||||
@endcode
|
||||
|
||||
Use with `std::enable_if` (SFINAE):
|
||||
|
||||
@code
|
||||
template<class DynamicBuffer>
|
||||
typename std::enable_if<is_dynamic_buffer<DynamicBuffer>::value>::type
|
||||
f(DynamicBuffer const& buffer);
|
||||
@endcode
|
||||
*/
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
template<class T>
|
||||
struct is_dynamic_buffer : std::integral_constant<bool, ...> {};
|
||||
#else
|
||||
template<class T, class = void>
|
||||
struct is_dynamic_buffer : std::false_type {};
|
||||
|
||||
template<class T>
|
||||
struct is_dynamic_buffer<T, detail::void_t<decltype(
|
||||
std::declval<std::size_t&>() =
|
||||
std::declval<T const&>().size(),
|
||||
std::declval<std::size_t&>() =
|
||||
std::declval<T const&>().max_size(),
|
||||
std::declval<std::size_t&>() =
|
||||
std::declval<T const&>().capacity(),
|
||||
std::declval<T&>().commit(std::declval<std::size_t>()),
|
||||
std::declval<T&>().consume(std::declval<std::size_t>()),
|
||||
(void)0)> > : std::integral_constant<bool,
|
||||
is_const_buffer_sequence<
|
||||
typename T::const_buffers_type>::value &&
|
||||
is_mutable_buffer_sequence<
|
||||
typename T::mutable_buffers_type>::value &&
|
||||
std::is_same<typename T::const_buffers_type,
|
||||
decltype(std::declval<T const&>().data())>::value &&
|
||||
std::is_same<typename T::mutable_buffers_type,
|
||||
decltype(std::declval<T&>().prepare(
|
||||
std::declval<std::size_t>()))>::value
|
||||
>
|
||||
{
|
||||
};
|
||||
|
||||
// Special case for Boost.Asio which doesn't adhere to
|
||||
// net-ts but still provides a read_size_helper so things work
|
||||
template<class Allocator>
|
||||
struct is_dynamic_buffer<
|
||||
boost::asio::basic_streambuf<Allocator>> : std::true_type
|
||||
{
|
||||
};
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// Handler concepts
|
||||
@@ -209,7 +62,7 @@ using is_completion_handler = std::integral_constant<bool,
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** Determine if `T` has the `get_io_service` member.
|
||||
/** Determine if `T` has the `get_executor` member function.
|
||||
|
||||
Metafunctions are used to perform compile time checking of template
|
||||
types. This type will be `std::true_type` if `T` has the member
|
||||
@@ -223,19 +76,24 @@ using is_completion_handler = std::integral_constant<bool,
|
||||
template<class T>
|
||||
void maybe_hello(T& t, std::true_type)
|
||||
{
|
||||
t.get_io_service().post([]{ std::cout << "Hello, world!" << std::endl; });
|
||||
boost::asio::post(
|
||||
t.get_executor(),
|
||||
[]
|
||||
{
|
||||
std::cout << "Hello, world!" << std::endl;
|
||||
});
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void maybe_hello(T&, std::false_type)
|
||||
{
|
||||
// T does not have get_io_service
|
||||
// T does not have get_executor
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void maybe_hello(T& t)
|
||||
{
|
||||
maybe_hello(t, has_get_io_service<T>{});
|
||||
maybe_hello(t, has_get_executor<T>{});
|
||||
}
|
||||
@endcode
|
||||
|
||||
@@ -244,24 +102,23 @@ using is_completion_handler = std::integral_constant<bool,
|
||||
@code
|
||||
struct stream
|
||||
{
|
||||
boost::asio::io_service& get_io_service();
|
||||
using executor_type = boost::asio::io_context::executor_type;
|
||||
executor_type get_executor() noexcept;
|
||||
};
|
||||
|
||||
static_assert(has_get_io_service<stream>::value,
|
||||
"Missing get_io_service member");
|
||||
static_assert(has_get_executor<stream>::value, "Missing get_executor member");
|
||||
@endcode
|
||||
*/
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
template<class T>
|
||||
struct has_get_io_service : std::integral_constant<bool, ...>{};
|
||||
struct has_get_executor : std::integral_constant<bool, ...>{};
|
||||
#else
|
||||
template<class T, class = void>
|
||||
struct has_get_io_service : std::false_type {};
|
||||
struct has_get_executor : std::false_type {};
|
||||
|
||||
template<class T>
|
||||
struct has_get_io_service<T, beast::detail::void_t<decltype(
|
||||
detail::accept_rv<boost::asio::io_service&>(
|
||||
std::declval<T&>().get_io_service()),
|
||||
struct has_get_executor<T, beast::detail::void_t<decltype(
|
||||
std::declval<T&>().get_executor(),
|
||||
(void)0)>> : std::true_type {};
|
||||
#endif
|
||||
|
||||
@@ -350,7 +207,7 @@ struct is_async_read_stream<T, detail::void_t<decltype(
|
||||
std::declval<detail::MutableBufferSequence>(),
|
||||
std::declval<detail::ReadHandler>()),
|
||||
(void)0)>> : std::integral_constant<bool,
|
||||
has_get_io_service<T>::value
|
||||
has_get_executor<T>::value
|
||||
> {};
|
||||
#endif
|
||||
|
||||
@@ -394,7 +251,7 @@ struct is_async_write_stream<T, detail::void_t<decltype(
|
||||
std::declval<detail::ConstBufferSequence>(),
|
||||
std::declval<detail::WriteHandler>()),
|
||||
(void)0)>> : std::integral_constant<bool,
|
||||
has_get_io_service<T>::value
|
||||
has_get_executor<T>::value
|
||||
> {};
|
||||
#endif
|
||||
|
||||
@@ -439,12 +296,10 @@ struct is_sync_read_stream<T, detail::void_t<decltype(
|
||||
std::declval<std::size_t&>() = std::declval<T>().read_some(
|
||||
std::declval<detail::MutableBufferSequence>(),
|
||||
std::declval<boost::system::error_code&>()),
|
||||
(void)0)>> : std::integral_constant<bool,
|
||||
has_get_io_service<T>::value
|
||||
> {};
|
||||
(void)0)>> : std::true_type {};
|
||||
#endif
|
||||
|
||||
/** Determine if `T` meets the requirements of @b SyncWriterStream.
|
||||
/** Determine if `T` meets the requirements of @b SyncWriteStream.
|
||||
|
||||
Metafunctions are used to perform compile time checking of template
|
||||
types. This type will be `std::true_type` if `T` meets the requirements,
|
||||
@@ -485,9 +340,7 @@ struct is_sync_write_stream<T, detail::void_t<decltype(
|
||||
std::declval<std::size_t&>() = std::declval<T&>().write_some(
|
||||
std::declval<detail::ConstBufferSequence>(),
|
||||
std::declval<boost::system::error_code&>()),
|
||||
(void)0)>> : std::integral_constant<bool,
|
||||
has_get_io_service<T>::value
|
||||
> {};
|
||||
(void)0)>> : std::true_type {};
|
||||
#endif
|
||||
|
||||
/** Determine if `T` meets the requirements of @b AsyncStream.
|
||||
|
||||
@@ -32,7 +32,8 @@ namespace http {
|
||||
template<class DynamicBuffer>
|
||||
struct basic_dynamic_body
|
||||
{
|
||||
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
|
||||
/** The type of container used for the body
|
||||
|
||||
@@ -143,7 +143,13 @@ public:
|
||||
|
||||
/** Set the open file
|
||||
|
||||
This function is used to set the open
|
||||
This function is used to set the open file. Any previously
|
||||
set file will be closed.
|
||||
|
||||
@param file The file to set. The file must be open or else
|
||||
an error occurs
|
||||
|
||||
@param ec Set to the error, if any occurred
|
||||
*/
|
||||
void
|
||||
reset(File&& file, error_code& ec);
|
||||
@@ -229,7 +235,7 @@ public:
|
||||
// The type of buffer sequence returned by `get`.
|
||||
//
|
||||
using const_buffers_type =
|
||||
boost::asio::const_buffers_1;
|
||||
boost::asio::const_buffer;
|
||||
|
||||
// Constructor.
|
||||
//
|
||||
@@ -485,13 +491,13 @@ put(ConstBufferSequence const& buffers, error_code& ec)
|
||||
|
||||
// Loop over all the buffers in the sequence,
|
||||
// and write each one to the file.
|
||||
for(boost::asio::const_buffer buffer : buffers)
|
||||
for(auto it = boost::asio::buffer_sequence_begin(buffers);
|
||||
it != boost::asio::buffer_sequence_end(buffers); ++it)
|
||||
{
|
||||
// Write this buffer to the file
|
||||
boost::asio::const_buffer buffer = *it;
|
||||
nwritten += body_.file_.write(
|
||||
boost::asio::buffer_cast<void const*>(buffer),
|
||||
boost::asio::buffer_size(buffer),
|
||||
ec);
|
||||
buffer.data(), buffer.size(), ec);
|
||||
if(ec)
|
||||
return nwritten;
|
||||
}
|
||||
|
||||
@@ -515,7 +515,7 @@ public:
|
||||
|
||||
#if ! BOOST_BEAST_DOXYGEN
|
||||
std::size_t
|
||||
put(boost::asio::const_buffers_1 const& buffer,
|
||||
put(boost::asio::const_buffer const& buffer,
|
||||
error_code& ec);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ struct buffer_body
|
||||
|
||||
public:
|
||||
using const_buffers_type =
|
||||
boost::asio::const_buffers_1;
|
||||
boost::asio::const_buffer;
|
||||
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
|
||||
@@ -106,7 +106,7 @@ class chunk_header
|
||||
{
|
||||
using view_type = buffers_cat_view<
|
||||
detail::chunk_size, // chunk-size
|
||||
boost::asio::const_buffers_1, // chunk-extensions
|
||||
boost::asio::const_buffer, // chunk-extensions
|
||||
chunk_crlf>; // CRLF
|
||||
|
||||
std::shared_ptr<
|
||||
@@ -285,7 +285,7 @@ class chunk_body
|
||||
{
|
||||
using view_type = buffers_cat_view<
|
||||
detail::chunk_size, // chunk-size
|
||||
boost::asio::const_buffers_1, // chunk-extensions
|
||||
boost::asio::const_buffer, // chunk-extensions
|
||||
chunk_crlf, // CRLF
|
||||
ConstBufferSequence, // chunk-body
|
||||
chunk_crlf>; // CRLF
|
||||
@@ -459,7 +459,7 @@ class chunk_last
|
||||
{
|
||||
static_assert(
|
||||
is_fields<Trailer>::value ||
|
||||
is_const_buffer_sequence<Trailer>::value,
|
||||
boost::asio::is_const_buffer_sequence<Trailer>::value,
|
||||
"Trailer requirements not met");
|
||||
|
||||
using buffers_type = typename
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace detail {
|
||||
struct chunk_extensions
|
||||
{
|
||||
virtual ~chunk_extensions() = default;
|
||||
virtual boost::asio::const_buffers_1 str() = 0;
|
||||
virtual boost::asio::const_buffer str() = 0;
|
||||
};
|
||||
|
||||
template<class ChunkExtensions>
|
||||
@@ -43,7 +43,7 @@ struct chunk_extensions_impl : chunk_extensions
|
||||
{
|
||||
}
|
||||
|
||||
boost::asio::const_buffers_1
|
||||
boost::asio::const_buffer
|
||||
str() override
|
||||
{
|
||||
auto const s = ext_.str();
|
||||
@@ -151,7 +151,7 @@ prepare(std::size_t n)
|
||||
|
||||
/// Returns a buffer sequence holding a CRLF for chunk encoding
|
||||
inline
|
||||
boost::asio::const_buffers_1
|
||||
boost::asio::const_buffer
|
||||
chunk_crlf()
|
||||
{
|
||||
return {"\r\n", 2};
|
||||
@@ -159,7 +159,7 @@ chunk_crlf()
|
||||
|
||||
/// Returns a buffer sequence holding a final chunk header
|
||||
inline
|
||||
boost::asio::const_buffers_1
|
||||
boost::asio::const_buffer
|
||||
chunk_last()
|
||||
{
|
||||
return {"0\r\n", 3};
|
||||
|
||||
@@ -103,14 +103,13 @@ basic_parser<isRequest, Derived>::
|
||||
put(ConstBufferSequence const& buffers,
|
||||
error_code& ec)
|
||||
{
|
||||
static_assert(is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
using boost::asio::buffer_cast;
|
||||
using boost::asio::buffer_copy;
|
||||
using boost::asio::buffer_size;
|
||||
auto const p = buffers.begin();
|
||||
auto const last = buffers.end();
|
||||
auto const p = boost::asio::buffer_sequence_begin(buffers);
|
||||
auto const last = boost::asio::buffer_sequence_end(buffers);
|
||||
if(p == last)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
@@ -119,10 +118,7 @@ put(ConstBufferSequence const& buffers,
|
||||
if(std::next(p) == last)
|
||||
{
|
||||
// single buffer
|
||||
auto const b = *p;
|
||||
return put(boost::asio::const_buffers_1{
|
||||
buffer_cast<char const*>(b),
|
||||
buffer_size(b)}, ec);
|
||||
return put(boost::asio::const_buffer(*p), ec);
|
||||
}
|
||||
auto const size = buffer_size(buffers);
|
||||
if(size <= max_stack_buffer)
|
||||
@@ -136,21 +132,21 @@ put(ConstBufferSequence const& buffers,
|
||||
// flatten
|
||||
buffer_copy(boost::asio::buffer(
|
||||
buf_.get(), buf_len_), buffers);
|
||||
return put(boost::asio::const_buffers_1{
|
||||
return put(boost::asio::const_buffer{
|
||||
buf_.get(), buf_len_}, ec);
|
||||
}
|
||||
|
||||
template<bool isRequest, class Derived>
|
||||
std::size_t
|
||||
basic_parser<isRequest, Derived>::
|
||||
put(boost::asio::const_buffers_1 const& buffer,
|
||||
put(boost::asio::const_buffer const& buffer,
|
||||
error_code& ec)
|
||||
{
|
||||
BOOST_ASSERT(state_ != state::complete);
|
||||
using boost::asio::buffer_size;
|
||||
auto p = boost::asio::buffer_cast<
|
||||
char const*>(*buffer.begin());
|
||||
auto n = buffer_size(*buffer.begin());
|
||||
auto p = reinterpret_cast<
|
||||
char const*>(buffer.data());
|
||||
auto n = buffer.size();
|
||||
auto const p0 = p;
|
||||
auto const p1 = p0 + n;
|
||||
ec.assign(0, ec.category());
|
||||
@@ -324,7 +320,7 @@ put_from_stack(std::size_t size,
|
||||
using boost::asio::buffer;
|
||||
using boost::asio::buffer_copy;
|
||||
buffer_copy(buffer(buf, sizeof(buf)), buffers);
|
||||
return put(boost::asio::const_buffers_1{
|
||||
return put(boost::asio::const_buffer{
|
||||
buf, size}, ec);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ chunk_header::
|
||||
chunk_header(std::size_t size)
|
||||
: view_(
|
||||
size,
|
||||
boost::asio::const_buffers_1{nullptr, 0},
|
||||
boost::asio::const_buffer{nullptr, 0},
|
||||
chunk_crlf{})
|
||||
{
|
||||
BOOST_ASSERT(size > 0);
|
||||
@@ -37,7 +37,7 @@ chunk_header(
|
||||
string_view extensions)
|
||||
: view_(
|
||||
size,
|
||||
boost::asio::const_buffers_1{
|
||||
boost::asio::const_buffer{
|
||||
extensions.data(), extensions.size()},
|
||||
chunk_crlf{})
|
||||
{
|
||||
@@ -90,7 +90,7 @@ chunk_body<ConstBufferSequence>::
|
||||
chunk_body(ConstBufferSequence const& buffers)
|
||||
: view_(
|
||||
boost::asio::buffer_size(buffers),
|
||||
boost::asio::const_buffers_1{nullptr, 0},
|
||||
boost::asio::const_buffer{nullptr, 0},
|
||||
chunk_crlf{},
|
||||
buffers,
|
||||
chunk_crlf{})
|
||||
@@ -104,7 +104,7 @@ chunk_body(
|
||||
string_view extensions)
|
||||
: view_(
|
||||
boost::asio::buffer_size(buffers),
|
||||
boost::asio::const_buffers_1{
|
||||
boost::asio::const_buffer{
|
||||
extensions.data(), extensions.size()},
|
||||
chunk_crlf{},
|
||||
buffers,
|
||||
|
||||
@@ -143,9 +143,9 @@ public:
|
||||
};
|
||||
|
||||
using view_type = buffers_cat_view<
|
||||
boost::asio::const_buffers_1,
|
||||
boost::asio::const_buffers_1,
|
||||
boost::asio::const_buffers_1,
|
||||
boost::asio::const_buffer,
|
||||
boost::asio::const_buffer,
|
||||
boost::asio::const_buffer,
|
||||
field_range,
|
||||
chunk_crlf>;
|
||||
|
||||
@@ -178,9 +178,9 @@ reader(basic_fields const& f)
|
||||
: f_(f)
|
||||
{
|
||||
view_.emplace(
|
||||
boost::asio::const_buffers_1{nullptr, 0},
|
||||
boost::asio::const_buffers_1{nullptr, 0},
|
||||
boost::asio::const_buffers_1{nullptr, 0},
|
||||
boost::asio::const_buffer{nullptr, 0},
|
||||
boost::asio::const_buffer{nullptr, 0},
|
||||
boost::asio::const_buffer{nullptr, 0},
|
||||
field_range(f_.list_.begin(), f_.list_.end()),
|
||||
chunk_crlf());
|
||||
}
|
||||
@@ -218,11 +218,11 @@ reader(basic_fields const& f,
|
||||
buf_[10]= '\n';
|
||||
|
||||
view_.emplace(
|
||||
boost::asio::const_buffers_1{sv.data(), sv.size()},
|
||||
boost::asio::const_buffers_1{
|
||||
boost::asio::const_buffer{sv.data(), sv.size()},
|
||||
boost::asio::const_buffer{
|
||||
f_.target_or_reason_.data(),
|
||||
f_.target_or_reason_.size()},
|
||||
boost::asio::const_buffers_1{buf_, 11},
|
||||
boost::asio::const_buffer{buf_, 11},
|
||||
field_range(f_.list_.begin(), f_.list_.end()),
|
||||
chunk_crlf());
|
||||
}
|
||||
@@ -260,9 +260,9 @@ reader(basic_fields const& f,
|
||||
sv = obsolete_reason(static_cast<status>(code));
|
||||
|
||||
view_.emplace(
|
||||
boost::asio::const_buffers_1{buf_, 13},
|
||||
boost::asio::const_buffers_1{sv.data(), sv.size()},
|
||||
boost::asio::const_buffers_1{"\r\n", 2},
|
||||
boost::asio::const_buffer{buf_, 13},
|
||||
boost::asio::const_buffer{sv.data(), sv.size()},
|
||||
boost::asio::const_buffer{"\r\n", 2},
|
||||
field_range(f_.list_.begin(), f_.list_.end()),
|
||||
chunk_crlf{});
|
||||
}
|
||||
|
||||
@@ -12,15 +12,15 @@
|
||||
|
||||
#if BOOST_BEAST_USE_WIN32_FILE
|
||||
|
||||
#include <boost/beast/core/async_result.hpp>
|
||||
#include <boost/beast/core/bind_handler.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/beast/core/detail/clamp.hpp>
|
||||
#include <boost/beast/http/serializer.hpp>
|
||||
#include <boost/asio/associated_allocator.hpp>
|
||||
#include <boost/asio/associated_executor.hpp>
|
||||
#include <boost/asio/async_result.hpp>
|
||||
#include <boost/asio/basic_stream_socket.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/asio/windows/overlapped_ptr.hpp>
|
||||
#include <boost/make_unique.hpp>
|
||||
#include <boost/smart_ptr/make_shared_array.hpp>
|
||||
@@ -120,7 +120,7 @@ struct basic_file_body<file_win32>
|
||||
|
||||
public:
|
||||
using const_buffers_type =
|
||||
boost::asio::const_buffers_1;
|
||||
boost::asio::const_buffer;
|
||||
|
||||
template<bool isRequest, class Fields>
|
||||
reader(message<isRequest,
|
||||
@@ -189,12 +189,10 @@ struct basic_file_body<file_win32>
|
||||
error_code& ec)
|
||||
{
|
||||
std::size_t nwritten = 0;
|
||||
for(boost::asio::const_buffer buffer : buffers)
|
||||
for(auto buffer : beast::detail::buffers_range(buffers))
|
||||
{
|
||||
nwritten += body_.file_.write(
|
||||
boost::asio::buffer_cast<void const*>(buffer),
|
||||
boost::asio::buffer_size(buffer),
|
||||
ec);
|
||||
buffer.data(), buffer.size(), ec);
|
||||
if(ec)
|
||||
return nwritten;
|
||||
}
|
||||
@@ -360,6 +358,24 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
using allocator_type =
|
||||
boost::asio::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_allocator(h_);
|
||||
}
|
||||
|
||||
using executor_type = boost::asio::associated_executor_t<
|
||||
Handler, decltype(sock_.get_executor())>;
|
||||
|
||||
executor_type get_executor() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_executor(
|
||||
h_, sock_.get_executor());
|
||||
}
|
||||
|
||||
void
|
||||
operator()();
|
||||
|
||||
@@ -368,24 +384,6 @@ public:
|
||||
error_code ec,
|
||||
std::size_t bytes_transferred = 0);
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, write_some_win32_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
void asio_handler_deallocate(
|
||||
void* p, std::size_t size, write_some_win32_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(write_some_win32_op* op)
|
||||
{
|
||||
@@ -393,15 +391,6 @@ public:
|
||||
return asio_handler_is_continuation(
|
||||
std::addressof(op->h_));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, write_some_win32_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(
|
||||
f, std::addressof(op->h_));
|
||||
}
|
||||
};
|
||||
|
||||
template<
|
||||
@@ -431,7 +420,7 @@ operator()()
|
||||
r.body_.last_ - r.pos_, sr_.limit())),
|
||||
2147483646);
|
||||
boost::asio::windows::overlapped_ptr overlapped{
|
||||
sock_.get_io_service(), *this};
|
||||
sock_.get_executor().context(), *this};
|
||||
auto& ov = *overlapped.get();
|
||||
ov.Offset = lowPart(r.pos_);
|
||||
ov.OffsetHigh = highPart(r.pos_);
|
||||
@@ -567,21 +556,20 @@ template<
|
||||
class Protocol,
|
||||
bool isRequest, class Fields,
|
||||
class WriteHandler>
|
||||
async_return_type<
|
||||
WriteHandler,
|
||||
void(error_code, std::size_t)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
WriteHandler, void(error_code, std::size_t))
|
||||
async_write_some(
|
||||
boost::asio::basic_stream_socket<Protocol>& sock,
|
||||
serializer<isRequest,
|
||||
basic_file_body<file_win32>, Fields>& sr,
|
||||
WriteHandler&& handler)
|
||||
{
|
||||
async_completion<WriteHandler,
|
||||
boost::asio::async_completion<WriteHandler,
|
||||
void(error_code)> init{handler};
|
||||
detail::write_some_win32_op<
|
||||
Protocol,
|
||||
handler_type<WriteHandler,
|
||||
void(error_code, std::size_t)>,
|
||||
BOOST_ASIO_HANDLER_TYPE(WriteHandler,
|
||||
void(error_code, std::size_t)),
|
||||
isRequest, Fields>{
|
||||
init.completion_handler, sock, sr}();
|
||||
return init.result.get();
|
||||
|
||||
@@ -18,9 +18,10 @@
|
||||
#include <boost/beast/core/handler_ptr.hpp>
|
||||
#include <boost/beast/core/read_size.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/associated_allocator.hpp>
|
||||
#include <boost/asio/associated_executor.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/asio/post.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
@@ -61,29 +62,29 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
using allocator_type =
|
||||
boost::asio::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_allocator(h_);
|
||||
}
|
||||
|
||||
using executor_type = boost::asio::associated_executor_t<
|
||||
Handler, decltype(s_.get_executor())>;
|
||||
|
||||
executor_type get_executor() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_executor(
|
||||
h_, s_.get_executor());
|
||||
}
|
||||
|
||||
void
|
||||
operator()(
|
||||
error_code ec = {},
|
||||
std::size_t bytes_transferred = 0);
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, read_some_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
void asio_handler_deallocate(
|
||||
void* p, std::size_t size, read_some_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(read_some_op* op)
|
||||
{
|
||||
@@ -92,15 +93,6 @@ public:
|
||||
asio_handler_is_continuation(
|
||||
std::addressof(op->h_));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, read_some_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(
|
||||
f, std::addressof(op->h_));
|
||||
}
|
||||
};
|
||||
|
||||
template<class Stream, class DynamicBuffer,
|
||||
@@ -170,7 +162,8 @@ operator()(
|
||||
if(state_ >= 2)
|
||||
goto upcall;
|
||||
state_ = 3;
|
||||
return s_.get_io_service().post(
|
||||
return boost::asio::post(
|
||||
s_.get_executor(),
|
||||
bind_handler(std::move(*this), ec, 0));
|
||||
|
||||
case 3:
|
||||
@@ -231,29 +224,29 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
using allocator_type =
|
||||
boost::asio::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_allocator(h_);
|
||||
}
|
||||
|
||||
using executor_type = boost::asio::associated_executor_t<
|
||||
Handler, decltype(s_.get_executor())>;
|
||||
|
||||
executor_type get_executor() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_executor(
|
||||
h_, s_.get_executor());
|
||||
}
|
||||
|
||||
void
|
||||
operator()(
|
||||
error_code ec = {},
|
||||
std::size_t bytes_transferred = 0);
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, read_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
void asio_handler_deallocate(
|
||||
void* p, std::size_t size, read_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(read_op* op)
|
||||
{
|
||||
@@ -262,15 +255,6 @@ public:
|
||||
asio_handler_is_continuation(
|
||||
std::addressof(op->h_));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, read_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(
|
||||
f, std::addressof(op->h_));
|
||||
}
|
||||
};
|
||||
|
||||
template<class Stream, class DynamicBuffer,
|
||||
@@ -289,7 +273,8 @@ operator()(
|
||||
if(Condition{}(p_))
|
||||
{
|
||||
state_ = 1;
|
||||
return s_.get_io_service().post(
|
||||
return boost::asio::post(
|
||||
s_.get_executor(),
|
||||
bind_handler(std::move(*this), ec));
|
||||
}
|
||||
state_ = 2;
|
||||
@@ -361,29 +346,29 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
using allocator_type =
|
||||
boost::asio::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_allocator(d_.handler());
|
||||
}
|
||||
|
||||
using executor_type = boost::asio::associated_executor_t<
|
||||
Handler, decltype(d_->s.get_executor())>;
|
||||
|
||||
executor_type get_executor() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_executor(
|
||||
d_.handler(), d_->s.get_executor());
|
||||
}
|
||||
|
||||
void
|
||||
operator()(
|
||||
error_code ec = {},
|
||||
std::size_t bytes_transferred = 0);
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, read_msg_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
friend
|
||||
void asio_handler_deallocate(
|
||||
void* p, std::size_t size, read_msg_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(read_msg_op* op)
|
||||
{
|
||||
@@ -392,15 +377,6 @@ public:
|
||||
asio_handler_is_continuation(
|
||||
std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, read_msg_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(
|
||||
f, std::addressof(op->d_.handler()));
|
||||
}
|
||||
};
|
||||
|
||||
template<class Stream, class DynamicBuffer,
|
||||
@@ -458,7 +434,8 @@ read_some(
|
||||
{
|
||||
static_assert(is_sync_read_stream<SyncReadStream>::value,
|
||||
"SyncReadStream requirements not met");
|
||||
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
BOOST_ASSERT(! parser.is_done());
|
||||
error_code ec;
|
||||
@@ -482,7 +459,8 @@ read_some(
|
||||
{
|
||||
static_assert(is_sync_read_stream<SyncReadStream>::value,
|
||||
"SyncReadStream requirements not met");
|
||||
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
BOOST_ASSERT(! parser.is_done());
|
||||
std::size_t bytes_transferred = 0;
|
||||
@@ -541,8 +519,8 @@ template<
|
||||
class DynamicBuffer,
|
||||
bool isRequest, class Derived,
|
||||
class ReadHandler>
|
||||
async_return_type<
|
||||
ReadHandler, void(error_code, std::size_t)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
ReadHandler, void(error_code, std::size_t))
|
||||
async_read_some(
|
||||
AsyncReadStream& stream,
|
||||
DynamicBuffer& buffer,
|
||||
@@ -551,13 +529,14 @@ async_read_some(
|
||||
{
|
||||
static_assert(is_async_read_stream<AsyncReadStream>::value,
|
||||
"AsyncReadStream requirements not met");
|
||||
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
BOOST_ASSERT(! parser.is_done());
|
||||
async_completion<ReadHandler, void(error_code)> init{handler};
|
||||
boost::asio::async_completion<ReadHandler, void(error_code)> init{handler};
|
||||
detail::read_some_op<AsyncReadStream,
|
||||
DynamicBuffer, isRequest, Derived, handler_type<
|
||||
ReadHandler, void(error_code, std::size_t)>>{
|
||||
DynamicBuffer, isRequest, Derived, BOOST_ASIO_HANDLER_TYPE(
|
||||
ReadHandler, void(error_code, std::size_t))>{
|
||||
init.completion_handler, stream, buffer, parser}();
|
||||
return init.result.get();
|
||||
}
|
||||
@@ -576,7 +555,8 @@ read_header(
|
||||
{
|
||||
static_assert(is_sync_read_stream<SyncReadStream>::value,
|
||||
"SyncReadStream requirements not met");
|
||||
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
error_code ec;
|
||||
auto const bytes_transferred =
|
||||
@@ -599,7 +579,8 @@ read_header(
|
||||
{
|
||||
static_assert(is_sync_read_stream<SyncReadStream>::value,
|
||||
"SyncReadStream requirements not met");
|
||||
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
parser.eager(false);
|
||||
if(parser.is_header_done())
|
||||
@@ -624,9 +605,8 @@ template<
|
||||
class DynamicBuffer,
|
||||
bool isRequest, class Derived,
|
||||
class ReadHandler>
|
||||
async_return_type<
|
||||
ReadHandler,
|
||||
void(error_code, std::size_t)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
ReadHandler, void(error_code, std::size_t))
|
||||
async_read_header(
|
||||
AsyncReadStream& stream,
|
||||
DynamicBuffer& buffer,
|
||||
@@ -635,14 +615,15 @@ async_read_header(
|
||||
{
|
||||
static_assert(is_async_read_stream<AsyncReadStream>::value,
|
||||
"AsyncReadStream requirements not met");
|
||||
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
parser.eager(false);
|
||||
async_completion<ReadHandler,
|
||||
boost::asio::async_completion<ReadHandler,
|
||||
void(error_code, std::size_t)> init{handler};
|
||||
detail::read_op<AsyncReadStream, DynamicBuffer,
|
||||
isRequest, Derived, detail::parser_is_header_done,
|
||||
handler_type<ReadHandler, void(error_code, std::size_t)>>{
|
||||
BOOST_ASIO_HANDLER_TYPE(ReadHandler, void(error_code, std::size_t))>{
|
||||
init.completion_handler, stream, buffer, parser}();
|
||||
return init.result.get();
|
||||
}
|
||||
@@ -661,7 +642,8 @@ read(
|
||||
{
|
||||
static_assert(is_sync_read_stream<SyncReadStream>::value,
|
||||
"SyncReadStream requirements not met");
|
||||
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
error_code ec;
|
||||
auto const bytes_transferred =
|
||||
@@ -684,7 +666,8 @@ read(
|
||||
{
|
||||
static_assert(is_sync_read_stream<SyncReadStream>::value,
|
||||
"SyncReadStream requirements not met");
|
||||
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
parser.eager(true);
|
||||
if(parser.is_done())
|
||||
@@ -709,9 +692,8 @@ template<
|
||||
class DynamicBuffer,
|
||||
bool isRequest, class Derived,
|
||||
class ReadHandler>
|
||||
async_return_type<
|
||||
ReadHandler,
|
||||
void(error_code, std::size_t)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
ReadHandler, void(error_code, std::size_t))
|
||||
async_read(
|
||||
AsyncReadStream& stream,
|
||||
DynamicBuffer& buffer,
|
||||
@@ -720,15 +702,16 @@ async_read(
|
||||
{
|
||||
static_assert(is_async_read_stream<AsyncReadStream>::value,
|
||||
"AsyncReadStream requirements not met");
|
||||
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
parser.eager(true);
|
||||
async_completion<
|
||||
boost::asio::async_completion<
|
||||
ReadHandler,
|
||||
void(error_code, std::size_t)> init{handler};
|
||||
detail::read_op<AsyncReadStream, DynamicBuffer,
|
||||
isRequest, Derived, detail::parser_is_done,
|
||||
handler_type<ReadHandler, void(error_code, std::size_t)>>{
|
||||
BOOST_ASIO_HANDLER_TYPE(ReadHandler, void(error_code, std::size_t))>{
|
||||
init.completion_handler, stream, buffer, parser}();
|
||||
return init.result.get();
|
||||
}
|
||||
@@ -747,7 +730,8 @@ read(
|
||||
{
|
||||
static_assert(is_sync_read_stream<SyncReadStream>::value,
|
||||
"SyncReadStream requirements not met");
|
||||
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
static_assert(is_body<Body>::value,
|
||||
"Body requirements not met");
|
||||
@@ -774,7 +758,8 @@ read(
|
||||
{
|
||||
static_assert(is_sync_read_stream<SyncReadStream>::value,
|
||||
"SyncReadStream requirements not met");
|
||||
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
static_assert(is_body<Body>::value,
|
||||
"Body requirements not met");
|
||||
@@ -795,9 +780,8 @@ template<
|
||||
class DynamicBuffer,
|
||||
bool isRequest, class Body, class Allocator,
|
||||
class ReadHandler>
|
||||
async_return_type<
|
||||
ReadHandler,
|
||||
void(error_code, std::size_t)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
ReadHandler, void(error_code, std::size_t))
|
||||
async_read(
|
||||
AsyncReadStream& stream,
|
||||
DynamicBuffer& buffer,
|
||||
@@ -806,21 +790,22 @@ async_read(
|
||||
{
|
||||
static_assert(is_async_read_stream<AsyncReadStream>::value,
|
||||
"AsyncReadStream requirements not met");
|
||||
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
static_assert(is_body<Body>::value,
|
||||
"Body requirements not met");
|
||||
static_assert(is_body_writer<Body>::value,
|
||||
"BodyWriter requirements not met");
|
||||
async_completion<
|
||||
boost::asio::async_completion<
|
||||
ReadHandler,
|
||||
void(error_code, std::size_t)> init{handler};
|
||||
detail::read_msg_op<
|
||||
AsyncReadStream,
|
||||
DynamicBuffer,
|
||||
isRequest, Body, Allocator,
|
||||
handler_type<ReadHandler,
|
||||
void(error_code, std::size_t)>>{
|
||||
BOOST_ASIO_HANDLER_TYPE(
|
||||
ReadHandler, void(error_code, std::size_t))>{
|
||||
init.completion_handler, stream, buffer, msg}();
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
@@ -166,12 +166,12 @@ next(error_code& ec, Visit&& visit)
|
||||
boost::in_place_init,
|
||||
frd_->get(),
|
||||
buffer_size(result->first),
|
||||
boost::asio::const_buffers_1{nullptr, 0},
|
||||
boost::asio::const_buffer{nullptr, 0},
|
||||
chunk_crlf{},
|
||||
result->first,
|
||||
chunk_crlf{},
|
||||
detail::chunk_last(),
|
||||
boost::asio::const_buffers_1{nullptr, 0},
|
||||
boost::asio::const_buffer{nullptr, 0},
|
||||
chunk_crlf{});
|
||||
goto go_all_c;
|
||||
}
|
||||
@@ -179,7 +179,7 @@ next(error_code& ec, Visit&& visit)
|
||||
boost::in_place_init,
|
||||
frd_->get(),
|
||||
buffer_size(result->first),
|
||||
boost::asio::const_buffers_1{nullptr, 0},
|
||||
boost::asio::const_buffer{nullptr, 0},
|
||||
chunk_crlf{},
|
||||
result->first,
|
||||
chunk_crlf{});
|
||||
@@ -216,19 +216,19 @@ next(error_code& ec, Visit&& visit)
|
||||
v_.template emplace<6>(
|
||||
boost::in_place_init,
|
||||
buffer_size(result->first),
|
||||
boost::asio::const_buffers_1{nullptr, 0},
|
||||
boost::asio::const_buffer{nullptr, 0},
|
||||
chunk_crlf{},
|
||||
result->first,
|
||||
chunk_crlf{},
|
||||
detail::chunk_last(),
|
||||
boost::asio::const_buffers_1{nullptr, 0},
|
||||
boost::asio::const_buffer{nullptr, 0},
|
||||
chunk_crlf{});
|
||||
goto go_body_final_c;
|
||||
}
|
||||
v_.template emplace<5>(
|
||||
boost::in_place_init,
|
||||
buffer_size(result->first),
|
||||
boost::asio::const_buffers_1{nullptr, 0},
|
||||
boost::asio::const_buffer{nullptr, 0},
|
||||
chunk_crlf{},
|
||||
result->first,
|
||||
chunk_crlf{});
|
||||
@@ -257,7 +257,7 @@ next(error_code& ec, Visit&& visit)
|
||||
v_.template emplace<8>(
|
||||
boost::in_place_init,
|
||||
detail::chunk_last(),
|
||||
boost::asio::const_buffers_1{nullptr, 0},
|
||||
boost::asio::const_buffer{nullptr, 0},
|
||||
chunk_crlf{});
|
||||
s_ = do_final_c + 1;
|
||||
BOOST_BEAST_FALLTHROUGH;
|
||||
|
||||
@@ -16,9 +16,10 @@
|
||||
#include <boost/beast/core/handler_ptr.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/beast/core/detail/config.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/associated_allocator.hpp>
|
||||
#include <boost/asio/associated_executor.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/asio/post.hpp>
|
||||
#include <boost/asio/write.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
@@ -77,6 +78,24 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
using allocator_type =
|
||||
boost::asio::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_allocator(h_);
|
||||
}
|
||||
|
||||
using executor_type = boost::asio::associated_executor_t<
|
||||
Handler, decltype(s_.get_executor())>;
|
||||
|
||||
executor_type get_executor() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_executor(
|
||||
h_, s_.get_executor());
|
||||
}
|
||||
|
||||
void
|
||||
operator()();
|
||||
|
||||
@@ -85,24 +104,6 @@ public:
|
||||
error_code ec,
|
||||
std::size_t bytes_transferred);
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, write_some_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
void asio_handler_deallocate(
|
||||
void* p, std::size_t size, write_some_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(write_some_op* op)
|
||||
{
|
||||
@@ -110,14 +111,6 @@ public:
|
||||
return asio_handler_is_continuation(
|
||||
std::addressof(op->h_));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, write_some_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(f, std::addressof(op->h_));
|
||||
}
|
||||
};
|
||||
|
||||
template<
|
||||
@@ -136,7 +129,8 @@ operator()()
|
||||
if(ec)
|
||||
{
|
||||
BOOST_ASSERT(! f.invoked);
|
||||
return s_.get_io_service().post(
|
||||
return boost::asio::post(
|
||||
s_.get_executor(),
|
||||
bind_handler(std::move(*this), ec, 0));
|
||||
}
|
||||
if(f.invoked)
|
||||
@@ -148,7 +142,8 @@ operator()()
|
||||
// What else could it be?
|
||||
BOOST_ASSERT(sr_.is_done());
|
||||
}
|
||||
return s_.get_io_service().post(
|
||||
return boost::asio::post(
|
||||
s_.get_executor(),
|
||||
bind_handler(std::move(*this), ec, 0));
|
||||
}
|
||||
|
||||
@@ -218,29 +213,29 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
using allocator_type =
|
||||
boost::asio::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_allocator(h_);
|
||||
}
|
||||
|
||||
using executor_type = boost::asio::associated_executor_t<
|
||||
Handler, decltype(s_.get_executor())>;
|
||||
|
||||
executor_type get_executor() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_executor(
|
||||
h_, s_.get_executor());
|
||||
}
|
||||
|
||||
void
|
||||
operator()(
|
||||
error_code ec = {},
|
||||
std::size_t bytes_transferred = 0);
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, write_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
void asio_handler_deallocate(
|
||||
void* p, std::size_t size, write_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(write_op* op)
|
||||
{
|
||||
@@ -249,15 +244,6 @@ public:
|
||||
asio_handler_is_continuation(
|
||||
std::addressof(op->h_));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, write_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(
|
||||
f, std::addressof(op->h_));
|
||||
}
|
||||
};
|
||||
|
||||
template<
|
||||
@@ -278,7 +264,8 @@ operator()(
|
||||
if(Predicate{}(sr_))
|
||||
{
|
||||
state_ = 1;
|
||||
return s_.get_io_service().post(
|
||||
return boost::asio::post(
|
||||
s_.get_executor(),
|
||||
bind_handler(std::move(*this), ec, 0));
|
||||
}
|
||||
state_ = 2;
|
||||
@@ -338,6 +325,24 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
using allocator_type =
|
||||
boost::asio::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_allocator(d_.handler());
|
||||
}
|
||||
|
||||
using executor_type = boost::asio::associated_executor_t<
|
||||
Handler, decltype(d_->s.get_executor())>;
|
||||
|
||||
executor_type get_executor() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_executor(
|
||||
d_.handler(), d_->s.get_executor());
|
||||
}
|
||||
|
||||
void
|
||||
operator()();
|
||||
|
||||
@@ -345,24 +350,6 @@ public:
|
||||
operator()(
|
||||
error_code ec, std::size_t bytes_transferred);
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, write_msg_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
friend
|
||||
void asio_handler_deallocate(
|
||||
void* p, std::size_t size, write_msg_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(write_msg_op* op)
|
||||
{
|
||||
@@ -370,15 +357,6 @@ public:
|
||||
return asio_handler_is_continuation(
|
||||
std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, write_msg_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(
|
||||
f, std::addressof(op->d_.handler()));
|
||||
}
|
||||
};
|
||||
|
||||
template<class Stream, class Handler,
|
||||
@@ -483,21 +461,20 @@ template<
|
||||
class AsyncWriteStream,
|
||||
bool isRequest, class Body, class Fields,
|
||||
class WriteHandler>
|
||||
async_return_type<
|
||||
WriteHandler,
|
||||
void(error_code, std::size_t)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
WriteHandler, void(error_code, std::size_t))
|
||||
async_write_some(
|
||||
AsyncWriteStream& stream,
|
||||
serializer<isRequest, Body, Fields>& sr,
|
||||
WriteHandler&& handler)
|
||||
{
|
||||
async_completion<
|
||||
boost::asio::async_completion<
|
||||
WriteHandler,
|
||||
void(error_code, std::size_t)> init{handler};
|
||||
detail::write_some_op<
|
||||
AsyncWriteStream,
|
||||
handler_type<WriteHandler,
|
||||
void(error_code, std::size_t)>,
|
||||
BOOST_ASIO_HANDLER_TYPE(WriteHandler,
|
||||
void(error_code, std::size_t)),
|
||||
isRequest, Body, Fields>{
|
||||
init.completion_handler, stream, sr}();
|
||||
return init.result.get();
|
||||
@@ -551,9 +528,8 @@ template<
|
||||
class AsyncWriteStream,
|
||||
bool isRequest, class Body, class Fields,
|
||||
class WriteHandler>
|
||||
async_return_type<
|
||||
WriteHandler,
|
||||
void(error_code, std::size_t)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
WriteHandler, void(error_code, std::size_t))
|
||||
async_write_some(
|
||||
AsyncWriteStream& stream,
|
||||
serializer<isRequest, Body, Fields>& sr,
|
||||
@@ -635,9 +611,8 @@ template<
|
||||
class AsyncWriteStream,
|
||||
bool isRequest, class Body, class Fields,
|
||||
class WriteHandler>
|
||||
async_return_type<
|
||||
WriteHandler,
|
||||
void(error_code, std::size_t)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
WriteHandler, void(error_code, std::size_t))
|
||||
async_write_header(
|
||||
AsyncWriteStream& stream,
|
||||
serializer<isRequest, Body, Fields>& sr,
|
||||
@@ -651,13 +626,13 @@ async_write_header(
|
||||
static_assert(is_body_reader<Body>::value,
|
||||
"BodyReader requirements not met");
|
||||
sr.split(true);
|
||||
async_completion<
|
||||
boost::asio::async_completion<
|
||||
WriteHandler,
|
||||
void(error_code, std::size_t)> init{handler};
|
||||
detail::write_op<
|
||||
AsyncWriteStream,
|
||||
handler_type<WriteHandler,
|
||||
void(error_code, std::size_t)>,
|
||||
BOOST_ASIO_HANDLER_TYPE(WriteHandler,
|
||||
void(error_code, std::size_t)),
|
||||
detail::serializer_is_header_done,
|
||||
isRequest, Body, Fields>{
|
||||
init.completion_handler, stream, sr}();
|
||||
@@ -713,9 +688,8 @@ template<
|
||||
class AsyncWriteStream,
|
||||
bool isRequest, class Body, class Fields,
|
||||
class WriteHandler>
|
||||
async_return_type<
|
||||
WriteHandler,
|
||||
void(error_code, std::size_t)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
WriteHandler, void(error_code, std::size_t))
|
||||
async_write(
|
||||
AsyncWriteStream& stream,
|
||||
serializer<isRequest, Body, Fields>& sr,
|
||||
@@ -729,13 +703,13 @@ async_write(
|
||||
static_assert(is_body_reader<Body>::value,
|
||||
"BodyReader requirements not met");
|
||||
sr.split(false);
|
||||
async_completion<
|
||||
boost::asio::async_completion<
|
||||
WriteHandler,
|
||||
void(error_code, std::size_t)> init{handler};
|
||||
detail::write_op<
|
||||
AsyncWriteStream,
|
||||
handler_type<WriteHandler,
|
||||
void(error_code, std::size_t)>,
|
||||
BOOST_ASIO_HANDLER_TYPE(WriteHandler,
|
||||
void(error_code, std::size_t)),
|
||||
detail::serializer_is_done,
|
||||
isRequest, Body, Fields>{
|
||||
init.completion_handler, stream, sr}();
|
||||
@@ -789,9 +763,8 @@ template<
|
||||
class AsyncWriteStream,
|
||||
bool isRequest, class Body, class Fields,
|
||||
class WriteHandler>
|
||||
async_return_type<
|
||||
WriteHandler,
|
||||
void(error_code, std::size_t)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
WriteHandler, void(error_code, std::size_t))
|
||||
async_write(
|
||||
AsyncWriteStream& stream,
|
||||
message<isRequest, Body, Fields>& msg,
|
||||
@@ -804,13 +777,13 @@ async_write(
|
||||
"Body requirements not met");
|
||||
static_assert(is_body_reader<Body>::value,
|
||||
"BodyReader requirements not met");
|
||||
async_completion<
|
||||
boost::asio::async_completion<
|
||||
WriteHandler,
|
||||
void(error_code, std::size_t)> init{handler};
|
||||
detail::write_msg_op<
|
||||
AsyncWriteStream,
|
||||
handler_type<WriteHandler,
|
||||
void(error_code, std::size_t)>,
|
||||
BOOST_ASIO_HANDLER_TYPE(WriteHandler,
|
||||
void(error_code, std::size_t)),
|
||||
isRequest, Body, Fields>{
|
||||
init.completion_handler, stream, msg}();
|
||||
return init.result.get();
|
||||
@@ -843,17 +816,13 @@ public:
|
||||
if(os_.fail())
|
||||
return;
|
||||
std::size_t bytes_transferred = 0;
|
||||
using boost::asio::buffer_cast;
|
||||
using boost::asio::buffer_size;
|
||||
for(auto it = buffers.begin();
|
||||
it != buffers.end(); ++it)
|
||||
for(auto b : buffers_range(buffers))
|
||||
{
|
||||
boost::asio::const_buffer b = *it;
|
||||
auto const n = buffer_size(b);
|
||||
os_.write(buffer_cast<char const*>(b), n);
|
||||
os_.write(reinterpret_cast<char const*>(
|
||||
b.data()), b.size());
|
||||
if(os_.fail())
|
||||
return;
|
||||
bytes_transferred += n;
|
||||
bytes_transferred += b.size();
|
||||
}
|
||||
sr_.consume(bytes_transferred);
|
||||
}
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
#define BOOST_BEAST_HTTP_READ_HPP
|
||||
|
||||
#include <boost/beast/core/detail/config.hpp>
|
||||
#include <boost/beast/core/async_result.hpp>
|
||||
#include <boost/beast/core/error.hpp>
|
||||
#include <boost/beast/http/basic_parser.hpp>
|
||||
#include <boost/beast/http/message.hpp>
|
||||
#include <boost/asio/async_result.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
@@ -185,7 +185,7 @@ read_some(
|
||||
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
|
||||
manner equivalent to using `boost::asio::io_service::post`.
|
||||
manner equivalent to using `boost::asio::io_context::post`.
|
||||
|
||||
The completion handler will receive as a parameter the number
|
||||
of octets processed from the dynamic buffer. The octets should
|
||||
@@ -197,12 +197,8 @@ template<
|
||||
class DynamicBuffer,
|
||||
bool isRequest, class Derived,
|
||||
class ReadHandler>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
void_or_deduced
|
||||
#else
|
||||
async_return_type<
|
||||
ReadHandler, void(error_code, std::size_t)>
|
||||
#endif
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
ReadHandler, void(error_code, std::size_t))
|
||||
async_read_some(
|
||||
AsyncReadStream& stream,
|
||||
DynamicBuffer& buffer,
|
||||
@@ -375,7 +371,7 @@ read_header(
|
||||
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
|
||||
manner equivalent to using `boost::asio::io_service::post`.
|
||||
manner equivalent to using `boost::asio::io_context::post`.
|
||||
|
||||
@note The implementation will call @ref basic_parser::eager
|
||||
with the value `false` on the parser passed in.
|
||||
@@ -385,12 +381,8 @@ template<
|
||||
class DynamicBuffer,
|
||||
bool isRequest, class Derived,
|
||||
class ReadHandler>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
void_or_deduced
|
||||
#else
|
||||
async_return_type<
|
||||
ReadHandler, void(error_code, std::size_t)>
|
||||
#endif
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
ReadHandler, void(error_code, std::size_t))
|
||||
async_read_header(
|
||||
AsyncReadStream& stream,
|
||||
DynamicBuffer& buffer,
|
||||
@@ -563,7 +555,7 @@ read(
|
||||
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
|
||||
manner equivalent to using `boost::asio::io_service::post`.
|
||||
manner equivalent to using `boost::asio::io_context::post`.
|
||||
|
||||
@note The implementation will call @ref basic_parser::eager
|
||||
with the value `true` on the parser passed in.
|
||||
@@ -573,13 +565,8 @@ template<
|
||||
class DynamicBuffer,
|
||||
bool isRequest, class Derived,
|
||||
class ReadHandler>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
void_or_deduced
|
||||
#else
|
||||
async_return_type<
|
||||
ReadHandler,
|
||||
void(error_code, std::size_t)>
|
||||
#endif
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
ReadHandler, void(error_code, std::size_t))
|
||||
async_read(
|
||||
AsyncReadStream& stream,
|
||||
DynamicBuffer& buffer,
|
||||
@@ -754,20 +741,15 @@ read(
|
||||
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
|
||||
manner equivalent to using `boost::asio::io_service::post`.
|
||||
manner equivalent to using `boost::asio::io_context::post`.
|
||||
*/
|
||||
template<
|
||||
class AsyncReadStream,
|
||||
class DynamicBuffer,
|
||||
bool isRequest, class Body, class Allocator,
|
||||
class ReadHandler>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
void_or_deduced
|
||||
#else
|
||||
async_return_type<
|
||||
ReadHandler,
|
||||
void(error_code, std::size_t)>
|
||||
#endif
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
ReadHandler, void(error_code, std::size_t))
|
||||
async_read(
|
||||
AsyncReadStream& stream,
|
||||
DynamicBuffer& buffer,
|
||||
|
||||
@@ -132,7 +132,7 @@ private:
|
||||
using cb4_t = buffers_suffix<buffers_cat_view<
|
||||
typename Fields::reader::const_buffers_type,// header
|
||||
detail::chunk_size, // chunk-size
|
||||
boost::asio::const_buffers_1, // chunk-ext
|
||||
boost::asio::const_buffer, // chunk-ext
|
||||
chunk_crlf, // crlf
|
||||
typename reader::const_buffers_type, // body
|
||||
chunk_crlf>>; // crlf
|
||||
@@ -140,7 +140,7 @@ private:
|
||||
|
||||
using cb5_t = buffers_suffix<buffers_cat_view<
|
||||
detail::chunk_size, // chunk-header
|
||||
boost::asio::const_buffers_1, // chunk-ext
|
||||
boost::asio::const_buffer, // chunk-ext
|
||||
chunk_crlf, // crlf
|
||||
typename reader::const_buffers_type, // body
|
||||
chunk_crlf>>; // crlf
|
||||
@@ -148,30 +148,30 @@ private:
|
||||
|
||||
using cb6_t = buffers_suffix<buffers_cat_view<
|
||||
detail::chunk_size, // chunk-header
|
||||
boost::asio::const_buffers_1, // chunk-size
|
||||
boost::asio::const_buffer, // chunk-size
|
||||
chunk_crlf, // crlf
|
||||
typename reader::const_buffers_type, // body
|
||||
chunk_crlf, // crlf
|
||||
boost::asio::const_buffers_1, // chunk-final
|
||||
boost::asio::const_buffers_1, // trailers
|
||||
boost::asio::const_buffer, // chunk-final
|
||||
boost::asio::const_buffer, // trailers
|
||||
chunk_crlf>>; // crlf
|
||||
using pcb6_t = buffers_prefix_view<cb6_t const&>;
|
||||
|
||||
using cb7_t = buffers_suffix<buffers_cat_view<
|
||||
typename Fields::reader::const_buffers_type,// header
|
||||
detail::chunk_size, // chunk-size
|
||||
boost::asio::const_buffers_1, // chunk-ext
|
||||
boost::asio::const_buffer, // chunk-ext
|
||||
chunk_crlf, // crlf
|
||||
typename reader::const_buffers_type, // body
|
||||
chunk_crlf, // crlf
|
||||
boost::asio::const_buffers_1, // chunk-final
|
||||
boost::asio::const_buffers_1, // trailers
|
||||
boost::asio::const_buffer, // chunk-final
|
||||
boost::asio::const_buffer, // trailers
|
||||
chunk_crlf>>; // crlf
|
||||
using pcb7_t = buffers_prefix_view<cb7_t const&>;
|
||||
|
||||
using cb8_t = buffers_suffix<buffers_cat_view<
|
||||
boost::asio::const_buffers_1, // chunk-final
|
||||
boost::asio::const_buffers_1, // trailers
|
||||
boost::asio::const_buffer, // chunk-final
|
||||
boost::asio::const_buffer, // trailers
|
||||
chunk_crlf>>; // crlf
|
||||
using pcb8_t = buffers_prefix_view<cb8_t const&>;
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
|
||||
public:
|
||||
using const_buffers_type =
|
||||
boost::asio::const_buffers_1;
|
||||
boost::asio::const_buffer;
|
||||
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
|
||||
public:
|
||||
using const_buffers_type =
|
||||
boost::asio::const_buffers_1;
|
||||
boost::asio::const_buffer;
|
||||
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
@@ -172,13 +172,11 @@ public:
|
||||
}
|
||||
ec.assign(0, ec.category());
|
||||
CharT* dest = &body_[size];
|
||||
for(boost::asio::const_buffer b : buffers)
|
||||
for(auto b : beast::detail::buffers_range(buffers))
|
||||
{
|
||||
using boost::asio::buffer_cast;
|
||||
auto const len = boost::asio::buffer_size(b);
|
||||
Traits::copy(
|
||||
dest, buffer_cast<CharT const*>(b), len);
|
||||
dest += len;
|
||||
Traits::copy(dest, reinterpret_cast<
|
||||
CharT const*>(b.data()), b.size());
|
||||
dest += b.size();
|
||||
}
|
||||
return extra;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ struct is_body_reader<T, beast::detail::void_t<
|
||||
typename T::reader::const_buffers_type, bool>>&>() =
|
||||
std::declval<typename T::reader>().get(std::declval<error_code&>()),
|
||||
(void)0)>> : std::integral_constant<bool,
|
||||
is_const_buffer_sequence<
|
||||
boost::asio::is_const_buffer_sequence<
|
||||
typename T::reader::const_buffers_type>::value &&
|
||||
std::is_constructible<typename T::reader,
|
||||
message<true, T, detail::fields_model>&>::value &&
|
||||
@@ -131,7 +131,7 @@ struct is_body_writer<T, beast::detail::void_t<decltype(
|
||||
std::declval<error_code&>()),
|
||||
std::declval<std::size_t&>() =
|
||||
std::declval<typename T::writer&>().put(
|
||||
std::declval<boost::asio::const_buffers_1>(),
|
||||
std::declval<boost::asio::const_buffer>(),
|
||||
std::declval<error_code&>()),
|
||||
std::declval<typename T::writer&>().finish(
|
||||
std::declval<error_code&>()),
|
||||
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
|
||||
public:
|
||||
using const_buffers_type =
|
||||
boost::asio::const_buffers_1;
|
||||
boost::asio::const_buffer;
|
||||
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
#include <boost/beast/http/serializer.hpp>
|
||||
#include <boost/beast/http/detail/chunk_encode.hpp>
|
||||
#include <boost/beast/core/error.hpp>
|
||||
#include <boost/beast/core/async_result.hpp>
|
||||
#include <boost/beast/core/string.hpp>
|
||||
#include <boost/asio/async_result.hpp>
|
||||
#include <iosfwd>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
@@ -158,7 +158,7 @@ write_some(
|
||||
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
|
||||
manner equivalent to using `boost::asio::io_service::post`.
|
||||
manner equivalent to using `boost::asio::io_context::post`.
|
||||
|
||||
@see @ref serializer
|
||||
*/
|
||||
@@ -166,13 +166,8 @@ template<
|
||||
class AsyncWriteStream,
|
||||
bool isRequest, class Body, class Fields,
|
||||
class WriteHandler>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
void_or_deduced
|
||||
#else
|
||||
async_return_type<
|
||||
WriteHandler,
|
||||
void(error_code, std::size_t)>
|
||||
#endif
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
WriteHandler, void(error_code, std::size_t))
|
||||
async_write_some(
|
||||
AsyncWriteStream& stream,
|
||||
serializer<isRequest, Body, Fields>& sr,
|
||||
@@ -284,7 +279,7 @@ write_header(
|
||||
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
|
||||
manner equivalent to using `boost::asio::io_service::post`.
|
||||
manner equivalent to using `boost::asio::io_context::post`.
|
||||
|
||||
@note The implementation will call @ref serializer::split with
|
||||
the value `true` on the serializer passed in.
|
||||
@@ -295,13 +290,8 @@ template<
|
||||
class AsyncWriteStream,
|
||||
bool isRequest, class Body, class Fields,
|
||||
class WriteHandler>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
void_or_deduced
|
||||
#else
|
||||
async_return_type<
|
||||
WriteHandler,
|
||||
void(error_code, std::size_t)>
|
||||
#endif
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
WriteHandler, void(error_code, std::size_t))
|
||||
async_write_header(
|
||||
AsyncWriteStream& stream,
|
||||
serializer<isRequest, Body, Fields>& sr,
|
||||
@@ -407,7 +397,7 @@ write(
|
||||
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
|
||||
manner equivalent to using `boost::asio::io_service::post`.
|
||||
manner equivalent to using `boost::asio::io_context::post`.
|
||||
|
||||
@see @ref serializer
|
||||
*/
|
||||
@@ -415,13 +405,8 @@ template<
|
||||
class AsyncWriteStream,
|
||||
bool isRequest, class Body, class Fields,
|
||||
class WriteHandler>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
void_or_deduced
|
||||
#else
|
||||
async_return_type<
|
||||
WriteHandler,
|
||||
void(error_code, std::size_t)>
|
||||
#endif
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
WriteHandler, void(error_code, std::size_t))
|
||||
async_write(
|
||||
AsyncWriteStream& stream,
|
||||
serializer<isRequest, Body, Fields>& sr,
|
||||
@@ -527,7 +512,7 @@ write(
|
||||
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
|
||||
manner equivalent to using `boost::asio::io_service::post`.
|
||||
manner equivalent to using `boost::asio::io_context::post`.
|
||||
|
||||
@see @ref message
|
||||
*/
|
||||
@@ -535,9 +520,8 @@ template<
|
||||
class AsyncWriteStream,
|
||||
bool isRequest, class Body, class Fields,
|
||||
class WriteHandler>
|
||||
async_return_type<
|
||||
WriteHandler,
|
||||
void(error_code, std::size_t)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
WriteHandler, void(error_code, std::size_t))
|
||||
async_write(
|
||||
AsyncWriteStream& stream,
|
||||
message<isRequest, Body, Fields>& msg,
|
||||
|
||||
@@ -233,10 +233,10 @@ read_ping(ping_data& data, Buffers const& bs)
|
||||
{
|
||||
using boost::asio::buffer_copy;
|
||||
using boost::asio::buffer_size;
|
||||
using boost::asio::mutable_buffers_1;
|
||||
using boost::asio::mutable_buffer;
|
||||
BOOST_ASSERT(buffer_size(bs) <= data.max_size());
|
||||
data.resize(buffer_size(bs));
|
||||
buffer_copy(mutable_buffers_1{
|
||||
buffer_copy(mutable_buffer{
|
||||
data.data(), data.size()}, bs);
|
||||
}
|
||||
|
||||
|
||||
@@ -122,10 +122,8 @@ mask_inplace_fast(
|
||||
boost::asio::mutable_buffer const& b,
|
||||
std::uint32_t& key)
|
||||
{
|
||||
using boost::asio::buffer_cast;
|
||||
using boost::asio::buffer_size;
|
||||
auto n = buffer_size(b);
|
||||
auto p = buffer_cast<std::uint8_t*>(b);
|
||||
auto n = b.size();
|
||||
auto p = reinterpret_cast<std::uint8_t*>(b.data());
|
||||
if(n >= sizeof(key))
|
||||
{
|
||||
// Bring p to 4-byte alignment
|
||||
@@ -177,10 +175,8 @@ mask_inplace_fast(
|
||||
boost::asio::mutable_buffer const& b,
|
||||
std::uint64_t& key)
|
||||
{
|
||||
using boost::asio::buffer_cast;
|
||||
using boost::asio::buffer_size;
|
||||
auto n = buffer_size(b);
|
||||
auto p = buffer_cast<std::uint8_t*>(b);
|
||||
auto n = b.size();
|
||||
auto p = reinterpret_cast<std::uint8_t*>(b.data());
|
||||
if(n >= sizeof(key))
|
||||
{
|
||||
// Bring p to 8-byte alignment
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#define BOOST_BEAST_WEBSOCKET_DETAIL_PAUSATION_HPP
|
||||
|
||||
#include <boost/beast/core/handler_ptr.hpp>
|
||||
#include <boost/asio/associated_allocator.hpp>
|
||||
#include <boost/asio/coroutine.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <array>
|
||||
@@ -88,13 +89,16 @@ class pausation
|
||||
public:
|
||||
~saved_op()
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
if(op_)
|
||||
{
|
||||
Op op(std::move(*op_));
|
||||
op_->~Op();
|
||||
asio_handler_deallocate(op_,
|
||||
sizeof(*op_), std::addressof(op.handler()));
|
||||
typename std::allocator_traits<
|
||||
boost::asio::associated_allocator_t<Op>>::
|
||||
template rebind_alloc<Op> alloc{
|
||||
boost::asio::get_associated_allocator(op)};
|
||||
std::allocator_traits<
|
||||
decltype(alloc)>::deallocate(alloc, op_, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,10 +119,13 @@ class pausation
|
||||
explicit
|
||||
saved_op(Op&& op)
|
||||
{
|
||||
using boost::asio::asio_handler_allocate;
|
||||
op_ = new(asio_handler_allocate(sizeof(Op),
|
||||
std::addressof(op.handler()))) Op{
|
||||
std::move(op)};
|
||||
typename std::allocator_traits<
|
||||
boost::asio::associated_allocator_t<Op>>::
|
||||
template rebind_alloc<Op> alloc{
|
||||
boost::asio::get_associated_allocator(op)};
|
||||
auto const p = std::allocator_traits<
|
||||
decltype(alloc)>::allocate(alloc, 1);
|
||||
op_ = new(p) Op{std::move(op)};
|
||||
}
|
||||
|
||||
void
|
||||
@@ -126,9 +133,12 @@ class pausation
|
||||
{
|
||||
BOOST_ASSERT(op_);
|
||||
Op op{std::move(*op_)};
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(op_,
|
||||
sizeof(*op_), std::addressof(op_->handler()));
|
||||
typename std::allocator_traits<
|
||||
boost::asio::associated_allocator_t<Op>>::
|
||||
template rebind_alloc<Op> alloc{
|
||||
boost::asio::get_associated_allocator(op)};
|
||||
std::allocator_traits<
|
||||
decltype(alloc)>::deallocate(alloc, op_, 1);
|
||||
op_ = nullptr;
|
||||
op();
|
||||
}
|
||||
|
||||
@@ -371,33 +371,31 @@ deflate(
|
||||
error_code& ec)
|
||||
{
|
||||
using boost::asio::buffer;
|
||||
using boost::asio::buffer_cast;
|
||||
using boost::asio::buffer_size;
|
||||
BOOST_ASSERT(buffer_size(out) >= 6);
|
||||
BOOST_ASSERT(out.size() >= 6);
|
||||
zlib::z_params zs;
|
||||
zs.avail_in = 0;
|
||||
zs.next_in = nullptr;
|
||||
zs.avail_out = buffer_size(out);
|
||||
zs.next_out = buffer_cast<void*>(out);
|
||||
for(boost::asio::const_buffer in : cb)
|
||||
zs.avail_out = out.size();
|
||||
zs.next_out = out.data();
|
||||
for(auto in : beast::detail::buffers_range(cb))
|
||||
{
|
||||
zs.avail_in = buffer_size(in);
|
||||
zs.avail_in = in.size();
|
||||
if(zs.avail_in == 0)
|
||||
continue;
|
||||
zs.next_in = buffer_cast<void const*>(in);
|
||||
zs.next_in = in.data();
|
||||
zo.write(zs, zlib::Flush::none, ec);
|
||||
if(ec)
|
||||
{
|
||||
if(ec != zlib::error::need_buffers)
|
||||
return false;
|
||||
BOOST_ASSERT(zs.avail_out == 0);
|
||||
BOOST_ASSERT(zs.total_out == buffer_size(out));
|
||||
BOOST_ASSERT(zs.total_out == out.size());
|
||||
ec.assign(0, ec.category());
|
||||
break;
|
||||
}
|
||||
if(zs.avail_out == 0)
|
||||
{
|
||||
BOOST_ASSERT(zs.total_out == buffer_size(out));
|
||||
BOOST_ASSERT(zs.total_out == out.size());
|
||||
break;
|
||||
}
|
||||
BOOST_ASSERT(zs.avail_in == 0);
|
||||
@@ -406,7 +404,7 @@ deflate(
|
||||
cb.consume(zs.total_in);
|
||||
if(zs.avail_out > 0 && fin)
|
||||
{
|
||||
auto const remain = buffer_size(cb);
|
||||
auto const remain = boost::asio::buffer_size(cb);
|
||||
if(remain == 0)
|
||||
{
|
||||
// Inspired by Mark Adler
|
||||
@@ -426,15 +424,13 @@ deflate(
|
||||
BOOST_ASSERT(! ec);
|
||||
// remove flush marker
|
||||
zs.total_out -= 4;
|
||||
out = buffer(
|
||||
buffer_cast<void*>(out), zs.total_out);
|
||||
out = buffer(out.data(), zs.total_out);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
ec.assign(0, ec.category());
|
||||
out = buffer(
|
||||
buffer_cast<void*>(out), zs.total_out);
|
||||
out = buffer(out.data(), zs.total_out);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -86,13 +86,12 @@ bool
|
||||
utf8_checker_t<_>::
|
||||
write(ConstBufferSequence const& bs)
|
||||
{
|
||||
static_assert(is_const_buffer_sequence<ConstBufferSequence>::value,
|
||||
static_assert(boost::asio::is_const_buffer_sequence<ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
using boost::asio::buffer_cast;
|
||||
using boost::asio::buffer_size;
|
||||
for(boost::asio::const_buffer b : bs)
|
||||
if(! write(buffer_cast<std::uint8_t const*>(b),
|
||||
buffer_size(b)))
|
||||
for(auto b : beast::detail::buffers_range(bs))
|
||||
if(! write(reinterpret_cast<
|
||||
std::uint8_t const*>(b.data()),
|
||||
b.size()))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -20,9 +20,10 @@
|
||||
#include <boost/beast/core/handler_ptr.hpp>
|
||||
#include <boost/beast/core/detail/type_traits.hpp>
|
||||
#include <boost/asio/coroutine.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/associated_allocator.hpp>
|
||||
#include <boost/asio/associated_executor.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/asio/post.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <memory>
|
||||
@@ -67,28 +68,28 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
using allocator_type =
|
||||
boost::asio::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_allocator(d_.handler());
|
||||
}
|
||||
|
||||
using executor_type = boost::asio::associated_executor_t<
|
||||
Handler, decltype(d_->ws.get_executor())>;
|
||||
|
||||
executor_type get_executor() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_executor(
|
||||
d_.handler(), d_->ws.get_executor());
|
||||
}
|
||||
|
||||
void operator()(
|
||||
error_code ec = {},
|
||||
std::size_t bytes_transferred = 0);
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, response_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
friend
|
||||
void asio_handler_deallocate(
|
||||
void* p, std::size_t size, response_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(response_op* op)
|
||||
{
|
||||
@@ -96,15 +97,6 @@ public:
|
||||
return asio_handler_is_continuation(
|
||||
std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, response_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(
|
||||
f, std::addressof(op->d_.handler()));
|
||||
}
|
||||
};
|
||||
|
||||
template<class NextLayer>
|
||||
@@ -171,6 +163,24 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
using allocator_type =
|
||||
boost::asio::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_allocator(d_.handler());
|
||||
}
|
||||
|
||||
using executor_type = boost::asio::associated_executor_t<
|
||||
Handler, decltype(d_->ws.get_executor())>;
|
||||
|
||||
executor_type get_executor() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_executor(
|
||||
d_.handler(), d_->ws.get_executor());
|
||||
}
|
||||
|
||||
template<class Buffers>
|
||||
void run(Buffers const& buffers);
|
||||
|
||||
@@ -178,24 +188,6 @@ public:
|
||||
error_code ec = {},
|
||||
std::size_t bytes_used = 0);
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, accept_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
friend
|
||||
void asio_handler_deallocate(
|
||||
void* p, std::size_t size, accept_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(accept_op* op)
|
||||
{
|
||||
@@ -203,15 +195,6 @@ public:
|
||||
return asio_handler_is_continuation(
|
||||
std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, accept_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(
|
||||
f, std::addressof(op->d_.handler()));
|
||||
}
|
||||
};
|
||||
|
||||
template<class NextLayer>
|
||||
@@ -256,7 +239,8 @@ operator()(error_code ec, std::size_t)
|
||||
if(ec)
|
||||
{
|
||||
BOOST_ASIO_CORO_YIELD
|
||||
d.ws.get_io_service().post(
|
||||
boost::asio::post(
|
||||
d.ws.get_executor(),
|
||||
bind_handler(std::move(*this), ec));
|
||||
}
|
||||
else
|
||||
@@ -269,7 +253,7 @@ operator()(error_code ec, std::size_t)
|
||||
ec = error::closed;
|
||||
if(! ec)
|
||||
{
|
||||
// Arguments from our step must be
|
||||
// Arguments from our state must be
|
||||
// moved to the stack before releasing
|
||||
// the handler.
|
||||
auto& ws = d.ws;
|
||||
@@ -359,7 +343,7 @@ accept(ConstBufferSequence const& buffers)
|
||||
{
|
||||
static_assert(is_sync_stream<next_layer_type>::value,
|
||||
"SyncStream requirements not met");
|
||||
static_assert(is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
error_code ec;
|
||||
@@ -381,7 +365,7 @@ accept_ex(
|
||||
{
|
||||
static_assert(is_sync_stream<next_layer_type>::value,
|
||||
"SyncStream requirements not met");
|
||||
static_assert(is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
static_assert(detail::is_ResponseDecorator<
|
||||
@@ -403,7 +387,7 @@ accept(
|
||||
{
|
||||
static_assert(is_sync_stream<next_layer_type>::value,
|
||||
"SyncStream requirements not met");
|
||||
static_assert(is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
using boost::asio::buffer_copy;
|
||||
@@ -440,10 +424,10 @@ accept_ex(
|
||||
{
|
||||
static_assert(is_sync_stream<next_layer_type>::value,
|
||||
"SyncStream requirements not met");
|
||||
static_assert(is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
static_assert(is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
using boost::asio::buffer_copy;
|
||||
@@ -544,22 +528,24 @@ accept_ex(
|
||||
template<class NextLayer>
|
||||
template<
|
||||
class AcceptHandler>
|
||||
async_return_type<AcceptHandler, void(error_code)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
AcceptHandler, void(error_code))
|
||||
stream<NextLayer>::
|
||||
async_accept(
|
||||
AcceptHandler&& handler)
|
||||
{
|
||||
static_assert(is_async_stream<next_layer_type>::value,
|
||||
"AsyncStream requirements requirements not met");
|
||||
async_completion<AcceptHandler,
|
||||
boost::asio::async_completion<AcceptHandler,
|
||||
void(error_code)> init{handler};
|
||||
reset();
|
||||
accept_op<
|
||||
decltype(&default_decorate_res),
|
||||
handler_type<AcceptHandler, void(error_code)>>{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
&default_decorate_res}({});
|
||||
BOOST_ASIO_HANDLER_TYPE(
|
||||
AcceptHandler, void(error_code))>{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
&default_decorate_res}({});
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
@@ -567,7 +553,8 @@ template<class NextLayer>
|
||||
template<
|
||||
class ResponseDecorator,
|
||||
class AcceptHandler>
|
||||
async_return_type<AcceptHandler, void(error_code)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
AcceptHandler, void(error_code))
|
||||
stream<NextLayer>::
|
||||
async_accept_ex(
|
||||
ResponseDecorator const& decorator,
|
||||
@@ -578,15 +565,16 @@ async_accept_ex(
|
||||
static_assert(detail::is_ResponseDecorator<
|
||||
ResponseDecorator>::value,
|
||||
"ResponseDecorator requirements not met");
|
||||
async_completion<AcceptHandler,
|
||||
boost::asio::async_completion<AcceptHandler,
|
||||
void(error_code)> init{handler};
|
||||
reset();
|
||||
accept_op<
|
||||
ResponseDecorator,
|
||||
handler_type<AcceptHandler, void(error_code)>>{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
decorator}({});
|
||||
BOOST_ASIO_HANDLER_TYPE(
|
||||
AcceptHandler, void(error_code))>{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
decorator}({});
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
@@ -596,7 +584,8 @@ template<
|
||||
class AcceptHandler>
|
||||
typename std::enable_if<
|
||||
! http::detail::is_header<ConstBufferSequence>::value,
|
||||
async_return_type<AcceptHandler, void(error_code)>>::type
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
AcceptHandler, void(error_code))>::type
|
||||
stream<NextLayer>::
|
||||
async_accept(
|
||||
ConstBufferSequence const& buffers,
|
||||
@@ -604,18 +593,19 @@ async_accept(
|
||||
{
|
||||
static_assert(is_async_stream<next_layer_type>::value,
|
||||
"AsyncStream requirements requirements not met");
|
||||
static_assert(is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
async_completion<AcceptHandler,
|
||||
boost::asio::async_completion<AcceptHandler,
|
||||
void(error_code)> init{handler};
|
||||
reset();
|
||||
accept_op<
|
||||
decltype(&default_decorate_res),
|
||||
handler_type<AcceptHandler, void(error_code)>>{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
&default_decorate_res}.run(buffers);
|
||||
BOOST_ASIO_HANDLER_TYPE(
|
||||
AcceptHandler, void(error_code))>{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
&default_decorate_res}.run(buffers);
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
@@ -626,7 +616,8 @@ template<
|
||||
class AcceptHandler>
|
||||
typename std::enable_if<
|
||||
! http::detail::is_header<ConstBufferSequence>::value,
|
||||
async_return_type<AcceptHandler, void(error_code)>>::type
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
AcceptHandler, void(error_code))>::type
|
||||
stream<NextLayer>::
|
||||
async_accept_ex(
|
||||
ConstBufferSequence const& buffers,
|
||||
@@ -635,21 +626,22 @@ async_accept_ex(
|
||||
{
|
||||
static_assert(is_async_stream<next_layer_type>::value,
|
||||
"AsyncStream requirements requirements not met");
|
||||
static_assert(is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
static_assert(detail::is_ResponseDecorator<
|
||||
ResponseDecorator>::value,
|
||||
"ResponseDecorator requirements not met");
|
||||
async_completion<AcceptHandler,
|
||||
boost::asio::async_completion<AcceptHandler,
|
||||
void(error_code)> init{handler};
|
||||
reset();
|
||||
accept_op<
|
||||
ResponseDecorator,
|
||||
handler_type<AcceptHandler, void(error_code)>>{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
decorator}.run(buffers);
|
||||
BOOST_ASIO_HANDLER_TYPE(
|
||||
AcceptHandler, void(error_code))>{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
decorator}.run(buffers);
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
@@ -657,7 +649,8 @@ template<class NextLayer>
|
||||
template<
|
||||
class Body, class Allocator,
|
||||
class AcceptHandler>
|
||||
async_return_type<AcceptHandler, void(error_code)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
AcceptHandler, void(error_code))
|
||||
stream<NextLayer>::
|
||||
async_accept(
|
||||
http::request<Body, http::basic_fields<Allocator>> const& req,
|
||||
@@ -665,16 +658,17 @@ async_accept(
|
||||
{
|
||||
static_assert(is_async_stream<next_layer_type>::value,
|
||||
"AsyncStream requirements requirements not met");
|
||||
async_completion<AcceptHandler,
|
||||
boost::asio::async_completion<AcceptHandler,
|
||||
void(error_code)> init{handler};
|
||||
reset();
|
||||
using boost::asio::asio_handler_is_continuation;
|
||||
response_op<
|
||||
handler_type<AcceptHandler, void(error_code)>>{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
req,
|
||||
&default_decorate_res}();
|
||||
BOOST_ASIO_HANDLER_TYPE(
|
||||
AcceptHandler, void(error_code))>{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
req,
|
||||
&default_decorate_res}();
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
@@ -683,7 +677,8 @@ template<
|
||||
class Body, class Allocator,
|
||||
class ResponseDecorator,
|
||||
class AcceptHandler>
|
||||
async_return_type<AcceptHandler, void(error_code)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
AcceptHandler, void(error_code))
|
||||
stream<NextLayer>::
|
||||
async_accept_ex(
|
||||
http::request<Body, http::basic_fields<Allocator>> const& req,
|
||||
@@ -695,16 +690,17 @@ async_accept_ex(
|
||||
static_assert(detail::is_ResponseDecorator<
|
||||
ResponseDecorator>::value,
|
||||
"ResponseDecorator requirements not met");
|
||||
async_completion<AcceptHandler,
|
||||
boost::asio::async_completion<AcceptHandler,
|
||||
void(error_code)> init{handler};
|
||||
reset();
|
||||
using boost::asio::asio_handler_is_continuation;
|
||||
response_op<
|
||||
handler_type<AcceptHandler, void(error_code)>>{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
req,
|
||||
decorator}();
|
||||
BOOST_ASIO_HANDLER_TYPE(
|
||||
AcceptHandler, void(error_code))>{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
req,
|
||||
decorator}();
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
|
||||
@@ -15,10 +15,11 @@
|
||||
#include <boost/beast/core/flat_static_buffer.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/beast/core/detail/config.hpp>
|
||||
#include <boost/asio/associated_allocator.hpp>
|
||||
#include <boost/asio/associated_executor.hpp>
|
||||
#include <boost/asio/coroutine.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/asio/post.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <memory>
|
||||
|
||||
@@ -74,30 +75,30 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
using allocator_type =
|
||||
boost::asio::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_allocator(d_.handler());
|
||||
}
|
||||
|
||||
using executor_type = boost::asio::associated_executor_t<
|
||||
Handler, decltype(d_->ws.get_executor())>;
|
||||
|
||||
executor_type get_executor() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_executor(
|
||||
d_.handler(), d_->ws.get_executor());
|
||||
}
|
||||
|
||||
void
|
||||
operator()(
|
||||
error_code ec = {},
|
||||
std::size_t bytes_transferred = 0,
|
||||
bool cont = true);
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, close_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
friend
|
||||
void asio_handler_deallocate(
|
||||
void* p, std::size_t size, close_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(close_op* op)
|
||||
{
|
||||
@@ -105,15 +106,6 @@ public:
|
||||
return op->d_->cont || asio_handler_is_continuation(
|
||||
std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, close_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(
|
||||
f, std::addressof(op->d_.handler()));
|
||||
}
|
||||
};
|
||||
|
||||
template<class NextLayer>
|
||||
@@ -155,7 +147,8 @@ operator()(
|
||||
|
||||
// Resume
|
||||
BOOST_ASIO_CORO_YIELD
|
||||
d.ws.get_io_service().post(std::move(*this));
|
||||
boost::asio::post(
|
||||
d.ws.get_executor(), std::move(*this));
|
||||
BOOST_ASSERT(d.ws.wr_block_ == d.tok);
|
||||
|
||||
// Make sure the stream is open
|
||||
@@ -205,7 +198,8 @@ operator()(
|
||||
|
||||
// Resume
|
||||
BOOST_ASIO_CORO_YIELD
|
||||
d.ws.get_io_service().post(std::move(*this));
|
||||
boost::asio::post(
|
||||
d.ws.get_executor(), std::move(*this));
|
||||
BOOST_ASSERT(d.ws.rd_block_ == d.tok);
|
||||
|
||||
// Make sure the stream is open
|
||||
@@ -322,7 +316,8 @@ operator()(
|
||||
if(! d.cont)
|
||||
{
|
||||
auto& ws = d.ws;
|
||||
return ws.stream_.get_io_service().post(
|
||||
return boost::asio::post(
|
||||
ws.stream_.get_executor(),
|
||||
bind_handler(d_.release_handler(), ec));
|
||||
}
|
||||
d_.invoke(ec);
|
||||
@@ -440,17 +435,17 @@ close(close_reason const& cr, error_code& ec)
|
||||
|
||||
template<class NextLayer>
|
||||
template<class CloseHandler>
|
||||
async_return_type<
|
||||
CloseHandler, void(error_code)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
CloseHandler, void(error_code))
|
||||
stream<NextLayer>::
|
||||
async_close(close_reason const& cr, CloseHandler&& handler)
|
||||
{
|
||||
static_assert(is_async_stream<next_layer_type>::value,
|
||||
"AsyncStream requirements not met");
|
||||
async_completion<CloseHandler,
|
||||
boost::asio::async_completion<CloseHandler,
|
||||
void(error_code)> init{handler};
|
||||
close_op<handler_type<
|
||||
CloseHandler, void(error_code)>>{
|
||||
close_op<BOOST_ASIO_HANDLER_TYPE(
|
||||
CloseHandler, void(error_code))>{
|
||||
init.completion_handler, *this, cr}(
|
||||
{}, 0, false);
|
||||
return init.result.get();
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
#include <boost/beast/http/write.hpp>
|
||||
#include <boost/beast/core/handler_ptr.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/asio/associated_allocator.hpp>
|
||||
#include <boost/asio/associated_executor.hpp>
|
||||
#include <boost/asio/coroutine.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <memory>
|
||||
@@ -75,29 +75,29 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
using allocator_type =
|
||||
boost::asio::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_allocator(d_.handler());
|
||||
}
|
||||
|
||||
using executor_type = boost::asio::associated_executor_t<
|
||||
Handler, decltype(d_->ws.get_executor())>;
|
||||
|
||||
executor_type get_executor() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_executor(
|
||||
d_.handler(), d_->ws.get_executor());
|
||||
}
|
||||
|
||||
void
|
||||
operator()(
|
||||
error_code ec = {},
|
||||
std::size_t bytes_used = 0);
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, handshake_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
friend
|
||||
void asio_handler_deallocate(
|
||||
void* p, std::size_t size, handshake_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(handshake_op* op)
|
||||
{
|
||||
@@ -105,15 +105,6 @@ public:
|
||||
return asio_handler_is_continuation(
|
||||
std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, handshake_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(
|
||||
f, std::addressof(op->d_.handler()));
|
||||
}
|
||||
};
|
||||
|
||||
template<class NextLayer>
|
||||
@@ -156,8 +147,8 @@ operator()(error_code ec, std::size_t)
|
||||
|
||||
template<class NextLayer>
|
||||
template<class HandshakeHandler>
|
||||
async_return_type<
|
||||
HandshakeHandler, void(error_code)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
HandshakeHandler, void(error_code))
|
||||
stream<NextLayer>::
|
||||
async_handshake(string_view host,
|
||||
string_view target,
|
||||
@@ -165,10 +156,10 @@ async_handshake(string_view host,
|
||||
{
|
||||
static_assert(is_async_stream<next_layer_type>::value,
|
||||
"AsyncStream requirements not met");
|
||||
async_completion<HandshakeHandler,
|
||||
boost::asio::async_completion<HandshakeHandler,
|
||||
void(error_code)> init{handler};
|
||||
handshake_op<handler_type<
|
||||
HandshakeHandler, void(error_code)>>{
|
||||
handshake_op<BOOST_ASIO_HANDLER_TYPE(
|
||||
HandshakeHandler, void(error_code))>{
|
||||
init.completion_handler, *this, nullptr, host,
|
||||
target, &default_decorate_req}();
|
||||
return init.result.get();
|
||||
@@ -176,8 +167,8 @@ async_handshake(string_view host,
|
||||
|
||||
template<class NextLayer>
|
||||
template<class HandshakeHandler>
|
||||
async_return_type<
|
||||
HandshakeHandler, void(error_code)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
HandshakeHandler, void(error_code))
|
||||
stream<NextLayer>::
|
||||
async_handshake(response_type& res,
|
||||
string_view host,
|
||||
@@ -186,10 +177,10 @@ async_handshake(response_type& res,
|
||||
{
|
||||
static_assert(is_async_stream<next_layer_type>::value,
|
||||
"AsyncStream requirements not met");
|
||||
async_completion<HandshakeHandler,
|
||||
boost::asio::async_completion<HandshakeHandler,
|
||||
void(error_code)> init{handler};
|
||||
handshake_op<handler_type<
|
||||
HandshakeHandler, void(error_code)>>{
|
||||
handshake_op<BOOST_ASIO_HANDLER_TYPE(
|
||||
HandshakeHandler, void(error_code))>{
|
||||
init.completion_handler, *this, &res, host,
|
||||
target, &default_decorate_req}();
|
||||
return init.result.get();
|
||||
@@ -197,8 +188,8 @@ async_handshake(response_type& res,
|
||||
|
||||
template<class NextLayer>
|
||||
template<class RequestDecorator, class HandshakeHandler>
|
||||
async_return_type<
|
||||
HandshakeHandler, void(error_code)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
HandshakeHandler, void(error_code))
|
||||
stream<NextLayer>::
|
||||
async_handshake_ex(string_view host,
|
||||
string_view target,
|
||||
@@ -210,10 +201,10 @@ async_handshake_ex(string_view host,
|
||||
static_assert(detail::is_RequestDecorator<
|
||||
RequestDecorator>::value,
|
||||
"RequestDecorator requirements not met");
|
||||
async_completion<HandshakeHandler,
|
||||
boost::asio::async_completion<HandshakeHandler,
|
||||
void(error_code)> init{handler};
|
||||
handshake_op<handler_type<
|
||||
HandshakeHandler, void(error_code)>>{
|
||||
handshake_op<BOOST_ASIO_HANDLER_TYPE(
|
||||
HandshakeHandler, void(error_code))>{
|
||||
init.completion_handler, *this, nullptr, host,
|
||||
target, decorator}();
|
||||
return init.result.get();
|
||||
@@ -221,8 +212,8 @@ async_handshake_ex(string_view host,
|
||||
|
||||
template<class NextLayer>
|
||||
template<class RequestDecorator, class HandshakeHandler>
|
||||
async_return_type<
|
||||
HandshakeHandler, void(error_code)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
HandshakeHandler, void(error_code))
|
||||
stream<NextLayer>::
|
||||
async_handshake_ex(response_type& res,
|
||||
string_view host,
|
||||
@@ -235,10 +226,10 @@ async_handshake_ex(response_type& res,
|
||||
static_assert(detail::is_RequestDecorator<
|
||||
RequestDecorator>::value,
|
||||
"RequestDecorator requirements not met");
|
||||
async_completion<HandshakeHandler,
|
||||
boost::asio::async_completion<HandshakeHandler,
|
||||
void(error_code)> init{handler};
|
||||
handshake_op<handler_type<
|
||||
HandshakeHandler, void(error_code)>>{
|
||||
handshake_op<BOOST_ASIO_HANDLER_TYPE(
|
||||
HandshakeHandler, void(error_code))>{
|
||||
init.completion_handler, *this, &res, host,
|
||||
target, decorator}();
|
||||
return init.result.get();
|
||||
|
||||
@@ -15,10 +15,11 @@
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/beast/core/detail/config.hpp>
|
||||
#include <boost/beast/websocket/detail/frame.hpp>
|
||||
#include <boost/asio/associated_allocator.hpp>
|
||||
#include <boost/asio/associated_executor.hpp>
|
||||
#include <boost/asio/coroutine.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/asio/post.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <memory>
|
||||
|
||||
@@ -74,28 +75,28 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
using allocator_type =
|
||||
boost::asio::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_allocator(d_.handler());
|
||||
}
|
||||
|
||||
using executor_type = boost::asio::associated_executor_t<
|
||||
Handler, decltype(d_->ws.get_executor())>;
|
||||
|
||||
executor_type get_executor() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_executor(
|
||||
d_.handler(), d_->ws.get_executor());
|
||||
}
|
||||
|
||||
void operator()(
|
||||
error_code ec = {},
|
||||
std::size_t bytes_transferred = 0);
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, ping_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
friend
|
||||
void asio_handler_deallocate(
|
||||
void* p, std::size_t size, ping_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(ping_op* op)
|
||||
{
|
||||
@@ -103,15 +104,6 @@ public:
|
||||
return asio_handler_is_continuation(
|
||||
std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, ping_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(
|
||||
f, std::addressof(op->d_.handler()));
|
||||
}
|
||||
};
|
||||
|
||||
template<class NextLayer>
|
||||
@@ -134,7 +126,8 @@ operator()(error_code ec, std::size_t)
|
||||
if(! d.ws.check_open(ec))
|
||||
{
|
||||
BOOST_ASIO_CORO_YIELD
|
||||
d.ws.get_io_service().post(
|
||||
boost::asio::post(
|
||||
d.ws.get_executor(),
|
||||
bind_handler(std::move(*this), ec));
|
||||
goto upcall;
|
||||
}
|
||||
@@ -152,7 +145,8 @@ operator()(error_code ec, std::size_t)
|
||||
|
||||
// Resume
|
||||
BOOST_ASIO_CORO_YIELD
|
||||
d.ws.get_io_service().post(std::move(*this));
|
||||
boost::asio::post(
|
||||
d.ws.get_executor(), std::move(*this));
|
||||
BOOST_ASSERT(d.ws.wr_block_ == d.tok);
|
||||
|
||||
// Make sure the stream is open
|
||||
@@ -235,17 +229,17 @@ pong(ping_data const& payload, error_code& ec)
|
||||
|
||||
template<class NextLayer>
|
||||
template<class WriteHandler>
|
||||
async_return_type<
|
||||
WriteHandler, void(error_code)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
WriteHandler, void(error_code))
|
||||
stream<NextLayer>::
|
||||
async_ping(ping_data const& payload, WriteHandler&& handler)
|
||||
{
|
||||
static_assert(is_async_stream<next_layer_type>::value,
|
||||
"AsyncStream requirements requirements not met");
|
||||
async_completion<WriteHandler,
|
||||
boost::asio::async_completion<WriteHandler,
|
||||
void(error_code)> init{handler};
|
||||
ping_op<handler_type<
|
||||
WriteHandler, void(error_code)>>{
|
||||
ping_op<BOOST_ASIO_HANDLER_TYPE(
|
||||
WriteHandler, void(error_code))>{
|
||||
init.completion_handler, *this,
|
||||
detail::opcode::ping, payload}();
|
||||
return init.result.get();
|
||||
@@ -253,17 +247,17 @@ async_ping(ping_data const& payload, WriteHandler&& handler)
|
||||
|
||||
template<class NextLayer>
|
||||
template<class WriteHandler>
|
||||
async_return_type<
|
||||
WriteHandler, void(error_code)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
WriteHandler, void(error_code))
|
||||
stream<NextLayer>::
|
||||
async_pong(ping_data const& payload, WriteHandler&& handler)
|
||||
{
|
||||
static_assert(is_async_stream<next_layer_type>::value,
|
||||
"AsyncStream requirements requirements not met");
|
||||
async_completion<WriteHandler,
|
||||
boost::asio::async_completion<WriteHandler,
|
||||
void(error_code)> init{handler};
|
||||
ping_op<handler_type<
|
||||
WriteHandler, void(error_code)>>{
|
||||
ping_op<BOOST_ASIO_HANDLER_TYPE(
|
||||
WriteHandler, void(error_code))>{
|
||||
init.completion_handler, *this,
|
||||
detail::opcode::pong, payload}();
|
||||
return init.result.get();
|
||||
|
||||
@@ -18,10 +18,11 @@
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/beast/core/detail/clamp.hpp>
|
||||
#include <boost/beast/core/detail/config.hpp>
|
||||
#include <boost/asio/associated_allocator.hpp>
|
||||
#include <boost/asio/associated_executor.hpp>
|
||||
#include <boost/asio/coroutine.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/asio/post.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
@@ -74,6 +75,24 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
using allocator_type =
|
||||
boost::asio::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_allocator(h_);
|
||||
}
|
||||
|
||||
using executor_type = boost::asio::associated_executor_t<
|
||||
Handler, decltype(ws_.get_executor())>;
|
||||
|
||||
executor_type get_executor() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_executor(
|
||||
h_, ws_.get_executor());
|
||||
}
|
||||
|
||||
Handler&
|
||||
handler()
|
||||
{
|
||||
@@ -85,24 +104,6 @@ public:
|
||||
std::size_t bytes_transferred = 0,
|
||||
bool cont = true);
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, read_some_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
void asio_handler_deallocate(
|
||||
void* p, std::size_t size, read_some_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(p, size,
|
||||
std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(read_some_op* op)
|
||||
{
|
||||
@@ -110,15 +111,6 @@ public:
|
||||
return op->cont_ || asio_handler_is_continuation(
|
||||
std::addressof(op->h_));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, read_some_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(
|
||||
f, std::addressof(op->h_));
|
||||
}
|
||||
};
|
||||
|
||||
template<class NextLayer>
|
||||
@@ -133,7 +125,6 @@ operator()(
|
||||
{
|
||||
using beast::detail::clamp;
|
||||
using boost::asio::buffer;
|
||||
using boost::asio::buffer_cast;
|
||||
using boost::asio::buffer_size;
|
||||
close_code code{};
|
||||
cont_ = cont;
|
||||
@@ -168,7 +159,8 @@ operator()(
|
||||
|
||||
// Resume
|
||||
BOOST_ASIO_CORO_YIELD
|
||||
ws_.get_io_service().post(std::move(*this));
|
||||
boost::asio::post(
|
||||
ws_.get_executor(), std::move(*this));
|
||||
BOOST_ASSERT(ws_.rd_block_ == tok_);
|
||||
|
||||
// The only way to get read blocked is if
|
||||
@@ -290,7 +282,8 @@ operator()(
|
||||
|
||||
// Resume
|
||||
BOOST_ASIO_CORO_YIELD
|
||||
ws_.get_io_service().post(std::move(*this));
|
||||
boost::asio::post(
|
||||
ws_.get_executor(), std::move(*this));
|
||||
BOOST_ASSERT(ws_.wr_block_ == tok_);
|
||||
|
||||
// Make sure the stream is open
|
||||
@@ -489,8 +482,8 @@ operator()(
|
||||
zlib::z_params zs;
|
||||
{
|
||||
auto const out = buffers_front(cb_);
|
||||
zs.next_out = buffer_cast<void*>(out);
|
||||
zs.avail_out = buffer_size(out);
|
||||
zs.next_out = out.data();
|
||||
zs.avail_out = out.size();
|
||||
BOOST_ASSERT(zs.avail_out > 0);
|
||||
}
|
||||
if(ws_.rd_remain_ > 0)
|
||||
@@ -501,8 +494,8 @@ operator()(
|
||||
auto const in = buffers_prefix(
|
||||
clamp(ws_.rd_remain_), buffers_front(
|
||||
ws_.rd_buf_.data()));
|
||||
zs.avail_in = buffer_size(in);
|
||||
zs.next_in = buffer_cast<void const*>(in);
|
||||
zs.avail_in = in.size();
|
||||
zs.next_in = in.data();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -594,7 +587,8 @@ operator()(
|
||||
|
||||
// Resume
|
||||
BOOST_ASIO_CORO_YIELD
|
||||
ws_.get_io_service().post(std::move(*this));
|
||||
boost::asio::post(
|
||||
ws_.get_executor(), std::move(*this));
|
||||
BOOST_ASSERT(ws_.wr_block_ == tok_);
|
||||
|
||||
// Make sure the stream is open
|
||||
@@ -659,7 +653,8 @@ operator()(
|
||||
ws_.paused_wr_.maybe_invoke();
|
||||
}
|
||||
if(! cont_)
|
||||
return ws_.stream_.get_io_service().post(
|
||||
return boost::asio::post(
|
||||
ws_.stream_.get_executor(),
|
||||
bind_handler(std::move(h_),
|
||||
ec, bytes_written_));
|
||||
h_(ec, bytes_written_);
|
||||
@@ -683,6 +678,9 @@ class stream<NextLayer>::read_op
|
||||
bool some_;
|
||||
|
||||
public:
|
||||
using allocator_type =
|
||||
boost::asio::associated_allocator_t<Handler>;
|
||||
|
||||
read_op(read_op&&) = default;
|
||||
read_op(read_op const&) = default;
|
||||
|
||||
@@ -702,28 +700,25 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_allocator(h_);
|
||||
}
|
||||
|
||||
using executor_type = boost::asio::associated_executor_t<
|
||||
Handler, decltype(ws_.get_executor())>;
|
||||
|
||||
executor_type get_executor() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_executor(
|
||||
h_, ws_.get_executor());
|
||||
}
|
||||
|
||||
void operator()(
|
||||
error_code ec = {},
|
||||
std::size_t bytes_transferred = 0);
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, read_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
void asio_handler_deallocate(
|
||||
void* p, std::size_t size, read_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(read_op* op)
|
||||
{
|
||||
@@ -731,15 +726,6 @@ public:
|
||||
return asio_handler_is_continuation(
|
||||
std::addressof(op->h_));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, read_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(
|
||||
f, std::addressof(op->h_));
|
||||
}
|
||||
};
|
||||
|
||||
template<class NextLayer>
|
||||
@@ -771,7 +757,8 @@ operator()(
|
||||
if(ec)
|
||||
{
|
||||
BOOST_ASIO_CORO_YIELD
|
||||
ws_.get_io_service().post(
|
||||
boost::asio::post(
|
||||
ws_.get_executor(),
|
||||
bind_handler(std::move(*this),
|
||||
error::buffer_overflow, 0));
|
||||
break;
|
||||
@@ -800,7 +787,8 @@ read(DynamicBuffer& buffer)
|
||||
{
|
||||
static_assert(is_sync_stream<next_layer_type>::value,
|
||||
"SyncStream requirements not met");
|
||||
static_assert(beast::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
error_code ec;
|
||||
auto const bytes_written = read(buffer, ec);
|
||||
@@ -817,7 +805,8 @@ read(DynamicBuffer& buffer, error_code& ec)
|
||||
{
|
||||
static_assert(is_sync_stream<next_layer_type>::value,
|
||||
"SyncStream requirements not met");
|
||||
static_assert(beast::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
std::size_t bytes_written = 0;
|
||||
do
|
||||
@@ -832,24 +821,27 @@ read(DynamicBuffer& buffer, error_code& ec)
|
||||
|
||||
template<class NextLayer>
|
||||
template<class DynamicBuffer, class ReadHandler>
|
||||
async_return_type<ReadHandler, void(error_code, std::size_t)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
ReadHandler, void(error_code, std::size_t))
|
||||
stream<NextLayer>::
|
||||
async_read(DynamicBuffer& buffer, ReadHandler&& handler)
|
||||
{
|
||||
static_assert(is_async_stream<next_layer_type>::value,
|
||||
"AsyncStream requirements requirements not met");
|
||||
static_assert(beast::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
async_completion<
|
||||
boost::asio::async_completion<
|
||||
ReadHandler, void(error_code, std::size_t)> init{handler};
|
||||
read_op<
|
||||
DynamicBuffer,
|
||||
handler_type<ReadHandler, void(error_code, std::size_t)> >{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
buffer,
|
||||
0,
|
||||
false}();
|
||||
BOOST_ASIO_HANDLER_TYPE(
|
||||
ReadHandler, void(error_code, std::size_t))>{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
buffer,
|
||||
0,
|
||||
false}();
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
@@ -865,7 +857,8 @@ read_some(
|
||||
{
|
||||
static_assert(is_sync_stream<next_layer_type>::value,
|
||||
"SyncStream requirements not met");
|
||||
static_assert(beast::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
error_code ec;
|
||||
auto const bytes_written =
|
||||
@@ -886,7 +879,8 @@ read_some(
|
||||
{
|
||||
static_assert(is_sync_stream<next_layer_type>::value,
|
||||
"SyncStream requirements not met");
|
||||
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
using beast::detail::clamp;
|
||||
if(! limit)
|
||||
@@ -912,8 +906,8 @@ read_some(
|
||||
|
||||
template<class NextLayer>
|
||||
template<class DynamicBuffer, class ReadHandler>
|
||||
async_return_type<ReadHandler,
|
||||
void(error_code, std::size_t)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
ReadHandler, void(error_code, std::size_t))
|
||||
stream<NextLayer>::
|
||||
async_read_some(
|
||||
DynamicBuffer& buffer,
|
||||
@@ -922,19 +916,20 @@ async_read_some(
|
||||
{
|
||||
static_assert(is_async_stream<next_layer_type>::value,
|
||||
"AsyncStream requirements requirements not met");
|
||||
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
async_completion<ReadHandler,
|
||||
boost::asio::async_completion<ReadHandler,
|
||||
void(error_code, std::size_t)> init{handler};
|
||||
read_op<
|
||||
DynamicBuffer,
|
||||
handler_type<ReadHandler,
|
||||
void(error_code, std::size_t)>>{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
buffer,
|
||||
limit,
|
||||
true}({}, 0);
|
||||
BOOST_ASIO_HANDLER_TYPE(
|
||||
ReadHandler, void(error_code, std::size_t))>{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
buffer,
|
||||
limit,
|
||||
true}({}, 0);
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
@@ -949,7 +944,7 @@ read_some(
|
||||
{
|
||||
static_assert(is_sync_stream<next_layer_type>::value,
|
||||
"SyncStream requirements not met");
|
||||
static_assert(is_mutable_buffer_sequence<
|
||||
static_assert(boost::asio::is_mutable_buffer_sequence<
|
||||
MutableBufferSequence>::value,
|
||||
"MutableBufferSequence requirements not met");
|
||||
error_code ec;
|
||||
@@ -969,12 +964,11 @@ read_some(
|
||||
{
|
||||
static_assert(is_sync_stream<next_layer_type>::value,
|
||||
"SyncStream requirements not met");
|
||||
static_assert(is_mutable_buffer_sequence<
|
||||
static_assert(boost::asio::is_mutable_buffer_sequence<
|
||||
MutableBufferSequence>::value,
|
||||
"MutableBufferSequence requirements not met");
|
||||
using beast::detail::clamp;
|
||||
using boost::asio::buffer;
|
||||
using boost::asio::buffer_cast;
|
||||
using boost::asio::buffer_size;
|
||||
close_code code{};
|
||||
std::size_t bytes_written = 0;
|
||||
@@ -1191,8 +1185,8 @@ loop:
|
||||
zlib::z_params zs;
|
||||
{
|
||||
auto const out = buffers_front(cb);
|
||||
zs.next_out = buffer_cast<void*>(out);
|
||||
zs.avail_out = buffer_size(out);
|
||||
zs.next_out = out.data();
|
||||
zs.avail_out = out.size();
|
||||
BOOST_ASSERT(zs.avail_out > 0);
|
||||
}
|
||||
if(rd_remain_ > 0)
|
||||
@@ -1203,8 +1197,8 @@ loop:
|
||||
auto const in = buffers_prefix(
|
||||
clamp(rd_remain_), buffers_front(
|
||||
rd_buf_.data()));
|
||||
zs.avail_in = buffer_size(in);
|
||||
zs.next_in = buffer_cast<void const*>(in);
|
||||
zs.avail_in = in.size();
|
||||
zs.next_in = in.data();
|
||||
}
|
||||
else if(! did_read)
|
||||
{
|
||||
@@ -1225,8 +1219,8 @@ loop:
|
||||
auto const in = buffers_prefix(
|
||||
clamp(rd_remain_), buffers_front(
|
||||
rd_buf_.data()));
|
||||
zs.avail_in = buffer_size(in);
|
||||
zs.next_in = buffer_cast<void const*>(in);
|
||||
zs.avail_in = in.size();
|
||||
zs.next_in = in.data();
|
||||
did_read = true;
|
||||
}
|
||||
else
|
||||
@@ -1299,7 +1293,8 @@ loop:
|
||||
|
||||
template<class NextLayer>
|
||||
template<class MutableBufferSequence, class ReadHandler>
|
||||
async_return_type<ReadHandler, void(error_code, std::size_t)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
ReadHandler, void(error_code, std::size_t))
|
||||
stream<NextLayer>::
|
||||
async_read_some(
|
||||
MutableBufferSequence const& buffers,
|
||||
@@ -1307,13 +1302,13 @@ async_read_some(
|
||||
{
|
||||
static_assert(is_async_stream<next_layer_type>::value,
|
||||
"AsyncStream requirements requirements not met");
|
||||
static_assert(is_mutable_buffer_sequence<
|
||||
static_assert(boost::asio::is_mutable_buffer_sequence<
|
||||
MutableBufferSequence>::value,
|
||||
"MutableBufferSequence requirements not met");
|
||||
async_completion<ReadHandler,
|
||||
boost::asio::async_completion<ReadHandler,
|
||||
void(error_code, std::size_t)> init{handler};
|
||||
read_some_op<MutableBufferSequence, handler_type<
|
||||
ReadHandler, void(error_code, std::size_t)>>{
|
||||
read_some_op<MutableBufferSequence, BOOST_ASIO_HANDLER_TYPE(
|
||||
ReadHandler, void(error_code, std::size_t))>{
|
||||
init.completion_handler,*this, buffers}(
|
||||
{}, 0, false);
|
||||
return init.result.get();
|
||||
|
||||
@@ -91,7 +91,8 @@ std::size_t
|
||||
stream<NextLayer>::
|
||||
read_size_hint(DynamicBuffer& buffer) const
|
||||
{
|
||||
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
auto const initial_size = (std::min)(
|
||||
+tcp_frame_size,
|
||||
@@ -503,7 +504,7 @@ write_ping(DynamicBuffer& db,
|
||||
detail::prepare_key(key, fh.key);
|
||||
auto mb = db.prepare(data.size());
|
||||
boost::asio::buffer_copy(mb,
|
||||
boost::asio::const_buffers_1(
|
||||
boost::asio::const_buffer(
|
||||
data.data(), data.size()));
|
||||
if(fh.mask)
|
||||
detail::mask_inplace(mb, key);
|
||||
|
||||
@@ -12,9 +12,10 @@
|
||||
|
||||
#include <boost/beast/core/bind_handler.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/associated_allocator.hpp>
|
||||
#include <boost/asio/associated_executor.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/asio/post.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace boost {
|
||||
@@ -49,29 +50,29 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
using allocator_type =
|
||||
boost::asio::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_allocator(h_);
|
||||
}
|
||||
|
||||
using executor_type = boost::asio::associated_executor_t<
|
||||
Handler, decltype(s_.get_executor())>;
|
||||
|
||||
executor_type get_executor() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_executor(
|
||||
h_, s_.get_executor());
|
||||
}
|
||||
|
||||
void
|
||||
operator()(
|
||||
error_code ec = {},
|
||||
std::size_t bytes_transferred = 0);
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(std::size_t size,
|
||||
teardown_tcp_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
void asio_handler_deallocate(void* p,
|
||||
std::size_t size, teardown_tcp_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(teardown_tcp_op* op)
|
||||
{
|
||||
@@ -79,16 +80,6 @@ public:
|
||||
return op->step_ >= 3 ||
|
||||
asio_handler_is_continuation(std::addressof(op->h_));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f,
|
||||
teardown_tcp_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(
|
||||
f, std::addressof(op->h_));
|
||||
}
|
||||
};
|
||||
|
||||
template<class Handler>
|
||||
@@ -105,7 +96,8 @@ operator()(error_code ec, std::size_t)
|
||||
if(ec)
|
||||
{
|
||||
step_ = 1;
|
||||
return s_.get_io_service().post(
|
||||
return boost::asio::post(
|
||||
s_.get_executor(),
|
||||
bind_handler(std::move(*this), ec, 0));
|
||||
}
|
||||
step_ = 2;
|
||||
|
||||
@@ -20,10 +20,10 @@
|
||||
#include <boost/beast/core/detail/clamp.hpp>
|
||||
#include <boost/beast/core/detail/config.hpp>
|
||||
#include <boost/beast/websocket/detail/frame.hpp>
|
||||
#include <boost/asio/associated_allocator.hpp>
|
||||
#include <boost/asio/associated_executor.hpp>
|
||||
#include <boost/asio/coroutine.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
@@ -71,6 +71,24 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
using allocator_type =
|
||||
boost::asio::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_allocator(h_);
|
||||
}
|
||||
|
||||
using executor_type = boost::asio::associated_executor_t<
|
||||
Handler, decltype(ws_.get_executor())>;
|
||||
|
||||
executor_type get_executor() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_executor(
|
||||
h_, ws_.get_executor());
|
||||
}
|
||||
|
||||
Handler&
|
||||
handler()
|
||||
{
|
||||
@@ -82,24 +100,6 @@ public:
|
||||
std::size_t bytes_transferred = 0,
|
||||
bool cont = true);
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, write_some_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
void asio_handler_deallocate(
|
||||
void* p, std::size_t size, write_some_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(write_some_op* op)
|
||||
{
|
||||
@@ -107,15 +107,6 @@ public:
|
||||
return op->cont_ || asio_handler_is_continuation(
|
||||
std::addressof(op->h_));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, write_some_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(
|
||||
f, std::addressof(op->h_));
|
||||
}
|
||||
};
|
||||
|
||||
template<class NextLayer>
|
||||
@@ -132,7 +123,7 @@ operator()(
|
||||
using boost::asio::buffer;
|
||||
using boost::asio::buffer_copy;
|
||||
using boost::asio::buffer_size;
|
||||
using boost::asio::mutable_buffers_1;
|
||||
using boost::asio::mutable_buffer;
|
||||
enum
|
||||
{
|
||||
do_nomask_nofrag,
|
||||
@@ -225,7 +216,8 @@ operator()(
|
||||
|
||||
// Resume
|
||||
BOOST_ASIO_CORO_YIELD
|
||||
ws_.get_io_service().post(std::move(*this));
|
||||
boost::asio::post(
|
||||
ws_.get_executor(), std::move(*this));
|
||||
BOOST_ASSERT(ws_.wr_block_ == tok_);
|
||||
|
||||
// Make sure the stream is open
|
||||
@@ -435,8 +427,8 @@ operator()(
|
||||
// Send frame
|
||||
BOOST_ASIO_CORO_YIELD
|
||||
boost::asio::async_write(ws_.stream_,
|
||||
buffers_cat(ws_.wr_fb_.data(),
|
||||
mutable_buffers_1{b}), std::move(*this));
|
||||
buffers_cat(ws_.wr_fb_.data(), b),
|
||||
std::move(*this));
|
||||
if(! ws_.check_ok(ec))
|
||||
goto upcall;
|
||||
bytes_transferred_ += in_;
|
||||
@@ -478,7 +470,8 @@ operator()(
|
||||
ws_.paused_rd_.maybe_invoke() ||
|
||||
ws_.paused_ping_.maybe_invoke();
|
||||
if(! cont_)
|
||||
return ws_.stream_.get_io_service().post(
|
||||
return boost::asio::post(
|
||||
ws_.stream_.get_executor(),
|
||||
bind_handler(h_, ec, bytes_transferred_));
|
||||
h_(ec, bytes_transferred_);
|
||||
}
|
||||
@@ -494,7 +487,7 @@ write_some(bool fin, ConstBufferSequence const& buffers)
|
||||
{
|
||||
static_assert(is_sync_stream<next_layer_type>::value,
|
||||
"SyncStream requirements not met");
|
||||
static_assert(beast::is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
error_code ec;
|
||||
@@ -514,7 +507,7 @@ write_some(bool fin,
|
||||
{
|
||||
static_assert(is_sync_stream<next_layer_type>::value,
|
||||
"SyncStream requirements not met");
|
||||
static_assert(beast::is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
using beast::detail::clamp;
|
||||
@@ -720,21 +713,21 @@ write_some(bool fin,
|
||||
|
||||
template<class NextLayer>
|
||||
template<class ConstBufferSequence, class WriteHandler>
|
||||
async_return_type<
|
||||
WriteHandler, void(error_code, std::size_t)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
WriteHandler, void(error_code, std::size_t))
|
||||
stream<NextLayer>::
|
||||
async_write_some(bool fin,
|
||||
ConstBufferSequence const& bs, WriteHandler&& handler)
|
||||
{
|
||||
static_assert(is_async_stream<next_layer_type>::value,
|
||||
"AsyncStream requirements not met");
|
||||
static_assert(beast::is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
async_completion<WriteHandler,
|
||||
boost::asio::async_completion<WriteHandler,
|
||||
void(error_code, std::size_t)> init{handler};
|
||||
write_some_op<ConstBufferSequence, handler_type<
|
||||
WriteHandler, void(error_code, std::size_t)>>{
|
||||
write_some_op<ConstBufferSequence, BOOST_ASIO_HANDLER_TYPE(
|
||||
WriteHandler, void(error_code, std::size_t))>{
|
||||
init.completion_handler, *this, fin, bs}(
|
||||
{}, 0, false);
|
||||
return init.result.get();
|
||||
@@ -750,7 +743,7 @@ write(ConstBufferSequence const& buffers)
|
||||
{
|
||||
static_assert(is_sync_stream<next_layer_type>::value,
|
||||
"SyncStream requirements not met");
|
||||
static_assert(beast::is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
error_code ec;
|
||||
@@ -768,7 +761,7 @@ write(ConstBufferSequence const& buffers, error_code& ec)
|
||||
{
|
||||
static_assert(is_sync_stream<next_layer_type>::value,
|
||||
"SyncStream requirements not met");
|
||||
static_assert(beast::is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
return write_some(true, buffers, ec);
|
||||
@@ -776,21 +769,21 @@ write(ConstBufferSequence const& buffers, error_code& ec)
|
||||
|
||||
template<class NextLayer>
|
||||
template<class ConstBufferSequence, class WriteHandler>
|
||||
async_return_type<
|
||||
WriteHandler, void(error_code, std::size_t)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
WriteHandler, void(error_code, std::size_t))
|
||||
stream<NextLayer>::
|
||||
async_write(
|
||||
ConstBufferSequence const& bs, WriteHandler&& handler)
|
||||
{
|
||||
static_assert(is_async_stream<next_layer_type>::value,
|
||||
"AsyncStream requirements not met");
|
||||
static_assert(beast::is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
async_completion<WriteHandler,
|
||||
boost::asio::async_completion<WriteHandler,
|
||||
void(error_code, std::size_t)> init{handler};
|
||||
write_some_op<ConstBufferSequence, handler_type<
|
||||
WriteHandler, void(error_code, std::size_t)>>{
|
||||
write_some_op<ConstBufferSequence, BOOST_ASIO_HANDLER_TYPE(
|
||||
WriteHandler, void(error_code, std::size_t))>{
|
||||
init.completion_handler, *this, true, bs}(
|
||||
{}, 0, false);
|
||||
return init.result.get();
|
||||
|
||||
@@ -64,7 +64,7 @@ teardown(
|
||||
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
|
||||
manner equivalent to using boost::asio::io_service::post().
|
||||
manner equivalent to using boost::asio::io_context::post().
|
||||
|
||||
*/
|
||||
template<class AsyncStream, class TeardownHandler>
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <boost/beast/websocket/detail/pausation.hpp>
|
||||
#include <boost/beast/websocket/detail/pmd_extension.hpp>
|
||||
#include <boost/beast/websocket/detail/utf8_checker.hpp>
|
||||
#include <boost/beast/core/async_result.hpp>
|
||||
#include <boost/beast/core/static_buffer.hpp>
|
||||
#include <boost/beast/core/string.hpp>
|
||||
#include <boost/beast/core/detail/type_traits.hpp>
|
||||
@@ -31,6 +30,7 @@
|
||||
#include <boost/beast/http/detail/type_traits.hpp>
|
||||
#include <boost/beast/zlib/deflate_stream.hpp>
|
||||
#include <boost/beast/zlib/inflate_stream.hpp>
|
||||
#include <boost/asio/async_result.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
@@ -38,6 +38,8 @@
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/asio/io_context.hpp> // DEPRECATED
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace websocket {
|
||||
@@ -91,11 +93,11 @@ enum class frame_type
|
||||
you would write:
|
||||
|
||||
@code
|
||||
websocket::stream<ip::tcp::socket> ws{io_service};
|
||||
websocket::stream<ip::tcp::socket> ws{io_context};
|
||||
@endcode
|
||||
Alternatively, you can write:
|
||||
@code
|
||||
ip::tcp::socket sock{io_service};
|
||||
ip::tcp::socket sock{io_context};
|
||||
websocket::stream<ip::tcp::socket&> ws{sock};
|
||||
@endcode
|
||||
|
||||
@@ -289,19 +291,29 @@ public:
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/** Return the `io_service` associated with the stream
|
||||
/** Get the executor associated with the object.
|
||||
|
||||
This function may be used to obtain the executor object that the stream
|
||||
uses to dispatch handlers for asynchronous operations.
|
||||
|
||||
This function may be used to obtain the `io_service` object
|
||||
that the stream uses to dispatch handlers for asynchronous
|
||||
operations.
|
||||
@return A copy of the executor that stream will use to dispatch handlers.
|
||||
|
||||
@return A reference to the io_service object that the stream
|
||||
will use to dispatch handlers.
|
||||
@note This function participates in overload resolution only if
|
||||
`NextLayer` has a member function named `get_executor`.
|
||||
*/
|
||||
boost::asio::io_service&
|
||||
get_io_service()
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
implementation_defined
|
||||
#else
|
||||
template<
|
||||
class T = next_layer_type,
|
||||
class = typename std::enable_if<
|
||||
has_get_executor<next_layer_type>::value>::type>
|
||||
auto
|
||||
#endif
|
||||
get_executor() noexcept ->
|
||||
decltype(std::declval<T&>().get_executor())
|
||||
{
|
||||
return stream_.get_io_service();
|
||||
return stream_.get_executor();
|
||||
}
|
||||
|
||||
/** Get a reference to the next layer
|
||||
@@ -746,7 +758,7 @@ public:
|
||||
|
||||
@par Example
|
||||
@code
|
||||
websocket::stream<ip::tcp::socket> ws{io_service};
|
||||
websocket::stream<ip::tcp::socket> ws{io_context};
|
||||
...
|
||||
try
|
||||
{
|
||||
@@ -793,7 +805,7 @@ public:
|
||||
|
||||
@par Example
|
||||
@code
|
||||
websocket::stream<ip::tcp::socket> ws{io_service};
|
||||
websocket::stream<ip::tcp::socket> ws{io_context};
|
||||
...
|
||||
try
|
||||
{
|
||||
@@ -848,7 +860,7 @@ public:
|
||||
|
||||
@par Example
|
||||
@code
|
||||
websocket::stream<ip::tcp::socket> ws{io_service};
|
||||
websocket::stream<ip::tcp::socket> ws{io_context};
|
||||
...
|
||||
try
|
||||
{
|
||||
@@ -910,7 +922,7 @@ public:
|
||||
|
||||
@par Example
|
||||
@code
|
||||
websocket::stream<ip::tcp::socket> ws{io_service};
|
||||
websocket::stream<ip::tcp::socket> ws{io_context};
|
||||
...
|
||||
try
|
||||
{
|
||||
@@ -962,7 +974,7 @@ public:
|
||||
|
||||
@par Example
|
||||
@code
|
||||
websocket::stream<ip::tcp::socket> ws{io_service};
|
||||
websocket::stream<ip::tcp::socket> ws{io_context};
|
||||
...
|
||||
error_code ec;
|
||||
ws.handshake(host, target, ec);
|
||||
@@ -1008,7 +1020,7 @@ public:
|
||||
|
||||
@par Example
|
||||
@code
|
||||
websocket::stream<ip::tcp::socket> ws{io_service};
|
||||
websocket::stream<ip::tcp::socket> ws{io_context};
|
||||
...
|
||||
error_code ec;
|
||||
response_type res;
|
||||
@@ -1062,7 +1074,7 @@ public:
|
||||
|
||||
@par Example
|
||||
@code
|
||||
websocket::stream<ip::tcp::socket> ws{io_service};
|
||||
websocket::stream<ip::tcp::socket> ws{io_context};
|
||||
...
|
||||
error_code ec;
|
||||
ws.handshake("localhost", "/",
|
||||
@@ -1124,7 +1136,7 @@ public:
|
||||
|
||||
@par Example
|
||||
@code
|
||||
websocket::stream<ip::tcp::socket> ws{io_service};
|
||||
websocket::stream<ip::tcp::socket> ws{io_context};
|
||||
...
|
||||
error_code ec;
|
||||
response_type res;
|
||||
@@ -1187,15 +1199,11 @@ public:
|
||||
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
|
||||
manner equivalent to using `boost::asio::io_service::post`.
|
||||
manner equivalent to using `boost::asio::io_context::post`.
|
||||
*/
|
||||
template<class HandshakeHandler>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
void_or_deduced
|
||||
#else
|
||||
async_return_type<
|
||||
HandshakeHandler, void(error_code)>
|
||||
#endif
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
HandshakeHandler, void(error_code))
|
||||
async_handshake(
|
||||
string_view host,
|
||||
string_view target,
|
||||
@@ -1243,15 +1251,11 @@ public:
|
||||
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
|
||||
manner equivalent to using `boost::asio::io_service::post`.
|
||||
manner equivalent to using `boost::asio::io_context::post`.
|
||||
*/
|
||||
template<class HandshakeHandler>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
void_or_deduced
|
||||
#else
|
||||
async_return_type<
|
||||
HandshakeHandler, void(error_code)>
|
||||
#endif
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
HandshakeHandler, void(error_code))
|
||||
async_handshake(
|
||||
response_type& res,
|
||||
string_view host,
|
||||
@@ -1305,15 +1309,11 @@ public:
|
||||
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
|
||||
manner equivalent to using `boost::asio::io_service::post`.
|
||||
manner equivalent to using `boost::asio::io_context::post`.
|
||||
*/
|
||||
template<class RequestDecorator, class HandshakeHandler>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
void_or_deduced
|
||||
#else
|
||||
async_return_type<
|
||||
HandshakeHandler, void(error_code)>
|
||||
#endif
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
HandshakeHandler, void(error_code))
|
||||
async_handshake_ex(
|
||||
string_view host,
|
||||
string_view target,
|
||||
@@ -1371,15 +1371,11 @@ public:
|
||||
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
|
||||
manner equivalent to using `boost::asio::io_service::post`.
|
||||
manner equivalent to using `boost::asio::io_context::post`.
|
||||
*/
|
||||
template<class RequestDecorator, class HandshakeHandler>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
void_or_deduced
|
||||
#else
|
||||
async_return_type<
|
||||
HandshakeHandler, void(error_code)>
|
||||
#endif
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
HandshakeHandler, void(error_code))
|
||||
async_handshake_ex(
|
||||
response_type& res,
|
||||
string_view host,
|
||||
@@ -1950,15 +1946,11 @@ public:
|
||||
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
|
||||
manner equivalent to using `boost::asio::io_service::post`.
|
||||
manner equivalent to using `boost::asio::io_context::post`.
|
||||
*/
|
||||
template<class AcceptHandler>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
void_or_deduced
|
||||
#else
|
||||
async_return_type<
|
||||
AcceptHandler, void(error_code)>
|
||||
#endif
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
AcceptHandler, void(error_code))
|
||||
async_accept(AcceptHandler&& handler);
|
||||
|
||||
/** Start reading and responding to a WebSocket HTTP Upgrade request.
|
||||
@@ -2015,17 +2007,13 @@ public:
|
||||
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
|
||||
manner equivalent to using `boost::asio::io_service::post`.
|
||||
manner equivalent to using `boost::asio::io_context::post`.
|
||||
*/
|
||||
template<
|
||||
class ResponseDecorator,
|
||||
class AcceptHandler>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
void_or_deduced
|
||||
#else
|
||||
async_return_type<
|
||||
AcceptHandler, void(error_code)>
|
||||
#endif
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
AcceptHandler, void(error_code))
|
||||
async_accept_ex(
|
||||
ResponseDecorator const& decorator,
|
||||
AcceptHandler&& handler);
|
||||
@@ -2082,7 +2070,7 @@ public:
|
||||
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
|
||||
manner equivalent to using `boost::asio::io_service::post`.
|
||||
manner equivalent to using `boost::asio::io_context::post`.
|
||||
*/
|
||||
template<
|
||||
class ConstBufferSequence,
|
||||
@@ -2092,7 +2080,8 @@ public:
|
||||
#else
|
||||
typename std::enable_if<
|
||||
! http::detail::is_header<ConstBufferSequence>::value,
|
||||
async_return_type<AcceptHandler, void(error_code)>>::type
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
AcceptHandler, void(error_code))>::type
|
||||
#endif
|
||||
async_accept(
|
||||
ConstBufferSequence const& buffers,
|
||||
@@ -2159,7 +2148,7 @@ public:
|
||||
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
|
||||
manner equivalent to using `boost::asio::io_service::post`.
|
||||
manner equivalent to using `boost::asio::io_context::post`.
|
||||
*/
|
||||
template<
|
||||
class ConstBufferSequence,
|
||||
@@ -2170,7 +2159,8 @@ public:
|
||||
#else
|
||||
typename std::enable_if<
|
||||
! http::detail::is_header<ConstBufferSequence>::value,
|
||||
async_return_type<AcceptHandler, void(error_code)>>::type
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
AcceptHandler, void(error_code))>::type
|
||||
#endif
|
||||
async_accept_ex(
|
||||
ConstBufferSequence const& buffers,
|
||||
@@ -2219,17 +2209,13 @@ public:
|
||||
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
|
||||
manner equivalent to using `boost::asio::io_service::post`.
|
||||
manner equivalent to using `boost::asio::io_context::post`.
|
||||
*/
|
||||
template<
|
||||
class Body, class Allocator,
|
||||
class AcceptHandler>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
void_or_deduced
|
||||
#else
|
||||
async_return_type<
|
||||
AcceptHandler, void(error_code)>
|
||||
#endif
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
AcceptHandler, void(error_code))
|
||||
async_accept(
|
||||
http::request<Body,
|
||||
http::basic_fields<Allocator>> const& req,
|
||||
@@ -2286,18 +2272,14 @@ public:
|
||||
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
|
||||
manner equivalent to using `boost::asio::io_service::post`.
|
||||
manner equivalent to using `boost::asio::io_context::post`.
|
||||
*/
|
||||
template<
|
||||
class Body, class Allocator,
|
||||
class ResponseDecorator,
|
||||
class AcceptHandler>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
void_or_deduced
|
||||
#else
|
||||
async_return_type<
|
||||
AcceptHandler, void(error_code)>
|
||||
#endif
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
AcceptHandler, void(error_code))
|
||||
async_accept_ex(
|
||||
http::request<Body,
|
||||
http::basic_fields<Allocator>> const& req,
|
||||
@@ -2409,15 +2391,11 @@ public:
|
||||
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
|
||||
manner equivalent to using `boost::asio::io_service::post`.
|
||||
manner equivalent to using `boost::asio::io_context::post`.
|
||||
*/
|
||||
template<class CloseHandler>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
void_or_deduced
|
||||
#else
|
||||
async_return_type<
|
||||
CloseHandler, void(error_code)>
|
||||
#endif
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
CloseHandler, void(error_code))
|
||||
async_close(close_reason const& cr, CloseHandler&& handler);
|
||||
|
||||
/** Send a WebSocket ping frame.
|
||||
@@ -2491,15 +2469,11 @@ public:
|
||||
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
|
||||
manner equivalent to using `boost::asio::io_service::post`.
|
||||
manner equivalent to using `boost::asio::io_context::post`.
|
||||
*/
|
||||
template<class WriteHandler>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
void_or_deduced
|
||||
#else
|
||||
async_return_type<
|
||||
WriteHandler, void(error_code)>
|
||||
#endif
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
WriteHandler, void(error_code))
|
||||
async_ping(ping_data const& payload, WriteHandler&& handler);
|
||||
|
||||
/** Send a WebSocket pong frame.
|
||||
@@ -2588,15 +2562,11 @@ public:
|
||||
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
|
||||
manner equivalent to using `boost::asio::io_service::post`.
|
||||
manner equivalent to using `boost::asio::io_context::post`.
|
||||
*/
|
||||
template<class WriteHandler>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
void_or_deduced
|
||||
#else
|
||||
async_return_type<
|
||||
WriteHandler, void(error_code)>
|
||||
#endif
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
WriteHandler, void(error_code))
|
||||
async_pong(ping_data const& payload, WriteHandler&& handler);
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -2751,16 +2721,11 @@ public:
|
||||
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
|
||||
manner equivalent to using `boost::asio::io_service::post`.
|
||||
manner equivalent to using `boost::asio::io_context::post`.
|
||||
*/
|
||||
template<class DynamicBuffer, class ReadHandler>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
void_or_deduced
|
||||
#else
|
||||
async_return_type<
|
||||
ReadHandler,
|
||||
void(error_code, std::size_t)>
|
||||
#endif
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
ReadHandler, void(error_code, std::size_t))
|
||||
async_read(
|
||||
DynamicBuffer& buffer,
|
||||
ReadHandler&& handler);
|
||||
@@ -2936,15 +2901,11 @@ public:
|
||||
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
|
||||
manner equivalent to using `boost::asio::io_service::post`.
|
||||
manner equivalent to using `boost::asio::io_context::post`.
|
||||
*/
|
||||
template<class DynamicBuffer, class ReadHandler>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
void_or_deduced
|
||||
#else
|
||||
async_return_type<
|
||||
ReadHandler, void(error_code, std::size_t)>
|
||||
#endif
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
ReadHandler, void(error_code, std::size_t))
|
||||
async_read_some(
|
||||
DynamicBuffer& buffer,
|
||||
std::size_t limit,
|
||||
@@ -3113,14 +3074,11 @@ public:
|
||||
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
|
||||
manner equivalent to using `boost::asio::io_service::post`.
|
||||
manner equivalent to using `boost::asio::io_context::post`.
|
||||
*/
|
||||
template<class MutableBufferSequence, class ReadHandler>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
void_or_deduced
|
||||
#else
|
||||
async_return_type<ReadHandler, void(error_code, std::size_t)>
|
||||
#endif
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
ReadHandler, void(error_code, std::size_t))
|
||||
async_read_some(
|
||||
MutableBufferSequence const& buffers,
|
||||
ReadHandler&& handler);
|
||||
@@ -3257,18 +3215,13 @@ public:
|
||||
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
|
||||
manner equivalent to using `boost::asio::io_service::post`.
|
||||
manner equivalent to using `boost::asio::io_context::post`.
|
||||
*/
|
||||
template<
|
||||
class ConstBufferSequence,
|
||||
class WriteHandler>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
void_or_deduced
|
||||
#else
|
||||
async_return_type<
|
||||
WriteHandler,
|
||||
void(error_code, std::size_t)>
|
||||
#endif
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
WriteHandler, void(error_code, std::size_t))
|
||||
async_write(
|
||||
ConstBufferSequence const& buffers,
|
||||
WriteHandler&& handler);
|
||||
@@ -3389,12 +3342,8 @@ public:
|
||||
); @endcode
|
||||
*/
|
||||
template<class ConstBufferSequence, class WriteHandler>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
void_or_deduced
|
||||
#else
|
||||
async_return_type<WriteHandler,
|
||||
void(error_code, std::size_t)>
|
||||
#endif
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
WriteHandler, void(error_code, std::size_t))
|
||||
async_write_some(bool fin,
|
||||
ConstBufferSequence const& buffers, WriteHandler&& handler);
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ teardown(
|
||||
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
|
||||
manner equivalent to using boost::asio::io_service::post().
|
||||
manner equivalent to using boost::asio::io_context::post().
|
||||
|
||||
*/
|
||||
template<
|
||||
@@ -155,7 +155,7 @@ teardown(
|
||||
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
|
||||
manner equivalent to using boost::asio::io_service::post().
|
||||
manner equivalent to using boost::asio::io_context::post().
|
||||
|
||||
*/
|
||||
template<class TeardownHandler>
|
||||
|
||||
Reference in new issue
Block a user