Update for Net-TS Asio (API Change):

fix #769

The following classes are removed:

* handler_type
* async_result
* async_completion
* is_dynamic_buffer
* is_const_buffer_sequence
* is_mutable_buffer_sequence
* handler_alloc

Actions Required:

* Use BOOST_ASIO_HANDLER_TYPE instead of handler_type
* Use BOOST_ASIO_INITFN_RESULT_TYPE instead of async_result
* Use boost::asio::async_completion
* Use boost::asio::is_dynamic_buffer
* Use boost::asio::is_const_buffer_sequence
* Use boost::asio::is_mutable_buffer_sequence
* boost::asio::associated_allocator_t replaces handler_alloc
This commit is contained in:
Vinnie Falco committed 2017-10-23 17:11:27 -07:00
1 parent 9dc9ca13b9
commit 3a28e999af
173 files changed
+3214 -4138

No files matched your search

+10 -14
View File
@@ -103,14 +103,13 @@ basic_parser<isRequest, Derived>::
put(ConstBufferSequence const& buffers,
error_code& ec)
{
static_assert(is_const_buffer_sequence<
static_assert(boost::asio::is_const_buffer_sequence<
ConstBufferSequence>::value,
"ConstBufferSequence requirements not met");
using boost::asio::buffer_cast;
using boost::asio::buffer_copy;
using boost::asio::buffer_size;
auto const p = buffers.begin();
auto const last = buffers.end();
auto const p = boost::asio::buffer_sequence_begin(buffers);
auto const last = boost::asio::buffer_sequence_end(buffers);
if(p == last)
{
ec.assign(0, ec.category());
@@ -119,10 +118,7 @@ put(ConstBufferSequence const& buffers,
if(std::next(p) == last)
{
// single buffer
auto const b = *p;
return put(boost::asio::const_buffers_1{
buffer_cast<char const*>(b),
buffer_size(b)}, ec);
return put(boost::asio::const_buffer(*p), ec);
}
auto const size = buffer_size(buffers);
if(size <= max_stack_buffer)
@@ -136,21 +132,21 @@ put(ConstBufferSequence const& buffers,
// flatten
buffer_copy(boost::asio::buffer(
buf_.get(), buf_len_), buffers);
return put(boost::asio::const_buffers_1{
return put(boost::asio::const_buffer{
buf_.get(), buf_len_}, ec);
}
template<bool isRequest, class Derived>
std::size_t
basic_parser<isRequest, Derived>::
put(boost::asio::const_buffers_1 const& buffer,
put(boost::asio::const_buffer const& buffer,
error_code& ec)
{
BOOST_ASSERT(state_ != state::complete);
using boost::asio::buffer_size;
auto p = boost::asio::buffer_cast<
char const*>(*buffer.begin());
auto n = buffer_size(*buffer.begin());
auto p = reinterpret_cast<
char const*>(buffer.data());
auto n = buffer.size();
auto const p0 = p;
auto const p1 = p0 + n;
ec.assign(0, ec.category());
@@ -324,7 +320,7 @@ put_from_stack(std::size_t size,
using boost::asio::buffer;
using boost::asio::buffer_copy;
buffer_copy(buffer(buf, sizeof(buf)), buffers);
return put(boost::asio::const_buffers_1{
return put(boost::asio::const_buffer{
buf, size}, ec);
}
@@ -24,7 +24,7 @@ chunk_header::
chunk_header(std::size_t size)
: view_(
size,
boost::asio::const_buffers_1{nullptr, 0},
boost::asio::const_buffer{nullptr, 0},
chunk_crlf{})
{
BOOST_ASSERT(size > 0);
@@ -37,7 +37,7 @@ chunk_header(
string_view extensions)
: view_(
size,
boost::asio::const_buffers_1{
boost::asio::const_buffer{
extensions.data(), extensions.size()},
chunk_crlf{})
{
@@ -90,7 +90,7 @@ chunk_body<ConstBufferSequence>::
chunk_body(ConstBufferSequence const& buffers)
: view_(
boost::asio::buffer_size(buffers),
boost::asio::const_buffers_1{nullptr, 0},
boost::asio::const_buffer{nullptr, 0},
chunk_crlf{},
buffers,
chunk_crlf{})
@@ -104,7 +104,7 @@ chunk_body(
string_view extensions)
: view_(
boost::asio::buffer_size(buffers),
boost::asio::const_buffers_1{
boost::asio::const_buffer{
extensions.data(), extensions.size()},
chunk_crlf{},
buffers,
+12 -12
View File
@@ -143,9 +143,9 @@ public:
};
using view_type = buffers_cat_view<
boost::asio::const_buffers_1,
boost::asio::const_buffers_1,
boost::asio::const_buffers_1,
boost::asio::const_buffer,
boost::asio::const_buffer,
boost::asio::const_buffer,
field_range,
chunk_crlf>;
@@ -178,9 +178,9 @@ reader(basic_fields const& f)
: f_(f)
{
view_.emplace(
boost::asio::const_buffers_1{nullptr, 0},
boost::asio::const_buffers_1{nullptr, 0},
boost::asio::const_buffers_1{nullptr, 0},
boost::asio::const_buffer{nullptr, 0},
boost::asio::const_buffer{nullptr, 0},
boost::asio::const_buffer{nullptr, 0},
field_range(f_.list_.begin(), f_.list_.end()),
chunk_crlf());
}
@@ -218,11 +218,11 @@ reader(basic_fields const& f,
buf_[10]= '\n';
view_.emplace(
boost::asio::const_buffers_1{sv.data(), sv.size()},
boost::asio::const_buffers_1{
boost::asio::const_buffer{sv.data(), sv.size()},
boost::asio::const_buffer{
f_.target_or_reason_.data(),
f_.target_or_reason_.size()},
boost::asio::const_buffers_1{buf_, 11},
boost::asio::const_buffer{buf_, 11},
field_range(f_.list_.begin(), f_.list_.end()),
chunk_crlf());
}
@@ -260,9 +260,9 @@ reader(basic_fields const& f,
sv = obsolete_reason(static_cast<status>(code));
view_.emplace(
boost::asio::const_buffers_1{buf_, 13},
boost::asio::const_buffers_1{sv.data(), sv.size()},
boost::asio::const_buffers_1{"\r\n", 2},
boost::asio::const_buffer{buf_, 13},
boost::asio::const_buffer{sv.data(), sv.size()},
boost::asio::const_buffer{"\r\n", 2},
field_range(f_.list_.begin(), f_.list_.end()),
chunk_crlf{});
}
@@ -12,15 +12,15 @@
#if BOOST_BEAST_USE_WIN32_FILE
#include <boost/beast/core/async_result.hpp>
#include <boost/beast/core/bind_handler.hpp>
#include <boost/beast/core/type_traits.hpp>
#include <boost/beast/core/detail/clamp.hpp>
#include <boost/beast/http/serializer.hpp>
#include <boost/asio/associated_allocator.hpp>
#include <boost/asio/associated_executor.hpp>
#include <boost/asio/async_result.hpp>
#include <boost/asio/basic_stream_socket.hpp>
#include <boost/asio/handler_alloc_hook.hpp>
#include <boost/asio/handler_continuation_hook.hpp>
#include <boost/asio/handler_invoke_hook.hpp>
#include <boost/asio/windows/overlapped_ptr.hpp>
#include <boost/make_unique.hpp>
#include <boost/smart_ptr/make_shared_array.hpp>
@@ -120,7 +120,7 @@ struct basic_file_body<file_win32>
public:
using const_buffers_type =
boost::asio::const_buffers_1;
boost::asio::const_buffer;
template<bool isRequest, class Fields>
reader(message<isRequest,
@@ -189,12 +189,10 @@ struct basic_file_body<file_win32>
error_code& ec)
{
std::size_t nwritten = 0;
for(boost::asio::const_buffer buffer : buffers)
for(auto buffer : beast::detail::buffers_range(buffers))
{
nwritten += body_.file_.write(
boost::asio::buffer_cast<void const*>(buffer),
boost::asio::buffer_size(buffer),
ec);
buffer.data(), buffer.size(), ec);
if(ec)
return nwritten;
}
@@ -360,6 +358,24 @@ public:
{
}
using allocator_type =
boost::asio::associated_allocator_t<Handler>;
allocator_type
get_allocator() const noexcept
{
return boost::asio::get_associated_allocator(h_);
}
using executor_type = boost::asio::associated_executor_t<
Handler, decltype(sock_.get_executor())>;
executor_type get_executor() const noexcept
{
return boost::asio::get_associated_executor(
h_, sock_.get_executor());
}
void
operator()();
@@ -368,24 +384,6 @@ public:
error_code ec,
std::size_t bytes_transferred = 0);
friend
void* asio_handler_allocate(
std::size_t size, write_some_win32_op* op)
{
using boost::asio::asio_handler_allocate;
return asio_handler_allocate(
size, std::addressof(op->h_));
}
friend
void asio_handler_deallocate(
void* p, std::size_t size, write_some_win32_op* op)
{
using boost::asio::asio_handler_deallocate;
asio_handler_deallocate(
p, size, std::addressof(op->h_));
}
friend
bool asio_handler_is_continuation(write_some_win32_op* op)
{
@@ -393,15 +391,6 @@ public:
return asio_handler_is_continuation(
std::addressof(op->h_));
}
template<class Function>
friend
void asio_handler_invoke(Function&& f, write_some_win32_op* op)
{
using boost::asio::asio_handler_invoke;
asio_handler_invoke(
f, std::addressof(op->h_));
}
};
template<
@@ -431,7 +420,7 @@ operator()()
r.body_.last_ - r.pos_, sr_.limit())),
2147483646);
boost::asio::windows::overlapped_ptr overlapped{
sock_.get_io_service(), *this};
sock_.get_executor().context(), *this};
auto& ov = *overlapped.get();
ov.Offset = lowPart(r.pos_);
ov.OffsetHigh = highPart(r.pos_);
@@ -567,21 +556,20 @@ template<
class Protocol,
bool isRequest, class Fields,
class WriteHandler>
async_return_type<
WriteHandler,
void(error_code, std::size_t)>
BOOST_ASIO_INITFN_RESULT_TYPE(
WriteHandler, void(error_code, std::size_t))
async_write_some(
boost::asio::basic_stream_socket<Protocol>& sock,
serializer<isRequest,
basic_file_body<file_win32>, Fields>& sr,
WriteHandler&& handler)
{
async_completion<WriteHandler,
boost::asio::async_completion<WriteHandler,
void(error_code)> init{handler};
detail::write_some_win32_op<
Protocol,
handler_type<WriteHandler,
void(error_code, std::size_t)>,
BOOST_ASIO_HANDLER_TYPE(WriteHandler,
void(error_code, std::size_t)),
isRequest, Fields>{
init.completion_handler, sock, sr}();
return init.result.get();
+103 -118
View File
@@ -18,9 +18,10 @@
#include <boost/beast/core/handler_ptr.hpp>
#include <boost/beast/core/read_size.hpp>
#include <boost/beast/core/type_traits.hpp>
#include <boost/asio/handler_alloc_hook.hpp>
#include <boost/asio/associated_allocator.hpp>
#include <boost/asio/associated_executor.hpp>
#include <boost/asio/handler_continuation_hook.hpp>
#include <boost/asio/handler_invoke_hook.hpp>
#include <boost/asio/post.hpp>
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/optional.hpp>
@@ -61,29 +62,29 @@ public:
{
}
using allocator_type =
boost::asio::associated_allocator_t<Handler>;
allocator_type
get_allocator() const noexcept
{
return boost::asio::get_associated_allocator(h_);
}
using executor_type = boost::asio::associated_executor_t<
Handler, decltype(s_.get_executor())>;
executor_type get_executor() const noexcept
{
return boost::asio::get_associated_executor(
h_, s_.get_executor());
}
void
operator()(
error_code ec = {},
std::size_t bytes_transferred = 0);
friend
void* asio_handler_allocate(
std::size_t size, read_some_op* op)
{
using boost::asio::asio_handler_allocate;
return asio_handler_allocate(
size, std::addressof(op->h_));
}
friend
void asio_handler_deallocate(
void* p, std::size_t size, read_some_op* op)
{
using boost::asio::asio_handler_deallocate;
asio_handler_deallocate(
p, size, std::addressof(op->h_));
}
friend
bool asio_handler_is_continuation(read_some_op* op)
{
@@ -92,15 +93,6 @@ public:
asio_handler_is_continuation(
std::addressof(op->h_));
}
template<class Function>
friend
void asio_handler_invoke(Function&& f, read_some_op* op)
{
using boost::asio::asio_handler_invoke;
asio_handler_invoke(
f, std::addressof(op->h_));
}
};
template<class Stream, class DynamicBuffer,
@@ -170,7 +162,8 @@ operator()(
if(state_ >= 2)
goto upcall;
state_ = 3;
return s_.get_io_service().post(
return boost::asio::post(
s_.get_executor(),
bind_handler(std::move(*this), ec, 0));
case 3:
@@ -231,29 +224,29 @@ public:
{
}
using allocator_type =
boost::asio::associated_allocator_t<Handler>;
allocator_type
get_allocator() const noexcept
{
return boost::asio::get_associated_allocator(h_);
}
using executor_type = boost::asio::associated_executor_t<
Handler, decltype(s_.get_executor())>;
executor_type get_executor() const noexcept
{
return boost::asio::get_associated_executor(
h_, s_.get_executor());
}
void
operator()(
error_code ec = {},
std::size_t bytes_transferred = 0);
friend
void* asio_handler_allocate(
std::size_t size, read_op* op)
{
using boost::asio::asio_handler_allocate;
return asio_handler_allocate(
size, std::addressof(op->h_));
}
friend
void asio_handler_deallocate(
void* p, std::size_t size, read_op* op)
{
using boost::asio::asio_handler_deallocate;
asio_handler_deallocate(
p, size, std::addressof(op->h_));
}
friend
bool asio_handler_is_continuation(read_op* op)
{
@@ -262,15 +255,6 @@ public:
asio_handler_is_continuation(
std::addressof(op->h_));
}
template<class Function>
friend
void asio_handler_invoke(Function&& f, read_op* op)
{
using boost::asio::asio_handler_invoke;
asio_handler_invoke(
f, std::addressof(op->h_));
}
};
template<class Stream, class DynamicBuffer,
@@ -289,7 +273,8 @@ operator()(
if(Condition{}(p_))
{
state_ = 1;
return s_.get_io_service().post(
return boost::asio::post(
s_.get_executor(),
bind_handler(std::move(*this), ec));
}
state_ = 2;
@@ -361,29 +346,29 @@ public:
{
}
using allocator_type =
boost::asio::associated_allocator_t<Handler>;
allocator_type
get_allocator() const noexcept
{
return boost::asio::get_associated_allocator(d_.handler());
}
using executor_type = boost::asio::associated_executor_t<
Handler, decltype(d_->s.get_executor())>;
executor_type get_executor() const noexcept
{
return boost::asio::get_associated_executor(
d_.handler(), d_->s.get_executor());
}
void
operator()(
error_code ec = {},
std::size_t bytes_transferred = 0);
friend
void* asio_handler_allocate(
std::size_t size, read_msg_op* op)
{
using boost::asio::asio_handler_allocate;
return asio_handler_allocate(
size, std::addressof(op->d_.handler()));
}
friend
void asio_handler_deallocate(
void* p, std::size_t size, read_msg_op* op)
{
using boost::asio::asio_handler_deallocate;
asio_handler_deallocate(
p, size, std::addressof(op->d_.handler()));
}
friend
bool asio_handler_is_continuation(read_msg_op* op)
{
@@ -392,15 +377,6 @@ public:
asio_handler_is_continuation(
std::addressof(op->d_.handler()));
}
template<class Function>
friend
void asio_handler_invoke(Function&& f, read_msg_op* op)
{
using boost::asio::asio_handler_invoke;
asio_handler_invoke(
f, std::addressof(op->d_.handler()));
}
};
template<class Stream, class DynamicBuffer,
@@ -458,7 +434,8 @@ read_some(
{
static_assert(is_sync_read_stream<SyncReadStream>::value,
"SyncReadStream requirements not met");
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
static_assert(
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
"DynamicBuffer requirements not met");
BOOST_ASSERT(! parser.is_done());
error_code ec;
@@ -482,7 +459,8 @@ read_some(
{
static_assert(is_sync_read_stream<SyncReadStream>::value,
"SyncReadStream requirements not met");
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
static_assert(
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
"DynamicBuffer requirements not met");
BOOST_ASSERT(! parser.is_done());
std::size_t bytes_transferred = 0;
@@ -541,8 +519,8 @@ template<
class DynamicBuffer,
bool isRequest, class Derived,
class ReadHandler>
async_return_type<
ReadHandler, void(error_code, std::size_t)>
BOOST_ASIO_INITFN_RESULT_TYPE(
ReadHandler, void(error_code, std::size_t))
async_read_some(
AsyncReadStream& stream,
DynamicBuffer& buffer,
@@ -551,13 +529,14 @@ async_read_some(
{
static_assert(is_async_read_stream<AsyncReadStream>::value,
"AsyncReadStream requirements not met");
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
static_assert(
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
"DynamicBuffer requirements not met");
BOOST_ASSERT(! parser.is_done());
async_completion<ReadHandler, void(error_code)> init{handler};
boost::asio::async_completion<ReadHandler, void(error_code)> init{handler};
detail::read_some_op<AsyncReadStream,
DynamicBuffer, isRequest, Derived, handler_type<
ReadHandler, void(error_code, std::size_t)>>{
DynamicBuffer, isRequest, Derived, BOOST_ASIO_HANDLER_TYPE(
ReadHandler, void(error_code, std::size_t))>{
init.completion_handler, stream, buffer, parser}();
return init.result.get();
}
@@ -576,7 +555,8 @@ read_header(
{
static_assert(is_sync_read_stream<SyncReadStream>::value,
"SyncReadStream requirements not met");
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
static_assert(
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
"DynamicBuffer requirements not met");
error_code ec;
auto const bytes_transferred =
@@ -599,7 +579,8 @@ read_header(
{
static_assert(is_sync_read_stream<SyncReadStream>::value,
"SyncReadStream requirements not met");
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
static_assert(
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
"DynamicBuffer requirements not met");
parser.eager(false);
if(parser.is_header_done())
@@ -624,9 +605,8 @@ template<
class DynamicBuffer,
bool isRequest, class Derived,
class ReadHandler>
async_return_type<
ReadHandler,
void(error_code, std::size_t)>
BOOST_ASIO_INITFN_RESULT_TYPE(
ReadHandler, void(error_code, std::size_t))
async_read_header(
AsyncReadStream& stream,
DynamicBuffer& buffer,
@@ -635,14 +615,15 @@ async_read_header(
{
static_assert(is_async_read_stream<AsyncReadStream>::value,
"AsyncReadStream requirements not met");
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
static_assert(
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
"DynamicBuffer requirements not met");
parser.eager(false);
async_completion<ReadHandler,
boost::asio::async_completion<ReadHandler,
void(error_code, std::size_t)> init{handler};
detail::read_op<AsyncReadStream, DynamicBuffer,
isRequest, Derived, detail::parser_is_header_done,
handler_type<ReadHandler, void(error_code, std::size_t)>>{
BOOST_ASIO_HANDLER_TYPE(ReadHandler, void(error_code, std::size_t))>{
init.completion_handler, stream, buffer, parser}();
return init.result.get();
}
@@ -661,7 +642,8 @@ read(
{
static_assert(is_sync_read_stream<SyncReadStream>::value,
"SyncReadStream requirements not met");
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
static_assert(
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
"DynamicBuffer requirements not met");
error_code ec;
auto const bytes_transferred =
@@ -684,7 +666,8 @@ read(
{
static_assert(is_sync_read_stream<SyncReadStream>::value,
"SyncReadStream requirements not met");
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
static_assert(
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
"DynamicBuffer requirements not met");
parser.eager(true);
if(parser.is_done())
@@ -709,9 +692,8 @@ template<
class DynamicBuffer,
bool isRequest, class Derived,
class ReadHandler>
async_return_type<
ReadHandler,
void(error_code, std::size_t)>
BOOST_ASIO_INITFN_RESULT_TYPE(
ReadHandler, void(error_code, std::size_t))
async_read(
AsyncReadStream& stream,
DynamicBuffer& buffer,
@@ -720,15 +702,16 @@ async_read(
{
static_assert(is_async_read_stream<AsyncReadStream>::value,
"AsyncReadStream requirements not met");
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
static_assert(
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
"DynamicBuffer requirements not met");
parser.eager(true);
async_completion<
boost::asio::async_completion<
ReadHandler,
void(error_code, std::size_t)> init{handler};
detail::read_op<AsyncReadStream, DynamicBuffer,
isRequest, Derived, detail::parser_is_done,
handler_type<ReadHandler, void(error_code, std::size_t)>>{
BOOST_ASIO_HANDLER_TYPE(ReadHandler, void(error_code, std::size_t))>{
init.completion_handler, stream, buffer, parser}();
return init.result.get();
}
@@ -747,7 +730,8 @@ read(
{
static_assert(is_sync_read_stream<SyncReadStream>::value,
"SyncReadStream requirements not met");
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
static_assert(
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
"DynamicBuffer requirements not met");
static_assert(is_body<Body>::value,
"Body requirements not met");
@@ -774,7 +758,8 @@ read(
{
static_assert(is_sync_read_stream<SyncReadStream>::value,
"SyncReadStream requirements not met");
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
static_assert(
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
"DynamicBuffer requirements not met");
static_assert(is_body<Body>::value,
"Body requirements not met");
@@ -795,9 +780,8 @@ template<
class DynamicBuffer,
bool isRequest, class Body, class Allocator,
class ReadHandler>
async_return_type<
ReadHandler,
void(error_code, std::size_t)>
BOOST_ASIO_INITFN_RESULT_TYPE(
ReadHandler, void(error_code, std::size_t))
async_read(
AsyncReadStream& stream,
DynamicBuffer& buffer,
@@ -806,21 +790,22 @@ async_read(
{
static_assert(is_async_read_stream<AsyncReadStream>::value,
"AsyncReadStream requirements not met");
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
static_assert(
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
"DynamicBuffer requirements not met");
static_assert(is_body<Body>::value,
"Body requirements not met");
static_assert(is_body_writer<Body>::value,
"BodyWriter requirements not met");
async_completion<
boost::asio::async_completion<
ReadHandler,
void(error_code, std::size_t)> init{handler};
detail::read_msg_op<
AsyncReadStream,
DynamicBuffer,
isRequest, Body, Allocator,
handler_type<ReadHandler,
void(error_code, std::size_t)>>{
BOOST_ASIO_HANDLER_TYPE(
ReadHandler, void(error_code, std::size_t))>{
init.completion_handler, stream, buffer, msg}();
return init.result.get();
}
+7 -7
View File
@@ -166,12 +166,12 @@ next(error_code& ec, Visit&& visit)
boost::in_place_init,
frd_->get(),
buffer_size(result->first),
boost::asio::const_buffers_1{nullptr, 0},
boost::asio::const_buffer{nullptr, 0},
chunk_crlf{},
result->first,
chunk_crlf{},
detail::chunk_last(),
boost::asio::const_buffers_1{nullptr, 0},
boost::asio::const_buffer{nullptr, 0},
chunk_crlf{});
goto go_all_c;
}
@@ -179,7 +179,7 @@ next(error_code& ec, Visit&& visit)
boost::in_place_init,
frd_->get(),
buffer_size(result->first),
boost::asio::const_buffers_1{nullptr, 0},
boost::asio::const_buffer{nullptr, 0},
chunk_crlf{},
result->first,
chunk_crlf{});
@@ -216,19 +216,19 @@ next(error_code& ec, Visit&& visit)
v_.template emplace<6>(
boost::in_place_init,
buffer_size(result->first),
boost::asio::const_buffers_1{nullptr, 0},
boost::asio::const_buffer{nullptr, 0},
chunk_crlf{},
result->first,
chunk_crlf{},
detail::chunk_last(),
boost::asio::const_buffers_1{nullptr, 0},
boost::asio::const_buffer{nullptr, 0},
chunk_crlf{});
goto go_body_final_c;
}
v_.template emplace<5>(
boost::in_place_init,
buffer_size(result->first),
boost::asio::const_buffers_1{nullptr, 0},
boost::asio::const_buffer{nullptr, 0},
chunk_crlf{},
result->first,
chunk_crlf{});
@@ -257,7 +257,7 @@ next(error_code& ec, Visit&& visit)
v_.template emplace<8>(
boost::in_place_init,
detail::chunk_last(),
boost::asio::const_buffers_1{nullptr, 0},
boost::asio::const_buffer{nullptr, 0},
chunk_crlf{});
s_ = do_final_c + 1;
BOOST_BEAST_FALLTHROUGH;
+89 -120
View File
@@ -16,9 +16,10 @@
#include <boost/beast/core/handler_ptr.hpp>
#include <boost/beast/core/type_traits.hpp>
#include <boost/beast/core/detail/config.hpp>
#include <boost/asio/handler_alloc_hook.hpp>
#include <boost/asio/associated_allocator.hpp>
#include <boost/asio/associated_executor.hpp>
#include <boost/asio/handler_continuation_hook.hpp>
#include <boost/asio/handler_invoke_hook.hpp>
#include <boost/asio/post.hpp>
#include <boost/asio/write.hpp>
#include <boost/optional.hpp>
#include <boost/throw_exception.hpp>
@@ -77,6 +78,24 @@ public:
{
}
using allocator_type =
boost::asio::associated_allocator_t<Handler>;
allocator_type
get_allocator() const noexcept
{
return boost::asio::get_associated_allocator(h_);
}
using executor_type = boost::asio::associated_executor_t<
Handler, decltype(s_.get_executor())>;
executor_type get_executor() const noexcept
{
return boost::asio::get_associated_executor(
h_, s_.get_executor());
}
void
operator()();
@@ -85,24 +104,6 @@ public:
error_code ec,
std::size_t bytes_transferred);
friend
void* asio_handler_allocate(
std::size_t size, write_some_op* op)
{
using boost::asio::asio_handler_allocate;
return asio_handler_allocate(
size, std::addressof(op->h_));
}
friend
void asio_handler_deallocate(
void* p, std::size_t size, write_some_op* op)
{
using boost::asio::asio_handler_deallocate;
asio_handler_deallocate(
p, size, std::addressof(op->h_));
}
friend
bool asio_handler_is_continuation(write_some_op* op)
{
@@ -110,14 +111,6 @@ public:
return asio_handler_is_continuation(
std::addressof(op->h_));
}
template<class Function>
friend
void asio_handler_invoke(Function&& f, write_some_op* op)
{
using boost::asio::asio_handler_invoke;
asio_handler_invoke(f, std::addressof(op->h_));
}
};
template<
@@ -136,7 +129,8 @@ operator()()
if(ec)
{
BOOST_ASSERT(! f.invoked);
return s_.get_io_service().post(
return boost::asio::post(
s_.get_executor(),
bind_handler(std::move(*this), ec, 0));
}
if(f.invoked)
@@ -148,7 +142,8 @@ operator()()
// What else could it be?
BOOST_ASSERT(sr_.is_done());
}
return s_.get_io_service().post(
return boost::asio::post(
s_.get_executor(),
bind_handler(std::move(*this), ec, 0));
}
@@ -218,29 +213,29 @@ public:
{
}
using allocator_type =
boost::asio::associated_allocator_t<Handler>;
allocator_type
get_allocator() const noexcept
{
return boost::asio::get_associated_allocator(h_);
}
using executor_type = boost::asio::associated_executor_t<
Handler, decltype(s_.get_executor())>;
executor_type get_executor() const noexcept
{
return boost::asio::get_associated_executor(
h_, s_.get_executor());
}
void
operator()(
error_code ec = {},
std::size_t bytes_transferred = 0);
friend
void* asio_handler_allocate(
std::size_t size, write_op* op)
{
using boost::asio::asio_handler_allocate;
return asio_handler_allocate(
size, std::addressof(op->h_));
}
friend
void asio_handler_deallocate(
void* p, std::size_t size, write_op* op)
{
using boost::asio::asio_handler_deallocate;
asio_handler_deallocate(
p, size, std::addressof(op->h_));
}
friend
bool asio_handler_is_continuation(write_op* op)
{
@@ -249,15 +244,6 @@ public:
asio_handler_is_continuation(
std::addressof(op->h_));
}
template<class Function>
friend
void asio_handler_invoke(Function&& f, write_op* op)
{
using boost::asio::asio_handler_invoke;
asio_handler_invoke(
f, std::addressof(op->h_));
}
};
template<
@@ -278,7 +264,8 @@ operator()(
if(Predicate{}(sr_))
{
state_ = 1;
return s_.get_io_service().post(
return boost::asio::post(
s_.get_executor(),
bind_handler(std::move(*this), ec, 0));
}
state_ = 2;
@@ -338,6 +325,24 @@ public:
{
}
using allocator_type =
boost::asio::associated_allocator_t<Handler>;
allocator_type
get_allocator() const noexcept
{
return boost::asio::get_associated_allocator(d_.handler());
}
using executor_type = boost::asio::associated_executor_t<
Handler, decltype(d_->s.get_executor())>;
executor_type get_executor() const noexcept
{
return boost::asio::get_associated_executor(
d_.handler(), d_->s.get_executor());
}
void
operator()();
@@ -345,24 +350,6 @@ public:
operator()(
error_code ec, std::size_t bytes_transferred);
friend
void* asio_handler_allocate(
std::size_t size, write_msg_op* op)
{
using boost::asio::asio_handler_allocate;
return asio_handler_allocate(
size, std::addressof(op->d_.handler()));
}
friend
void asio_handler_deallocate(
void* p, std::size_t size, write_msg_op* op)
{
using boost::asio::asio_handler_deallocate;
asio_handler_deallocate(
p, size, std::addressof(op->d_.handler()));
}
friend
bool asio_handler_is_continuation(write_msg_op* op)
{
@@ -370,15 +357,6 @@ public:
return asio_handler_is_continuation(
std::addressof(op->d_.handler()));
}
template<class Function>
friend
void asio_handler_invoke(Function&& f, write_msg_op* op)
{
using boost::asio::asio_handler_invoke;
asio_handler_invoke(
f, std::addressof(op->d_.handler()));
}
};
template<class Stream, class Handler,
@@ -483,21 +461,20 @@ template<
class AsyncWriteStream,
bool isRequest, class Body, class Fields,
class WriteHandler>
async_return_type<
WriteHandler,
void(error_code, std::size_t)>
BOOST_ASIO_INITFN_RESULT_TYPE(
WriteHandler, void(error_code, std::size_t))
async_write_some(
AsyncWriteStream& stream,
serializer<isRequest, Body, Fields>& sr,
WriteHandler&& handler)
{
async_completion<
boost::asio::async_completion<
WriteHandler,
void(error_code, std::size_t)> init{handler};
detail::write_some_op<
AsyncWriteStream,
handler_type<WriteHandler,
void(error_code, std::size_t)>,
BOOST_ASIO_HANDLER_TYPE(WriteHandler,
void(error_code, std::size_t)),
isRequest, Body, Fields>{
init.completion_handler, stream, sr}();
return init.result.get();
@@ -551,9 +528,8 @@ template<
class AsyncWriteStream,
bool isRequest, class Body, class Fields,
class WriteHandler>
async_return_type<
WriteHandler,
void(error_code, std::size_t)>
BOOST_ASIO_INITFN_RESULT_TYPE(
WriteHandler, void(error_code, std::size_t))
async_write_some(
AsyncWriteStream& stream,
serializer<isRequest, Body, Fields>& sr,
@@ -635,9 +611,8 @@ template<
class AsyncWriteStream,
bool isRequest, class Body, class Fields,
class WriteHandler>
async_return_type<
WriteHandler,
void(error_code, std::size_t)>
BOOST_ASIO_INITFN_RESULT_TYPE(
WriteHandler, void(error_code, std::size_t))
async_write_header(
AsyncWriteStream& stream,
serializer<isRequest, Body, Fields>& sr,
@@ -651,13 +626,13 @@ async_write_header(
static_assert(is_body_reader<Body>::value,
"BodyReader requirements not met");
sr.split(true);
async_completion<
boost::asio::async_completion<
WriteHandler,
void(error_code, std::size_t)> init{handler};
detail::write_op<
AsyncWriteStream,
handler_type<WriteHandler,
void(error_code, std::size_t)>,
BOOST_ASIO_HANDLER_TYPE(WriteHandler,
void(error_code, std::size_t)),
detail::serializer_is_header_done,
isRequest, Body, Fields>{
init.completion_handler, stream, sr}();
@@ -713,9 +688,8 @@ template<
class AsyncWriteStream,
bool isRequest, class Body, class Fields,
class WriteHandler>
async_return_type<
WriteHandler,
void(error_code, std::size_t)>
BOOST_ASIO_INITFN_RESULT_TYPE(
WriteHandler, void(error_code, std::size_t))
async_write(
AsyncWriteStream& stream,
serializer<isRequest, Body, Fields>& sr,
@@ -729,13 +703,13 @@ async_write(
static_assert(is_body_reader<Body>::value,
"BodyReader requirements not met");
sr.split(false);
async_completion<
boost::asio::async_completion<
WriteHandler,
void(error_code, std::size_t)> init{handler};
detail::write_op<
AsyncWriteStream,
handler_type<WriteHandler,
void(error_code, std::size_t)>,
BOOST_ASIO_HANDLER_TYPE(WriteHandler,
void(error_code, std::size_t)),
detail::serializer_is_done,
isRequest, Body, Fields>{
init.completion_handler, stream, sr}();
@@ -789,9 +763,8 @@ template<
class AsyncWriteStream,
bool isRequest, class Body, class Fields,
class WriteHandler>
async_return_type<
WriteHandler,
void(error_code, std::size_t)>
BOOST_ASIO_INITFN_RESULT_TYPE(
WriteHandler, void(error_code, std::size_t))
async_write(
AsyncWriteStream& stream,
message<isRequest, Body, Fields>& msg,
@@ -804,13 +777,13 @@ async_write(
"Body requirements not met");
static_assert(is_body_reader<Body>::value,
"BodyReader requirements not met");
async_completion<
boost::asio::async_completion<
WriteHandler,
void(error_code, std::size_t)> init{handler};
detail::write_msg_op<
AsyncWriteStream,
handler_type<WriteHandler,
void(error_code, std::size_t)>,
BOOST_ASIO_HANDLER_TYPE(WriteHandler,
void(error_code, std::size_t)),
isRequest, Body, Fields>{
init.completion_handler, stream, msg}();
return init.result.get();
@@ -843,17 +816,13 @@ public:
if(os_.fail())
return;
std::size_t bytes_transferred = 0;
using boost::asio::buffer_cast;
using boost::asio::buffer_size;
for(auto it = buffers.begin();
it != buffers.end(); ++it)
for(auto b : buffers_range(buffers))
{
boost::asio::const_buffer b = *it;
auto const n = buffer_size(b);
os_.write(buffer_cast<char const*>(b), n);
os_.write(reinterpret_cast<char const*>(
b.data()), b.size());
if(os_.fail())
return;
bytes_transferred += n;
bytes_transferred += b.size();
}
sr_.consume(bytes_transferred);
}