Tidy up experimental files

This commit is contained in:
Vinnie Falco
2018-12-08 14:13:43 -08:00
parent 0a583a331d
commit d8a23776d4
21 changed files with 489 additions and 379 deletions

View File

@ -6,6 +6,7 @@ Version 198:
* flat_static_buffer_improvements
* saved_handler maintains a work_guard (websocket)
* Add buffer_traits.hpp, buffers_type
* Tidy up experimental files
API Changes:

View File

@ -0,0 +1,99 @@
//
// Copyright (c) 2018 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_CORE_DETAIL_DYNAMIC_BUFFER_REF_HPP
#define BOOST_BEAST_CORE_DETAIL_DYNAMIC_BUFFER_REF_HPP
#include <boost/asio/buffer.hpp>
#include <cstdlib>
#include <type_traits>
namespace boost {
namespace beast {
namespace detail {
template<class DynamicBuffer>
class dynamic_buffer_ref
{
DynamicBuffer& b_;
public:
using const_buffers_type = typename
DynamicBuffer::const_buffers_type;
using mutable_buffers_type = typename
DynamicBuffer::mutable_buffers_type;
dynamic_buffer_ref(
dynamic_buffer_ref&&) = default;
explicit
dynamic_buffer_ref(
DynamicBuffer& b) noexcept
: b_(b)
{
}
std::size_t
size() const noexcept
{
return b_.size();
}
std::size_t
max_size() const noexcept
{
return b_.max_size();
}
std::size_t
capacity() const noexcept
{
return b_.capacity();
}
const_buffers_type
data() const noexcept
{
return b_.data();
}
mutable_buffers_type
prepare(std::size_t n)
{
return b_.prepare(n);
}
void
commit(std::size_t n)
{
b_.commit(n);
}
void
consume(std::size_t n)
{
b_.consume(n);
}
};
template<class DynamicBuffer>
typename std::enable_if<
net::is_dynamic_buffer<DynamicBuffer>::value,
dynamic_buffer_ref<DynamicBuffer>>::type
ref(DynamicBuffer& b)
{
return dynamic_buffer_ref<DynamicBuffer>(b);
}
} // detail
} // beast
} // boost
#endif

View File

@ -34,7 +34,8 @@ public:
template<class BufferSequence>
static
coalesce_result
coalesce(BufferSequence const& buffers, std::size_t limit)
coalesce(
BufferSequence const& buffers, std::size_t limit)
{
coalesce_result result{0, false};
auto first = net::buffer_sequence_begin(buffers);

View File

@ -41,7 +41,7 @@ class saved_handler
void operator()() override
{
boost::asio::dispatch(std::move(h_));
net::dispatch(std::move(h_));
}
};

View File

@ -21,7 +21,7 @@
namespace boost {
namespace beast {
/** Stream wrapper to improve ssl::stream write performance.
/** Stream wrapper to improve write performance.
This wrapper flattens writes for buffer sequences having length
greater than 1 and total size below a predefined amount, using
@ -30,6 +30,11 @@ namespace beast {
which does not use OpenSSL's scatter/gather interface for its
low-level read some and write some operations.
It is normally not necessary to use this class directly if you
are already using @ref ssl_stream. The following examples shows
how to use this class with the ssl stream that comes with
networking:
@par Example
To use the @ref flat_stream template with SSL streams, declare
@ -37,12 +42,12 @@ namespace beast {
will be forwarded to the next layer's constructor:
@code
flat_stream<ssl::stream<ip::tcp::socket>> fs{ioc, ctx};
flat_stream<net::ssl::stream<ip::tcp::socket>> fs{ioc, ctx};
@endcode
Alternatively you can write
@code
ssl::stream<ip::tcp::socket> ss{ioc, ctx};
flat_stream<ssl::stream<ip::tcp::socket>&> fs{ss};
flat_stream<net::ssl::stream<ip::tcp::socket>&> fs{ss};
@endcode
The resulting stream may be passed to any stream algorithms which
@ -58,7 +63,7 @@ namespace beast {
The stream may also be used as a template parameter in other
stream wrappers, such as for websocket:
@code
websocket::stream<flat_stream<ssl::stream<ip::tcp::socket>>> ws{ioc, ctx};
websocket::stream<flat_stream<net::ssl::stream<ip::tcp::socket>>> ws{ioc, ctx};
@endcode
@tparam NextLayer The type representing the next layer, to which
@ -147,7 +152,7 @@ public:
stream layers.
*/
next_layer_type&
next_layer()
next_layer() noexcept
{
return stream_;
}
@ -161,7 +166,7 @@ public:
stream layers.
*/
next_layer_type const&
next_layer() const
next_layer() const noexcept
{
return stream_;
}
@ -175,7 +180,7 @@ public:
stream layers.
*/
lowest_layer_type&
lowest_layer()
lowest_layer() noexcept
{
return stream_.lowest_layer();
}
@ -189,7 +194,7 @@ public:
stream layers. Ownership is not transferred to the caller.
*/
lowest_layer_type const&
lowest_layer() const
lowest_layer() const noexcept
{
return stream_.lowest_layer();
}
@ -349,6 +354,6 @@ public:
} // beast
} // boost
#include <boost/beast/_experimental/core/impl/flat_stream.ipp>
#include <boost/beast/_experimental/core/impl/flat_stream.hpp>
#endif

View File

@ -7,8 +7,8 @@
// Official repository: https://github.com/boostorg/beast
//
#ifndef BOOST_BEAST_CORE_IMPL_FLAT_STREAM_IPP
#define BOOST_BEAST_CORE_IMPL_FLAT_STREAM_IPP
#ifndef BOOST_BEAST_CORE_IMPL_FLAT_STREAM_HPP
#define BOOST_BEAST_CORE_IMPL_FLAT_STREAM_HPP
#include <boost/beast/core/buffers_prefix.hpp>
#include <boost/beast/websocket/teardown.hpp>
@ -16,6 +16,7 @@
#include <boost/asio/associated_executor.hpp>
#include <boost/asio/buffer.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>
@ -73,36 +74,30 @@ public:
{
}
using allocator_type =
net::associated_allocator_t<Handler>;
allocator_type
get_allocator() const noexcept
{
return (net::get_associated_allocator)(h_);
}
using executor_type = net::associated_executor_t<
Handler, decltype(std::declval<NextLayer&>().get_executor())>;
executor_type
get_executor() const noexcept
{
return (net::get_associated_executor)(
h_, s_.get_executor());
}
void
operator()(
boost::system::error_code ec,
std::size_t bytes_transferred);
friend
bool asio_handler_is_continuation(write_op* op)
//
using allocator_type =
net::associated_allocator_t<Handler>;
using executor_type = net::associated_executor_t<
Handler, decltype(std::declval<NextLayer&>().get_executor())>;
allocator_type
get_allocator() const noexcept
{
using net::asio_handler_is_continuation;
return asio_handler_is_continuation(
std::addressof(op->h_));
return net::get_associated_allocator(h_);
}
executor_type
get_executor() const noexcept
{
return net::get_associated_executor(
h_, s_.get_executor());
}
template<class Function>
@ -112,6 +107,32 @@ public:
using net::asio_handler_invoke;
asio_handler_invoke(f, std::addressof(op->h_));
}
friend
void* asio_handler_allocate(
std::size_t size, write_op* op)
{
using net::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 net::asio_handler_deallocate;
asio_handler_deallocate(
p, size, std::addressof(op->h_));
}
friend
bool asio_handler_is_continuation(write_op* op)
{
using net::asio_handler_is_continuation;
return asio_handler_is_continuation(
std::addressof(op->h_));
}
};
template<class NextLayer>

View File

@ -10,7 +10,7 @@
#ifndef BOOST_BEAST_CORE_IMPL_TIMEOUT_SOCKET_HPP
#define BOOST_BEAST_CORE_IMPL_TIMEOUT_SOCKET_HPP
#include <boost/beast/core/type_traits.hpp>
#include <boost/beast/core/detail/stream_algorithm.hpp>
#include <boost/beast/_experimental/core/timeout_work_guard.hpp>
#include <boost/asio/executor_work_guard.hpp>
#include <memory>
@ -60,43 +60,6 @@ public:
s_.sock_.async_write_some(b, std::move(*this));
}
using allocator_type =
net::associated_allocator_t<Handler>;
allocator_type
get_allocator() const noexcept
{
return net::get_associated_allocator(h_);
}
using executor_type =
net::associated_executor_t<Handler,
decltype(std::declval<basic_timeout_socket<
Protocol, Executor>&>().get_executor())>;
executor_type
get_executor() const noexcept
{
return net::get_associated_executor(
h_, s_.get_executor());
}
friend
bool asio_handler_is_continuation(async_op* op)
{
using net::asio_handler_is_continuation;
return asio_handler_is_continuation(
std::addressof(op->h_));
}
template<class Function>
friend
void asio_handler_invoke(Function&& f, async_op* op)
{
using net::asio_handler_invoke;
asio_handler_invoke(f, std::addressof(op->h_));
}
void
operator()(error_code ec, std::size_t bytes_transferred)
{
@ -111,6 +74,63 @@ public:
h_(ec, bytes_transferred);
}
//
using allocator_type =
net::associated_allocator_t<Handler>;
using executor_type =
net::associated_executor_t<Handler,
decltype(std::declval<basic_timeout_socket<
Protocol, Executor>&>().get_executor())>;
allocator_type
get_allocator() const noexcept
{
return net::get_associated_allocator(h_);
}
executor_type
get_executor() const noexcept
{
return net::get_associated_executor(
h_, s_.get_executor());
}
template<class Function>
friend
void asio_handler_invoke(Function&& f, async_op* op)
{
using net::asio_handler_invoke;
asio_handler_invoke(f, std::addressof(op->h_));
}
friend
void* asio_handler_allocate(
std::size_t size, async_op* op)
{
using net::asio_handler_allocate;
return asio_handler_allocate(
size, std::addressof(op->h_));
}
friend
void asio_handler_deallocate(
void* p, std::size_t size, async_op* op)
{
using net::asio_handler_deallocate;
asio_handler_deallocate(
p, size, std::addressof(op->h_));
}
friend
bool asio_handler_is_continuation(async_op* op)
{
using net::asio_handler_is_continuation;
return asio_handler_is_continuation(
std::addressof(op->h_));
}
private:
Handler h_;
basic_timeout_socket& s_;
@ -171,7 +191,7 @@ basic_timeout_socket<Protocol, Executor>::
template<class Protocol, class Executor>
template<class MutableBufferSequence, class ReadHandler>
BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
void(boost::system::error_code, std::size_t))
void(error_code, std::size_t))
basic_timeout_socket<Protocol, Executor>::
async_read_some(
MutableBufferSequence const& buffers,
@ -192,7 +212,7 @@ async_read_some(
template<class Protocol, class Executor>
template<class ConstBufferSequence, class WriteHandler>
BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
void(boost::system::error_code, std::size_t))
void(error_code, std::size_t))
basic_timeout_socket<Protocol, Executor>::
async_write_some(
ConstBufferSequence const& buffers,
@ -240,43 +260,6 @@ public:
std::move(*this));
}
using allocator_type =
net::associated_allocator_t<Handler>;
allocator_type
get_allocator() const noexcept
{
return net::get_associated_allocator(h_);
}
using executor_type =
net::associated_executor_t<Handler,
decltype(std::declval<basic_timeout_socket<
Protocol, Executor>&>().get_executor())>;
executor_type
get_executor() const noexcept
{
return net::get_associated_executor(
h_, s_.get_executor());
}
friend
bool asio_handler_is_continuation(connect_op* op)
{
using net::asio_handler_is_continuation;
return asio_handler_is_continuation(
std::addressof(op->h_));
}
template<class Function>
friend
void asio_handler_invoke(Function&& f, connect_op* op)
{
using net::asio_handler_invoke;
asio_handler_invoke(f, std::addressof(op->h_));
}
template<class Arg>
void
operator()(error_code ec, Arg&& arg)
@ -292,6 +275,65 @@ public:
h_(ec, std::forward<Arg>(arg));
}
//
using allocator_type =
net::associated_allocator_t<Handler>;
using executor_type =
net::associated_executor_t<Handler,
decltype(std::declval<basic_timeout_socket<
Protocol, Executor>&>().get_executor())>;
allocator_type
get_allocator() const noexcept
{
return net::get_associated_allocator(h_);
}
executor_type
get_executor() const noexcept
{
return net::get_associated_executor(
h_, s_.get_executor());
}
template<class Function>
friend
void asio_handler_invoke(
Function&& f, connect_op* op)
{
using net::asio_handler_invoke;
asio_handler_invoke(
f, std::addressof(op->h_));
}
friend
void* asio_handler_allocate(
std::size_t size, connect_op* op)
{
using net::asio_handler_allocate;
return asio_handler_allocate(
size, std::addressof(op->h_));
}
friend
void asio_handler_deallocate(
void* p, std::size_t size, connect_op* op)
{
using net::asio_handler_deallocate;
asio_handler_deallocate(
p, size, std::addressof(op->h_));
}
friend
bool asio_handler_is_continuation(connect_op* op)
{
using net::asio_handler_is_continuation;
return asio_handler_is_continuation(
std::addressof(op->h_));
}
private:
Handler h_;
timeout_work_guard work_;
@ -304,7 +346,8 @@ struct any_endpoint
{
template<class Error, class Endpoint>
bool
operator()(Error const&, Endpoint const&) const noexcept
operator()(
Error const&, Endpoint const&) const noexcept
{
return true;
}
@ -344,17 +387,17 @@ template<
class EndpointSequence,
class RangeConnectHandler, class>
BOOST_ASIO_INITFN_RESULT_TYPE(RangeConnectHandler,
void(boost::system::error_code, typename Protocol::endpoint))
void(error_code, typename Protocol::endpoint))
async_connect(
basic_timeout_socket<Protocol, Executor>& s,
EndpointSequence const& endpoints,
RangeConnectHandler&& handler)
{
BOOST_BEAST_HANDLER_INIT(RangeConnectHandler,
void(boost::system::error_code, typename Protocol::endpoint));
void(error_code, typename Protocol::endpoint));
detail::connect_op<Protocol, Executor,
BOOST_ASIO_HANDLER_TYPE(RangeConnectHandler,
void(boost::system::error_code,
void(error_code,
typename Protocol::endpoint))>(
s, endpoints, detail::any_endpoint{},
std::forward<RangeConnectHandler>(handler));
@ -367,7 +410,7 @@ template<
class ConnectCondition,
class RangeConnectHandler, class>
BOOST_ASIO_INITFN_RESULT_TYPE(RangeConnectHandler,
void (boost::system::error_code, typename Protocol::endpoint))
void (error_code, typename Protocol::endpoint))
async_connect(
basic_timeout_socket<Protocol, Executor>& s,
EndpointSequence const& endpoints,
@ -375,10 +418,10 @@ async_connect(
RangeConnectHandler&& handler)
{
BOOST_BEAST_HANDLER_INIT(RangeConnectHandler,
void(boost::system::error_code, typename Protocol::endpoint));
void(error_code, typename Protocol::endpoint));
detail::connect_op<Protocol, Executor,
BOOST_ASIO_HANDLER_TYPE(RangeConnectHandler,
void(boost::system::error_code,
void(error_code,
typename Protocol::endpoint))>(
s, endpoints, connect_condition,
std::forward<RangeConnectHandler>(handler));
@ -390,17 +433,17 @@ template<
class Iterator,
class IteratorConnectHandler, class>
BOOST_ASIO_INITFN_RESULT_TYPE(IteratorConnectHandler,
void (boost::system::error_code, Iterator))
void (error_code, Iterator))
async_connect(
basic_timeout_socket<Protocol, Executor>& s,
Iterator begin, Iterator end,
IteratorConnectHandler&& handler)
{
BOOST_BEAST_HANDLER_INIT(IteratorConnectHandler,
void(boost::system::error_code, Iterator));
void(error_code, Iterator));
detail::connect_op<Protocol, Executor,
BOOST_ASIO_HANDLER_TYPE(IteratorConnectHandler,
void(boost::system::error_code, Iterator))>(
void(error_code, Iterator))>(
s, detail::endpoint_range(begin, end), detail::any_endpoint{},
std::forward<IteratorConnectHandler>(handler));
return init.result.get();
@ -412,7 +455,7 @@ template<
class ConnectCondition,
class IteratorConnectHandler, class>
BOOST_ASIO_INITFN_RESULT_TYPE(IteratorConnectHandler,
void (boost::system::error_code, Iterator))
void (error_code, Iterator))
async_connect(
basic_timeout_socket<Protocol, Executor>& s,
Iterator begin, Iterator end,
@ -420,10 +463,10 @@ async_connect(
IteratorConnectHandler&& handler)
{
BOOST_BEAST_HANDLER_INIT(IteratorConnectHandler,
void(boost::system::error_code, Iterator));
void(error_code, Iterator));
detail::connect_op<Protocol, Executor,
BOOST_ASIO_HANDLER_TYPE(IteratorConnectHandler,
void(boost::system::error_code, Iterator))>(
void(error_code, Iterator))>(
s, detail::endpoint_range(begin, end), connect_condition,
std::forward<IteratorConnectHandler>(handler));
return init.result.get();

View File

@ -146,7 +146,7 @@ public:
@endcode
*/
native_handle_type
native_handle()
native_handle() noexcept
{
return p_->next_layer().native_handle();
}
@ -163,7 +163,7 @@ public:
Ownership is not transferred to the caller.
*/
next_layer_type const&
next_layer() const
next_layer() const noexcept
{
return p_->next_layer().next_layer();
}
@ -180,7 +180,7 @@ public:
Ownership is not transferred to the caller.
*/
next_layer_type&
next_layer()
next_layer() noexcept
{
return p_->next_layer().next_layer();
}
@ -194,7 +194,7 @@ public:
Ownership is not transferred to the caller.
*/
lowest_layer_type&
lowest_layer()
lowest_layer() noexcept
{
return p_->lowest_layer();
}
@ -208,7 +208,7 @@ public:
Ownership is not transferred to the caller.
*/
lowest_layer_type const&
lowest_layer() const
lowest_layer() const noexcept
{
return p_->lowest_layer();
}

View File

@ -14,8 +14,6 @@
#include <boost/asio/io_context.hpp> // #include <boost/asio/execution_context.hpp>
#include <cstddef>
#include <functional> // temporary
namespace boost {
namespace beast {

View File

@ -51,16 +51,17 @@ template<
class basic_timeout_socket
{
template<class> class async_op;
template<class, class, class> friend class detail::connect_op;
template<class, class, class>
friend class detail::connect_op;
Executor ex_; // must come first
timeout_handle rd_timer_;
timeout_handle wr_timer_;
timeout_handle cn_timer_;
net::basic_stream_socket<Protocol> sock_;
detail::saved_handler rd_op_;
detail::saved_handler wr_op_;
detail::saved_handler cn_op_;
net::basic_stream_socket<Protocol> sock_;
public:
/// The type of the next layer.
@ -127,7 +128,7 @@ public:
stream layers.
*/
next_layer_type&
next_layer()
next_layer() noexcept
{
return sock_;
}
@ -141,7 +142,7 @@ public:
stream layers.
*/
next_layer_type const&
next_layer() const
next_layer() const noexcept
{
return sock_;
}
@ -155,7 +156,7 @@ public:
stream layers.
*/
lowest_layer_type&
lowest_layer()
lowest_layer() noexcept
{
return sock_.lowest_layer();
}
@ -169,7 +170,7 @@ public:
stream layers. Ownership is not transferred to the caller.
*/
lowest_layer_type const&
lowest_layer() const
lowest_layer() const noexcept
{
return sock_.lowest_layer();
}

View File

@ -10,6 +10,7 @@
#ifndef BOOST_BEAST_CORE_TIMEOUT_WORK_GUARD_HPP
#define BOOST_BEAST_CORE_TIMEOUT_WORK_GUARD_HPP
#include <boost/beast/core/detail/config.hpp>
#include <boost/beast/_experimental/core/timeout_service.hpp>
#include <boost/assert.hpp>

View File

@ -88,7 +88,8 @@ public:
typename std::remove_reference<NextLayer>::type;
/// The type of the lowest layer.
using lowest_layer_type = boost::beast::get_lowest_layer<next_layer_type>;
using lowest_layer_type =
get_lowest_layer<next_layer_type>;
/// The type of the executor associated with the object.
using executor_type = typename next_layer_type::executor_type;
@ -196,7 +197,7 @@ public:
@returns The number of bytes read.
@throws boost::system::system_error Thrown on failure.
@throws system_error Thrown on failure.
@note The `read_some` operation may not read all of the requested number of
bytes. Consider using the function `net::read` if you need to ensure
@ -272,7 +273,7 @@ public:
@returns The number of bytes written.
@throws boost::system::system_error Thrown on failure.
@throws system_error Thrown on failure.
@note The `write_some` operation may not transmit all of the data to the
peer. Consider using the function `net::write` if you need to
@ -340,6 +341,6 @@ public:
} // beast
} // boost
#include <boost/beast/_experimental/http/impl/icy_stream.ipp>
#include <boost/beast/_experimental/http/impl/icy_stream.hpp>
#endif

View File

@ -7,28 +7,24 @@
// Official repository: https://github.com/boostorg/beast
//
#ifndef BOOST_BEAST_CORE_IMPL_ICY_STREAM_IPP
#define BOOST_BEAST_CORE_IMPL_ICY_STREAM_IPP
#ifndef BOOST_BEAST_CORE_IMPL_ICY_STREAM_HPP
#define BOOST_BEAST_CORE_IMPL_ICY_STREAM_HPP
#include <boost/beast/_experimental/core/detail/dynamic_buffer_ref.hpp>
#include <boost/beast/core/bind_handler.hpp>
#include <boost/beast/core/buffers_adapter.hpp>
#include <boost/beast/core/buffers_prefix.hpp>
#include <boost/beast/core/buffers_suffix.hpp>
#include <boost/beast/core/detail/buffers_ref.hpp>
#include <boost/beast/core/detail/stream_algorithm.hpp>
#include <boost/beast/core/handler_ptr.hpp>
#include <boost/asio/associated_allocator.hpp>
#include <boost/asio/associated_executor.hpp>
#include <boost/asio/buffer.hpp>
#include <boost/asio/buffers_iterator.hpp>
#include <boost/asio/coroutine.hpp>
#include <boost/asio/handler_continuation_hook.hpp>
#include <boost/asio/handler_invoke_hook.hpp>
#include <boost/asio/post.hpp>
#include <boost/asio/read.hpp>
#include <boost/asio/read_until.hpp>
#include <boost/assert.hpp>
#include <boost/throw_exception.hpp>
#include <algorithm>
#include <cstring>
#include <memory>
#include <utility>
@ -38,87 +34,15 @@ namespace http {
namespace detail {
template<class DynamicBuffer>
class dynamic_buffer_ref
{
DynamicBuffer& b_;
public:
using const_buffers_type =
typename DynamicBuffer::const_buffers_type;
using mutable_buffers_type =
typename DynamicBuffer::mutable_buffers_type;
dynamic_buffer_ref(dynamic_buffer_ref&&) = default;
explicit
dynamic_buffer_ref(DynamicBuffer& b)
: b_(b)
{
}
std::size_t
size() const
{
return b_.size();
}
std::size_t
max_size() const
{
return b_.max_size();
}
std::size_t
capacity() const
{
return b_.capacity();
}
const_buffers_type
data() const
{
return b_.data();
}
mutable_buffers_type
prepare(std::size_t n)
{
return b_.prepare(n);
}
void
commit(std::size_t n)
{
b_.commit(n);
}
void
consume(std::size_t n)
{
b_.consume(n);
}
};
template<class DynamicBuffer>
typename std::enable_if<
net::is_dynamic_buffer<DynamicBuffer>::value,
dynamic_buffer_ref<DynamicBuffer>>::type
ref(DynamicBuffer& b)
{
return dynamic_buffer_ref<DynamicBuffer>(b);
}
template<class MutableBuffers, class ConstBuffers>
void
buffer_shift(MutableBuffers const& out, ConstBuffers const& in)
{
using net::buffer_size;
auto in_pos = net::buffer_sequence_end(in);
auto out_pos = net::buffer_sequence_end(out);
auto const in_begin = net::buffer_sequence_begin(in);
auto const out_begin = net::buffer_sequence_begin(out);
using net::buffer_size;
BOOST_ASSERT(buffer_size(in) == buffer_size(out));
if(in_pos == in_begin || out_pos == out_begin)
return;
@ -201,8 +125,8 @@ class icy_stream<NextLayer>::read_op
net::associated_allocator_t<Handler>::template
rebind<char>::other;
#else
std::allocator_traits<net::associated_allocator_t<Handler>>
::template rebind_alloc<char>;
std::allocator_traits<net::associated_allocator_t<
Handler>>::template rebind_alloc<char>;
#endif
struct data
@ -236,36 +160,66 @@ public:
{
}
using allocator_type =
net::associated_allocator_t<Handler>;
allocator_type
get_allocator() const noexcept
{
return (net::get_associated_allocator)(d_.handler());
}
using executor_type = net::associated_executor_t<
Handler, decltype(std::declval<NextLayer&>().get_executor())>;
executor_type
get_executor() const noexcept
{
return (net::get_associated_executor)(
d_.handler(), d_->s.get_executor());
}
void
operator()(
boost::system::error_code ec,
std::size_t bytes_transferred);
//
using allocator_type =
net::associated_allocator_t<Handler>;
using executor_type = net::associated_executor_t<
Handler, decltype(std::declval<NextLayer&>().get_executor())>;
allocator_type
get_allocator() const noexcept
{
return net::get_associated_allocator(d_.handler());
}
executor_type
get_executor() const noexcept
{
return net::get_associated_executor(
d_.handler(), d_->s.get_executor());
}
template<class Function>
friend
void asio_handler_invoke(Function&& f, read_op* op)
void asio_handler_invoke(
Function&& f, read_op* op)
{
using net::asio_handler_invoke;
asio_handler_invoke(f, std::addressof(op->d_.handler()));
asio_handler_invoke(
f, std::addressof(op->d_.handler()));
}
friend
void* asio_handler_allocate(
std::size_t size, read_op* op)
{
using net::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_op* op)
{
using net::asio_handler_deallocate;
asio_handler_deallocate(
p, size, std::addressof(op->d_.handler()));
}
friend
bool asio_handler_is_continuation(read_op* op)
{
using net::asio_handler_is_continuation;
return asio_handler_is_continuation(
std::addressof(op->d_.handler()));
}
};
@ -278,10 +232,8 @@ operator()(
error_code ec,
std::size_t bytes_transferred)
{
using net::buffer_copy;
using net::buffer_size;
using iterator = net::buffers_iterator<
typename detail::dynamic_buffer_ref<
typename beast::detail::dynamic_buffer_ref<
buffers_adapter<MutableBufferSequence>>::const_buffers_type>;
auto& d = *d_;
BOOST_ASIO_CORO_REENTER(*this)
@ -297,7 +249,7 @@ operator()(
{
if(d.s.copy_ > 0)
{
auto const n = buffer_copy(
auto const n = net::buffer_copy(
d.b.prepare(std::min<std::size_t>(
d.s.copy_, d.b.max_size())),
net::buffer(d.s.buf_));
@ -339,7 +291,7 @@ operator()(
d.s.buf_[1] != 'C' ||
d.s.buf_[2] != 'Y')
{
buffer_copy(
net::buffer_copy(
d.b.value(),
net::buffer(d.s.buf_, n));
if(d.b.max_size() < 3)
@ -369,7 +321,7 @@ operator()(
BOOST_ASIO_CORO_YIELD
net::async_read_until(
d.s.next_layer(),
detail::ref(d.b),
beast::detail::ref(d.b),
detail::match_icy<iterator>(d.match),
std::move(*this));
if(ec)
@ -395,9 +347,9 @@ operator()(
boost::in_place_init, d.b.value());
dest.consume(5);
detail::buffer_shift(
buffers_prefix(n, dest),
buffers_prefix(n, d.b.value()));
buffer_copy(d.b.value(), icy_stream::version());
beast::buffers_prefix(n, dest),
beast::buffers_prefix(n, d.b.value()));
net::buffer_copy(d.b.value(), icy_stream::version());
n += 5;
bytes_transferred = n;
}
@ -423,7 +375,7 @@ std::size_t
icy_stream<NextLayer>::
read_some(MutableBufferSequence const& buffers)
{
static_assert(boost::beast::is_sync_read_stream<next_layer_type>::value,
static_assert(is_sync_read_stream<next_layer_type>::value,
"SyncReadStream requirements not met");
static_assert(net::is_mutable_buffer_sequence<
MutableBufferSequence>::value,
@ -431,7 +383,7 @@ read_some(MutableBufferSequence const& buffers)
error_code ec;
auto n = read_some(buffers, ec);
if(ec)
BOOST_THROW_EXCEPTION(boost::system::system_error{ec});
BOOST_THROW_EXCEPTION(system_error{ec});
return n;
}
@ -441,27 +393,25 @@ std::size_t
icy_stream<NextLayer>::
read_some(MutableBufferSequence const& buffers, error_code& ec)
{
static_assert(boost::beast::is_sync_read_stream<next_layer_type>::value,
static_assert(is_sync_read_stream<next_layer_type>::value,
"SyncReadStream requirements not met");
static_assert(net::is_mutable_buffer_sequence<
MutableBufferSequence>::value,
"MutableBufferSequence requirements not met");
using net::buffer_copy;
using net::buffer_size;
using iterator = net::buffers_iterator<
typename detail::dynamic_buffer_ref<
typename beast::detail::dynamic_buffer_ref<
buffers_adapter<MutableBufferSequence>>::const_buffers_type>;
buffers_adapter<MutableBufferSequence> b(buffers);
if(b.max_size() == 0)
{
ec.assign(0, ec.category());
ec = {};
return 0;
}
if(! detect_)
{
if(copy_ > 0)
{
auto const n = buffer_copy(
auto const n = net::buffer_copy(
b.prepare(std::min<std::size_t>(
copy_, b.max_size())),
net::buffer(buf_));
@ -495,7 +445,7 @@ read_some(MutableBufferSequence const& buffers, error_code& ec)
buf_[1] != 'C' ||
buf_[2] != 'Y')
{
buffer_copy(
net::buffer_copy(
buffers,
net::buffer(buf_, n));
if(b.max_size() < 3)
@ -508,13 +458,14 @@ read_some(MutableBufferSequence const& buffers, error_code& ec)
copy_);
}
return (std::min)(n, b.max_size());
return std::min<std::size_t>(
n, b.max_size());
}
copy_ = static_cast<unsigned char>(
buffer_copy(
net::buffer_copy(
net::buffer(buf_),
version() + b.max_size()));
return buffer_copy(
return net::buffer_copy(
buffers,
version());
}
@ -522,7 +473,7 @@ read_some(MutableBufferSequence const& buffers, error_code& ec)
bool match = false;
auto n = net::read_until(
stream_,
detail::ref(b),
beast::detail::ref(b),
detail::match_icy<iterator>(match),
ec);
if(ec)
@ -547,7 +498,7 @@ read_some(MutableBufferSequence const& buffers, error_code& ec)
detail::buffer_shift(
buffers_prefix(n, dest),
buffers_prefix(n, buffers));
buffer_copy(buffers, version());
net::buffer_copy(buffers, version());
n += 5;
return n;
}
@ -563,7 +514,7 @@ async_read_some(
MutableBufferSequence const& buffers,
ReadHandler&& handler)
{
static_assert(boost::beast::is_async_read_stream<next_layer_type>::value,
static_assert(is_async_read_stream<next_layer_type>::value,
"AsyncReadStream requirements not met");
static_assert(net::is_mutable_buffer_sequence<
MutableBufferSequence >::value,
@ -585,7 +536,7 @@ std::size_t
icy_stream<NextLayer>::
write_some(MutableBufferSequence const& buffers)
{
static_assert(boost::beast::is_sync_write_stream<next_layer_type>::value,
static_assert(is_sync_write_stream<next_layer_type>::value,
"SyncWriteStream requirements not met");
static_assert(net::is_const_buffer_sequence<
MutableBufferSequence>::value,
@ -599,7 +550,7 @@ std::size_t
icy_stream<NextLayer>::
write_some(MutableBufferSequence const& buffers, error_code& ec)
{
static_assert(boost::beast::is_sync_write_stream<next_layer_type>::value,
static_assert(is_sync_write_stream<next_layer_type>::value,
"SyncWriteStream requirements not met");
static_assert(net::is_const_buffer_sequence<
MutableBufferSequence>::value,
@ -618,12 +569,13 @@ async_write_some(
MutableBufferSequence const& buffers,
WriteHandler&& handler)
{
static_assert(boost::beast::is_async_write_stream<next_layer_type>::value,
static_assert(is_async_write_stream<next_layer_type>::value,
"AsyncWriteStream requirements not met");
static_assert(net::is_const_buffer_sequence<
MutableBufferSequence>::value,
"MutableBufferSequence requirements not met");
return stream_.async_write_some(buffers, std::forward<WriteHandler>(handler));
return stream_.async_write_some(
buffers, std::forward<WriteHandler>(handler));
}
} // http

View File

@ -10,8 +10,7 @@
#ifndef BOOST_BEAST_TEST_ERROR_HPP
#define BOOST_BEAST_TEST_ERROR_HPP
#include <boost/beast/core/error.hpp>
#include <boost/beast/_experimental/test/detail/error.hpp>
#include <boost/beast/core/detail/config.hpp>
namespace boost {
namespace beast {
@ -32,6 +31,6 @@ enum class error
} // beast
} // boost
#include <boost/beast/_experimental/test/impl/error.ipp>
#include <boost/beast/_experimental/test/impl/error.hpp>
#endif

View File

@ -12,7 +12,7 @@
#include <boost/beast/core/error.hpp>
#include <boost/beast/_experimental/test/error.hpp>
#include <boost/throw_exception.hpp>
#include <cstdlib>
namespace boost {
namespace beast {
@ -42,16 +42,19 @@ public:
@param n The 0-based index of the operation to fail on or after
@param ev An optional error code to use when generating a simulated failure
*/
BOOST_BEAST_DECL
explicit
fail_count(
std::size_t n,
error_code ev = make_error_code(error::test_failure));
/// Throw an exception on the Nth failure
BOOST_BEAST_DECL
void
fail();
/// Set an error code on the Nth failure
BOOST_BEAST_DECL
bool
fail(error_code& ec);
};
@ -60,6 +63,6 @@ public:
} // beast
} // boost
#include <boost/beast/_experimental/test/impl/fail_count.ipp>
#include <boost/beast/_experimental/test/impl/fail_count.hpp>
#endif

View File

@ -7,54 +7,56 @@
// Official repository: https://github.com/boostorg/beast
//
#ifndef BOOST_BEAST_TEST_DETAIL_ERROR_HPP
#define BOOST_BEAST_TEST_DETAIL_ERROR_HPP
#ifndef BOOST_BEAST_TEST_IMPL_ERROR_HPP
#define BOOST_BEAST_TEST_IMPL_ERROR_HPP
#include <boost/beast/core/error.hpp>
#include <boost/beast/core/string.hpp>
#include <type_traits>
namespace boost {
namespace beast {
namespace test {
enum class error;
} // test
} // beast
namespace system {
template<>
struct is_error_code_enum<beast::test::error>
struct is_error_code_enum<
boost::beast::test::error>
: std::true_type
{
static bool const value = true;
};
} // system
} // boost
namespace boost {
namespace beast {
namespace test {
namespace detail {
class error_codes : public error_category
{
public:
BOOST_BEAST_DECL
const char*
name() const noexcept override;
BOOST_BEAST_DECL
std::string
message(int ev) const override;
BOOST_BEAST_DECL
error_condition
default_error_condition(int ev) const noexcept override;
};
} // detail
BOOST_BEAST_DECL
error_code
make_error_code(error e);
make_error_code(error e) noexcept;
} // test
} // beast
} // boost
#include <boost/beast/_experimental/test/impl/impl/error.hpp>
#endif

View File

@ -7,18 +7,15 @@
// Official repository: https://github.com/boostorg/beast
//
#ifndef BOOST_BEAST_TEST_IMPL_FAIL_COUNT_IPP
#define BOOST_BEAST_TEST_IMPL_FAIL_COUNT_IPP
#ifndef BOOST_BEAST_TEST_IMPL_FAIL_COUNT_HPP
#define BOOST_BEAST_TEST_IMPL_FAIL_COUNT_HPP
#include <boost/beast/core/error.hpp>
#include <boost/beast/_experimental/test/error.hpp>
#include <boost/throw_exception.hpp>
namespace boost {
namespace beast {
namespace test {
inline
fail_count::
fail_count(
std::size_t n,
@ -28,7 +25,6 @@ fail_count(
{
}
inline
void
fail_count::
fail()
@ -39,7 +35,6 @@ fail()
BOOST_THROW_EXCEPTION(system_error{ec_});
}
inline
bool
fail_count::
fail(error_code& ec)
@ -51,7 +46,7 @@ fail(error_code& ec)
ec = ec_;
return true;
}
ec.assign(0, ec.category());
ec = {};
return false;
}

View File

@ -7,8 +7,8 @@
// Official repository: https://github.com/boostorg/beast
//
#ifndef BOOST_BEAST_TEST_IMPL_ERROR_IPP
#define BOOST_BEAST_TEST_IMPL_ERROR_IPP
#ifndef BOOST_BEAST_TEST_IMPL_IMPL_ERROR_HPP
#define BOOST_BEAST_TEST_IMPL_IMPL_ERROR_HPP
namespace boost {
namespace beast {
@ -16,7 +16,6 @@ namespace test {
namespace detail {
inline
const char*
error_codes::
name() const noexcept
@ -24,7 +23,6 @@ name() const noexcept
return "boost.beast.test";
}
inline
std::string
error_codes::
message(int ev) const
@ -32,11 +30,11 @@ message(int ev) const
switch(static_cast<error>(ev))
{
default:
case error::test_failure: return "The test stream generated a simulated error";
case error::test_failure: return
"The test stream generated a simulated error";
}
}
inline
error_condition
error_codes::
default_error_condition(int ev) const noexcept
@ -46,9 +44,8 @@ default_error_condition(int ev) const noexcept
} // detail
inline
error_code
make_error_code(error e)
make_error_code(error e) noexcept
{
static detail::error_codes const cat{};
return error_code{static_cast<

View File

@ -7,16 +7,16 @@
// Official repository: https://github.com/boostorg/beast
//
#ifndef BOOST_BEAST_TEST_IMPL_STREAM_IPP
#define BOOST_BEAST_TEST_IMPL_STREAM_IPP
#ifndef BOOST_BEAST_TEST_IMPL_STREAM_HPP
#define BOOST_BEAST_TEST_IMPL_STREAM_HPP
#include <boost/beast/core/detail/stream_algorithm.hpp>
#include <boost/beast/core/buffers_prefix.hpp>
namespace boost {
namespace beast {
namespace test {
inline
stream::
~stream()
{
@ -36,7 +36,6 @@ stream::
}
}
inline
stream::
stream(stream&& other)
{
@ -47,7 +46,6 @@ stream(stream&& other)
other.in_ = in;
}
inline
stream&
stream::
operator=(stream&& other)
@ -60,14 +58,12 @@ operator=(stream&& other)
return *this;
}
inline
stream::
stream(net::io_context& ioc)
: in_(std::make_shared<state>(ioc, nullptr))
{
}
inline
stream::
stream(
net::io_context& ioc,
@ -76,21 +72,17 @@ stream(
{
}
inline
stream::
stream(
net::io_context& ioc,
string_view s)
: in_(std::make_shared<state>(ioc, nullptr))
{
using net::buffer;
using net::buffer_copy;
in_->b.commit(buffer_copy(
in_->b.commit(net::buffer_copy(
in_->b.prepare(s.size()),
buffer(s.data(), s.size())));
net::buffer(s.data(), s.size())));
}
inline
stream::
stream(
net::io_context& ioc,
@ -98,14 +90,11 @@ stream(
string_view s)
: in_(std::make_shared<state>(ioc, &fc))
{
using net::buffer;
using net::buffer_copy;
in_->b.commit(buffer_copy(
in_->b.commit(net::buffer_copy(
in_->b.prepare(s.size()),
buffer(s.data(), s.size())));
net::buffer(s.data(), s.size())));
}
inline
void
stream::
connect(stream& remote)
@ -115,32 +104,29 @@ connect(stream& remote)
out_ = remote.in_;
remote.out_ = in_;
}
inline
string_view
stream::
str() const
{
auto const bs = in_->b.data();
if(net::buffer_size(bs) == 0)
using net::buffer_size;
if(buffer_size(bs) == 0)
return {};
auto const b = buffers_front(bs);
auto const b = beast::buffers_front(bs);
return {static_cast<char const*>(b.data()), b.size()};
}
inline
void
stream::
append(string_view s)
{
using net::buffer;
using net::buffer_copy;
std::lock_guard<std::mutex> lock{in_->m};
in_->b.commit(buffer_copy(
in_->b.commit(net::buffer_copy(
in_->b.prepare(s.size()),
buffer(s.data(), s.size())));
net::buffer(s.data(), s.size())));
}
inline
void
stream::
clear()
@ -149,7 +135,6 @@ clear()
in_->b.consume(in_->b.size());
}
inline
void
stream::
close()
@ -166,7 +151,6 @@ close()
}
}
inline
void
stream::
close_remote()
@ -203,10 +187,9 @@ read_some(MutableBufferSequence const& buffers,
static_assert(net::is_mutable_buffer_sequence<
MutableBufferSequence>::value,
"MutableBufferSequence requirements not met");
using net::buffer_copy;
using net::buffer_size;
if(in_->fc && in_->fc->fail(ec))
return 0;
using net::buffer_size;
if(buffer_size(buffers) == 0)
{
ec.clear();
@ -224,8 +207,8 @@ read_some(MutableBufferSequence const& buffers,
std::size_t bytes_transferred;
if(in_->b.size() > 0)
{
ec.assign(0, ec.category());
bytes_transferred = buffer_copy(
ec = {};
bytes_transferred = net::buffer_copy(
buffers, in_->b.data(), in_->read_max);
in_->b.consume(bytes_transferred);
}
@ -253,11 +236,8 @@ async_read_some(
static_assert(net::is_mutable_buffer_sequence<
MutableBufferSequence>::value,
"MutableBufferSequence requirements not met");
using net::buffer_copy;
using net::buffer_size;
BOOST_BEAST_HANDLER_INIT(
ReadHandler, void(error_code, std::size_t));
error_code ec;
if(in_->fc && in_->fc->fail(ec))
{
@ -272,10 +252,11 @@ async_read_some(
{
std::unique_lock<std::mutex> lock{in_->m};
BOOST_ASSERT(! in_->op);
if(buffer_size(buffers) == 0 ||
using net::buffer_size;
if( buffer_size(buffers) == 0 ||
buffer_size(in_->b.data()) > 0)
{
auto const bytes_transferred = buffer_copy(
auto const bytes_transferred = net::buffer_copy(
buffers, in_->b.data(), in_->read_max);
in_->b.consume(bytes_transferred);
lock.unlock();
@ -338,8 +319,6 @@ write_some(
static_assert(net::is_const_buffer_sequence<
ConstBufferSequence>::value,
"ConstBufferSequence requirements not met");
using net::buffer_copy;
using net::buffer_size;
auto out = out_.lock();
if(! out)
{
@ -349,16 +328,17 @@ write_some(
BOOST_ASSERT(out->code == status::ok);
if(in_->fc && in_->fc->fail(ec))
return 0;
auto const n = (std::min)(
using net::buffer_size;
auto const n = std::min<std::size_t>(
buffer_size(buffers), in_->write_max);
std::unique_lock<std::mutex> lock{out->m};
auto const bytes_transferred =
buffer_copy(out->b.prepare(n), buffers);
net::buffer_copy(out->b.prepare(n), buffers);
out->b.commit(bytes_transferred);
out->on_write();
lock.unlock();
++in_->nwrite;
ec.assign(0, ec.category());
ec = {};
return bytes_transferred;
}
@ -372,8 +352,6 @@ async_write_some(ConstBufferSequence const& buffers,
static_assert(net::is_const_buffer_sequence<
ConstBufferSequence>::value,
"ConstBufferSequence requirements not met");
using net::buffer_copy;
using net::buffer_size;
BOOST_BEAST_HANDLER_INIT(
WriteHandler, void(error_code, std::size_t));
auto out = out_.lock();
@ -401,11 +379,12 @@ async_write_some(ConstBufferSequence const& buffers,
}
else
{
auto const n =
(std::min)(buffer_size(buffers), in_->write_max);
using net::buffer_size;
auto const n = std::min<std::size_t>(
buffer_size(buffers), in_->write_max);
std::unique_lock<std::mutex> lock{out->m};
auto const bytes_transferred =
buffer_copy(out->b.prepare(n), buffers);
net::buffer_copy(out->b.prepare(n), buffers);
out->b.commit(bytes_transferred);
out->on_write();
lock.unlock();
@ -422,7 +401,6 @@ async_write_some(ConstBufferSequence const& buffers,
return init.result.get();
}
inline
void
teardown(
websocket::role_type,
@ -439,11 +417,10 @@ boost::system::error_code& ec)
s.in_->fc->fail(ec))
ec = net::error::eof;
else
ec.assign(0, ec.category());
ec = {};
}
template<class TeardownHandler>
inline
void
async_teardown(
websocket::role_type,
@ -461,7 +438,7 @@ TeardownHandler&& handler)
s.in_->fc->fail(ec))
ec = net::error::eof;
else
ec.assign(0, ec.category());
ec = {};
net::post(
s.get_executor(),
@ -506,14 +483,13 @@ class stream::read_op : public stream::read_op_base
void
operator()()
{
using net::buffer_copy;
using net::buffer_size;
std::unique_lock<std::mutex> lock{s_.m};
BOOST_ASSERT(! s_.op);
if(s_.b.size() > 0)
{
auto const bytes_transferred = buffer_copy(
b_, s_.b.data(), s_.read_max);
auto const bytes_transferred =
net::buffer_copy(
b_, s_.b.data(), s_.read_max);
s_.b.consume(bytes_transferred);
auto& s = s_;
Handler h{std::move(h_)};
@ -561,7 +537,6 @@ public:
}
};
inline
stream
connect(stream& to)
{

View File

@ -178,6 +178,7 @@ public:
the peer will see the error `net::error::connection_reset`
when performing any reads or writes.
*/
BOOST_BEAST_DECL
~stream();
/** Move Constructor
@ -185,6 +186,7 @@ public:
Moving the stream while asynchronous operations are pending
results in undefined behavior.
*/
BOOST_BEAST_DECL
stream(stream&& other);
/** Move Assignment
@ -192,6 +194,7 @@ public:
Moving the stream while asynchronous operations are pending
results in undefined behavior.
*/
BOOST_BEAST_DECL
stream&
operator=(stream&& other);
@ -202,6 +205,7 @@ public:
@param ioc The `io_context` object that the stream will use to
dispatch handlers for any asynchronous operations.
*/
BOOST_BEAST_DECL
explicit
stream(net::io_context& ioc);
@ -217,6 +221,7 @@ public:
fail count. When the fail count reaches its internal limit,
a simulated failure error will be raised.
*/
BOOST_BEAST_DECL
stream(
net::io_context& ioc,
fail_count& fc);
@ -231,6 +236,7 @@ public:
@param s A string which will be appended to the input area, not
including the null terminator.
*/
BOOST_BEAST_DECL
stream(
net::io_context& ioc,
string_view s);
@ -250,12 +256,14 @@ public:
@param s A string which will be appended to the input area, not
including the null terminator.
*/
BOOST_BEAST_DECL
stream(
net::io_context& ioc,
fail_count& fc,
string_view s);
/// Establish a connection
BOOST_BEAST_DECL
void
connect(stream& remote);
@ -279,7 +287,7 @@ public:
stream layers.
*/
lowest_layer_type&
lowest_layer()
lowest_layer() noexcept
{
return *this;
}
@ -293,54 +301,57 @@ public:
stream layers. Ownership is not transferred to the caller.
*/
lowest_layer_type const&
lowest_layer() const
lowest_layer() const noexcept
{
return *this;
}
/// Set the maximum number of bytes returned by read_some
void
read_size(std::size_t n)
read_size(std::size_t n) noexcept
{
in_->read_max = n;
}
/// Set the maximum number of bytes returned by write_some
void
write_size(std::size_t n)
write_size(std::size_t n) noexcept
{
in_->write_max = n;
}
/// Direct input buffer access
buffer_type&
buffer()
buffer() noexcept
{
return in_->b;
}
/// Returns a string view representing the pending input data
BOOST_BEAST_DECL
string_view
str() const;
/// Appends a string to the pending input data
BOOST_BEAST_DECL
void
append(string_view s);
/// Clear the pending input area
BOOST_BEAST_DECL
void
clear();
/// Return the number of reads
std::size_t
nread() const
nread() const noexcept
{
return in_->nread;
}
/// Return the number of writes
std::size_t
nwrite() const
nwrite() const noexcept
{
return in_->nwrite;
}
@ -350,6 +361,7 @@ public:
The other end of the connection will see
`error::eof` after reading all the remaining data.
*/
BOOST_BEAST_DECL
void
close();
@ -358,6 +370,7 @@ public:
This end of the connection will see
`error::eof` after reading all the remaining data.
*/
BOOST_BEAST_DECL
void
close_remote();
@ -504,6 +517,7 @@ public:
#if ! BOOST_BEAST_DOXYGEN
friend
BOOST_BEAST_DECL
void
teardown(
websocket::role_type,
@ -512,6 +526,7 @@ public:
template<class TeardownHandler>
friend
BOOST_BEAST_DECL
void
async_teardown(
websocket::role_type role,
@ -534,6 +549,7 @@ stream
connect(stream& to, Args&&... args);
#else
BOOST_BEAST_DECL
stream
connect(stream& to);
@ -546,6 +562,6 @@ connect(stream& to, Arg1&& arg1, ArgN&&... argn);
} // beast
} // boost
#include <boost/beast/_experimental/test/impl/stream.ipp>
#include <boost/beast/_experimental/test/impl/stream.hpp>
#endif

View File

@ -39,7 +39,7 @@ dynamic_buffer_prepare_noexcept(
boost::optional<typename
DynamicBuffer::mutable_buffers_type> result;
result.emplace(buffer.prepare(size));
ec.assign(0, ec.category());
ec = {};
return result;
}
@ -61,7 +61,7 @@ dynamic_buffer_prepare(
boost::optional<typename
DynamicBuffer::mutable_buffers_type> result;
result.emplace(buffer.prepare(size));
ec.assign(0, ec.category());
ec = {};
return result;
}
catch(std::length_error const&)