Boost prep

This commit is contained in:
Vinnie Falco
2017-07-23 17:34:13 -07:00
parent 3777cb8b9c
commit 7139dd639a
375 changed files with 5253 additions and 3884 deletions
+11 -9
View File
@@ -4,9 +4,11 @@
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/beast
//
#ifndef BEAST_EXAMPLE_COMMON_DETECT_SSL_HPP
#define BEAST_EXAMPLE_COMMON_DETECT_SSL_HPP
#ifndef BOOST_BEAST_EXAMPLE_COMMON_DETECT_SSL_HPP
#define BOOST_BEAST_EXAMPLE_COMMON_DETECT_SSL_HPP
#include <boost/assert.hpp>
#include <boost/config.hpp>
@@ -19,7 +21,7 @@
//[example_core_detect_ssl_1
#include <beast.hpp>
#include <boost/beast.hpp>
#include <boost/logic/tribool.hpp>
/** Return `true` if a buffer contains a TLS/SSL client handshake.
@@ -50,7 +52,7 @@ is_ssl_handshake(ConstBufferSequence const& buffers);
//]
using namespace beast;
using namespace boost::beast;
//[example_core_detect_ssl_2
@@ -263,8 +265,8 @@ async_detect_ssl(
// uses the result and handler specializations associated with
// the completion token to help customize the return value.
//
beast::async_completion<
CompletionToken, void(beast::error_code, boost::tribool)> init{token};
boost::beast::async_completion<
CompletionToken, void(boost::beast::error_code, boost::tribool)> init{token};
// Create the composed operation and launch it. This is a constructor
// call followed by invocation of operator(). We use handler_type
@@ -275,7 +277,7 @@ async_detect_ssl(
detect_ssl_op<AsyncReadStream, DynamicBuffer, handler_type<
CompletionToken, void(error_code, boost::tribool)>>{
stream, buffer, init.completion_handler}(
beast::error_code{}, 0);
boost::beast::error_code{}, 0);
// This hook lets the caller see a return value when appropriate.
// For example this might return std::future<error_code, boost::tribool> if
@@ -381,7 +383,7 @@ public:
// Our main entry point. This will get called as our
// intermediate operations complete. Definition below.
//
void operator()(beast::error_code ec, std::size_t bytes_transferred);
void operator()(boost::beast::error_code ec, std::size_t bytes_transferred);
};
//]
@@ -398,7 +400,7 @@ template<
class Handler>
void
detect_ssl_op<AsyncStream, DynamicBuffer, Handler>::
operator()(beast::error_code ec, std::size_t bytes_transferred)
operator()(boost::beast::error_code ec, std::size_t bytes_transferred)
{
// Execute the state machine
switch(step_)
+4 -2
View File
@@ -4,9 +4,11 @@
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/beast
//
#ifndef BEAST_EXAMPLE_COMMON_HELPERS_HPP
#define BEAST_EXAMPLE_COMMON_HELPERS_HPP
#ifndef BOOST_BEAST_EXAMPLE_COMMON_HELPERS_HPP
#define BOOST_BEAST_EXAMPLE_COMMON_HELPERS_HPP
#include <boost/asio/io_service.hpp>
#include <boost/asio/signal_set.hpp>
+7 -5
View File
@@ -4,20 +4,22 @@
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/beast
//
#ifndef BEAST_EXAMPLE_COMMON_MIME_TYPES_HPP
#define BEAST_EXAMPLE_COMMON_MIME_TYPES_HPP
#ifndef BOOST_BEAST_EXAMPLE_COMMON_MIME_TYPES_HPP
#define BOOST_BEAST_EXAMPLE_COMMON_MIME_TYPES_HPP
#include <beast/core/string.hpp>
#include <boost/beast/core/string.hpp>
#include <boost/filesystem/path.hpp>
// Return a reasonable mime type based on the extension of a file.
//
template<class = void>
beast::string_view
boost::beast::string_view
mime_type(boost::filesystem::path const& path)
{
using beast::iequals;
using boost::beast::iequals;
auto const ext = path.extension().string();
if(iequals(ext, ".txt")) return "text/plain";
if(iequals(ext, ".htm")) return "text/html";
+10 -8
View File
@@ -4,12 +4,14 @@
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/beast
//
#ifndef BEAST_EXAMPLE_COMMON_RFC7231_HPP
#define BEAST_EXAMPLE_COMMON_RFC7231_HPP
#ifndef BOOST_BEAST_EXAMPLE_COMMON_RFC7231_HPP
#define BOOST_BEAST_EXAMPLE_COMMON_RFC7231_HPP
#include <beast/core/string.hpp>
#include <beast/http/message.hpp>
#include <boost/beast/core/string.hpp>
#include <boost/beast/http/message.hpp>
namespace rfc7231 {
@@ -27,11 +29,11 @@ namespace rfc7231 {
*/
template<class Body, class Allocator>
bool
is_expect_100_continue(beast::http::request<
Body, beast::http::basic_fields<Allocator>> const& req)
is_expect_100_continue(boost::beast::http::request<
Body, boost::beast::http::basic_fields<Allocator>> const& req)
{
return beast::iequals(
req[beast::http::field::expect], "100-continue");
return boost::beast::iequals(
req[boost::beast::http::field::expect], "100-continue");
}
} // rfc7231
+4 -2
View File
@@ -4,9 +4,11 @@
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/beast
//
#ifndef BEAST_EXAMPLE_COMMON_ROOT_CERTIFICATES_HPP
#define BEAST_EXAMPLE_COMMON_ROOT_CERTIFICATES_HPP
#ifndef BOOST_BEAST_EXAMPLE_COMMON_ROOT_CERTIFICATES_HPP
#define BOOST_BEAST_EXAMPLE_COMMON_ROOT_CERTIFICATES_HPP
#include <boost/asio/ssl.hpp>
#include <string>
+5 -3
View File
@@ -4,9 +4,11 @@
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/beast
//
#ifndef BEAST_EXAMPLE_COMMON_SESSION_ALLOC_HPP
#define BEAST_EXAMPLE_COMMON_SESSION_ALLOC_HPP
#ifndef BOOST_BEAST_EXAMPLE_COMMON_SESSION_ALLOC_HPP
#define BOOST_BEAST_EXAMPLE_COMMON_SESSION_ALLOC_HPP
#include <boost/asio/handler_alloc_hook.hpp>
#include <boost/asio/handler_continuation_hook.hpp>
@@ -18,7 +20,7 @@
#include <utility>
#if 1
#include "extras/beast/unit_test/dstream.hpp"
#include "extras/boost/beast/unit_test/dstream.hpp"
#endif
template<class Context>
+15 -13
View File
@@ -4,12 +4,14 @@
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/beast
//
#ifndef BEAST_EXAMPLE_COMMON_SSL_STREAM_HPP
#define BEAST_EXAMPLE_COMMON_SSL_STREAM_HPP
#ifndef BOOST_BEAST_EXAMPLE_COMMON_SSL_STREAM_HPP
#define BOOST_BEAST_EXAMPLE_COMMON_SSL_STREAM_HPP
// This include is necessary to work with `ssl::stream` and `beast::websocket::stream`
#include <beast/websocket/ssl.hpp>
// This include is necessary to work with `ssl::stream` and `boost::beast::websocket::stream`
#include <boost/beast/websocket/ssl.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/ssl/stream.hpp>
@@ -292,42 +294,42 @@ public:
template<class SyncStream>
friend
void
teardown(beast::websocket::teardown_tag,
teardown(boost::beast::websocket::teardown_tag,
ssl_stream<SyncStream>& stream,
boost::system::error_code& ec);
template<class AsyncStream, class TeardownHandler>
friend
void
async_teardown(beast::websocket::teardown_tag,
async_teardown(boost::beast::websocket::teardown_tag,
ssl_stream<AsyncStream>& stream, TeardownHandler&& handler);
};
// These hooks are used to inform beast::websocket::stream on
// These hooks are used to inform boost::beast::websocket::stream on
// how to tear down the connection as part of the WebSocket
// protocol specifications
template<class SyncStream>
inline
void
teardown(beast::websocket::teardown_tag,
teardown(boost::beast::websocket::teardown_tag,
ssl_stream<SyncStream>& stream,
boost::system::error_code& ec)
{
// Just forward it to the wrapped ssl::stream
using beast::websocket::teardown;
teardown(beast::websocket::teardown_tag{}, *stream.p_, ec);
using boost::beast::websocket::teardown;
teardown(boost::beast::websocket::teardown_tag{}, *stream.p_, ec);
}
template<class AsyncStream, class TeardownHandler>
inline
void
async_teardown(beast::websocket::teardown_tag,
async_teardown(boost::beast::websocket::teardown_tag,
ssl_stream<AsyncStream>& stream, TeardownHandler&& handler)
{
// Just forward it to the wrapped ssl::stream
using beast::websocket::async_teardown;
async_teardown(beast::websocket::teardown_tag{},
using boost::beast::websocket::async_teardown;
async_teardown(boost::beast::websocket::teardown_tag{},
*stream.p_, std::forward<TeardownHandler>(handler));
}
+24 -22
View File
@@ -4,16 +4,18 @@
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/beast
//
#ifndef BEAST_EXAMPLE_COMMON_WRITE_MSG_HPP
#define BEAST_EXAMPLE_COMMON_WRITE_MSG_HPP
#ifndef BOOST_BEAST_EXAMPLE_COMMON_WRITE_MSG_HPP
#define BOOST_BEAST_EXAMPLE_COMMON_WRITE_MSG_HPP
#include <beast/core/async_result.hpp>
#include <beast/core/handler_ptr.hpp>
#include <beast/core/type_traits.hpp>
#include <beast/http/message.hpp>
#include <beast/http/write.hpp>
#include <beast/http/type_traits.hpp>
#include <boost/beast/core/async_result.hpp>
#include <boost/beast/core/handler_ptr.hpp>
#include <boost/beast/core/type_traits.hpp>
#include <boost/beast/http/message.hpp>
#include <boost/beast/http/write.hpp>
#include <boost/beast/http/type_traits.hpp>
#include <boost/asio/handler_alloc_hook.hpp>
#include <boost/asio/handler_continuation_hook.hpp>
#include <boost/asio/handler_invoke_hook.hpp>
@@ -44,15 +46,15 @@ class write_msg_op
// operation takes ownership of the message and destroys
// it when it is done.
//
beast::http::message<isRequest, Body, Fields> msg;
boost::beast::http::message<isRequest, Body, Fields> msg;
// Serializer for the message
beast::http::serializer<isRequest, Body, Fields> sr;
boost::beast::http::serializer<isRequest, Body, Fields> sr;
data(
Handler& handler,
AsyncWriteStream& stream_,
beast::http::message<isRequest, Body, Fields>&& msg_)
boost::beast::http::message<isRequest, Body, Fields>&& msg_)
: stream(stream_)
, msg(std::move(msg_))
, sr(msg)
@@ -67,7 +69,7 @@ class write_msg_op
// and it also helps to meet Asio's deallocate-before-invocation
// guarantee.
//
beast::handler_ptr<data, Handler> d_;
boost::beast::handler_ptr<data, Handler> d_;
public:
// Asio can move and copy the handler, we support both
@@ -99,16 +101,16 @@ public:
operator()()
{
auto& d = *d_;
beast::http::async_write(
boost::beast::http::async_write(
d.stream, d.sr, std::move(*this));
}
// Completion handler
//
// This gets called when beast::http::async_write completes
// This gets called when boost::beast::http::async_write completes
//
void
operator()(beast::error_code ec)
operator()(boost::beast::error_code ec)
{
d_.invoke(ec);
}
@@ -196,27 +198,27 @@ template<
class AsyncWriteStream,
bool isRequest, class Body, class Fields,
class WriteHandler>
beast::async_return_type<WriteHandler, void(beast::error_code)>
boost::beast::async_return_type<WriteHandler, void(boost::beast::error_code)>
async_write_msg(
AsyncWriteStream& stream,
beast::http::message<isRequest, Body, Fields>&& msg,
boost::beast::http::message<isRequest, Body, Fields>&& msg,
WriteHandler&& handler)
{
static_assert(
beast::is_async_write_stream<AsyncWriteStream>::value,
boost::beast::is_async_write_stream<AsyncWriteStream>::value,
"AsyncWriteStream requirements not met");
static_assert(beast::http::is_body<Body>::value,
static_assert(boost::beast::http::is_body<Body>::value,
"Body requirements not met");
static_assert(beast::http::is_body_reader<Body>::value,
static_assert(boost::beast::http::is_body_reader<Body>::value,
"BodyReader requirements not met");
beast::async_completion<WriteHandler, void(beast::error_code)> init{handler};
boost::beast::async_completion<WriteHandler, void(boost::beast::error_code)> init{handler};
::detail::write_msg_op<
AsyncWriteStream,
beast::handler_type<WriteHandler, void(beast::error_code)>,
boost::beast::handler_type<WriteHandler, void(boost::beast::error_code)>,
isRequest, Body, Fields>{
init.completion_handler,
stream,