BodyReader and BodyWriter names are swapped (API Change):

Body::reader and Body::writer meanings are reversed, for
consistency with the names of the stream operations:

* Body::reader is used for read, read_some, async_read, async_read_some
* Body::writer is used for write, write_some, async_write, async_write_some

Actions Required:

* Swap the reader and writer names for user defined Body types
* Swap use of is_body_reader and is_body_writer
This commit is contained in:
Vinnie Falco committed 2017-10-30 18:13:40 -07:00
1 parent 101023553e
commit 895c9fa7ed
29 files changed
+582 -583

No files matched your search

+1 -1
View File
@@ -15,8 +15,8 @@ namespace beast {
namespace http {
BOOST_STATIC_ASSERT(is_body<empty_body>::value);
BOOST_STATIC_ASSERT(is_body_reader<empty_body>::value);
BOOST_STATIC_ASSERT(is_body_writer<empty_body>::value);
BOOST_STATIC_ASSERT(is_body_reader<empty_body>::value);
} // http
} // beast
+4 -4
View File
@@ -24,13 +24,13 @@ public:
{
struct value_type{};
struct reader
struct writer
{
using const_buffers_type =
boost::asio::const_buffer;
template<bool isRequest, class Fields>
reader(message<isRequest, const_body, Fields> const&);
writer(message<isRequest, const_body, Fields> const&);
void
init(error_code& ec);
@@ -44,13 +44,13 @@ public:
{
struct value_type{};
struct reader
struct writer
{
using const_buffers_type =
boost::asio::const_buffer;
template<bool isRequest, class Fields>
reader(message<isRequest, mutable_body, Fields>&);
writer(message<isRequest, mutable_body, Fields>&);
void
init(error_code& ec);
+2 -2
View File
@@ -34,7 +34,7 @@ struct span_body_test
BEAST_EXPECT(req.body().size() == 3);
BEAST_EXPECT(B::size(req.body()) == 3);
B::reader r{req};
B::writer r{req};
error_code ec;
r.init(ec);
BEAST_EXPECTS(! ec, ec.message());
@@ -50,7 +50,7 @@ struct span_body_test
using B = span_body<char>;
request<B> req;
req.body() = span<char>{buf, sizeof(buf)};
B::writer w{req};
B::reader w{req};
error_code ec;
w.init(boost::none, ec);
BEAST_EXPECTS(! ec, ec.message());
+1 -1
View File
@@ -15,8 +15,8 @@ namespace beast {
namespace http {
BOOST_STATIC_ASSERT(is_body<string_body>::value);
BOOST_STATIC_ASSERT(is_body_reader<string_body>::value);
BOOST_STATIC_ASSERT(is_body_writer<string_body>::value);
BOOST_STATIC_ASSERT(is_body_reader<string_body>::value);
} // http
} // beast
+3 -3
View File
@@ -17,11 +17,11 @@ namespace boost {
namespace beast {
namespace http {
BOOST_STATIC_ASSERT(! is_body_reader<int>::value);
BOOST_STATIC_ASSERT(! is_body_writer<int>::value);
BOOST_STATIC_ASSERT(is_body_reader<empty_body>::value);
BOOST_STATIC_ASSERT(is_body_writer<empty_body>::value);
BOOST_STATIC_ASSERT(! is_body_writer<std::string>::value);
BOOST_STATIC_ASSERT(! is_body_reader<std::string>::value);
namespace {
+1 -1
View File
@@ -15,8 +15,8 @@ namespace beast {
namespace http {
BOOST_STATIC_ASSERT(is_body<vector_body<char>>::value);
BOOST_STATIC_ASSERT(is_body_reader<vector_body<char>>::value);
BOOST_STATIC_ASSERT(is_body_writer<vector_body<char>>::value);
BOOST_STATIC_ASSERT(is_body_reader<vector_body<char>>::value);
} // http
} // beast
+8 -8
View File
@@ -38,7 +38,7 @@ public:
{
using value_type = std::string;
class reader
class writer
{
value_type const& body_;
@@ -48,7 +48,7 @@ public:
template<bool isRequest, class Allocator>
explicit
reader(message<isRequest,
writer(message<isRequest,
unsized_body, Allocator> const& msg)
: body_(msg.body())
{
@@ -82,7 +82,7 @@ public:
bool mutable read = false;
};
class reader
class writer
{
int step_ = 0;
value_type const& body_;
@@ -93,7 +93,7 @@ public:
template<bool isRequest, class Fields>
explicit
reader(message<isRequest,
writer(message<isRequest,
test_body, Fields> const& msg)
: body_(msg.body())
{
@@ -195,11 +195,11 @@ public:
struct fail_body
{
class reader;
class writer;
class value_type
{
friend class reader;
friend class writer;
std::string s_;
test::fail_counter& fc_;
@@ -219,7 +219,7 @@ public:
}
};
class reader
class writer
{
std::size_t n_ = 0;
value_type const& body_;
@@ -230,7 +230,7 @@ public:
template<bool isRequest, class Allocator>
explicit
reader(message<isRequest,
writer(message<isRequest,
fail_body, Allocator> const& msg)
: body_(msg.body())
{
+21 -21
View File
@@ -19,8 +19,8 @@ namespace boost {
namespace beast {
namespace http {
class BodyReader;
class BodyWriter;
class BodyReader;
//[concept_Body
@@ -29,10 +29,10 @@ struct Body
// The type of message::body when used
struct value_type;
/// The algorithm used for extracting buffers
/// The algorithm used during parsing
class reader;
/// The algorithm used for inserting buffers
/// The algorithm used during serialization
class writer;
/// Returns the body's payload size
@@ -45,27 +45,27 @@ static_assert(is_body<Body>::value, "");
//]
struct Body_BodyReader {
struct Body_BodyWriter {
struct value_type{};
//[concept_BodyReader
//[concept_BodyWriter
struct BodyReader
struct BodyWriter
{
public:
/// The type of buffer returned by `get`.
using const_buffers_type = boost::asio::const_buffer;
/** Construct the reader.
/** Construct the writer.
@param msg The message whose body is to be retrieved.
@param msg The message whose body is to be serialized.
@param ec Set to the error, if any occurred.
*/
template<bool isRequest, class Body, class Fields>
explicit
BodyReader(message<isRequest, Body, Fields> const& msg);
BodyWriter(message<isRequest, Body, Fields> const& msg);
/** Initialize the reader
/** Initialize the writer.
This is called after construction and before the first
call to `get`. The message is valid and complete upon
@@ -109,26 +109,26 @@ public:
};
//]
using reader = BodyReader;
using writer = BodyWriter;
};
static_assert(is_body_reader<Body_BodyReader>::value, "");
static_assert(is_body_writer<Body_BodyWriter>::value, "");
struct Body_BodyWriter {
struct Body_BodyReader {
struct value_type{};
//[concept_BodyWriter
//[concept_BodyReader
struct BodyWriter
struct BodyReader
{
/** Construct the writer.
/** Construct the reader.
@param msg The message whose body is to be stored.
@param msg The message whose body is to be parsed.
*/
template<bool isRequest, class Body, class Fields>
explicit
BodyWriter(message<isRequest, Body, Fields>& msg);
BodyReader(message<isRequest, Body, Fields>& msg);
/** Initialize the writer
/** Initialize the reader.
This is called after construction and before the first
call to `put`. The message is valid and complete upon
@@ -180,10 +180,10 @@ struct BodyWriter
};
//]
using writer = BodyWriter;
using reader = BodyReader;
};
static_assert(is_body_writer<Body_BodyWriter>::value, "");
static_assert(is_body_reader<Body_BodyReader>::value, "");
//[concept_Fields
+3 -3
View File
@@ -299,7 +299,7 @@ void fxx() {
the @b SyncWriteStream concept.
@param m The message to send. The Body type must support
the @b BodyReader concept.
the @b BodyWriter concept.
*/
template<
class SyncWriteStream,
@@ -312,8 +312,8 @@ send(
// Check the template types
static_assert(is_sync_write_stream<SyncWriteStream>::value,
"SyncWriteStream requirements not met");
static_assert(is_body_reader<Body>::value,
"BodyReader requirements not met");
static_assert(is_body_writer<Body>::value,
"BodyWriter requirements not met");
// Create the instance of serializer for the message
serializer<isRequest, Body, Fields> sr{m};