mirror of
https://github.com/boostorg/beast.git
synced 2025-07-31 05:17:26 +02:00
Tidy up experimental files
This commit is contained in:
@ -6,6 +6,7 @@ Version 198:
|
|||||||
* flat_static_buffer_improvements
|
* flat_static_buffer_improvements
|
||||||
* saved_handler maintains a work_guard (websocket)
|
* saved_handler maintains a work_guard (websocket)
|
||||||
* Add buffer_traits.hpp, buffers_type
|
* Add buffer_traits.hpp, buffers_type
|
||||||
|
* Tidy up experimental files
|
||||||
|
|
||||||
API Changes:
|
API Changes:
|
||||||
|
|
||||||
|
@ -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
|
@ -34,7 +34,8 @@ public:
|
|||||||
template<class BufferSequence>
|
template<class BufferSequence>
|
||||||
static
|
static
|
||||||
coalesce_result
|
coalesce_result
|
||||||
coalesce(BufferSequence const& buffers, std::size_t limit)
|
coalesce(
|
||||||
|
BufferSequence const& buffers, std::size_t limit)
|
||||||
{
|
{
|
||||||
coalesce_result result{0, false};
|
coalesce_result result{0, false};
|
||||||
auto first = net::buffer_sequence_begin(buffers);
|
auto first = net::buffer_sequence_begin(buffers);
|
||||||
|
@ -41,7 +41,7 @@ class saved_handler
|
|||||||
|
|
||||||
void operator()() override
|
void operator()() override
|
||||||
{
|
{
|
||||||
boost::asio::dispatch(std::move(h_));
|
net::dispatch(std::move(h_));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
namespace boost {
|
namespace boost {
|
||||||
namespace beast {
|
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
|
This wrapper flattens writes for buffer sequences having length
|
||||||
greater than 1 and total size below a predefined amount, using
|
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
|
which does not use OpenSSL's scatter/gather interface for its
|
||||||
low-level read some and write some operations.
|
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
|
@par Example
|
||||||
|
|
||||||
To use the @ref flat_stream template with SSL streams, declare
|
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:
|
will be forwarded to the next layer's constructor:
|
||||||
|
|
||||||
@code
|
@code
|
||||||
flat_stream<ssl::stream<ip::tcp::socket>> fs{ioc, ctx};
|
flat_stream<net::ssl::stream<ip::tcp::socket>> fs{ioc, ctx};
|
||||||
@endcode
|
@endcode
|
||||||
Alternatively you can write
|
Alternatively you can write
|
||||||
@code
|
@code
|
||||||
ssl::stream<ip::tcp::socket> ss{ioc, ctx};
|
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
|
@endcode
|
||||||
|
|
||||||
The resulting stream may be passed to any stream algorithms which
|
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
|
The stream may also be used as a template parameter in other
|
||||||
stream wrappers, such as for websocket:
|
stream wrappers, such as for websocket:
|
||||||
@code
|
@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
|
@endcode
|
||||||
|
|
||||||
@tparam NextLayer The type representing the next layer, to which
|
@tparam NextLayer The type representing the next layer, to which
|
||||||
@ -147,7 +152,7 @@ public:
|
|||||||
stream layers.
|
stream layers.
|
||||||
*/
|
*/
|
||||||
next_layer_type&
|
next_layer_type&
|
||||||
next_layer()
|
next_layer() noexcept
|
||||||
{
|
{
|
||||||
return stream_;
|
return stream_;
|
||||||
}
|
}
|
||||||
@ -161,7 +166,7 @@ public:
|
|||||||
stream layers.
|
stream layers.
|
||||||
*/
|
*/
|
||||||
next_layer_type const&
|
next_layer_type const&
|
||||||
next_layer() const
|
next_layer() const noexcept
|
||||||
{
|
{
|
||||||
return stream_;
|
return stream_;
|
||||||
}
|
}
|
||||||
@ -175,7 +180,7 @@ public:
|
|||||||
stream layers.
|
stream layers.
|
||||||
*/
|
*/
|
||||||
lowest_layer_type&
|
lowest_layer_type&
|
||||||
lowest_layer()
|
lowest_layer() noexcept
|
||||||
{
|
{
|
||||||
return stream_.lowest_layer();
|
return stream_.lowest_layer();
|
||||||
}
|
}
|
||||||
@ -189,7 +194,7 @@ public:
|
|||||||
stream layers. Ownership is not transferred to the caller.
|
stream layers. Ownership is not transferred to the caller.
|
||||||
*/
|
*/
|
||||||
lowest_layer_type const&
|
lowest_layer_type const&
|
||||||
lowest_layer() const
|
lowest_layer() const noexcept
|
||||||
{
|
{
|
||||||
return stream_.lowest_layer();
|
return stream_.lowest_layer();
|
||||||
}
|
}
|
||||||
@ -349,6 +354,6 @@ public:
|
|||||||
} // beast
|
} // beast
|
||||||
} // boost
|
} // boost
|
||||||
|
|
||||||
#include <boost/beast/_experimental/core/impl/flat_stream.ipp>
|
#include <boost/beast/_experimental/core/impl/flat_stream.hpp>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
// Official repository: https://github.com/boostorg/beast
|
// Official repository: https://github.com/boostorg/beast
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef BOOST_BEAST_CORE_IMPL_FLAT_STREAM_IPP
|
#ifndef BOOST_BEAST_CORE_IMPL_FLAT_STREAM_HPP
|
||||||
#define BOOST_BEAST_CORE_IMPL_FLAT_STREAM_IPP
|
#define BOOST_BEAST_CORE_IMPL_FLAT_STREAM_HPP
|
||||||
|
|
||||||
#include <boost/beast/core/buffers_prefix.hpp>
|
#include <boost/beast/core/buffers_prefix.hpp>
|
||||||
#include <boost/beast/websocket/teardown.hpp>
|
#include <boost/beast/websocket/teardown.hpp>
|
||||||
@ -16,6 +16,7 @@
|
|||||||
#include <boost/asio/associated_executor.hpp>
|
#include <boost/asio/associated_executor.hpp>
|
||||||
#include <boost/asio/buffer.hpp>
|
#include <boost/asio/buffer.hpp>
|
||||||
#include <boost/asio/coroutine.hpp>
|
#include <boost/asio/coroutine.hpp>
|
||||||
|
#include <boost/asio/handler_alloc_hook.hpp>
|
||||||
#include <boost/asio/handler_continuation_hook.hpp>
|
#include <boost/asio/handler_continuation_hook.hpp>
|
||||||
#include <boost/asio/handler_invoke_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
|
void
|
||||||
operator()(
|
operator()(
|
||||||
boost::system::error_code ec,
|
boost::system::error_code ec,
|
||||||
std::size_t bytes_transferred);
|
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 net::get_associated_allocator(h_);
|
||||||
return asio_handler_is_continuation(
|
}
|
||||||
std::addressof(op->h_));
|
|
||||||
|
executor_type
|
||||||
|
get_executor() const noexcept
|
||||||
|
{
|
||||||
|
return net::get_associated_executor(
|
||||||
|
h_, s_.get_executor());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Function>
|
template<class Function>
|
||||||
@ -112,6 +107,32 @@ public:
|
|||||||
using net::asio_handler_invoke;
|
using net::asio_handler_invoke;
|
||||||
asio_handler_invoke(f, std::addressof(op->h_));
|
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>
|
template<class NextLayer>
|
@ -10,7 +10,7 @@
|
|||||||
#ifndef BOOST_BEAST_CORE_IMPL_TIMEOUT_SOCKET_HPP
|
#ifndef BOOST_BEAST_CORE_IMPL_TIMEOUT_SOCKET_HPP
|
||||||
#define 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/beast/_experimental/core/timeout_work_guard.hpp>
|
||||||
#include <boost/asio/executor_work_guard.hpp>
|
#include <boost/asio/executor_work_guard.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -60,43 +60,6 @@ public:
|
|||||||
s_.sock_.async_write_some(b, std::move(*this));
|
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
|
void
|
||||||
operator()(error_code ec, std::size_t bytes_transferred)
|
operator()(error_code ec, std::size_t bytes_transferred)
|
||||||
{
|
{
|
||||||
@ -111,6 +74,63 @@ public:
|
|||||||
h_(ec, bytes_transferred);
|
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:
|
private:
|
||||||
Handler h_;
|
Handler h_;
|
||||||
basic_timeout_socket& s_;
|
basic_timeout_socket& s_;
|
||||||
@ -171,7 +191,7 @@ basic_timeout_socket<Protocol, Executor>::
|
|||||||
template<class Protocol, class Executor>
|
template<class Protocol, class Executor>
|
||||||
template<class MutableBufferSequence, class ReadHandler>
|
template<class MutableBufferSequence, class ReadHandler>
|
||||||
BOOST_ASIO_INITFN_RESULT_TYPE(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>::
|
basic_timeout_socket<Protocol, Executor>::
|
||||||
async_read_some(
|
async_read_some(
|
||||||
MutableBufferSequence const& buffers,
|
MutableBufferSequence const& buffers,
|
||||||
@ -192,7 +212,7 @@ async_read_some(
|
|||||||
template<class Protocol, class Executor>
|
template<class Protocol, class Executor>
|
||||||
template<class ConstBufferSequence, class WriteHandler>
|
template<class ConstBufferSequence, class WriteHandler>
|
||||||
BOOST_ASIO_INITFN_RESULT_TYPE(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>::
|
basic_timeout_socket<Protocol, Executor>::
|
||||||
async_write_some(
|
async_write_some(
|
||||||
ConstBufferSequence const& buffers,
|
ConstBufferSequence const& buffers,
|
||||||
@ -240,43 +260,6 @@ public:
|
|||||||
std::move(*this));
|
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>
|
template<class Arg>
|
||||||
void
|
void
|
||||||
operator()(error_code ec, Arg&& arg)
|
operator()(error_code ec, Arg&& arg)
|
||||||
@ -292,6 +275,65 @@ public:
|
|||||||
h_(ec, std::forward<Arg>(arg));
|
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:
|
private:
|
||||||
Handler h_;
|
Handler h_;
|
||||||
timeout_work_guard work_;
|
timeout_work_guard work_;
|
||||||
@ -304,7 +346,8 @@ struct any_endpoint
|
|||||||
{
|
{
|
||||||
template<class Error, class Endpoint>
|
template<class Error, class Endpoint>
|
||||||
bool
|
bool
|
||||||
operator()(Error const&, Endpoint const&) const noexcept
|
operator()(
|
||||||
|
Error const&, Endpoint const&) const noexcept
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -344,17 +387,17 @@ template<
|
|||||||
class EndpointSequence,
|
class EndpointSequence,
|
||||||
class RangeConnectHandler, class>
|
class RangeConnectHandler, class>
|
||||||
BOOST_ASIO_INITFN_RESULT_TYPE(RangeConnectHandler,
|
BOOST_ASIO_INITFN_RESULT_TYPE(RangeConnectHandler,
|
||||||
void(boost::system::error_code, typename Protocol::endpoint))
|
void(error_code, typename Protocol::endpoint))
|
||||||
async_connect(
|
async_connect(
|
||||||
basic_timeout_socket<Protocol, Executor>& s,
|
basic_timeout_socket<Protocol, Executor>& s,
|
||||||
EndpointSequence const& endpoints,
|
EndpointSequence const& endpoints,
|
||||||
RangeConnectHandler&& handler)
|
RangeConnectHandler&& handler)
|
||||||
{
|
{
|
||||||
BOOST_BEAST_HANDLER_INIT(RangeConnectHandler,
|
BOOST_BEAST_HANDLER_INIT(RangeConnectHandler,
|
||||||
void(boost::system::error_code, typename Protocol::endpoint));
|
void(error_code, typename Protocol::endpoint));
|
||||||
detail::connect_op<Protocol, Executor,
|
detail::connect_op<Protocol, Executor,
|
||||||
BOOST_ASIO_HANDLER_TYPE(RangeConnectHandler,
|
BOOST_ASIO_HANDLER_TYPE(RangeConnectHandler,
|
||||||
void(boost::system::error_code,
|
void(error_code,
|
||||||
typename Protocol::endpoint))>(
|
typename Protocol::endpoint))>(
|
||||||
s, endpoints, detail::any_endpoint{},
|
s, endpoints, detail::any_endpoint{},
|
||||||
std::forward<RangeConnectHandler>(handler));
|
std::forward<RangeConnectHandler>(handler));
|
||||||
@ -367,7 +410,7 @@ template<
|
|||||||
class ConnectCondition,
|
class ConnectCondition,
|
||||||
class RangeConnectHandler, class>
|
class RangeConnectHandler, class>
|
||||||
BOOST_ASIO_INITFN_RESULT_TYPE(RangeConnectHandler,
|
BOOST_ASIO_INITFN_RESULT_TYPE(RangeConnectHandler,
|
||||||
void (boost::system::error_code, typename Protocol::endpoint))
|
void (error_code, typename Protocol::endpoint))
|
||||||
async_connect(
|
async_connect(
|
||||||
basic_timeout_socket<Protocol, Executor>& s,
|
basic_timeout_socket<Protocol, Executor>& s,
|
||||||
EndpointSequence const& endpoints,
|
EndpointSequence const& endpoints,
|
||||||
@ -375,10 +418,10 @@ async_connect(
|
|||||||
RangeConnectHandler&& handler)
|
RangeConnectHandler&& handler)
|
||||||
{
|
{
|
||||||
BOOST_BEAST_HANDLER_INIT(RangeConnectHandler,
|
BOOST_BEAST_HANDLER_INIT(RangeConnectHandler,
|
||||||
void(boost::system::error_code, typename Protocol::endpoint));
|
void(error_code, typename Protocol::endpoint));
|
||||||
detail::connect_op<Protocol, Executor,
|
detail::connect_op<Protocol, Executor,
|
||||||
BOOST_ASIO_HANDLER_TYPE(RangeConnectHandler,
|
BOOST_ASIO_HANDLER_TYPE(RangeConnectHandler,
|
||||||
void(boost::system::error_code,
|
void(error_code,
|
||||||
typename Protocol::endpoint))>(
|
typename Protocol::endpoint))>(
|
||||||
s, endpoints, connect_condition,
|
s, endpoints, connect_condition,
|
||||||
std::forward<RangeConnectHandler>(handler));
|
std::forward<RangeConnectHandler>(handler));
|
||||||
@ -390,17 +433,17 @@ template<
|
|||||||
class Iterator,
|
class Iterator,
|
||||||
class IteratorConnectHandler, class>
|
class IteratorConnectHandler, class>
|
||||||
BOOST_ASIO_INITFN_RESULT_TYPE(IteratorConnectHandler,
|
BOOST_ASIO_INITFN_RESULT_TYPE(IteratorConnectHandler,
|
||||||
void (boost::system::error_code, Iterator))
|
void (error_code, Iterator))
|
||||||
async_connect(
|
async_connect(
|
||||||
basic_timeout_socket<Protocol, Executor>& s,
|
basic_timeout_socket<Protocol, Executor>& s,
|
||||||
Iterator begin, Iterator end,
|
Iterator begin, Iterator end,
|
||||||
IteratorConnectHandler&& handler)
|
IteratorConnectHandler&& handler)
|
||||||
{
|
{
|
||||||
BOOST_BEAST_HANDLER_INIT(IteratorConnectHandler,
|
BOOST_BEAST_HANDLER_INIT(IteratorConnectHandler,
|
||||||
void(boost::system::error_code, Iterator));
|
void(error_code, Iterator));
|
||||||
detail::connect_op<Protocol, Executor,
|
detail::connect_op<Protocol, Executor,
|
||||||
BOOST_ASIO_HANDLER_TYPE(IteratorConnectHandler,
|
BOOST_ASIO_HANDLER_TYPE(IteratorConnectHandler,
|
||||||
void(boost::system::error_code, Iterator))>(
|
void(error_code, Iterator))>(
|
||||||
s, detail::endpoint_range(begin, end), detail::any_endpoint{},
|
s, detail::endpoint_range(begin, end), detail::any_endpoint{},
|
||||||
std::forward<IteratorConnectHandler>(handler));
|
std::forward<IteratorConnectHandler>(handler));
|
||||||
return init.result.get();
|
return init.result.get();
|
||||||
@ -412,7 +455,7 @@ template<
|
|||||||
class ConnectCondition,
|
class ConnectCondition,
|
||||||
class IteratorConnectHandler, class>
|
class IteratorConnectHandler, class>
|
||||||
BOOST_ASIO_INITFN_RESULT_TYPE(IteratorConnectHandler,
|
BOOST_ASIO_INITFN_RESULT_TYPE(IteratorConnectHandler,
|
||||||
void (boost::system::error_code, Iterator))
|
void (error_code, Iterator))
|
||||||
async_connect(
|
async_connect(
|
||||||
basic_timeout_socket<Protocol, Executor>& s,
|
basic_timeout_socket<Protocol, Executor>& s,
|
||||||
Iterator begin, Iterator end,
|
Iterator begin, Iterator end,
|
||||||
@ -420,10 +463,10 @@ async_connect(
|
|||||||
IteratorConnectHandler&& handler)
|
IteratorConnectHandler&& handler)
|
||||||
{
|
{
|
||||||
BOOST_BEAST_HANDLER_INIT(IteratorConnectHandler,
|
BOOST_BEAST_HANDLER_INIT(IteratorConnectHandler,
|
||||||
void(boost::system::error_code, Iterator));
|
void(error_code, Iterator));
|
||||||
detail::connect_op<Protocol, Executor,
|
detail::connect_op<Protocol, Executor,
|
||||||
BOOST_ASIO_HANDLER_TYPE(IteratorConnectHandler,
|
BOOST_ASIO_HANDLER_TYPE(IteratorConnectHandler,
|
||||||
void(boost::system::error_code, Iterator))>(
|
void(error_code, Iterator))>(
|
||||||
s, detail::endpoint_range(begin, end), connect_condition,
|
s, detail::endpoint_range(begin, end), connect_condition,
|
||||||
std::forward<IteratorConnectHandler>(handler));
|
std::forward<IteratorConnectHandler>(handler));
|
||||||
return init.result.get();
|
return init.result.get();
|
||||||
|
@ -146,7 +146,7 @@ public:
|
|||||||
@endcode
|
@endcode
|
||||||
*/
|
*/
|
||||||
native_handle_type
|
native_handle_type
|
||||||
native_handle()
|
native_handle() noexcept
|
||||||
{
|
{
|
||||||
return p_->next_layer().native_handle();
|
return p_->next_layer().native_handle();
|
||||||
}
|
}
|
||||||
@ -163,7 +163,7 @@ public:
|
|||||||
Ownership is not transferred to the caller.
|
Ownership is not transferred to the caller.
|
||||||
*/
|
*/
|
||||||
next_layer_type const&
|
next_layer_type const&
|
||||||
next_layer() const
|
next_layer() const noexcept
|
||||||
{
|
{
|
||||||
return p_->next_layer().next_layer();
|
return p_->next_layer().next_layer();
|
||||||
}
|
}
|
||||||
@ -180,7 +180,7 @@ public:
|
|||||||
Ownership is not transferred to the caller.
|
Ownership is not transferred to the caller.
|
||||||
*/
|
*/
|
||||||
next_layer_type&
|
next_layer_type&
|
||||||
next_layer()
|
next_layer() noexcept
|
||||||
{
|
{
|
||||||
return p_->next_layer().next_layer();
|
return p_->next_layer().next_layer();
|
||||||
}
|
}
|
||||||
@ -194,7 +194,7 @@ public:
|
|||||||
Ownership is not transferred to the caller.
|
Ownership is not transferred to the caller.
|
||||||
*/
|
*/
|
||||||
lowest_layer_type&
|
lowest_layer_type&
|
||||||
lowest_layer()
|
lowest_layer() noexcept
|
||||||
{
|
{
|
||||||
return p_->lowest_layer();
|
return p_->lowest_layer();
|
||||||
}
|
}
|
||||||
@ -208,7 +208,7 @@ public:
|
|||||||
Ownership is not transferred to the caller.
|
Ownership is not transferred to the caller.
|
||||||
*/
|
*/
|
||||||
lowest_layer_type const&
|
lowest_layer_type const&
|
||||||
lowest_layer() const
|
lowest_layer() const noexcept
|
||||||
{
|
{
|
||||||
return p_->lowest_layer();
|
return p_->lowest_layer();
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,6 @@
|
|||||||
#include <boost/asio/io_context.hpp> // #include <boost/asio/execution_context.hpp>
|
#include <boost/asio/io_context.hpp> // #include <boost/asio/execution_context.hpp>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
#include <functional> // temporary
|
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
|
|
||||||
|
@ -51,16 +51,17 @@ template<
|
|||||||
class basic_timeout_socket
|
class basic_timeout_socket
|
||||||
{
|
{
|
||||||
template<class> class async_op;
|
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
|
Executor ex_; // must come first
|
||||||
timeout_handle rd_timer_;
|
timeout_handle rd_timer_;
|
||||||
timeout_handle wr_timer_;
|
timeout_handle wr_timer_;
|
||||||
timeout_handle cn_timer_;
|
timeout_handle cn_timer_;
|
||||||
net::basic_stream_socket<Protocol> sock_;
|
|
||||||
detail::saved_handler rd_op_;
|
detail::saved_handler rd_op_;
|
||||||
detail::saved_handler wr_op_;
|
detail::saved_handler wr_op_;
|
||||||
detail::saved_handler cn_op_;
|
detail::saved_handler cn_op_;
|
||||||
|
net::basic_stream_socket<Protocol> sock_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// The type of the next layer.
|
/// The type of the next layer.
|
||||||
@ -127,7 +128,7 @@ public:
|
|||||||
stream layers.
|
stream layers.
|
||||||
*/
|
*/
|
||||||
next_layer_type&
|
next_layer_type&
|
||||||
next_layer()
|
next_layer() noexcept
|
||||||
{
|
{
|
||||||
return sock_;
|
return sock_;
|
||||||
}
|
}
|
||||||
@ -141,7 +142,7 @@ public:
|
|||||||
stream layers.
|
stream layers.
|
||||||
*/
|
*/
|
||||||
next_layer_type const&
|
next_layer_type const&
|
||||||
next_layer() const
|
next_layer() const noexcept
|
||||||
{
|
{
|
||||||
return sock_;
|
return sock_;
|
||||||
}
|
}
|
||||||
@ -155,7 +156,7 @@ public:
|
|||||||
stream layers.
|
stream layers.
|
||||||
*/
|
*/
|
||||||
lowest_layer_type&
|
lowest_layer_type&
|
||||||
lowest_layer()
|
lowest_layer() noexcept
|
||||||
{
|
{
|
||||||
return sock_.lowest_layer();
|
return sock_.lowest_layer();
|
||||||
}
|
}
|
||||||
@ -169,7 +170,7 @@ public:
|
|||||||
stream layers. Ownership is not transferred to the caller.
|
stream layers. Ownership is not transferred to the caller.
|
||||||
*/
|
*/
|
||||||
lowest_layer_type const&
|
lowest_layer_type const&
|
||||||
lowest_layer() const
|
lowest_layer() const noexcept
|
||||||
{
|
{
|
||||||
return sock_.lowest_layer();
|
return sock_.lowest_layer();
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#ifndef BOOST_BEAST_CORE_TIMEOUT_WORK_GUARD_HPP
|
#ifndef BOOST_BEAST_CORE_TIMEOUT_WORK_GUARD_HPP
|
||||||
#define 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/beast/_experimental/core/timeout_service.hpp>
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
|
|
||||||
|
@ -88,7 +88,8 @@ public:
|
|||||||
typename std::remove_reference<NextLayer>::type;
|
typename std::remove_reference<NextLayer>::type;
|
||||||
|
|
||||||
/// The type of the lowest layer.
|
/// 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.
|
/// The type of the executor associated with the object.
|
||||||
using executor_type = typename next_layer_type::executor_type;
|
using executor_type = typename next_layer_type::executor_type;
|
||||||
@ -196,7 +197,7 @@ public:
|
|||||||
|
|
||||||
@returns The number of bytes read.
|
@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
|
@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
|
bytes. Consider using the function `net::read` if you need to ensure
|
||||||
@ -272,7 +273,7 @@ public:
|
|||||||
|
|
||||||
@returns The number of bytes written.
|
@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
|
@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
|
peer. Consider using the function `net::write` if you need to
|
||||||
@ -340,6 +341,6 @@ public:
|
|||||||
} // beast
|
} // beast
|
||||||
} // boost
|
} // boost
|
||||||
|
|
||||||
#include <boost/beast/_experimental/http/impl/icy_stream.ipp>
|
#include <boost/beast/_experimental/http/impl/icy_stream.hpp>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -7,28 +7,24 @@
|
|||||||
// Official repository: https://github.com/boostorg/beast
|
// Official repository: https://github.com/boostorg/beast
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef BOOST_BEAST_CORE_IMPL_ICY_STREAM_IPP
|
#ifndef BOOST_BEAST_CORE_IMPL_ICY_STREAM_HPP
|
||||||
#define BOOST_BEAST_CORE_IMPL_ICY_STREAM_IPP
|
#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/bind_handler.hpp>
|
||||||
#include <boost/beast/core/buffers_adapter.hpp>
|
#include <boost/beast/core/buffers_adapter.hpp>
|
||||||
#include <boost/beast/core/buffers_prefix.hpp>
|
#include <boost/beast/core/buffers_prefix.hpp>
|
||||||
#include <boost/beast/core/buffers_suffix.hpp>
|
#include <boost/beast/core/buffers_suffix.hpp>
|
||||||
#include <boost/beast/core/detail/buffers_ref.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/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/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.hpp>
|
||||||
#include <boost/asio/read_until.hpp>
|
#include <boost/asio/read_until.hpp>
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
#include <boost/throw_exception.hpp>
|
#include <boost/throw_exception.hpp>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cstring>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
@ -38,87 +34,15 @@ namespace http {
|
|||||||
|
|
||||||
namespace detail {
|
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>
|
template<class MutableBuffers, class ConstBuffers>
|
||||||
void
|
void
|
||||||
buffer_shift(MutableBuffers const& out, ConstBuffers const& in)
|
buffer_shift(MutableBuffers const& out, ConstBuffers const& in)
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
auto in_pos = net::buffer_sequence_end(in);
|
auto in_pos = net::buffer_sequence_end(in);
|
||||||
auto out_pos = net::buffer_sequence_end(out);
|
auto out_pos = net::buffer_sequence_end(out);
|
||||||
auto const in_begin = net::buffer_sequence_begin(in);
|
auto const in_begin = net::buffer_sequence_begin(in);
|
||||||
auto const out_begin = net::buffer_sequence_begin(out);
|
auto const out_begin = net::buffer_sequence_begin(out);
|
||||||
|
using net::buffer_size;
|
||||||
BOOST_ASSERT(buffer_size(in) == buffer_size(out));
|
BOOST_ASSERT(buffer_size(in) == buffer_size(out));
|
||||||
if(in_pos == in_begin || out_pos == out_begin)
|
if(in_pos == in_begin || out_pos == out_begin)
|
||||||
return;
|
return;
|
||||||
@ -201,8 +125,8 @@ class icy_stream<NextLayer>::read_op
|
|||||||
net::associated_allocator_t<Handler>::template
|
net::associated_allocator_t<Handler>::template
|
||||||
rebind<char>::other;
|
rebind<char>::other;
|
||||||
#else
|
#else
|
||||||
std::allocator_traits<net::associated_allocator_t<Handler>>
|
std::allocator_traits<net::associated_allocator_t<
|
||||||
::template rebind_alloc<char>;
|
Handler>>::template rebind_alloc<char>;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct data
|
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
|
void
|
||||||
operator()(
|
operator()(
|
||||||
boost::system::error_code ec,
|
boost::system::error_code ec,
|
||||||
std::size_t bytes_transferred);
|
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>
|
template<class Function>
|
||||||
friend
|
friend
|
||||||
void asio_handler_invoke(Function&& f, read_op* op)
|
void asio_handler_invoke(
|
||||||
|
Function&& f, read_op* op)
|
||||||
{
|
{
|
||||||
using net::asio_handler_invoke;
|
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,
|
error_code ec,
|
||||||
std::size_t bytes_transferred)
|
std::size_t bytes_transferred)
|
||||||
{
|
{
|
||||||
using net::buffer_copy;
|
|
||||||
using net::buffer_size;
|
|
||||||
using iterator = net::buffers_iterator<
|
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>>::const_buffers_type>;
|
||||||
auto& d = *d_;
|
auto& d = *d_;
|
||||||
BOOST_ASIO_CORO_REENTER(*this)
|
BOOST_ASIO_CORO_REENTER(*this)
|
||||||
@ -297,7 +249,7 @@ operator()(
|
|||||||
{
|
{
|
||||||
if(d.s.copy_ > 0)
|
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.b.prepare(std::min<std::size_t>(
|
||||||
d.s.copy_, d.b.max_size())),
|
d.s.copy_, d.b.max_size())),
|
||||||
net::buffer(d.s.buf_));
|
net::buffer(d.s.buf_));
|
||||||
@ -339,7 +291,7 @@ operator()(
|
|||||||
d.s.buf_[1] != 'C' ||
|
d.s.buf_[1] != 'C' ||
|
||||||
d.s.buf_[2] != 'Y')
|
d.s.buf_[2] != 'Y')
|
||||||
{
|
{
|
||||||
buffer_copy(
|
net::buffer_copy(
|
||||||
d.b.value(),
|
d.b.value(),
|
||||||
net::buffer(d.s.buf_, n));
|
net::buffer(d.s.buf_, n));
|
||||||
if(d.b.max_size() < 3)
|
if(d.b.max_size() < 3)
|
||||||
@ -369,7 +321,7 @@ operator()(
|
|||||||
BOOST_ASIO_CORO_YIELD
|
BOOST_ASIO_CORO_YIELD
|
||||||
net::async_read_until(
|
net::async_read_until(
|
||||||
d.s.next_layer(),
|
d.s.next_layer(),
|
||||||
detail::ref(d.b),
|
beast::detail::ref(d.b),
|
||||||
detail::match_icy<iterator>(d.match),
|
detail::match_icy<iterator>(d.match),
|
||||||
std::move(*this));
|
std::move(*this));
|
||||||
if(ec)
|
if(ec)
|
||||||
@ -395,9 +347,9 @@ operator()(
|
|||||||
boost::in_place_init, d.b.value());
|
boost::in_place_init, d.b.value());
|
||||||
dest.consume(5);
|
dest.consume(5);
|
||||||
detail::buffer_shift(
|
detail::buffer_shift(
|
||||||
buffers_prefix(n, dest),
|
beast::buffers_prefix(n, dest),
|
||||||
buffers_prefix(n, d.b.value()));
|
beast::buffers_prefix(n, d.b.value()));
|
||||||
buffer_copy(d.b.value(), icy_stream::version());
|
net::buffer_copy(d.b.value(), icy_stream::version());
|
||||||
n += 5;
|
n += 5;
|
||||||
bytes_transferred = n;
|
bytes_transferred = n;
|
||||||
}
|
}
|
||||||
@ -423,7 +375,7 @@ std::size_t
|
|||||||
icy_stream<NextLayer>::
|
icy_stream<NextLayer>::
|
||||||
read_some(MutableBufferSequence const& buffers)
|
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");
|
"SyncReadStream requirements not met");
|
||||||
static_assert(net::is_mutable_buffer_sequence<
|
static_assert(net::is_mutable_buffer_sequence<
|
||||||
MutableBufferSequence>::value,
|
MutableBufferSequence>::value,
|
||||||
@ -431,7 +383,7 @@ read_some(MutableBufferSequence const& buffers)
|
|||||||
error_code ec;
|
error_code ec;
|
||||||
auto n = read_some(buffers, ec);
|
auto n = read_some(buffers, ec);
|
||||||
if(ec)
|
if(ec)
|
||||||
BOOST_THROW_EXCEPTION(boost::system::system_error{ec});
|
BOOST_THROW_EXCEPTION(system_error{ec});
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,27 +393,25 @@ std::size_t
|
|||||||
icy_stream<NextLayer>::
|
icy_stream<NextLayer>::
|
||||||
read_some(MutableBufferSequence const& buffers, error_code& ec)
|
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");
|
"SyncReadStream requirements not met");
|
||||||
static_assert(net::is_mutable_buffer_sequence<
|
static_assert(net::is_mutable_buffer_sequence<
|
||||||
MutableBufferSequence>::value,
|
MutableBufferSequence>::value,
|
||||||
"MutableBufferSequence requirements not met");
|
"MutableBufferSequence requirements not met");
|
||||||
using net::buffer_copy;
|
|
||||||
using net::buffer_size;
|
|
||||||
using iterator = net::buffers_iterator<
|
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>>::const_buffers_type>;
|
||||||
buffers_adapter<MutableBufferSequence> b(buffers);
|
buffers_adapter<MutableBufferSequence> b(buffers);
|
||||||
if(b.max_size() == 0)
|
if(b.max_size() == 0)
|
||||||
{
|
{
|
||||||
ec.assign(0, ec.category());
|
ec = {};
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(! detect_)
|
if(! detect_)
|
||||||
{
|
{
|
||||||
if(copy_ > 0)
|
if(copy_ > 0)
|
||||||
{
|
{
|
||||||
auto const n = buffer_copy(
|
auto const n = net::buffer_copy(
|
||||||
b.prepare(std::min<std::size_t>(
|
b.prepare(std::min<std::size_t>(
|
||||||
copy_, b.max_size())),
|
copy_, b.max_size())),
|
||||||
net::buffer(buf_));
|
net::buffer(buf_));
|
||||||
@ -495,7 +445,7 @@ read_some(MutableBufferSequence const& buffers, error_code& ec)
|
|||||||
buf_[1] != 'C' ||
|
buf_[1] != 'C' ||
|
||||||
buf_[2] != 'Y')
|
buf_[2] != 'Y')
|
||||||
{
|
{
|
||||||
buffer_copy(
|
net::buffer_copy(
|
||||||
buffers,
|
buffers,
|
||||||
net::buffer(buf_, n));
|
net::buffer(buf_, n));
|
||||||
if(b.max_size() < 3)
|
if(b.max_size() < 3)
|
||||||
@ -508,13 +458,14 @@ read_some(MutableBufferSequence const& buffers, error_code& ec)
|
|||||||
copy_);
|
copy_);
|
||||||
|
|
||||||
}
|
}
|
||||||
return (std::min)(n, b.max_size());
|
return std::min<std::size_t>(
|
||||||
|
n, b.max_size());
|
||||||
}
|
}
|
||||||
copy_ = static_cast<unsigned char>(
|
copy_ = static_cast<unsigned char>(
|
||||||
buffer_copy(
|
net::buffer_copy(
|
||||||
net::buffer(buf_),
|
net::buffer(buf_),
|
||||||
version() + b.max_size()));
|
version() + b.max_size()));
|
||||||
return buffer_copy(
|
return net::buffer_copy(
|
||||||
buffers,
|
buffers,
|
||||||
version());
|
version());
|
||||||
}
|
}
|
||||||
@ -522,7 +473,7 @@ read_some(MutableBufferSequence const& buffers, error_code& ec)
|
|||||||
bool match = false;
|
bool match = false;
|
||||||
auto n = net::read_until(
|
auto n = net::read_until(
|
||||||
stream_,
|
stream_,
|
||||||
detail::ref(b),
|
beast::detail::ref(b),
|
||||||
detail::match_icy<iterator>(match),
|
detail::match_icy<iterator>(match),
|
||||||
ec);
|
ec);
|
||||||
if(ec)
|
if(ec)
|
||||||
@ -547,7 +498,7 @@ read_some(MutableBufferSequence const& buffers, error_code& ec)
|
|||||||
detail::buffer_shift(
|
detail::buffer_shift(
|
||||||
buffers_prefix(n, dest),
|
buffers_prefix(n, dest),
|
||||||
buffers_prefix(n, buffers));
|
buffers_prefix(n, buffers));
|
||||||
buffer_copy(buffers, version());
|
net::buffer_copy(buffers, version());
|
||||||
n += 5;
|
n += 5;
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@ -563,7 +514,7 @@ async_read_some(
|
|||||||
MutableBufferSequence const& buffers,
|
MutableBufferSequence const& buffers,
|
||||||
ReadHandler&& handler)
|
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");
|
"AsyncReadStream requirements not met");
|
||||||
static_assert(net::is_mutable_buffer_sequence<
|
static_assert(net::is_mutable_buffer_sequence<
|
||||||
MutableBufferSequence >::value,
|
MutableBufferSequence >::value,
|
||||||
@ -585,7 +536,7 @@ std::size_t
|
|||||||
icy_stream<NextLayer>::
|
icy_stream<NextLayer>::
|
||||||
write_some(MutableBufferSequence const& buffers)
|
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");
|
"SyncWriteStream requirements not met");
|
||||||
static_assert(net::is_const_buffer_sequence<
|
static_assert(net::is_const_buffer_sequence<
|
||||||
MutableBufferSequence>::value,
|
MutableBufferSequence>::value,
|
||||||
@ -599,7 +550,7 @@ std::size_t
|
|||||||
icy_stream<NextLayer>::
|
icy_stream<NextLayer>::
|
||||||
write_some(MutableBufferSequence const& buffers, error_code& ec)
|
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");
|
"SyncWriteStream requirements not met");
|
||||||
static_assert(net::is_const_buffer_sequence<
|
static_assert(net::is_const_buffer_sequence<
|
||||||
MutableBufferSequence>::value,
|
MutableBufferSequence>::value,
|
||||||
@ -618,12 +569,13 @@ async_write_some(
|
|||||||
MutableBufferSequence const& buffers,
|
MutableBufferSequence const& buffers,
|
||||||
WriteHandler&& handler)
|
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");
|
"AsyncWriteStream requirements not met");
|
||||||
static_assert(net::is_const_buffer_sequence<
|
static_assert(net::is_const_buffer_sequence<
|
||||||
MutableBufferSequence>::value,
|
MutableBufferSequence>::value,
|
||||||
"MutableBufferSequence requirements not met");
|
"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
|
} // http
|
@ -10,8 +10,7 @@
|
|||||||
#ifndef BOOST_BEAST_TEST_ERROR_HPP
|
#ifndef BOOST_BEAST_TEST_ERROR_HPP
|
||||||
#define BOOST_BEAST_TEST_ERROR_HPP
|
#define BOOST_BEAST_TEST_ERROR_HPP
|
||||||
|
|
||||||
#include <boost/beast/core/error.hpp>
|
#include <boost/beast/core/detail/config.hpp>
|
||||||
#include <boost/beast/_experimental/test/detail/error.hpp>
|
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
@ -32,6 +31,6 @@ enum class error
|
|||||||
} // beast
|
} // beast
|
||||||
} // boost
|
} // boost
|
||||||
|
|
||||||
#include <boost/beast/_experimental/test/impl/error.ipp>
|
#include <boost/beast/_experimental/test/impl/error.hpp>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#include <boost/beast/core/error.hpp>
|
#include <boost/beast/core/error.hpp>
|
||||||
#include <boost/beast/_experimental/test/error.hpp>
|
#include <boost/beast/_experimental/test/error.hpp>
|
||||||
#include <boost/throw_exception.hpp>
|
#include <cstdlib>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
@ -42,16 +42,19 @@ public:
|
|||||||
@param n The 0-based index of the operation to fail on or after
|
@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
|
@param ev An optional error code to use when generating a simulated failure
|
||||||
*/
|
*/
|
||||||
|
BOOST_BEAST_DECL
|
||||||
explicit
|
explicit
|
||||||
fail_count(
|
fail_count(
|
||||||
std::size_t n,
|
std::size_t n,
|
||||||
error_code ev = make_error_code(error::test_failure));
|
error_code ev = make_error_code(error::test_failure));
|
||||||
|
|
||||||
/// Throw an exception on the Nth failure
|
/// Throw an exception on the Nth failure
|
||||||
|
BOOST_BEAST_DECL
|
||||||
void
|
void
|
||||||
fail();
|
fail();
|
||||||
|
|
||||||
/// Set an error code on the Nth failure
|
/// Set an error code on the Nth failure
|
||||||
|
BOOST_BEAST_DECL
|
||||||
bool
|
bool
|
||||||
fail(error_code& ec);
|
fail(error_code& ec);
|
||||||
};
|
};
|
||||||
@ -60,6 +63,6 @@ public:
|
|||||||
} // beast
|
} // beast
|
||||||
} // boost
|
} // boost
|
||||||
|
|
||||||
#include <boost/beast/_experimental/test/impl/fail_count.ipp>
|
#include <boost/beast/_experimental/test/impl/fail_count.hpp>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -7,54 +7,56 @@
|
|||||||
// Official repository: https://github.com/boostorg/beast
|
// Official repository: https://github.com/boostorg/beast
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef BOOST_BEAST_TEST_DETAIL_ERROR_HPP
|
#ifndef BOOST_BEAST_TEST_IMPL_ERROR_HPP
|
||||||
#define BOOST_BEAST_TEST_DETAIL_ERROR_HPP
|
#define BOOST_BEAST_TEST_IMPL_ERROR_HPP
|
||||||
|
|
||||||
#include <boost/beast/core/error.hpp>
|
#include <boost/beast/core/error.hpp>
|
||||||
#include <boost/beast/core/string.hpp>
|
#include <boost/beast/core/string.hpp>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace test {
|
|
||||||
enum class error;
|
|
||||||
} // test
|
|
||||||
} // beast
|
|
||||||
|
|
||||||
namespace system {
|
namespace system {
|
||||||
template<>
|
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
|
} // system
|
||||||
|
} // boost
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
class error_codes : public error_category
|
class error_codes : public error_category
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
BOOST_BEAST_DECL
|
||||||
const char*
|
const char*
|
||||||
name() const noexcept override;
|
name() const noexcept override;
|
||||||
|
|
||||||
|
BOOST_BEAST_DECL
|
||||||
std::string
|
std::string
|
||||||
message(int ev) const override;
|
message(int ev) const override;
|
||||||
|
|
||||||
|
BOOST_BEAST_DECL
|
||||||
error_condition
|
error_condition
|
||||||
default_error_condition(int ev) const noexcept override;
|
default_error_condition(int ev) const noexcept override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // detail
|
} // detail
|
||||||
|
|
||||||
|
BOOST_BEAST_DECL
|
||||||
error_code
|
error_code
|
||||||
make_error_code(error e);
|
make_error_code(error e) noexcept;
|
||||||
|
|
||||||
} // test
|
} // test
|
||||||
} // beast
|
} // beast
|
||||||
|
|
||||||
} // boost
|
} // boost
|
||||||
|
|
||||||
|
#include <boost/beast/_experimental/test/impl/impl/error.hpp>
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -7,18 +7,15 @@
|
|||||||
// Official repository: https://github.com/boostorg/beast
|
// Official repository: https://github.com/boostorg/beast
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef BOOST_BEAST_TEST_IMPL_FAIL_COUNT_IPP
|
#ifndef BOOST_BEAST_TEST_IMPL_FAIL_COUNT_HPP
|
||||||
#define BOOST_BEAST_TEST_IMPL_FAIL_COUNT_IPP
|
#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>
|
#include <boost/throw_exception.hpp>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
||||||
inline
|
|
||||||
fail_count::
|
fail_count::
|
||||||
fail_count(
|
fail_count(
|
||||||
std::size_t n,
|
std::size_t n,
|
||||||
@ -28,7 +25,6 @@ fail_count(
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
|
||||||
void
|
void
|
||||||
fail_count::
|
fail_count::
|
||||||
fail()
|
fail()
|
||||||
@ -39,7 +35,6 @@ fail()
|
|||||||
BOOST_THROW_EXCEPTION(system_error{ec_});
|
BOOST_THROW_EXCEPTION(system_error{ec_});
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
|
||||||
bool
|
bool
|
||||||
fail_count::
|
fail_count::
|
||||||
fail(error_code& ec)
|
fail(error_code& ec)
|
||||||
@ -51,7 +46,7 @@ fail(error_code& ec)
|
|||||||
ec = ec_;
|
ec = ec_;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
ec.assign(0, ec.category());
|
ec = {};
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -7,8 +7,8 @@
|
|||||||
// Official repository: https://github.com/boostorg/beast
|
// Official repository: https://github.com/boostorg/beast
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef BOOST_BEAST_TEST_IMPL_ERROR_IPP
|
#ifndef BOOST_BEAST_TEST_IMPL_IMPL_ERROR_HPP
|
||||||
#define BOOST_BEAST_TEST_IMPL_ERROR_IPP
|
#define BOOST_BEAST_TEST_IMPL_IMPL_ERROR_HPP
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
@ -16,7 +16,6 @@ namespace test {
|
|||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
inline
|
|
||||||
const char*
|
const char*
|
||||||
error_codes::
|
error_codes::
|
||||||
name() const noexcept
|
name() const noexcept
|
||||||
@ -24,7 +23,6 @@ name() const noexcept
|
|||||||
return "boost.beast.test";
|
return "boost.beast.test";
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
|
||||||
std::string
|
std::string
|
||||||
error_codes::
|
error_codes::
|
||||||
message(int ev) const
|
message(int ev) const
|
||||||
@ -32,11 +30,11 @@ message(int ev) const
|
|||||||
switch(static_cast<error>(ev))
|
switch(static_cast<error>(ev))
|
||||||
{
|
{
|
||||||
default:
|
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_condition
|
||||||
error_codes::
|
error_codes::
|
||||||
default_error_condition(int ev) const noexcept
|
default_error_condition(int ev) const noexcept
|
||||||
@ -46,9 +44,8 @@ default_error_condition(int ev) const noexcept
|
|||||||
|
|
||||||
} // detail
|
} // detail
|
||||||
|
|
||||||
inline
|
|
||||||
error_code
|
error_code
|
||||||
make_error_code(error e)
|
make_error_code(error e) noexcept
|
||||||
{
|
{
|
||||||
static detail::error_codes const cat{};
|
static detail::error_codes const cat{};
|
||||||
return error_code{static_cast<
|
return error_code{static_cast<
|
@ -7,16 +7,16 @@
|
|||||||
// Official repository: https://github.com/boostorg/beast
|
// Official repository: https://github.com/boostorg/beast
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef BOOST_BEAST_TEST_IMPL_STREAM_IPP
|
#ifndef BOOST_BEAST_TEST_IMPL_STREAM_HPP
|
||||||
#define BOOST_BEAST_TEST_IMPL_STREAM_IPP
|
#define BOOST_BEAST_TEST_IMPL_STREAM_HPP
|
||||||
|
|
||||||
|
#include <boost/beast/core/detail/stream_algorithm.hpp>
|
||||||
#include <boost/beast/core/buffers_prefix.hpp>
|
#include <boost/beast/core/buffers_prefix.hpp>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
||||||
inline
|
|
||||||
stream::
|
stream::
|
||||||
~stream()
|
~stream()
|
||||||
{
|
{
|
||||||
@ -36,7 +36,6 @@ stream::
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
|
||||||
stream::
|
stream::
|
||||||
stream(stream&& other)
|
stream(stream&& other)
|
||||||
{
|
{
|
||||||
@ -47,7 +46,6 @@ stream(stream&& other)
|
|||||||
other.in_ = in;
|
other.in_ = in;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
|
||||||
stream&
|
stream&
|
||||||
stream::
|
stream::
|
||||||
operator=(stream&& other)
|
operator=(stream&& other)
|
||||||
@ -60,14 +58,12 @@ operator=(stream&& other)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
|
||||||
stream::
|
stream::
|
||||||
stream(net::io_context& ioc)
|
stream(net::io_context& ioc)
|
||||||
: in_(std::make_shared<state>(ioc, nullptr))
|
: in_(std::make_shared<state>(ioc, nullptr))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
|
||||||
stream::
|
stream::
|
||||||
stream(
|
stream(
|
||||||
net::io_context& ioc,
|
net::io_context& ioc,
|
||||||
@ -76,21 +72,17 @@ stream(
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
|
||||||
stream::
|
stream::
|
||||||
stream(
|
stream(
|
||||||
net::io_context& ioc,
|
net::io_context& ioc,
|
||||||
string_view s)
|
string_view s)
|
||||||
: in_(std::make_shared<state>(ioc, nullptr))
|
: in_(std::make_shared<state>(ioc, nullptr))
|
||||||
{
|
{
|
||||||
using net::buffer;
|
in_->b.commit(net::buffer_copy(
|
||||||
using net::buffer_copy;
|
|
||||||
in_->b.commit(buffer_copy(
|
|
||||||
in_->b.prepare(s.size()),
|
in_->b.prepare(s.size()),
|
||||||
buffer(s.data(), s.size())));
|
net::buffer(s.data(), s.size())));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
|
||||||
stream::
|
stream::
|
||||||
stream(
|
stream(
|
||||||
net::io_context& ioc,
|
net::io_context& ioc,
|
||||||
@ -98,14 +90,11 @@ stream(
|
|||||||
string_view s)
|
string_view s)
|
||||||
: in_(std::make_shared<state>(ioc, &fc))
|
: in_(std::make_shared<state>(ioc, &fc))
|
||||||
{
|
{
|
||||||
using net::buffer;
|
in_->b.commit(net::buffer_copy(
|
||||||
using net::buffer_copy;
|
|
||||||
in_->b.commit(buffer_copy(
|
|
||||||
in_->b.prepare(s.size()),
|
in_->b.prepare(s.size()),
|
||||||
buffer(s.data(), s.size())));
|
net::buffer(s.data(), s.size())));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
|
||||||
void
|
void
|
||||||
stream::
|
stream::
|
||||||
connect(stream& remote)
|
connect(stream& remote)
|
||||||
@ -115,32 +104,29 @@ connect(stream& remote)
|
|||||||
out_ = remote.in_;
|
out_ = remote.in_;
|
||||||
remote.out_ = in_;
|
remote.out_ = in_;
|
||||||
}
|
}
|
||||||
inline
|
|
||||||
string_view
|
string_view
|
||||||
stream::
|
stream::
|
||||||
str() const
|
str() const
|
||||||
{
|
{
|
||||||
auto const bs = in_->b.data();
|
auto const bs = in_->b.data();
|
||||||
if(net::buffer_size(bs) == 0)
|
using net::buffer_size;
|
||||||
|
if(buffer_size(bs) == 0)
|
||||||
return {};
|
return {};
|
||||||
auto const b = buffers_front(bs);
|
auto const b = beast::buffers_front(bs);
|
||||||
return {static_cast<char const*>(b.data()), b.size()};
|
return {static_cast<char const*>(b.data()), b.size()};
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
|
||||||
void
|
void
|
||||||
stream::
|
stream::
|
||||||
append(string_view s)
|
append(string_view s)
|
||||||
{
|
{
|
||||||
using net::buffer;
|
|
||||||
using net::buffer_copy;
|
|
||||||
std::lock_guard<std::mutex> lock{in_->m};
|
std::lock_guard<std::mutex> lock{in_->m};
|
||||||
in_->b.commit(buffer_copy(
|
in_->b.commit(net::buffer_copy(
|
||||||
in_->b.prepare(s.size()),
|
in_->b.prepare(s.size()),
|
||||||
buffer(s.data(), s.size())));
|
net::buffer(s.data(), s.size())));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
|
||||||
void
|
void
|
||||||
stream::
|
stream::
|
||||||
clear()
|
clear()
|
||||||
@ -149,7 +135,6 @@ clear()
|
|||||||
in_->b.consume(in_->b.size());
|
in_->b.consume(in_->b.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
|
||||||
void
|
void
|
||||||
stream::
|
stream::
|
||||||
close()
|
close()
|
||||||
@ -166,7 +151,6 @@ close()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
|
||||||
void
|
void
|
||||||
stream::
|
stream::
|
||||||
close_remote()
|
close_remote()
|
||||||
@ -203,10 +187,9 @@ read_some(MutableBufferSequence const& buffers,
|
|||||||
static_assert(net::is_mutable_buffer_sequence<
|
static_assert(net::is_mutable_buffer_sequence<
|
||||||
MutableBufferSequence>::value,
|
MutableBufferSequence>::value,
|
||||||
"MutableBufferSequence requirements not met");
|
"MutableBufferSequence requirements not met");
|
||||||
using net::buffer_copy;
|
|
||||||
using net::buffer_size;
|
|
||||||
if(in_->fc && in_->fc->fail(ec))
|
if(in_->fc && in_->fc->fail(ec))
|
||||||
return 0;
|
return 0;
|
||||||
|
using net::buffer_size;
|
||||||
if(buffer_size(buffers) == 0)
|
if(buffer_size(buffers) == 0)
|
||||||
{
|
{
|
||||||
ec.clear();
|
ec.clear();
|
||||||
@ -224,8 +207,8 @@ read_some(MutableBufferSequence const& buffers,
|
|||||||
std::size_t bytes_transferred;
|
std::size_t bytes_transferred;
|
||||||
if(in_->b.size() > 0)
|
if(in_->b.size() > 0)
|
||||||
{
|
{
|
||||||
ec.assign(0, ec.category());
|
ec = {};
|
||||||
bytes_transferred = buffer_copy(
|
bytes_transferred = net::buffer_copy(
|
||||||
buffers, in_->b.data(), in_->read_max);
|
buffers, in_->b.data(), in_->read_max);
|
||||||
in_->b.consume(bytes_transferred);
|
in_->b.consume(bytes_transferred);
|
||||||
}
|
}
|
||||||
@ -253,11 +236,8 @@ async_read_some(
|
|||||||
static_assert(net::is_mutable_buffer_sequence<
|
static_assert(net::is_mutable_buffer_sequence<
|
||||||
MutableBufferSequence>::value,
|
MutableBufferSequence>::value,
|
||||||
"MutableBufferSequence requirements not met");
|
"MutableBufferSequence requirements not met");
|
||||||
using net::buffer_copy;
|
|
||||||
using net::buffer_size;
|
|
||||||
BOOST_BEAST_HANDLER_INIT(
|
BOOST_BEAST_HANDLER_INIT(
|
||||||
ReadHandler, void(error_code, std::size_t));
|
ReadHandler, void(error_code, std::size_t));
|
||||||
|
|
||||||
error_code ec;
|
error_code ec;
|
||||||
if(in_->fc && in_->fc->fail(ec))
|
if(in_->fc && in_->fc->fail(ec))
|
||||||
{
|
{
|
||||||
@ -272,10 +252,11 @@ async_read_some(
|
|||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock{in_->m};
|
std::unique_lock<std::mutex> lock{in_->m};
|
||||||
BOOST_ASSERT(! in_->op);
|
BOOST_ASSERT(! in_->op);
|
||||||
if(buffer_size(buffers) == 0 ||
|
using net::buffer_size;
|
||||||
|
if( buffer_size(buffers) == 0 ||
|
||||||
buffer_size(in_->b.data()) > 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);
|
buffers, in_->b.data(), in_->read_max);
|
||||||
in_->b.consume(bytes_transferred);
|
in_->b.consume(bytes_transferred);
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
@ -338,8 +319,6 @@ write_some(
|
|||||||
static_assert(net::is_const_buffer_sequence<
|
static_assert(net::is_const_buffer_sequence<
|
||||||
ConstBufferSequence>::value,
|
ConstBufferSequence>::value,
|
||||||
"ConstBufferSequence requirements not met");
|
"ConstBufferSequence requirements not met");
|
||||||
using net::buffer_copy;
|
|
||||||
using net::buffer_size;
|
|
||||||
auto out = out_.lock();
|
auto out = out_.lock();
|
||||||
if(! out)
|
if(! out)
|
||||||
{
|
{
|
||||||
@ -349,16 +328,17 @@ write_some(
|
|||||||
BOOST_ASSERT(out->code == status::ok);
|
BOOST_ASSERT(out->code == status::ok);
|
||||||
if(in_->fc && in_->fc->fail(ec))
|
if(in_->fc && in_->fc->fail(ec))
|
||||||
return 0;
|
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);
|
buffer_size(buffers), in_->write_max);
|
||||||
std::unique_lock<std::mutex> lock{out->m};
|
std::unique_lock<std::mutex> lock{out->m};
|
||||||
auto const bytes_transferred =
|
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->b.commit(bytes_transferred);
|
||||||
out->on_write();
|
out->on_write();
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
++in_->nwrite;
|
++in_->nwrite;
|
||||||
ec.assign(0, ec.category());
|
ec = {};
|
||||||
return bytes_transferred;
|
return bytes_transferred;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,8 +352,6 @@ async_write_some(ConstBufferSequence const& buffers,
|
|||||||
static_assert(net::is_const_buffer_sequence<
|
static_assert(net::is_const_buffer_sequence<
|
||||||
ConstBufferSequence>::value,
|
ConstBufferSequence>::value,
|
||||||
"ConstBufferSequence requirements not met");
|
"ConstBufferSequence requirements not met");
|
||||||
using net::buffer_copy;
|
|
||||||
using net::buffer_size;
|
|
||||||
BOOST_BEAST_HANDLER_INIT(
|
BOOST_BEAST_HANDLER_INIT(
|
||||||
WriteHandler, void(error_code, std::size_t));
|
WriteHandler, void(error_code, std::size_t));
|
||||||
auto out = out_.lock();
|
auto out = out_.lock();
|
||||||
@ -401,11 +379,12 @@ async_write_some(ConstBufferSequence const& buffers,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto const n =
|
using net::buffer_size;
|
||||||
(std::min)(buffer_size(buffers), in_->write_max);
|
auto const n = std::min<std::size_t>(
|
||||||
|
buffer_size(buffers), in_->write_max);
|
||||||
std::unique_lock<std::mutex> lock{out->m};
|
std::unique_lock<std::mutex> lock{out->m};
|
||||||
auto const bytes_transferred =
|
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->b.commit(bytes_transferred);
|
||||||
out->on_write();
|
out->on_write();
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
@ -422,7 +401,6 @@ async_write_some(ConstBufferSequence const& buffers,
|
|||||||
return init.result.get();
|
return init.result.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
|
||||||
void
|
void
|
||||||
teardown(
|
teardown(
|
||||||
websocket::role_type,
|
websocket::role_type,
|
||||||
@ -439,11 +417,10 @@ boost::system::error_code& ec)
|
|||||||
s.in_->fc->fail(ec))
|
s.in_->fc->fail(ec))
|
||||||
ec = net::error::eof;
|
ec = net::error::eof;
|
||||||
else
|
else
|
||||||
ec.assign(0, ec.category());
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class TeardownHandler>
|
template<class TeardownHandler>
|
||||||
inline
|
|
||||||
void
|
void
|
||||||
async_teardown(
|
async_teardown(
|
||||||
websocket::role_type,
|
websocket::role_type,
|
||||||
@ -461,7 +438,7 @@ TeardownHandler&& handler)
|
|||||||
s.in_->fc->fail(ec))
|
s.in_->fc->fail(ec))
|
||||||
ec = net::error::eof;
|
ec = net::error::eof;
|
||||||
else
|
else
|
||||||
ec.assign(0, ec.category());
|
ec = {};
|
||||||
|
|
||||||
net::post(
|
net::post(
|
||||||
s.get_executor(),
|
s.get_executor(),
|
||||||
@ -506,14 +483,13 @@ class stream::read_op : public stream::read_op_base
|
|||||||
void
|
void
|
||||||
operator()()
|
operator()()
|
||||||
{
|
{
|
||||||
using net::buffer_copy;
|
|
||||||
using net::buffer_size;
|
|
||||||
std::unique_lock<std::mutex> lock{s_.m};
|
std::unique_lock<std::mutex> lock{s_.m};
|
||||||
BOOST_ASSERT(! s_.op);
|
BOOST_ASSERT(! s_.op);
|
||||||
if(s_.b.size() > 0)
|
if(s_.b.size() > 0)
|
||||||
{
|
{
|
||||||
auto const bytes_transferred = buffer_copy(
|
auto const bytes_transferred =
|
||||||
b_, s_.b.data(), s_.read_max);
|
net::buffer_copy(
|
||||||
|
b_, s_.b.data(), s_.read_max);
|
||||||
s_.b.consume(bytes_transferred);
|
s_.b.consume(bytes_transferred);
|
||||||
auto& s = s_;
|
auto& s = s_;
|
||||||
Handler h{std::move(h_)};
|
Handler h{std::move(h_)};
|
||||||
@ -561,7 +537,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline
|
|
||||||
stream
|
stream
|
||||||
connect(stream& to)
|
connect(stream& to)
|
||||||
{
|
{
|
@ -178,6 +178,7 @@ public:
|
|||||||
the peer will see the error `net::error::connection_reset`
|
the peer will see the error `net::error::connection_reset`
|
||||||
when performing any reads or writes.
|
when performing any reads or writes.
|
||||||
*/
|
*/
|
||||||
|
BOOST_BEAST_DECL
|
||||||
~stream();
|
~stream();
|
||||||
|
|
||||||
/** Move Constructor
|
/** Move Constructor
|
||||||
@ -185,6 +186,7 @@ public:
|
|||||||
Moving the stream while asynchronous operations are pending
|
Moving the stream while asynchronous operations are pending
|
||||||
results in undefined behavior.
|
results in undefined behavior.
|
||||||
*/
|
*/
|
||||||
|
BOOST_BEAST_DECL
|
||||||
stream(stream&& other);
|
stream(stream&& other);
|
||||||
|
|
||||||
/** Move Assignment
|
/** Move Assignment
|
||||||
@ -192,6 +194,7 @@ public:
|
|||||||
Moving the stream while asynchronous operations are pending
|
Moving the stream while asynchronous operations are pending
|
||||||
results in undefined behavior.
|
results in undefined behavior.
|
||||||
*/
|
*/
|
||||||
|
BOOST_BEAST_DECL
|
||||||
stream&
|
stream&
|
||||||
operator=(stream&& other);
|
operator=(stream&& other);
|
||||||
|
|
||||||
@ -202,6 +205,7 @@ public:
|
|||||||
@param ioc The `io_context` object that the stream will use to
|
@param ioc The `io_context` object that the stream will use to
|
||||||
dispatch handlers for any asynchronous operations.
|
dispatch handlers for any asynchronous operations.
|
||||||
*/
|
*/
|
||||||
|
BOOST_BEAST_DECL
|
||||||
explicit
|
explicit
|
||||||
stream(net::io_context& ioc);
|
stream(net::io_context& ioc);
|
||||||
|
|
||||||
@ -217,6 +221,7 @@ public:
|
|||||||
fail count. When the fail count reaches its internal limit,
|
fail count. When the fail count reaches its internal limit,
|
||||||
a simulated failure error will be raised.
|
a simulated failure error will be raised.
|
||||||
*/
|
*/
|
||||||
|
BOOST_BEAST_DECL
|
||||||
stream(
|
stream(
|
||||||
net::io_context& ioc,
|
net::io_context& ioc,
|
||||||
fail_count& fc);
|
fail_count& fc);
|
||||||
@ -231,6 +236,7 @@ public:
|
|||||||
@param s A string which will be appended to the input area, not
|
@param s A string which will be appended to the input area, not
|
||||||
including the null terminator.
|
including the null terminator.
|
||||||
*/
|
*/
|
||||||
|
BOOST_BEAST_DECL
|
||||||
stream(
|
stream(
|
||||||
net::io_context& ioc,
|
net::io_context& ioc,
|
||||||
string_view s);
|
string_view s);
|
||||||
@ -250,12 +256,14 @@ public:
|
|||||||
@param s A string which will be appended to the input area, not
|
@param s A string which will be appended to the input area, not
|
||||||
including the null terminator.
|
including the null terminator.
|
||||||
*/
|
*/
|
||||||
|
BOOST_BEAST_DECL
|
||||||
stream(
|
stream(
|
||||||
net::io_context& ioc,
|
net::io_context& ioc,
|
||||||
fail_count& fc,
|
fail_count& fc,
|
||||||
string_view s);
|
string_view s);
|
||||||
|
|
||||||
/// Establish a connection
|
/// Establish a connection
|
||||||
|
BOOST_BEAST_DECL
|
||||||
void
|
void
|
||||||
connect(stream& remote);
|
connect(stream& remote);
|
||||||
|
|
||||||
@ -279,7 +287,7 @@ public:
|
|||||||
stream layers.
|
stream layers.
|
||||||
*/
|
*/
|
||||||
lowest_layer_type&
|
lowest_layer_type&
|
||||||
lowest_layer()
|
lowest_layer() noexcept
|
||||||
{
|
{
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -293,54 +301,57 @@ public:
|
|||||||
stream layers. Ownership is not transferred to the caller.
|
stream layers. Ownership is not transferred to the caller.
|
||||||
*/
|
*/
|
||||||
lowest_layer_type const&
|
lowest_layer_type const&
|
||||||
lowest_layer() const
|
lowest_layer() const noexcept
|
||||||
{
|
{
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the maximum number of bytes returned by read_some
|
/// Set the maximum number of bytes returned by read_some
|
||||||
void
|
void
|
||||||
read_size(std::size_t n)
|
read_size(std::size_t n) noexcept
|
||||||
{
|
{
|
||||||
in_->read_max = n;
|
in_->read_max = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the maximum number of bytes returned by write_some
|
/// Set the maximum number of bytes returned by write_some
|
||||||
void
|
void
|
||||||
write_size(std::size_t n)
|
write_size(std::size_t n) noexcept
|
||||||
{
|
{
|
||||||
in_->write_max = n;
|
in_->write_max = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Direct input buffer access
|
/// Direct input buffer access
|
||||||
buffer_type&
|
buffer_type&
|
||||||
buffer()
|
buffer() noexcept
|
||||||
{
|
{
|
||||||
return in_->b;
|
return in_->b;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a string view representing the pending input data
|
/// Returns a string view representing the pending input data
|
||||||
|
BOOST_BEAST_DECL
|
||||||
string_view
|
string_view
|
||||||
str() const;
|
str() const;
|
||||||
|
|
||||||
/// Appends a string to the pending input data
|
/// Appends a string to the pending input data
|
||||||
|
BOOST_BEAST_DECL
|
||||||
void
|
void
|
||||||
append(string_view s);
|
append(string_view s);
|
||||||
|
|
||||||
/// Clear the pending input area
|
/// Clear the pending input area
|
||||||
|
BOOST_BEAST_DECL
|
||||||
void
|
void
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
/// Return the number of reads
|
/// Return the number of reads
|
||||||
std::size_t
|
std::size_t
|
||||||
nread() const
|
nread() const noexcept
|
||||||
{
|
{
|
||||||
return in_->nread;
|
return in_->nread;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the number of writes
|
/// Return the number of writes
|
||||||
std::size_t
|
std::size_t
|
||||||
nwrite() const
|
nwrite() const noexcept
|
||||||
{
|
{
|
||||||
return in_->nwrite;
|
return in_->nwrite;
|
||||||
}
|
}
|
||||||
@ -350,6 +361,7 @@ public:
|
|||||||
The other end of the connection will see
|
The other end of the connection will see
|
||||||
`error::eof` after reading all the remaining data.
|
`error::eof` after reading all the remaining data.
|
||||||
*/
|
*/
|
||||||
|
BOOST_BEAST_DECL
|
||||||
void
|
void
|
||||||
close();
|
close();
|
||||||
|
|
||||||
@ -358,6 +370,7 @@ public:
|
|||||||
This end of the connection will see
|
This end of the connection will see
|
||||||
`error::eof` after reading all the remaining data.
|
`error::eof` after reading all the remaining data.
|
||||||
*/
|
*/
|
||||||
|
BOOST_BEAST_DECL
|
||||||
void
|
void
|
||||||
close_remote();
|
close_remote();
|
||||||
|
|
||||||
@ -504,6 +517,7 @@ public:
|
|||||||
|
|
||||||
#if ! BOOST_BEAST_DOXYGEN
|
#if ! BOOST_BEAST_DOXYGEN
|
||||||
friend
|
friend
|
||||||
|
BOOST_BEAST_DECL
|
||||||
void
|
void
|
||||||
teardown(
|
teardown(
|
||||||
websocket::role_type,
|
websocket::role_type,
|
||||||
@ -512,6 +526,7 @@ public:
|
|||||||
|
|
||||||
template<class TeardownHandler>
|
template<class TeardownHandler>
|
||||||
friend
|
friend
|
||||||
|
BOOST_BEAST_DECL
|
||||||
void
|
void
|
||||||
async_teardown(
|
async_teardown(
|
||||||
websocket::role_type role,
|
websocket::role_type role,
|
||||||
@ -534,6 +549,7 @@ stream
|
|||||||
connect(stream& to, Args&&... args);
|
connect(stream& to, Args&&... args);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
BOOST_BEAST_DECL
|
||||||
stream
|
stream
|
||||||
connect(stream& to);
|
connect(stream& to);
|
||||||
|
|
||||||
@ -546,6 +562,6 @@ connect(stream& to, Arg1&& arg1, ArgN&&... argn);
|
|||||||
} // beast
|
} // beast
|
||||||
} // boost
|
} // boost
|
||||||
|
|
||||||
#include <boost/beast/_experimental/test/impl/stream.ipp>
|
#include <boost/beast/_experimental/test/impl/stream.hpp>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -39,7 +39,7 @@ dynamic_buffer_prepare_noexcept(
|
|||||||
boost::optional<typename
|
boost::optional<typename
|
||||||
DynamicBuffer::mutable_buffers_type> result;
|
DynamicBuffer::mutable_buffers_type> result;
|
||||||
result.emplace(buffer.prepare(size));
|
result.emplace(buffer.prepare(size));
|
||||||
ec.assign(0, ec.category());
|
ec = {};
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ dynamic_buffer_prepare(
|
|||||||
boost::optional<typename
|
boost::optional<typename
|
||||||
DynamicBuffer::mutable_buffers_type> result;
|
DynamicBuffer::mutable_buffers_type> result;
|
||||||
result.emplace(buffer.prepare(size));
|
result.emplace(buffer.prepare(size));
|
||||||
ec.assign(0, ec.category());
|
ec = {};
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
catch(std::length_error const&)
|
catch(std::length_error const&)
|
||||||
|
Reference in New Issue
Block a user