Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initiating functions no longer perform mutating operations #2915

Merged
merged 2 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions include/boost/beast/http/impl/write.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,15 @@
write_op(
Handler_&& h,
Stream& s,
serializer<isRequest, Body, Fields>& sr)
serializer<isRequest, Body, Fields>& sr,
bool split)
: async_base<
Handler, beast::executor_type<Stream>>(
std::forward<Handler_>(h), s.get_executor())
, s_(s)
, sr_(sr)
{
sr.split(split);
(*this)();
}

Expand Down Expand Up @@ -358,7 +360,8 @@
operator()(
WriteHandler&& h,
Predicate const&,
serializer<isRequest, Body, Fields>* sr)
serializer<isRequest, Body, Fields>* sr,
bool split)
{
// If you get an error on the following line it means
// that your handler does not meet the documented type
Expand All @@ -374,7 +377,7 @@
AsyncWriteStream,
Predicate,
isRequest, Body, Fields>(
std::forward<WriteHandler>(h), *stream, *sr);
std::forward<WriteHandler>(h), *stream, *sr, split);
}
};

Expand Down Expand Up @@ -686,14 +689,14 @@
"Body type requirements not met");
static_assert(is_body_writer<Body>::value,
"BodyWriter type requirements not met");
sr.split(true);
return net::async_initiate<
WriteHandler,
void(error_code, std::size_t)>(
detail::run_write_op<AsyncWriteStream>{&stream},
handler,
detail::serializer_is_header_done{},
&sr);
&sr,

Check warning on line 698 in include/boost/beast/http/impl/write.hpp

View check run for this annotation

Codecov / codecov/patch

include/boost/beast/http/impl/write.hpp#L698

Added line #L698 was not covered by tests
true);
}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -758,14 +761,14 @@
"Body type requirements not met");
static_assert(is_body_writer<Body>::value,
"BodyWriter type requirements not met");
sr.split(false);
return net::async_initiate<
WriteHandler,
void(error_code, std::size_t)>(
detail::run_write_op<AsyncWriteStream>{&stream},
handler,
detail::serializer_is_done{},
&sr);
&sr,

Check warning on line 770 in include/boost/beast/http/impl/write.hpp

View check run for this annotation

Codecov / codecov/patch

include/boost/beast/http/impl/write.hpp#L770

Added line #L770 was not covered by tests
false);
}

//------------------------------------------------------------------------------
Expand Down
4 changes: 1 addition & 3 deletions include/boost/beast/websocket/impl/accept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ class stream<NextLayer, deflateSupported>::accept_op
, d_(decorator)
{
auto& impl = *sp;
impl.reset();
error_code ec;
auto const mb =
beast::detail::dynamic_buffer_prepare(
Expand Down Expand Up @@ -629,7 +630,6 @@ async_accept(
{
static_assert(is_async_stream<next_layer_type>::value,
"AsyncStream type requirements not met");
impl_->reset();
return net::async_initiate<
AcceptHandler,
void(error_code)>(
Expand Down Expand Up @@ -661,7 +661,6 @@ async_accept(
static_assert(net::is_const_buffer_sequence<
ConstBufferSequence>::value,
"ConstBufferSequence type requirements not met");
impl_->reset();
return net::async_initiate<
AcceptHandler,
void(error_code)>(
Expand All @@ -683,7 +682,6 @@ async_accept(
{
static_assert(is_async_stream<next_layer_type>::value,
"AsyncStream type requirements not met");
impl_->reset();
return net::async_initiate<
AcceptHandler,
void(error_code)>(
Expand Down
3 changes: 2 additions & 1 deletion include/boost/beast/websocket/impl/handshake.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class stream<NextLayer, deflateSupported>::handshake_op
*this, std::move(req)))
{
sp->reset(); // VFALCO I don't like this
if(res_p)
res_p->result(http::status::internal_server_error);
(*this)({}, 0, false);
}

Expand Down Expand Up @@ -342,7 +344,6 @@ async_handshake(
detail::sec_ws_key_type key;
auto req = impl_->build_request(
key, host, target, &default_decorate_req);
res.result(http::status::internal_server_error);
return net::async_initiate<
HandshakeHandler,
void(error_code)>(
Expand Down
2 changes: 1 addition & 1 deletion include/boost/beast/websocket/impl/teardown.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ class teardown_tcp_op
, role_(role)
, nb_(false)
{
(*this)({}, 0, false);
this->set_allowed_cancellation(net::cancellation_type::all);
(*this)({}, 0, false);
}

void
Expand Down
Loading