http write returns success on connection close (API Change):

fix #767

The write family of HTTP stream algorithms no longer returns
error::end_of_stream when the message indicates that the connection
should be closed.

Actions Required:

* Add code to servers to close the connection after successfully
  writing a message where `message::keep_alive()` would return `false`.
This commit is contained in:
Vinnie Falco
2017-10-20 10:19:58 -07:00
parent 885b9dfe0b
commit d0d4e0a740
16 changed files with 122 additions and 83 deletions

View File

@@ -244,7 +244,8 @@ class session : public std::enable_shared_from_this<session>
&session::on_write,
self_.shared_from_this(),
std::placeholders::_1,
std::placeholders::_2)));
std::placeholders::_2,
! sp->keep_alive())));
}
};
@@ -309,20 +310,21 @@ public:
void
on_write(
boost::system::error_code ec,
std::size_t bytes_transferred)
std::size_t bytes_transferred,
bool close)
{
boost::ignore_unused(bytes_transferred);
if(ec == http::error::end_of_stream)
if(ec)
return fail(ec, "write");
if(close)
{
// This means we should close the connection, usually because
// the response indicated the "Connection: close" semantic.
return do_close();
}
if(ec)
return fail(ec, "write");
// We're done with the response so delete it
res_ = nullptr;