forked from boostorg/beast
Return std::size_t from Body::writer::put (API Change)
`put` returns the number of bytes actually transferred from the input buffers. Actions Required: * Return the number of bytes actually transferred from the input buffers in user defined `Body::writer::put` functions.
This commit is contained in:
1 parent
f3afc834b1
commit
c149321013
19 files changed
+179
-55
No files matched your search
@@ -199,11 +199,11 @@ public:
|
||||
ec.assign(0, ec.category());
|
||||
}
|
||||
|
||||
void
|
||||
on_data(string_view,
|
||||
error_code& ec)
|
||||
std::size_t
|
||||
on_data(string_view s, error_code& ec)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
return s.size();
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Part of Beast
|
||||
|
||||
GroupSources(examples examples)
|
||||
GroupSources(example example)
|
||||
GroupSources(extras/beast extras)
|
||||
GroupSources(include/beast beast)
|
||||
|
||||
|
||||
+3
-1
@@ -125,9 +125,11 @@ struct BodyWriter
|
||||
@param buffers The constant buffer sequence to store.
|
||||
|
||||
@param ec Set to the error, if any occurred.
|
||||
|
||||
@return The number of bytes transferred from the input buffers.
|
||||
*/
|
||||
template<class ConstBufferSequence>
|
||||
void
|
||||
std::size_t
|
||||
put(ConstBufferSequence const& buffers, error_code& ec)
|
||||
{
|
||||
// The specification requires this to indicate "no error"
|
||||
|
||||
@@ -49,13 +49,13 @@ BOOST_STATIC_ASSERT(::detail::is_mutable_container<string_view>::value == false)
|
||||
BOOST_STATIC_ASSERT(::detail::is_mutable_container<std::vector<char>>::value == true);
|
||||
BOOST_STATIC_ASSERT(::detail::is_mutable_container<std::list<char>>::value == false);
|
||||
|
||||
class doc_http_samples_test
|
||||
class doc_examples_test
|
||||
: public beast::unit_test::suite
|
||||
, public beast::test::enable_yield_to
|
||||
{
|
||||
public:
|
||||
// two threads, for some examples using a pipe
|
||||
doc_http_samples_test()
|
||||
doc_examples_test()
|
||||
: enable_yield_to(2)
|
||||
{
|
||||
}
|
||||
@@ -386,6 +386,27 @@ public:
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
doIncrementalRead()
|
||||
{
|
||||
test::pipe c{ios_};
|
||||
std::string s(2048, '*');
|
||||
ostream(c.server.buffer) <<
|
||||
"HTTP/1.1 200 OK\r\n"
|
||||
"Content-Length: 2048\r\n"
|
||||
"Server: test\r\n"
|
||||
"\r\n" <<
|
||||
s;
|
||||
error_code ec;
|
||||
flat_buffer b;
|
||||
std::stringstream ss;
|
||||
read_and_print_body<false>(ss, c.server, b, ec);
|
||||
if(BEAST_EXPECTS(! ec, ec.message()))
|
||||
BEAST_EXPECT(ss.str() == s);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
run()
|
||||
{
|
||||
@@ -399,10 +420,11 @@ public:
|
||||
doDeferredBody();
|
||||
doFileBody();
|
||||
doConstAndMutableBody();
|
||||
doIncrementalRead();
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(doc_http_samples,http,beast);
|
||||
BEAST_DEFINE_TESTSUITE(doc_examples,http,beast);
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
@@ -118,7 +118,7 @@ public:
|
||||
ec.assign(0, ec.category());
|
||||
}
|
||||
|
||||
void
|
||||
std::size_t
|
||||
on_data(string_view s,
|
||||
error_code& ec)
|
||||
{
|
||||
@@ -127,6 +127,7 @@ public:
|
||||
fc_->fail(ec);
|
||||
else
|
||||
ec.assign(0, ec.category());
|
||||
return s.size();
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in new issue
Block a user