Skip to content

Commit 98e2312

Browse files
committed
chore: http_session uses serializer correctly
1 parent 2c49d51 commit 98e2312

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

include/boost/beast2/server/http_session.hpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ http_session<Stream>::
147147
do_read()
148148
{
149149
pr_.start();
150+
sr_.reset();
150151
beast2::async_read(stream_, pr_,
151152
call_mf(&http_session::on_read, this));
152153
}
@@ -234,8 +235,8 @@ on_read(
234235
pres_->status(http_proto::status::not_found);
235236
std::string s;
236237
format_to(s, "The requested URL {} was not found on this server.", preq_->target);
238+
//pres_->m.set_keep_alive(false); // VFALCO?
237239
pres_->set_body(s);
238-
pres_->m.set_keep_alive(false);
239240
goto do_write;
240241
}
241242

@@ -244,11 +245,17 @@ on_read(
244245
pres_->status(http_proto::status::internal_server_error);
245246
std::string s;
246247
format_to(s, "An internal server error occurred: {}", ec.message());
248+
//pres_->m.set_keep_alive(false); // VFALCO?
247249
pres_->set_body(s);
248-
pres_->m.set_keep_alive(false);
249250
}
250251

251252
do_write:
253+
if(sr_.is_done())
254+
{
255+
// happens when the handler sends the response
256+
return on_write(system::error_code(), 0);
257+
}
258+
252259
beast2::async_write(stream_, sr_,
253260
call_mf(&http_session::on_write, this));
254261
}

0 commit comments

Comments
 (0)