forked from boostorg/beast
Fixes to support Asio changes (API Change):
This adjusts Beast's interfaces and implementation to match the changes in Boost.Asio.
This commit is contained in:
1 parent
ac24e58fb3
commit
6baa607295
58 files changed
+762
-723
No files matched your search
@@ -24,6 +24,7 @@ add_executable (tests-beast-core
|
||||
_detail_bind_continuation.cpp
|
||||
_detail_buffer.cpp
|
||||
_detail_clamp.cpp
|
||||
_detail_get_io_context.cpp
|
||||
_detail_is_invocable.cpp
|
||||
_detail_read.cpp
|
||||
_detail_sha1.cpp
|
||||
|
||||
@@ -12,6 +12,7 @@ local SOURCES =
|
||||
_detail_bind_continuation.cpp
|
||||
_detail_buffer.cpp
|
||||
_detail_clamp.cpp
|
||||
_detail_get_io_context.cpp
|
||||
_detail_is_invocable.cpp
|
||||
_detail_read.cpp
|
||||
_detail_sha1.cpp
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Official repository: https://github.com/boostorg/beast
|
||||
//
|
||||
|
||||
#include <boost/beast/core/detail/config.hpp>
|
||||
#include <boost/beast/core/make_strand.hpp>
|
||||
#include <boost/beast/core/detail/get_io_context.hpp>
|
||||
#include <boost/beast/_experimental/unit_test/suite.hpp>
|
||||
#include <boost/asio/strand.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace detail {
|
||||
|
||||
class get_io_context_test : public beast::unit_test::suite
|
||||
{
|
||||
public:
|
||||
void
|
||||
testFunction()
|
||||
{
|
||||
struct none
|
||||
{
|
||||
};
|
||||
|
||||
net::io_context ioc;
|
||||
BEAST_EXPECT(get_io_context(5) == nullptr);
|
||||
BEAST_EXPECT(get_io_context(none{}) == nullptr);
|
||||
BEAST_EXPECT(get_io_context(ioc) == &ioc);
|
||||
BEAST_EXPECT(get_io_context(ioc.get_executor()) == &ioc);
|
||||
BEAST_EXPECT(get_io_context(make_strand(ioc)) == &ioc);
|
||||
BEAST_EXPECT(get_io_context(net::executor(ioc.get_executor())) == &ioc);
|
||||
#if 0
|
||||
// VFALCO FIXME
|
||||
BEAST_EXPECT(
|
||||
get_io_context(
|
||||
net::strand<net::executor>(
|
||||
net::executor(ioc.get_executor()))) == &ioc);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
run() override
|
||||
{
|
||||
testFunction();
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(beast,core,get_io_context);
|
||||
|
||||
} // detail
|
||||
} // beast
|
||||
} // boost
|
||||
@@ -303,7 +303,6 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // (anon)
|
||||
|
||||
class basic_stream_test
|
||||
@@ -319,9 +318,6 @@ public:
|
||||
void
|
||||
testSpecialMembers()
|
||||
{
|
||||
using stream_type = tcp_stream<
|
||||
net::io_context::executor_type>;
|
||||
|
||||
net::io_context ioc;
|
||||
|
||||
// net::io_context::executor_type
|
||||
@@ -332,7 +328,8 @@ public:
|
||||
basic_stream<tcp, executor> s2(ex);
|
||||
basic_stream<tcp, executor> s3(ioc, tcp::v4());
|
||||
basic_stream<tcp, executor> s4(std::move(s1));
|
||||
s2.socket() = tcp::socket(ioc);
|
||||
s2.socket() =
|
||||
net::basic_stream_socket<tcp, executor>(ioc);
|
||||
BEAST_EXPECT(s1.get_executor() == ex);
|
||||
BEAST_EXPECT(s2.get_executor() == ex);
|
||||
BEAST_EXPECT(s3.get_executor() == ex);
|
||||
@@ -358,14 +355,19 @@ public:
|
||||
basic_stream<tcp, strand> s1(ex);
|
||||
basic_stream<tcp, strand> s2(ex, tcp::v4());
|
||||
basic_stream<tcp, strand> s3(std::move(s1));
|
||||
s2.socket() = tcp::socket(ioc);
|
||||
#if 0
|
||||
s2.socket() = net::basic_stream_socket<
|
||||
tcp, strand>(ioc);
|
||||
#endif
|
||||
BEAST_EXPECT(s1.get_executor() == ex);
|
||||
BEAST_EXPECT(s2.get_executor() == ex);
|
||||
BEAST_EXPECT(s3.get_executor() == ex);
|
||||
|
||||
#if 0
|
||||
BEAST_EXPECT((! static_cast<
|
||||
basic_stream<tcp, strand> const&>(
|
||||
s2).socket().is_open()));
|
||||
#endif
|
||||
|
||||
test_sync_stream<
|
||||
basic_stream<
|
||||
@@ -378,6 +380,7 @@ public:
|
||||
|
||||
// construction from existing socket
|
||||
|
||||
#if 0
|
||||
{
|
||||
tcp::socket sock(ioc);
|
||||
basic_stream<tcp, executor> stream(std::move(sock));
|
||||
@@ -387,22 +390,13 @@ public:
|
||||
tcp::socket sock(ioc);
|
||||
basic_stream<tcp, strand> stream(std::move(sock));
|
||||
}
|
||||
|
||||
struct other_type
|
||||
{
|
||||
};
|
||||
|
||||
BOOST_STATIC_ASSERT(! std::is_constructible<
|
||||
stream_type, other_type>::value);
|
||||
|
||||
BOOST_STATIC_ASSERT(! std::is_constructible<
|
||||
stream_type, other_type, tcp::socket>::value);
|
||||
#endif
|
||||
|
||||
// layers
|
||||
|
||||
{
|
||||
net::socket_base::keep_alive opt;
|
||||
stream_type s(ioc);
|
||||
tcp_stream s(ioc);
|
||||
s.socket().open(tcp::v4());
|
||||
s.socket().get_option(opt);
|
||||
BEAST_EXPECT(! opt.value());
|
||||
@@ -450,7 +444,7 @@ public:
|
||||
void
|
||||
testRead()
|
||||
{
|
||||
using stream_type = tcp_stream<
|
||||
using stream_type = basic_stream<tcp,
|
||||
net::io_context::executor_type>;
|
||||
|
||||
char buf[4];
|
||||
@@ -585,7 +579,7 @@ public:
|
||||
void
|
||||
testWrite()
|
||||
{
|
||||
using stream_type = tcp_stream<
|
||||
using stream_type = basic_stream<tcp,
|
||||
net::io_context::executor_type>;
|
||||
|
||||
char buf[4];
|
||||
@@ -667,7 +661,7 @@ public:
|
||||
void
|
||||
testConnect()
|
||||
{
|
||||
using stream_type = tcp_stream<
|
||||
using stream_type = basic_stream<tcp,
|
||||
net::io_context::executor_type>;
|
||||
|
||||
struct range
|
||||
@@ -1057,7 +1051,7 @@ public:
|
||||
void
|
||||
testMembers()
|
||||
{
|
||||
using stream_type = tcp_stream<
|
||||
using stream_type = basic_stream<tcp,
|
||||
net::io_context::executor_type>;
|
||||
|
||||
class handler
|
||||
@@ -1184,7 +1178,7 @@ public:
|
||||
return {};
|
||||
}
|
||||
|
||||
void process_http_1 (tcp_stream<net::io_context::executor_type>& stream, net::yield_context yield)
|
||||
void process_http_1 (tcp_stream& stream, net::yield_context yield)
|
||||
{
|
||||
flat_buffer buffer;
|
||||
http::request<http::empty_body> req;
|
||||
@@ -1201,7 +1195,7 @@ public:
|
||||
http::async_write (stream, res, yield);
|
||||
}
|
||||
|
||||
void process_http_2 (tcp_stream<net::io_context::executor_type>& stream, net::yield_context yield)
|
||||
void process_http_2 (tcp_stream& stream, net::yield_context yield)
|
||||
{
|
||||
flat_buffer buffer;
|
||||
http::request<http::empty_body> req;
|
||||
|
||||
@@ -9,3 +9,37 @@
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include <boost/beast/core/tcp_stream.hpp>
|
||||
|
||||
#include <boost/beast/_experimental/unit_test/suite.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
class tcp_stream_test
|
||||
: public beast::unit_test::suite
|
||||
{
|
||||
public:
|
||||
using tcp = net::ip::tcp;
|
||||
|
||||
void
|
||||
testStream()
|
||||
{
|
||||
net::io_context ioc;
|
||||
{
|
||||
tcp::socket s(ioc);
|
||||
tcp_stream s1(std::move(s));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
run()
|
||||
{
|
||||
testStream();
|
||||
pass();
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(beast,core,tcp_stream);
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
@@ -10,6 +10,7 @@
|
||||
// Test that header file is self-contained.
|
||||
#include <boost/beast/websocket/stream.hpp>
|
||||
|
||||
#include <boost/beast/core/make_strand.hpp>
|
||||
#include <boost/beast/core/tcp_stream.hpp>
|
||||
#include <boost/asio/strand.hpp>
|
||||
|
||||
@@ -157,11 +158,10 @@ public:
|
||||
{
|
||||
net::io_context ioc;
|
||||
{
|
||||
websocket::stream<tcp_stream<
|
||||
net::io_context::strand>> ws{net::io_context::strand(ioc)};
|
||||
websocket::stream<tcp_stream> ws{make_strand(ioc)};
|
||||
}
|
||||
{
|
||||
websocket::stream<tcp_stream<net::io_context::executor_type>> ws(ioc);
|
||||
websocket::stream<tcp_stream> ws(ioc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ public:
|
||||
run() override
|
||||
{
|
||||
testJavadoc();
|
||||
pass();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -59,8 +59,8 @@ boost::ignore_unused(ec);
|
||||
{
|
||||
//[ws_snippet_6
|
||||
std::string const host = "example.com";
|
||||
net::ip::tcp::resolver r{ioc};
|
||||
stream<tcp_stream<net::io_context::executor_type>> ws{ioc};
|
||||
net::ip::tcp::resolver r(ioc);
|
||||
stream<tcp_stream> ws(ioc);
|
||||
auto const results = r.resolve(host, "ws");
|
||||
connect(get_lowest_layer(ws), results.begin(), results.end());
|
||||
//]
|
||||
@@ -69,7 +69,7 @@ boost::ignore_unused(ec);
|
||||
{
|
||||
//[ws_snippet_7
|
||||
net::ip::tcp::acceptor acceptor{ioc};
|
||||
stream<tcp_stream<net::io_context::executor_type>> ws{acceptor.get_executor().context()};
|
||||
stream<tcp_stream> ws{acceptor.get_executor()};
|
||||
acceptor.accept(get_lowest_layer(ws).socket());
|
||||
//]
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user