forked from boostorg/beast
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:
1 parent
bef9ae11ea
commit
69259efe87
45 files changed
+744
-745
No files matched your search
+18
-18
@@ -75,22 +75,22 @@ public:
|
||||
auto check =
|
||||
[&](frame_header const& fh)
|
||||
{
|
||||
fh_streambuf sb;
|
||||
write(sb, fh);
|
||||
fh_streambuf b;
|
||||
write(b, fh);
|
||||
close_code code;
|
||||
stream_base stream;
|
||||
stream.open(role);
|
||||
detail::frame_header fh1;
|
||||
auto const n =
|
||||
stream.read_fh1(fh1, sb, code);
|
||||
stream.read_fh1(fh1, b, code);
|
||||
if(! BEAST_EXPECT(! code))
|
||||
return;
|
||||
if(! BEAST_EXPECT(sb.size() == n))
|
||||
if(! BEAST_EXPECT(b.size() == n))
|
||||
return;
|
||||
stream.read_fh2(fh1, sb, code);
|
||||
stream.read_fh2(fh1, b, code);
|
||||
if(! BEAST_EXPECT(! code))
|
||||
return;
|
||||
if(! BEAST_EXPECT(sb.size() == 0))
|
||||
if(! BEAST_EXPECT(b.size() == 0))
|
||||
return;
|
||||
BEAST_EXPECT(fh1 == fh);
|
||||
};
|
||||
@@ -127,25 +127,25 @@ public:
|
||||
auto check =
|
||||
[&](frame_header const& fh)
|
||||
{
|
||||
fh_streambuf sb;
|
||||
write(sb, fh);
|
||||
fh_streambuf b;
|
||||
write(b, fh);
|
||||
close_code code;
|
||||
stream_base stream;
|
||||
stream.open(role);
|
||||
detail::frame_header fh1;
|
||||
auto const n =
|
||||
stream.read_fh1(fh1, sb, code);
|
||||
stream.read_fh1(fh1, b, code);
|
||||
if(code)
|
||||
{
|
||||
pass();
|
||||
return;
|
||||
}
|
||||
if(! BEAST_EXPECT(sb.size() == n))
|
||||
if(! BEAST_EXPECT(b.size() == n))
|
||||
return;
|
||||
stream.read_fh2(fh1, sb, code);
|
||||
stream.read_fh2(fh1, b, code);
|
||||
if(! BEAST_EXPECT(code))
|
||||
return;
|
||||
if(! BEAST_EXPECT(sb.size() == 0))
|
||||
if(! BEAST_EXPECT(b.size() == 0))
|
||||
return;
|
||||
};
|
||||
|
||||
@@ -193,25 +193,25 @@ public:
|
||||
using boost::asio::buffer_copy;
|
||||
static role_type constexpr role = role_type::client;
|
||||
std::vector<std::uint8_t> v{bs};
|
||||
fh_streambuf sb;
|
||||
sb.commit(buffer_copy(sb.prepare(v.size()), buffer(v)));
|
||||
fh_streambuf b;
|
||||
b.commit(buffer_copy(b.prepare(v.size()), buffer(v)));
|
||||
stream_base stream;
|
||||
stream.open(role);
|
||||
close_code code;
|
||||
detail::frame_header fh;
|
||||
auto const n =
|
||||
stream.read_fh1(fh, sb, code);
|
||||
stream.read_fh1(fh, b, code);
|
||||
if(code)
|
||||
{
|
||||
pass();
|
||||
return;
|
||||
}
|
||||
if(! BEAST_EXPECT(sb.size() == n))
|
||||
if(! BEAST_EXPECT(b.size() == n))
|
||||
return;
|
||||
stream.read_fh2(fh, sb, code);
|
||||
stream.read_fh2(fh, b, code);
|
||||
if(! BEAST_EXPECT(code))
|
||||
return;
|
||||
if(! BEAST_EXPECT(sb.size() == 0))
|
||||
if(! BEAST_EXPECT(b.size() == 0))
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -129,16 +129,16 @@ public:
|
||||
ws.write(boost::asio::buffer("Hello, world!", 13));
|
||||
|
||||
// Receive Secure WebSocket message, print and close using Beast
|
||||
beast::streambuf sb;
|
||||
beast::multi_buffer b;
|
||||
beast::websocket::opcode op;
|
||||
ws.read(op, sb);
|
||||
ws.read(op, b);
|
||||
ws.close(beast::websocket::close_code::normal);
|
||||
try
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
ws.read(op, sb);
|
||||
sb.consume(sb.size());
|
||||
ws.read(op, b);
|
||||
b.consume(b.size());
|
||||
}
|
||||
}
|
||||
catch(system_error const& se)
|
||||
@@ -147,7 +147,7 @@ public:
|
||||
throw;
|
||||
}
|
||||
BEAST_EXPECT(boost::lexical_cast<std::string>(
|
||||
buffers(sb.data())) == "Hello, world!");
|
||||
buffers(b.data())) == "Hello, world!");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#define WEBSOCKET_ASYNC_SSL_ECHO_SERVER_HPP
|
||||
|
||||
#include <beast/core/placeholders.hpp>
|
||||
#include <beast/core/streambuf.hpp>
|
||||
#include <beast/core/multi_buffer.hpp>
|
||||
#include <beast/websocket/ssl.hpp>
|
||||
#include <beast/websocket/stream.hpp>
|
||||
#include <boost/asio/ssl.hpp>
|
||||
@@ -156,7 +156,7 @@ private:
|
||||
boost::asio::ssl::stream<socket_type>> ws;
|
||||
boost::asio::io_service::strand strand;
|
||||
beast::websocket::opcode op;
|
||||
beast::streambuf db;
|
||||
beast::multi_buffer db;
|
||||
std::size_t id;
|
||||
|
||||
data(async_ssl_echo_server& server_,
|
||||
|
||||
+27
-27
@@ -12,7 +12,7 @@
|
||||
#include "websocket_sync_echo_server.hpp"
|
||||
|
||||
#include <beast/core/ostream.hpp>
|
||||
#include <beast/core/streambuf.hpp>
|
||||
#include <beast/core/multi_buffer.hpp>
|
||||
#include <beast/test/fail_stream.hpp>
|
||||
#include <beast/test/string_istream.hpp>
|
||||
#include <beast/test/string_iostream.hpp>
|
||||
@@ -747,8 +747,8 @@ public:
|
||||
try
|
||||
{
|
||||
opcode op;
|
||||
streambuf sb;
|
||||
c.read(ws, op, sb);
|
||||
multi_buffer b;
|
||||
c.read(ws, op, b);
|
||||
fail("success", __FILE__, __LINE__);
|
||||
}
|
||||
catch(system_error const& e)
|
||||
@@ -777,8 +777,8 @@ public:
|
||||
try
|
||||
{
|
||||
opcode op;
|
||||
streambuf sb;
|
||||
c.read(ws, op, sb);
|
||||
multi_buffer b;
|
||||
c.read(ws, op, b);
|
||||
fail("success", __FILE__, __LINE__);
|
||||
}
|
||||
catch(system_error const& e)
|
||||
@@ -805,8 +805,8 @@ public:
|
||||
try
|
||||
{
|
||||
opcode op;
|
||||
streambuf sb;
|
||||
c.read(ws, op, sb);
|
||||
multi_buffer b;
|
||||
c.read(ws, op, b);
|
||||
fail("success", __FILE__, __LINE__);
|
||||
}
|
||||
catch(system_error const& e)
|
||||
@@ -834,8 +834,8 @@ public:
|
||||
try
|
||||
{
|
||||
opcode op;
|
||||
streambuf sb;
|
||||
c.read(ws, op, sb);
|
||||
multi_buffer b;
|
||||
c.read(ws, op, b);
|
||||
fail("success", __FILE__, __LINE__);
|
||||
}
|
||||
catch(system_error const& e)
|
||||
@@ -1199,7 +1199,7 @@ public:
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
break;
|
||||
opcode op;
|
||||
streambuf db;
|
||||
multi_buffer db;
|
||||
ws.read(op, db, ec);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
break;
|
||||
@@ -1225,7 +1225,7 @@ public:
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
break;
|
||||
opcode op;
|
||||
streambuf db;
|
||||
multi_buffer db;
|
||||
ws.async_read(op, db, do_yield[ec]);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
break;
|
||||
@@ -1290,7 +1290,7 @@ public:
|
||||
|
||||
// Read
|
||||
opcode op;
|
||||
streambuf db;
|
||||
multi_buffer db;
|
||||
++count;
|
||||
ws.async_read(op, db,
|
||||
[&](error_code ec)
|
||||
@@ -1346,7 +1346,7 @@ public:
|
||||
ws.write(buffer_cat(sbuf("TEXT"),
|
||||
cbuf(0x03, 0xea, 0xf0, 0x28, 0x8c, 0xbc)));
|
||||
opcode op;
|
||||
streambuf db;
|
||||
multi_buffer db;
|
||||
std::size_t count = 0;
|
||||
// Read text message with bad utf8.
|
||||
// Causes a close to be sent, blocking writes.
|
||||
@@ -1414,7 +1414,7 @@ public:
|
||||
ws.set_option(message_type(opcode::binary));
|
||||
ws.write(sbuf("CLOSE"));
|
||||
opcode op;
|
||||
streambuf db;
|
||||
multi_buffer db;
|
||||
std::size_t count = 0;
|
||||
// Read a close frame.
|
||||
// Sends a close frame, blocking writes.
|
||||
@@ -1480,7 +1480,7 @@ public:
|
||||
ws.set_option(message_type(opcode::binary));
|
||||
ws.write(sbuf("CLOSE"));
|
||||
opcode op;
|
||||
streambuf db;
|
||||
multi_buffer db;
|
||||
std::size_t count = 0;
|
||||
ws.async_read(op, db,
|
||||
[&](error_code ec)
|
||||
@@ -1531,7 +1531,7 @@ public:
|
||||
});
|
||||
});
|
||||
opcode op;
|
||||
streambuf db;
|
||||
multi_buffer db;
|
||||
ws.async_read(op, db,
|
||||
[&](error_code ec)
|
||||
{
|
||||
@@ -1562,9 +1562,9 @@ public:
|
||||
return;
|
||||
ws.write_frame(false, sbuf("u"));
|
||||
ws.write_frame(true, sbuf("v"));
|
||||
streambuf sb;
|
||||
multi_buffer b;
|
||||
opcode op;
|
||||
ws.read(op, sb, ec);
|
||||
ws.read(op, b, ec);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
return;
|
||||
}
|
||||
@@ -1623,7 +1623,7 @@ public:
|
||||
try
|
||||
{
|
||||
opcode op;
|
||||
streambuf db;
|
||||
multi_buffer db;
|
||||
c.read(ws, op, db);
|
||||
fail();
|
||||
throw abort_test{};
|
||||
@@ -1657,7 +1657,7 @@ public:
|
||||
{
|
||||
// receive echoed message
|
||||
opcode op;
|
||||
streambuf db;
|
||||
multi_buffer db;
|
||||
c.read(ws, op, db);
|
||||
BEAST_EXPECT(op == opcode::text);
|
||||
BEAST_EXPECT(to_string(db.data()) == "Hello");
|
||||
@@ -1691,7 +1691,7 @@ public:
|
||||
{
|
||||
// receive echoed message
|
||||
opcode op;
|
||||
streambuf db;
|
||||
multi_buffer db;
|
||||
c.read(ws, op, db);
|
||||
BEAST_EXPECT(pong == 1);
|
||||
BEAST_EXPECT(op == opcode::binary);
|
||||
@@ -1713,7 +1713,7 @@ public:
|
||||
{
|
||||
// receive echoed message
|
||||
opcode op;
|
||||
streambuf db;
|
||||
multi_buffer db;
|
||||
c.read(ws, op, db);
|
||||
BEAST_EXPECT(pong == 1);
|
||||
BEAST_EXPECT(to_string(db.data()) == "Hello, World!");
|
||||
@@ -1730,9 +1730,9 @@ public:
|
||||
{
|
||||
// receive echoed message
|
||||
opcode op;
|
||||
streambuf sb;
|
||||
c.read(ws, op, sb);
|
||||
BEAST_EXPECT(to_string(sb.data()) == "Now is the time for all good men");
|
||||
multi_buffer b;
|
||||
c.read(ws, op, b);
|
||||
BEAST_EXPECT(to_string(b.data()) == "Now is the time for all good men");
|
||||
}
|
||||
ws.set_option(auto_fragment{false});
|
||||
ws.set_option(write_buffer_size{4096});
|
||||
@@ -1745,7 +1745,7 @@ public:
|
||||
{
|
||||
// receive echoed message
|
||||
opcode op;
|
||||
streambuf db;
|
||||
multi_buffer db;
|
||||
c.read(ws, op, db);
|
||||
BEAST_EXPECT(to_string(db.data()) == s);
|
||||
}
|
||||
@@ -1759,7 +1759,7 @@ public:
|
||||
{
|
||||
// receive echoed message
|
||||
opcode op;
|
||||
streambuf db;
|
||||
multi_buffer db;
|
||||
c.read(ws, op, db);
|
||||
BEAST_EXPECT(op == opcode::text);
|
||||
BEAST_EXPECT(to_string(db.data()) == "Hello");
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <beast/websocket/detail/utf8_checker.hpp>
|
||||
|
||||
#include <beast/core/consuming_buffers.hpp>
|
||||
#include <beast/core/streambuf.hpp>
|
||||
#include <beast/core/multi_buffer.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <array>
|
||||
|
||||
@@ -379,15 +379,15 @@ public:
|
||||
consuming_buffers<
|
||||
boost::asio::const_buffers_1> cb{
|
||||
boost::asio::const_buffers_1(s.data(), n)};
|
||||
streambuf sb{size};
|
||||
multi_buffer b{size};
|
||||
while(n)
|
||||
{
|
||||
auto const amount = (std::min)(n, size);
|
||||
sb.commit(buffer_copy(sb.prepare(amount), cb));
|
||||
b.commit(buffer_copy(b.prepare(amount), cb));
|
||||
cb.consume(amount);
|
||||
n -= amount;
|
||||
}
|
||||
BEAST_EXPECT(utf8.write(sb.data()));
|
||||
BEAST_EXPECT(utf8.write(b.data()));
|
||||
BEAST_EXPECT(utf8.finish());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#define BEAST_WEBSOCKET_ASYNC_ECHO_SERVER_HPP
|
||||
|
||||
#include <beast/core/placeholders.hpp>
|
||||
#include <beast/core/streambuf.hpp>
|
||||
#include <beast/core/multi_buffer.hpp>
|
||||
#include <beast/websocket/stream.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
@@ -216,7 +216,7 @@ private:
|
||||
beast::websocket::stream<socket_type> ws;
|
||||
boost::asio::io_service::strand strand;
|
||||
beast::websocket::opcode op;
|
||||
beast::streambuf db;
|
||||
beast::multi_buffer db;
|
||||
std::size_t id;
|
||||
|
||||
data(async_echo_server& server_,
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#define BEAST_WEBSOCKET_SYNC_ECHO_SERVER_HPP
|
||||
|
||||
#include <beast/core/placeholders.hpp>
|
||||
#include <beast/core/streambuf.hpp>
|
||||
#include <beast/core/multi_buffer.hpp>
|
||||
#include <beast/websocket.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
@@ -306,41 +306,41 @@ private:
|
||||
for(;;)
|
||||
{
|
||||
beast::websocket::opcode op;
|
||||
beast::streambuf sb;
|
||||
ws.read(op, sb, ec);
|
||||
beast::multi_buffer b;
|
||||
ws.read(op, b, ec);
|
||||
if(ec)
|
||||
{
|
||||
auto const s = ec.message();
|
||||
break;
|
||||
}
|
||||
ws.set_option(beast::websocket::message_type{op});
|
||||
if(match(sb, "RAW"))
|
||||
if(match(b, "RAW"))
|
||||
{
|
||||
boost::asio::write(
|
||||
ws.next_layer(), sb.data(), ec);
|
||||
ws.next_layer(), b.data(), ec);
|
||||
}
|
||||
else if(match(sb, "TEXT"))
|
||||
else if(match(b, "TEXT"))
|
||||
{
|
||||
ws.set_option(
|
||||
beast::websocket::message_type{
|
||||
beast::websocket::opcode::text});
|
||||
ws.write(sb.data(), ec);
|
||||
ws.write(b.data(), ec);
|
||||
}
|
||||
else if(match(sb, "PING"))
|
||||
else if(match(b, "PING"))
|
||||
{
|
||||
beast::websocket::ping_data payload;
|
||||
sb.consume(buffer_copy(
|
||||
b.consume(buffer_copy(
|
||||
buffer(payload.data(), payload.size()),
|
||||
sb.data()));
|
||||
b.data()));
|
||||
ws.ping(payload, ec);
|
||||
}
|
||||
else if(match(sb, "CLOSE"))
|
||||
else if(match(b, "CLOSE"))
|
||||
{
|
||||
ws.close({}, ec);
|
||||
}
|
||||
else
|
||||
{
|
||||
ws.write(sb.data(), ec);
|
||||
ws.write(b.data(), ec);
|
||||
}
|
||||
if(ec)
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user