Rename to multi_buffer, basic_multi_buffer (API Change):

These classes are renamed:

* streambuf to multi_buffer
* basic_streambuf to basic_multi_buffer
This commit is contained in:
Vinnie Falco committed 2017-05-09 07:23:07 -07:00
1 parent bef9ae11ea
commit 69259efe87
45 files changed
+744 -745

No files matched your search

+6 -6
View File
@@ -12,7 +12,7 @@
#include <beast/core/buffer_cat.hpp>
#include <beast/core/consuming_buffers.hpp>
#include <beast/core/streambuf.hpp>
#include <beast/core/multi_buffer.hpp>
#include <beast/unit_test/suite.hpp>
namespace beast {
@@ -902,8 +902,8 @@ public:
testSplit()
{
#if 0
streambuf sb;
sb <<
multi_buffer b;
b <<
"POST / HTTP/1.1\r\n"
"Content-Length: 5\r\n"
"\r\n"
@@ -911,7 +911,7 @@ public:
error_code ec;
test_parser<true> p;
p.pause();
auto n = feed(sb.data(), p, ec);
auto n = feed(b.data(), p, ec);
BEAST_EXPECTS(! ec, ec.message());
BEAST_EXPECT(p.got_on_begin);
BEAST_EXPECT(p.got_on_field);
@@ -922,9 +922,9 @@ public:
BEAST_EXPECT(p.state() != parse_state::header);
BEAST_EXPECT(! p.is_complete());
BEAST_EXPECT(p.body.empty());
sb.consume(n);
b.consume(n);
p.resume();
n = feed(sb.data(), p, ec);
n = feed(b.data(), p, ec);
BEAST_EXPECTS(! ec, ec.message());
BEAST_EXPECT(p.got_on_begin);
BEAST_EXPECT(p.got_on_field);
+37 -37
View File
@@ -104,8 +104,8 @@ public:
"*"
};
message<true, direct_body, fields> m;
flat_streambuf sb{1024};
read(is, sb, m);
flat_streambuf b{1024};
read(is, b, m);
BEAST_EXPECT(m.body == "*");
}
@@ -117,8 +117,8 @@ public:
"*"
};
message<false, direct_body, fields> m;
flat_streambuf sb{20};
read(is, sb, m);
flat_streambuf b{20};
read(is, b, m);
BEAST_EXPECT(m.body == "*");
}
@@ -133,8 +133,8 @@ public:
"0\r\n\r\n"
};
message<true, direct_body, fields> m;
flat_streambuf sb{100};
read(is, sb, m);
flat_streambuf b{100};
read(is, b, m);
BEAST_EXPECT(m.body == "*");
}
}
@@ -201,8 +201,8 @@ public:
"*"
};
message<true, indirect_body, fields> m;
flat_streambuf sb{1024};
read(is, sb, m);
flat_streambuf b{1024};
read(is, b, m);
BEAST_EXPECT(m.body == "*");
}
@@ -214,8 +214,8 @@ public:
"*"
};
message<false, indirect_body, fields> m;
flat_streambuf sb{20};
read(is, sb, m);
flat_streambuf b{20};
read(is, b, m);
BEAST_EXPECT(m.body == "*");
}
@@ -231,8 +231,8 @@ public:
"0\r\n\r\n"
};
message<true, indirect_body, fields> m;
flat_streambuf sb{1024};
read(is, sb, m);
flat_streambuf b{1024};
read(is, b, m);
BEAST_EXPECT(m.body == "*");
}
}
@@ -253,15 +253,15 @@ public:
"*****"
};
header_parser<true, fields> p;
flat_streambuf sb{38};
flat_streambuf b{38};
auto const bytes_used =
read_some(is, sb, p);
sb.consume(bytes_used);
read_some(is, b, p);
b.consume(bytes_used);
BEAST_EXPECT(p.size() == 5);
BEAST_EXPECT(sb.size() < 5);
sb.commit(boost::asio::read(
is, sb.prepare(5 - sb.size())));
BEAST_EXPECT(sb.size() == 5);
BEAST_EXPECT(b.size() < 5);
b.commit(boost::asio::read(
is, b.prepare(5 - b.size())));
BEAST_EXPECT(b.size() == 5);
}
// end of file
@@ -272,16 +272,16 @@ public:
"*****"
};
header_parser<false, fields> p;
flat_streambuf sb{20};
flat_streambuf b{20};
auto const bytes_used =
read_some(is, sb, p);
sb.consume(bytes_used);
read_some(is, b, p);
b.consume(bytes_used);
BEAST_EXPECT(p.state() ==
parse_state::body_to_eof);
BEAST_EXPECT(sb.size() < 5);
sb.commit(boost::asio::read(
is, sb.prepare(5 - sb.size())));
BEAST_EXPECT(sb.size() == 5);
BEAST_EXPECT(b.size() < 5);
b.commit(boost::asio::read(
is, b.prepare(5 - b.size())));
BEAST_EXPECT(b.size() == 5);
}
}
@@ -303,10 +303,10 @@ public:
};
header_parser<true, fields> p;
flat_streambuf sb{128};
flat_streambuf b{128};
auto const bytes_used =
read_some(is, sb, p);
sb.consume(bytes_used);
read_some(is, b, p);
b.consume(bytes_used);
BEAST_EXPECT(p.got_header());
BEAST_EXPECT(
p.get().fields["Expect"] ==
@@ -314,7 +314,7 @@ public:
message_parser<
true, string_body, fields> p1{
std::move(p)};
read(is, sb, p1);
read(is, b, p1);
BEAST_EXPECT(
p1.get().body == "*****");
}
@@ -332,7 +332,7 @@ public:
void
relay(
SyncWriteStream& out,
DynamicBuffer& sb,
DynamicBuffer& b,
SyncReadStream& in)
{
flat_streambuf buffer{4096}; // 4K limit
@@ -397,8 +397,8 @@ public:
3 // max_read
};
test::string_ostream os{ios_};
flat_streambuf sb{16};
relay<true>(os, sb, is);
flat_streambuf b{16};
relay<true>(os, b, is);
}
// end of file
@@ -410,8 +410,8 @@ public:
3 // max_read
};
test::string_ostream os{ios_};
flat_streambuf sb{16};
relay<false>(os, sb, is);
flat_streambuf b{16};
relay<false>(os, b, is);
}
// chunked
@@ -427,8 +427,8 @@ public:
2 // max_read
};
test::string_ostream os{ios_};
flat_streambuf sb{16};
relay<true>(os, sb, is);
flat_streambuf b{16};
relay<true>(os, b, is);
}
}
+2 -2
View File
@@ -36,8 +36,8 @@ public:
"xyz";
test::string_istream ss(ios_, s);
message_parser<false, dynamic_body, fields> p;
streambuf sb;
read(ss, sb, p);
multi_buffer b;
read(ss, b, p);
auto const& m = p.get();
BEAST_EXPECT(boost::lexical_cast<std::string>(
buffers(m.body.data())) == "xyz");
+16 -16
View File
@@ -15,7 +15,7 @@
#include <beast/test/string_ostream.hpp>
#include <beast/test/yield_to.hpp>
#include <beast/core/flat_streambuf.hpp>
#include <beast/core/streambuf.hpp>
#include <beast/core/multi_buffer.hpp>
#include <beast/http/header_parser.hpp>
#include <beast/http/read.hpp>
#include <beast/http/read.hpp>
@@ -37,7 +37,7 @@ public:
beast::test::string_istream ss{get_io_service(), s};
error_code ec;
#if 0
streambuf dynabuf;
multi_buffer dynabuf;
#else
flat_streambuf dynabuf{1024};
#endif
@@ -124,9 +124,9 @@ public:
"Content-Length: 1\r\n"
"\r\n"
"*"};
flat_streambuf sb{1024};
flat_streambuf b{1024};
message_parser<true, string_body, fields> p;
read(is, sb, p, ec);
read(is, b, p, ec);
auto const& m = p.get();
BEAST_EXPECTS(! ec, ec.message());
BEAST_EXPECT(p.is_complete());
@@ -142,8 +142,8 @@ public:
// parse through the chunk body
beast::test::string_istream is{
get_io_service(), ""};
streambuf sb;
sb <<
multi_buffer b;
b <<
"PUT / HTTP/1.1\r\n"
"Transfer-Encoding: chunked\r\n"
"\r\n"
@@ -151,20 +151,20 @@ public:
"*";
error_code ec;
message_parser<true, string_body, fields> p;
read(is, sb, p, ec);
BEAST_EXPECT(sb.size() == 0);
read(is, b, p, ec);
BEAST_EXPECT(b.size() == 0);
BEAST_EXPECTS(! ec, ec.message());
BEAST_EXPECT(!p.is_complete());
BEAST_EXPECT(p.get().body == "*");
sb << "\r\n0;d;e=3;f=\"4\"\r\n"
b << "\r\n0;d;e=3;f=\"4\"\r\n"
"Expires: never\r\n"
"MD5-Fingerprint: -\r\n";
// incomplete parse, missing the final crlf
BEAST_EXPECT(p.write(sb.data(), ec) == 0);
BEAST_EXPECT(p.write(b.data(), ec) == 0);
BEAST_EXPECTS(! ec, ec.message());
BEAST_EXPECT(!p.is_complete());
sb << "\r\n"; // final crlf to end message
BEAST_EXPECT(p.write(sb.data(), ec) == sb.size());
b << "\r\n"; // final crlf to end message
BEAST_EXPECT(p.write(b.data(), ec) == b.size());
BEAST_EXPECTS(! ec, ec.message());
BEAST_EXPECT(p.is_complete());
}
@@ -212,18 +212,18 @@ public:
"Content-Length: 5\r\n"
"\r\n"
"*****"};
streambuf sb;
multi_buffer b;
error_code ec;
header_parser<true, fields> p0;
auto const bytes_used =
read_some(ss, sb, p0, ec);
sb.consume(bytes_used);
read_some(ss, b, p0, ec);
b.consume(bytes_used);
BEAST_EXPECTS(! ec, ec.message());
BEAST_EXPECT(p0.state() != parse_state::header);
BEAST_EXPECT(! p0.is_complete());
message_parser<true,
string_body, fields> p1{std::move(p0)};
read(ss, sb, p1, ec);
read(ss, b, p1, ec);
BEAST_EXPECTS(! ec, ec.message());
BEAST_EXPECT(p1.get().body == "*****");
}
+8 -8
View File
@@ -11,7 +11,7 @@
#include <beast/http.hpp>
#include <beast/core/consuming_buffers.hpp>
#include <beast/core/ostream.hpp>
#include <beast/core/streambuf.hpp>
#include <beast/core/multi_buffer.hpp>
#include <beast/unit_test/suite.hpp>
#include <boost/lexical_cast.hpp>
#include <chrono>
@@ -26,7 +26,7 @@ class parser_bench_test : public beast::unit_test::suite
public:
static std::size_t constexpr N = 2000;
using corpus = std::vector<streambuf>;
using corpus = std::vector<multi_buffer>;
corpus creq_;
corpus cres_;
@@ -110,13 +110,13 @@ public:
testParser1(std::size_t repeat, corpus const& v)
{
while(repeat--)
for(auto const& sb : v)
for(auto const& b : v)
{
Parser p;
error_code ec;
p.write(sb.data(), ec);
p.write(b.data(), ec);
if(! BEAST_EXPECTS(! ec, ec.message()))
log << to_string(sb.data()) << std::endl;
log << to_string(b.data()) << std::endl;
}
}
@@ -125,13 +125,13 @@ public:
testParser2(std::size_t repeat, corpus const& v)
{
while(repeat--)
for(auto const& sb : v)
for(auto const& b : v)
{
Parser p;
error_code ec;
feed(sb.data(), p, ec);
feed(b.data(), p, ec);
if(! BEAST_EXPECTS(! ec, ec.message()))
log << to_string(sb.data()) << std::endl;
log << to_string(b.data()) << std::endl;
}
}
+32 -32
View File
@@ -40,15 +40,15 @@ public:
auto const len = strlen(s);
for(n = 0; n < limit; ++n)
{
streambuf sb;
sb.commit(buffer_copy(
sb.prepare(len), buffer(s, len)));
multi_buffer b;
b.commit(buffer_copy(
b.prepare(len), buffer(s, len)));
test::fail_counter fc(n);
test::fail_stream<
test::string_istream> fs{fc, ios_, ""};
test_parser<isRequest> p(fc);
error_code ec;
read(fs, sb, p, ec);
read(fs, b, p, ec);
if(! ec)
break;
}
@@ -56,30 +56,30 @@ public:
for(n = 0; n < limit; ++n)
{
static std::size_t constexpr pre = 10;
streambuf sb;
sb.commit(buffer_copy(
sb.prepare(pre), buffer(s, pre)));
multi_buffer b;
b.commit(buffer_copy(
b.prepare(pre), buffer(s, pre)));
test::fail_counter fc(n);
test::fail_stream<test::string_istream> fs{
fc, ios_, std::string{s + pre, len - pre}};
test_parser<isRequest> p(fc);
error_code ec;
read(fs, sb, p, ec);
read(fs, b, p, ec);
if(! ec)
break;
}
BEAST_EXPECT(n < limit);
for(n = 0; n < limit; ++n)
{
streambuf sb;
sb.commit(buffer_copy(
sb.prepare(len), buffer(s, len)));
multi_buffer b;
b.commit(buffer_copy(
b.prepare(len), buffer(s, len)));
test::fail_counter fc(n);
test::fail_stream<
test::string_istream> fs{fc, ios_, ""};
test_parser<isRequest> p(fc);
error_code ec;
async_read(fs, sb, p, do_yield[ec]);
async_read(fs, b, p, do_yield[ec]);
if(! ec)
break;
}
@@ -87,15 +87,15 @@ public:
for(n = 0; n < limit; ++n)
{
static std::size_t constexpr pre = 10;
streambuf sb;
sb.commit(buffer_copy(
sb.prepare(pre), buffer(s, pre)));
multi_buffer b;
b.commit(buffer_copy(
b.prepare(pre), buffer(s, pre)));
test::fail_counter fc(n);
test::fail_stream<test::string_istream> fs{
fc, ios_, std::string{s + pre, len - pre}};
test_parser<isRequest> p(fc);
error_code ec;
async_read(fs, sb, p, do_yield[ec]);
async_read(fs, b, p, do_yield[ec]);
if(! ec)
break;
}
@@ -106,10 +106,10 @@ public:
{
try
{
streambuf sb;
multi_buffer b;
test::string_istream ss(ios_, "GET / X");
message_parser<true, dynamic_body, fields> p;
read(ss, sb, p);
read(ss, b, p);
fail();
}
catch(std::exception const&)
@@ -197,8 +197,8 @@ public:
request<dynamic_body> m;
try
{
streambuf sb;
read(fs, sb, m);
multi_buffer b;
read(fs, b, m);
break;
}
catch(std::exception const&)
@@ -218,8 +218,8 @@ public:
);
request<dynamic_body> m;
error_code ec;
streambuf sb;
read(fs, sb, m, ec);
multi_buffer b;
read(fs, b, m, ec);
if(! ec)
break;
}
@@ -236,8 +236,8 @@ public:
);
request<dynamic_body> m;
error_code ec;
streambuf sb;
async_read(fs, sb, m, do_yield[ec]);
multi_buffer b;
async_read(fs, b, m, do_yield[ec]);
if(! ec)
break;
}
@@ -248,19 +248,19 @@ public:
testEof(yield_context do_yield)
{
{
streambuf sb;
multi_buffer b;
test::string_istream ss(ios_, "");
message_parser<true, dynamic_body, fields> p;
error_code ec;
read(ss, sb, p, ec);
read(ss, b, p, ec);
BEAST_EXPECT(ec == boost::asio::error::eof);
}
{
streambuf sb;
multi_buffer b;
test::string_istream ss(ios_, "");
message_parser<true, dynamic_body, fields> p;
error_code ec;
async_read(ss, sb, p, do_yield[ec]);
async_read(ss, b, p, do_yield[ec]);
BEAST_EXPECT(ec == boost::asio::error::eof);
}
}
@@ -286,9 +286,9 @@ public:
test::string_istream is{ios,
"GET / HTTP/1.1\r\n\r\n"};
BEAST_EXPECT(handler::count() == 0);
streambuf sb;
multi_buffer b;
message<true, dynamic_body, fields> m;
async_read(is, sb, m, handler{});
async_read(is, b, m, handler{});
BEAST_EXPECT(handler::count() > 0);
ios.stop();
BEAST_EXPECT(handler::count() > 0);
@@ -305,9 +305,9 @@ public:
test::string_istream is{ios,
"GET / HTTP/1.1\r\n\r\n"};
BEAST_EXPECT(handler::count() == 0);
streambuf sb;
multi_buffer b;
message<true, dynamic_body, fields> m;
async_read(is, sb, m, handler{});
async_read(is, b, m, handler{});
BEAST_EXPECT(handler::count() > 0);
}
BEAST_EXPECT(handler::count() == 0);
+1 -1
View File
@@ -13,7 +13,7 @@
#include <beast/http/string_body.hpp>
#include <beast/http/write.hpp>
#include <beast/core/error.hpp>
#include <beast/core/streambuf.hpp>
#include <beast/core/multi_buffer.hpp>
#include <beast/test/fail_stream.hpp>
#include <beast/test/string_ostream.hpp>
#include <beast/test/yield_to.hpp>