mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-01 16:35:53 +00:00
Reduce requirements to C++11 only
This commit is contained in:
@@ -256,6 +256,8 @@
|
|||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\beast\include\beast\detail\empty_base_optimization.hpp">
|
<ClInclude Include="..\..\src\beast\include\beast\detail\empty_base_optimization.hpp">
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\beast\include\beast\detail\integer_sequence.hpp">
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\beast\include\beast\detail\is_call_possible.hpp">
|
<ClInclude Include="..\..\src\beast\include\beast\detail\is_call_possible.hpp">
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\beast\include\beast\detail\sha1.hpp">
|
<ClInclude Include="..\..\src\beast\include\beast\detail\sha1.hpp">
|
||||||
@@ -403,10 +405,10 @@
|
|||||||
</None>
|
</None>
|
||||||
<None Include="..\..\src\beast\include\beast\websocket\impl\response_op.ipp">
|
<None Include="..\..\src\beast\include\beast\websocket\impl\response_op.ipp">
|
||||||
</None>
|
</None>
|
||||||
<None Include="..\..\src\beast\include\beast\websocket\impl\socket.ipp">
|
|
||||||
</None>
|
|
||||||
<None Include="..\..\src\beast\include\beast\websocket\impl\ssl.ipp">
|
<None Include="..\..\src\beast\include\beast\websocket\impl\ssl.ipp">
|
||||||
</None>
|
</None>
|
||||||
|
<None Include="..\..\src\beast\include\beast\websocket\impl\stream.ipp">
|
||||||
|
</None>
|
||||||
<None Include="..\..\src\beast\include\beast\websocket\impl\teardown.ipp">
|
<None Include="..\..\src\beast\include\beast\websocket\impl\teardown.ipp">
|
||||||
</None>
|
</None>
|
||||||
<None Include="..\..\src\beast\include\beast\websocket\impl\write_frame_op.ipp">
|
<None Include="..\..\src\beast\include\beast\websocket\impl\write_frame_op.ipp">
|
||||||
|
|||||||
@@ -564,6 +564,9 @@
|
|||||||
<ClInclude Include="..\..\src\beast\include\beast\detail\empty_base_optimization.hpp">
|
<ClInclude Include="..\..\src\beast\include\beast\detail\empty_base_optimization.hpp">
|
||||||
<Filter>include\beast\detail</Filter>
|
<Filter>include\beast\detail</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\beast\include\beast\detail\integer_sequence.hpp">
|
||||||
|
<Filter>include\beast\detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\beast\include\beast\detail\is_call_possible.hpp">
|
<ClInclude Include="..\..\src\beast\include\beast\detail\is_call_possible.hpp">
|
||||||
<Filter>include\beast\detail</Filter>
|
<Filter>include\beast\detail</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@@ -783,10 +786,10 @@
|
|||||||
<None Include="..\..\src\beast\include\beast\websocket\impl\response_op.ipp">
|
<None Include="..\..\src\beast\include\beast\websocket\impl\response_op.ipp">
|
||||||
<Filter>include\beast\websocket\impl</Filter>
|
<Filter>include\beast\websocket\impl</Filter>
|
||||||
</None>
|
</None>
|
||||||
<None Include="..\..\src\beast\include\beast\websocket\impl\socket.ipp">
|
<None Include="..\..\src\beast\include\beast\websocket\impl\ssl.ipp">
|
||||||
<Filter>include\beast\websocket\impl</Filter>
|
<Filter>include\beast\websocket\impl</Filter>
|
||||||
</None>
|
</None>
|
||||||
<None Include="..\..\src\beast\include\beast\websocket\impl\ssl.ipp">
|
<None Include="..\..\src\beast\include\beast\websocket\impl\stream.ipp">
|
||||||
<Filter>include\beast\websocket\impl</Filter>
|
<Filter>include\beast\websocket\impl</Filter>
|
||||||
</None>
|
</None>
|
||||||
<None Include="..\..\src\beast\include\beast\websocket\impl\teardown.ipp">
|
<None Include="..\..\src\beast\include\beast\websocket\impl\teardown.ipp">
|
||||||
|
|||||||
@@ -53,14 +53,15 @@ project beast
|
|||||||
<library>/boost/system//boost_system
|
<library>/boost/system//boost_system
|
||||||
<library>/boost/filesystem//boost_filesystem
|
<library>/boost/filesystem//boost_filesystem
|
||||||
<library>/boost/program_options//boost_program_options
|
<library>/boost/program_options//boost_program_options
|
||||||
# <library>ssl
|
# <library>ssl
|
||||||
# <library>crypto
|
# <library>crypto
|
||||||
<define>BOOST_ALL_NO_LIB=1
|
<define>BOOST_ALL_NO_LIB=1
|
||||||
|
<define>BOOST_SYSTEM_NO_DEPRECATED=1
|
||||||
<threading>multi
|
<threading>multi
|
||||||
<link>static
|
<link>static
|
||||||
<runtime-link>shared
|
<runtime-link>shared
|
||||||
<toolset>gcc:<cxxflags>-std=c++14
|
<toolset>gcc:<cxxflags>-std=c++11
|
||||||
<toolset>clang:<cxxflags>-std=c++14
|
<toolset>clang:<cxxflags>-std=c++11
|
||||||
<os>LINUX:<define>_XOPEN_SOURCE=600
|
<os>LINUX:<define>_XOPEN_SOURCE=600
|
||||||
<os>LINUX:<define>_GNU_SOURCE=1
|
<os>LINUX:<define>_GNU_SOURCE=1
|
||||||
<os>SOLARIS:<define>_XOPEN_SOURCE=500
|
<os>SOLARIS:<define>_XOPEN_SOURCE=500
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ struct file_body
|
|||||||
size_ = boost::filesystem::file_size(path_);
|
size_ = boost::filesystem::file_size(path_);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto
|
std::size_t
|
||||||
content_length() const
|
content_length() const
|
||||||
{
|
{
|
||||||
return size_;
|
return size_;
|
||||||
|
|||||||
@@ -96,15 +96,12 @@ private:
|
|||||||
|
|
||||||
explicit
|
explicit
|
||||||
peer(socket_type&& sock, std::string const& root)
|
peer(socket_type&& sock, std::string const& root)
|
||||||
: id_([]
|
: stream_(std::move(sock))
|
||||||
{
|
|
||||||
static int n = 0;
|
|
||||||
return ++n;
|
|
||||||
}())
|
|
||||||
, stream_(std::move(sock))
|
|
||||||
, strand_(stream_.get_io_service())
|
, strand_(stream_.get_io_service())
|
||||||
, root_(root)
|
, root_(root)
|
||||||
{
|
{
|
||||||
|
static int n = 0;
|
||||||
|
id_ = ++n;
|
||||||
}
|
}
|
||||||
|
|
||||||
void run()
|
void run()
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#define BEAST_HTTP_STREAM_H_INCLUDED
|
#define BEAST_HTTP_STREAM_H_INCLUDED
|
||||||
|
|
||||||
#include <beast/http.hpp>
|
#include <beast/http.hpp>
|
||||||
|
#include <beast/async_completion.hpp>
|
||||||
#include <beast/basic_streambuf.hpp>
|
#include <beast/basic_streambuf.hpp>
|
||||||
#include <boost/asio/io_service.hpp>
|
#include <boost/asio/io_service.hpp>
|
||||||
#include <boost/intrusive/list.hpp>
|
#include <boost/intrusive/list.hpp>
|
||||||
@@ -94,7 +95,7 @@ class stream : public detail::stream_base
|
|||||||
public:
|
public:
|
||||||
/// The type of the next layer.
|
/// The type of the next layer.
|
||||||
using next_layer_type =
|
using next_layer_type =
|
||||||
std::remove_reference_t<NextLayer>;
|
typename std::remove_reference<NextLayer>::type;
|
||||||
|
|
||||||
/// The type of the lowest layer.
|
/// The type of the lowest layer.
|
||||||
using lowest_layer_type =
|
using lowest_layer_type =
|
||||||
@@ -335,7 +336,8 @@ public:
|
|||||||
#if GENERATING_DOCS
|
#if GENERATING_DOCS
|
||||||
void_or_deduced
|
void_or_deduced
|
||||||
#else
|
#else
|
||||||
auto
|
typename async_completion<
|
||||||
|
ReadHandler, void(error_code)>::result_type
|
||||||
#endif
|
#endif
|
||||||
async_read(message<isRequest, Body, Headers>& msg,
|
async_read(message<isRequest, Body, Headers>& msg,
|
||||||
ReadHandler&& handler);
|
ReadHandler&& handler);
|
||||||
@@ -429,7 +431,8 @@ public:
|
|||||||
#if GENERATING_DOCS
|
#if GENERATING_DOCS
|
||||||
void_or_deduced
|
void_or_deduced
|
||||||
#else
|
#else
|
||||||
auto
|
typename async_completion<
|
||||||
|
WriteHandler, void(error_code)>::result_type
|
||||||
#endif
|
#endif
|
||||||
async_write(message<isRequest, Body, Headers> const& msg,
|
async_write(message<isRequest, Body, Headers> const& msg,
|
||||||
WriteHandler&& handler);
|
WriteHandler&& handler);
|
||||||
@@ -467,7 +470,8 @@ public:
|
|||||||
#if GENERATING_DOCS
|
#if GENERATING_DOCS
|
||||||
void_or_deduced
|
void_or_deduced
|
||||||
#else
|
#else
|
||||||
auto
|
typename async_completion<
|
||||||
|
WriteHandler, void(error_code)>::result_type
|
||||||
#endif
|
#endif
|
||||||
async_write(message<isRequest, Body, Headers>&& msg,
|
async_write(message<isRequest, Body, Headers>&& msg,
|
||||||
WriteHandler&& handler);
|
WriteHandler&& handler);
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
#ifndef BEAST_HTTP_STREAM_IPP_INCLUDED
|
#ifndef BEAST_HTTP_STREAM_IPP_INCLUDED
|
||||||
#define BEAST_HTTP_STREAM_IPP_INCLUDED
|
#define BEAST_HTTP_STREAM_IPP_INCLUDED
|
||||||
|
|
||||||
#include <beast/async_completion.hpp>
|
|
||||||
#include <beast/bind_handler.hpp>
|
#include <beast/bind_handler.hpp>
|
||||||
#include <beast/handler_alloc.hpp>
|
#include <beast/handler_alloc.hpp>
|
||||||
#include <beast/http/read.hpp>
|
#include <beast/http/read.hpp>
|
||||||
@@ -78,7 +77,7 @@ public:
|
|||||||
void operator()(error_code const& ec, bool again = true);
|
void operator()(error_code const& ec, bool again = true);
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_allocate(
|
void* asio_handler_allocate(
|
||||||
std::size_t size, read_op* op)
|
std::size_t size, read_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -86,7 +85,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_deallocate(
|
void asio_handler_deallocate(
|
||||||
void* p, std::size_t size, read_op* op)
|
void* p, std::size_t size, read_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -94,14 +93,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_is_continuation(read_op* op)
|
bool asio_handler_is_continuation(read_op* op)
|
||||||
{
|
{
|
||||||
return op->d_->cont;
|
return op->d_->cont;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Function>
|
template <class Function>
|
||||||
friend
|
friend
|
||||||
auto asio_handler_invoke(Function&& f, read_op* op)
|
void asio_handler_invoke(Function&& f, read_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_invoke_helpers::
|
return boost_asio_handler_invoke_helpers::
|
||||||
invoke(f, op->d_->h);
|
invoke(f, op->d_->h);
|
||||||
@@ -198,7 +197,7 @@ public:
|
|||||||
void operator()(error_code const& ec, bool again = true);
|
void operator()(error_code const& ec, bool again = true);
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_allocate(
|
void* asio_handler_allocate(
|
||||||
std::size_t size, write_op* op)
|
std::size_t size, write_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -206,7 +205,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_deallocate(
|
void asio_handler_deallocate(
|
||||||
void* p, std::size_t size, write_op* op)
|
void* p, std::size_t size, write_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -214,14 +213,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_is_continuation(write_op* op)
|
bool asio_handler_is_continuation(write_op* op)
|
||||||
{
|
{
|
||||||
return op->d_->cont;
|
return op->d_->cont;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Function>
|
template <class Function>
|
||||||
friend
|
friend
|
||||||
auto asio_handler_invoke(Function&& f, write_op* op)
|
void asio_handler_invoke(Function&& f, write_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_invoke_helpers::
|
return boost_asio_handler_invoke_helpers::
|
||||||
invoke(f, op->d_->h);
|
invoke(f, op->d_->h);
|
||||||
@@ -319,7 +318,9 @@ template<bool isRequest, class Body, class Headers,
|
|||||||
auto
|
auto
|
||||||
stream<NextLayer, Allocator>::
|
stream<NextLayer, Allocator>::
|
||||||
async_read(message<isRequest, Body, Headers>& msg,
|
async_read(message<isRequest, Body, Headers>& msg,
|
||||||
ReadHandler&& handler)
|
ReadHandler&& handler) ->
|
||||||
|
typename async_completion<
|
||||||
|
ReadHandler, void(error_code)>::result_type
|
||||||
{
|
{
|
||||||
async_completion<
|
async_completion<
|
||||||
ReadHandler, void(error_code)
|
ReadHandler, void(error_code)
|
||||||
@@ -346,7 +347,9 @@ template<bool isRequest, class Body, class Headers,
|
|||||||
auto
|
auto
|
||||||
stream<NextLayer, Allocator>::
|
stream<NextLayer, Allocator>::
|
||||||
async_write(message<isRequest, Body, Headers> const& msg,
|
async_write(message<isRequest, Body, Headers> const& msg,
|
||||||
WriteHandler&& handler)
|
WriteHandler&& handler) ->
|
||||||
|
typename async_completion<
|
||||||
|
WriteHandler, void(error_code)>::result_type
|
||||||
{
|
{
|
||||||
async_completion<
|
async_completion<
|
||||||
WriteHandler, void(error_code)> completion(handler);
|
WriteHandler, void(error_code)> completion(handler);
|
||||||
@@ -375,7 +378,9 @@ template<bool isRequest, class Body, class Headers,
|
|||||||
auto
|
auto
|
||||||
stream<NextLayer, Allocator>::
|
stream<NextLayer, Allocator>::
|
||||||
async_write(message<isRequest, Body, Headers>&& msg,
|
async_write(message<isRequest, Body, Headers>&& msg,
|
||||||
WriteHandler&& handler)
|
WriteHandler&& handler) ->
|
||||||
|
typename async_completion<
|
||||||
|
WriteHandler, void(error_code)>::result_type
|
||||||
{
|
{
|
||||||
async_completion<
|
async_completion<
|
||||||
WriteHandler, void(error_code)> completion(handler);
|
WriteHandler, void(error_code)> completion(handler);
|
||||||
|
|||||||
@@ -94,6 +94,28 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct lambda
|
||||||
|
{
|
||||||
|
int id;
|
||||||
|
http_sync_server& self;
|
||||||
|
socket_type sock;
|
||||||
|
boost::asio::io_service::work work;
|
||||||
|
|
||||||
|
lambda(int id_, http_sync_server& self_,
|
||||||
|
socket_type&& sock_)
|
||||||
|
: id(id_)
|
||||||
|
, self(self_)
|
||||||
|
, sock(std::move(sock_))
|
||||||
|
, work(sock.get_io_service())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void operator()()
|
||||||
|
{
|
||||||
|
self.do_peer(id, std::move(sock));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
on_accept(error_code ec)
|
on_accept(error_code ec)
|
||||||
{
|
{
|
||||||
@@ -101,16 +123,7 @@ public:
|
|||||||
return;
|
return;
|
||||||
maybe_throw(ec, "accept");
|
maybe_throw(ec, "accept");
|
||||||
static int id_ = 0;
|
static int id_ = 0;
|
||||||
std::thread{
|
std::thread{lambda{++id_, *this, std::move(sock_)}}.detach();
|
||||||
[
|
|
||||||
id = ++id_,
|
|
||||||
this,
|
|
||||||
sock = std::move(sock_),
|
|
||||||
work = boost::asio::io_service::work{ios_}
|
|
||||||
]() mutable
|
|
||||||
{
|
|
||||||
do_peer(id, std::move(sock));
|
|
||||||
}}.detach();
|
|
||||||
acceptor_.async_accept(sock_,
|
acceptor_.async_accept(sock_,
|
||||||
std::bind(&http_sync_server::on_accept, this,
|
std::bind(&http_sync_server::on_accept, this,
|
||||||
asio::placeholders::error));
|
asio::placeholders::error));
|
||||||
|
|||||||
@@ -102,6 +102,28 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct lambda
|
||||||
|
{
|
||||||
|
int id;
|
||||||
|
sync_echo_peer& self;
|
||||||
|
socket_type sock;
|
||||||
|
boost::asio::io_service::work work;
|
||||||
|
|
||||||
|
lambda(int id_, sync_echo_peer& self_,
|
||||||
|
socket_type&& sock_)
|
||||||
|
: id(id_)
|
||||||
|
, self(self_)
|
||||||
|
, sock(std::move(sock_))
|
||||||
|
, work(sock.get_io_service())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void operator()()
|
||||||
|
{
|
||||||
|
self.do_peer(id, std::move(sock));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
on_accept(error_code ec)
|
on_accept(error_code ec)
|
||||||
{
|
{
|
||||||
@@ -109,16 +131,7 @@ private:
|
|||||||
return;
|
return;
|
||||||
maybe_throw(ec, "accept");
|
maybe_throw(ec, "accept");
|
||||||
static int id_ = 0;
|
static int id_ = 0;
|
||||||
std::thread{
|
std::thread{lambda{++id_, *this, std::move(sock_)}}.detach();
|
||||||
[
|
|
||||||
id = ++id_,
|
|
||||||
this,
|
|
||||||
sock = std::move(sock_),
|
|
||||||
work = boost::asio::io_service::work{ios_}
|
|
||||||
]() mutable
|
|
||||||
{
|
|
||||||
do_peer(id, std::move(sock));
|
|
||||||
}}.detach();
|
|
||||||
acceptor_.async_accept(sock_,
|
acceptor_.async_accept(sock_,
|
||||||
std::bind(&sync_echo_peer::on_accept, this,
|
std::bind(&sync_echo_peer::on_accept, this,
|
||||||
beast::asio::placeholders::error));
|
beast::asio::placeholders::error));
|
||||||
|
|||||||
@@ -32,12 +32,12 @@ namespace beast {
|
|||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
@code
|
@code
|
||||||
|
...
|
||||||
template<class CompletionToken>
|
template<class CompletionToken>
|
||||||
auto
|
typename async_completion<CompletionToken, Signature>::result_type
|
||||||
async_initfn(..., CompletionToken&& token)
|
async_initfn(..., CompletionToken&& token)
|
||||||
{
|
{
|
||||||
async_completion<CompletionToken,
|
async_completion<CompletionToken, Signature> completion(token);
|
||||||
void(error_code, std::size_t)> completion(token);
|
|
||||||
...
|
...
|
||||||
return completion.result.get();
|
return completion.result.get();
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,6 @@ namespace beast {
|
|||||||
See <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3896.pdf">
|
See <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3896.pdf">
|
||||||
Library Foundations For Asynchronous Operations</a>
|
Library Foundations For Asynchronous Operations</a>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template <class CompletionToken, class Signature>
|
template <class CompletionToken, class Signature>
|
||||||
struct async_completion
|
struct async_completion
|
||||||
{
|
{
|
||||||
@@ -59,12 +58,15 @@ struct async_completion
|
|||||||
typename boost::asio::handler_type<
|
typename boost::asio::handler_type<
|
||||||
CompletionToken, Signature>::type;
|
CompletionToken, Signature>::type;
|
||||||
|
|
||||||
|
using result_type = typename
|
||||||
|
boost::asio::async_result<handler_type>::type;
|
||||||
|
|
||||||
/** Construct the completion helper.
|
/** Construct the completion helper.
|
||||||
|
|
||||||
@param token The completion token. Copies will be made as
|
@param token The completion token. Copies will be made as
|
||||||
required. If `CompletionToken` is movable, it may also be moved.
|
required. If `CompletionToken` is movable, it may also be moved.
|
||||||
*/
|
*/
|
||||||
async_completion(std::remove_reference_t<CompletionToken>& token)
|
async_completion(typename std::remove_reference<CompletionToken>::type& token)
|
||||||
: handler(std::forward<CompletionToken>(token))
|
: handler(std::forward<CompletionToken>(token))
|
||||||
, result(handler)
|
, result(handler)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#ifndef BEAST_BIND_HANDLER_HPP
|
#ifndef BEAST_BIND_HANDLER_HPP
|
||||||
#define BEAST_BIND_HANDLER_HPP
|
#define BEAST_BIND_HANDLER_HPP
|
||||||
|
|
||||||
|
#include <beast/detail/integer_sequence.hpp>
|
||||||
#include <boost/asio/detail/handler_alloc_helpers.hpp>
|
#include <boost/asio/detail/handler_alloc_helpers.hpp>
|
||||||
#include <boost/asio/detail/handler_cont_helpers.hpp>
|
#include <boost/asio/detail/handler_cont_helpers.hpp>
|
||||||
#include <boost/asio/detail/handler_invoke_helpers.hpp>
|
#include <boost/asio/detail/handler_invoke_helpers.hpp>
|
||||||
@@ -28,14 +29,14 @@ template<class Handler, class... Args>
|
|||||||
class bound_handler
|
class bound_handler
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
using args_type = std::tuple<std::decay_t<Args>...>;
|
using args_type = std::tuple<typename std::decay<Args>::type...>;
|
||||||
|
|
||||||
Handler h_;
|
Handler h_;
|
||||||
args_type args_;
|
args_type args_;
|
||||||
|
|
||||||
template<class Tuple, std::size_t... S>
|
template<class Tuple, std::size_t... S>
|
||||||
static void invoke(Handler& h, Tuple& args,
|
static void invoke(Handler& h, Tuple& args,
|
||||||
std::index_sequence <S...>)
|
index_sequence<S...>)
|
||||||
{
|
{
|
||||||
h(std::get<S>(args)...);
|
h(std::get<S>(args)...);
|
||||||
}
|
}
|
||||||
@@ -55,14 +56,14 @@ public:
|
|||||||
operator()()
|
operator()()
|
||||||
{
|
{
|
||||||
invoke(h_, args_,
|
invoke(h_, args_,
|
||||||
std::index_sequence_for<Args...> ());
|
index_sequence_for<Args...> ());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
operator()() const
|
operator()() const
|
||||||
{
|
{
|
||||||
invoke(h_, args_,
|
invoke(h_, args_,
|
||||||
std::index_sequence_for<Args...> ());
|
index_sequence_for<Args...> ());
|
||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
@@ -133,19 +134,19 @@ public:
|
|||||||
@param handler The handler to wrap.
|
@param handler The handler to wrap.
|
||||||
|
|
||||||
@param args A list of arguments to bind to the handler. The
|
@param args A list of arguments to bind to the handler. The
|
||||||
arguments are forwarded into the returned
|
arguments are forwarded into the returned object.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
template<class CompletionHandler, class... Args>
|
template<class CompletionHandler, class... Args>
|
||||||
#if GENERATING_DOCS
|
#if GENERATING_DOCS
|
||||||
implementation_defined
|
implementation_defined
|
||||||
#else
|
#else
|
||||||
detail::bound_handler<std::decay_t<CompletionHandler>, Args...>
|
detail::bound_handler<
|
||||||
|
typename std::decay<CompletionHandler>::type, Args...>
|
||||||
#endif
|
#endif
|
||||||
bind_handler(CompletionHandler&& handler, Args&&... args)
|
bind_handler(CompletionHandler&& handler, Args&&... args)
|
||||||
{
|
{
|
||||||
return detail::bound_handler<std::decay_t<
|
return detail::bound_handler<typename std::decay<
|
||||||
CompletionHandler>, Args...>(std::forward<
|
CompletionHandler>::type, Args...>(std::forward<
|
||||||
CompletionHandler>(handler),
|
CompletionHandler>(handler),
|
||||||
std::forward<Args>(args)...);
|
std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,8 +79,8 @@ class buffer_cat_helper<
|
|||||||
using C = std::integral_constant<std::size_t, I>;
|
using C = std::integral_constant<std::size_t, I>;
|
||||||
|
|
||||||
template<std::size_t I>
|
template<std::size_t I>
|
||||||
using iter_t = typename std::tuple_element_t<
|
using iter_t = typename std::tuple_element<
|
||||||
I, std::tuple<Bs...>>::const_iterator;
|
I, std::tuple<Bs...>>::type::const_iterator;
|
||||||
|
|
||||||
template<std::size_t I>
|
template<std::size_t I>
|
||||||
iter_t<I>&
|
iter_t<I>&
|
||||||
@@ -491,7 +491,8 @@ implementation_defined
|
|||||||
buffer_cat(BufferSequence const&... buffers)
|
buffer_cat(BufferSequence const&... buffers)
|
||||||
#else
|
#else
|
||||||
template<class B1, class B2, class... Bn>
|
template<class B1, class B2, class... Bn>
|
||||||
auto
|
detail::buffer_cat_helper<
|
||||||
|
boost::asio::const_buffer, B1, B2, Bn...>
|
||||||
buffer_cat(B1 const& b1, B2 const& b2, Bn const&... bn)
|
buffer_cat(B1 const& b1, B2 const& b2, Bn const&... bn)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ template<class Buffers>
|
|||||||
class buffers_adapter
|
class buffers_adapter
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
using buffers_type = std::decay_t<Buffers>;
|
using buffers_type = typename std::decay<Buffers>::type;
|
||||||
using iter_type = typename buffers_type::const_iterator;
|
using iter_type = typename buffers_type::const_iterator;
|
||||||
|
|
||||||
static auto constexpr is_mutable =
|
static auto constexpr is_mutable =
|
||||||
|
|||||||
@@ -45,8 +45,10 @@ bool
|
|||||||
ci_equal(std::pair<const char*, std::size_t> lhs,
|
ci_equal(std::pair<const char*, std::size_t> lhs,
|
||||||
std::pair<const char*, std::size_t> rhs)
|
std::pair<const char*, std::size_t> rhs)
|
||||||
{
|
{
|
||||||
|
if(lhs.second != rhs.second)
|
||||||
|
return false;
|
||||||
return std::equal (lhs.first, lhs.first + lhs.second,
|
return std::equal (lhs.first, lhs.first + lhs.second,
|
||||||
rhs.first, rhs.first + rhs.second,
|
rhs.first,
|
||||||
[] (char lhs, char rhs)
|
[] (char lhs, char rhs)
|
||||||
{
|
{
|
||||||
return std::tolower(lhs) == std::tolower(rhs);
|
return std::tolower(lhs) == std::tolower(rhs);
|
||||||
|
|||||||
145
src/beast/include/beast/detail/integer_sequence.hpp
Normal file
145
src/beast/include/beast/detail/integer_sequence.hpp
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) 2013-2016 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)
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef BEAST_DETAIL_INTEGER_SEQUENCE_H_INCLUDED
|
||||||
|
#define BEAST_DETAIL_INTEGER_SEQUENCE_H_INCLUDED
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
namespace beast {
|
||||||
|
namespace detail {
|
||||||
|
|
||||||
|
template<class T, T... Ints>
|
||||||
|
struct integer_sequence
|
||||||
|
{
|
||||||
|
using value_type = T;
|
||||||
|
static_assert (std::is_integral<T>::value,
|
||||||
|
"std::integer_sequence can only be instantiated with an integral type" );
|
||||||
|
|
||||||
|
static std::size_t constexpr static_size = sizeof...(Ints);
|
||||||
|
|
||||||
|
static std::size_t constexpr size()
|
||||||
|
{
|
||||||
|
return sizeof...(Ints);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<std::size_t... Ints>
|
||||||
|
using index_sequence = integer_sequence<std::size_t, Ints...>;
|
||||||
|
|
||||||
|
// This workaround is needed for broken sizeof...
|
||||||
|
template<class... Args>
|
||||||
|
struct sizeof_workaround
|
||||||
|
{
|
||||||
|
static std::size_t constexpr size = sizeof... (Args);
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
|
// This implementation compiles on MSVC and clang but not gcc
|
||||||
|
|
||||||
|
template<class T, unsigned long long N, class Seq>
|
||||||
|
struct make_integer_sequence_unchecked;
|
||||||
|
|
||||||
|
template<class T, unsigned long long N, unsigned long long ...Indices>
|
||||||
|
struct make_integer_sequence_unchecked<
|
||||||
|
T, N, integer_sequence<T, Indices...>>
|
||||||
|
{
|
||||||
|
using type = typename make_integer_sequence_unchecked<
|
||||||
|
T, N-1, integer_sequence<T, N-1, Indices...>>::type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T, unsigned long long ...Indices>
|
||||||
|
struct make_integer_sequence_unchecked<
|
||||||
|
T, 0, integer_sequence<T, Indices...>>
|
||||||
|
{
|
||||||
|
using type = integer_sequence<T, Indices...>;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T, T N>
|
||||||
|
struct make_integer_sequence_checked
|
||||||
|
{
|
||||||
|
static_assert (std::is_integral<T>::value,
|
||||||
|
"T must be an integral type");
|
||||||
|
|
||||||
|
static_assert (N >= 0,
|
||||||
|
"N must be non-negative");
|
||||||
|
|
||||||
|
using type = typename make_integer_sequence_unchecked<
|
||||||
|
T, N, integer_sequence<T>>::type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T, T N>
|
||||||
|
using make_integer_sequence =
|
||||||
|
typename make_integer_sequence_checked<T, N>::type;
|
||||||
|
|
||||||
|
template<std::size_t N>
|
||||||
|
using make_index_sequence = make_integer_sequence<std::size_t, N>;
|
||||||
|
|
||||||
|
template<class... Args>
|
||||||
|
using index_sequence_for =
|
||||||
|
make_index_sequence<sizeof_workaround<Args...>::size>;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
// This implementation compiles on gcc but not MSVC
|
||||||
|
|
||||||
|
template<std::size_t... Ints>
|
||||||
|
struct index_tuple
|
||||||
|
{
|
||||||
|
using next = index_tuple<Ints..., sizeof... (Ints)>;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
template<std::size_t N>
|
||||||
|
struct build_index_tuple
|
||||||
|
{
|
||||||
|
using type = typename build_index_tuple<N-1>::type::next;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct build_index_tuple<0>
|
||||||
|
{
|
||||||
|
using type = index_tuple<>;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T, T N,
|
||||||
|
class Seq = typename build_index_tuple<N>::type
|
||||||
|
>
|
||||||
|
struct integer_sequence_helper;
|
||||||
|
|
||||||
|
template<class T, T N, std::size_t... Ints>
|
||||||
|
struct integer_sequence_helper<T, N, index_tuple<Ints...>>
|
||||||
|
{
|
||||||
|
static_assert (std::is_integral<T>::value,
|
||||||
|
"T must be an integral type");
|
||||||
|
|
||||||
|
static_assert (N >= 0,
|
||||||
|
"N must be non-negative");
|
||||||
|
|
||||||
|
using type = integer_sequence<T, static_cast<T> (Ints)...>;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T, T N>
|
||||||
|
using make_integer_sequence =
|
||||||
|
typename integer_sequence_helper<T, N>::type;
|
||||||
|
|
||||||
|
template<std::size_t N>
|
||||||
|
using make_index_sequence = make_integer_sequence<std::size_t, N>;
|
||||||
|
|
||||||
|
template<class... Args>
|
||||||
|
using index_sequence_for =
|
||||||
|
make_index_sequence<sizeof_workaround<Args...>::size>;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} // detail
|
||||||
|
} // beast
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -78,7 +78,7 @@ public:
|
|||||||
explicit basic_scoped_ostream (Handler&& handler)
|
explicit basic_scoped_ostream (Handler&& handler)
|
||||||
: m_handler (std::forward <Handler> (handler))
|
: m_handler (std::forward <Handler> (handler))
|
||||||
#if BEAST_NO_STDLIB_STREAM_MOVE
|
#if BEAST_NO_STDLIB_STREAM_MOVE
|
||||||
, m_ss (std::make_unique <stream_type>())
|
, m_ss (new stream_type())
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ public:
|
|||||||
basic_scoped_ostream (T const& t, Handler&& handler)
|
basic_scoped_ostream (T const& t, Handler&& handler)
|
||||||
: m_handler (std::forward <Handler> (handler))
|
: m_handler (std::forward <Handler> (handler))
|
||||||
#if BEAST_NO_STDLIB_STREAM_MOVE
|
#if BEAST_NO_STDLIB_STREAM_MOVE
|
||||||
, m_ss (std::make_unique <stream_type>())
|
, m_ss (new stream_type())
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
stream() << t;
|
stream() << t;
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
#include <beast/http/chunk_encode.hpp>
|
#include <beast/http/chunk_encode.hpp>
|
||||||
#include <beast/http/empty_body.hpp>
|
#include <beast/http/empty_body.hpp>
|
||||||
#include <beast/http/error.hpp>
|
#include <beast/http/error.hpp>
|
||||||
#include <beast/http/fields.hpp>
|
|
||||||
#include <beast/http/headers.hpp>
|
#include <beast/http/headers.hpp>
|
||||||
#include <beast/http/message.hpp>
|
#include <beast/http/message.hpp>
|
||||||
#include <beast/http/parser.hpp>
|
#include <beast/http/parser.hpp>
|
||||||
|
|||||||
@@ -393,8 +393,8 @@ public:
|
|||||||
extended as per RFC2616 Section 4.2.
|
extended as per RFC2616 Section 4.2.
|
||||||
*/
|
*/
|
||||||
template<class T,
|
template<class T,
|
||||||
class = std::enable_if_t<
|
class = typename std::enable_if<
|
||||||
! std::is_constructible<boost::string_ref, T>::value>>
|
! std::is_constructible<boost::string_ref, T>::value>::type>
|
||||||
void
|
void
|
||||||
insert(boost::string_ref name, T const& value)
|
insert(boost::string_ref name, T const& value)
|
||||||
{
|
{
|
||||||
@@ -417,8 +417,8 @@ public:
|
|||||||
specified value is inserted as if by insert(field, value).
|
specified value is inserted as if by insert(field, value).
|
||||||
*/
|
*/
|
||||||
template<class T,
|
template<class T,
|
||||||
class = std::enable_if_t<
|
class = typename std::enable_if<
|
||||||
! std::is_constructible<boost::string_ref, T>::value>>
|
! std::is_constructible<boost::string_ref, T>::value>::type>
|
||||||
void
|
void
|
||||||
replace(boost::string_ref const& name, T const& value)
|
replace(boost::string_ref const& name, T const& value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -61,7 +61,8 @@ private:
|
|||||||
// Unchecked conversion of unsigned to hex string
|
// Unchecked conversion of unsigned to hex string
|
||||||
template<class OutIter, class Unsigned>
|
template<class OutIter, class Unsigned>
|
||||||
static
|
static
|
||||||
std::enable_if_t<std::is_unsigned<Unsigned>::value, OutIter>
|
typename std::enable_if<
|
||||||
|
std::is_unsigned<Unsigned>::value, OutIter>::type
|
||||||
to_hex(OutIter const first, OutIter const last, Unsigned n);
|
to_hex(OutIter const first, OutIter const last, Unsigned n);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -114,7 +115,8 @@ chunk_encoded_buffers<Buffers>::chunk_encoded_buffers (
|
|||||||
|
|
||||||
template <class Buffers>
|
template <class Buffers>
|
||||||
template <class OutIter, class Unsigned>
|
template <class OutIter, class Unsigned>
|
||||||
std::enable_if_t<std::is_unsigned<Unsigned>::value, OutIter>
|
typename std::enable_if<
|
||||||
|
std::is_unsigned<Unsigned>::value, OutIter>::type
|
||||||
chunk_encoded_buffers<Buffers>::to_hex(
|
chunk_encoded_buffers<Buffers>::to_hex(
|
||||||
OutIter const first, OutIter const last, Unsigned n)
|
OutIter const first, OutIter const last, Unsigned n)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<class = void>
|
template<class = void>
|
||||||
auto
|
boost::system::error_code
|
||||||
make_error(int http_errno)
|
make_error(int http_errno)
|
||||||
{
|
{
|
||||||
static message_category const mc{};
|
static message_category const mc{};
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ namespace http {
|
|||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
template<class Streambuf, class T,
|
template<class Streambuf, class T,
|
||||||
class = std::enable_if_t<is_Streambuf<Streambuf>::value>>
|
class = typename std::enable_if<
|
||||||
|
is_Streambuf<Streambuf>::value>::type>
|
||||||
void
|
void
|
||||||
write(Streambuf& streambuf, T&& t)
|
write(Streambuf& streambuf, T&& t)
|
||||||
{
|
{
|
||||||
@@ -34,8 +35,8 @@ write(Streambuf& streambuf, T&& t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class Streambuf, std::size_t N,
|
template<class Streambuf, std::size_t N,
|
||||||
class = std::enable_if_t< (N>0) &&
|
class = typename std::enable_if< (N>0) &&
|
||||||
is_Streambuf<Streambuf>::value>>
|
is_Streambuf<Streambuf>::value>::type>
|
||||||
void
|
void
|
||||||
write(Streambuf& streambuf, char const(&s)[N])
|
write(Streambuf& streambuf, char const(&s)[N])
|
||||||
{
|
{
|
||||||
@@ -46,7 +47,8 @@ write(Streambuf& streambuf, char const(&s)[N])
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class Streambuf,
|
template<class Streambuf,
|
||||||
class = std::enable_if_t<is_Streambuf<Streambuf>::value>>
|
class = typename std::enable_if<
|
||||||
|
is_Streambuf<Streambuf>::value>::type>
|
||||||
void
|
void
|
||||||
write(Streambuf& streambuf, boost::string_ref const& s)
|
write(Streambuf& streambuf, boost::string_ref const& s)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,133 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef BEAST_HTTP_FIELDS_H_INCLUDED
|
|
||||||
#define BEAST_HTTP_FIELDS_H_INCLUDED
|
|
||||||
|
|
||||||
#include <array>
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace http {
|
|
||||||
|
|
||||||
#if defined(__clang__)
|
|
||||||
#pragma clang diagnostic push
|
|
||||||
#pragma clang diagnostic ignored "-Wmissing-braces"
|
|
||||||
#endif // defined(__clang__)
|
|
||||||
|
|
||||||
template<class = void>
|
|
||||||
auto const&
|
|
||||||
common_fields()
|
|
||||||
{
|
|
||||||
// Must be sorted
|
|
||||||
static std::array<char const*, 82> constexpr h{
|
|
||||||
"Accept"
|
|
||||||
,"Accept-Charset"
|
|
||||||
,"Accept-Datetime"
|
|
||||||
,"Accept-Encoding"
|
|
||||||
,"Accept-Language"
|
|
||||||
,"Accept-Ranges"
|
|
||||||
,"Access-Control-Allow-Credentials"
|
|
||||||
,"Access-Control-Allow-Headers"
|
|
||||||
,"Access-Control-Allow-Methods"
|
|
||||||
,"Access-Control-Allow-Origin"
|
|
||||||
,"Access-Control-Expose-Headers"
|
|
||||||
,"Access-Control-Max-Age"
|
|
||||||
,"Access-Control-Request-Headers"
|
|
||||||
,"Access-Control-Request-Method"
|
|
||||||
,"Age"
|
|
||||||
,"Allow"
|
|
||||||
,"Authorization"
|
|
||||||
,"Cache-Control"
|
|
||||||
,"Connection"
|
|
||||||
,"Content-Disposition"
|
|
||||||
,"Content-Encoding"
|
|
||||||
,"Content-Language"
|
|
||||||
,"Content-Length"
|
|
||||||
,"Content-Location"
|
|
||||||
,"Content-MD5"
|
|
||||||
,"Content-Range"
|
|
||||||
,"Content-Type"
|
|
||||||
,"Cookie"
|
|
||||||
,"DNT"
|
|
||||||
,"Date"
|
|
||||||
,"ETag"
|
|
||||||
,"Expect"
|
|
||||||
,"Expires"
|
|
||||||
,"From"
|
|
||||||
,"Front-End-Https"
|
|
||||||
,"Host"
|
|
||||||
,"If-Match"
|
|
||||||
,"If-Modified-Since"
|
|
||||||
,"If-None-Match"
|
|
||||||
,"If-Range"
|
|
||||||
,"If-Unmodified-Since"
|
|
||||||
,"Keep-Alive"
|
|
||||||
,"Last-Modified"
|
|
||||||
,"Link"
|
|
||||||
,"Location"
|
|
||||||
,"Max-Forwards"
|
|
||||||
,"Origin"
|
|
||||||
,"P3P"
|
|
||||||
,"Pragma"
|
|
||||||
,"Proxy-Authenticate"
|
|
||||||
,"Proxy-Authorization"
|
|
||||||
,"Proxy-Connection"
|
|
||||||
,"Range"
|
|
||||||
,"Referer"
|
|
||||||
,"Refresh"
|
|
||||||
,"Retry-After"
|
|
||||||
,"Server"
|
|
||||||
,"Set-Cookie"
|
|
||||||
,"Strict-Transport-Security"
|
|
||||||
,"TE"
|
|
||||||
,"Timestamp"
|
|
||||||
,"Trailer"
|
|
||||||
,"Transfer-Encoding"
|
|
||||||
,"Upgrade"
|
|
||||||
,"User-Agent"
|
|
||||||
,"VIP"
|
|
||||||
,"Vary"
|
|
||||||
,"Via"
|
|
||||||
,"WWW-Authenticate"
|
|
||||||
,"Warning"
|
|
||||||
,"X-Accel-Redirect"
|
|
||||||
,"X-Content-Security-Policy-Report-Only"
|
|
||||||
,"X-Content-Type-Options"
|
|
||||||
,"X-Forwarded-For"
|
|
||||||
,"X-Forwarded-Proto"
|
|
||||||
,"X-Frame-Options"
|
|
||||||
,"X-Powered-By"
|
|
||||||
,"X-Real-IP"
|
|
||||||
,"X-Requested-With"
|
|
||||||
,"X-UA-Compatible"
|
|
||||||
,"X-Wap-Profile"
|
|
||||||
,"X-XSS-Protection"
|
|
||||||
};
|
|
||||||
|
|
||||||
return h;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(__clang__)
|
|
||||||
#pragma clang diagnostic pop
|
|
||||||
#endif // defined(__clang__)
|
|
||||||
|
|
||||||
} // http
|
|
||||||
} // beast
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -127,6 +127,31 @@ buffers_to_string(ConstBufferSequence const& buffers)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class writef_ostream
|
||||||
|
{
|
||||||
|
std::ostream& os_;
|
||||||
|
bool chunked_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
writef_ostream(std::ostream& os, bool chunked)
|
||||||
|
: os_(os)
|
||||||
|
, chunked_(chunked)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class ConstBufferSequence>
|
||||||
|
void
|
||||||
|
operator()(ConstBufferSequence const& buffers)
|
||||||
|
{
|
||||||
|
if(chunked_)
|
||||||
|
os_ << buffers_to_string(
|
||||||
|
chunk_encode(buffers));
|
||||||
|
else
|
||||||
|
os_ << buffers_to_string(
|
||||||
|
buffers);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // detail
|
} // detail
|
||||||
|
|
||||||
// Diagnostic output only
|
// Diagnostic output only
|
||||||
@@ -155,16 +180,7 @@ operator<<(std::ostream& os,
|
|||||||
auto copy = resume;
|
auto copy = resume;
|
||||||
os << detail::buffers_to_string(wp.sb.data());
|
os << detail::buffers_to_string(wp.sb.data());
|
||||||
wp.sb.consume(wp.sb.size());
|
wp.sb.consume(wp.sb.size());
|
||||||
auto writef =
|
detail::writef_ostream writef(os, wp.chunked);
|
||||||
[&os, &wp](auto const& buffers)
|
|
||||||
{
|
|
||||||
if(wp.chunked)
|
|
||||||
os << detail::buffers_to_string(
|
|
||||||
chunk_encode(buffers));
|
|
||||||
else
|
|
||||||
os << detail::buffers_to_string(
|
|
||||||
buffers);
|
|
||||||
};
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
#define BEAST_HTTP_IMPL_READ_IPP_HPP
|
#define BEAST_HTTP_IMPL_READ_IPP_HPP
|
||||||
|
|
||||||
#include <beast/http/type_check.hpp>
|
#include <beast/http/type_check.hpp>
|
||||||
#include <beast/async_completion.hpp>
|
|
||||||
#include <beast/bind_handler.hpp>
|
#include <beast/bind_handler.hpp>
|
||||||
#include <beast/handler_alloc.hpp>
|
#include <beast/handler_alloc.hpp>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
@@ -76,7 +75,7 @@ public:
|
|||||||
std::size_t bytes_transferred, bool again = true);
|
std::size_t bytes_transferred, bool again = true);
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_allocate(
|
void* asio_handler_allocate(
|
||||||
std::size_t size, read_op* op)
|
std::size_t size, read_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -84,7 +83,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_deallocate(
|
void asio_handler_deallocate(
|
||||||
void* p, std::size_t size, read_op* op)
|
void* p, std::size_t size, read_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -92,14 +91,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_is_continuation(read_op* op)
|
bool asio_handler_is_continuation(read_op* op)
|
||||||
{
|
{
|
||||||
return op->d_->cont;
|
return op->d_->cont;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Function>
|
template <class Function>
|
||||||
friend
|
friend
|
||||||
auto asio_handler_invoke(Function&& f, read_op* op)
|
void asio_handler_invoke(Function&& f, read_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_invoke_helpers::
|
return boost_asio_handler_invoke_helpers::
|
||||||
invoke(f, op->d_->h);
|
invoke(f, op->d_->h);
|
||||||
@@ -258,11 +257,12 @@ read(SyncReadStream& stream, Streambuf& streambuf,
|
|||||||
|
|
||||||
template<class AsyncReadStream, class Streambuf,
|
template<class AsyncReadStream, class Streambuf,
|
||||||
bool isRequest, class Body, class Headers,
|
bool isRequest, class Body, class Headers,
|
||||||
class CompletionToken>
|
class ReadHandler>
|
||||||
auto
|
typename async_completion<
|
||||||
|
ReadHandler, void(error_code)>::result_type
|
||||||
async_read(AsyncReadStream& stream, Streambuf& streambuf,
|
async_read(AsyncReadStream& stream, Streambuf& streambuf,
|
||||||
message<isRequest, Body, Headers>& m,
|
message<isRequest, Body, Headers>& m,
|
||||||
CompletionToken&& token)
|
ReadHandler&& handler)
|
||||||
{
|
{
|
||||||
static_assert(is_AsyncReadStream<AsyncReadStream>::value,
|
static_assert(is_AsyncReadStream<AsyncReadStream>::value,
|
||||||
"AsyncReadStream requirements not met");
|
"AsyncReadStream requirements not met");
|
||||||
@@ -270,8 +270,8 @@ async_read(AsyncReadStream& stream, Streambuf& streambuf,
|
|||||||
"Streambuf requirements not met");
|
"Streambuf requirements not met");
|
||||||
static_assert(is_ReadableBody<Body>::value,
|
static_assert(is_ReadableBody<Body>::value,
|
||||||
"ReadableBody requirements not met");
|
"ReadableBody requirements not met");
|
||||||
beast::async_completion<CompletionToken,
|
beast::async_completion<ReadHandler,
|
||||||
void(error_code)> completion(token);
|
void(error_code)> completion(handler);
|
||||||
detail::read_op<AsyncReadStream, Streambuf,
|
detail::read_op<AsyncReadStream, Streambuf,
|
||||||
isRequest, Body, Headers, decltype(
|
isRequest, Body, Headers, decltype(
|
||||||
completion.handler)>{completion.handler,
|
completion.handler)>{completion.handler,
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
#include <beast/http/detail/writes.hpp>
|
#include <beast/http/detail/writes.hpp>
|
||||||
#include <beast/http/detail/write_preparation.hpp>
|
#include <beast/http/detail/write_preparation.hpp>
|
||||||
#include <beast/buffer_cat.hpp>
|
#include <beast/buffer_cat.hpp>
|
||||||
#include <beast/async_completion.hpp>
|
|
||||||
#include <beast/bind_handler.hpp>
|
#include <beast/bind_handler.hpp>
|
||||||
#include <beast/handler_alloc.hpp>
|
#include <beast/handler_alloc.hpp>
|
||||||
#include <beast/streambuf.hpp>
|
#include <beast/streambuf.hpp>
|
||||||
@@ -61,6 +60,60 @@ class write_op
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class writef0
|
||||||
|
{
|
||||||
|
write_op& self_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit
|
||||||
|
writef0(write_op& self)
|
||||||
|
: self_(self)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class ConstBufferSequence>
|
||||||
|
void operator()(ConstBufferSequence const& buffers)
|
||||||
|
{
|
||||||
|
auto& d = *self_.d_;
|
||||||
|
// write headers and body
|
||||||
|
if(d.wp.chunked)
|
||||||
|
boost::asio::async_write(d.s,
|
||||||
|
buffer_cat(d.wp.sb.data(),
|
||||||
|
chunk_encode(buffers)),
|
||||||
|
std::move(self_));
|
||||||
|
else
|
||||||
|
boost::asio::async_write(d.s,
|
||||||
|
buffer_cat(d.wp.sb.data(),
|
||||||
|
buffers), std::move(self_));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class writef
|
||||||
|
{
|
||||||
|
write_op& self_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit
|
||||||
|
writef(write_op& self)
|
||||||
|
: self_(self)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class ConstBufferSequence>
|
||||||
|
void operator()(ConstBufferSequence const& buffers)
|
||||||
|
{
|
||||||
|
auto& d = *self_.d_;
|
||||||
|
// write body
|
||||||
|
if(d.wp.chunked)
|
||||||
|
boost::asio::async_write(d.s,
|
||||||
|
chunk_encode(buffers),
|
||||||
|
std::move(self_));
|
||||||
|
else
|
||||||
|
boost::asio::async_write(d.s,
|
||||||
|
buffers, std::move(self_));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
std::shared_ptr<data> d_;
|
std::shared_ptr<data> d_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -74,9 +127,11 @@ public:
|
|||||||
std::forward<Args>(args)...))
|
std::forward<Args>(args)...))
|
||||||
{
|
{
|
||||||
auto& d = *d_;
|
auto& d = *d_;
|
||||||
|
auto sp = d_;
|
||||||
d.resume = {
|
d.resume = {
|
||||||
[self = *this]() mutable
|
[sp]() mutable
|
||||||
{
|
{
|
||||||
|
write_op self(std::move(sp));
|
||||||
self.d_->cont = false;
|
self.d_->cont = false;
|
||||||
auto& ios = self.d_->s.get_io_service();
|
auto& ios = self.d_->s.get_io_service();
|
||||||
ios.dispatch(bind_handler(std::move(self),
|
ios.dispatch(bind_handler(std::move(self),
|
||||||
@@ -97,7 +152,7 @@ public:
|
|||||||
std::size_t bytes_transferred, bool again = true);
|
std::size_t bytes_transferred, bool again = true);
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_allocate(
|
void* asio_handler_allocate(
|
||||||
std::size_t size, write_op* op)
|
std::size_t size, write_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -105,7 +160,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_deallocate(
|
void asio_handler_deallocate(
|
||||||
void* p, std::size_t size, write_op* op)
|
void* p, std::size_t size, write_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -113,14 +168,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_is_continuation(write_op* op)
|
bool asio_handler_is_continuation(write_op* op)
|
||||||
{
|
{
|
||||||
return op->d_->cont;
|
return op->d_->cont;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Function>
|
template <class Function>
|
||||||
friend
|
friend
|
||||||
auto asio_handler_invoke(Function&& f, write_op* op)
|
void asio_handler_invoke(Function&& f, write_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_invoke_helpers::
|
return boost_asio_handler_invoke_helpers::
|
||||||
invoke(f, op->d_->h);
|
invoke(f, op->d_->h);
|
||||||
@@ -156,20 +211,8 @@ operator()(error_code ec, std::size_t, bool again)
|
|||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
auto const result = d.wp.w(std::move(d.copy), ec,
|
auto const result = d.wp.w(
|
||||||
[&](auto const& buffers)
|
std::move(d.copy), ec, writef0{*this});
|
||||||
{
|
|
||||||
// write headers and body
|
|
||||||
if(d.wp.chunked)
|
|
||||||
boost::asio::async_write(d.s,
|
|
||||||
buffer_cat(d.wp.sb.data(),
|
|
||||||
chunk_encode(buffers)),
|
|
||||||
std::move(*this));
|
|
||||||
else
|
|
||||||
boost::asio::async_write(d.s,
|
|
||||||
buffer_cat(d.wp.sb.data(),
|
|
||||||
buffers), std::move(*this));
|
|
||||||
});
|
|
||||||
if(ec)
|
if(ec)
|
||||||
{
|
{
|
||||||
// call handler
|
// call handler
|
||||||
@@ -199,18 +242,8 @@ operator()(error_code ec, std::size_t, bool again)
|
|||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
{
|
{
|
||||||
auto const result = d.wp.w(std::move(d.copy), ec,
|
auto const result = d.wp.w(
|
||||||
[&](auto const& buffers)
|
std::move(d.copy), ec, writef{*this});
|
||||||
{
|
|
||||||
// write body
|
|
||||||
if(d.wp.chunked)
|
|
||||||
boost::asio::async_write(d.s,
|
|
||||||
chunk_encode(buffers),
|
|
||||||
std::move(*this));
|
|
||||||
else
|
|
||||||
boost::asio::async_write(d.s,
|
|
||||||
buffers, std::move(*this));
|
|
||||||
});
|
|
||||||
if(ec)
|
if(ec)
|
||||||
{
|
{
|
||||||
// call handler
|
// call handler
|
||||||
@@ -256,6 +289,65 @@ operator()(error_code ec, std::size_t, bool again)
|
|||||||
d.copy = {};
|
d.copy = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class SyncWriteStream, class Streambuf>
|
||||||
|
class writef0_write
|
||||||
|
{
|
||||||
|
Streambuf const& sb_;
|
||||||
|
SyncWriteStream& stream_;
|
||||||
|
bool chunked_;
|
||||||
|
error_code& ec_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
writef0_write(SyncWriteStream& stream,
|
||||||
|
Streambuf const& sb, bool chunked, error_code& ec)
|
||||||
|
: sb_(sb)
|
||||||
|
, stream_(stream)
|
||||||
|
, chunked_(chunked)
|
||||||
|
, ec_(ec)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class ConstBufferSequence>
|
||||||
|
void operator()(ConstBufferSequence const& buffers)
|
||||||
|
{
|
||||||
|
// write headers and body
|
||||||
|
if(chunked_)
|
||||||
|
boost::asio::write(stream_, buffer_cat(
|
||||||
|
sb_.data(), chunk_encode(buffers)), ec_);
|
||||||
|
else
|
||||||
|
boost::asio::write(stream_, buffer_cat(
|
||||||
|
sb_.data(), buffers), ec_);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class SyncWriteStream>
|
||||||
|
class writef_write
|
||||||
|
{
|
||||||
|
SyncWriteStream& stream_;
|
||||||
|
bool chunked_;
|
||||||
|
error_code& ec_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
writef_write(SyncWriteStream& stream,
|
||||||
|
bool chunked, error_code& ec)
|
||||||
|
: stream_(stream)
|
||||||
|
, chunked_(chunked)
|
||||||
|
, ec_(ec)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class ConstBufferSequence>
|
||||||
|
void operator()(ConstBufferSequence const& buffers)
|
||||||
|
{
|
||||||
|
// write body
|
||||||
|
if(chunked_)
|
||||||
|
boost::asio::write(stream_,
|
||||||
|
chunk_encode(buffers), ec_);
|
||||||
|
else
|
||||||
|
boost::asio::write(stream_, buffers, ec_);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // detail
|
} // detail
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@@ -288,16 +380,8 @@ write(SyncWriteStream& stream,
|
|||||||
{
|
{
|
||||||
{
|
{
|
||||||
auto result = wp.w(std::move(copy), ec,
|
auto result = wp.w(std::move(copy), ec,
|
||||||
[&](auto const& buffers)
|
detail::writef0_write<SyncWriteStream, decltype(wp.sb)>{
|
||||||
{
|
stream, wp.sb, wp.chunked, ec});
|
||||||
// write headers and body
|
|
||||||
if(wp.chunked)
|
|
||||||
boost::asio::write(stream, buffer_cat(
|
|
||||||
wp.sb.data(), chunk_encode(buffers)), ec);
|
|
||||||
else
|
|
||||||
boost::asio::write(stream, buffer_cat(
|
|
||||||
wp.sb.data(), buffers), ec);
|
|
||||||
});
|
|
||||||
if(ec)
|
if(ec)
|
||||||
return;
|
return;
|
||||||
if(result)
|
if(result)
|
||||||
@@ -318,15 +402,8 @@ write(SyncWriteStream& stream,
|
|||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
auto result = wp.w(std::move(copy), ec,
|
auto result = wp.w(std::move(copy), ec,
|
||||||
[&](auto const& buffers)
|
detail::writef_write<SyncWriteStream>{
|
||||||
{
|
stream, wp.chunked, ec});
|
||||||
// write body
|
|
||||||
if(wp.chunked)
|
|
||||||
boost::asio::write(stream,
|
|
||||||
chunk_encode(buffers), ec);
|
|
||||||
else
|
|
||||||
boost::asio::write(stream, buffers, ec);
|
|
||||||
});
|
|
||||||
if(ec)
|
if(ec)
|
||||||
return;
|
return;
|
||||||
if(result)
|
if(result)
|
||||||
@@ -360,19 +437,20 @@ write(SyncWriteStream& stream,
|
|||||||
|
|
||||||
template<class AsyncWriteStream,
|
template<class AsyncWriteStream,
|
||||||
bool isRequest, class Body, class Headers,
|
bool isRequest, class Body, class Headers,
|
||||||
class CompletionToken>
|
class WriteHandler>
|
||||||
auto
|
typename async_completion<
|
||||||
|
WriteHandler, void(error_code)>::result_type
|
||||||
async_write(AsyncWriteStream& stream,
|
async_write(AsyncWriteStream& stream,
|
||||||
message<isRequest, Body, Headers> const& msg,
|
message<isRequest, Body, Headers> const& msg,
|
||||||
CompletionToken&& token)
|
WriteHandler&& handler)
|
||||||
{
|
{
|
||||||
static_assert(
|
static_assert(
|
||||||
is_AsyncWriteStream<AsyncWriteStream>::value,
|
is_AsyncWriteStream<AsyncWriteStream>::value,
|
||||||
"AsyncWriteStream requirements not met");
|
"AsyncWriteStream requirements not met");
|
||||||
static_assert(is_WritableBody<Body>::value,
|
static_assert(is_WritableBody<Body>::value,
|
||||||
"WritableBody requirements not met");
|
"WritableBody requirements not met");
|
||||||
beast::async_completion<CompletionToken,
|
beast::async_completion<WriteHandler,
|
||||||
void(error_code)> completion(token);
|
void(error_code)> completion(handler);
|
||||||
detail::write_op<AsyncWriteStream, decltype(completion.handler),
|
detail::write_op<AsyncWriteStream, decltype(completion.handler),
|
||||||
isRequest, Body, Headers>{completion.handler, stream, msg};
|
isRequest, Body, Headers>{completion.handler, stream, msg};
|
||||||
return completion.result.get();
|
return completion.result.get();
|
||||||
|
|||||||
@@ -66,8 +66,8 @@ struct response_params
|
|||||||
*/
|
*/
|
||||||
template<bool isRequest, class Body, class Headers>
|
template<bool isRequest, class Body, class Headers>
|
||||||
struct message
|
struct message
|
||||||
: std::conditional_t<isRequest,
|
: std::conditional<isRequest,
|
||||||
detail::request_fields, detail::response_fields>
|
detail::request_fields, detail::response_fields>::type
|
||||||
{
|
{
|
||||||
/** The trait type characterizing the body.
|
/** The trait type characterizing the body.
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#ifndef BEAST_HTTP_READ_HPP
|
#ifndef BEAST_HTTP_READ_HPP
|
||||||
#define BEAST_HTTP_READ_HPP
|
#define BEAST_HTTP_READ_HPP
|
||||||
|
|
||||||
|
#include <beast/async_completion.hpp>
|
||||||
#include <beast/http/error.hpp>
|
#include <beast/http/error.hpp>
|
||||||
#include <beast/http/parser.hpp>
|
#include <beast/http/parser.hpp>
|
||||||
#include <beast/http/type_check.hpp>
|
#include <beast/http/type_check.hpp>
|
||||||
@@ -76,7 +77,7 @@ read(SyncReadStream& stream, Streambuf& streambuf,
|
|||||||
@param msg An object used to store the read message. Any
|
@param msg An object used to store the read message. Any
|
||||||
contents will be overwritten.
|
contents will be overwritten.
|
||||||
|
|
||||||
@param token The handler to be called when the request completes.
|
@param handler The handler to be called when the request completes.
|
||||||
Copies will be made of the handler as required. The equivalent
|
Copies will be made of the handler as required. The equivalent
|
||||||
function signature of the handler must be:
|
function signature of the handler must be:
|
||||||
@code void handler(
|
@code void handler(
|
||||||
@@ -89,15 +90,16 @@ read(SyncReadStream& stream, Streambuf& streambuf,
|
|||||||
*/
|
*/
|
||||||
template<class AsyncReadStream, class Streambuf,
|
template<class AsyncReadStream, class Streambuf,
|
||||||
bool isRequest, class Body, class Headers,
|
bool isRequest, class Body, class Headers,
|
||||||
class CompletionToken>
|
class ReadHandler>
|
||||||
#if GENERATING_DOCS
|
#if GENERATING_DOCS
|
||||||
void_or_deduced
|
void_or_deduced
|
||||||
#else
|
#else
|
||||||
auto
|
typename async_completion<
|
||||||
|
ReadHandler, void(error_code)>::result_type
|
||||||
#endif
|
#endif
|
||||||
async_read(AsyncReadStream& stream, Streambuf& streambuf,
|
async_read(AsyncReadStream& stream, Streambuf& streambuf,
|
||||||
message<isRequest, Body, Headers>& msg,
|
message<isRequest, Body, Headers>& msg,
|
||||||
CompletionToken&& token);
|
ReadHandler&& handler);
|
||||||
|
|
||||||
} // http
|
} // http
|
||||||
} // beast
|
} // beast
|
||||||
|
|||||||
@@ -429,13 +429,12 @@ ci_equal(boost::string_ref s1, boost::string_ref s2)
|
|||||||
|
|
||||||
/** Returns a range representing the list. */
|
/** Returns a range representing the list. */
|
||||||
inline
|
inline
|
||||||
auto
|
boost::iterator_range<list_iterator>
|
||||||
make_list(boost::string_ref const& field)
|
make_list(boost::string_ref const& field)
|
||||||
{
|
{
|
||||||
return boost::iterator_range<list_iterator>{
|
return boost::iterator_range<list_iterator>{
|
||||||
list_iterator{field.begin(), field.end()},
|
list_iterator{field.begin(), field.end()},
|
||||||
list_iterator{field.end(), field.end()}};
|
list_iterator{field.end(), field.end()}};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true if the specified token exists in the list.
|
/** Returns true if the specified token exists in the list.
|
||||||
|
|||||||
@@ -80,12 +80,6 @@ struct basic_streambuf_body
|
|||||||
write(body_.data());
|
write(body_.data());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto
|
|
||||||
data() const noexcept
|
|
||||||
{
|
|
||||||
return body_.data();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include <beast/http/error.hpp>
|
#include <beast/http/error.hpp>
|
||||||
#include <beast/http/message.hpp>
|
#include <beast/http/message.hpp>
|
||||||
|
#include <beast/async_completion.hpp>
|
||||||
#include <boost/system/error_code.hpp>
|
#include <boost/system/error_code.hpp>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
@@ -73,15 +74,16 @@ write(SyncWriteStream& stream,
|
|||||||
*/
|
*/
|
||||||
template<class AsyncWriteStream,
|
template<class AsyncWriteStream,
|
||||||
bool isRequest, class Body, class Headers,
|
bool isRequest, class Body, class Headers,
|
||||||
class CompletionToken>
|
class WriteHandler>
|
||||||
#if GENERATING_DOCS
|
#if GENERATING_DOCS
|
||||||
void_or_deduced
|
void_or_deduced
|
||||||
#else
|
#else
|
||||||
auto
|
typename async_completion<
|
||||||
|
WriteHandler, void(error_code)>::result_type
|
||||||
#endif
|
#endif
|
||||||
async_write(AsyncWriteStream& stream,
|
async_write(AsyncWriteStream& stream,
|
||||||
message<isRequest, Body, Headers> const& msg,
|
message<isRequest, Body, Headers> const& msg,
|
||||||
CompletionToken&& token);
|
WriteHandler&& handler);
|
||||||
|
|
||||||
} // http
|
} // http
|
||||||
} // beast
|
} // beast
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
#ifndef BEAST_IMPL_STREAMBUF_READSTREAM_IPP
|
#ifndef BEAST_IMPL_STREAMBUF_READSTREAM_IPP
|
||||||
#define BEAST_IMPL_STREAMBUF_READSTREAM_IPP
|
#define BEAST_IMPL_STREAMBUF_READSTREAM_IPP
|
||||||
|
|
||||||
#include <beast/async_completion.hpp>
|
|
||||||
#include <beast/bind_handler.hpp>
|
#include <beast/bind_handler.hpp>
|
||||||
#include <beast/handler_alloc.hpp>
|
#include <beast/handler_alloc.hpp>
|
||||||
#include <beast/type_check.hpp>
|
#include <beast/type_check.hpp>
|
||||||
@@ -61,7 +60,7 @@ public:
|
|||||||
std::size_t bytes_transferred);
|
std::size_t bytes_transferred);
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_allocate(
|
void* asio_handler_allocate(
|
||||||
std::size_t size, read_some_op* op)
|
std::size_t size, read_some_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -69,7 +68,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_deallocate(
|
void asio_handler_deallocate(
|
||||||
void* p, std::size_t size, read_some_op* op)
|
void* p, std::size_t size, read_some_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -77,7 +76,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_is_continuation(read_some_op* op)
|
bool asio_handler_is_continuation(read_some_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_cont_helpers::
|
return boost_asio_handler_cont_helpers::
|
||||||
is_continuation(op->d_->h);
|
is_continuation(op->d_->h);
|
||||||
@@ -85,7 +84,7 @@ public:
|
|||||||
|
|
||||||
template <class Function>
|
template <class Function>
|
||||||
friend
|
friend
|
||||||
auto asio_handler_invoke(Function&& f, read_some_op* op)
|
void asio_handler_invoke(Function&& f, read_some_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_invoke_helpers::
|
return boost_asio_handler_invoke_helpers::
|
||||||
invoke(f, op->d_->h);
|
invoke(f, op->d_->h);
|
||||||
@@ -170,7 +169,9 @@ template<class ConstBufferSequence, class WriteHandler>
|
|||||||
auto
|
auto
|
||||||
streambuf_readstream<Stream, Streambuf>::
|
streambuf_readstream<Stream, Streambuf>::
|
||||||
async_write_some(ConstBufferSequence const& buffers,
|
async_write_some(ConstBufferSequence const& buffers,
|
||||||
WriteHandler&& handler)
|
WriteHandler&& handler) ->
|
||||||
|
typename async_completion<
|
||||||
|
WriteHandler, void(error_code)>::result_type
|
||||||
{
|
{
|
||||||
static_assert(is_ConstBufferSequence<
|
static_assert(is_ConstBufferSequence<
|
||||||
ConstBufferSequence>::value,
|
ConstBufferSequence>::value,
|
||||||
@@ -234,7 +235,9 @@ auto
|
|||||||
streambuf_readstream<Stream, Streambuf>::
|
streambuf_readstream<Stream, Streambuf>::
|
||||||
async_read_some(
|
async_read_some(
|
||||||
MutableBufferSequence const& buffers,
|
MutableBufferSequence const& buffers,
|
||||||
ReadHandler&& handler)
|
ReadHandler&& handler) ->
|
||||||
|
typename async_completion<
|
||||||
|
ReadHandler, void(error_code)>::result_type
|
||||||
{
|
{
|
||||||
static_assert(is_MutableBufferSequence<
|
static_assert(is_MutableBufferSequence<
|
||||||
MutableBufferSequence>::value,
|
MutableBufferSequence>::value,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#ifndef BEAST_STREAMBUF_READSTREAM_HPP
|
#ifndef BEAST_STREAMBUF_READSTREAM_HPP
|
||||||
#define BEAST_STREAMBUF_READSTREAM_HPP
|
#define BEAST_STREAMBUF_READSTREAM_HPP
|
||||||
|
|
||||||
|
#include <beast/async_completion.hpp>
|
||||||
#include <beast/streambuf.hpp>
|
#include <beast/streambuf.hpp>
|
||||||
#include <boost/asio/buffer.hpp>
|
#include <boost/asio/buffer.hpp>
|
||||||
#include <boost/asio/io_service.hpp>
|
#include <boost/asio/io_service.hpp>
|
||||||
@@ -101,7 +102,7 @@ public:
|
|||||||
|
|
||||||
/// The type of the next layer.
|
/// The type of the next layer.
|
||||||
using next_layer_type =
|
using next_layer_type =
|
||||||
std::remove_reference_t<Stream>;
|
typename std::remove_reference<Stream>::type;
|
||||||
|
|
||||||
/// The type of the lowest layer.
|
/// The type of the lowest layer.
|
||||||
using lowest_layer_type =
|
using lowest_layer_type =
|
||||||
@@ -215,7 +216,8 @@ public:
|
|||||||
/// Start an asynchronous write. The data being written must be valid for the
|
/// Start an asynchronous write. The data being written must be valid for the
|
||||||
/// lifetime of the asynchronous operation.
|
/// lifetime of the asynchronous operation.
|
||||||
template<class ConstBufferSequence, class WriteHandler>
|
template<class ConstBufferSequence, class WriteHandler>
|
||||||
auto
|
typename async_completion<
|
||||||
|
WriteHandler, void(error_code)>::result_type
|
||||||
async_write_some(ConstBufferSequence const& buffers,
|
async_write_some(ConstBufferSequence const& buffers,
|
||||||
WriteHandler&& handler);
|
WriteHandler&& handler);
|
||||||
|
|
||||||
@@ -235,7 +237,8 @@ public:
|
|||||||
/// Start an asynchronous read. The buffer into which the data will be read
|
/// Start an asynchronous read. The buffer into which the data will be read
|
||||||
/// must be valid for the lifetime of the asynchronous operation.
|
/// must be valid for the lifetime of the asynchronous operation.
|
||||||
template<class MutableBufferSequence, class ReadHandler>
|
template<class MutableBufferSequence, class ReadHandler>
|
||||||
auto
|
typename async_completion<
|
||||||
|
ReadHandler, void(error_code)>::result_type
|
||||||
async_read_some(MutableBufferSequence const& buffers,
|
async_read_some(MutableBufferSequence const& buffers,
|
||||||
ReadHandler&& handler);
|
ReadHandler&& handler);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -338,7 +338,7 @@ public:
|
|||||||
/// Determine if `T` meets the requirements of `CompletionHandler`.
|
/// Determine if `T` meets the requirements of `CompletionHandler`.
|
||||||
template<class T, class Signature>
|
template<class T, class Signature>
|
||||||
using is_Handler = std::integral_constant<bool,
|
using is_Handler = std::integral_constant<bool,
|
||||||
std::is_copy_constructible<std::decay_t<T>>::value &&
|
std::is_copy_constructible<typename std::decay<T>::type>::value &&
|
||||||
detail::is_call_possible<T, Signature>::value>;
|
detail::is_call_possible<T, Signature>::value>;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ private:
|
|||||||
base&
|
base&
|
||||||
get()
|
get()
|
||||||
{
|
{
|
||||||
return *reinterpret_cast<base*>(buf_);
|
return *reinterpret_cast<base*>(&buf_[0]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -106,28 +106,28 @@ prepare_key(std::uint64_t& prepared, std::uint32_t key)
|
|||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline
|
inline
|
||||||
std::enable_if_t<std::is_integral<T>::value, T>
|
typename std::enable_if<std::is_integral<T>::value, T>::type
|
||||||
rol(T t, unsigned n = 1)
|
rol(T t, unsigned n = 1)
|
||||||
{
|
{
|
||||||
auto constexpr bits =
|
auto constexpr bits =
|
||||||
static_cast<unsigned>(
|
static_cast<unsigned>(
|
||||||
sizeof(T) * CHAR_BIT);
|
sizeof(T) * CHAR_BIT);
|
||||||
n &= bits-1;
|
n &= bits-1;
|
||||||
return static_cast<T>((t << n) |
|
return static_cast<T>((t << n) | (
|
||||||
(static_cast<std::make_unsigned_t<T>>(t) >> (bits - n)));
|
static_cast<typename std::make_unsigned<T>::type>(t) >> (bits - n)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline
|
inline
|
||||||
std::enable_if_t<std::is_integral<T>::value, T>
|
typename std::enable_if<std::is_integral<T>::value, T>::type
|
||||||
ror(T t, unsigned n = 1)
|
ror(T t, unsigned n = 1)
|
||||||
{
|
{
|
||||||
auto constexpr bits =
|
auto constexpr bits =
|
||||||
static_cast<unsigned>(
|
static_cast<unsigned>(
|
||||||
sizeof(T) * CHAR_BIT);
|
sizeof(T) * CHAR_BIT);
|
||||||
n &= bits-1;
|
n &= bits-1;
|
||||||
return static_cast<T>((t << (bits - n)) |
|
return static_cast<T>((t << (bits - n)) | (
|
||||||
(static_cast<std::make_unsigned_t<T>>(t) >> n));
|
static_cast<typename std::make_unsigned<T>::type>(t) >> n));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 32-bit Uuoptimized
|
// 32-bit Uuoptimized
|
||||||
|
|||||||
@@ -97,8 +97,7 @@ protected:
|
|||||||
close_reason cr_; // set from received close frame
|
close_reason cr_; // set from received close frame
|
||||||
|
|
||||||
stream_base()
|
stream_base()
|
||||||
: d_(std::make_unique<
|
: d_(new decorator<default_decorator>{})
|
||||||
decorator<default_decorator>>())
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public:
|
|||||||
std::size_t bytes_transferred, bool again = true);
|
std::size_t bytes_transferred, bool again = true);
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_allocate(
|
void* asio_handler_allocate(
|
||||||
std::size_t size, accept_op* op)
|
std::size_t size, accept_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -86,7 +86,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_deallocate(
|
void asio_handler_deallocate(
|
||||||
void* p, std::size_t size, accept_op* op)
|
void* p, std::size_t size, accept_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -94,14 +94,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_is_continuation(accept_op* op)
|
bool asio_handler_is_continuation(accept_op* op)
|
||||||
{
|
{
|
||||||
return op->d_->cont;
|
return op->d_->cont;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Function>
|
template <class Function>
|
||||||
friend
|
friend
|
||||||
auto asio_handler_invoke(Function&& f, accept_op* op)
|
void asio_handler_invoke(Function&& f, accept_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_invoke_helpers::
|
return boost_asio_handler_invoke_helpers::
|
||||||
invoke(f, op->d_->h);
|
invoke(f, op->d_->h);
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public:
|
|||||||
std::size_t bytes_transferred, bool again = true);
|
std::size_t bytes_transferred, bool again = true);
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_allocate(
|
void* asio_handler_allocate(
|
||||||
std::size_t size, close_op* op)
|
std::size_t size, close_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -93,7 +93,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_deallocate(
|
void asio_handler_deallocate(
|
||||||
void* p, std::size_t size, close_op* op)
|
void* p, std::size_t size, close_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -101,14 +101,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_is_continuation(close_op* op)
|
bool asio_handler_is_continuation(close_op* op)
|
||||||
{
|
{
|
||||||
return op->d_->cont;
|
return op->d_->cont;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Function>
|
template <class Function>
|
||||||
friend
|
friend
|
||||||
auto asio_handler_invoke(Function&& f, close_op* op)
|
void asio_handler_invoke(Function&& f, close_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_invoke_helpers::
|
return boost_asio_handler_invoke_helpers::
|
||||||
invoke(f, op->d_->h);
|
invoke(f, op->d_->h);
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public:
|
|||||||
std::size_t bytes_transferred, bool again = true);
|
std::size_t bytes_transferred, bool again = true);
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_allocate(
|
void* asio_handler_allocate(
|
||||||
std::size_t size, handshake_op* op)
|
std::size_t size, handshake_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -84,7 +84,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_deallocate(
|
void asio_handler_deallocate(
|
||||||
void* p, std::size_t size, handshake_op* op)
|
void* p, std::size_t size, handshake_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -92,14 +92,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_is_continuation(handshake_op* op)
|
bool asio_handler_is_continuation(handshake_op* op)
|
||||||
{
|
{
|
||||||
return op->d_->cont;
|
return op->d_->cont;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Function>
|
template <class Function>
|
||||||
friend
|
friend
|
||||||
auto asio_handler_invoke(Function&& f, handshake_op* op)
|
void asio_handler_invoke(Function&& f, handshake_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_invoke_helpers::
|
return boost_asio_handler_invoke_helpers::
|
||||||
invoke(f, op->d_->h);
|
invoke(f, op->d_->h);
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ public:
|
|||||||
std::size_t bytes_transferred, bool again = true);
|
std::size_t bytes_transferred, bool again = true);
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_allocate(
|
void* asio_handler_allocate(
|
||||||
std::size_t size, read_frame_op* op)
|
std::size_t size, read_frame_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -102,7 +102,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_deallocate(
|
void asio_handler_deallocate(
|
||||||
void* p, std::size_t size, read_frame_op* op)
|
void* p, std::size_t size, read_frame_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -110,14 +110,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_is_continuation(read_frame_op* op)
|
bool asio_handler_is_continuation(read_frame_op* op)
|
||||||
{
|
{
|
||||||
return op->d_->cont;
|
return op->d_->cont;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Function>
|
template <class Function>
|
||||||
friend
|
friend
|
||||||
auto asio_handler_invoke(Function&& f, read_frame_op* op)
|
void asio_handler_invoke(Function&& f, read_frame_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_invoke_helpers::
|
return boost_asio_handler_invoke_helpers::
|
||||||
invoke(f, op->d_->h);
|
invoke(f, op->d_->h);
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public:
|
|||||||
error_code const& ec, bool again = true);
|
error_code const& ec, bool again = true);
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_allocate(
|
void* asio_handler_allocate(
|
||||||
std::size_t size, read_op* op)
|
std::size_t size, read_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -75,7 +75,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_deallocate(
|
void asio_handler_deallocate(
|
||||||
void* p, std::size_t size, read_op* op)
|
void* p, std::size_t size, read_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -83,14 +83,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_is_continuation(read_op* op)
|
bool asio_handler_is_continuation(read_op* op)
|
||||||
{
|
{
|
||||||
return op->d_->cont;
|
return op->d_->cont;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Function>
|
template <class Function>
|
||||||
friend
|
friend
|
||||||
auto asio_handler_invoke(Function&& f, read_op* op)
|
void asio_handler_invoke(Function&& f, read_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_invoke_helpers::
|
return boost_asio_handler_invoke_helpers::
|
||||||
invoke(f, op->d_->h);
|
invoke(f, op->d_->h);
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public:
|
|||||||
error_code ec, bool again = true);
|
error_code ec, bool again = true);
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_allocate(
|
void* asio_handler_allocate(
|
||||||
std::size_t size, response_op* op)
|
std::size_t size, response_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -76,7 +76,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_deallocate(
|
void asio_handler_deallocate(
|
||||||
void* p, std::size_t size, response_op* op)
|
void* p, std::size_t size, response_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -84,14 +84,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_is_continuation(response_op* op)
|
bool asio_handler_is_continuation(response_op* op)
|
||||||
{
|
{
|
||||||
return op->d_->cont;
|
return op->d_->cont;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Function>
|
template <class Function>
|
||||||
friend
|
friend
|
||||||
auto asio_handler_invoke(Function&& f, response_op* op)
|
void asio_handler_invoke(Function&& f, response_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_invoke_helpers::
|
return boost_asio_handler_invoke_helpers::
|
||||||
invoke(f, op->d_->h);
|
invoke(f, op->d_->h);
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public:
|
|||||||
operator()(error_code ec, bool again = true);
|
operator()(error_code ec, bool again = true);
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_allocate(std::size_t size,
|
void* asio_handler_allocate(std::size_t size,
|
||||||
teardown_ssl_op* op)
|
teardown_ssl_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -81,7 +81,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_deallocate(void* p,
|
void asio_handler_deallocate(void* p,
|
||||||
std::size_t size, teardown_ssl_op* op)
|
std::size_t size, teardown_ssl_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -89,7 +89,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_is_continuation(
|
bool asio_handler_is_continuation(
|
||||||
teardown_ssl_op* op)
|
teardown_ssl_op* op)
|
||||||
{
|
{
|
||||||
return op->d_->cont;
|
return op->d_->cont;
|
||||||
@@ -97,7 +97,7 @@ public:
|
|||||||
|
|
||||||
template <class Function>
|
template <class Function>
|
||||||
friend
|
friend
|
||||||
auto asio_handler_invoke(Function&& f,
|
void asio_handler_invoke(Function&& f,
|
||||||
teardown_ssl_op* op)
|
teardown_ssl_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_invoke_helpers::
|
return boost_asio_handler_invoke_helpers::
|
||||||
@@ -147,8 +147,8 @@ async_teardown(
|
|||||||
static_assert(beast::is_Handler<
|
static_assert(beast::is_Handler<
|
||||||
TeardownHandler, void(error_code)>::value,
|
TeardownHandler, void(error_code)>::value,
|
||||||
"TeardownHandler requirements not met");
|
"TeardownHandler requirements not met");
|
||||||
detail::teardown_ssl_op<AsyncStream, std::decay_t<
|
detail::teardown_ssl_op<AsyncStream, typename std::decay<
|
||||||
TeardownHandler>>{std::forward<TeardownHandler>(
|
TeardownHandler>::type>{std::forward<TeardownHandler>(
|
||||||
handler), stream};
|
handler), stream};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef BEAST_WEBSOCKET_IMPL_SOCKET_IPP
|
#ifndef BEAST_WEBSOCKET_IMPL_STREAM_IPP
|
||||||
#define BEAST_WEBSOCKET_IMPL_SOCKET_IPP
|
#define BEAST_WEBSOCKET_IMPL_STREAM_IPP
|
||||||
|
|
||||||
#include <beast/websocket/teardown.hpp>
|
#include <beast/websocket/teardown.hpp>
|
||||||
#include <beast/websocket/detail/hybi13.hpp>
|
#include <beast/websocket/detail/hybi13.hpp>
|
||||||
@@ -19,7 +19,6 @@
|
|||||||
#include <beast/websocket/impl/write_op.ipp>
|
#include <beast/websocket/impl/write_op.ipp>
|
||||||
#include <beast/websocket/impl/write_frame_op.ipp>
|
#include <beast/websocket/impl/write_frame_op.ipp>
|
||||||
#include <beast/buffer_cat.hpp>
|
#include <beast/buffer_cat.hpp>
|
||||||
#include <beast/async_completion.hpp>
|
|
||||||
#include <beast/consuming_buffers.hpp>
|
#include <beast/consuming_buffers.hpp>
|
||||||
#include <beast/prepare_buffers.hpp>
|
#include <beast/prepare_buffers.hpp>
|
||||||
#include <beast/static_streambuf.hpp>
|
#include <beast/static_streambuf.hpp>
|
||||||
@@ -167,7 +166,8 @@ stream_base::write_ping(Streambuf& sb,
|
|||||||
|
|
||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
template<class... Args>
|
template<class... Args>
|
||||||
stream<NextLayer>::stream(Args&&... args)
|
stream<NextLayer>::
|
||||||
|
stream(Args&&... args)
|
||||||
: next_layer_(std::forward<Args>(args)...)
|
: next_layer_(std::forward<Args>(args)...)
|
||||||
, stream_(next_layer_)
|
, stream_(next_layer_)
|
||||||
{
|
{
|
||||||
@@ -177,15 +177,18 @@ stream<NextLayer>::stream(Args&&... args)
|
|||||||
|
|
||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
void
|
void
|
||||||
stream<NextLayer>::accept(error_code& ec)
|
stream<NextLayer>::
|
||||||
|
accept(error_code& ec)
|
||||||
{
|
{
|
||||||
accept(boost::asio::null_buffers{}, ec);
|
accept(boost::asio::null_buffers{}, ec);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
template<class AcceptHandler>
|
template<class AcceptHandler>
|
||||||
auto
|
typename async_completion<
|
||||||
stream<NextLayer>::async_accept(AcceptHandler&& handler)
|
AcceptHandler, void(error_code)>::result_type
|
||||||
|
stream<NextLayer>::
|
||||||
|
async_accept(AcceptHandler&& handler)
|
||||||
{
|
{
|
||||||
return async_accept(boost::asio::null_buffers{},
|
return async_accept(boost::asio::null_buffers{},
|
||||||
std::forward<AcceptHandler>(handler));
|
std::forward<AcceptHandler>(handler));
|
||||||
@@ -194,8 +197,8 @@ stream<NextLayer>::async_accept(AcceptHandler&& handler)
|
|||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
template<class ConstBufferSequence>
|
template<class ConstBufferSequence>
|
||||||
void
|
void
|
||||||
stream<NextLayer>::accept(
|
stream<NextLayer>::
|
||||||
ConstBufferSequence const& buffers)
|
accept(ConstBufferSequence const& buffers)
|
||||||
{
|
{
|
||||||
static_assert(is_ConstBufferSequence<
|
static_assert(is_ConstBufferSequence<
|
||||||
ConstBufferSequence>::value,
|
ConstBufferSequence>::value,
|
||||||
@@ -208,8 +211,8 @@ stream<NextLayer>::accept(
|
|||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
template<class ConstBufferSequence>
|
template<class ConstBufferSequence>
|
||||||
void
|
void
|
||||||
stream<NextLayer>::accept(
|
stream<NextLayer>::
|
||||||
ConstBufferSequence const& buffers, error_code& ec)
|
accept(ConstBufferSequence const& buffers, error_code& ec)
|
||||||
{
|
{
|
||||||
static_assert(beast::is_ConstBufferSequence<
|
static_assert(beast::is_ConstBufferSequence<
|
||||||
ConstBufferSequence>::value,
|
ConstBufferSequence>::value,
|
||||||
@@ -228,9 +231,10 @@ stream<NextLayer>::accept(
|
|||||||
|
|
||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
template<class ConstBufferSequence, class AcceptHandler>
|
template<class ConstBufferSequence, class AcceptHandler>
|
||||||
auto
|
typename async_completion<
|
||||||
stream<NextLayer>::async_accept(
|
AcceptHandler, void(error_code)>::result_type
|
||||||
ConstBufferSequence const& bs, AcceptHandler&& handler)
|
stream<NextLayer>::
|
||||||
|
async_accept(ConstBufferSequence const& bs, AcceptHandler&& handler)
|
||||||
{
|
{
|
||||||
static_assert(beast::is_ConstBufferSequence<
|
static_assert(beast::is_ConstBufferSequence<
|
||||||
ConstBufferSequence>::value,
|
ConstBufferSequence>::value,
|
||||||
@@ -246,8 +250,8 @@ stream<NextLayer>::async_accept(
|
|||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
template<class Body, class Headers>
|
template<class Body, class Headers>
|
||||||
void
|
void
|
||||||
stream<NextLayer>::accept(
|
stream<NextLayer>::
|
||||||
http::message<true, Body, Headers> const& request)
|
accept(http::message<true, Body, Headers> const& request)
|
||||||
{
|
{
|
||||||
error_code ec;
|
error_code ec;
|
||||||
accept(request, ec);
|
accept(request, ec);
|
||||||
@@ -257,9 +261,9 @@ stream<NextLayer>::accept(
|
|||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
template<class Body, class Headers>
|
template<class Body, class Headers>
|
||||||
void
|
void
|
||||||
stream<NextLayer>::accept(
|
stream<NextLayer>::
|
||||||
http::message<true, Body, Headers> const& req,
|
accept(http::message<true, Body, Headers> const& req,
|
||||||
error_code& ec)
|
error_code& ec)
|
||||||
{
|
{
|
||||||
auto resp = build_response(req);
|
auto resp = build_response(req);
|
||||||
http::write(stream_, resp, ec);
|
http::write(stream_, resp, ec);
|
||||||
@@ -275,10 +279,11 @@ stream<NextLayer>::accept(
|
|||||||
|
|
||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
template<class Body, class Headers, class AcceptHandler>
|
template<class Body, class Headers, class AcceptHandler>
|
||||||
auto
|
typename async_completion<
|
||||||
stream<NextLayer>::async_accept(
|
AcceptHandler, void(error_code)>::result_type
|
||||||
http::message<true, Body, Headers> const& req,
|
stream<NextLayer>::
|
||||||
AcceptHandler&& handler)
|
async_accept(http::message<true, Body, Headers> const& req,
|
||||||
|
AcceptHandler&& handler)
|
||||||
{
|
{
|
||||||
beast::async_completion<
|
beast::async_completion<
|
||||||
AcceptHandler, void(error_code)
|
AcceptHandler, void(error_code)
|
||||||
@@ -292,7 +297,8 @@ stream<NextLayer>::async_accept(
|
|||||||
|
|
||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
void
|
void
|
||||||
stream<NextLayer>::handshake(boost::string_ref const& host,
|
stream<NextLayer>::
|
||||||
|
handshake(boost::string_ref const& host,
|
||||||
boost::string_ref const& resource, error_code& ec)
|
boost::string_ref const& resource, error_code& ec)
|
||||||
{
|
{
|
||||||
std::string key;
|
std::string key;
|
||||||
@@ -309,8 +315,10 @@ stream<NextLayer>::handshake(boost::string_ref const& host,
|
|||||||
|
|
||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
template<class HandshakeHandler>
|
template<class HandshakeHandler>
|
||||||
auto
|
typename async_completion<
|
||||||
stream<NextLayer>::async_handshake(boost::string_ref const& host,
|
HandshakeHandler, void(error_code)>::result_type
|
||||||
|
stream<NextLayer>::
|
||||||
|
async_handshake(boost::string_ref const& host,
|
||||||
boost::string_ref const& resource, HandshakeHandler&& handler)
|
boost::string_ref const& resource, HandshakeHandler&& handler)
|
||||||
{
|
{
|
||||||
beast::async_completion<
|
beast::async_completion<
|
||||||
@@ -323,8 +331,8 @@ stream<NextLayer>::async_handshake(boost::string_ref const& host,
|
|||||||
|
|
||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
void
|
void
|
||||||
stream<NextLayer>::close(
|
stream<NextLayer>::
|
||||||
close_reason const& cr, error_code& ec)
|
close(close_reason const& cr, error_code& ec)
|
||||||
{
|
{
|
||||||
assert(! wr_close_);
|
assert(! wr_close_);
|
||||||
wr_close_ = true;
|
wr_close_ = true;
|
||||||
@@ -336,9 +344,10 @@ stream<NextLayer>::close(
|
|||||||
|
|
||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
template<class CloseHandler>
|
template<class CloseHandler>
|
||||||
auto
|
typename async_completion<
|
||||||
stream<NextLayer>::async_close(
|
CloseHandler, void(error_code)>::result_type
|
||||||
close_reason const& cr, CloseHandler&& handler)
|
stream<NextLayer>::
|
||||||
|
async_close(close_reason const& cr, CloseHandler&& handler)
|
||||||
{
|
{
|
||||||
beast::async_completion<
|
beast::async_completion<
|
||||||
CloseHandler, void(error_code)
|
CloseHandler, void(error_code)
|
||||||
@@ -368,7 +377,8 @@ read(opcode& op, Streambuf& streambuf, error_code& ec)
|
|||||||
|
|
||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
template<class Streambuf, class ReadHandler>
|
template<class Streambuf, class ReadHandler>
|
||||||
auto
|
typename async_completion<
|
||||||
|
ReadHandler, void(error_code)>::result_type
|
||||||
stream<NextLayer>::
|
stream<NextLayer>::
|
||||||
async_read(opcode& op,
|
async_read(opcode& op,
|
||||||
Streambuf& streambuf, ReadHandler&& handler)
|
Streambuf& streambuf, ReadHandler&& handler)
|
||||||
@@ -386,8 +396,8 @@ async_read(opcode& op,
|
|||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
template<class Streambuf>
|
template<class Streambuf>
|
||||||
void
|
void
|
||||||
stream<NextLayer>::read_frame(frame_info& fi,
|
stream<NextLayer>::
|
||||||
Streambuf& streambuf, error_code& ec)
|
read_frame(frame_info& fi, Streambuf& streambuf, error_code& ec)
|
||||||
{
|
{
|
||||||
close_code code{};
|
close_code code{};
|
||||||
for(;;)
|
for(;;)
|
||||||
@@ -521,8 +531,10 @@ stream<NextLayer>::read_frame(frame_info& fi,
|
|||||||
|
|
||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
template<class Streambuf, class ReadHandler>
|
template<class Streambuf, class ReadHandler>
|
||||||
auto
|
typename async_completion<
|
||||||
stream<NextLayer>::async_read_frame(frame_info& fi,
|
ReadHandler, void(error_code)>::result_type
|
||||||
|
stream<NextLayer>::
|
||||||
|
async_read_frame(frame_info& fi,
|
||||||
Streambuf& streambuf, ReadHandler&& handler)
|
Streambuf& streambuf, ReadHandler&& handler)
|
||||||
{
|
{
|
||||||
static_assert(beast::is_Streambuf<Streambuf>::value,
|
static_assert(beast::is_Streambuf<Streambuf>::value,
|
||||||
@@ -537,8 +549,8 @@ stream<NextLayer>::async_read_frame(frame_info& fi,
|
|||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
template<class ConstBufferSequence>
|
template<class ConstBufferSequence>
|
||||||
void
|
void
|
||||||
stream<NextLayer>::write(
|
stream<NextLayer>::
|
||||||
ConstBufferSequence const& bs, error_code& ec)
|
write(ConstBufferSequence const& bs, error_code& ec)
|
||||||
{
|
{
|
||||||
static_assert(beast::is_ConstBufferSequence<
|
static_assert(beast::is_ConstBufferSequence<
|
||||||
ConstBufferSequence>::value,
|
ConstBufferSequence>::value,
|
||||||
@@ -563,9 +575,10 @@ stream<NextLayer>::write(
|
|||||||
|
|
||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
template<class ConstBufferSequence, class WriteHandler>
|
template<class ConstBufferSequence, class WriteHandler>
|
||||||
auto
|
typename async_completion<
|
||||||
stream<NextLayer>::async_write(
|
WriteHandler, void(error_code)>::result_type
|
||||||
ConstBufferSequence const& bs, WriteHandler&& handler)
|
stream<NextLayer>::
|
||||||
|
async_write(ConstBufferSequence const& bs, WriteHandler&& handler)
|
||||||
{
|
{
|
||||||
static_assert(beast::is_ConstBufferSequence<
|
static_assert(beast::is_ConstBufferSequence<
|
||||||
ConstBufferSequence>::value,
|
ConstBufferSequence>::value,
|
||||||
@@ -580,8 +593,8 @@ stream<NextLayer>::async_write(
|
|||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
template<class ConstBufferSequence>
|
template<class ConstBufferSequence>
|
||||||
void
|
void
|
||||||
stream<NextLayer>::write_frame(bool fin,
|
stream<NextLayer>::
|
||||||
ConstBufferSequence const& bs, error_code& ec)
|
write_frame(bool fin, ConstBufferSequence const& bs, error_code& ec)
|
||||||
{
|
{
|
||||||
static_assert(beast::is_ConstBufferSequence<
|
static_assert(beast::is_ConstBufferSequence<
|
||||||
ConstBufferSequence>::value,
|
ConstBufferSequence>::value,
|
||||||
@@ -656,8 +669,10 @@ stream<NextLayer>::write_frame(bool fin,
|
|||||||
|
|
||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
template<class ConstBufferSequence, class WriteHandler>
|
template<class ConstBufferSequence, class WriteHandler>
|
||||||
auto
|
typename async_completion<
|
||||||
stream<NextLayer>::async_write_frame(bool fin,
|
WriteHandler, void(error_code)>::result_type
|
||||||
|
stream<NextLayer>::
|
||||||
|
async_write_frame(bool fin,
|
||||||
ConstBufferSequence const& bs, WriteHandler&& handler)
|
ConstBufferSequence const& bs, WriteHandler&& handler)
|
||||||
{
|
{
|
||||||
static_assert(beast::is_ConstBufferSequence<
|
static_assert(beast::is_ConstBufferSequence<
|
||||||
@@ -676,7 +691,8 @@ stream<NextLayer>::async_write_frame(bool fin,
|
|||||||
|
|
||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
http::request<http::empty_body>
|
http::request<http::empty_body>
|
||||||
stream<NextLayer>::build_request(boost::string_ref const& host,
|
stream<NextLayer>::
|
||||||
|
build_request(boost::string_ref const& host,
|
||||||
boost::string_ref const& resource, std::string& key)
|
boost::string_ref const& resource, std::string& key)
|
||||||
{
|
{
|
||||||
http::request<http::empty_body> req;
|
http::request<http::empty_body> req;
|
||||||
@@ -696,11 +712,11 @@ stream<NextLayer>::build_request(boost::string_ref const& host,
|
|||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
template<class Body, class Headers>
|
template<class Body, class Headers>
|
||||||
http::response<http::string_body>
|
http::response<http::string_body>
|
||||||
stream<NextLayer>::build_response(
|
stream<NextLayer>::
|
||||||
http::message<true, Body, Headers> const& req)
|
build_response(http::message<true, Body, Headers> const& req)
|
||||||
{
|
{
|
||||||
auto err =
|
auto err =
|
||||||
[&](auto const& text)
|
[&](std::string const& text)
|
||||||
{
|
{
|
||||||
http::response<http::string_body> resp(
|
http::response<http::string_body> resp(
|
||||||
{400, http::reason_string(400), req.version});
|
{400, http::reason_string(400), req.version});
|
||||||
@@ -748,9 +764,9 @@ stream<NextLayer>::build_response(
|
|||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
template<class Body, class Headers>
|
template<class Body, class Headers>
|
||||||
void
|
void
|
||||||
stream<NextLayer>::do_response(
|
stream<NextLayer>::
|
||||||
http::message<false, Body, Headers> const& resp,
|
do_response(http::message<false, Body, Headers> const& resp,
|
||||||
boost::string_ref const& key, error_code& ec)
|
boost::string_ref const& key, error_code& ec)
|
||||||
{
|
{
|
||||||
// VFALCO Review these error codes
|
// VFALCO Review these error codes
|
||||||
auto fail = [&]{ ec = error::response_failed; };
|
auto fail = [&]{ ec = error::response_failed; };
|
||||||
@@ -771,9 +787,9 @@ stream<NextLayer>::do_response(
|
|||||||
|
|
||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
void
|
void
|
||||||
stream<NextLayer>::do_read_fh(
|
stream<NextLayer>::
|
||||||
detail::frame_streambuf& fb,
|
do_read_fh(detail::frame_streambuf& fb,
|
||||||
close_code& code, error_code& ec)
|
close_code& code, error_code& ec)
|
||||||
{
|
{
|
||||||
fb.commit(boost::asio::read(
|
fb.commit(boost::asio::read(
|
||||||
stream_, fb.prepare(2), ec));
|
stream_, fb.prepare(2), ec));
|
||||||
@@ -61,7 +61,7 @@ public:
|
|||||||
error_code ec, std::size_t, bool again = true);
|
error_code ec, std::size_t, bool again = true);
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_allocate(std::size_t size,
|
void* asio_handler_allocate(std::size_t size,
|
||||||
teardown_tcp_op* op)
|
teardown_tcp_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -69,7 +69,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_deallocate(void* p,
|
void asio_handler_deallocate(void* p,
|
||||||
std::size_t size, teardown_tcp_op* op)
|
std::size_t size, teardown_tcp_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -77,14 +77,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_is_continuation(teardown_tcp_op* op)
|
bool asio_handler_is_continuation(teardown_tcp_op* op)
|
||||||
{
|
{
|
||||||
return op->d_->cont;
|
return op->d_->cont;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Function>
|
template <class Function>
|
||||||
friend
|
friend
|
||||||
auto asio_handler_invoke(Function&& f,
|
void asio_handler_invoke(Function&& f,
|
||||||
teardown_tcp_op* op)
|
teardown_tcp_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_invoke_helpers::
|
return boost_asio_handler_invoke_helpers::
|
||||||
@@ -160,8 +160,8 @@ async_teardown(
|
|||||||
static_assert(beast::is_Handler<
|
static_assert(beast::is_Handler<
|
||||||
TeardownHandler, void(error_code)>::value,
|
TeardownHandler, void(error_code)>::value,
|
||||||
"TeardownHandler requirements not met");
|
"TeardownHandler requirements not met");
|
||||||
detail::teardown_tcp_op<std::decay_t<
|
detail::teardown_tcp_op<typename std::decay<
|
||||||
TeardownHandler>>{std::forward<
|
TeardownHandler>::type>{std::forward<
|
||||||
TeardownHandler>(handler), socket};
|
TeardownHandler>(handler), socket};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ public:
|
|||||||
std::size_t bytes_transferred, bool again = true);
|
std::size_t bytes_transferred, bool again = true);
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_allocate(
|
void* asio_handler_allocate(
|
||||||
std::size_t size, write_frame_op* op)
|
std::size_t size, write_frame_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -121,7 +121,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_deallocate(
|
void asio_handler_deallocate(
|
||||||
void* p, std::size_t size, write_frame_op* op)
|
void* p, std::size_t size, write_frame_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -129,14 +129,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_is_continuation(write_frame_op* op)
|
bool asio_handler_is_continuation(write_frame_op* op)
|
||||||
{
|
{
|
||||||
return op->d_->cont;
|
return op->d_->cont;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Function>
|
template <class Function>
|
||||||
friend
|
friend
|
||||||
auto asio_handler_invoke(Function&& f, write_frame_op* op)
|
void asio_handler_invoke(Function&& f, write_frame_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_invoke_helpers::
|
return boost_asio_handler_invoke_helpers::
|
||||||
invoke(f, op->d_->h);
|
invoke(f, op->d_->h);
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public:
|
|||||||
void operator()(error_code ec, bool again = true);
|
void operator()(error_code ec, bool again = true);
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_allocate(
|
void* asio_handler_allocate(
|
||||||
std::size_t size, write_op* op)
|
std::size_t size, write_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -78,7 +78,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_deallocate(
|
void asio_handler_deallocate(
|
||||||
void* p, std::size_t size, write_op* op)
|
void* p, std::size_t size, write_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_alloc_helpers::
|
return boost_asio_handler_alloc_helpers::
|
||||||
@@ -86,14 +86,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
auto asio_handler_is_continuation(write_op* op)
|
bool asio_handler_is_continuation(write_op* op)
|
||||||
{
|
{
|
||||||
return op->d_->cont;
|
return op->d_->cont;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Function>
|
template <class Function>
|
||||||
friend
|
friend
|
||||||
auto asio_handler_invoke(Function&& f, write_op* op)
|
void asio_handler_invoke(Function&& f, write_op* op)
|
||||||
{
|
{
|
||||||
return boost_asio_handler_invoke_helpers::
|
return boost_asio_handler_invoke_helpers::
|
||||||
invoke(f, op->d_->h);
|
invoke(f, op->d_->h);
|
||||||
|
|||||||
@@ -99,12 +99,12 @@ using decorate = implementation_defined;
|
|||||||
#else
|
#else
|
||||||
template<class Decorator>
|
template<class Decorator>
|
||||||
inline
|
inline
|
||||||
auto
|
detail::decorator_type
|
||||||
decorate(Decorator&& d)
|
decorate(Decorator&& d)
|
||||||
{
|
{
|
||||||
return std::make_unique<detail::decorator<
|
return detail::decorator_type{new
|
||||||
std::decay_t<Decorator>>>(
|
detail::decorator<typename std::decay<Decorator>::type>{
|
||||||
std::forward<Decorator>(d));
|
std::forward<Decorator>(d)}};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include <beast/websocket/option.hpp>
|
#include <beast/websocket/option.hpp>
|
||||||
#include <beast/websocket/detail/stream_base.hpp>
|
#include <beast/websocket/detail/stream_base.hpp>
|
||||||
#include <beast/streambuf_readstream.hpp>
|
#include <beast/streambuf_readstream.hpp>
|
||||||
|
#include <beast/async_completion.hpp>
|
||||||
#include <beast/http/message.hpp>
|
#include <beast/http/message.hpp>
|
||||||
#include <beast/http/string_body.hpp>
|
#include <beast/http/string_body.hpp>
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
@@ -85,7 +86,7 @@ class stream : public detail::stream_base
|
|||||||
public:
|
public:
|
||||||
/// The type of the next layer.
|
/// The type of the next layer.
|
||||||
using next_layer_type =
|
using next_layer_type =
|
||||||
std::remove_reference_t<NextLayer>;
|
typename std::remove_reference<NextLayer>::type;
|
||||||
|
|
||||||
/// The type of the lowest layer.
|
/// The type of the lowest layer.
|
||||||
using lowest_layer_type =
|
using lowest_layer_type =
|
||||||
@@ -365,7 +366,8 @@ public:
|
|||||||
manner equivalent to using boost::asio::io_service::post().
|
manner equivalent to using boost::asio::io_service::post().
|
||||||
*/
|
*/
|
||||||
template<class AcceptHandler>
|
template<class AcceptHandler>
|
||||||
auto
|
typename async_completion<
|
||||||
|
AcceptHandler, void(error_code)>::result_type
|
||||||
async_accept(AcceptHandler&& handler);
|
async_accept(AcceptHandler&& handler);
|
||||||
|
|
||||||
/** Read and respond to a WebSocket HTTP Upgrade request.
|
/** Read and respond to a WebSocket HTTP Upgrade request.
|
||||||
@@ -465,7 +467,8 @@ public:
|
|||||||
manner equivalent to using boost::asio::io_service::post().
|
manner equivalent to using boost::asio::io_service::post().
|
||||||
*/
|
*/
|
||||||
template<class ConstBufferSequence, class AcceptHandler>
|
template<class ConstBufferSequence, class AcceptHandler>
|
||||||
auto
|
typename async_completion<
|
||||||
|
AcceptHandler, void(error_code)>::result_type
|
||||||
async_accept(ConstBufferSequence const& buffers,
|
async_accept(ConstBufferSequence const& buffers,
|
||||||
AcceptHandler&& handler);
|
AcceptHandler&& handler);
|
||||||
|
|
||||||
@@ -560,7 +563,8 @@ public:
|
|||||||
manner equivalent to using boost::asio::io_service::post().
|
manner equivalent to using boost::asio::io_service::post().
|
||||||
*/
|
*/
|
||||||
template<class Body, class Headers, class AcceptHandler>
|
template<class Body, class Headers, class AcceptHandler>
|
||||||
auto
|
typename async_completion<
|
||||||
|
AcceptHandler, void(error_code)>::result_type
|
||||||
async_accept(http::message<true,
|
async_accept(http::message<true,
|
||||||
Body, Headers> const& request, AcceptHandler&& handler);
|
Body, Headers> const& request, AcceptHandler&& handler);
|
||||||
|
|
||||||
@@ -666,7 +670,8 @@ public:
|
|||||||
manner equivalent to using boost::asio::io_service::post().
|
manner equivalent to using boost::asio::io_service::post().
|
||||||
*/
|
*/
|
||||||
template<class HandshakeHandler>
|
template<class HandshakeHandler>
|
||||||
auto
|
typename async_completion<
|
||||||
|
HandshakeHandler, void(error_code)>::result_type
|
||||||
async_handshake(boost::string_ref const& host,
|
async_handshake(boost::string_ref const& host,
|
||||||
boost::string_ref const& resource, HandshakeHandler&& h);
|
boost::string_ref const& resource, HandshakeHandler&& h);
|
||||||
|
|
||||||
@@ -745,7 +750,8 @@ public:
|
|||||||
manner equivalent to using boost::asio::io_service::post().
|
manner equivalent to using boost::asio::io_service::post().
|
||||||
*/
|
*/
|
||||||
template<class CloseHandler>
|
template<class CloseHandler>
|
||||||
auto
|
typename async_completion<
|
||||||
|
CloseHandler, void(error_code)>::result_type
|
||||||
async_close(close_reason const& cr, CloseHandler&& handler);
|
async_close(close_reason const& cr, CloseHandler&& handler);
|
||||||
|
|
||||||
/** Read a message.
|
/** Read a message.
|
||||||
@@ -829,7 +835,8 @@ public:
|
|||||||
#if GENERATING_DOCS
|
#if GENERATING_DOCS
|
||||||
void_or_deduced
|
void_or_deduced
|
||||||
#else
|
#else
|
||||||
auto
|
typename async_completion<
|
||||||
|
ReadHandler, void(error_code)>::result_type
|
||||||
#endif
|
#endif
|
||||||
async_read(opcode& op,
|
async_read(opcode& op,
|
||||||
Streambuf& streambuf, ReadHandler&& handler);
|
Streambuf& streambuf, ReadHandler&& handler);
|
||||||
@@ -938,7 +945,8 @@ public:
|
|||||||
manner equivalent to using boost::asio::io_service::post().
|
manner equivalent to using boost::asio::io_service::post().
|
||||||
*/
|
*/
|
||||||
template<class Streambuf, class ReadHandler>
|
template<class Streambuf, class ReadHandler>
|
||||||
auto
|
typename async_completion<
|
||||||
|
ReadHandler, void(error_code)>::result_type
|
||||||
async_read_frame(frame_info& fi,
|
async_read_frame(frame_info& fi,
|
||||||
Streambuf& streambuf, ReadHandler&& handler);
|
Streambuf& streambuf, ReadHandler&& handler);
|
||||||
|
|
||||||
@@ -1041,7 +1049,8 @@ public:
|
|||||||
#if GENERATING_DOCS
|
#if GENERATING_DOCS
|
||||||
void_or_deduced
|
void_or_deduced
|
||||||
#else
|
#else
|
||||||
auto
|
typename async_completion<
|
||||||
|
WriteHandler, void(error_code)>::result_type
|
||||||
#endif
|
#endif
|
||||||
async_write(ConstBufferSequence const& buffers,
|
async_write(ConstBufferSequence const& buffers,
|
||||||
WriteHandler&& handler);
|
WriteHandler&& handler);
|
||||||
@@ -1140,7 +1149,8 @@ public:
|
|||||||
); @endcode
|
); @endcode
|
||||||
*/
|
*/
|
||||||
template<class ConstBufferSequence, class WriteHandler>
|
template<class ConstBufferSequence, class WriteHandler>
|
||||||
auto
|
typename async_completion<
|
||||||
|
WriteHandler, void(error_code)>::result_type
|
||||||
async_write_frame(bool fin,
|
async_write_frame(bool fin,
|
||||||
ConstBufferSequence const& buffers, WriteHandler&& handler);
|
ConstBufferSequence const& buffers, WriteHandler&& handler);
|
||||||
|
|
||||||
@@ -1176,6 +1186,6 @@ private:
|
|||||||
} // websocket
|
} // websocket
|
||||||
} // beast
|
} // beast
|
||||||
|
|
||||||
#include <beast/websocket/impl/socket.ipp>
|
#include <beast/websocket/impl/stream.ipp>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ unit-test http_tests :
|
|||||||
http/chunk_encode.cpp
|
http/chunk_encode.cpp
|
||||||
http/empty_body.cpp
|
http/empty_body.cpp
|
||||||
http/error.cpp
|
http/error.cpp
|
||||||
http/fields.cpp
|
|
||||||
http/headers.cpp
|
http/headers.cpp
|
||||||
http/message.cpp
|
http/message.cpp
|
||||||
http/method.cpp
|
http/method.cpp
|
||||||
|
|||||||
@@ -21,6 +21,13 @@ namespace test {
|
|||||||
class buffer_cat_test : public detail::unit_test::suite
|
class buffer_cat_test : public detail::unit_test::suite
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
template< class Iterator >
|
||||||
|
static
|
||||||
|
std::reverse_iterator<Iterator>
|
||||||
|
make_reverse_iterator( Iterator i )
|
||||||
|
{
|
||||||
|
return std::reverse_iterator<Iterator>(i);
|
||||||
|
}
|
||||||
|
|
||||||
void testBufferCat()
|
void testBufferCat()
|
||||||
{
|
{
|
||||||
@@ -43,8 +50,8 @@ public:
|
|||||||
b1, b2, b3, b4, b5, b6);
|
b1, b2, b3, b4, b5, b6);
|
||||||
expect(buffer_size(bs) == 10);
|
expect(buffer_size(bs) == 10);
|
||||||
std::vector<const_buffer> v;
|
std::vector<const_buffer> v;
|
||||||
for(auto iter = std::make_reverse_iterator(bs.end());
|
for(auto iter = make_reverse_iterator(bs.end());
|
||||||
iter != std::make_reverse_iterator(bs.begin()); ++iter)
|
iter != make_reverse_iterator(bs.begin()); ++iter)
|
||||||
v.emplace_back(*iter);
|
v.emplace_back(*iter);
|
||||||
expect(buffer_size(bs) == 10);
|
expect(buffer_size(bs) == 10);
|
||||||
decltype(bs) bs2(bs);
|
decltype(bs) bs2(bs);
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright (c) 2013-2016 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)
|
|
||||||
//
|
|
||||||
|
|
||||||
// Test that header file is self-contained.
|
|
||||||
#include <beast/http/fields.hpp>
|
|
||||||
Reference in New Issue
Block a user