forked from boostorg/beast
net is a namespace alias for boost::asio:
The namespace alias beast::net replaces boost::asio in all code and documentation.
This commit is contained in:
1 parent
a5739c3ea0
commit
f995fd41a3
185 files changed
+2486
-2392
No files matched your search
@@ -103,12 +103,12 @@ public:
|
||||
// make sure things compile, also can set a
|
||||
// breakpoint in asio_handler_invoke to make sure
|
||||
// it is instantiated.
|
||||
boost::asio::io_context ioc;
|
||||
boost::asio::strand<
|
||||
boost::asio::io_context::executor_type> s{
|
||||
net::io_context ioc;
|
||||
net::strand<
|
||||
net::io_context::executor_type> s{
|
||||
ioc.get_executor()};
|
||||
test::stream ts{ioc};
|
||||
boost::asio::post(s,
|
||||
net::post(s,
|
||||
bind_handler(copyable{}, 42));
|
||||
}
|
||||
}
|
||||
@@ -174,12 +174,12 @@ public:
|
||||
// make sure things compile, also can set a
|
||||
// breakpoint in asio_handler_invoke to make sure
|
||||
// it is instantiated.
|
||||
boost::asio::io_context ioc;
|
||||
boost::asio::strand<
|
||||
boost::asio::io_context::executor_type> s{
|
||||
net::io_context ioc;
|
||||
net::strand<
|
||||
net::io_context::executor_type> s{
|
||||
ioc.get_executor()};
|
||||
test::stream ts{ioc};
|
||||
boost::asio::post(s,
|
||||
net::post(s,
|
||||
bind_front_handler(copyable{}, 42));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace boost {
|
||||
namespace beast {
|
||||
|
||||
// VFALCO No idea why boost::system::errc::message_size fails
|
||||
// to compile, so we use boost::asio::error::eof instead.
|
||||
// to compile, so we use net::error::eof instead.
|
||||
//
|
||||
class buffer_test : public beast::unit_test::suite
|
||||
{
|
||||
@@ -35,17 +35,17 @@ public:
|
||||
DynamicBuffer b(32);
|
||||
detail::dynamic_buffer_prepare(b, 20, ec,
|
||||
//boost::system::errc::message_size);
|
||||
boost::asio::error::eof);
|
||||
net::error::eof);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
b.commit(20);
|
||||
auto const result =
|
||||
detail::dynamic_buffer_prepare(b, 20, ec,
|
||||
//boost::system::errc::message_size);
|
||||
boost::asio::error::eof);
|
||||
net::error::eof);
|
||||
BEAST_EXPECT(result == boost::none);
|
||||
BEAST_EXPECTS(
|
||||
//ec == boost::system::errc::message_size,
|
||||
ec == boost::asio::error::eof, ec.message());
|
||||
ec == net::error::eof, ec.message());
|
||||
#else
|
||||
fail("exceptions disabled", __FILE__, __LINE__);
|
||||
#endif
|
||||
@@ -59,17 +59,17 @@ public:
|
||||
DynamicBuffer b(32);
|
||||
detail::dynamic_buffer_prepare_noexcept(b, 20, ec,
|
||||
//boost::system::errc::message_size);
|
||||
boost::asio::error::eof);
|
||||
net::error::eof);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
b.commit(20);
|
||||
auto const result =
|
||||
detail::dynamic_buffer_prepare_noexcept(b, 20, ec,
|
||||
//boost::system::errc::message_size);
|
||||
boost::asio::error::eof);
|
||||
net::error::eof);
|
||||
BEAST_EXPECT(result == boost::none);
|
||||
BEAST_EXPECTS(
|
||||
//ec == boost::system::errc::message_size,
|
||||
ec == boost::asio::error::eof, ec.message());
|
||||
ec == net::error::eof, ec.message());
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -28,14 +28,14 @@ template<class DynamicBuffer>
|
||||
void
|
||||
write_buffer(DynamicBuffer& b, string_view s)
|
||||
{
|
||||
b.commit(boost::asio::buffer_copy(
|
||||
b.prepare(s.size()), boost::asio::buffer(
|
||||
b.commit(net::buffer_copy(
|
||||
b.prepare(s.size()), net::buffer(
|
||||
s.data(), s.size())));
|
||||
}
|
||||
|
||||
template<class ConstBufferSequence>
|
||||
typename std::enable_if<
|
||||
boost::asio::is_const_buffer_sequence<ConstBufferSequence>::value,
|
||||
net::is_const_buffer_sequence<ConstBufferSequence>::value,
|
||||
std::size_t>::type
|
||||
buffer_count(ConstBufferSequence const& buffers)
|
||||
{
|
||||
@@ -44,7 +44,7 @@ buffer_count(ConstBufferSequence const& buffers)
|
||||
|
||||
template<class ConstBufferSequence>
|
||||
typename std::enable_if<
|
||||
boost::asio::is_const_buffer_sequence<ConstBufferSequence>::value,
|
||||
net::is_const_buffer_sequence<ConstBufferSequence>::value,
|
||||
std::size_t>::type
|
||||
size_pre(ConstBufferSequence const& buffers)
|
||||
{
|
||||
@@ -55,7 +55,7 @@ size_pre(ConstBufferSequence const& buffers)
|
||||
typename ConstBufferSequence::const_iterator it1(it0);
|
||||
typename ConstBufferSequence::const_iterator it2;
|
||||
it2 = it1;
|
||||
n += boost::asio::buffer_size(*it2);
|
||||
n += net::buffer_size(*it2);
|
||||
it = std::move(it2);
|
||||
}
|
||||
return n;
|
||||
@@ -63,31 +63,31 @@ size_pre(ConstBufferSequence const& buffers)
|
||||
|
||||
template<class ConstBufferSequence>
|
||||
typename std::enable_if<
|
||||
boost::asio::is_const_buffer_sequence<ConstBufferSequence>::value,
|
||||
net::is_const_buffer_sequence<ConstBufferSequence>::value,
|
||||
std::size_t>::type
|
||||
size_post(ConstBufferSequence const& buffers)
|
||||
{
|
||||
std::size_t n = 0;
|
||||
for(auto it = buffers.begin(); it != buffers.end(); it++)
|
||||
n += boost::asio::buffer_size(*it);
|
||||
n += net::buffer_size(*it);
|
||||
return n;
|
||||
}
|
||||
|
||||
template<class ConstBufferSequence>
|
||||
typename std::enable_if<
|
||||
boost::asio::is_const_buffer_sequence<ConstBufferSequence>::value,
|
||||
net::is_const_buffer_sequence<ConstBufferSequence>::value,
|
||||
std::size_t>::type
|
||||
size_rev_pre(ConstBufferSequence const& buffers)
|
||||
{
|
||||
std::size_t n = 0;
|
||||
for(auto it = buffers.end(); it != buffers.begin();)
|
||||
n += boost::asio::buffer_size(*--it);
|
||||
n += net::buffer_size(*--it);
|
||||
return n;
|
||||
}
|
||||
|
||||
template<class ConstBufferSequence>
|
||||
typename std::enable_if<
|
||||
boost::asio::is_const_buffer_sequence<ConstBufferSequence>::value,
|
||||
net::is_const_buffer_sequence<ConstBufferSequence>::value,
|
||||
std::size_t>::type
|
||||
size_rev_post(ConstBufferSequence const& buffers)
|
||||
{
|
||||
@@ -95,7 +95,7 @@ size_rev_post(ConstBufferSequence const& buffers)
|
||||
for(auto it = buffers.end(); it != buffers.begin();)
|
||||
{
|
||||
it--;
|
||||
n += boost::asio::buffer_size(*it);
|
||||
n += net::buffer_size(*it);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class buffered_read_stream_test
|
||||
public:
|
||||
void testSpecialMembers()
|
||||
{
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
{
|
||||
buffered_read_stream<test::stream, multi_buffer> srs(ioc);
|
||||
buffered_read_stream<test::stream, multi_buffer> srs2(std::move(srs));
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
std::size_t n_ = 0;
|
||||
std::size_t cap_;
|
||||
unit_test::suite& suite_;
|
||||
boost::asio::io_context& ioc_;
|
||||
net::io_context& ioc_;
|
||||
boost::optional<test::stream> ts_;
|
||||
boost::optional<test::fail_count> fc_;
|
||||
boost::optional<buffered_read_stream<
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
|
||||
loop(
|
||||
unit_test::suite& suite,
|
||||
boost::asio::io_context& ioc,
|
||||
net::io_context& ioc,
|
||||
std::size_t cap)
|
||||
: cap_(cap)
|
||||
, suite_(suite)
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
void
|
||||
on_read(error_code ec, std::size_t)
|
||||
{
|
||||
using boost::asio::buffer;
|
||||
using net::buffer;
|
||||
if(! ec)
|
||||
{
|
||||
suite_.expect(s_ ==
|
||||
@@ -97,15 +97,15 @@ public:
|
||||
void
|
||||
do_read()
|
||||
{
|
||||
using boost::asio::buffer;
|
||||
using boost::asio::buffer_copy;
|
||||
using net::buffer;
|
||||
using net::buffer_copy;
|
||||
s_.resize(13);
|
||||
fc_.emplace(n_);
|
||||
ts_.emplace(ioc_, *fc_, ", world!");
|
||||
brs_.emplace(*ts_);
|
||||
brs_->buffer().commit(buffer_copy(
|
||||
brs_->buffer().prepare(5), buffer("Hello", 5)));
|
||||
boost::asio::async_read(*brs_,
|
||||
net::async_read(*brs_,
|
||||
buffer(&s_[0], s_.size()),
|
||||
std::bind(
|
||||
&loop::on_read,
|
||||
@@ -124,8 +124,8 @@ public:
|
||||
|
||||
void testRead(yield_context do_yield)
|
||||
{
|
||||
using boost::asio::buffer;
|
||||
using boost::asio::buffer_copy;
|
||||
using net::buffer;
|
||||
using net::buffer_copy;
|
||||
static std::size_t constexpr limit = 100;
|
||||
std::size_t n;
|
||||
std::string s;
|
||||
@@ -140,7 +140,7 @@ public:
|
||||
srs.buffer().commit(buffer_copy(
|
||||
srs.buffer().prepare(5), buffer("Hello", 5)));
|
||||
error_code ec = test::error::test_failure;
|
||||
boost::asio::read(srs, buffer(&s[0], s.size()), ec);
|
||||
net::read(srs, buffer(&s[0], s.size()), ec);
|
||||
if(! ec)
|
||||
{
|
||||
BEAST_EXPECT(s == "Hello, world!");
|
||||
@@ -159,7 +159,7 @@ public:
|
||||
srs.buffer().commit(buffer_copy(
|
||||
srs.buffer().prepare(5), buffer("Hello", 5)));
|
||||
error_code ec = test::error::test_failure;
|
||||
boost::asio::read(srs, buffer(&s[0], s.size()), ec);
|
||||
net::read(srs, buffer(&s[0], s.size()), ec);
|
||||
if(! ec)
|
||||
{
|
||||
BEAST_EXPECT(s == "Hello, world!");
|
||||
@@ -177,7 +177,7 @@ public:
|
||||
srs.buffer().commit(buffer_copy(
|
||||
srs.buffer().prepare(5), buffer("Hello", 5)));
|
||||
error_code ec = test::error::test_failure;
|
||||
boost::asio::async_read(
|
||||
net::async_read(
|
||||
srs, buffer(&s[0], s.size()), do_yield[ec]);
|
||||
if(! ec)
|
||||
{
|
||||
@@ -197,7 +197,7 @@ public:
|
||||
srs.buffer().commit(buffer_copy(
|
||||
srs.buffer().prepare(5), buffer("Hello", 5)));
|
||||
error_code ec = test::error::test_failure;
|
||||
boost::asio::async_read(
|
||||
net::async_read(
|
||||
srs, buffer(&s[0], s.size()), do_yield[ec]);
|
||||
if(! ec)
|
||||
{
|
||||
@@ -223,15 +223,15 @@ public:
|
||||
// make sure things compile, also can set a
|
||||
// breakpoint in asio_handler_invoke to make sure
|
||||
// it is instantiated.
|
||||
boost::asio::io_context ioc;
|
||||
boost::asio::strand<
|
||||
boost::asio::io_context::executor_type> s(
|
||||
net::io_context ioc;
|
||||
net::strand<
|
||||
net::io_context::executor_type> s(
|
||||
ioc.get_executor());
|
||||
test::stream ts{ioc};
|
||||
buffered_read_stream<
|
||||
test::stream&, multi_buffer> brs(ts);
|
||||
brs.async_read_some(boost::asio::mutable_buffer{},
|
||||
boost::asio::bind_executor(
|
||||
brs.async_read_some(net::mutable_buffer{},
|
||||
net::bind_executor(
|
||||
s, copyable_handler{}));
|
||||
}
|
||||
|
||||
|
||||
@@ -26,10 +26,10 @@ class buffers_adapter_test : public unit_test::suite
|
||||
public:
|
||||
void testBuffersAdapter()
|
||||
{
|
||||
using boost::asio::buffer;
|
||||
using boost::asio::buffer_size;
|
||||
using boost::asio::const_buffer;
|
||||
using boost::asio::mutable_buffer;
|
||||
using net::buffer;
|
||||
using net::buffer_size;
|
||||
using net::const_buffer;
|
||||
using net::mutable_buffer;
|
||||
char buf[12];
|
||||
std::string const s = "Hello, world";
|
||||
BEAST_EXPECT(s.size() == sizeof(buf));
|
||||
@@ -141,9 +141,9 @@ public:
|
||||
}
|
||||
void testCommit()
|
||||
{
|
||||
using boost::asio::buffer_size;
|
||||
using net::buffer_size;
|
||||
{
|
||||
using sb_type = boost::asio::streambuf;
|
||||
using sb_type = net::streambuf;
|
||||
sb_type b;
|
||||
buffers_adapter<
|
||||
sb_type::mutable_buffers_type> ba(b.prepare(3));
|
||||
@@ -171,7 +171,7 @@ public:
|
||||
void
|
||||
testIssue386()
|
||||
{
|
||||
using type = boost::asio::streambuf;
|
||||
using type = net::streambuf;
|
||||
type buffer;
|
||||
buffers_adapter<
|
||||
type::mutable_buffers_type> ba{buffer.prepare(512)};
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
std::size_t
|
||||
bsize1(ConstBufferSequence const& bs)
|
||||
{
|
||||
using boost::asio::buffer_size;
|
||||
using net::buffer_size;
|
||||
std::size_t n = 0;
|
||||
for(auto it = bs.begin(); it != bs.end(); ++it)
|
||||
n += buffer_size(*it);
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
std::size_t
|
||||
bsize2(ConstBufferSequence const& bs)
|
||||
{
|
||||
using boost::asio::buffer_size;
|
||||
using net::buffer_size;
|
||||
std::size_t n = 0;
|
||||
for(auto it = bs.begin(); it != bs.end(); it++)
|
||||
n += buffer_size(*it);
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
std::size_t
|
||||
bsize3(ConstBufferSequence const& bs)
|
||||
{
|
||||
using boost::asio::buffer_size;
|
||||
using net::buffer_size;
|
||||
std::size_t n = 0;
|
||||
for(auto it = bs.end(); it != bs.begin();)
|
||||
n += buffer_size(*--it);
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
std::size_t
|
||||
bsize4(ConstBufferSequence const& bs)
|
||||
{
|
||||
using boost::asio::buffer_size;
|
||||
using net::buffer_size;
|
||||
std::size_t n = 0;
|
||||
for(auto it = bs.end(); it != bs.begin();)
|
||||
{
|
||||
@@ -87,8 +87,8 @@ public:
|
||||
|
||||
void testBufferCat()
|
||||
{
|
||||
using boost::asio::buffer_size;
|
||||
using boost::asio::const_buffer;
|
||||
using net::buffer_size;
|
||||
using net::const_buffer;
|
||||
char buf[10];
|
||||
std::list<const_buffer> b1;
|
||||
std::vector<const_buffer> b2{
|
||||
@@ -117,7 +117,7 @@ public:
|
||||
decltype(bs) bs2(bs);
|
||||
auto bs3(std::move(bs));
|
||||
{
|
||||
boost::asio::streambuf sb1, sb2;
|
||||
net::streambuf sb1, sb2;
|
||||
BEAST_EXPECT(buffer_size(buffers_cat(
|
||||
sb1.prepare(5), sb2.prepare(7))) == 12);
|
||||
sb1.commit(5);
|
||||
@@ -137,8 +137,8 @@ public:
|
||||
|
||||
void testIterators()
|
||||
{
|
||||
using boost::asio::buffer_size;
|
||||
using boost::asio::const_buffer;
|
||||
using net::buffer_size;
|
||||
using net::const_buffer;
|
||||
char buf[9];
|
||||
std::vector<const_buffer> b1{
|
||||
const_buffer{buf+0, 1},
|
||||
@@ -222,8 +222,8 @@ public:
|
||||
{
|
||||
using boost::beast::buffers_cat;
|
||||
using boost::beast::buffers_suffix;
|
||||
using boost::asio::buffer;
|
||||
using boost::asio::const_buffer;
|
||||
using net::buffer;
|
||||
using net::const_buffer;
|
||||
|
||||
char out[64];
|
||||
std::array<const_buffer, 2> buffers{
|
||||
@@ -231,7 +231,7 @@ public:
|
||||
std::size_t i = 3;
|
||||
buffers_suffix<std::array<const_buffer, 2>> cb(buffers);
|
||||
cb.consume(i);
|
||||
boost::asio::buffer_copy(
|
||||
net::buffer_copy(
|
||||
buffer(out),
|
||||
buffers_cat(cb, cb));
|
||||
}
|
||||
@@ -242,9 +242,9 @@ public:
|
||||
void
|
||||
testGccWarning2()
|
||||
{
|
||||
using boost::asio::buffer;
|
||||
using boost::asio::buffer_copy;
|
||||
using boost::asio::const_buffer;
|
||||
using net::buffer;
|
||||
using net::buffer_copy;
|
||||
using net::const_buffer;
|
||||
|
||||
char out[64];
|
||||
const_buffer buffers("Hello, world!", 13);
|
||||
@@ -259,8 +259,8 @@ public:
|
||||
void
|
||||
test_empty_buffer_sequences()
|
||||
{
|
||||
using boost::asio::buffer_size;
|
||||
using boost::asio::const_buffer;
|
||||
using net::buffer_size;
|
||||
using net::const_buffer;
|
||||
std::vector<const_buffer> v1;
|
||||
std::vector<const_buffer> v2;
|
||||
BEAST_EXPECT(buffer_size(buffers_cat(v1, v2)) == 0);
|
||||
@@ -268,9 +268,9 @@ public:
|
||||
|
||||
void run() override
|
||||
{
|
||||
using boost::asio::const_buffer;
|
||||
using boost::asio::const_buffer;
|
||||
using boost::asio::mutable_buffer;
|
||||
using net::const_buffer;
|
||||
using net::const_buffer;
|
||||
using net::mutable_buffer;
|
||||
struct user_defined : mutable_buffer
|
||||
{
|
||||
};
|
||||
|
||||
@@ -21,19 +21,19 @@ namespace boost {
|
||||
namespace beast {
|
||||
|
||||
BOOST_STATIC_ASSERT(
|
||||
std::is_same<boost::asio::const_buffer, decltype(
|
||||
std::is_same<net::const_buffer, decltype(
|
||||
buffers_prefix(0,
|
||||
std::declval<boost::asio::const_buffer>()))>::value);
|
||||
std::declval<net::const_buffer>()))>::value);
|
||||
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_const_buffer_sequence<decltype(
|
||||
net::is_const_buffer_sequence<decltype(
|
||||
buffers_prefix(0,
|
||||
std::declval<boost::asio::const_buffer>()))>::value);
|
||||
std::declval<net::const_buffer>()))>::value);
|
||||
|
||||
BOOST_STATIC_ASSERT(
|
||||
std::is_same<boost::asio::mutable_buffer, decltype(
|
||||
std::is_same<net::mutable_buffer, decltype(
|
||||
buffers_prefix(0,
|
||||
std::declval<boost::asio::mutable_buffer>()))>::value);
|
||||
std::declval<net::mutable_buffer>()))>::value);
|
||||
|
||||
class buffers_prefix_test : public beast::unit_test::suite
|
||||
{
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
std::size_t
|
||||
bsize1(ConstBufferSequence const& bs)
|
||||
{
|
||||
using boost::asio::buffer_size;
|
||||
using net::buffer_size;
|
||||
std::size_t n = 0;
|
||||
for(auto it = bs.begin(); it != bs.end(); ++it)
|
||||
n += buffer_size(*it);
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
std::size_t
|
||||
bsize2(ConstBufferSequence const& bs)
|
||||
{
|
||||
using boost::asio::buffer_size;
|
||||
using net::buffer_size;
|
||||
std::size_t n = 0;
|
||||
for(auto it = bs.begin(); it != bs.end(); it++)
|
||||
n += buffer_size(*it);
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
std::size_t
|
||||
bsize3(ConstBufferSequence const& bs)
|
||||
{
|
||||
using boost::asio::buffer_size;
|
||||
using net::buffer_size;
|
||||
std::size_t n = 0;
|
||||
for(auto it = bs.end(); it != bs.begin();)
|
||||
n += buffer_size(*--it);
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
std::size_t
|
||||
bsize4(ConstBufferSequence const& bs)
|
||||
{
|
||||
using boost::asio::buffer_size;
|
||||
using net::buffer_size;
|
||||
std::size_t n = 0;
|
||||
for(auto it = bs.end(); it != bs.begin();)
|
||||
{
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
template<class BufferType>
|
||||
void testMatrix()
|
||||
{
|
||||
using boost::asio::buffer_size;
|
||||
using net::buffer_size;
|
||||
std::string s = "Hello, world";
|
||||
BEAST_EXPECT(s.size() == 12);
|
||||
for(std::size_t x = 1; x < 4; ++x) {
|
||||
@@ -121,9 +121,9 @@ public:
|
||||
|
||||
void testEmptyBuffers()
|
||||
{
|
||||
using boost::asio::buffer_copy;
|
||||
using boost::asio::buffer_size;
|
||||
using boost::asio::mutable_buffer;
|
||||
using net::buffer_copy;
|
||||
using net::buffer_size;
|
||||
using net::mutable_buffer;
|
||||
auto pb0 = buffers_prefix(0, mutable_buffer{});
|
||||
BEAST_EXPECT(buffer_size(pb0) == 0);
|
||||
auto pb1 = buffers_prefix(1, mutable_buffer{});
|
||||
@@ -145,8 +145,8 @@ public:
|
||||
|
||||
void testIterator()
|
||||
{
|
||||
using boost::asio::buffer_size;
|
||||
using boost::asio::const_buffer;
|
||||
using net::buffer_size;
|
||||
using net::const_buffer;
|
||||
char b[3];
|
||||
std::array<const_buffer, 3> bs{{
|
||||
const_buffer{&b[0], 1},
|
||||
@@ -161,8 +161,8 @@ public:
|
||||
|
||||
void run() override
|
||||
{
|
||||
testMatrix<boost::asio::const_buffer>();
|
||||
testMatrix<boost::asio::mutable_buffer>();
|
||||
testMatrix<net::const_buffer>();
|
||||
testMatrix<net::mutable_buffer>();
|
||||
testEmptyBuffers();
|
||||
testIterator();
|
||||
}
|
||||
|
||||
@@ -58,10 +58,10 @@ public:
|
||||
{
|
||||
char buf[12];
|
||||
buffers_suffix<
|
||||
boost::asio::const_buffer> cb1{
|
||||
net::const_buffer> cb1{
|
||||
boost::in_place_init, buf, sizeof(buf)};
|
||||
buffers_suffix<
|
||||
boost::asio::const_buffer> cb2{
|
||||
net::const_buffer> cb2{
|
||||
boost::in_place_init, nullptr, 0};
|
||||
cb2 = cb1;
|
||||
cb1 = std::move(cb2);
|
||||
@@ -71,8 +71,8 @@ public:
|
||||
testMatrix()
|
||||
{
|
||||
using namespace test;
|
||||
using boost::asio::buffer;
|
||||
using boost::asio::const_buffer;
|
||||
using net::buffer;
|
||||
using net::const_buffer;
|
||||
char buf[12];
|
||||
std::string const s = "Hello, world";
|
||||
BEAST_EXPECT(s.size() == sizeof(buf));
|
||||
@@ -116,11 +116,11 @@ public:
|
||||
testDefaultCtor()
|
||||
{
|
||||
using namespace test;
|
||||
class test_buffer : public boost::asio::const_buffer
|
||||
class test_buffer : public net::const_buffer
|
||||
{
|
||||
public:
|
||||
test_buffer()
|
||||
: boost::asio::const_buffer("\r\n", 2)
|
||||
: net::const_buffer("\r\n", 2)
|
||||
{
|
||||
}
|
||||
};
|
||||
@@ -134,20 +134,20 @@ public:
|
||||
{
|
||||
using namespace test;
|
||||
buffers_suffix<buffers_cat_view<
|
||||
boost::asio::const_buffer,
|
||||
boost::asio::const_buffer>> cb(
|
||||
net::const_buffer,
|
||||
net::const_buffer>> cb(
|
||||
boost::in_place_init,
|
||||
boost::asio::const_buffer("\r", 1),
|
||||
boost::asio::const_buffer("\n", 1));
|
||||
net::const_buffer("\r", 1),
|
||||
net::const_buffer("\n", 1));
|
||||
BEAST_EXPECT(buffers_to_string(cb) == "\r\n");
|
||||
}
|
||||
|
||||
void
|
||||
testEmptyBuffers()
|
||||
{
|
||||
using boost::asio::buffer_copy;
|
||||
using boost::asio::buffer_size;
|
||||
using boost::asio::mutable_buffer;
|
||||
using net::buffer_copy;
|
||||
using net::buffer_size;
|
||||
using net::mutable_buffer;
|
||||
buffers_suffix<mutable_buffer> cb(
|
||||
mutable_buffer{});
|
||||
BEAST_EXPECT(buffer_size(cb) == 0);
|
||||
@@ -159,7 +159,7 @@ public:
|
||||
void
|
||||
testIterator()
|
||||
{
|
||||
using boost::asio::const_buffer;
|
||||
using net::const_buffer;
|
||||
std::array<const_buffer, 3> ba;
|
||||
buffers_suffix<decltype(ba)> cb(ba);
|
||||
std::size_t n = 0;
|
||||
|
||||
@@ -28,16 +28,16 @@ class flat_buffer_test : public beast::unit_test::suite
|
||||
{
|
||||
public:
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_dynamic_buffer<
|
||||
net::is_dynamic_buffer<
|
||||
flat_buffer>::value);
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_const_buffer_sequence<
|
||||
net::is_const_buffer_sequence<
|
||||
flat_buffer::const_buffers_type>::value);
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_mutable_buffer_sequence<
|
||||
net::is_mutable_buffer_sequence<
|
||||
flat_buffer::mutable_data_type>::value);
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_mutable_buffer_sequence<
|
||||
net::is_mutable_buffer_sequence<
|
||||
flat_buffer::mutable_buffers_type>::value);
|
||||
BOOST_STATIC_ASSERT(std::is_convertible<
|
||||
flat_buffer::mutable_data_type,
|
||||
@@ -51,21 +51,21 @@ public:
|
||||
DynamicBuffer const& cb = b;
|
||||
ostream(b) << "Hello";
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_const_buffer_sequence<
|
||||
net::is_const_buffer_sequence<
|
||||
decltype(cb.data())>::value &&
|
||||
! boost::asio::is_mutable_buffer_sequence<
|
||||
! net::is_mutable_buffer_sequence<
|
||||
decltype(cb.data())>::value);
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_const_buffer_sequence<
|
||||
net::is_const_buffer_sequence<
|
||||
decltype(cb.cdata())>::value &&
|
||||
! boost::asio::is_mutable_buffer_sequence<
|
||||
! net::is_mutable_buffer_sequence<
|
||||
decltype(cb.cdata())>::value);
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_mutable_buffer_sequence<
|
||||
net::is_mutable_buffer_sequence<
|
||||
decltype(b.data())>::value);
|
||||
std::for_each(
|
||||
boost::asio::buffers_iterator<decltype(b.data())>::begin(b.data()),
|
||||
boost::asio::buffers_iterator<decltype(b.data())>::end(b.data()),
|
||||
net::buffers_iterator<decltype(b.data())>::begin(b.data()),
|
||||
net::buffers_iterator<decltype(b.data())>::end(b.data()),
|
||||
[](char& c)
|
||||
{
|
||||
c = static_cast<char>(std::toupper(c));
|
||||
|
||||
@@ -27,16 +27,16 @@ class flat_static_buffer_test : public beast::unit_test::suite
|
||||
{
|
||||
public:
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_dynamic_buffer<
|
||||
net::is_dynamic_buffer<
|
||||
flat_static_buffer_base>::value);
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_const_buffer_sequence<
|
||||
net::is_const_buffer_sequence<
|
||||
flat_static_buffer_base::const_buffers_type>::value);
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_mutable_buffer_sequence<
|
||||
net::is_mutable_buffer_sequence<
|
||||
flat_static_buffer_base::mutable_data_type>::value);
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_mutable_buffer_sequence<
|
||||
net::is_mutable_buffer_sequence<
|
||||
flat_static_buffer_base::mutable_buffers_type>::value);
|
||||
BOOST_STATIC_ASSERT(std::is_convertible<
|
||||
flat_static_buffer_base::mutable_data_type,
|
||||
@@ -50,21 +50,21 @@ public:
|
||||
DynamicBuffer const& cb = b;
|
||||
ostream(b) << "Hello";
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_const_buffer_sequence<
|
||||
net::is_const_buffer_sequence<
|
||||
decltype(cb.data())>::value &&
|
||||
! boost::asio::is_mutable_buffer_sequence<
|
||||
! net::is_mutable_buffer_sequence<
|
||||
decltype(cb.data())>::value);
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_const_buffer_sequence<
|
||||
net::is_const_buffer_sequence<
|
||||
decltype(cb.cdata())>::value &&
|
||||
! boost::asio::is_mutable_buffer_sequence<
|
||||
! net::is_mutable_buffer_sequence<
|
||||
decltype(cb.cdata())>::value);
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_mutable_buffer_sequence<
|
||||
net::is_mutable_buffer_sequence<
|
||||
decltype(b.data())>::value);
|
||||
std::for_each(
|
||||
boost::asio::buffers_iterator<decltype(b.data())>::begin(b.data()),
|
||||
boost::asio::buffers_iterator<decltype(b.data())>::end(b.data()),
|
||||
net::buffers_iterator<decltype(b.data())>::begin(b.data()),
|
||||
net::buffers_iterator<decltype(b.data())>::end(b.data()),
|
||||
[](char& c)
|
||||
{
|
||||
c = static_cast<char>(std::toupper(c));
|
||||
@@ -77,8 +77,8 @@ public:
|
||||
testStaticBuffer()
|
||||
{
|
||||
using namespace test;
|
||||
using boost::asio::buffer;
|
||||
using boost::asio::buffer_size;
|
||||
using net::buffer;
|
||||
using net::buffer_size;
|
||||
char buf[12];
|
||||
std::string const s = "Hello, world";
|
||||
BEAST_EXPECT(s.size() == sizeof(buf));
|
||||
|
||||
@@ -32,16 +32,16 @@ class multi_buffer_test : public beast::unit_test::suite
|
||||
{
|
||||
public:
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_dynamic_buffer<
|
||||
net::is_dynamic_buffer<
|
||||
multi_buffer>::value);
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_const_buffer_sequence<
|
||||
net::is_const_buffer_sequence<
|
||||
multi_buffer::const_buffers_type>::value);
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_mutable_buffer_sequence<
|
||||
net::is_mutable_buffer_sequence<
|
||||
multi_buffer::mutable_data_type>::value);
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_mutable_buffer_sequence<
|
||||
net::is_mutable_buffer_sequence<
|
||||
multi_buffer::mutable_buffers_type>::value);
|
||||
BOOST_STATIC_ASSERT(std::is_convertible<
|
||||
multi_buffer::mutable_data_type,
|
||||
@@ -83,22 +83,22 @@ public:
|
||||
DynamicBuffer const& cb = b;
|
||||
ostream(b) << "Hello";
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_const_buffer_sequence<
|
||||
net::is_const_buffer_sequence<
|
||||
decltype(cb.data())>::value &&
|
||||
! boost::asio::is_mutable_buffer_sequence<
|
||||
! net::is_mutable_buffer_sequence<
|
||||
decltype(cb.data())>::value);
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_const_buffer_sequence<
|
||||
net::is_const_buffer_sequence<
|
||||
decltype(cb.cdata())>::value &&
|
||||
! boost::asio::is_mutable_buffer_sequence<
|
||||
! net::is_mutable_buffer_sequence<
|
||||
decltype(cb.cdata())>::value);
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_mutable_buffer_sequence<
|
||||
net::is_mutable_buffer_sequence<
|
||||
decltype(b.data())>::value);
|
||||
|
||||
std::for_each(
|
||||
boost::asio::buffers_iterator<decltype(b.data())>::begin(b.data()),
|
||||
boost::asio::buffers_iterator<decltype(b.data())>::end(b.data()),
|
||||
net::buffers_iterator<decltype(b.data())>::begin(b.data()),
|
||||
net::buffers_iterator<decltype(b.data())>::end(b.data()),
|
||||
[](char& c)
|
||||
{
|
||||
c = static_cast<char>(std::toupper(c));
|
||||
@@ -111,7 +111,7 @@ public:
|
||||
testMatrix1()
|
||||
{
|
||||
using namespace test;
|
||||
using boost::asio::buffer;
|
||||
using net::buffer;
|
||||
std::string const s = "Hello, world";
|
||||
BEAST_EXPECT(s.size() == 12);
|
||||
for(std::size_t i = 1; i < 12; ++i) {
|
||||
@@ -153,8 +153,8 @@ public:
|
||||
testMatrix2()
|
||||
{
|
||||
using namespace test;
|
||||
using boost::asio::buffer;
|
||||
using boost::asio::buffer_size;
|
||||
using net::buffer;
|
||||
using net::buffer_size;
|
||||
std::string const s = "Hello, world";
|
||||
BEAST_EXPECT(s.size() == 12);
|
||||
for(std::size_t i = 1; i < 12; ++i) {
|
||||
@@ -248,7 +248,7 @@ public:
|
||||
void
|
||||
testIterators()
|
||||
{
|
||||
using boost::asio::buffer_size;
|
||||
using net::buffer_size;
|
||||
multi_buffer b;
|
||||
b.prepare(1);
|
||||
b.commit(1);
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
check<flat_static_buffer<1024>>();
|
||||
check<multi_buffer>();
|
||||
check<static_buffer<1024>>();
|
||||
check<boost::asio::streambuf>();
|
||||
check<net::streambuf>();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -24,22 +24,22 @@ namespace boost {
|
||||
namespace beast {
|
||||
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_dynamic_buffer<static_buffer_base>::value);
|
||||
net::is_dynamic_buffer<static_buffer_base>::value);
|
||||
|
||||
class static_buffer_test : public beast::unit_test::suite
|
||||
{
|
||||
public:
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_dynamic_buffer<
|
||||
net::is_dynamic_buffer<
|
||||
static_buffer_base>::value);
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_const_buffer_sequence<
|
||||
net::is_const_buffer_sequence<
|
||||
static_buffer_base::const_buffers_type>::value);
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_mutable_buffer_sequence<
|
||||
net::is_mutable_buffer_sequence<
|
||||
static_buffer_base::mutable_data_type>::value);
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_mutable_buffer_sequence<
|
||||
net::is_mutable_buffer_sequence<
|
||||
static_buffer_base::mutable_buffers_type>::value);
|
||||
BOOST_STATIC_ASSERT(std::is_convertible<
|
||||
static_buffer_base::mutable_data_type,
|
||||
@@ -53,21 +53,21 @@ public:
|
||||
DynamicBuffer const& cb = b;
|
||||
ostream(b) << "Hello";
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_const_buffer_sequence<
|
||||
net::is_const_buffer_sequence<
|
||||
decltype(cb.data())>::value &&
|
||||
! boost::asio::is_mutable_buffer_sequence<
|
||||
! net::is_mutable_buffer_sequence<
|
||||
decltype(cb.data())>::value);
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_const_buffer_sequence<
|
||||
net::is_const_buffer_sequence<
|
||||
decltype(cb.cdata())>::value &&
|
||||
! boost::asio::is_mutable_buffer_sequence<
|
||||
! net::is_mutable_buffer_sequence<
|
||||
decltype(cb.cdata())>::value);
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::asio::is_mutable_buffer_sequence<
|
||||
net::is_mutable_buffer_sequence<
|
||||
decltype(b.data())>::value);
|
||||
std::for_each(
|
||||
boost::asio::buffers_iterator<decltype(b.data())>::begin(b.data()),
|
||||
boost::asio::buffers_iterator<decltype(b.data())>::end(b.data()),
|
||||
net::buffers_iterator<decltype(b.data())>::begin(b.data()),
|
||||
net::buffers_iterator<decltype(b.data())>::end(b.data()),
|
||||
[](char& c)
|
||||
{
|
||||
c = static_cast<char>(std::toupper(c));
|
||||
@@ -80,8 +80,8 @@ public:
|
||||
testStaticBuffer()
|
||||
{
|
||||
using namespace test;
|
||||
using boost::asio::buffer;
|
||||
using boost::asio::buffer_size;
|
||||
using net::buffer;
|
||||
using net::buffer_size;
|
||||
char buf[12];
|
||||
std::string const s = "Hello, world";
|
||||
BEAST_EXPECT(s.size() == sizeof(buf));
|
||||
|
||||
@@ -142,7 +142,7 @@ BOOST_STATIC_ASSERT(! is_completion_handler<H, void(void)>::value);
|
||||
|
||||
namespace {
|
||||
|
||||
using stream_type = boost::asio::ip::tcp::socket;
|
||||
using stream_type = net::ip::tcp::socket;
|
||||
|
||||
struct not_a_stream
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
unsigned long count,
|
||||
bool copy)
|
||||
{
|
||||
std::vector<boost::asio::const_buffer> v;
|
||||
std::vector<net::const_buffer> v;
|
||||
v.reserve(v0.size());
|
||||
for(auto const n : v0)
|
||||
v.emplace_back("", n);
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
{
|
||||
error_code ec;
|
||||
test::ws_echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
websocket::stream<flat_stream<test::stream>> ws{ioc};
|
||||
ws.next_layer().next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/", ec);
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
}
|
||||
{
|
||||
test::ws_echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
websocket::stream<flat_stream<test::stream>> ws{ioc};
|
||||
ws.next_layer().next_layer().connect(es.stream());
|
||||
ws.async_handshake("localhost", "/",
|
||||
|
||||
@@ -30,8 +30,8 @@ public:
|
||||
void
|
||||
doMatrix(string_view in, string_view out)
|
||||
{
|
||||
using boost::asio::mutable_buffer;
|
||||
boost::asio::io_context ioc;
|
||||
using net::mutable_buffer;
|
||||
net::io_context ioc;
|
||||
auto len = out.size() + 8;
|
||||
std::unique_ptr<char[]> p(new char[len]);
|
||||
for(std::size_t i = 1; i < len; ++i)
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
break;
|
||||
}
|
||||
if(! BEAST_EXPECTS(
|
||||
ec == boost::asio::error::eof, ec.message()))
|
||||
ec == net::error::eof, ec.message()))
|
||||
continue;
|
||||
auto const s = buffers_to_string(ba.data());
|
||||
BEAST_EXPECTS(s == out, s);
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
break;
|
||||
}
|
||||
if(! BEAST_EXPECTS(
|
||||
ec == boost::asio::error::eof, ec.message()))
|
||||
ec == net::error::eof, ec.message()))
|
||||
continue;
|
||||
auto const s = buffers_to_string(ba.data());
|
||||
if(! BEAST_EXPECTS(s == out, s))
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
void
|
||||
run() override
|
||||
{
|
||||
boost::asio::io_context ctx;
|
||||
net::io_context ctx;
|
||||
set_timeout_service_options(ctx,
|
||||
std::chrono::seconds(1));
|
||||
pass();
|
||||
|
||||
@@ -28,21 +28,21 @@ public:
|
||||
class server
|
||||
{
|
||||
std::ostream& log_;
|
||||
boost::asio::io_context ioc_;
|
||||
boost::asio::ip::tcp::acceptor acceptor_;
|
||||
boost::asio::ip::tcp::socket socket_;
|
||||
net::io_context ioc_;
|
||||
net::ip::tcp::acceptor acceptor_;
|
||||
net::ip::tcp::socket socket_;
|
||||
std::thread t_;
|
||||
|
||||
void
|
||||
fail(error_code ec, string_view what)
|
||||
{
|
||||
if(ec != boost::asio::error::operation_aborted)
|
||||
if(ec != net::error::operation_aborted)
|
||||
log_ << what << ": " << ec.message() << "\n";
|
||||
}
|
||||
|
||||
public:
|
||||
server(
|
||||
boost::asio::ip::tcp::endpoint ep,
|
||||
net::ip::tcp::endpoint ep,
|
||||
std::ostream& log)
|
||||
: log_(log)
|
||||
, ioc_(1)
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
}
|
||||
|
||||
acceptor_.set_option(
|
||||
boost::asio::socket_base::reuse_address(true), ec);
|
||||
net::socket_base::reuse_address(true), ec);
|
||||
if(ec)
|
||||
{
|
||||
fail(ec, "set_option");
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
}
|
||||
|
||||
acceptor_.listen(
|
||||
boost::asio::socket_base::max_listen_connections, ec);
|
||||
net::socket_base::max_listen_connections, ec);
|
||||
if(ec)
|
||||
{
|
||||
fail(ec, "listen");
|
||||
@@ -97,11 +97,11 @@ public:
|
||||
class session
|
||||
: public std::enable_shared_from_this<session>
|
||||
{
|
||||
boost::asio::ip::tcp::socket socket_;
|
||||
net::ip::tcp::socket socket_;
|
||||
|
||||
public:
|
||||
session(
|
||||
boost::asio::ip::tcp::socket sock,
|
||||
net::ip::tcp::socket sock,
|
||||
std::ostream&)
|
||||
: socket_(std::move(sock))
|
||||
{
|
||||
@@ -111,7 +111,7 @@ public:
|
||||
run()
|
||||
{
|
||||
socket_.async_wait(
|
||||
boost::asio::socket_base::wait_read,
|
||||
net::socket_base::wait_read,
|
||||
std::bind(
|
||||
&session::on_read,
|
||||
shared_from_this(),
|
||||
@@ -147,17 +147,17 @@ public:
|
||||
void
|
||||
testAsync()
|
||||
{
|
||||
boost::asio::ip::tcp::endpoint ep(
|
||||
boost::asio::ip::make_address("127.0.0.1"), 8080);
|
||||
net::ip::tcp::endpoint ep(
|
||||
net::ip::make_address("127.0.0.1"), 8080);
|
||||
server srv(ep, log);
|
||||
{
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
set_timeout_service_options(
|
||||
ioc, std::chrono::seconds(1));
|
||||
timeout_socket s(ioc);
|
||||
s.next_layer().connect(ep);
|
||||
char buf[32];
|
||||
s.async_read_some(boost::asio::buffer(buf),
|
||||
s.async_read_some(net::buffer(buf),
|
||||
[&](error_code ec, std::size_t n)
|
||||
{
|
||||
log << "read_some: " << ec.message() << "\n";
|
||||
|
||||
@@ -152,11 +152,11 @@ public:
|
||||
|
||||
template<class Parser, class ConstBufferSequence, class Test>
|
||||
typename std::enable_if<
|
||||
boost::asio::is_const_buffer_sequence<ConstBufferSequence>::value>::type
|
||||
net::is_const_buffer_sequence<ConstBufferSequence>::value>::type
|
||||
parsegrind(ConstBufferSequence const& buffers,
|
||||
Test const& test, bool skip = false)
|
||||
{
|
||||
auto const size = boost::asio::buffer_size(buffers);
|
||||
auto const size = net::buffer_size(buffers);
|
||||
for(std::size_t i = 1; i < size - 1; ++i)
|
||||
{
|
||||
Parser p;
|
||||
@@ -174,7 +174,7 @@ public:
|
||||
n = p.put(cb, ec);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
continue;
|
||||
if(! BEAST_EXPECT(n == boost::asio::buffer_size(cb)))
|
||||
if(! BEAST_EXPECT(n == net::buffer_size(cb)))
|
||||
continue;
|
||||
if(p.need_eof())
|
||||
{
|
||||
@@ -213,13 +213,13 @@ public:
|
||||
void
|
||||
parsegrind(string_view msg, Test const& test, bool skip = false)
|
||||
{
|
||||
parsegrind<Parser>(boost::asio::const_buffer{
|
||||
parsegrind<Parser>(net::const_buffer{
|
||||
msg.data(), msg.size()}, test, skip);
|
||||
}
|
||||
|
||||
template<class Parser, class ConstBufferSequence>
|
||||
typename std::enable_if<
|
||||
boost::asio::is_const_buffer_sequence<ConstBufferSequence>::value>::type
|
||||
net::is_const_buffer_sequence<ConstBufferSequence>::value>::type
|
||||
parsegrind(ConstBufferSequence const& buffers)
|
||||
{
|
||||
parsegrind<Parser>(buffers, [](Parser const&){});
|
||||
@@ -241,7 +241,7 @@ public:
|
||||
Parser p;
|
||||
p.eager(true);
|
||||
error_code ec;
|
||||
buffers_suffix<boost::asio::const_buffer> cb{
|
||||
buffers_suffix<net::const_buffer> cb{
|
||||
boost::in_place_init, msg.data(), msg.size()};
|
||||
auto n = p.put(buffers_prefix(i, cb), ec);
|
||||
if(ec == result)
|
||||
@@ -266,8 +266,8 @@ public:
|
||||
p.eager(true);
|
||||
error_code ec;
|
||||
p.put(buffers_cat(
|
||||
boost::asio::const_buffer{msg.data(), i},
|
||||
boost::asio::const_buffer{
|
||||
net::const_buffer{msg.data(), i},
|
||||
net::const_buffer{
|
||||
msg.data() + i, msg.size() - i}), ec);
|
||||
if(! ec)
|
||||
p.put_eof(ec);
|
||||
@@ -887,7 +887,7 @@ public:
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
static
|
||||
boost::asio::const_buffer
|
||||
net::const_buffer
|
||||
buf(string_view s)
|
||||
{
|
||||
return {s.data(), s.size()};
|
||||
@@ -1080,7 +1080,7 @@ public:
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"\r\n"
|
||||
"die!";
|
||||
p.put(boost::asio::buffer(
|
||||
p.put(net::buffer(
|
||||
s.data(), s.size()), ec);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
return;
|
||||
@@ -1117,7 +1117,7 @@ public:
|
||||
"HTTP/1.1 101 Switching Protocols\r\n"
|
||||
"Content-Length: 2147483648\r\n"
|
||||
"\r\n";
|
||||
p.put(boost::asio::buffer(
|
||||
p.put(net::buffer(
|
||||
s.data(), s.size()), ec);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
return;
|
||||
@@ -1140,7 +1140,7 @@ public:
|
||||
error_code ec;
|
||||
test_parser<false> p;
|
||||
p.eager(true);
|
||||
p.put(boost::asio::const_buffer{
|
||||
p.put(net::const_buffer{
|
||||
s.data(), s.size()}, ec);
|
||||
});
|
||||
};
|
||||
@@ -1156,7 +1156,7 @@ public:
|
||||
error_code ec;
|
||||
test_parser<false> p;
|
||||
p.eager(true);
|
||||
p.put(boost::asio::const_buffer{
|
||||
p.put(net::const_buffer{
|
||||
msg.data(), msg.size()}, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
grind(msg);
|
||||
@@ -1173,7 +1173,7 @@ public:
|
||||
error_code ec;
|
||||
test_parser<false> p;
|
||||
p.eager(true);
|
||||
p.put(boost::asio::const_buffer{
|
||||
p.put(net::const_buffer{
|
||||
msg.data(), msg.size()}, ec);
|
||||
BEAST_EXPECT(ec);
|
||||
grind(msg);
|
||||
@@ -1209,7 +1209,7 @@ public:
|
||||
|
||||
error_code ec;
|
||||
test_parser<true> p;
|
||||
feed(boost::asio::buffer(buf, sizeof(buf)), p, ec);
|
||||
feed(net::buffer(buf, sizeof(buf)), p, ec);
|
||||
BEAST_EXPECT(ec);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
BEAST_EXPECT(buffers_to_string(t3) == match);
|
||||
}
|
||||
|
||||
using cb_t = boost::asio::const_buffer;
|
||||
using cb_t = net::const_buffer;
|
||||
|
||||
static
|
||||
cb_t
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace http {
|
||||
|
||||
class dynamic_body_test : public beast::unit_test::suite
|
||||
{
|
||||
boost::asio::io_context ioc_;
|
||||
net::io_context ioc_;
|
||||
|
||||
public:
|
||||
template<bool isRequest, class Body, class Fields>
|
||||
|
||||
@@ -33,8 +33,8 @@ public:
|
||||
void
|
||||
operator()(error_code&, ConstBufferSequence const& buffers)
|
||||
{
|
||||
buffer.commit(boost::asio::buffer_copy(
|
||||
buffer.prepare(boost::asio::buffer_size(buffers)),
|
||||
buffer.commit(net::buffer_copy(
|
||||
buffer.prepare(net::buffer_size(buffers)),
|
||||
buffers));
|
||||
}
|
||||
};
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
temp.string<std::string>().c_str(), file_mode::write, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
|
||||
p.put(boost::asio::buffer(s.data(), s.size()), ec);
|
||||
p.put(net::buffer(s.data(), s.size()), ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
}
|
||||
{
|
||||
|
||||
@@ -504,11 +504,11 @@ public:
|
||||
ostream(db) <<
|
||||
"Content-Length: " << len << "\r\n\r\n";
|
||||
auto mb = db.prepare(len);
|
||||
for(auto it = boost::asio::buffer_sequence_begin(mb);
|
||||
it != boost::asio::buffer_sequence_end(mb);
|
||||
for(auto it = net::buffer_sequence_begin(mb);
|
||||
it != net::buffer_sequence_end(mb);
|
||||
++it)
|
||||
{
|
||||
boost::asio::mutable_buffer b = *it;
|
||||
net::mutable_buffer b = *it;
|
||||
auto p = static_cast<char*>(b.data());
|
||||
auto n = b.size();
|
||||
while(n--)
|
||||
@@ -528,11 +528,11 @@ public:
|
||||
ostream(db) <<
|
||||
to_hex(n) << "\r\n";
|
||||
auto mb = db.prepare(n);
|
||||
for(auto it = boost::asio::buffer_sequence_begin(mb);
|
||||
it != boost::asio::buffer_sequence_end(mb);
|
||||
for(auto it = net::buffer_sequence_begin(mb);
|
||||
it != net::buffer_sequence_end(mb);
|
||||
++it)
|
||||
{
|
||||
boost::asio::mutable_buffer b = *it;
|
||||
net::mutable_buffer b = *it;
|
||||
auto p = static_cast<char*>(b.data());
|
||||
auto m = b.size();
|
||||
while(m--)
|
||||
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
parser<isRequest, string_body>;
|
||||
|
||||
static
|
||||
boost::asio::const_buffer
|
||||
net::const_buffer
|
||||
buf(string_view s)
|
||||
{
|
||||
return {s.data(), s.size()};
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
basic_parser<isRequest, Derived>& p,
|
||||
error_code& ec)
|
||||
{
|
||||
using boost::asio::buffer_size;
|
||||
using net::buffer_size;
|
||||
buffers_suffix<ConstBufferSequence> cb{buffers};
|
||||
for(;;)
|
||||
{
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
void
|
||||
doMatrix(string_view s0, F const& f)
|
||||
{
|
||||
using boost::asio::buffer;
|
||||
using net::buffer;
|
||||
// parse a single buffer
|
||||
{
|
||||
auto s = s0;
|
||||
|
||||
+13
-13
@@ -38,8 +38,8 @@ public:
|
||||
void
|
||||
failMatrix(char const* s, yield_context do_yield)
|
||||
{
|
||||
using boost::asio::buffer;
|
||||
using boost::asio::buffer_copy;
|
||||
using net::buffer;
|
||||
using net::buffer_copy;
|
||||
static std::size_t constexpr limit = 100;
|
||||
std::size_t n;
|
||||
auto const len = strlen(s);
|
||||
@@ -373,7 +373,7 @@ public:
|
||||
{
|
||||
// Make sure handlers are not destroyed
|
||||
// after calling io_context::stop
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
test::stream ts{ioc,
|
||||
"GET / HTTP/1.1\r\n\r\n"};
|
||||
BEAST_EXPECT(handler::count() == 0);
|
||||
@@ -392,7 +392,7 @@ public:
|
||||
// Make sure uninvoked handlers are
|
||||
// destroyed when calling ~io_context
|
||||
{
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
test::stream ts{ioc,
|
||||
"GET / HTTP/1.1\r\n\r\n"};
|
||||
BEAST_EXPECT(handler::count() == 0);
|
||||
@@ -431,7 +431,7 @@ public:
|
||||
void
|
||||
readgrind(string_view s, Pred&& pred)
|
||||
{
|
||||
using boost::asio::buffer;
|
||||
using net::buffer;
|
||||
for(std::size_t n = 1; n < s.size() - 1; ++n)
|
||||
{
|
||||
Parser p;
|
||||
@@ -493,40 +493,40 @@ public:
|
||||
void
|
||||
testAsioHandlerInvoke()
|
||||
{
|
||||
using strand = boost::asio::strand<
|
||||
boost::asio::io_context::executor_type>;
|
||||
using strand = net::strand<
|
||||
net::io_context::executor_type>;
|
||||
|
||||
// make sure things compile, also can set a
|
||||
// breakpoint in asio_handler_invoke to make sure
|
||||
// it is instantiated.
|
||||
{
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
strand s{ioc.get_executor()};
|
||||
test::stream ts{ioc};
|
||||
flat_buffer b;
|
||||
request_parser<dynamic_body> p;
|
||||
async_read_some(ts, b, p,
|
||||
boost::asio::bind_executor(
|
||||
net::bind_executor(
|
||||
s, copyable_handler{}));
|
||||
}
|
||||
{
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
strand s{ioc.get_executor()};
|
||||
test::stream ts{ioc};
|
||||
flat_buffer b;
|
||||
request_parser<dynamic_body> p;
|
||||
async_read(ts, b, p,
|
||||
boost::asio::bind_executor(
|
||||
net::bind_executor(
|
||||
s, copyable_handler{}));
|
||||
}
|
||||
{
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
strand s{ioc.get_executor()};
|
||||
test::stream ts{ioc};
|
||||
flat_buffer b;
|
||||
request<dynamic_body> m;
|
||||
async_read(ts, b, m,
|
||||
boost::asio::bind_executor(
|
||||
net::bind_executor(
|
||||
s, copyable_handler{}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
struct writer
|
||||
{
|
||||
using const_buffers_type =
|
||||
boost::asio::const_buffer;
|
||||
net::const_buffer;
|
||||
|
||||
template<bool isRequest, class Fields>
|
||||
writer(header<isRequest, Fields> const&, value_type const&);
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
struct writer
|
||||
{
|
||||
using const_buffers_type =
|
||||
boost::asio::const_buffer;
|
||||
net::const_buffer;
|
||||
|
||||
template<bool isRequest, class Fields>
|
||||
writer(header<isRequest, Fields>&, value_type&);
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
operator()(error_code&,
|
||||
ConstBufferSequence const& buffers)
|
||||
{
|
||||
size = boost::asio::buffer_size(buffers);
|
||||
size = net::buffer_size(buffers);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ struct span_body_test
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
if(! BEAST_EXPECT(buf != boost::none))
|
||||
return;
|
||||
BEAST_EXPECT(boost::asio::buffer_size(buf->first) == 3);
|
||||
BEAST_EXPECT(net::buffer_size(buf->first) == 3);
|
||||
BEAST_EXPECT(! buf->second);
|
||||
}
|
||||
{
|
||||
@@ -54,13 +54,13 @@ struct span_body_test
|
||||
error_code ec;
|
||||
w.init(boost::none, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
w.put(boost::asio::const_buffer{
|
||||
w.put(net::const_buffer{
|
||||
"123", 3}, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BEAST_EXPECT(buf[0] == '1');
|
||||
BEAST_EXPECT(buf[1] == '2');
|
||||
BEAST_EXPECT(buf[2] == '3');
|
||||
w.put(boost::asio::const_buffer{
|
||||
w.put(net::const_buffer{
|
||||
"456", 3}, ec);
|
||||
BEAST_EXPECTS(ec == error::buffer_overflow, ec.message());
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class test_parser
|
||||
|
||||
public:
|
||||
using mutable_buffers_type =
|
||||
boost::asio::mutable_buffer;
|
||||
net::mutable_buffer;
|
||||
|
||||
int status = 0;
|
||||
int version = 0;
|
||||
|
||||
+21
-21
@@ -47,7 +47,7 @@ public:
|
||||
|
||||
public:
|
||||
using const_buffers_type =
|
||||
boost::asio::const_buffer;
|
||||
net::const_buffer;
|
||||
|
||||
template<bool isRequest, class Fields>
|
||||
writer(
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
|
||||
public:
|
||||
using const_buffers_type =
|
||||
boost::asio::const_buffer;
|
||||
net::const_buffer;
|
||||
|
||||
template<bool isRequest, class Fields>
|
||||
writer(
|
||||
@@ -124,7 +124,7 @@ public:
|
||||
std::false_type, // isSplit
|
||||
std::false_type) // isFinalEmpty
|
||||
{
|
||||
using boost::asio::buffer;
|
||||
using net::buffer;
|
||||
if(body_.s.empty())
|
||||
return boost::none;
|
||||
return {{buffer(body_.s.data(), body_.s.size()), false}};
|
||||
@@ -135,7 +135,7 @@ public:
|
||||
std::false_type, // isSplit
|
||||
std::true_type) // isFinalEmpty
|
||||
{
|
||||
using boost::asio::buffer;
|
||||
using net::buffer;
|
||||
if(body_.s.empty())
|
||||
return boost::none;
|
||||
switch(step_)
|
||||
@@ -154,7 +154,7 @@ public:
|
||||
std::true_type, // isSplit
|
||||
std::false_type) // isFinalEmpty
|
||||
{
|
||||
using boost::asio::buffer;
|
||||
using net::buffer;
|
||||
auto const n = (body_.s.size() + 1) / 2;
|
||||
switch(step_)
|
||||
{
|
||||
@@ -175,7 +175,7 @@ public:
|
||||
std::true_type, // isSplit
|
||||
std::true_type) // isFinalEmpty
|
||||
{
|
||||
using boost::asio::buffer;
|
||||
using net::buffer;
|
||||
auto const n = (body_.s.size() + 1) / 2;
|
||||
switch(step_)
|
||||
{
|
||||
@@ -229,7 +229,7 @@ public:
|
||||
|
||||
public:
|
||||
using const_buffers_type =
|
||||
boost::asio::const_buffer;
|
||||
net::const_buffer;
|
||||
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
@@ -636,7 +636,7 @@ public:
|
||||
{
|
||||
// Make sure handlers are not destroyed
|
||||
// after calling io_context::stop
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
test::stream ts{ioc};
|
||||
BEAST_EXPECT(handler::count() == 0);
|
||||
request<string_body> m;
|
||||
@@ -658,7 +658,7 @@ public:
|
||||
// Make sure uninvoked handlers are
|
||||
// destroyed when calling ~io_context
|
||||
{
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
test::stream ts{ioc}, tr{ioc};
|
||||
ts.connect(tr);
|
||||
BEAST_EXPECT(handler::count() == 0);
|
||||
@@ -718,7 +718,7 @@ public:
|
||||
|
||||
template<class Body>
|
||||
void
|
||||
testWriteStream(boost::asio::yield_context yield)
|
||||
testWriteStream(net::yield_context yield)
|
||||
{
|
||||
test::stream ts{ioc_}, tr{ioc_};
|
||||
ts.connect(tr);
|
||||
@@ -832,7 +832,7 @@ public:
|
||||
void
|
||||
testIssue655()
|
||||
{
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
test::stream ts{ioc}, tr{ioc};
|
||||
ts.connect(tr);
|
||||
response<empty_body> res;
|
||||
@@ -857,42 +857,42 @@ public:
|
||||
void
|
||||
testAsioHandlerInvoke()
|
||||
{
|
||||
using strand = boost::asio::strand<
|
||||
boost::asio::io_context::executor_type>;
|
||||
using strand = net::strand<
|
||||
net::io_context::executor_type>;
|
||||
|
||||
// make sure things compile, also can set a
|
||||
// breakpoint in asio_handler_invoke to make sure
|
||||
// it is instantiated.
|
||||
{
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
strand s{ioc.get_executor()};
|
||||
test::stream ts{ioc};
|
||||
flat_buffer b;
|
||||
request<empty_body> m;
|
||||
request_serializer<empty_body, fields> sr{m};
|
||||
async_write_some(ts, sr,
|
||||
boost::asio::bind_executor(
|
||||
net::bind_executor(
|
||||
s, copyable_handler{}));
|
||||
}
|
||||
{
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
strand s{ioc.get_executor()};
|
||||
test::stream ts{ioc};
|
||||
flat_buffer b;
|
||||
request<empty_body> m;
|
||||
request_serializer<empty_body, fields> sr{m};
|
||||
async_write(ts, sr,
|
||||
boost::asio::bind_executor(
|
||||
net::bind_executor(
|
||||
s, copyable_handler{}));
|
||||
}
|
||||
{
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
strand s{ioc.get_executor()};
|
||||
test::stream ts{ioc};
|
||||
flat_buffer b;
|
||||
request<empty_body> m;
|
||||
async_write(ts, m,
|
||||
boost::asio::bind_executor(
|
||||
net::bind_executor(
|
||||
s, copyable_handler{}));
|
||||
}
|
||||
}
|
||||
@@ -904,7 +904,7 @@ public:
|
||||
struct writer
|
||||
{
|
||||
using const_buffers_type =
|
||||
boost::asio::const_buffer;
|
||||
net::const_buffer;
|
||||
|
||||
template<bool isRequest, class Fields>
|
||||
writer(
|
||||
@@ -935,7 +935,7 @@ public:
|
||||
struct writer
|
||||
{
|
||||
using const_buffers_type =
|
||||
boost::asio::const_buffer;
|
||||
net::const_buffer;
|
||||
|
||||
template<bool isRequest, class Fields>
|
||||
writer(
|
||||
|
||||
@@ -165,7 +165,7 @@ public:
|
||||
auto tr = connect(ws.next_layer());
|
||||
try
|
||||
{
|
||||
w.accept(ws, boost::asio::buffer(
|
||||
w.accept(ws, net::buffer(
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"Host: localhost\r\n"
|
||||
"Upgrade: websocket\r\n"
|
||||
@@ -210,7 +210,7 @@ public:
|
||||
try
|
||||
{
|
||||
bool called = false;
|
||||
w.accept_ex(ws, boost::asio::buffer(
|
||||
w.accept_ex(ws, net::buffer(
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"Host: localhost\r\n"
|
||||
"Upgrade: websocket\r\n"
|
||||
@@ -411,7 +411,7 @@ public:
|
||||
if( e.code() !=
|
||||
websocket::error::no_sec_key &&
|
||||
e.code() !=
|
||||
boost::asio::error::eof)
|
||||
net::error::eof)
|
||||
throw;
|
||||
}
|
||||
});
|
||||
@@ -476,7 +476,7 @@ public:
|
||||
try
|
||||
{
|
||||
ws.accept(
|
||||
boost::asio::buffer(s.data(), n));
|
||||
net::buffer(s.data(), n));
|
||||
BEAST_EXPECTS(! ev, ev.message());
|
||||
}
|
||||
catch(system_error const& se)
|
||||
@@ -616,7 +616,7 @@ public:
|
||||
void
|
||||
testMoveOnly()
|
||||
{
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc};
|
||||
ws.async_accept(move_only_handler{});
|
||||
}
|
||||
@@ -636,12 +636,12 @@ public:
|
||||
// make sure things compile, also can set a
|
||||
// breakpoint in asio_handler_invoke to make sure
|
||||
// it is instantiated.
|
||||
boost::asio::io_context ioc;
|
||||
boost::asio::strand<
|
||||
boost::asio::io_context::executor_type> s(
|
||||
net::io_context ioc;
|
||||
net::strand<
|
||||
net::io_context::executor_type> s(
|
||||
ioc.get_executor());
|
||||
stream<test::stream> ws{ioc};
|
||||
ws.async_accept(boost::asio::bind_executor(
|
||||
ws.async_accept(net::bind_executor(
|
||||
s, copyable_handler{}));
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
catch(system_error const& se)
|
||||
{
|
||||
BEAST_EXPECTS(
|
||||
se.code() == boost::asio::error::operation_aborted,
|
||||
se.code() == net::error::operation_aborted,
|
||||
se.code().message());
|
||||
}
|
||||
}
|
||||
@@ -171,13 +171,13 @@ public:
|
||||
void
|
||||
testSuspend()
|
||||
{
|
||||
using boost::asio::buffer;
|
||||
using net::buffer;
|
||||
|
||||
// suspend on ping
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -209,7 +209,7 @@ public:
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -242,7 +242,7 @@ public:
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -283,7 +283,7 @@ public:
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -310,7 +310,7 @@ public:
|
||||
ws.async_close({},
|
||||
[&](error_code ec)
|
||||
{
|
||||
if(ec != boost::asio::error::operation_aborted)
|
||||
if(ec != net::error::operation_aborted)
|
||||
BOOST_THROW_EXCEPTION(
|
||||
system_error{ec});
|
||||
BEAST_EXPECT(++count == 2);
|
||||
@@ -324,7 +324,7 @@ public:
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -351,7 +351,7 @@ public:
|
||||
ws.async_close({},
|
||||
[&](error_code ec)
|
||||
{
|
||||
if(ec != boost::asio::error::operation_aborted)
|
||||
if(ec != net::error::operation_aborted)
|
||||
BOOST_THROW_EXCEPTION(
|
||||
system_error{ec});
|
||||
BEAST_EXPECT(++count == 2);
|
||||
@@ -365,7 +365,7 @@ public:
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -387,7 +387,7 @@ public:
|
||||
ws.async_read(b,
|
||||
[&](error_code ec, std::size_t)
|
||||
{
|
||||
if(ec != boost::asio::error::operation_aborted)
|
||||
if(ec != net::error::operation_aborted)
|
||||
BOOST_THROW_EXCEPTION(
|
||||
system_error{ec});
|
||||
BEAST_EXPECT(++count == 3);
|
||||
@@ -409,7 +409,7 @@ public:
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -431,7 +431,7 @@ public:
|
||||
ws.async_read(b,
|
||||
[&](error_code ec, std::size_t)
|
||||
{
|
||||
if(ec != boost::asio::error::operation_aborted)
|
||||
if(ec != net::error::operation_aborted)
|
||||
BOOST_THROW_EXCEPTION(
|
||||
system_error{ec});
|
||||
BEAST_EXPECT(++count == 3);
|
||||
@@ -456,7 +456,7 @@ public:
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -474,7 +474,7 @@ public:
|
||||
ws.async_read(b,
|
||||
[&](error_code ec, std::size_t)
|
||||
{
|
||||
if(ec != boost::asio::error::operation_aborted)
|
||||
if(ec != net::error::operation_aborted)
|
||||
BOOST_THROW_EXCEPTION(
|
||||
system_error{ec});
|
||||
++count;
|
||||
@@ -482,7 +482,7 @@ public:
|
||||
ws.async_write(buffer(s),
|
||||
[&](error_code ec, std::size_t)
|
||||
{
|
||||
if(ec != boost::asio::error::operation_aborted)
|
||||
if(ec != net::error::operation_aborted)
|
||||
BOOST_THROW_EXCEPTION(
|
||||
system_error{ec});
|
||||
++count;
|
||||
@@ -490,7 +490,7 @@ public:
|
||||
ws.async_ping({},
|
||||
[&](error_code ec)
|
||||
{
|
||||
if(ec != boost::asio::error::operation_aborted)
|
||||
if(ec != net::error::operation_aborted)
|
||||
BOOST_THROW_EXCEPTION(
|
||||
system_error{ec});
|
||||
++count;
|
||||
@@ -504,7 +504,7 @@ public:
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -514,7 +514,7 @@ public:
|
||||
ws.async_read(b,
|
||||
[&](error_code ec, std::size_t)
|
||||
{
|
||||
if(ec && ec != boost::asio::error::operation_aborted)
|
||||
if(ec && ec != net::error::operation_aborted)
|
||||
{
|
||||
BEAST_EXPECTS(ec, ec.message());
|
||||
BOOST_THROW_EXCEPTION(
|
||||
@@ -525,7 +525,7 @@ public:
|
||||
++count;
|
||||
if(count == 4)
|
||||
BEAST_EXPECT(
|
||||
ec == boost::asio::error::operation_aborted);
|
||||
ec == net::error::operation_aborted);
|
||||
});
|
||||
ws.async_write(buffer(s),
|
||||
[&](error_code ec, std::size_t n)
|
||||
@@ -539,7 +539,7 @@ public:
|
||||
ws.async_ping({},
|
||||
[&](error_code ec)
|
||||
{
|
||||
if(ec != boost::asio::error::operation_aborted)
|
||||
if(ec != net::error::operation_aborted)
|
||||
{
|
||||
BEAST_EXPECTS(ec, ec.message());
|
||||
BOOST_THROW_EXCEPTION(
|
||||
@@ -565,7 +565,7 @@ public:
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -583,7 +583,7 @@ public:
|
||||
ws.async_read(b,
|
||||
[&](error_code ec, std::size_t)
|
||||
{
|
||||
if(ec != boost::asio::error::operation_aborted)
|
||||
if(ec != net::error::operation_aborted)
|
||||
BOOST_THROW_EXCEPTION(
|
||||
system_error{ec});
|
||||
++count;
|
||||
@@ -591,7 +591,7 @@ public:
|
||||
ws.async_write(buffer(s),
|
||||
[&](error_code ec, std::size_t)
|
||||
{
|
||||
if(ec != boost::asio::error::operation_aborted)
|
||||
if(ec != net::error::operation_aborted)
|
||||
BOOST_THROW_EXCEPTION(
|
||||
system_error{ec});
|
||||
++count;
|
||||
@@ -621,14 +621,14 @@ public:
|
||||
stream<test::stream> ws{ioc_};
|
||||
stream<test::stream>::close_op<handler> op{
|
||||
handler{}, ws, {}};
|
||||
using boost::asio::asio_handler_is_continuation;
|
||||
using net::asio_handler_is_continuation;
|
||||
asio_handler_is_continuation(&op);
|
||||
}
|
||||
|
||||
void
|
||||
testMoveOnly()
|
||||
{
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc};
|
||||
ws.async_close({}, move_only_handler{});
|
||||
}
|
||||
@@ -648,12 +648,12 @@ public:
|
||||
// make sure things compile, also can set a
|
||||
// breakpoint in asio_handler_invoke to make sure
|
||||
// it is instantiated.
|
||||
boost::asio::io_context ioc;
|
||||
boost::asio::strand<
|
||||
boost::asio::io_context::executor_type> s(
|
||||
net::io_context ioc;
|
||||
net::strand<
|
||||
net::io_context::executor_type> s(
|
||||
ioc.get_executor());
|
||||
stream<test::stream> ws{ioc};
|
||||
ws.async_close({}, boost::asio::bind_executor(
|
||||
ws.async_close({}, net::bind_executor(
|
||||
s, copyable_handler{}));
|
||||
}
|
||||
|
||||
|
||||
@@ -27,53 +27,53 @@ namespace doc_ws_snippets {
|
||||
|
||||
void fxx() {
|
||||
|
||||
boost::asio::io_service ios;
|
||||
boost::asio::io_service::work work{ios};
|
||||
net::io_service ios;
|
||||
net::io_service::work work{ios};
|
||||
std::thread t{[&](){ ios.run(); }};
|
||||
error_code ec;
|
||||
boost::asio::ip::tcp::socket sock{ios};
|
||||
net::ip::tcp::socket sock{ios};
|
||||
|
||||
{
|
||||
//[ws_snippet_2
|
||||
stream<boost::asio::ip::tcp::socket> ws{ios};
|
||||
stream<net::ip::tcp::socket> ws{ios};
|
||||
//]
|
||||
}
|
||||
|
||||
{
|
||||
//[ws_snippet_3
|
||||
stream<boost::asio::ip::tcp::socket> ws{std::move(sock)};
|
||||
stream<net::ip::tcp::socket> ws{std::move(sock)};
|
||||
//]
|
||||
}
|
||||
|
||||
{
|
||||
//[ws_snippet_4
|
||||
stream<boost::asio::ip::tcp::socket&> ws{sock};
|
||||
stream<net::ip::tcp::socket&> ws{sock};
|
||||
//]
|
||||
|
||||
//[ws_snippet_5
|
||||
ws.next_layer().shutdown(boost::asio::ip::tcp::socket::shutdown_send);
|
||||
ws.next_layer().shutdown(net::ip::tcp::socket::shutdown_send);
|
||||
//]
|
||||
}
|
||||
|
||||
{
|
||||
//[ws_snippet_6
|
||||
std::string const host = "mywebapp.com";
|
||||
boost::asio::ip::tcp::resolver r{ios};
|
||||
stream<boost::asio::ip::tcp::socket> ws{ios};
|
||||
boost::asio::connect(ws.next_layer(), r.resolve({host, "ws"}));
|
||||
net::ip::tcp::resolver r{ios};
|
||||
stream<net::ip::tcp::socket> ws{ios};
|
||||
net::connect(ws.next_layer(), r.resolve({host, "ws"}));
|
||||
//]
|
||||
}
|
||||
|
||||
{
|
||||
//[ws_snippet_7
|
||||
boost::asio::ip::tcp::acceptor acceptor{ios};
|
||||
stream<boost::asio::ip::tcp::socket> ws{acceptor.get_io_service()};
|
||||
net::ip::tcp::acceptor acceptor{ios};
|
||||
stream<net::ip::tcp::socket> ws{acceptor.get_io_service()};
|
||||
acceptor.accept(ws.next_layer());
|
||||
//]
|
||||
}
|
||||
|
||||
{
|
||||
stream<boost::asio::ip::tcp::socket> ws{ios};
|
||||
stream<net::ip::tcp::socket> ws{ios};
|
||||
//[ws_snippet_8
|
||||
ws.handshake("localhost", "/");
|
||||
//]
|
||||
@@ -119,7 +119,7 @@ boost::asio::ip::tcp::socket sock{ios};
|
||||
if(websocket::is_upgrade(req))
|
||||
{
|
||||
// Construct the stream, transferring ownership of the socket
|
||||
stream<boost::asio::ip::tcp::socket> ws{std::move(sock)};
|
||||
stream<net::ip::tcp::socket> ws{std::move(sock)};
|
||||
|
||||
// Accept the request from our message. Clients SHOULD NOT
|
||||
// begin sending WebSocket frames until the server has
|
||||
@@ -137,19 +137,19 @@ boost::asio::ip::tcp::socket sock{ios};
|
||||
}
|
||||
|
||||
{
|
||||
stream<boost::asio::ip::tcp::socket> ws{ios};
|
||||
stream<net::ip::tcp::socket> ws{ios};
|
||||
//[ws_snippet_14
|
||||
// Read into our buffer until we reach the end of the HTTP request.
|
||||
// No parsing takes place here, we are just accumulating data.
|
||||
boost::asio::streambuf buffer;
|
||||
boost::asio::read_until(sock, buffer, "\r\n\r\n");
|
||||
net::streambuf buffer;
|
||||
net::read_until(sock, buffer, "\r\n\r\n");
|
||||
|
||||
// Now accept the connection, using the buffered data.
|
||||
ws.accept(buffer.data());
|
||||
//]
|
||||
}
|
||||
{
|
||||
stream<boost::asio::ip::tcp::socket> ws{ios};
|
||||
stream<net::ip::tcp::socket> ws{ios};
|
||||
//[ws_snippet_15
|
||||
multi_buffer buffer;
|
||||
ws.read(buffer);
|
||||
@@ -161,7 +161,7 @@ boost::asio::ip::tcp::socket sock{ios};
|
||||
}
|
||||
|
||||
{
|
||||
stream<boost::asio::ip::tcp::socket> ws{ios};
|
||||
stream<net::ip::tcp::socket> ws{ios};
|
||||
//[ws_snippet_16
|
||||
multi_buffer buffer;
|
||||
for(;;)
|
||||
@@ -171,7 +171,7 @@ boost::asio::ip::tcp::socket sock{ios};
|
||||
consuming_buffers<multi_buffer::const_buffers_type> cb{buffer.data()};
|
||||
for(;;)
|
||||
{
|
||||
using boost::asio::buffer_size;
|
||||
using net::buffer_size;
|
||||
if(buffer_size(cb) > 512)
|
||||
{
|
||||
ws.write_some(false, buffer_prefix(512, cb));
|
||||
@@ -187,7 +187,7 @@ boost::asio::ip::tcp::socket sock{ios};
|
||||
}
|
||||
|
||||
{
|
||||
stream<boost::asio::ip::tcp::socket> ws{ios};
|
||||
stream<net::ip::tcp::socket> ws{ios};
|
||||
//[ws_snippet_17
|
||||
auto cb =
|
||||
[](frame_type kind, string_view payload)
|
||||
@@ -222,12 +222,12 @@ boost::asio::ip::tcp::socket sock{ios};
|
||||
// workaround for https://github.com/chriskohlhoff/asio/issues/112
|
||||
#ifdef BOOST_MSVC
|
||||
//[ws_snippet_21
|
||||
void echo(stream<boost::asio::ip::tcp::socket>& ws,
|
||||
multi_buffer& buffer, boost::asio::yield_context yield)
|
||||
void echo(stream<net::ip::tcp::socket>& ws,
|
||||
multi_buffer& buffer, net::yield_context yield)
|
||||
{
|
||||
ws.async_read(buffer, yield);
|
||||
std::future<void> fut =
|
||||
ws.async_write(buffer.data(), boost::asio::use_future);
|
||||
ws.async_write(buffer.data(), net::use_future);
|
||||
}
|
||||
//]
|
||||
#endif
|
||||
@@ -247,30 +247,30 @@ namespace doc_wss_snippets {
|
||||
|
||||
void fxx() {
|
||||
|
||||
boost::asio::io_service ios;
|
||||
boost::asio::io_service::work work{ios};
|
||||
net::io_service ios;
|
||||
net::io_service::work work{ios};
|
||||
std::thread t{[&](){ ios.run(); }};
|
||||
error_code ec;
|
||||
boost::asio::ip::tcp::socket sock{ios};
|
||||
net::ip::tcp::socket sock{ios};
|
||||
|
||||
{
|
||||
//[wss_snippet_2
|
||||
boost::asio::ssl::context ctx{boost::asio::ssl::context::sslv23};
|
||||
stream<boost::asio::ssl::stream<boost::asio::ip::tcp::socket>> wss{ios, ctx};
|
||||
net::ssl::context ctx{net::ssl::context::sslv23};
|
||||
stream<net::ssl::stream<net::ip::tcp::socket>> wss{ios, ctx};
|
||||
//]
|
||||
}
|
||||
|
||||
{
|
||||
//[wss_snippet_3
|
||||
boost::asio::ip::tcp::endpoint ep;
|
||||
boost::asio::ssl::context ctx{boost::asio::ssl::context::sslv23};
|
||||
stream<boost::asio::ssl::stream<boost::asio::ip::tcp::socket>> ws{ios, ctx};
|
||||
net::ip::tcp::endpoint ep;
|
||||
net::ssl::context ctx{net::ssl::context::sslv23};
|
||||
stream<net::ssl::stream<net::ip::tcp::socket>> ws{ios, ctx};
|
||||
|
||||
// connect the underlying TCP/IP socket
|
||||
ws.next_layer().next_layer().connect(ep);
|
||||
|
||||
// perform SSL handshake
|
||||
ws.next_layer().handshake(boost::asio::ssl::stream_base::client);
|
||||
ws.next_layer().handshake(net::ssl::stream_base::client);
|
||||
|
||||
// perform WebSocket handshake
|
||||
ws.handshake("localhost", "/");
|
||||
|
||||
@@ -490,7 +490,7 @@ public:
|
||||
void
|
||||
testMoveOnly()
|
||||
{
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc};
|
||||
ws.async_handshake("", "", move_only_handler{});
|
||||
}
|
||||
@@ -510,13 +510,13 @@ public:
|
||||
// make sure things compile, also can set a
|
||||
// breakpoint in asio_handler_invoke to make sure
|
||||
// it is instantiated.
|
||||
boost::asio::io_context ioc;
|
||||
boost::asio::strand<
|
||||
boost::asio::io_context::executor_type> s(
|
||||
net::io_context ioc;
|
||||
net::strand<
|
||||
net::io_context::executor_type> s(
|
||||
ioc.get_executor());
|
||||
stream<test::stream> ws{ioc};
|
||||
ws.async_handshake("localhost", "/",
|
||||
boost::asio::bind_executor(
|
||||
net::bind_executor(
|
||||
s, copyable_handler{}));
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
catch(system_error const& se)
|
||||
{
|
||||
BEAST_EXPECTS(
|
||||
se.code() == boost::asio::error::operation_aborted,
|
||||
se.code() == net::error::operation_aborted,
|
||||
se.code().message());
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
catch(system_error const& se)
|
||||
{
|
||||
BEAST_EXPECTS(
|
||||
se.code() == boost::asio::error::operation_aborted,
|
||||
se.code() == net::error::operation_aborted,
|
||||
se.code().message());
|
||||
}
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public:
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -134,7 +134,7 @@ public:
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -153,7 +153,7 @@ public:
|
||||
[&](error_code ec)
|
||||
{
|
||||
++count;
|
||||
if(ec != boost::asio::error::operation_aborted)
|
||||
if(ec != net::error::operation_aborted)
|
||||
BOOST_THROW_EXCEPTION(
|
||||
system_error{ec});
|
||||
});
|
||||
@@ -166,7 +166,7 @@ public:
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -207,7 +207,7 @@ public:
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -236,7 +236,7 @@ public:
|
||||
[&](error_code ec)
|
||||
{
|
||||
++count;
|
||||
if(ec != boost::asio::error::operation_aborted)
|
||||
if(ec != net::error::operation_aborted)
|
||||
BOOST_THROW_EXCEPTION(
|
||||
system_error{ec});
|
||||
});
|
||||
@@ -249,7 +249,7 @@ public:
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -277,7 +277,7 @@ public:
|
||||
[&](error_code ec)
|
||||
{
|
||||
++count;
|
||||
if(ec != boost::asio::error::operation_aborted)
|
||||
if(ec != net::error::operation_aborted)
|
||||
BOOST_THROW_EXCEPTION(
|
||||
system_error{ec});
|
||||
});
|
||||
@@ -290,7 +290,7 @@ public:
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log, kind::async};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -317,7 +317,7 @@ public:
|
||||
[&](error_code ec)
|
||||
{
|
||||
++count;
|
||||
if(ec != boost::asio::error::operation_aborted)
|
||||
if(ec != net::error::operation_aborted)
|
||||
BOOST_THROW_EXCEPTION(
|
||||
system_error{ec});
|
||||
});
|
||||
@@ -331,7 +331,7 @@ public:
|
||||
{
|
||||
echo_server es{log};
|
||||
error_code ec;
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -350,7 +350,7 @@ public:
|
||||
[&](error_code ec)
|
||||
{
|
||||
++count;
|
||||
if(ec != boost::asio::error::operation_aborted)
|
||||
if(ec != net::error::operation_aborted)
|
||||
BOOST_THROW_EXCEPTION(
|
||||
system_error{ec});
|
||||
});
|
||||
@@ -368,7 +368,7 @@ public:
|
||||
|
||||
{
|
||||
echo_server es{log, kind::async};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -397,7 +397,7 @@ public:
|
||||
{
|
||||
// Pings after a close are aborted
|
||||
++count;
|
||||
BEAST_EXPECTS(ec == boost::asio::
|
||||
BEAST_EXPECTS(ec == net::
|
||||
error::operation_aborted,
|
||||
ec.message());
|
||||
// Subsequent calls to close are aborted
|
||||
@@ -405,7 +405,7 @@ public:
|
||||
[&](error_code ec)
|
||||
{
|
||||
++count;
|
||||
BEAST_EXPECTS(ec == boost::asio::
|
||||
BEAST_EXPECTS(ec == net::
|
||||
error::operation_aborted,
|
||||
ec.message());
|
||||
});
|
||||
@@ -434,14 +434,14 @@ public:
|
||||
stream<test::stream> ws{ioc_};
|
||||
stream<test::stream>::ping_op<handler> op{
|
||||
handler{}, ws, detail::opcode::ping, {}};
|
||||
using boost::asio::asio_handler_is_continuation;
|
||||
using net::asio_handler_is_continuation;
|
||||
asio_handler_is_continuation(&op);
|
||||
}
|
||||
|
||||
void
|
||||
testMoveOnly()
|
||||
{
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc};
|
||||
ws.async_ping({}, move_only_handler{});
|
||||
}
|
||||
@@ -461,12 +461,12 @@ public:
|
||||
// make sure things compile, also can set a
|
||||
// breakpoint in asio_handler_invoke to make sure
|
||||
// it is instantiated.
|
||||
boost::asio::io_context ioc;
|
||||
boost::asio::strand<
|
||||
boost::asio::io_context::executor_type> s(
|
||||
net::io_context ioc;
|
||||
net::strand<
|
||||
net::io_context::executor_type> s(
|
||||
ioc.get_executor());
|
||||
stream<test::stream> ws{ioc};
|
||||
ws.async_ping({}, boost::asio::bind_executor(
|
||||
ws.async_ping({}, net::bind_executor(
|
||||
s, copyable_handler{}));
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
void
|
||||
doTestRead(Wrap const& w)
|
||||
{
|
||||
using boost::asio::buffer;
|
||||
using net::buffer;
|
||||
|
||||
permessage_deflate pmd;
|
||||
pmd.client_enable = false;
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
catch(system_error const& se)
|
||||
{
|
||||
BEAST_EXPECTS(
|
||||
se.code() == boost::asio::error::operation_aborted,
|
||||
se.code() == net::error::operation_aborted,
|
||||
se.code().message());
|
||||
}
|
||||
}
|
||||
@@ -248,7 +248,7 @@ public:
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log, kind::async};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream, deflateSupported> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -275,7 +275,7 @@ public:
|
||||
w.close(ws, {});
|
||||
multi_buffer b;
|
||||
doFailTest(w, ws,
|
||||
boost::asio::error::operation_aborted);
|
||||
net::error::operation_aborted);
|
||||
});
|
||||
|
||||
// buffer overflow
|
||||
@@ -437,7 +437,7 @@ public:
|
||||
void
|
||||
doTestReadDeflate(Wrap const& w)
|
||||
{
|
||||
using boost::asio::buffer;
|
||||
using net::buffer;
|
||||
|
||||
permessage_deflate pmd;
|
||||
pmd.client_enable = true;
|
||||
@@ -504,7 +504,7 @@ public:
|
||||
permessage_deflate const& pmd,
|
||||
Wrap const& w)
|
||||
{
|
||||
using boost::asio::buffer;
|
||||
using net::buffer;
|
||||
|
||||
// message
|
||||
doTest(pmd, [&](ws_type& ws)
|
||||
@@ -613,7 +613,7 @@ public:
|
||||
void
|
||||
testRead()
|
||||
{
|
||||
using boost::asio::buffer;
|
||||
using net::buffer;
|
||||
|
||||
doTestRead<false>(SyncClient{});
|
||||
doTestRead<true>(SyncClient{});
|
||||
|
||||
@@ -26,13 +26,13 @@ public:
|
||||
void
|
||||
testSuspend()
|
||||
{
|
||||
using boost::asio::buffer;
|
||||
using net::buffer;
|
||||
#if 1
|
||||
// suspend on read block
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
ws.async_read(b,
|
||||
[&](error_code ec, std::size_t)
|
||||
{
|
||||
if(ec != boost::asio::error::operation_aborted)
|
||||
if(ec != net::error::operation_aborted)
|
||||
BOOST_THROW_EXCEPTION(
|
||||
system_error{ec});
|
||||
BEAST_EXPECT(++count == 2);
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
{
|
||||
//log << "fc.count()==" << fc.count() << std::endl;
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
ws.async_read(b,
|
||||
[&](error_code ec, std::size_t)
|
||||
{
|
||||
if(ec != boost::asio::error::operation_aborted)
|
||||
if(ec != net::error::operation_aborted)
|
||||
BOOST_THROW_EXCEPTION(
|
||||
system_error{ec});
|
||||
BEAST_EXPECT(++count == 2);
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -136,7 +136,7 @@ public:
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -160,7 +160,7 @@ public:
|
||||
ws.async_read(b,
|
||||
[&](error_code ec, std::size_t)
|
||||
{
|
||||
if(ec != boost::asio::error::operation_aborted)
|
||||
if(ec != net::error::operation_aborted)
|
||||
BOOST_THROW_EXCEPTION(
|
||||
system_error{ec});
|
||||
BEAST_EXPECT(++count == 3);
|
||||
@@ -184,7 +184,7 @@ public:
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -199,7 +199,7 @@ public:
|
||||
ws.async_read(b,
|
||||
[&](error_code ec, std::size_t)
|
||||
{
|
||||
if(ec != boost::asio::error::operation_aborted)
|
||||
if(ec != net::error::operation_aborted)
|
||||
BOOST_THROW_EXCEPTION(
|
||||
system_error{ec});
|
||||
BEAST_EXPECT(++count == 2);
|
||||
@@ -227,7 +227,7 @@ public:
|
||||
[&](string_view s)
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -241,7 +241,7 @@ public:
|
||||
// chopped frame header
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -259,7 +259,7 @@ public:
|
||||
});
|
||||
ioc.run_one();
|
||||
es.stream().write_some(
|
||||
boost::asio::buffer("\x01" + s));
|
||||
net::buffer("\x01" + s));
|
||||
ioc.run();
|
||||
BEAST_EXPECT(count == 1);
|
||||
}
|
||||
@@ -297,7 +297,7 @@ public:
|
||||
// unmasked frame from client
|
||||
{
|
||||
echo_server es{log, kind::async_client};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
es.async_handshake();
|
||||
@@ -316,7 +316,7 @@ public:
|
||||
// chopped control frame payload
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -333,7 +333,7 @@ public:
|
||||
});
|
||||
ioc.run_one();
|
||||
es.stream().write_some(
|
||||
boost::asio::buffer(
|
||||
net::buffer(
|
||||
"*" "\x81\x02**"));
|
||||
ioc.run();
|
||||
BEAST_EXPECT(count == 1);
|
||||
@@ -356,11 +356,11 @@ public:
|
||||
char buf[32];
|
||||
stream<test::stream> ws{ioc_};
|
||||
stream<test::stream>::read_some_op<
|
||||
boost::asio::mutable_buffer,
|
||||
net::mutable_buffer,
|
||||
handler> op{handler{}, ws,
|
||||
boost::asio::mutable_buffer{
|
||||
net::mutable_buffer{
|
||||
buf, sizeof(buf)}};
|
||||
using boost::asio::asio_handler_is_continuation;
|
||||
using net::asio_handler_is_continuation;
|
||||
asio_handler_is_continuation(&op);
|
||||
pass();
|
||||
}
|
||||
@@ -375,7 +375,7 @@ public:
|
||||
stream<test::stream>::read_op<
|
||||
multi_buffer, handler> op{
|
||||
handler{}, ws, b, 32, true};
|
||||
using boost::asio::asio_handler_is_continuation;
|
||||
using net::asio_handler_is_continuation;
|
||||
asio_handler_is_continuation(&op);
|
||||
pass();
|
||||
}
|
||||
@@ -387,12 +387,12 @@ public:
|
||||
for(std::size_t i = 0; i < 100; ++i)
|
||||
{
|
||||
echo_server es{log, kind::async};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
// too-big message frame indicates payload of 2^64-1
|
||||
boost::asio::write(ws.next_layer(), sbuf(
|
||||
net::write(ws.next_layer(), sbuf(
|
||||
"\x81\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"));
|
||||
multi_buffer b;
|
||||
error_code ec;
|
||||
@@ -406,13 +406,13 @@ public:
|
||||
testIssue807()
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
ws.write(sbuf("Hello, world!"));
|
||||
char buf[4];
|
||||
boost::asio::mutable_buffer b{buf, 0};
|
||||
net::mutable_buffer b{buf, 0};
|
||||
auto const n = ws.read_some(b);
|
||||
BEAST_EXPECT(n == 0);
|
||||
}
|
||||
@@ -428,7 +428,7 @@ public:
|
||||
{
|
||||
echo_server es{log};
|
||||
multi_buffer b;
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -478,18 +478,18 @@ public:
|
||||
#if 0
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc};
|
||||
ws.set_option(pmd);
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
// invalid 1-byte deflate block in frame
|
||||
boost::asio::write(ws.next_layer(), sbuf(
|
||||
net::write(ws.next_layer(), sbuf(
|
||||
"\xc1\x81\x3a\xa1\x74\x3b\x49"));
|
||||
}
|
||||
#endif
|
||||
{
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> wsc{ioc};
|
||||
stream<test::stream> wss{ioc};
|
||||
wsc.set_option(pmd);
|
||||
@@ -503,7 +503,7 @@ public:
|
||||
BEAST_EXPECT(wsc.is_open());
|
||||
BEAST_EXPECT(wss.is_open());
|
||||
// invalid 1-byte deflate block in frame
|
||||
boost::asio::write(wsc.next_layer(), sbuf(
|
||||
net::write(wsc.next_layer(), sbuf(
|
||||
"\xc1\x81\x3a\xa1\x74\x3b\x49"));
|
||||
error_code ec;
|
||||
multi_buffer b;
|
||||
@@ -515,18 +515,18 @@ public:
|
||||
#if 0
|
||||
{
|
||||
echo_server es{log, kind::async};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc};
|
||||
ws.set_option(pmd);
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
// invalid 1-byte deflate block in frame
|
||||
boost::asio::write(ws.next_layer(), sbuf(
|
||||
net::write(ws.next_layer(), sbuf(
|
||||
"\xc1\x81\x3a\xa1\x74\x3b\x49"));
|
||||
}
|
||||
#endif
|
||||
{
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> wsc{ioc};
|
||||
stream<test::stream> wss{ioc};
|
||||
wsc.set_option(pmd);
|
||||
@@ -540,7 +540,7 @@ public:
|
||||
BEAST_EXPECT(wsc.is_open());
|
||||
BEAST_EXPECT(wss.is_open());
|
||||
// invalid 1-byte deflate block in frame
|
||||
boost::asio::write(wsc.next_layer(), sbuf(
|
||||
net::write(wsc.next_layer(), sbuf(
|
||||
"\xc1\x81\x3a\xa1\x74\x3b\x49"));
|
||||
error_code ec;
|
||||
flat_buffer b;
|
||||
@@ -566,7 +566,7 @@ public:
|
||||
|
||||
// read
|
||||
{
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> wsc{ioc};
|
||||
stream<test::stream> wss{ioc};
|
||||
wsc.set_option(pmd);
|
||||
@@ -580,7 +580,7 @@ public:
|
||||
BEAST_EXPECT(wsc.is_open());
|
||||
BEAST_EXPECT(wss.is_open());
|
||||
// contains a deflate block with BFINAL set
|
||||
boost::asio::write(wsc.next_layer(), sbuf(
|
||||
net::write(wsc.next_layer(), sbuf(
|
||||
"\xc1\xf8\xd1\xe4\xcc\x3e\xda\xe4\xcc\x3e"
|
||||
"\x2b\x1e\x36\xc4\x2b\x1e\x36\xc4\x2b\x1e"
|
||||
"\x36\x3e\x35\xae\x4f\x54\x18\xae\x4f\x7b"
|
||||
@@ -602,7 +602,7 @@ public:
|
||||
|
||||
// async read
|
||||
{
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> wsc{ioc};
|
||||
stream<test::stream> wss{ioc};
|
||||
wsc.set_option(pmd);
|
||||
@@ -616,7 +616,7 @@ public:
|
||||
BEAST_EXPECT(wsc.is_open());
|
||||
BEAST_EXPECT(wss.is_open());
|
||||
// contains a deflate block with BFINAL set
|
||||
boost::asio::write(wsc.next_layer(), sbuf(
|
||||
net::write(wsc.next_layer(), sbuf(
|
||||
"\xc1\xf8\xd1\xe4\xcc\x3e\xda\xe4\xcc\x3e"
|
||||
"\x2b\x1e\x36\xc4\x2b\x1e\x36\xc4\x2b\x1e"
|
||||
"\x36\x3e\x35\xae\x4f\x54\x18\xae\x4f\x7b"
|
||||
@@ -642,10 +642,10 @@ public:
|
||||
void
|
||||
testMoveOnly()
|
||||
{
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc};
|
||||
ws.async_read_some(
|
||||
boost::asio::mutable_buffer{},
|
||||
net::mutable_buffer{},
|
||||
move_only_handler{});
|
||||
}
|
||||
|
||||
@@ -665,13 +665,13 @@ public:
|
||||
// breakpoint in asio_handler_invoke to make sure
|
||||
// it is instantiated.
|
||||
{
|
||||
boost::asio::io_context ioc;
|
||||
boost::asio::strand<
|
||||
boost::asio::io_context::executor_type> s(
|
||||
net::io_context ioc;
|
||||
net::strand<
|
||||
net::io_context::executor_type> s(
|
||||
ioc.get_executor());
|
||||
stream<test::stream> ws{ioc};
|
||||
flat_buffer b;
|
||||
ws.async_read(b, boost::asio::bind_executor(
|
||||
ws.async_read(b, net::bind_executor(
|
||||
s, copyable_handler{}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ public:
|
||||
run() override
|
||||
{
|
||||
BOOST_STATIC_ASSERT(std::is_constructible<
|
||||
stream<test::stream>, boost::asio::io_context&>::value);
|
||||
stream<test::stream>, net::io_context&>::value);
|
||||
|
||||
BOOST_STATIC_ASSERT(std::is_move_constructible<
|
||||
stream<test::stream>>::value);
|
||||
|
||||
@@ -9,7 +9,15 @@
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include <boost/beast/websocket/stream.hpp>
|
||||
|
||||
#include <boost/beast/core/detail/config.hpp>
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
|
||||
template class boost::beast::websocket::stream<boost::asio::ip::tcp::socket, false>;
|
||||
template class boost::beast::websocket::stream<boost::asio::ip::tcp::socket, true>;
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
template class websocket::stream<net::ip::tcp::socket, false>;
|
||||
template class websocket::stream<net::ip::tcp::socket, true>;
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
@@ -72,9 +72,9 @@ public:
|
||||
};
|
||||
|
||||
std::ostream& log_;
|
||||
boost::asio::io_context ioc_;
|
||||
boost::asio::executor_work_guard<
|
||||
boost::asio::io_context::executor_type> work_;
|
||||
net::io_context ioc_;
|
||||
net::executor_work_guard<
|
||||
net::io_context::executor_type> work_;
|
||||
static_buffer<buf_size> buffer_;
|
||||
test::stream ts_;
|
||||
std::thread t_;
|
||||
@@ -139,7 +139,7 @@ public:
|
||||
void
|
||||
async_close()
|
||||
{
|
||||
boost::asio::post(ioc_,
|
||||
net::post(ioc_,
|
||||
[&]
|
||||
{
|
||||
if(ws_.is_open())
|
||||
@@ -178,7 +178,7 @@ public:
|
||||
#if 0
|
||||
if( se.code() != error::closed &&
|
||||
se.code() != error::failed &&
|
||||
se.code() != boost::asio::error::eof)
|
||||
se.code() != net::error::eof)
|
||||
log_ << "echo_server: " << se.code().message() << std::endl;
|
||||
#endif
|
||||
}
|
||||
@@ -270,7 +270,7 @@ public:
|
||||
#if 0
|
||||
if( ec != error::closed &&
|
||||
ec != error::failed &&
|
||||
ec != boost::asio::error::eof)
|
||||
ec != net::error::eof)
|
||||
log_ <<
|
||||
"echo_server_async: " <<
|
||||
ec.message() <<
|
||||
@@ -384,7 +384,7 @@ public:
|
||||
class cbuf_helper
|
||||
{
|
||||
std::array<std::uint8_t, N> v_;
|
||||
boost::asio::const_buffer cb_;
|
||||
net::const_buffer cb_;
|
||||
|
||||
public:
|
||||
using value_type = decltype(cb_);
|
||||
@@ -420,10 +420,10 @@ public:
|
||||
|
||||
template<std::size_t N>
|
||||
static
|
||||
boost::asio::const_buffer
|
||||
net::const_buffer
|
||||
sbuf(const char (&s)[N])
|
||||
{
|
||||
return boost::asio::const_buffer(&s[0], N-1);
|
||||
return net::const_buffer(&s[0], N-1);
|
||||
}
|
||||
|
||||
template<
|
||||
@@ -434,8 +434,8 @@ public:
|
||||
DynamicBuffer& buffer,
|
||||
ConstBufferSequence const& buffers)
|
||||
{
|
||||
using boost::asio::buffer_copy;
|
||||
using boost::asio::buffer_size;
|
||||
using net::buffer_copy;
|
||||
using net::buffer_size;
|
||||
buffer.commit(buffer_copy(
|
||||
buffer.prepare(buffer_size(buffers)),
|
||||
buffers));
|
||||
@@ -443,7 +443,7 @@ public:
|
||||
|
||||
template<class Pred>
|
||||
bool
|
||||
run_until(boost::asio::io_context& ioc,
|
||||
run_until(net::io_context& ioc,
|
||||
std::size_t limit, Pred&& pred)
|
||||
{
|
||||
for(std::size_t i = 0; i < limit; ++i)
|
||||
@@ -458,7 +458,7 @@ public:
|
||||
template<class Pred>
|
||||
bool
|
||||
run_until(
|
||||
boost::asio::io_context& ioc, Pred&& pred)
|
||||
net::io_context& ioc, Pred&& pred)
|
||||
{
|
||||
return run_until(ioc, 100, pred);
|
||||
}
|
||||
@@ -699,7 +699,7 @@ public:
|
||||
stream<NextLayer, deflateSupported>& ws,
|
||||
ConstBufferSequence const& buffers) const
|
||||
{
|
||||
return boost::asio::write(
|
||||
return net::write(
|
||||
ws.next_layer(), buffers);
|
||||
}
|
||||
};
|
||||
@@ -708,11 +708,11 @@ public:
|
||||
|
||||
class AsyncClient
|
||||
{
|
||||
boost::asio::yield_context& yield_;
|
||||
net::yield_context& yield_;
|
||||
|
||||
public:
|
||||
explicit
|
||||
AsyncClient(boost::asio::yield_context& yield)
|
||||
AsyncClient(net::yield_context& yield)
|
||||
: yield_(yield)
|
||||
{
|
||||
}
|
||||
@@ -1009,7 +1009,7 @@ public:
|
||||
{
|
||||
error_code ec;
|
||||
auto const bytes_transferred =
|
||||
boost::asio::async_write(
|
||||
net::async_write(
|
||||
ws.next_layer(), buffers, yield_[ec]);
|
||||
if(ec)
|
||||
throw system_error{ec};
|
||||
|
||||
@@ -86,7 +86,7 @@ public:
|
||||
// Autobahn 6.18.1
|
||||
{
|
||||
utf8_checker u;
|
||||
BEAST_EXPECT(! u.write(boost::asio::buffer("\xc1\xbf", 2)));
|
||||
BEAST_EXPECT(! u.write(net::buffer("\xc1\xbf", 2)));
|
||||
}
|
||||
|
||||
utf8_checker u;
|
||||
@@ -132,7 +132,7 @@ public:
|
||||
{
|
||||
{
|
||||
utf8_checker u;
|
||||
BEAST_EXPECT(u.write(boost::asio::buffer("\xef\xbf\xbf", 3)));
|
||||
BEAST_EXPECT(u.write(net::buffer("\xef\xbf\xbf", 3)));
|
||||
BEAST_EXPECT(u.finish());
|
||||
}
|
||||
utf8_checker u;
|
||||
@@ -278,7 +278,7 @@ public:
|
||||
void
|
||||
testFourByteSequence()
|
||||
{
|
||||
using boost::asio::const_buffer;
|
||||
using net::const_buffer;
|
||||
utf8_checker u;
|
||||
std::uint8_t buf[4];
|
||||
// First byte valid range 240-244
|
||||
@@ -461,13 +461,13 @@ public:
|
||||
static std::size_t constexpr size = 3;
|
||||
std::size_t n = s.size();
|
||||
buffers_suffix<
|
||||
boost::asio::const_buffer> cb{
|
||||
boost::asio::const_buffer(s.data(), n)};
|
||||
net::const_buffer> cb{
|
||||
net::const_buffer(s.data(), n)};
|
||||
multi_buffer b;
|
||||
while(n)
|
||||
{
|
||||
auto const amount = (std::min)(n, size);
|
||||
b.commit(boost::asio::buffer_copy(
|
||||
b.commit(net::buffer_copy(
|
||||
b.prepare(amount), cb));
|
||||
cb.consume(amount);
|
||||
n -= amount;
|
||||
@@ -529,12 +529,12 @@ public:
|
||||
for(auto const& s : data)
|
||||
{
|
||||
std::size_t n = s.size();
|
||||
buffers_suffix<boost::asio::const_buffer> cb{boost::asio::const_buffer(s.data(), n)};
|
||||
buffers_suffix<net::const_buffer> cb{net::const_buffer(s.data(), n)};
|
||||
multi_buffer b;
|
||||
while(n)
|
||||
{
|
||||
auto const amount = (std::min)(n, std::size_t(3)/*size*/);
|
||||
b.commit(boost::asio::buffer_copy(b.prepare(amount), cb));
|
||||
b.commit(net::buffer_copy(b.prepare(amount), cb));
|
||||
cb.consume(amount);
|
||||
n -= amount;
|
||||
}
|
||||
@@ -553,12 +553,12 @@ public:
|
||||
auto const& s = data[i];
|
||||
|
||||
std::size_t n = s.size();
|
||||
buffers_suffix<boost::asio::const_buffer> cb{boost::asio::const_buffer(s.data(), n)};
|
||||
buffers_suffix<net::const_buffer> cb{net::const_buffer(s.data(), n)};
|
||||
multi_buffer b;
|
||||
while(n)
|
||||
{
|
||||
auto const amount = (std::min)(n, std::size_t(3)/*size*/);
|
||||
b.commit(boost::asio::buffer_copy(b.prepare(amount), cb));
|
||||
b.commit(net::buffer_copy(b.prepare(amount), cb));
|
||||
cb.consume(amount);
|
||||
n -= amount;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
void
|
||||
doTestWrite(Wrap const& w)
|
||||
{
|
||||
using boost::asio::buffer;
|
||||
using net::buffer;
|
||||
|
||||
permessage_deflate pmd;
|
||||
pmd.client_enable = false;
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
catch(system_error const& se)
|
||||
{
|
||||
BEAST_EXPECTS(
|
||||
se.code() == boost::asio::error::operation_aborted,
|
||||
se.code() == net::error::operation_aborted,
|
||||
se.code().message());
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
[&](ws_type_t<deflateSupported>& ws)
|
||||
{
|
||||
ws.text(true);
|
||||
w.write(ws, boost::asio::const_buffer{});
|
||||
w.write(ws, net::const_buffer{});
|
||||
multi_buffer b;
|
||||
w.read(ws, b);
|
||||
BEAST_EXPECT(ws.got_text());
|
||||
@@ -203,7 +203,7 @@ public:
|
||||
void
|
||||
doTestWriteDeflate(Wrap const& w)
|
||||
{
|
||||
using boost::asio::buffer;
|
||||
using net::buffer;
|
||||
|
||||
permessage_deflate pmd;
|
||||
pmd.client_enable = true;
|
||||
@@ -254,7 +254,7 @@ public:
|
||||
void
|
||||
testWrite()
|
||||
{
|
||||
using boost::asio::buffer;
|
||||
using net::buffer;
|
||||
|
||||
doTestWrite<false>(SyncClient{});
|
||||
doTestWrite<true>(SyncClient{});
|
||||
@@ -271,13 +271,13 @@ public:
|
||||
void
|
||||
testWriteSuspend()
|
||||
{
|
||||
using boost::asio::buffer;
|
||||
using net::buffer;
|
||||
|
||||
// suspend on ping
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -310,7 +310,7 @@ public:
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -329,7 +329,7 @@ public:
|
||||
[&](error_code ec, std::size_t)
|
||||
{
|
||||
++count;
|
||||
if(ec != boost::asio::error::operation_aborted)
|
||||
if(ec != net::error::operation_aborted)
|
||||
BOOST_THROW_EXCEPTION(
|
||||
system_error{ec});
|
||||
});
|
||||
@@ -342,7 +342,7 @@ public:
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -384,7 +384,7 @@ public:
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log, kind::async_client};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
es.async_handshake();
|
||||
@@ -418,7 +418,7 @@ public:
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log, kind::async_client};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
es.async_handshake();
|
||||
@@ -452,7 +452,7 @@ public:
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -484,7 +484,7 @@ public:
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
ws.handshake("localhost", "/");
|
||||
@@ -516,7 +516,7 @@ public:
|
||||
doFailLoop([&](test::fail_count& fc)
|
||||
{
|
||||
echo_server es{log, kind::async};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc, fc};
|
||||
{
|
||||
permessage_deflate pmd;
|
||||
@@ -560,7 +560,7 @@ public:
|
||||
{
|
||||
echo_server es{log, i==1 ?
|
||||
kind::async : kind::sync};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
|
||||
@@ -569,7 +569,7 @@ public:
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
break;
|
||||
ws.async_write_some(false,
|
||||
boost::asio::const_buffer{},
|
||||
net::const_buffer{},
|
||||
[&](error_code, std::size_t)
|
||||
{
|
||||
fail();
|
||||
@@ -597,7 +597,7 @@ public:
|
||||
{
|
||||
echo_server es{log, i==1 ?
|
||||
kind::async : kind::sync};
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc};
|
||||
ws.next_layer().connect(es.stream());
|
||||
|
||||
@@ -624,21 +624,21 @@ public:
|
||||
char buf[32];
|
||||
stream<test::stream> ws{ioc_};
|
||||
stream<test::stream>::write_some_op<
|
||||
boost::asio::const_buffer,
|
||||
net::const_buffer,
|
||||
handler> op{handler{}, ws, true,
|
||||
boost::asio::const_buffer{
|
||||
net::const_buffer{
|
||||
buf, sizeof(buf)}};
|
||||
using boost::asio::asio_handler_is_continuation;
|
||||
using net::asio_handler_is_continuation;
|
||||
asio_handler_is_continuation(&op);
|
||||
}
|
||||
|
||||
void
|
||||
testMoveOnly()
|
||||
{
|
||||
boost::asio::io_context ioc;
|
||||
net::io_context ioc;
|
||||
stream<test::stream> ws{ioc};
|
||||
ws.async_write_some(
|
||||
true, boost::asio::const_buffer{},
|
||||
true, net::const_buffer{},
|
||||
move_only_handler{});
|
||||
}
|
||||
|
||||
@@ -658,14 +658,14 @@ public:
|
||||
// breakpoint in asio_handler_invoke to make sure
|
||||
// it is instantiated.
|
||||
{
|
||||
boost::asio::io_context ioc;
|
||||
boost::asio::strand<
|
||||
boost::asio::io_context::executor_type> s(
|
||||
net::io_context ioc;
|
||||
net::strand<
|
||||
net::io_context::executor_type> s(
|
||||
ioc.get_executor());
|
||||
stream<test::stream> ws{ioc};
|
||||
flat_buffer b;
|
||||
ws.async_write(boost::asio::const_buffer{},
|
||||
boost::asio::bind_executor(s,
|
||||
ws.async_write(net::const_buffer{},
|
||||
net::bind_executor(s,
|
||||
copyable_handler{}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,10 +224,10 @@ public:
|
||||
,[&](){ return do_hints <flat_buffer>(repeat, count, size); }
|
||||
,[&](){ return do_random <flat_buffer>(repeat, count, size); }
|
||||
);
|
||||
do_trials("boost::asio::streambuf", trials,
|
||||
[&](){ return do_prepares<boost::asio::streambuf>(repeat, count, size); }
|
||||
,[&](){ return do_hints <boost::asio::streambuf>(repeat, count, size); }
|
||||
,[&](){ return do_random <boost::asio::streambuf>(repeat, count, size); }
|
||||
do_trials("net::streambuf", trials,
|
||||
[&](){ return do_prepares<net::streambuf>(repeat, count, size); }
|
||||
,[&](){ return do_hints <net::streambuf>(repeat, count, size); }
|
||||
,[&](){ return do_random <net::streambuf>(repeat, count, size); }
|
||||
);
|
||||
log << std::endl;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
basic_parser<isRequest, Derived>& parser,
|
||||
error_code& ec)
|
||||
{
|
||||
using boost::asio::buffer_size;
|
||||
using net::buffer_size;
|
||||
beast::buffers_suffix<
|
||||
ConstBufferSequence> cb{buffers};
|
||||
std::size_t used = 0;
|
||||
@@ -158,7 +158,7 @@ public:
|
||||
isRequest, bench_parser<isRequest, Body, Fields>>
|
||||
{
|
||||
using mutable_buffers_type =
|
||||
boost::asio::mutable_buffer;
|
||||
net::mutable_buffer;
|
||||
|
||||
void
|
||||
on_request_impl(verb, string_view,
|
||||
|
||||
@@ -265,7 +265,7 @@ std::size_t
|
||||
nodejs_basic_parser<Derived>::write(
|
||||
ConstBufferSequence const& buffers, error_code& ec)
|
||||
{
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
static_assert(net::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
std::size_t bytes_used = 0;
|
||||
|
||||
@@ -32,23 +32,22 @@
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
namespace asio = boost::asio;
|
||||
namespace ip = boost::asio::ip;
|
||||
using tcp = boost::asio::ip::tcp;
|
||||
namespace ws = boost::beast::websocket;
|
||||
namespace ph = std::placeholders;
|
||||
using error_code = boost::beast::error_code;
|
||||
namespace beast = boost::beast; // from <boost/beast.hpp>
|
||||
namespace http = beast::http; // from <boost/beast/http.hpp>
|
||||
namespace websocket = beast::websocket; // from <boost/beast/websocket.hpp>
|
||||
namespace net = boost::asio; // from <boost/asio.hpp>
|
||||
using tcp = boost::asio::ip::tcp; // from <boost/asio/ip/tcp.hpp>
|
||||
|
||||
class test_buffer
|
||||
{
|
||||
char data_[4096];
|
||||
boost::asio::const_buffer b_;
|
||||
net::const_buffer b_;
|
||||
|
||||
public:
|
||||
using const_iterator =
|
||||
boost::asio::const_buffer const*;
|
||||
net::const_buffer const*;
|
||||
|
||||
using value_type = boost::asio::const_buffer;
|
||||
using value_type = net::const_buffer;
|
||||
|
||||
test_buffer()
|
||||
: b_(data_, sizeof(data_))
|
||||
@@ -101,7 +100,7 @@ public:
|
||||
};
|
||||
|
||||
void
|
||||
fail(boost::system::error_code ec, char const* what)
|
||||
fail(beast::error_code ec, char const* what)
|
||||
{
|
||||
std::cerr << what << ": " << ec.message() << "\n";
|
||||
}
|
||||
@@ -109,13 +108,13 @@ fail(boost::system::error_code ec, char const* what)
|
||||
class connection
|
||||
: public std::enable_shared_from_this<connection>
|
||||
{
|
||||
ws::stream<tcp::socket> ws_;
|
||||
websocket::stream<tcp::socket> ws_;
|
||||
tcp::endpoint ep_;
|
||||
std::size_t messages_;
|
||||
report& rep_;
|
||||
test_buffer const& tb_;
|
||||
asio::strand<
|
||||
asio::io_context::executor_type> strand_;
|
||||
net::strand<
|
||||
net::io_context::executor_type> strand_;
|
||||
boost::beast::multi_buffer buffer_;
|
||||
std::mt19937_64 rng_;
|
||||
std::size_t count_ = 0;
|
||||
@@ -124,7 +123,7 @@ class connection
|
||||
|
||||
public:
|
||||
connection(
|
||||
asio::io_context& ioc,
|
||||
net::io_context& ioc,
|
||||
tcp::endpoint const& ep,
|
||||
std::size_t messages,
|
||||
bool deflate,
|
||||
@@ -137,7 +136,7 @@ public:
|
||||
, tb_(tb)
|
||||
, strand_(ioc.get_executor())
|
||||
{
|
||||
ws::permessage_deflate pmd;
|
||||
websocket::permessage_deflate pmd;
|
||||
pmd.client_enable = deflate;
|
||||
ws_.set_option(pmd);
|
||||
ws_.binary(true);
|
||||
@@ -157,12 +156,12 @@ public:
|
||||
alloc_.wrap(std::bind(
|
||||
&connection::on_connect,
|
||||
shared_from_this(),
|
||||
ph::_1)));
|
||||
std::placeholders::_1)));
|
||||
}
|
||||
|
||||
private:
|
||||
void
|
||||
on_connect(error_code ec)
|
||||
on_connect(beast::error_code ec)
|
||||
{
|
||||
if(ec)
|
||||
return fail(ec, "on_connect");
|
||||
@@ -173,11 +172,11 @@ private:
|
||||
alloc_.wrap(std::bind(
|
||||
&connection::on_handshake,
|
||||
shared_from_this(),
|
||||
ph::_1)));
|
||||
std::placeholders::_1)));
|
||||
}
|
||||
|
||||
void
|
||||
on_handshake(error_code ec)
|
||||
on_handshake(beast::error_code ec)
|
||||
{
|
||||
if(ec)
|
||||
return fail(ec, "handshake");
|
||||
@@ -189,17 +188,17 @@ private:
|
||||
do_write()
|
||||
{
|
||||
std::geometric_distribution<std::size_t> dist{
|
||||
double(4) / boost::asio::buffer_size(tb_)};
|
||||
double(4) / net::buffer_size(tb_)};
|
||||
ws_.async_write_some(true,
|
||||
boost::beast::buffers_prefix(dist(rng_), tb_),
|
||||
alloc_.wrap(std::bind(
|
||||
&connection::on_write,
|
||||
shared_from_this(),
|
||||
ph::_1)));
|
||||
std::placeholders::_1)));
|
||||
}
|
||||
|
||||
void
|
||||
on_write(error_code ec)
|
||||
on_write(beast::error_code ec)
|
||||
{
|
||||
if(ec)
|
||||
return fail(ec, "write");
|
||||
@@ -211,7 +210,7 @@ private:
|
||||
alloc_.wrap(std::bind(
|
||||
&connection::on_close,
|
||||
shared_from_this(),
|
||||
ph::_1)));
|
||||
std::placeholders::_1)));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -221,11 +220,11 @@ private:
|
||||
alloc_.wrap(std::bind(
|
||||
&connection::on_read,
|
||||
shared_from_this(),
|
||||
ph::_1)));
|
||||
std::placeholders::_1)));
|
||||
}
|
||||
|
||||
void
|
||||
on_read(error_code ec)
|
||||
on_read(beast::error_code ec)
|
||||
{
|
||||
if(ec)
|
||||
return fail(ec, "read");
|
||||
@@ -237,7 +236,7 @@ private:
|
||||
}
|
||||
|
||||
void
|
||||
on_close(error_code ec)
|
||||
on_close(beast::error_code ec)
|
||||
{
|
||||
if(ec)
|
||||
return fail(ec, "close");
|
||||
@@ -293,7 +292,7 @@ main(int argc, char** argv)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
auto const address = boost::asio::ip::make_address(argv[1]);
|
||||
auto const address = net::ip::make_address(argv[1]);
|
||||
auto const port = static_cast<unsigned short>(std::atoi(argv[2]));
|
||||
auto const trials = static_cast<std::size_t>(std::atoi(argv[3]));
|
||||
auto const messages= static_cast<std::size_t>(std::atoi(argv[4]));
|
||||
@@ -305,7 +304,7 @@ main(int argc, char** argv)
|
||||
for(auto i = trials; i != 0; --i)
|
||||
{
|
||||
report rep;
|
||||
boost::asio::io_context ioc{1};
|
||||
net::io_context ioc{1};
|
||||
for(auto j = workers; j; --j)
|
||||
{
|
||||
auto sp =
|
||||
|
||||
@@ -32,18 +32,18 @@ public:
|
||||
buf[2] = 0;
|
||||
buf[3] = 0;
|
||||
BEAST_EXPECT(boost::indeterminate(is_ssl_handshake(
|
||||
boost::asio::buffer(buf, 0))));
|
||||
net::buffer(buf, 0))));
|
||||
BEAST_EXPECT(boost::indeterminate(is_ssl_handshake(
|
||||
boost::asio::buffer(buf, 1))));
|
||||
net::buffer(buf, 1))));
|
||||
BEAST_EXPECT(boost::indeterminate(is_ssl_handshake(
|
||||
boost::asio::buffer(buf, 2))));
|
||||
net::buffer(buf, 2))));
|
||||
BEAST_EXPECT(boost::indeterminate(is_ssl_handshake(
|
||||
boost::asio::buffer(buf, 3))));
|
||||
net::buffer(buf, 3))));
|
||||
BEAST_EXPECT(is_ssl_handshake(
|
||||
boost::asio::buffer(buf, 4)));
|
||||
net::buffer(buf, 4)));
|
||||
buf[0] = 0;
|
||||
BEAST_EXPECT(! is_ssl_handshake(
|
||||
boost::asio::buffer(buf, 1)));
|
||||
net::buffer(buf, 1)));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -26,12 +26,12 @@ void fxx()
|
||||
//
|
||||
using namespace boost::beast;
|
||||
|
||||
boost::asio::io_context ioc;
|
||||
auto work = boost::asio::make_work_guard(ioc);
|
||||
net::io_context ioc;
|
||||
auto work = net::make_work_guard(ioc);
|
||||
std::thread t{[&](){ ioc.run(); }};
|
||||
|
||||
error_code ec;
|
||||
boost::asio::ip::tcp::socket sock{ioc};
|
||||
net::ip::tcp::socket sock{ioc};
|
||||
|
||||
//]
|
||||
boost::ignore_unused(ec);
|
||||
@@ -40,10 +40,10 @@ boost::asio::ip::tcp::socket sock{ioc};
|
||||
//[snippet_core_2
|
||||
|
||||
char const* const host = "www.example.com";
|
||||
boost::asio::ip::tcp::resolver r{ioc};
|
||||
boost::asio::ip::tcp::socket stream{ioc};
|
||||
net::ip::tcp::resolver r{ioc};
|
||||
net::ip::tcp::socket stream{ioc};
|
||||
auto const results = r.resolve(host, "http");
|
||||
boost::asio::connect(stream, results.begin(), results.end());
|
||||
net::connect(stream, results.begin(), results.end());
|
||||
|
||||
// At this point `stream` is a connected to a remote
|
||||
// host and may be used to perform stream operations.
|
||||
@@ -62,7 +62,7 @@ void write_string(SyncWriteStream& stream, string_view s)
|
||||
{
|
||||
static_assert(is_sync_write_stream<SyncWriteStream>::value,
|
||||
"SyncWriteStream requirements not met");
|
||||
boost::asio::write(stream, boost::asio::const_buffer(s.data(), s.size()));
|
||||
net::write(stream, net::const_buffer(s.data(), s.size()));
|
||||
}
|
||||
|
||||
//]
|
||||
|
||||
@@ -53,7 +53,7 @@ struct BodyWriter
|
||||
{
|
||||
public:
|
||||
/// The type of buffer returned by `get`.
|
||||
using const_buffers_type = boost::asio::const_buffer;
|
||||
using const_buffers_type = net::const_buffer;
|
||||
|
||||
/** Construct the writer.
|
||||
|
||||
@@ -164,7 +164,7 @@ struct BodyReader
|
||||
// The specification requires this to indicate "no error"
|
||||
ec = {};
|
||||
|
||||
return boost::asio::buffer_size(buffers);
|
||||
return net::buffer_size(buffers);
|
||||
}
|
||||
|
||||
/** Called when the body is complete.
|
||||
|
||||
@@ -201,7 +201,7 @@ public:
|
||||
};
|
||||
error_code ec;
|
||||
custom_parser<true> p;
|
||||
p.put(boost::asio::buffer(
|
||||
p.put(net::buffer(
|
||||
s.data(), s.size()), ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
}
|
||||
@@ -218,7 +218,7 @@ public:
|
||||
};
|
||||
error_code ec;
|
||||
custom_parser<false> p;
|
||||
p.put(boost::asio::buffer(
|
||||
p.put(net::buffer(
|
||||
s.data(), s.size()), ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
}
|
||||
@@ -309,7 +309,7 @@ public:
|
||||
auto const buf =
|
||||
[](string_view s)
|
||||
{
|
||||
return boost::asio::const_buffer{
|
||||
return net::const_buffer{
|
||||
s.data(), s.size()};
|
||||
};
|
||||
test::stream ts{ioc_}, tr{ioc_};
|
||||
@@ -326,22 +326,22 @@ public:
|
||||
|
||||
chunk_extensions exts;
|
||||
|
||||
boost::asio::write(ts,
|
||||
net::write(ts,
|
||||
make_chunk(buf("First")), ec);
|
||||
|
||||
exts.insert("quality", "1.0");
|
||||
boost::asio::write(ts,
|
||||
net::write(ts,
|
||||
make_chunk(buf("Hello, world!"), exts), ec);
|
||||
|
||||
exts.clear();
|
||||
exts.insert("file", "abc.txt");
|
||||
exts.insert("quality", "0.7");
|
||||
boost::asio::write(ts,
|
||||
net::write(ts,
|
||||
make_chunk(buf("The Next Chunk"), std::move(exts)), ec);
|
||||
|
||||
exts.clear();
|
||||
exts.insert("last");
|
||||
boost::asio::write(ts,
|
||||
net::write(ts,
|
||||
make_chunk(buf("Last one"), std::move(exts),
|
||||
std::allocator<double>{}), ec);
|
||||
|
||||
@@ -349,7 +349,7 @@ public:
|
||||
trailers.set(field::expires, "never");
|
||||
trailers.set(field::content_md5, "f4a5c16584f03d90");
|
||||
|
||||
boost::asio::write(ts,
|
||||
net::write(ts,
|
||||
make_chunk_last(
|
||||
trailers,
|
||||
std::allocator<double>{}
|
||||
|
||||
+30
-30
@@ -26,20 +26,20 @@ namespace doc_http_snippets {
|
||||
|
||||
//[http_snippet_17
|
||||
// This function returns the buffer containing the next chunk body
|
||||
boost::asio::const_buffer get_next_chunk_body();
|
||||
net::const_buffer get_next_chunk_body();
|
||||
//]
|
||||
|
||||
boost::asio::const_buffer get_next_chunk_body()
|
||||
net::const_buffer get_next_chunk_body()
|
||||
{
|
||||
return {nullptr, 0};
|
||||
}
|
||||
|
||||
void fxx() {
|
||||
|
||||
boost::asio::io_context ioc;
|
||||
auto work = boost::asio::make_work_guard(ioc);
|
||||
net::io_context ioc;
|
||||
auto work = net::make_work_guard(ioc);
|
||||
std::thread t{[&](){ ioc.run(); }};
|
||||
boost::asio::ip::tcp::socket sock{ioc};
|
||||
net::ip::tcp::socket sock{ioc};
|
||||
|
||||
{
|
||||
//[http_snippet_2
|
||||
@@ -160,12 +160,12 @@ void fxx() {
|
||||
write_header(sock, sr);
|
||||
|
||||
// Now manually emit three chunks:
|
||||
boost::asio::write(sock, make_chunk(get_next_chunk_body()));
|
||||
boost::asio::write(sock, make_chunk(get_next_chunk_body()));
|
||||
boost::asio::write(sock, make_chunk(get_next_chunk_body()));
|
||||
net::write(sock, make_chunk(get_next_chunk_body()));
|
||||
net::write(sock, make_chunk(get_next_chunk_body()));
|
||||
net::write(sock, make_chunk(get_next_chunk_body()));
|
||||
|
||||
// We are responsible for sending the last chunk:
|
||||
boost::asio::write(sock, make_chunk_last());
|
||||
net::write(sock, make_chunk_last());
|
||||
//]
|
||||
}
|
||||
|
||||
@@ -180,18 +180,18 @@ void fxx() {
|
||||
// Write the next chunk with the chunk extensions
|
||||
// The implementation will make a copy of the extensions object,
|
||||
// so the caller does not need to manage lifetime issues.
|
||||
boost::asio::write(sock, make_chunk(get_next_chunk_body(), ext));
|
||||
net::write(sock, make_chunk(get_next_chunk_body(), ext));
|
||||
|
||||
// Write the next chunk with the chunk extensions
|
||||
// The implementation will make a copy of the extensions object, storing the copy
|
||||
// using the custom allocator, so the caller does not need to manage lifetime issues.
|
||||
boost::asio::write(sock, make_chunk(get_next_chunk_body(), ext, std::allocator<char>{}));
|
||||
net::write(sock, make_chunk(get_next_chunk_body(), ext, std::allocator<char>{}));
|
||||
|
||||
// Write the next chunk with the chunk extensions
|
||||
// The implementation allocates memory using the default allocator and takes ownership
|
||||
// of the extensions object, so the caller does not need to manage lifetime issues.
|
||||
// Note: ext is moved
|
||||
boost::asio::write(sock, make_chunk(get_next_chunk_body(), std::move(ext)));
|
||||
net::write(sock, make_chunk(get_next_chunk_body(), std::move(ext)));
|
||||
//]
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ void fxx() {
|
||||
//[http_snippet_20
|
||||
// Manually specify the chunk extensions.
|
||||
// Some of the strings contain spaces and a period and must be quoted
|
||||
boost::asio::write(sock, make_chunk(get_next_chunk_body(),
|
||||
net::write(sock, make_chunk(get_next_chunk_body(),
|
||||
";mp3"
|
||||
";title=\"Danny Boy\""
|
||||
";artist=\"Fred E. Weatherly\""
|
||||
@@ -221,8 +221,8 @@ void fxx() {
|
||||
// Serialize the header and two chunks
|
||||
response_serializer<empty_body> sr{res};
|
||||
write_header(sock, sr);
|
||||
boost::asio::write(sock, make_chunk(get_next_chunk_body()));
|
||||
boost::asio::write(sock, make_chunk(get_next_chunk_body()));
|
||||
net::write(sock, make_chunk(get_next_chunk_body()));
|
||||
net::write(sock, make_chunk(get_next_chunk_body()));
|
||||
|
||||
// Prepare the trailer
|
||||
fields trailer;
|
||||
@@ -232,7 +232,7 @@ void fxx() {
|
||||
// Emit the trailer in the last chunk.
|
||||
// The implementation will use the default allocator to create the storage for holding
|
||||
// the serialized fields.
|
||||
boost::asio::write(sock, make_chunk_last(trailer));
|
||||
net::write(sock, make_chunk_last(trailer));
|
||||
//]
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ void fxx() {
|
||||
// Use a custom allocator for serializing the last chunk
|
||||
fields trailer;
|
||||
trailer.set(field::approved, "yes");
|
||||
boost::asio::write(sock, make_chunk_last(trailer, std::allocator<char>{}));
|
||||
net::write(sock, make_chunk_last(trailer, std::allocator<char>{}));
|
||||
//]
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ void fxx() {
|
||||
"Content-MD5: f4a5c16584f03d90\r\n"
|
||||
"Expires: never\r\n"
|
||||
"\r\n";
|
||||
boost::asio::write(sock, make_chunk_last(boost::asio::const_buffer{ext.data(), ext.size()}));
|
||||
net::write(sock, make_chunk_last(net::const_buffer{ext.data(), ext.size()}));
|
||||
//]
|
||||
}
|
||||
|
||||
@@ -272,18 +272,18 @@ void fxx() {
|
||||
auto const cb3 = get_next_chunk_body();
|
||||
|
||||
// Manually emit a chunk by first writing the chunk-size header with the correct size
|
||||
boost::asio::write(sock, chunk_header{
|
||||
boost::asio::buffer_size(cb1) +
|
||||
boost::asio::buffer_size(cb2) +
|
||||
boost::asio::buffer_size(cb3)});
|
||||
net::write(sock, chunk_header{
|
||||
net::buffer_size(cb1) +
|
||||
net::buffer_size(cb2) +
|
||||
net::buffer_size(cb3)});
|
||||
|
||||
// And then output the chunk body in three pieces ("chunk the chunk")
|
||||
boost::asio::write(sock, cb1);
|
||||
boost::asio::write(sock, cb2);
|
||||
boost::asio::write(sock, cb3);
|
||||
net::write(sock, cb1);
|
||||
net::write(sock, cb2);
|
||||
net::write(sock, cb3);
|
||||
|
||||
// When we go this deep, we are also responsible for the terminating CRLF
|
||||
boost::asio::write(sock, chunk_crlf{});
|
||||
net::write(sock, chunk_crlf{});
|
||||
//]
|
||||
}
|
||||
|
||||
@@ -367,7 +367,7 @@ print_cxx14(message<isRequest, Body, Fields> const& m)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
std::cout << buffers(buffer);
|
||||
sr.consume(boost::asio::buffer_size(buffer));
|
||||
sr.consume(net::buffer_size(buffer));
|
||||
});
|
||||
}
|
||||
while(! ec && ! sr.is_done());
|
||||
@@ -394,7 +394,7 @@ struct lambda
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
std::cout << buffers(buffer);
|
||||
sr.consume(boost::asio::buffer_size(buffer));
|
||||
sr.consume(net::buffer_size(buffer));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -435,7 +435,7 @@ split_print_cxx14(message<isRequest, Body, Fields> const& m)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
std::cout << buffers(buffer);
|
||||
sr.consume(boost::asio::buffer_size(buffer));
|
||||
sr.consume(net::buffer_size(buffer));
|
||||
});
|
||||
}
|
||||
while(! sr.is_header_done());
|
||||
@@ -449,7 +449,7 @@ split_print_cxx14(message<isRequest, Body, Fields> const& m)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
std::cout << buffers(buffer);
|
||||
sr.consume(boost::asio::buffer_size(buffer));
|
||||
sr.consume(net::buffer_size(buffer));
|
||||
});
|
||||
}
|
||||
while(! ec && ! sr.is_done());
|
||||
|
||||
@@ -27,55 +27,55 @@ namespace doc_ws_snippets {
|
||||
|
||||
void fxx() {
|
||||
|
||||
boost::asio::io_context ioc;
|
||||
auto work = boost::asio::make_work_guard(ioc);
|
||||
net::io_context ioc;
|
||||
auto work = net::make_work_guard(ioc);
|
||||
std::thread t{[&](){ ioc.run(); }};
|
||||
error_code ec;
|
||||
boost::asio::ip::tcp::socket sock{ioc};
|
||||
net::ip::tcp::socket sock{ioc};
|
||||
boost::ignore_unused(ec);
|
||||
|
||||
{
|
||||
//[ws_snippet_2
|
||||
stream<boost::asio::ip::tcp::socket> ws{ioc};
|
||||
stream<net::ip::tcp::socket> ws{ioc};
|
||||
//]
|
||||
}
|
||||
|
||||
{
|
||||
//[ws_snippet_3
|
||||
stream<boost::asio::ip::tcp::socket> ws{std::move(sock)};
|
||||
stream<net::ip::tcp::socket> ws{std::move(sock)};
|
||||
//]
|
||||
}
|
||||
|
||||
{
|
||||
//[ws_snippet_4
|
||||
stream<boost::asio::ip::tcp::socket&> ws{sock};
|
||||
stream<net::ip::tcp::socket&> ws{sock};
|
||||
//]
|
||||
|
||||
//[ws_snippet_5
|
||||
ws.next_layer().shutdown(boost::asio::ip::tcp::socket::shutdown_send);
|
||||
ws.next_layer().shutdown(net::ip::tcp::socket::shutdown_send);
|
||||
//]
|
||||
}
|
||||
|
||||
{
|
||||
//[ws_snippet_6
|
||||
std::string const host = "example.com";
|
||||
boost::asio::ip::tcp::resolver r{ioc};
|
||||
stream<boost::asio::ip::tcp::socket> ws{ioc};
|
||||
net::ip::tcp::resolver r{ioc};
|
||||
stream<net::ip::tcp::socket> ws{ioc};
|
||||
auto const results = r.resolve(host, "ws");
|
||||
boost::asio::connect(ws.next_layer(), results.begin(), results.end());
|
||||
net::connect(ws.next_layer(), results.begin(), results.end());
|
||||
//]
|
||||
}
|
||||
|
||||
{
|
||||
//[ws_snippet_7
|
||||
boost::asio::ip::tcp::acceptor acceptor{ioc};
|
||||
stream<boost::asio::ip::tcp::socket> ws{acceptor.get_executor().context()};
|
||||
net::ip::tcp::acceptor acceptor{ioc};
|
||||
stream<net::ip::tcp::socket> ws{acceptor.get_executor().context()};
|
||||
acceptor.accept(ws.next_layer());
|
||||
//]
|
||||
}
|
||||
|
||||
{
|
||||
stream<boost::asio::ip::tcp::socket> ws{ioc};
|
||||
stream<net::ip::tcp::socket> ws{ioc};
|
||||
//[ws_snippet_8
|
||||
ws.handshake("localhost", "/");
|
||||
//]
|
||||
@@ -121,7 +121,7 @@ boost::ignore_unused(ec);
|
||||
if(websocket::is_upgrade(req))
|
||||
{
|
||||
// Construct the stream, transferring ownership of the socket
|
||||
stream<boost::asio::ip::tcp::socket> ws{std::move(sock)};
|
||||
stream<net::ip::tcp::socket> ws{std::move(sock)};
|
||||
|
||||
// Clients SHOULD NOT begin sending WebSocket
|
||||
// frames until the server has provided a response.
|
||||
@@ -139,19 +139,19 @@ boost::ignore_unused(ec);
|
||||
}
|
||||
|
||||
{
|
||||
stream<boost::asio::ip::tcp::socket> ws{ioc};
|
||||
stream<net::ip::tcp::socket> ws{ioc};
|
||||
//[ws_snippet_14
|
||||
// Read into our buffer until we reach the end of the HTTP request.
|
||||
// No parsing takes place here, we are just accumulating data.
|
||||
boost::asio::streambuf buffer;
|
||||
boost::asio::read_until(sock, buffer, "\r\n\r\n");
|
||||
net::streambuf buffer;
|
||||
net::read_until(sock, buffer, "\r\n\r\n");
|
||||
|
||||
// Now accept the connection, using the buffered data.
|
||||
ws.accept(buffer.data());
|
||||
//]
|
||||
}
|
||||
{
|
||||
stream<boost::asio::ip::tcp::socket> ws{ioc};
|
||||
stream<net::ip::tcp::socket> ws{ioc};
|
||||
//[ws_snippet_15
|
||||
// This DynamicBuffer will hold the received message
|
||||
multi_buffer buffer;
|
||||
@@ -176,7 +176,7 @@ boost::ignore_unused(ec);
|
||||
}
|
||||
|
||||
{
|
||||
stream<boost::asio::ip::tcp::socket> ws{ioc};
|
||||
stream<net::ip::tcp::socket> ws{ioc};
|
||||
//[ws_snippet_16
|
||||
// This DynamicBuffer will hold the received message
|
||||
multi_buffer buffer;
|
||||
@@ -202,7 +202,7 @@ boost::ignore_unused(ec);
|
||||
// This will cause the message to be broken up into multiple frames.
|
||||
for(;;)
|
||||
{
|
||||
using boost::asio::buffer_size;
|
||||
using net::buffer_size;
|
||||
if(buffer_size(cb) > 512)
|
||||
{
|
||||
// There are more than 512 bytes left to send, just
|
||||
@@ -232,7 +232,7 @@ boost::ignore_unused(ec);
|
||||
}
|
||||
|
||||
{
|
||||
stream<boost::asio::ip::tcp::socket> ws{ioc};
|
||||
stream<net::ip::tcp::socket> ws{ioc};
|
||||
//[ws_snippet_17
|
||||
ws.control_callback(
|
||||
[](frame_type kind, string_view payload)
|
||||
@@ -285,12 +285,12 @@ boost::ignore_unused(ec);
|
||||
// workaround for https://github.com/chriskohlhoff/asio/issues/112
|
||||
#ifdef BOOST_MSVC
|
||||
//[ws_snippet_21
|
||||
void echo(stream<boost::asio::ip::tcp::socket>& ws,
|
||||
multi_buffer& buffer, boost::asio::yield_context yield)
|
||||
void echo(stream<net::ip::tcp::socket>& ws,
|
||||
multi_buffer& buffer, net::yield_context yield)
|
||||
{
|
||||
ws.async_read(buffer, yield);
|
||||
std::future<std::size_t> fut =
|
||||
ws.async_write(buffer.data(), boost::asio::use_future);
|
||||
ws.async_write(buffer.data(), net::use_future);
|
||||
}
|
||||
//]
|
||||
#endif
|
||||
@@ -379,30 +379,30 @@ namespace doc_wss_snippets {
|
||||
|
||||
void fxx() {
|
||||
|
||||
boost::asio::io_context ioc;
|
||||
auto work = boost::asio::make_work_guard(ioc);
|
||||
net::io_context ioc;
|
||||
auto work = net::make_work_guard(ioc);
|
||||
std::thread t{[&](){ ioc.run(); }};
|
||||
error_code ec;
|
||||
boost::asio::ip::tcp::socket sock{ioc};
|
||||
net::ip::tcp::socket sock{ioc};
|
||||
|
||||
{
|
||||
//[wss_snippet_2
|
||||
boost::asio::ssl::context ctx{boost::asio::ssl::context::sslv23};
|
||||
stream<boost::asio::ssl::stream<boost::asio::ip::tcp::socket>> wss{ioc, ctx};
|
||||
net::ssl::context ctx{net::ssl::context::sslv23};
|
||||
stream<net::ssl::stream<net::ip::tcp::socket>> wss{ioc, ctx};
|
||||
//]
|
||||
}
|
||||
|
||||
{
|
||||
//[wss_snippet_3
|
||||
boost::asio::ip::tcp::endpoint ep;
|
||||
boost::asio::ssl::context ctx{boost::asio::ssl::context::sslv23};
|
||||
stream<boost::asio::ssl::stream<boost::asio::ip::tcp::socket>> ws{ioc, ctx};
|
||||
net::ip::tcp::endpoint ep;
|
||||
net::ssl::context ctx{net::ssl::context::sslv23};
|
||||
stream<net::ssl::stream<net::ip::tcp::socket>> ws{ioc, ctx};
|
||||
|
||||
// connect the underlying TCP/IP socket
|
||||
ws.next_layer().next_layer().connect(ep);
|
||||
|
||||
// perform SSL handshake
|
||||
ws.next_layer().handshake(boost::asio::ssl::stream_base::client);
|
||||
ws.next_layer().handshake(net::ssl::stream_base::client);
|
||||
|
||||
// perform WebSocket handshake
|
||||
ws.handshake("localhost", "/");
|
||||
|
||||
@@ -21,8 +21,8 @@ inline
|
||||
void
|
||||
sig_wait()
|
||||
{
|
||||
boost::asio::io_context ioc;
|
||||
boost::asio::signal_set signals(
|
||||
net::io_context ioc;
|
||||
net::signal_set signals(
|
||||
ioc, SIGINT, SIGTERM);
|
||||
signals.async_wait(
|
||||
[&](boost::system::error_code const&, int)
|
||||
|
||||
@@ -28,9 +28,9 @@ namespace test {
|
||||
class ws_echo_server
|
||||
{
|
||||
std::ostream& log_;
|
||||
boost::asio::io_context ioc_;
|
||||
boost::asio::executor_work_guard<
|
||||
boost::asio::io_context::executor_type> work_;
|
||||
net::io_context ioc_;
|
||||
net::executor_work_guard<
|
||||
net::io_context::executor_type> work_;
|
||||
multi_buffer buffer_;
|
||||
test::stream ts_;
|
||||
std::thread t_;
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
void
|
||||
async_close()
|
||||
{
|
||||
boost::asio::post(ioc_,
|
||||
net::post(ioc_,
|
||||
[&]
|
||||
{
|
||||
if(ws_.is_open())
|
||||
@@ -141,7 +141,7 @@ private:
|
||||
#if 0
|
||||
if( se.code() != error::closed &&
|
||||
se.code() != error::failed &&
|
||||
se.code() != boost::asio::error::eof)
|
||||
se.code() != net::error::eof)
|
||||
log_ << "ws_echo_server: " << se.code().message() << std::endl;
|
||||
#endif
|
||||
}
|
||||
@@ -233,7 +233,7 @@ private:
|
||||
#if 0
|
||||
if( ec != error::closed &&
|
||||
ec != error::failed &&
|
||||
ec != boost::asio::error::eof)
|
||||
ec != net::error::eof)
|
||||
log_ <<
|
||||
"echo_server_async: " <<
|
||||
ec.message() <<
|
||||
|
||||
@@ -32,11 +32,11 @@ namespace test {
|
||||
class enable_yield_to
|
||||
{
|
||||
protected:
|
||||
boost::asio::io_context ioc_;
|
||||
net::io_context ioc_;
|
||||
|
||||
private:
|
||||
boost::asio::executor_work_guard<
|
||||
boost::asio::io_context::executor_type> work_;
|
||||
net::executor_work_guard<
|
||||
net::io_context::executor_type> work_;
|
||||
std::vector<std::thread> threads_;
|
||||
std::mutex m_;
|
||||
std::condition_variable cv_;
|
||||
@@ -45,7 +45,7 @@ private:
|
||||
public:
|
||||
/// The type of yield context passed to functions.
|
||||
using yield_context =
|
||||
boost::asio::yield_context;
|
||||
net::yield_context;
|
||||
|
||||
explicit
|
||||
enable_yield_to(std::size_t concurrency = 1)
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
}
|
||||
|
||||
/// Return the `io_context` associated with the object
|
||||
boost::asio::io_context&
|
||||
net::io_context&
|
||||
get_io_service()
|
||||
{
|
||||
return ioc_;
|
||||
@@ -120,7 +120,7 @@ void
|
||||
enable_yield_to::
|
||||
spawn(F0&& f, FN&&... fn)
|
||||
{
|
||||
boost::asio::spawn(ioc_,
|
||||
net::spawn(ioc_,
|
||||
[&](yield_context yield)
|
||||
{
|
||||
f(yield);
|
||||
|
||||
Reference in new issue
Block a user