HTTP reads and writes return bytes transferred (API Change):

* HTTP read and write operations now return the
  number of bytes transferred to or from the stream.

Actions Required:

* Modify HTTP read and/or write completion handlers to receive
  the extra std::size_t bytes_transferred parameter.
This commit is contained in:
Vinnie Falco
2017-09-03 18:06:09 -07:00
parent cc8246e27e
commit 49d9d47a0b
22 changed files with 460 additions and 230 deletions
@@ -250,7 +250,8 @@ class session
self_.strand_.wrap(std::bind(
&session::loop,
self_.shared_from_this(),
std::placeholders::_1)));
std::placeholders::_1,
std::placeholders::_2)));
}
};
@@ -282,13 +283,16 @@ public:
void
run()
{
loop();
loop({}, 0);
}
#include <boost/asio/yield.hpp>
void
loop(boost::system::error_code ec = {})
loop(
boost::system::error_code ec,
std::size_t bytes_transferred)
{
boost::ignore_unused(bytes_transferred);
reenter(*this)
{
// Perform the SSL handshake
@@ -297,7 +301,8 @@ public:
strand_.wrap(std::bind(
&session::loop,
shared_from_this(),
std::placeholders::_1)));
std::placeholders::_1,
0)));
if(ec)
return fail(ec, "handshake");
@@ -308,7 +313,8 @@ public:
strand_.wrap(std::bind(
&session::loop,
shared_from_this(),
std::placeholders::_1)));
std::placeholders::_1,
std::placeholders::_2)));
if(ec == http::error::end_of_stream)
{
// The remote host closed the connection
@@ -337,7 +343,8 @@ public:
strand_.wrap(std::bind(
&session::loop,
shared_from_this(),
std::placeholders::_1)));
std::placeholders::_1,
0)));
if(ec)
return fail(ec, "shutdown");