forked from boostorg/beast
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:
1 parent
101023553e
commit
895c9fa7ed
29 files changed
+582
-583
No files matched your search
@@ -56,7 +56,7 @@ struct basic_dynamic_body
|
||||
return v.size();
|
||||
}
|
||||
|
||||
/** The algorithm for serializing the body
|
||||
/** The algorithm for parsing the body
|
||||
|
||||
Meets the requirements of @b BodyReader.
|
||||
*/
|
||||
@@ -64,51 +64,13 @@ struct basic_dynamic_body
|
||||
using reader = implementation_defined;
|
||||
#else
|
||||
class reader
|
||||
{
|
||||
DynamicBuffer const& body_;
|
||||
|
||||
public:
|
||||
using const_buffers_type =
|
||||
typename DynamicBuffer::const_buffers_type;
|
||||
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
reader(message<isRequest,
|
||||
basic_dynamic_body, Fields> const& m)
|
||||
: body_(m.body())
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
init(error_code& ec)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
}
|
||||
|
||||
boost::optional<std::pair<const_buffers_type, bool>>
|
||||
get(error_code& ec)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
return {{body_.data(), false}};
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
/** The algorithm for parsing the body
|
||||
|
||||
Meets the requirements of @b BodyReader.
|
||||
*/
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
using writer = implementation_defined;
|
||||
#else
|
||||
class writer
|
||||
{
|
||||
value_type& body_;
|
||||
|
||||
public:
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
writer(message<isRequest,
|
||||
reader(message<isRequest,
|
||||
basic_dynamic_body, Fields>& msg)
|
||||
: body_(msg.body())
|
||||
{
|
||||
@@ -160,6 +122,44 @@ struct basic_dynamic_body
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
/** The algorithm for serializing the body
|
||||
|
||||
Meets the requirements of @b BodyWriter.
|
||||
*/
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
using writer = implementation_defined;
|
||||
#else
|
||||
class writer
|
||||
{
|
||||
DynamicBuffer const& body_;
|
||||
|
||||
public:
|
||||
using const_buffers_type =
|
||||
typename DynamicBuffer::const_buffers_type;
|
||||
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
writer(message<isRequest,
|
||||
basic_dynamic_body, Fields> const& m)
|
||||
: body_(m.body())
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
init(error_code& ec)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
}
|
||||
|
||||
boost::optional<std::pair<const_buffers_type, bool>>
|
||||
get(error_code& ec)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
return {{body_.data(), false}};
|
||||
}
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
} // http
|
||||
|
||||
@@ -51,10 +51,10 @@ struct basic_file_body
|
||||
/// The type of File this body uses
|
||||
using file_type = File;
|
||||
|
||||
// Algorithm for retrieving buffers when serializing.
|
||||
// Algorithm for storing buffers when parsing.
|
||||
class reader;
|
||||
|
||||
// Algorithm for storing buffers when parsing.
|
||||
// Algorithm for retrieving buffers when serializing.
|
||||
class writer;
|
||||
|
||||
// The type of the @ref message::body member.
|
||||
@@ -225,7 +225,7 @@ size(value_type const& body)
|
||||
to extract the buffers representing the body.
|
||||
*/
|
||||
template<class File>
|
||||
class basic_file_body<File>::reader
|
||||
class basic_file_body<File>::writer
|
||||
{
|
||||
value_type& body_; // The body we are reading from
|
||||
std::uint64_t remain_; // The number of unread bytes
|
||||
@@ -239,8 +239,8 @@ public:
|
||||
|
||||
// Constructor.
|
||||
//
|
||||
// `m` holds the message we are sending, which will
|
||||
// always have the `file_body` as the body type.
|
||||
// `m` holds the message we are serializing, which will
|
||||
// always have the `basic_file_body` as the body type.
|
||||
//
|
||||
// Note that the message is passed by non-const reference.
|
||||
// This is intentional, because reading from the file
|
||||
@@ -248,7 +248,7 @@ public:
|
||||
// operation logically not-const (although it is bitwise
|
||||
// const).
|
||||
//
|
||||
// The BodyReader concept allows the reader to choose
|
||||
// The BodyWriter concept allows the writer to choose
|
||||
// whether to take the message by const reference or
|
||||
// non-const reference. Depending on the choice, a
|
||||
// serializer constructed using that body type will
|
||||
@@ -262,13 +262,13 @@ public:
|
||||
// a time.
|
||||
//
|
||||
template<bool isRequest, class Fields>
|
||||
reader(message<
|
||||
writer(message<
|
||||
isRequest, basic_file_body, Fields>& m);
|
||||
|
||||
// Initializer
|
||||
//
|
||||
// This is called before the body is serialized and
|
||||
// gives the reader a chance to do something that might
|
||||
// gives the writer a chance to do something that might
|
||||
// need to return an error code.
|
||||
//
|
||||
void
|
||||
@@ -295,8 +295,8 @@ public:
|
||||
template<class File>
|
||||
template<bool isRequest, class Fields>
|
||||
basic_file_body<File>::
|
||||
reader::
|
||||
reader(message<isRequest, basic_file_body, Fields>& m)
|
||||
writer::
|
||||
writer(message<isRequest, basic_file_body, Fields>& m)
|
||||
: body_(m.body())
|
||||
{
|
||||
// The file must already be open
|
||||
@@ -310,7 +310,7 @@ reader(message<isRequest, basic_file_body, Fields>& m)
|
||||
template<class File>
|
||||
void
|
||||
basic_file_body<File>::
|
||||
reader::
|
||||
writer::
|
||||
init(error_code& ec)
|
||||
{
|
||||
// The error_code specification requires that we
|
||||
@@ -329,7 +329,7 @@ init(error_code& ec)
|
||||
template<class File>
|
||||
auto
|
||||
basic_file_body<File>::
|
||||
reader::
|
||||
writer::
|
||||
get(error_code& ec) ->
|
||||
boost::optional<std::pair<const_buffers_type, bool>>
|
||||
{
|
||||
@@ -389,7 +389,7 @@ get(error_code& ec) ->
|
||||
to store incoming buffers representing the body.
|
||||
*/
|
||||
template<class File>
|
||||
class basic_file_body<File>::writer
|
||||
class basic_file_body<File>::reader
|
||||
{
|
||||
value_type& body_; // The body we are writing to
|
||||
|
||||
@@ -399,17 +399,17 @@ public:
|
||||
// This is called after the header is parsed and
|
||||
// indicates that a non-zero sized body may be present.
|
||||
// `m` holds the message we are receiving, which will
|
||||
// always have the `file_body` as the body type.
|
||||
// always have the `basic_file_body` as the body type.
|
||||
//
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
writer(
|
||||
reader(
|
||||
message<isRequest, basic_file_body, Fields>& m);
|
||||
|
||||
// Initializer
|
||||
//
|
||||
// This is called before the body is parsed and
|
||||
// gives the writer a chance to do something that might
|
||||
// gives the reader a chance to do something that might
|
||||
// need to return an error code. It informs us of
|
||||
// the payload size (`content_length`) which we can
|
||||
// optionally use for optimization.
|
||||
@@ -440,14 +440,14 @@ public:
|
||||
|
||||
//[example_http_file_body_6
|
||||
|
||||
// We don't do much in the writer constructor since the
|
||||
// We don't do much in the reader constructor since the
|
||||
// file is already open.
|
||||
//
|
||||
template<class File>
|
||||
template<bool isRequest, class Fields>
|
||||
basic_file_body<File>::
|
||||
writer::
|
||||
writer(message<isRequest, basic_file_body, Fields>& m)
|
||||
reader::
|
||||
reader(message<isRequest, basic_file_body, Fields>& m)
|
||||
: body_(m.body())
|
||||
{
|
||||
}
|
||||
@@ -455,7 +455,7 @@ writer(message<isRequest, basic_file_body, Fields>& m)
|
||||
template<class File>
|
||||
void
|
||||
basic_file_body<File>::
|
||||
writer::
|
||||
reader::
|
||||
init(
|
||||
boost::optional<std::uint64_t> const& content_length,
|
||||
error_code& ec)
|
||||
@@ -482,7 +482,7 @@ template<class File>
|
||||
template<class ConstBufferSequence>
|
||||
std::size_t
|
||||
basic_file_body<File>::
|
||||
writer::
|
||||
reader::
|
||||
put(ConstBufferSequence const& buffers, error_code& ec)
|
||||
{
|
||||
// This function must return the total number of
|
||||
@@ -513,7 +513,7 @@ put(ConstBufferSequence const& buffers, error_code& ec)
|
||||
template<class File>
|
||||
void
|
||||
basic_file_body<File>::
|
||||
writer::
|
||||
reader::
|
||||
finish(error_code& ec)
|
||||
{
|
||||
// This has to be cleared before returning, to
|
||||
|
||||
@@ -91,7 +91,7 @@ struct buffer_body
|
||||
bool more = true;
|
||||
};
|
||||
|
||||
/** The algorithm for serializing the body
|
||||
/** The algorithm for parsing the body
|
||||
|
||||
Meets the requirements of @b BodyReader.
|
||||
*/
|
||||
@@ -99,6 +99,64 @@ struct buffer_body
|
||||
using reader = implementation_defined;
|
||||
#else
|
||||
class reader
|
||||
{
|
||||
value_type& body_;
|
||||
|
||||
public:
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
reader(message<isRequest, buffer_body, Fields>& m)
|
||||
: body_(m.body())
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
init(boost::optional<std::uint64_t> const&, error_code& ec)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
}
|
||||
|
||||
template<class ConstBufferSequence>
|
||||
std::size_t
|
||||
put(ConstBufferSequence const& buffers,
|
||||
error_code& ec)
|
||||
{
|
||||
using boost::asio::buffer_size;
|
||||
using boost::asio::buffer_copy;
|
||||
if(! body_.data)
|
||||
{
|
||||
ec = error::need_buffer;
|
||||
return 0;
|
||||
}
|
||||
auto const bytes_transferred =
|
||||
buffer_copy(boost::asio::buffer(
|
||||
body_.data, body_.size), buffers);
|
||||
body_.data = reinterpret_cast<char*>(
|
||||
body_.data) + bytes_transferred;
|
||||
body_.size -= bytes_transferred;
|
||||
if(bytes_transferred == buffer_size(buffers))
|
||||
ec.assign(0, ec.category());
|
||||
else
|
||||
ec = error::need_buffer;
|
||||
return bytes_transferred;
|
||||
}
|
||||
|
||||
void
|
||||
finish(error_code& ec)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
/** The algorithm for serializing the body
|
||||
|
||||
Meets the requirements of @b BodyWriter.
|
||||
*/
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
using writer = implementation_defined;
|
||||
#else
|
||||
class writer
|
||||
{
|
||||
bool toggle_ = false;
|
||||
value_type const& body_;
|
||||
@@ -109,7 +167,7 @@ struct buffer_body
|
||||
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
reader(message<isRequest,
|
||||
writer(message<isRequest,
|
||||
buffer_body, Fields> const& msg)
|
||||
: body_(msg.body())
|
||||
{
|
||||
@@ -153,64 +211,6 @@ struct buffer_body
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
/** The algorithm for parsing the body
|
||||
|
||||
Meets the requirements of @b BodyReader.
|
||||
*/
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
using writer = implementation_defined;
|
||||
#else
|
||||
class writer
|
||||
{
|
||||
value_type& body_;
|
||||
|
||||
public:
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
writer(message<isRequest, buffer_body, Fields>& m)
|
||||
: body_(m.body())
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
init(boost::optional<std::uint64_t> const&, error_code& ec)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
}
|
||||
|
||||
template<class ConstBufferSequence>
|
||||
std::size_t
|
||||
put(ConstBufferSequence const& buffers,
|
||||
error_code& ec)
|
||||
{
|
||||
using boost::asio::buffer_size;
|
||||
using boost::asio::buffer_copy;
|
||||
if(! body_.data)
|
||||
{
|
||||
ec = error::need_buffer;
|
||||
return 0;
|
||||
}
|
||||
auto const bytes_transferred =
|
||||
buffer_copy(boost::asio::buffer(
|
||||
body_.data, body_.size), buffers);
|
||||
body_.data = reinterpret_cast<char*>(
|
||||
body_.data) + bytes_transferred;
|
||||
body_.size -= bytes_transferred;
|
||||
if(bytes_transferred == buffer_size(buffers))
|
||||
ec.assign(0, ec.category());
|
||||
else
|
||||
ec = error::need_buffer;
|
||||
return bytes_transferred;
|
||||
}
|
||||
|
||||
void
|
||||
finish(error_code& ec)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
}
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
#if ! BOOST_BEAST_DOXYGEN
|
||||
|
||||
@@ -52,7 +52,7 @@ struct empty_body
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** The algorithm for serializing the body
|
||||
/** The algorithm for parsing the body
|
||||
|
||||
Meets the requirements of @b BodyReader.
|
||||
*/
|
||||
@@ -61,43 +61,9 @@ struct empty_body
|
||||
#else
|
||||
struct reader
|
||||
{
|
||||
using const_buffers_type =
|
||||
boost::asio::null_buffers;
|
||||
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
reader(message<isRequest,
|
||||
empty_body, Fields> const&)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
init(error_code& ec)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
}
|
||||
|
||||
boost::optional<std::pair<const_buffers_type, bool>>
|
||||
get(error_code& ec)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
return boost::none;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
/** The algorithm for parsing the body
|
||||
|
||||
Meets the requirements of @b BodyReader.
|
||||
*/
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
using writer = implementation_defined;
|
||||
#else
|
||||
struct writer
|
||||
{
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
writer(message<isRequest, empty_body, Fields>&)
|
||||
reader(message<isRequest, empty_body, Fields>&)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -123,6 +89,40 @@ struct empty_body
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
/** The algorithm for serializing the body
|
||||
|
||||
Meets the requirements of @b BodyWriter.
|
||||
*/
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
using writer = implementation_defined;
|
||||
#else
|
||||
struct writer
|
||||
{
|
||||
using const_buffers_type =
|
||||
boost::asio::null_buffers;
|
||||
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
writer(message<isRequest,
|
||||
empty_body, Fields> const&)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
init(error_code& ec)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
}
|
||||
|
||||
boost::optional<std::pair<const_buffers_type, bool>>
|
||||
get(error_code& ec)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
return boost::none;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
} // http
|
||||
|
||||
@@ -42,15 +42,15 @@ struct basic_file_body<file_win32>
|
||||
{
|
||||
using file_type = file_win32;
|
||||
|
||||
class reader;
|
||||
class writer;
|
||||
class reader;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
class value_type
|
||||
{
|
||||
friend class reader;
|
||||
friend class writer;
|
||||
friend class reader;
|
||||
friend struct basic_file_body<file_win32>;
|
||||
|
||||
template<class, class, bool, class>
|
||||
@@ -100,7 +100,7 @@ struct basic_file_body<file_win32>
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
class reader
|
||||
class writer
|
||||
{
|
||||
template<class, class, bool, class>
|
||||
friend class detail::write_some_win32_op;
|
||||
@@ -123,7 +123,7 @@ struct basic_file_body<file_win32>
|
||||
boost::asio::const_buffer;
|
||||
|
||||
template<bool isRequest, class Fields>
|
||||
reader(message<isRequest,
|
||||
writer(message<isRequest,
|
||||
basic_file_body<file_win32>, Fields>& m)
|
||||
: body_(m.body())
|
||||
{
|
||||
@@ -160,14 +160,14 @@ struct basic_file_body<file_win32>
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
class writer
|
||||
class reader
|
||||
{
|
||||
value_type& body_;
|
||||
|
||||
public:
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
writer(message<isRequest, basic_file_body, Fields>& m)
|
||||
reader(message<isRequest, basic_file_body, Fields>& m)
|
||||
: body_(m.body())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ parser(parser<isRequest, OtherBody, Allocator>&& other,
|
||||
, m_(other.release(), std::forward<Args>(args)...)
|
||||
, wr_(m_)
|
||||
{
|
||||
if(other.wr_inited_)
|
||||
if(other.rd_inited_)
|
||||
BOOST_THROW_EXCEPTION(std::invalid_argument{
|
||||
"moved-from parser has a body"});
|
||||
}
|
||||
|
||||
@@ -738,8 +738,8 @@ read(
|
||||
"DynamicBuffer requirements not met");
|
||||
static_assert(is_body<Body>::value,
|
||||
"Body requirements not met");
|
||||
static_assert(is_body_writer<Body>::value,
|
||||
"BodyWriter requirements not met");
|
||||
static_assert(is_body_reader<Body>::value,
|
||||
"BodyReader requirements not met");
|
||||
error_code ec;
|
||||
auto const bytes_transferred =
|
||||
read(stream, buffer, msg, ec);
|
||||
@@ -766,8 +766,8 @@ read(
|
||||
"DynamicBuffer requirements not met");
|
||||
static_assert(is_body<Body>::value,
|
||||
"Body requirements not met");
|
||||
static_assert(is_body_writer<Body>::value,
|
||||
"BodyWriter requirements not met");
|
||||
static_assert(is_body_reader<Body>::value,
|
||||
"BodyReader requirements not met");
|
||||
parser<isRequest, Body, Allocator> p{std::move(msg)};
|
||||
p.eager(true);
|
||||
auto const bytes_transferred =
|
||||
@@ -798,8 +798,8 @@ async_read(
|
||||
"DynamicBuffer requirements not met");
|
||||
static_assert(is_body<Body>::value,
|
||||
"Body requirements not met");
|
||||
static_assert(is_body_writer<Body>::value,
|
||||
"BodyWriter requirements not met");
|
||||
static_assert(is_body_reader<Body>::value,
|
||||
"BodyReader requirements not met");
|
||||
boost::asio::async_completion<
|
||||
ReadHandler,
|
||||
void(error_code, std::size_t)> init{handler};
|
||||
|
||||
@@ -499,8 +499,8 @@ write_some(
|
||||
"SyncWriteStream requirements not met");
|
||||
static_assert(is_body<Body>::value,
|
||||
"Body 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");
|
||||
error_code ec;
|
||||
auto const bytes_transferred =
|
||||
write_some(stream, sr, ec);
|
||||
@@ -522,8 +522,8 @@ write_some(
|
||||
"SyncWriteStream requirements not met");
|
||||
static_assert(is_body<Body>::value,
|
||||
"Body 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");
|
||||
return detail::write_some(stream, sr, ec);
|
||||
}
|
||||
|
||||
@@ -543,8 +543,8 @@ async_write_some(
|
||||
"AsyncWriteStream requirements not met");
|
||||
static_assert(is_body<Body>::value,
|
||||
"Body 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");
|
||||
return detail::async_write_some(stream, sr,
|
||||
std::forward<WriteHandler>(handler));
|
||||
}
|
||||
@@ -562,8 +562,8 @@ write_header(SyncWriteStream& stream,
|
||||
"SyncWriteStream requirements not met");
|
||||
static_assert(is_body<Body>::value,
|
||||
"Body 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");
|
||||
error_code ec;
|
||||
auto const bytes_transferred =
|
||||
write_header(stream, sr, ec);
|
||||
@@ -585,8 +585,8 @@ write_header(
|
||||
"SyncWriteStream requirements not met");
|
||||
static_assert(is_body<Body>::value,
|
||||
"Body 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");
|
||||
sr.split(true);
|
||||
std::size_t bytes_transferred = 0;
|
||||
if(! sr.is_header_done())
|
||||
@@ -626,8 +626,8 @@ async_write_header(
|
||||
"AsyncWriteStream requirements not met");
|
||||
static_assert(is_body<Body>::value,
|
||||
"Body 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");
|
||||
sr.split(true);
|
||||
boost::asio::async_completion<
|
||||
WriteHandler,
|
||||
@@ -703,8 +703,8 @@ async_write(
|
||||
"AsyncWriteStream requirements not met");
|
||||
static_assert(is_body<Body>::value,
|
||||
"Body 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");
|
||||
sr.split(false);
|
||||
boost::asio::async_completion<
|
||||
WriteHandler,
|
||||
@@ -733,8 +733,8 @@ write(
|
||||
"SyncWriteStream requirements not met");
|
||||
static_assert(is_body<Body>::value,
|
||||
"Body 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");
|
||||
error_code ec;
|
||||
auto const bytes_transferred =
|
||||
write(stream, msg, ec);
|
||||
@@ -756,8 +756,8 @@ write(
|
||||
"SyncWriteStream requirements not met");
|
||||
static_assert(is_body<Body>::value,
|
||||
"Body 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");
|
||||
serializer<isRequest, Body, Fields> sr{msg};
|
||||
return write(stream, sr, ec);
|
||||
}
|
||||
@@ -778,8 +778,8 @@ async_write(
|
||||
"AsyncWriteStream requirements not met");
|
||||
static_assert(is_body<Body>::value,
|
||||
"Body 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");
|
||||
boost::asio::async_completion<
|
||||
WriteHandler,
|
||||
void(error_code, std::size_t)> init{handler};
|
||||
@@ -860,8 +860,8 @@ operator<<(std::ostream& os,
|
||||
{
|
||||
static_assert(is_body<Body>::value,
|
||||
"Body 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");
|
||||
serializer<isRequest, Body, Fields> sr{msg};
|
||||
error_code ec;
|
||||
detail::write_ostream_lambda<decltype(sr)> f{os, sr};
|
||||
|
||||
@@ -53,8 +53,8 @@ class parser
|
||||
static_assert(is_body<Body>::value,
|
||||
"Body requirements not met");
|
||||
|
||||
static_assert(is_body_writer<Body>::value,
|
||||
"BodyWriter requirements not met");
|
||||
static_assert(is_body_reader<Body>::value,
|
||||
"BodyReader requirements not met");
|
||||
|
||||
template<bool, class, class>
|
||||
friend class parser;
|
||||
@@ -63,8 +63,8 @@ class parser
|
||||
parser<isRequest, Body, Allocator>>;
|
||||
|
||||
message<isRequest, Body, basic_fields<Allocator>> m_;
|
||||
typename Body::writer wr_;
|
||||
bool wr_inited_ = false;
|
||||
typename Body::reader wr_;
|
||||
bool rd_inited_ = false;
|
||||
|
||||
std::function<void(
|
||||
std::uint64_t,
|
||||
@@ -127,7 +127,7 @@ public:
|
||||
This constructs a new parser by move constructing the
|
||||
header from another parser with a different body type. The
|
||||
constructed-from parser must not have any parsed body octets or
|
||||
initialized @b BodyWriter, otherwise an exception is generated.
|
||||
initialized @b BodyReader, otherwise an exception is generated.
|
||||
|
||||
@par Example
|
||||
@code
|
||||
@@ -148,7 +148,7 @@ public:
|
||||
constructor.
|
||||
|
||||
@throws std::invalid_argument Thrown when the constructed-from
|
||||
parser has already initialized a body writer.
|
||||
parser has already initialized a body reader.
|
||||
|
||||
@note This function participates in overload resolution only
|
||||
if the other parser uses a different body type.
|
||||
@@ -247,7 +247,7 @@ public:
|
||||
BOOST_STATIC_ASSERT(! std::is_const<Callback>::value);
|
||||
|
||||
// Can't set the callback after receiving any chunk data!
|
||||
BOOST_ASSERT(! wr_inited_);
|
||||
BOOST_ASSERT(! rd_inited_);
|
||||
|
||||
cb_h_ = std::ref(cb);
|
||||
}
|
||||
@@ -295,7 +295,7 @@ public:
|
||||
BOOST_STATIC_ASSERT(! std::is_const<Callback>::value);
|
||||
|
||||
// Can't set the callback after receiving any chunk data!
|
||||
BOOST_ASSERT(! wr_inited_);
|
||||
BOOST_ASSERT(! rd_inited_);
|
||||
|
||||
cb_b_ = std::ref(cb);
|
||||
}
|
||||
@@ -377,7 +377,7 @@ private:
|
||||
error_code& ec)
|
||||
{
|
||||
wr_.init(content_length, ec);
|
||||
wr_inited_ = true;
|
||||
rd_inited_ = true;
|
||||
}
|
||||
|
||||
std::size_t
|
||||
|
||||
@@ -60,22 +60,22 @@ public:
|
||||
static_assert(is_body<Body>::value,
|
||||
"Body 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");
|
||||
|
||||
/** The type of message this serializer uses
|
||||
|
||||
This may be const or non-const depending on the
|
||||
implementation of the corresponding @b BodyReader.
|
||||
implementation of the corresponding @b BodyWriter.
|
||||
*/
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
using value_type = implementation_defined;
|
||||
#else
|
||||
using value_type =
|
||||
typename std::conditional<
|
||||
std::is_constructible<typename Body::reader,
|
||||
std::is_constructible<typename Body::writer,
|
||||
message<isRequest, Body, Fields>&>::value &&
|
||||
! std::is_constructible<typename Body::reader,
|
||||
! std::is_constructible<typename Body::writer,
|
||||
message<isRequest, Body, Fields> const&>::value,
|
||||
message<isRequest, Body, Fields>,
|
||||
message<isRequest, Body, Fields> const>::type;
|
||||
@@ -111,7 +111,7 @@ private:
|
||||
void
|
||||
do_visit(error_code& ec, Visit& visit);
|
||||
|
||||
using reader = typename Body::reader;
|
||||
using writer = typename Body::writer;
|
||||
|
||||
using cb1_t = buffers_suffix<typename
|
||||
Fields::writer::const_buffers_type>; // header
|
||||
@@ -119,11 +119,11 @@ private:
|
||||
|
||||
using cb2_t = buffers_suffix<buffers_cat_view<
|
||||
typename Fields::writer::const_buffers_type,// header
|
||||
typename reader::const_buffers_type>>; // body
|
||||
typename writer::const_buffers_type>>; // body
|
||||
using pcb2_t = buffers_prefix_view<cb2_t const&>;
|
||||
|
||||
using cb3_t = buffers_suffix<
|
||||
typename reader::const_buffers_type>; // body
|
||||
typename writer::const_buffers_type>; // body
|
||||
using pcb3_t = buffers_prefix_view<cb3_t const&>;
|
||||
|
||||
using cb4_t = buffers_suffix<buffers_cat_view<
|
||||
@@ -131,7 +131,7 @@ private:
|
||||
detail::chunk_size, // chunk-size
|
||||
boost::asio::const_buffer, // chunk-ext
|
||||
chunk_crlf, // crlf
|
||||
typename reader::const_buffers_type, // body
|
||||
typename writer::const_buffers_type, // body
|
||||
chunk_crlf>>; // crlf
|
||||
using pcb4_t = buffers_prefix_view<cb4_t const&>;
|
||||
|
||||
@@ -139,7 +139,7 @@ private:
|
||||
detail::chunk_size, // chunk-header
|
||||
boost::asio::const_buffer, // chunk-ext
|
||||
chunk_crlf, // crlf
|
||||
typename reader::const_buffers_type, // body
|
||||
typename writer::const_buffers_type, // body
|
||||
chunk_crlf>>; // crlf
|
||||
using pcb5_t = buffers_prefix_view<cb5_t const&>;
|
||||
|
||||
@@ -147,7 +147,7 @@ private:
|
||||
detail::chunk_size, // chunk-header
|
||||
boost::asio::const_buffer, // chunk-size
|
||||
chunk_crlf, // crlf
|
||||
typename reader::const_buffers_type, // body
|
||||
typename writer::const_buffers_type, // body
|
||||
chunk_crlf, // crlf
|
||||
boost::asio::const_buffer, // chunk-final
|
||||
boost::asio::const_buffer, // trailers
|
||||
@@ -159,7 +159,7 @@ private:
|
||||
detail::chunk_size, // chunk-size
|
||||
boost::asio::const_buffer, // chunk-ext
|
||||
chunk_crlf, // crlf
|
||||
typename reader::const_buffers_type, // body
|
||||
typename writer::const_buffers_type, // body
|
||||
chunk_crlf, // crlf
|
||||
boost::asio::const_buffer, // chunk-final
|
||||
boost::asio::const_buffer, // trailers
|
||||
@@ -173,7 +173,7 @@ private:
|
||||
using pcb8_t = buffers_prefix_view<cb8_t const&>;
|
||||
|
||||
value_type& m_;
|
||||
reader rd_;
|
||||
writer rd_;
|
||||
boost::optional<typename Fields::writer> frd_;
|
||||
beast::detail::variant<
|
||||
cb1_t, cb2_t, cb3_t, cb4_t,
|
||||
@@ -210,7 +210,7 @@ public:
|
||||
the type of Body used, this may or may not be a `const` reference.
|
||||
|
||||
@note This function participates in overload resolution only if
|
||||
Body::reader is constructible from a `const` message reference.
|
||||
Body::writer is constructible from a `const` message reference.
|
||||
*/
|
||||
explicit
|
||||
serializer(value_type& msg);
|
||||
@@ -336,17 +336,17 @@ public:
|
||||
void
|
||||
consume(std::size_t n);
|
||||
|
||||
/** Provides low-level access to the associated @b BodyReader
|
||||
/** Provides low-level access to the associated @b BodyWriter
|
||||
|
||||
This function provides access to the instance of the reader
|
||||
This function provides access to the instance of the writer
|
||||
associated with the body and created by the serializer
|
||||
upon construction. The behavior of accessing this object
|
||||
is defined by the specification of the particular reader
|
||||
is defined by the specification of the particular writer
|
||||
and its associated body.
|
||||
|
||||
@return A reference to the reader.
|
||||
@return A reference to the writer.
|
||||
*/
|
||||
reader&
|
||||
writer&
|
||||
reader_impl()
|
||||
{
|
||||
return rd_;
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
return body.size();
|
||||
}
|
||||
|
||||
/** The algorithm for serializing the body
|
||||
/** The algorithm for parsing the body
|
||||
|
||||
Meets the requirements of @b BodyReader.
|
||||
*/
|
||||
@@ -67,55 +67,13 @@ public:
|
||||
using reader = implementation_defined;
|
||||
#else
|
||||
class reader
|
||||
{
|
||||
value_type const& body_;
|
||||
|
||||
public:
|
||||
using const_buffers_type =
|
||||
boost::asio::const_buffer;
|
||||
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
reader(message<isRequest,
|
||||
span_body, Fields> const& msg)
|
||||
: body_(msg.body())
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
init(error_code& ec)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
}
|
||||
|
||||
boost::optional<std::pair<const_buffers_type, bool>>
|
||||
get(error_code& ec)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
return {{
|
||||
{ body_.data(),
|
||||
body_.size() * sizeof(typename
|
||||
value_type::value_type)},
|
||||
false}};
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
/** The algorithm for parsing the body
|
||||
|
||||
Meets the requirements of @b BodyReader.
|
||||
*/
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
using writer = implementation_defined;
|
||||
#else
|
||||
class writer
|
||||
{
|
||||
value_type& body_;
|
||||
|
||||
public:
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
writer(message<isRequest,
|
||||
reader(message<isRequest,
|
||||
span_body, Fields>& m)
|
||||
: body_(m.body())
|
||||
{
|
||||
@@ -162,6 +120,48 @@ public:
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
/** The algorithm for serializing the body
|
||||
|
||||
Meets the requirements of @b BodyWriter.
|
||||
*/
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
using writer = implementation_defined;
|
||||
#else
|
||||
class writer
|
||||
{
|
||||
value_type const& body_;
|
||||
|
||||
public:
|
||||
using const_buffers_type =
|
||||
boost::asio::const_buffer;
|
||||
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
writer(message<isRequest,
|
||||
span_body, Fields> const& msg)
|
||||
: body_(msg.body())
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
init(error_code& ec)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
}
|
||||
|
||||
boost::optional<std::pair<const_buffers_type, bool>>
|
||||
get(error_code& ec)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
return {{
|
||||
{ body_.data(),
|
||||
body_.size() * sizeof(typename
|
||||
value_type::value_type)},
|
||||
false}};
|
||||
}
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
} // http
|
||||
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
return body.size();
|
||||
}
|
||||
|
||||
/** The algorithm for serializing the body
|
||||
/** The algorithm for parsing the body
|
||||
|
||||
Meets the requirements of @b BodyReader.
|
||||
*/
|
||||
@@ -75,52 +75,13 @@ public:
|
||||
using reader = implementation_defined;
|
||||
#else
|
||||
class reader
|
||||
{
|
||||
value_type const& body_;
|
||||
|
||||
public:
|
||||
using const_buffers_type =
|
||||
boost::asio::const_buffer;
|
||||
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
reader(message<isRequest,
|
||||
basic_string_body, Fields> const& msg)
|
||||
: body_(msg.body())
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
init(error_code& ec)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
}
|
||||
|
||||
boost::optional<std::pair<const_buffers_type, bool>>
|
||||
get(error_code& ec)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
return {{const_buffers_type{
|
||||
body_.data(), body_.size()}, false}};
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
/** The algorithm for parsing the body
|
||||
|
||||
Meets the requirements of @b BodyReader.
|
||||
*/
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
using writer = implementation_defined;
|
||||
#else
|
||||
class writer
|
||||
{
|
||||
value_type& body_;
|
||||
|
||||
public:
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
writer(message<isRequest,
|
||||
reader(message<isRequest,
|
||||
basic_string_body, Fields>& m)
|
||||
: body_(m.body())
|
||||
{
|
||||
@@ -188,6 +149,45 @@ public:
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
/** The algorithm for serializing the body
|
||||
|
||||
Meets the requirements of @b BodyWriter.
|
||||
*/
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
using writer = implementation_defined;
|
||||
#else
|
||||
class writer
|
||||
{
|
||||
value_type const& body_;
|
||||
|
||||
public:
|
||||
using const_buffers_type =
|
||||
boost::asio::const_buffer;
|
||||
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
writer(message<isRequest,
|
||||
basic_string_body, Fields> const& msg)
|
||||
: body_(msg.body())
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
init(error_code& ec)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
}
|
||||
|
||||
boost::optional<std::pair<const_buffers_type, bool>>
|
||||
get(error_code& ec)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
return {{const_buffers_type{
|
||||
body_.data(), body_.size()}, false}};
|
||||
}
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
/// A @b Body using `std::string`
|
||||
|
||||
@@ -57,7 +57,7 @@ using is_body = detail::has_value_type<T>;
|
||||
|
||||
@li `T` has a nested type named `reader`
|
||||
|
||||
@li The nested type meets the requirements of @b BodyReader.
|
||||
@li The nested type meets the requirements of @b BodyWriter.
|
||||
|
||||
@tparam T The body type to test.
|
||||
|
||||
@@ -65,55 +65,9 @@ using is_body = detail::has_value_type<T>;
|
||||
@code
|
||||
template<bool isRequest, class Body, class Fields>
|
||||
void check_can_serialize(message<isRequest, Body, Fields> const&)
|
||||
{
|
||||
static_assert(is_body_reader<Body>::value,
|
||||
"Cannot serialize Body, no reader");
|
||||
}
|
||||
@endcode
|
||||
*/
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
template<class T>
|
||||
struct is_body_reader : std::integral_constant<bool, ...> {};
|
||||
#else
|
||||
template<class T, class = void>
|
||||
struct is_body_reader : std::false_type {};
|
||||
|
||||
template<class T>
|
||||
struct is_body_reader<T, beast::detail::void_t<
|
||||
typename T::reader,
|
||||
typename T::reader::const_buffers_type,
|
||||
decltype(
|
||||
std::declval<typename T::reader&>().init(std::declval<error_code&>()),
|
||||
std::declval<boost::optional<std::pair<
|
||||
typename T::reader::const_buffers_type, bool>>&>() =
|
||||
std::declval<typename T::reader>().get(std::declval<error_code&>()),
|
||||
(void)0)>> : std::integral_constant<bool,
|
||||
boost::asio::is_const_buffer_sequence<
|
||||
typename T::reader::const_buffers_type>::value &&
|
||||
std::is_constructible<typename T::reader,
|
||||
message<true, T, detail::fields_model>&>::value &&
|
||||
std::is_constructible<typename T::reader,
|
||||
message<false, T, detail::fields_model>&>::value
|
||||
> {};
|
||||
#endif
|
||||
|
||||
/** Determine if a @b Body type has a writer.
|
||||
|
||||
This metafunction is equivalent to `std::true_type` if:
|
||||
|
||||
@li `T` has a nested type named `writer`
|
||||
|
||||
@li The nested type meets the requirements of @b BodyWriter.
|
||||
|
||||
@tparam T The body type to test.
|
||||
|
||||
@par Example
|
||||
@code
|
||||
template<bool isRequest, class Body, class Fields>
|
||||
void check_can_parse(message<isRequest, Body, Fields>&)
|
||||
{
|
||||
static_assert(is_body_writer<Body>::value,
|
||||
"Cannot parse Body, no writer");
|
||||
"Cannot serialize Body, no reader");
|
||||
}
|
||||
@endcode
|
||||
*/
|
||||
@@ -125,20 +79,66 @@ template<class T, class = void>
|
||||
struct is_body_writer : std::false_type {};
|
||||
|
||||
template<class T>
|
||||
struct is_body_writer<T, beast::detail::void_t<decltype(
|
||||
std::declval<typename T::writer&>().init(
|
||||
struct is_body_writer<T, beast::detail::void_t<
|
||||
typename T::writer,
|
||||
typename T::writer::const_buffers_type,
|
||||
decltype(
|
||||
std::declval<typename T::writer&>().init(std::declval<error_code&>()),
|
||||
std::declval<boost::optional<std::pair<
|
||||
typename T::writer::const_buffers_type, bool>>&>() =
|
||||
std::declval<typename T::writer>().get(std::declval<error_code&>()),
|
||||
(void)0)>> : std::integral_constant<bool,
|
||||
boost::asio::is_const_buffer_sequence<
|
||||
typename T::writer::const_buffers_type>::value &&
|
||||
std::is_constructible<typename T::writer,
|
||||
message<true, T, detail::fields_model>&>::value &&
|
||||
std::is_constructible<typename T::writer,
|
||||
message<false, T, detail::fields_model>&>::value
|
||||
> {};
|
||||
#endif
|
||||
|
||||
/** Determine if a @b Body type has a reader.
|
||||
|
||||
This metafunction is equivalent to `std::true_type` if:
|
||||
|
||||
@li `T` has a nested type named `reader`
|
||||
|
||||
@li The nested type meets the requirements of @b BodyReader.
|
||||
|
||||
@tparam T The body type to test.
|
||||
|
||||
@par Example
|
||||
@code
|
||||
template<bool isRequest, class Body, class Fields>
|
||||
void check_can_parse(message<isRequest, Body, Fields>&)
|
||||
{
|
||||
static_assert(is_body_reader<Body>::value,
|
||||
"Cannot parse Body, no reader");
|
||||
}
|
||||
@endcode
|
||||
*/
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
template<class T>
|
||||
struct is_body_reader : std::integral_constant<bool, ...> {};
|
||||
#else
|
||||
template<class T, class = void>
|
||||
struct is_body_reader : std::false_type {};
|
||||
|
||||
template<class T>
|
||||
struct is_body_reader<T, beast::detail::void_t<decltype(
|
||||
std::declval<typename T::reader&>().init(
|
||||
boost::optional<std::uint64_t>(),
|
||||
std::declval<error_code&>()),
|
||||
std::declval<std::size_t&>() =
|
||||
std::declval<typename T::writer&>().put(
|
||||
std::declval<typename T::reader&>().put(
|
||||
std::declval<boost::asio::const_buffer>(),
|
||||
std::declval<error_code&>()),
|
||||
std::declval<typename T::writer&>().finish(
|
||||
std::declval<typename T::reader&>().finish(
|
||||
std::declval<error_code&>()),
|
||||
(void)0)>> : std::integral_constant<bool,
|
||||
std::is_constructible<typename T::writer,
|
||||
std::is_constructible<typename T::reader,
|
||||
message<true, T, detail::fields_model>&>::value &&
|
||||
std::is_constructible<typename T::writer,
|
||||
std::is_constructible<typename T::reader,
|
||||
message<false, T, detail::fields_model>&>::value
|
||||
>
|
||||
{
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
return body.size();
|
||||
}
|
||||
|
||||
/** The algorithm for serializing the body
|
||||
/** The algorithm for parsing the body
|
||||
|
||||
Meets the requirements of @b BodyReader.
|
||||
*/
|
||||
@@ -70,52 +70,13 @@ public:
|
||||
using reader = implementation_defined;
|
||||
#else
|
||||
class reader
|
||||
{
|
||||
value_type const& body_;
|
||||
|
||||
public:
|
||||
using const_buffers_type =
|
||||
boost::asio::const_buffer;
|
||||
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
reader(message<isRequest,
|
||||
vector_body, Fields> const& msg)
|
||||
: body_(msg.body())
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
init(error_code& ec)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
}
|
||||
|
||||
boost::optional<std::pair<const_buffers_type, bool>>
|
||||
get(error_code& ec)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
return {{const_buffers_type{
|
||||
body_.data(), body_.size()}, false}};
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
/** The algorithm for parsing the body
|
||||
|
||||
Meets the requirements of @b BodyReader.
|
||||
*/
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
using writer = implementation_defined;
|
||||
#else
|
||||
class writer
|
||||
{
|
||||
value_type& body_;
|
||||
|
||||
public:
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
writer(message<isRequest,
|
||||
reader(message<isRequest,
|
||||
vector_body, Fields>& m)
|
||||
: body_(m.body())
|
||||
{
|
||||
@@ -177,6 +138,45 @@ public:
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
/** The algorithm for serializing the body
|
||||
|
||||
Meets the requirements of @b BodyWriter.
|
||||
*/
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
using writer = implementation_defined;
|
||||
#else
|
||||
class writer
|
||||
{
|
||||
value_type const& body_;
|
||||
|
||||
public:
|
||||
using const_buffers_type =
|
||||
boost::asio::const_buffer;
|
||||
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
writer(message<isRequest,
|
||||
vector_body, Fields> const& msg)
|
||||
: body_(msg.body())
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
init(error_code& ec)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
}
|
||||
|
||||
boost::optional<std::pair<const_buffers_type, bool>>
|
||||
get(error_code& ec)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
return {{const_buffers_type{
|
||||
body_.data(), body_.size()}, false}};
|
||||
}
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
} // http
|
||||
|
||||
Reference in new issue
Block a user