mirror of
https://github.com/boostorg/beast.git
synced 2025-08-03 23:04:35 +02:00
Next layer is a base class
This commit is contained in:
@@ -193,7 +193,7 @@ public:
|
|||||||
: stable_async_base<Handler,
|
: stable_async_base<Handler,
|
||||||
beast::executor_type<stream>>(
|
beast::executor_type<stream>>(
|
||||||
std::forward<Handler_>(h),
|
std::forward<Handler_>(h),
|
||||||
sp->stream.get_executor())
|
sp->stream().get_executor())
|
||||||
, wp_(sp)
|
, wp_(sp)
|
||||||
, res_(beast::allocate_stable<response_type>(*this,
|
, res_(beast::allocate_stable<response_type>(*this,
|
||||||
sp->build_response(req, decorator, result_)))
|
sp->build_response(req, decorator, result_)))
|
||||||
@@ -220,7 +220,7 @@ public:
|
|||||||
// Send response
|
// Send response
|
||||||
BOOST_ASIO_CORO_YIELD
|
BOOST_ASIO_CORO_YIELD
|
||||||
http::async_write(
|
http::async_write(
|
||||||
impl.stream, res_, std::move(*this));
|
impl.stream(), res_, std::move(*this));
|
||||||
if(impl.check_stop_now(ec))
|
if(impl.check_stop_now(ec))
|
||||||
goto upcall;
|
goto upcall;
|
||||||
if(! ec)
|
if(! ec)
|
||||||
@@ -261,7 +261,7 @@ public:
|
|||||||
: stable_async_base<Handler,
|
: stable_async_base<Handler,
|
||||||
beast::executor_type<stream>>(
|
beast::executor_type<stream>>(
|
||||||
std::forward<Handler_>(h),
|
std::forward<Handler_>(h),
|
||||||
sp->stream.get_executor())
|
sp->stream().get_executor())
|
||||||
, wp_(sp)
|
, wp_(sp)
|
||||||
, p_(beast::allocate_stable<
|
, p_(beast::allocate_stable<
|
||||||
http::request_parser<http::empty_body>>(*this))
|
http::request_parser<http::empty_body>>(*this))
|
||||||
@@ -300,7 +300,7 @@ public:
|
|||||||
goto upcall;
|
goto upcall;
|
||||||
|
|
||||||
BOOST_ASIO_CORO_YIELD
|
BOOST_ASIO_CORO_YIELD
|
||||||
http::async_read(impl.stream,
|
http::async_read(impl.stream(),
|
||||||
impl.rd_buf, p_, std::move(*this));
|
impl.rd_buf, p_, std::move(*this));
|
||||||
if(ec == http::error::end_of_stream)
|
if(ec == http::error::end_of_stream)
|
||||||
ec = error::closed;
|
ec = error::closed;
|
||||||
@@ -407,7 +407,7 @@ do_accept(
|
|||||||
|
|
||||||
error_code result;
|
error_code result;
|
||||||
auto const res = impl_->build_response(req, decorator, result);
|
auto const res = impl_->build_response(req, decorator, result);
|
||||||
http::write(impl_->stream, res, ec);
|
http::write(impl_->stream(), res, ec);
|
||||||
if(ec)
|
if(ec)
|
||||||
return;
|
return;
|
||||||
ec = result;
|
ec = result;
|
||||||
|
@@ -55,7 +55,7 @@ public:
|
|||||||
: stable_async_base<Handler,
|
: stable_async_base<Handler,
|
||||||
beast::executor_type<stream>>(
|
beast::executor_type<stream>>(
|
||||||
std::forward<Handler_>(h),
|
std::forward<Handler_>(h),
|
||||||
sp->stream.get_executor())
|
sp->stream().get_executor())
|
||||||
, wp_(sp)
|
, wp_(sp)
|
||||||
, fb_(beast::allocate_stable<
|
, fb_(beast::allocate_stable<
|
||||||
detail::frame_buffer>(*this))
|
detail::frame_buffer>(*this))
|
||||||
@@ -102,7 +102,7 @@ public:
|
|||||||
impl.change_status(status::closing);
|
impl.change_status(status::closing);
|
||||||
impl.update_timer(this->get_executor());
|
impl.update_timer(this->get_executor());
|
||||||
BOOST_ASIO_CORO_YIELD
|
BOOST_ASIO_CORO_YIELD
|
||||||
net::async_write(impl.stream, fb_.data(),
|
net::async_write(impl.stream(), fb_.data(),
|
||||||
beast::detail::bind_continuation(std::move(*this)));
|
beast::detail::bind_continuation(std::move(*this)));
|
||||||
if(impl.check_stop_now(ec))
|
if(impl.check_stop_now(ec))
|
||||||
goto upcall;
|
goto upcall;
|
||||||
@@ -142,7 +142,7 @@ public:
|
|||||||
if(ev_)
|
if(ev_)
|
||||||
goto teardown;
|
goto teardown;
|
||||||
BOOST_ASIO_CORO_YIELD
|
BOOST_ASIO_CORO_YIELD
|
||||||
impl.stream.async_read_some(
|
impl.stream().async_read_some(
|
||||||
impl.rd_buf.prepare(read_size(
|
impl.rd_buf.prepare(read_size(
|
||||||
impl.rd_buf, impl.rd_buf.max_size())),
|
impl.rd_buf, impl.rd_buf.max_size())),
|
||||||
beast::detail::bind_continuation(std::move(*this)));
|
beast::detail::bind_continuation(std::move(*this)));
|
||||||
@@ -182,7 +182,7 @@ public:
|
|||||||
impl.rd_remain -= impl.rd_buf.size();
|
impl.rd_remain -= impl.rd_buf.size();
|
||||||
impl.rd_buf.consume(impl.rd_buf.size());
|
impl.rd_buf.consume(impl.rd_buf.size());
|
||||||
BOOST_ASIO_CORO_YIELD
|
BOOST_ASIO_CORO_YIELD
|
||||||
impl.stream.async_read_some(
|
impl.stream().async_read_some(
|
||||||
impl.rd_buf.prepare(read_size(
|
impl.rd_buf.prepare(read_size(
|
||||||
impl.rd_buf, impl.rd_buf.max_size())),
|
impl.rd_buf, impl.rd_buf.max_size())),
|
||||||
beast::detail::bind_continuation(std::move(*this)));
|
beast::detail::bind_continuation(std::move(*this)));
|
||||||
@@ -200,7 +200,7 @@ public:
|
|||||||
BOOST_ASSERT(impl.wr_block.is_locked(this));
|
BOOST_ASSERT(impl.wr_block.is_locked(this));
|
||||||
using beast::websocket::async_teardown;
|
using beast::websocket::async_teardown;
|
||||||
BOOST_ASIO_CORO_YIELD
|
BOOST_ASIO_CORO_YIELD
|
||||||
async_teardown(impl.role, impl.stream,
|
async_teardown(impl.role, impl.stream(),
|
||||||
beast::detail::bind_continuation(std::move(*this)));
|
beast::detail::bind_continuation(std::move(*this)));
|
||||||
BOOST_ASSERT(impl.wr_block.is_locked(this));
|
BOOST_ASSERT(impl.wr_block.is_locked(this));
|
||||||
if(ec == net::error::eof)
|
if(ec == net::error::eof)
|
||||||
@@ -297,7 +297,7 @@ close(close_reason const& cr, error_code& ec)
|
|||||||
impl.change_status(status::closing);
|
impl.change_status(status::closing);
|
||||||
detail::frame_buffer fb;
|
detail::frame_buffer fb;
|
||||||
impl.template write_close<flat_static_buffer_base>(fb, cr);
|
impl.template write_close<flat_static_buffer_base>(fb, cr);
|
||||||
net::write(impl.stream, fb.data(), ec);
|
net::write(impl.stream(), fb.data(), ec);
|
||||||
if(impl.check_stop_now(ec))
|
if(impl.check_stop_now(ec))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -317,7 +317,7 @@ close(close_reason const& cr, error_code& ec)
|
|||||||
// Protocol violation
|
// Protocol violation
|
||||||
return do_fail(close_code::none, ev, ec);
|
return do_fail(close_code::none, ev, ec);
|
||||||
}
|
}
|
||||||
impl.rd_buf.commit(impl.stream.read_some(
|
impl.rd_buf.commit(impl.stream().read_some(
|
||||||
impl.rd_buf.prepare(read_size(
|
impl.rd_buf.prepare(read_size(
|
||||||
impl.rd_buf, impl.rd_buf.max_size())), ec));
|
impl.rd_buf, impl.rd_buf.max_size())), ec));
|
||||||
if(impl.check_stop_now(ec))
|
if(impl.check_stop_now(ec))
|
||||||
@@ -359,7 +359,7 @@ close(close_reason const& cr, error_code& ec)
|
|||||||
impl.rd_remain -= impl.rd_buf.size();
|
impl.rd_remain -= impl.rd_buf.size();
|
||||||
impl.rd_buf.consume(impl.rd_buf.size());
|
impl.rd_buf.consume(impl.rd_buf.size());
|
||||||
impl.rd_buf.commit(
|
impl.rd_buf.commit(
|
||||||
impl.stream.read_some(
|
impl.stream().read_some(
|
||||||
impl.rd_buf.prepare(
|
impl.rd_buf.prepare(
|
||||||
read_size(
|
read_size(
|
||||||
impl.rd_buf,
|
impl.rd_buf,
|
||||||
|
@@ -72,7 +72,7 @@ public:
|
|||||||
: stable_async_base<Handler,
|
: stable_async_base<Handler,
|
||||||
beast::executor_type<stream>>(
|
beast::executor_type<stream>>(
|
||||||
std::forward<Handler_>(h),
|
std::forward<Handler_>(h),
|
||||||
sp->stream.get_executor())
|
sp->stream().get_executor())
|
||||||
, wp_(sp)
|
, wp_(sp)
|
||||||
, key_(key)
|
, key_(key)
|
||||||
, res_p_(res_p)
|
, res_p_(res_p)
|
||||||
@@ -103,14 +103,14 @@ public:
|
|||||||
// write HTTP request
|
// write HTTP request
|
||||||
impl.do_pmd_config(d_.req);
|
impl.do_pmd_config(d_.req);
|
||||||
BOOST_ASIO_CORO_YIELD
|
BOOST_ASIO_CORO_YIELD
|
||||||
http::async_write(impl.stream,
|
http::async_write(impl.stream(),
|
||||||
d_.req, std::move(*this));
|
d_.req, std::move(*this));
|
||||||
if(impl.check_stop_now(ec))
|
if(impl.check_stop_now(ec))
|
||||||
goto upcall;
|
goto upcall;
|
||||||
|
|
||||||
// read HTTP response
|
// read HTTP response
|
||||||
BOOST_ASIO_CORO_YIELD
|
BOOST_ASIO_CORO_YIELD
|
||||||
http::async_read(impl.stream,
|
http::async_read(impl.stream(),
|
||||||
impl.rd_buf, d_.p,
|
impl.rd_buf, d_.p,
|
||||||
std::move(*this));
|
std::move(*this));
|
||||||
if(ec == http::error::buffer_overflow)
|
if(ec == http::error::buffer_overflow)
|
||||||
@@ -125,7 +125,7 @@ public:
|
|||||||
impl.rd_buf.clear();
|
impl.rd_buf.clear();
|
||||||
|
|
||||||
BOOST_ASIO_CORO_YIELD
|
BOOST_ASIO_CORO_YIELD
|
||||||
http::async_read(impl.stream,
|
http::async_read(impl.stream(),
|
||||||
d_.fb, d_.p, std::move(*this));
|
d_.fb, d_.p, std::move(*this));
|
||||||
|
|
||||||
if(! ec)
|
if(! ec)
|
||||||
@@ -213,7 +213,7 @@ do_handshake(
|
|||||||
auto const req = impl.build_request(
|
auto const req = impl.build_request(
|
||||||
key, host, target, decorator);
|
key, host, target, decorator);
|
||||||
impl.do_pmd_config(req);
|
impl.do_pmd_config(req);
|
||||||
http::write(impl.stream, req, ec);
|
http::write(impl.stream(), req, ec);
|
||||||
}
|
}
|
||||||
if(impl.check_stop_now(ec))
|
if(impl.check_stop_now(ec))
|
||||||
return;
|
return;
|
||||||
|
@@ -52,7 +52,7 @@ public:
|
|||||||
: stable_async_base<Handler,
|
: stable_async_base<Handler,
|
||||||
beast::executor_type<stream>>(
|
beast::executor_type<stream>>(
|
||||||
std::forward<Handler_>(h),
|
std::forward<Handler_>(h),
|
||||||
sp->stream.get_executor())
|
sp->stream().get_executor())
|
||||||
, wp_(sp)
|
, wp_(sp)
|
||||||
, fb_(beast::allocate_stable<
|
, fb_(beast::allocate_stable<
|
||||||
detail::frame_buffer>(*this))
|
detail::frame_buffer>(*this))
|
||||||
@@ -91,7 +91,7 @@ public:
|
|||||||
|
|
||||||
// Send ping frame
|
// Send ping frame
|
||||||
BOOST_ASIO_CORO_YIELD
|
BOOST_ASIO_CORO_YIELD
|
||||||
net::async_write(impl.stream, fb_.data(),
|
net::async_write(impl.stream(), fb_.data(),
|
||||||
beast::detail::bind_continuation(std::move(*this)));
|
beast::detail::bind_continuation(std::move(*this)));
|
||||||
if(impl.check_stop_now(ec))
|
if(impl.check_stop_now(ec))
|
||||||
goto upcall;
|
goto upcall;
|
||||||
@@ -182,7 +182,7 @@ public:
|
|||||||
|
|
||||||
// Send ping frame
|
// Send ping frame
|
||||||
BOOST_ASIO_CORO_YIELD
|
BOOST_ASIO_CORO_YIELD
|
||||||
net::async_write(impl.stream, fb_->data(),
|
net::async_write(impl.stream(), fb_->data(),
|
||||||
//beast::detail::bind_continuation(std::move(*this)));
|
//beast::detail::bind_continuation(std::move(*this)));
|
||||||
std::move(*this));
|
std::move(*this));
|
||||||
if(impl.check_stop_now(ec))
|
if(impl.check_stop_now(ec))
|
||||||
@@ -253,7 +253,7 @@ ping(ping_data const& payload, error_code& ec)
|
|||||||
detail::frame_buffer fb;
|
detail::frame_buffer fb;
|
||||||
impl_->template write_ping<flat_static_buffer_base>(
|
impl_->template write_ping<flat_static_buffer_base>(
|
||||||
fb, detail::opcode::ping, payload);
|
fb, detail::opcode::ping, payload);
|
||||||
net::write(impl_->stream, fb.data(), ec);
|
net::write(impl_->stream(), fb.data(), ec);
|
||||||
if(impl_->check_stop_now(ec))
|
if(impl_->check_stop_now(ec))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -279,7 +279,7 @@ pong(ping_data const& payload, error_code& ec)
|
|||||||
detail::frame_buffer fb;
|
detail::frame_buffer fb;
|
||||||
impl_->template write_ping<flat_static_buffer_base>(
|
impl_->template write_ping<flat_static_buffer_base>(
|
||||||
fb, detail::opcode::pong, payload);
|
fb, detail::opcode::pong, payload);
|
||||||
net::write(impl_->stream, fb.data(), ec);
|
net::write(impl_->stream(), fb.data(), ec);
|
||||||
if(impl_->check_stop_now(ec))
|
if(impl_->check_stop_now(ec))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -68,7 +68,7 @@ public:
|
|||||||
: async_base<
|
: async_base<
|
||||||
Handler, beast::executor_type<stream>>(
|
Handler, beast::executor_type<stream>>(
|
||||||
std::forward<Handler_>(h),
|
std::forward<Handler_>(h),
|
||||||
sp->stream.get_executor())
|
sp->stream().get_executor())
|
||||||
, wp_(sp)
|
, wp_(sp)
|
||||||
, bs_(bs)
|
, bs_(bs)
|
||||||
, cb_(bs)
|
, cb_(bs)
|
||||||
@@ -159,7 +159,7 @@ public:
|
|||||||
}
|
}
|
||||||
BOOST_ASSERT(impl.rd_block.is_locked(this));
|
BOOST_ASSERT(impl.rd_block.is_locked(this));
|
||||||
BOOST_ASIO_CORO_YIELD
|
BOOST_ASIO_CORO_YIELD
|
||||||
impl.stream.async_read_some(
|
impl.stream().async_read_some(
|
||||||
impl.rd_buf.prepare(read_size(
|
impl.rd_buf.prepare(read_size(
|
||||||
impl.rd_buf, impl.rd_buf.max_size())),
|
impl.rd_buf, impl.rd_buf.max_size())),
|
||||||
std::move(*this));
|
std::move(*this));
|
||||||
@@ -250,7 +250,7 @@ public:
|
|||||||
BOOST_ASSERT(impl.wr_block.is_locked(this));
|
BOOST_ASSERT(impl.wr_block.is_locked(this));
|
||||||
BOOST_ASIO_CORO_YIELD
|
BOOST_ASIO_CORO_YIELD
|
||||||
net::async_write(
|
net::async_write(
|
||||||
impl.stream, impl.rd_fb.data(),
|
impl.stream(), impl.rd_fb.data(),
|
||||||
beast::detail::bind_continuation(std::move(*this)));
|
beast::detail::bind_continuation(std::move(*this)));
|
||||||
BOOST_ASSERT(impl.wr_block.is_locked(this));
|
BOOST_ASSERT(impl.wr_block.is_locked(this));
|
||||||
if(impl.check_stop_now(ec))
|
if(impl.check_stop_now(ec))
|
||||||
@@ -355,7 +355,7 @@ public:
|
|||||||
// Fill the read buffer first, otherwise we
|
// Fill the read buffer first, otherwise we
|
||||||
// get fewer bytes at the cost of one I/O.
|
// get fewer bytes at the cost of one I/O.
|
||||||
BOOST_ASIO_CORO_YIELD
|
BOOST_ASIO_CORO_YIELD
|
||||||
impl.stream.async_read_some(
|
impl.stream().async_read_some(
|
||||||
impl.rd_buf.prepare(read_size(
|
impl.rd_buf.prepare(read_size(
|
||||||
impl.rd_buf, impl.rd_buf.max_size())),
|
impl.rd_buf, impl.rd_buf.max_size())),
|
||||||
std::move(*this));
|
std::move(*this));
|
||||||
@@ -401,7 +401,7 @@ public:
|
|||||||
BOOST_ASSERT(buffer_size(buffers_prefix(
|
BOOST_ASSERT(buffer_size(buffers_prefix(
|
||||||
clamp(impl.rd_remain), cb_)) > 0);
|
clamp(impl.rd_remain), cb_)) > 0);
|
||||||
BOOST_ASIO_CORO_YIELD
|
BOOST_ASIO_CORO_YIELD
|
||||||
impl.stream.async_read_some(buffers_prefix(
|
impl.stream().async_read_some(buffers_prefix(
|
||||||
clamp(impl.rd_remain), cb_), std::move(*this));
|
clamp(impl.rd_remain), cb_), std::move(*this));
|
||||||
if(impl.check_stop_now(ec))
|
if(impl.check_stop_now(ec))
|
||||||
goto upcall;
|
goto upcall;
|
||||||
@@ -443,7 +443,7 @@ public:
|
|||||||
{
|
{
|
||||||
// read new
|
// read new
|
||||||
BOOST_ASIO_CORO_YIELD
|
BOOST_ASIO_CORO_YIELD
|
||||||
impl.stream.async_read_some(
|
impl.stream().async_read_some(
|
||||||
impl.rd_buf.prepare(read_size(
|
impl.rd_buf.prepare(read_size(
|
||||||
impl.rd_buf, impl.rd_buf.max_size())),
|
impl.rd_buf, impl.rd_buf.max_size())),
|
||||||
std::move(*this));
|
std::move(*this));
|
||||||
@@ -567,7 +567,7 @@ public:
|
|||||||
// Send close frame
|
// Send close frame
|
||||||
BOOST_ASSERT(impl.wr_block.is_locked(this));
|
BOOST_ASSERT(impl.wr_block.is_locked(this));
|
||||||
BOOST_ASIO_CORO_YIELD
|
BOOST_ASIO_CORO_YIELD
|
||||||
net::async_write(impl.stream, impl.rd_fb.data(),
|
net::async_write(impl.stream(), impl.rd_fb.data(),
|
||||||
beast::detail::bind_continuation(std::move(*this)));
|
beast::detail::bind_continuation(std::move(*this)));
|
||||||
BOOST_ASSERT(impl.wr_block.is_locked(this));
|
BOOST_ASSERT(impl.wr_block.is_locked(this));
|
||||||
if(impl.check_stop_now(ec))
|
if(impl.check_stop_now(ec))
|
||||||
@@ -578,7 +578,7 @@ public:
|
|||||||
using beast::websocket::async_teardown;
|
using beast::websocket::async_teardown;
|
||||||
BOOST_ASSERT(impl.wr_block.is_locked(this));
|
BOOST_ASSERT(impl.wr_block.is_locked(this));
|
||||||
BOOST_ASIO_CORO_YIELD
|
BOOST_ASIO_CORO_YIELD
|
||||||
async_teardown(impl.role, impl.stream,
|
async_teardown(impl.role, impl.stream(),
|
||||||
beast::detail::bind_continuation(std::move(*this)));
|
beast::detail::bind_continuation(std::move(*this)));
|
||||||
BOOST_ASSERT(impl.wr_block.is_locked(this));
|
BOOST_ASSERT(impl.wr_block.is_locked(this));
|
||||||
if(ec == net::error::eof)
|
if(ec == net::error::eof)
|
||||||
@@ -634,7 +634,7 @@ public:
|
|||||||
: async_base<Handler,
|
: async_base<Handler,
|
||||||
beast::executor_type<stream>>(
|
beast::executor_type<stream>>(
|
||||||
std::forward<Handler_>(h),
|
std::forward<Handler_>(h),
|
||||||
sp->stream.get_executor())
|
sp->stream().get_executor())
|
||||||
, wp_(sp)
|
, wp_(sp)
|
||||||
, b_(b)
|
, b_(b)
|
||||||
, limit_(limit ? limit : (
|
, limit_(limit ? limit : (
|
||||||
@@ -959,7 +959,7 @@ loop:
|
|||||||
return bytes_written;
|
return bytes_written;
|
||||||
}
|
}
|
||||||
auto const bytes_transferred =
|
auto const bytes_transferred =
|
||||||
impl.stream.read_some(
|
impl.stream().read_some(
|
||||||
impl.rd_buf.prepare(read_size(
|
impl.rd_buf.prepare(read_size(
|
||||||
impl.rd_buf, impl.rd_buf.max_size())),
|
impl.rd_buf, impl.rd_buf.max_size())),
|
||||||
ec);
|
ec);
|
||||||
@@ -1001,7 +1001,7 @@ loop:
|
|||||||
detail::frame_buffer fb;
|
detail::frame_buffer fb;
|
||||||
impl.template write_ping<flat_static_buffer_base>(fb,
|
impl.template write_ping<flat_static_buffer_base>(fb,
|
||||||
detail::opcode::pong, payload);
|
detail::opcode::pong, payload);
|
||||||
net::write(impl.stream, fb.data(), ec);
|
net::write(impl.stream(), fb.data(), ec);
|
||||||
if(impl.check_stop_now(ec))
|
if(impl.check_stop_now(ec))
|
||||||
return bytes_written;
|
return bytes_written;
|
||||||
goto loop;
|
goto loop;
|
||||||
@@ -1065,7 +1065,7 @@ loop:
|
|||||||
{
|
{
|
||||||
// Fill the read buffer first, otherwise we
|
// Fill the read buffer first, otherwise we
|
||||||
// get fewer bytes at the cost of one I/O.
|
// get fewer bytes at the cost of one I/O.
|
||||||
impl.rd_buf.commit(impl.stream.read_some(
|
impl.rd_buf.commit(impl.stream().read_some(
|
||||||
impl.rd_buf.prepare(read_size(impl.rd_buf,
|
impl.rd_buf.prepare(read_size(impl.rd_buf,
|
||||||
impl.rd_buf.max_size())), ec));
|
impl.rd_buf.max_size())), ec));
|
||||||
if(impl.check_stop_now(ec))
|
if(impl.check_stop_now(ec))
|
||||||
@@ -1109,7 +1109,7 @@ loop:
|
|||||||
BOOST_ASSERT(buffer_size(buffers_prefix(
|
BOOST_ASSERT(buffer_size(buffers_prefix(
|
||||||
clamp(impl.rd_remain), buffers)) > 0);
|
clamp(impl.rd_remain), buffers)) > 0);
|
||||||
auto const bytes_transferred =
|
auto const bytes_transferred =
|
||||||
impl.stream.read_some(buffers_prefix(
|
impl.stream().read_some(buffers_prefix(
|
||||||
clamp(impl.rd_remain), buffers), ec);
|
clamp(impl.rd_remain), buffers), ec);
|
||||||
// VFALCO What if some bytes were written?
|
// VFALCO What if some bytes were written?
|
||||||
if(impl.check_stop_now(ec))
|
if(impl.check_stop_now(ec))
|
||||||
@@ -1170,7 +1170,7 @@ loop:
|
|||||||
{
|
{
|
||||||
// read new
|
// read new
|
||||||
auto const bytes_transferred =
|
auto const bytes_transferred =
|
||||||
impl.stream.read_some(
|
impl.stream().read_some(
|
||||||
impl.rd_buf.prepare(read_size(
|
impl.rd_buf.prepare(read_size(
|
||||||
impl.rd_buf, impl.rd_buf.max_size())),
|
impl.rd_buf, impl.rd_buf.max_size())),
|
||||||
ec);
|
ec);
|
||||||
|
@@ -60,7 +60,7 @@ stream<NextLayer, deflateSupported>::
|
|||||||
get_executor() const noexcept ->
|
get_executor() const noexcept ->
|
||||||
executor_type
|
executor_type
|
||||||
{
|
{
|
||||||
return impl_->stream.get_executor();
|
return impl_->stream().get_executor();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class NextLayer, bool deflateSupported>
|
template<class NextLayer, bool deflateSupported>
|
||||||
@@ -69,7 +69,7 @@ stream<NextLayer, deflateSupported>::
|
|||||||
next_layer() noexcept ->
|
next_layer() noexcept ->
|
||||||
next_layer_type&
|
next_layer_type&
|
||||||
{
|
{
|
||||||
return impl_->stream;
|
return impl_->stream();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class NextLayer, bool deflateSupported>
|
template<class NextLayer, bool deflateSupported>
|
||||||
@@ -78,7 +78,7 @@ stream<NextLayer, deflateSupported>::
|
|||||||
next_layer() const noexcept ->
|
next_layer() const noexcept ->
|
||||||
next_layer_type const&
|
next_layer_type const&
|
||||||
{
|
{
|
||||||
return impl_->stream;
|
return impl_->stream();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class NextLayer, bool deflateSupported>
|
template<class NextLayer, bool deflateSupported>
|
||||||
@@ -324,12 +324,12 @@ do_fail(
|
|||||||
detail::frame_buffer fb;
|
detail::frame_buffer fb;
|
||||||
impl_->template write_close<
|
impl_->template write_close<
|
||||||
flat_static_buffer_base>(fb, code);
|
flat_static_buffer_base>(fb, code);
|
||||||
net::write(impl_->stream, fb.data(), ec);
|
net::write(impl_->stream(), fb.data(), ec);
|
||||||
if(impl_->check_stop_now(ec))
|
if(impl_->check_stop_now(ec))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
using beast::websocket::teardown;
|
using beast::websocket::teardown;
|
||||||
teardown(impl_->role, impl_->stream, ec);
|
teardown(impl_->role, impl_->stream(), ec);
|
||||||
if(ec == net::error::eof)
|
if(ec == net::error::eof)
|
||||||
{
|
{
|
||||||
// Rationale:
|
// Rationale:
|
||||||
|
@@ -46,8 +46,13 @@ template<
|
|||||||
struct stream<NextLayer, deflateSupported>::impl_type
|
struct stream<NextLayer, deflateSupported>::impl_type
|
||||||
: boost::enable_shared_from_this<impl_type>
|
: boost::enable_shared_from_this<impl_type>
|
||||||
, detail::impl_base<deflateSupported>
|
, detail::impl_base<deflateSupported>
|
||||||
|
, boost::empty_value<NextLayer>
|
||||||
{
|
{
|
||||||
NextLayer stream; // The underlying stream
|
NextLayer& stream() noexcept
|
||||||
|
{
|
||||||
|
return this->boost::empty_value<NextLayer>::get();
|
||||||
|
}
|
||||||
|
|
||||||
net::steady_timer timer; // used for timeouts
|
net::steady_timer timer; // used for timeouts
|
||||||
close_reason cr; // set from received close frame
|
close_reason cr; // set from received close frame
|
||||||
control_cb_type ctrl_cb; // control callback
|
control_cb_type ctrl_cb; // control callback
|
||||||
@@ -91,20 +96,21 @@ struct stream<NextLayer, deflateSupported>::impl_type
|
|||||||
saved_handler op_r_rd; // paused read op (async read)
|
saved_handler op_r_rd; // paused read op (async read)
|
||||||
saved_handler op_r_close; // paused close op (async read)
|
saved_handler op_r_close; // paused close op (async read)
|
||||||
|
|
||||||
bool idle_pinging = false;
|
bool idle_pinging = false;
|
||||||
bool secure_prng_ = true;
|
bool secure_prng_ = true;
|
||||||
bool ec_delivered = false;
|
bool ec_delivered = false;
|
||||||
bool timed_out = false;
|
bool timed_out = false;
|
||||||
int idle_counter = 0;
|
int idle_counter = 0;
|
||||||
|
|
||||||
detail::decorator decorator_opt; // Decorator for HTTP messages
|
detail::decorator decorator_opt; // Decorator for HTTP messages
|
||||||
timeout timeout_opt; // Timeout/idle settings
|
timeout timeout_opt; // Timeout/idle settings
|
||||||
|
|
||||||
|
|
||||||
template<class... Args>
|
template<class... Args>
|
||||||
impl_type(Args&&... args)
|
impl_type(Args&&... args)
|
||||||
: stream(std::forward<Args>(args)...)
|
: boost::empty_value<NextLayer>(
|
||||||
, timer(stream.get_executor())
|
boost::empty_init_t{},
|
||||||
|
std::forward<Args>(args)...)
|
||||||
|
, timer(this->stream().get_executor())
|
||||||
{
|
{
|
||||||
timeout_opt.handshake_timeout = none();
|
timeout_opt.handshake_timeout = none();
|
||||||
timeout_opt.idle_timeout = none();
|
timeout_opt.idle_timeout = none();
|
||||||
@@ -472,7 +478,7 @@ private:
|
|||||||
{
|
{
|
||||||
case status::handshake:
|
case status::handshake:
|
||||||
impl.timed_out = true;
|
impl.timed_out = true;
|
||||||
close_socket(get_lowest_layer(impl.stream));
|
close_socket(get_lowest_layer(impl.stream()));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case status::open:
|
case status::open:
|
||||||
@@ -494,12 +500,12 @@ private:
|
|||||||
|
|
||||||
// timeout
|
// timeout
|
||||||
impl.timed_out = true;
|
impl.timed_out = true;
|
||||||
close_socket(get_lowest_layer(impl.stream));
|
close_socket(get_lowest_layer(impl.stream()));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case status::closing:
|
case status::closing:
|
||||||
impl.timed_out = true;
|
impl.timed_out = true;
|
||||||
close_socket(get_lowest_layer(impl.stream));
|
close_socket(get_lowest_layer(impl.stream()));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case status::closed:
|
case status::closed:
|
||||||
|
@@ -76,7 +76,7 @@ public:
|
|||||||
: beast::async_base<Handler,
|
: beast::async_base<Handler,
|
||||||
beast::executor_type<stream>>(
|
beast::executor_type<stream>>(
|
||||||
std::forward<Handler_>(h),
|
std::forward<Handler_>(h),
|
||||||
sp->stream.get_executor())
|
sp->stream().get_executor())
|
||||||
, wp_(sp)
|
, wp_(sp)
|
||||||
, cb_(bs)
|
, cb_(bs)
|
||||||
, fin_(fin)
|
, fin_(fin)
|
||||||
@@ -192,7 +192,7 @@ operator()(
|
|||||||
impl.wr_fb, fh_);
|
impl.wr_fb, fh_);
|
||||||
impl.wr_cont = ! fin_;
|
impl.wr_cont = ! fin_;
|
||||||
BOOST_ASIO_CORO_YIELD
|
BOOST_ASIO_CORO_YIELD
|
||||||
net::async_write(impl.stream,
|
net::async_write(impl.stream(),
|
||||||
buffers_cat(impl.wr_fb.data(), cb_),
|
buffers_cat(impl.wr_fb.data(), cb_),
|
||||||
beast::detail::bind_continuation(std::move(*this)));
|
beast::detail::bind_continuation(std::move(*this)));
|
||||||
bytes_transferred_ += clamp(fh_.len);
|
bytes_transferred_ += clamp(fh_.len);
|
||||||
@@ -218,7 +218,7 @@ operator()(
|
|||||||
impl.wr_cont = ! fin_;
|
impl.wr_cont = ! fin_;
|
||||||
// Send frame
|
// Send frame
|
||||||
BOOST_ASIO_CORO_YIELD
|
BOOST_ASIO_CORO_YIELD
|
||||||
net::async_write(impl.stream, buffers_cat(
|
net::async_write(impl.stream(), buffers_cat(
|
||||||
impl.wr_fb.data(),
|
impl.wr_fb.data(),
|
||||||
buffers_prefix(clamp(fh_.len), cb_)),
|
buffers_prefix(clamp(fh_.len), cb_)),
|
||||||
beast::detail::bind_continuation(std::move(*this)));
|
beast::detail::bind_continuation(std::move(*this)));
|
||||||
@@ -269,7 +269,7 @@ operator()(
|
|||||||
impl.wr_cont = ! fin_;
|
impl.wr_cont = ! fin_;
|
||||||
// write frame header and some payload
|
// write frame header and some payload
|
||||||
BOOST_ASIO_CORO_YIELD
|
BOOST_ASIO_CORO_YIELD
|
||||||
net::async_write(impl.stream, buffers_cat(
|
net::async_write(impl.stream(), buffers_cat(
|
||||||
impl.wr_fb.data(),
|
impl.wr_fb.data(),
|
||||||
net::buffer(impl.wr_buf.get(), n)),
|
net::buffer(impl.wr_buf.get(), n)),
|
||||||
beast::detail::bind_continuation(std::move(*this)));
|
beast::detail::bind_continuation(std::move(*this)));
|
||||||
@@ -289,7 +289,7 @@ operator()(
|
|||||||
remain_ -= n;
|
remain_ -= n;
|
||||||
// write more payload
|
// write more payload
|
||||||
BOOST_ASIO_CORO_YIELD
|
BOOST_ASIO_CORO_YIELD
|
||||||
net::async_write(impl.stream,
|
net::async_write(impl.stream(),
|
||||||
net::buffer(impl.wr_buf.get(), n),
|
net::buffer(impl.wr_buf.get(), n),
|
||||||
beast::detail::bind_continuation(std::move(*this)));
|
beast::detail::bind_continuation(std::move(*this)));
|
||||||
bytes_transferred_ += bytes_transferred;
|
bytes_transferred_ += bytes_transferred;
|
||||||
@@ -322,7 +322,7 @@ operator()(
|
|||||||
impl.wr_cont = ! fin_;
|
impl.wr_cont = ! fin_;
|
||||||
// Send frame
|
// Send frame
|
||||||
BOOST_ASIO_CORO_YIELD
|
BOOST_ASIO_CORO_YIELD
|
||||||
net::async_write(impl.stream, buffers_cat(
|
net::async_write(impl.stream(), buffers_cat(
|
||||||
impl.wr_fb.data(),
|
impl.wr_fb.data(),
|
||||||
net::buffer(impl.wr_buf.get(), n)),
|
net::buffer(impl.wr_buf.get(), n)),
|
||||||
beast::detail::bind_continuation(std::move(*this)));
|
beast::detail::bind_continuation(std::move(*this)));
|
||||||
@@ -386,7 +386,7 @@ operator()(
|
|||||||
impl.wr_cont = ! fin_;
|
impl.wr_cont = ! fin_;
|
||||||
// Send frame
|
// Send frame
|
||||||
BOOST_ASIO_CORO_YIELD
|
BOOST_ASIO_CORO_YIELD
|
||||||
net::async_write(impl.stream, buffers_cat(
|
net::async_write(impl.stream(), buffers_cat(
|
||||||
impl.wr_fb.data(), b),
|
impl.wr_fb.data(), b),
|
||||||
beast::detail::bind_continuation(std::move(*this)));
|
beast::detail::bind_continuation(std::move(*this)));
|
||||||
bytes_transferred_ += in_;
|
bytes_transferred_ += in_;
|
||||||
@@ -555,7 +555,7 @@ write_some(bool fin,
|
|||||||
detail::write<
|
detail::write<
|
||||||
flat_static_buffer_base>(fh_buf, fh);
|
flat_static_buffer_base>(fh_buf, fh);
|
||||||
impl.wr_cont = ! fin;
|
impl.wr_cont = ! fin;
|
||||||
net::write(impl.stream,
|
net::write(impl.stream(),
|
||||||
buffers_cat(fh_buf.data(), b), ec);
|
buffers_cat(fh_buf.data(), b), ec);
|
||||||
if(impl.check_stop_now(ec))
|
if(impl.check_stop_now(ec))
|
||||||
return bytes_transferred;
|
return bytes_transferred;
|
||||||
@@ -578,7 +578,7 @@ write_some(bool fin,
|
|||||||
detail::write<
|
detail::write<
|
||||||
flat_static_buffer_base>(fh_buf, fh);
|
flat_static_buffer_base>(fh_buf, fh);
|
||||||
impl.wr_cont = ! fin;
|
impl.wr_cont = ! fin;
|
||||||
net::write(impl.stream,
|
net::write(impl.stream(),
|
||||||
buffers_cat(fh_buf.data(), buffers), ec);
|
buffers_cat(fh_buf.data(), buffers), ec);
|
||||||
if(impl.check_stop_now(ec))
|
if(impl.check_stop_now(ec))
|
||||||
return bytes_transferred;
|
return bytes_transferred;
|
||||||
@@ -600,7 +600,7 @@ write_some(bool fin,
|
|||||||
detail::write<
|
detail::write<
|
||||||
flat_static_buffer_base>(fh_buf, fh);
|
flat_static_buffer_base>(fh_buf, fh);
|
||||||
impl.wr_cont = ! fin;
|
impl.wr_cont = ! fin;
|
||||||
net::write(impl.stream,
|
net::write(impl.stream(),
|
||||||
beast::buffers_cat(fh_buf.data(),
|
beast::buffers_cat(fh_buf.data(),
|
||||||
beast::buffers_prefix(n, cb)), ec);
|
beast::buffers_prefix(n, cb)), ec);
|
||||||
bytes_transferred += n;
|
bytes_transferred += n;
|
||||||
@@ -636,7 +636,7 @@ write_some(bool fin,
|
|||||||
remain -= n;
|
remain -= n;
|
||||||
detail::mask_inplace(b, key);
|
detail::mask_inplace(b, key);
|
||||||
impl.wr_cont = ! fin;
|
impl.wr_cont = ! fin;
|
||||||
net::write(impl.stream,
|
net::write(impl.stream(),
|
||||||
buffers_cat(fh_buf.data(), b), ec);
|
buffers_cat(fh_buf.data(), b), ec);
|
||||||
bytes_transferred += n;
|
bytes_transferred += n;
|
||||||
if(impl.check_stop_now(ec))
|
if(impl.check_stop_now(ec))
|
||||||
@@ -652,7 +652,7 @@ write_some(bool fin,
|
|||||||
cb.consume(n);
|
cb.consume(n);
|
||||||
remain -= n;
|
remain -= n;
|
||||||
detail::mask_inplace(b, key);
|
detail::mask_inplace(b, key);
|
||||||
net::write(impl.stream, b, ec);
|
net::write(impl.stream(), b, ec);
|
||||||
bytes_transferred += n;
|
bytes_transferred += n;
|
||||||
if(impl.check_stop_now(ec))
|
if(impl.check_stop_now(ec))
|
||||||
return bytes_transferred;
|
return bytes_transferred;
|
||||||
@@ -682,7 +682,7 @@ write_some(bool fin,
|
|||||||
detail::fh_buffer fh_buf;
|
detail::fh_buffer fh_buf;
|
||||||
detail::write<
|
detail::write<
|
||||||
flat_static_buffer_base>(fh_buf, fh);
|
flat_static_buffer_base>(fh_buf, fh);
|
||||||
net::write(impl.stream,
|
net::write(impl.stream(),
|
||||||
buffers_cat(fh_buf.data(), b), ec);
|
buffers_cat(fh_buf.data(), b), ec);
|
||||||
bytes_transferred += n;
|
bytes_transferred += n;
|
||||||
if(impl.check_stop_now(ec))
|
if(impl.check_stop_now(ec))
|
||||||
|
@@ -143,7 +143,6 @@ struct stream_base
|
|||||||
}
|
}
|
||||||
return opt;
|
return opt;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Reference in New Issue
Block a user