forked from boostorg/beast
binary, text are members of stream (API Change):
fix #446 * message_type is removed Actions Required: * Change call sites which use message_type with set_option to call stream::binary or stream::text instead.
This commit is contained in:
@@ -154,7 +154,7 @@ boost::asio::ip::tcp::socket sock{ios};
|
||||
opcode op;
|
||||
ws.read(op, buffer);
|
||||
|
||||
ws.set_option(message_type{op});
|
||||
ws.binary(op == opcode::binary);
|
||||
ws.write(buffer.data());
|
||||
buffer.consume(buffer.size());
|
||||
//]
|
||||
@@ -171,7 +171,7 @@ boost::asio::ip::tcp::socket sock{ios};
|
||||
if(fi.fin)
|
||||
break;
|
||||
}
|
||||
ws.set_option(message_type{fi.op});
|
||||
ws.binary(fi.op == opcode::binary);
|
||||
consuming_buffers<multi_buffer::const_buffers_type> cb{buffer.data()};
|
||||
for(;;)
|
||||
{
|
||||
|
||||
@@ -254,8 +254,7 @@ private:
|
||||
if(ec)
|
||||
return fail("async_read", ec);
|
||||
d.state = 3;
|
||||
d.ws.set_option(
|
||||
beast::websocket::message_type(d.op));
|
||||
d.ws.binary(d.op == beast::websocket::opcode::binary);
|
||||
d.ws.async_write(d.db.data(),
|
||||
d.strand.wrap(std::move(*this)));
|
||||
return;
|
||||
|
||||
+13
-22
@@ -555,7 +555,7 @@ public:
|
||||
stream<socket_type> ws(ios_);
|
||||
ws.auto_fragment(true);
|
||||
ws.set_option(write_buffer_size{2048});
|
||||
ws.set_option(message_type{opcode::text});
|
||||
ws.binary(false);
|
||||
ws.set_option(read_buffer_size{8192});
|
||||
ws.set_option(read_message_max{1 * 1024 * 1024});
|
||||
try
|
||||
@@ -567,15 +567,6 @@ public:
|
||||
{
|
||||
pass();
|
||||
}
|
||||
try
|
||||
{
|
||||
message_type{opcode::close};
|
||||
fail();
|
||||
}
|
||||
catch(std::exception const&)
|
||||
{
|
||||
pass();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -1279,7 +1270,7 @@ public:
|
||||
ws.handshake("localhost", "/");
|
||||
|
||||
// Make remote send a ping frame
|
||||
ws.set_option(message_type(opcode::text));
|
||||
ws.binary(false);
|
||||
ws.write(buffer_cat(sbuf("PING"), sbuf("ping")));
|
||||
|
||||
std::size_t count = 0;
|
||||
@@ -1346,7 +1337,7 @@ public:
|
||||
ws.handshake("localhost", "/");
|
||||
|
||||
// Make remote send a text message with bad utf8.
|
||||
ws.set_option(message_type(opcode::binary));
|
||||
ws.binary(true);
|
||||
ws.write(buffer_cat(sbuf("TEXT"),
|
||||
cbuf(0x03, 0xea, 0xf0, 0x28, 0x8c, 0xbc)));
|
||||
opcode op;
|
||||
@@ -1415,7 +1406,7 @@ public:
|
||||
ws.handshake("localhost", "/");
|
||||
|
||||
// Cause close to be received
|
||||
ws.set_option(message_type(opcode::binary));
|
||||
ws.binary(true);
|
||||
ws.write(sbuf("CLOSE"));
|
||||
opcode op;
|
||||
multi_buffer db;
|
||||
@@ -1481,7 +1472,7 @@ public:
|
||||
ws.handshake("localhost", "/");
|
||||
|
||||
// Cause close to be received
|
||||
ws.set_option(message_type(opcode::binary));
|
||||
ws.binary(true);
|
||||
ws.write(sbuf("CLOSE"));
|
||||
opcode op;
|
||||
multi_buffer db;
|
||||
@@ -1656,7 +1647,7 @@ public:
|
||||
|
||||
// send message
|
||||
ws.auto_fragment(false);
|
||||
ws.set_option(message_type(opcode::text));
|
||||
ws.binary(false);
|
||||
c.write(ws, sbuf("Hello"));
|
||||
{
|
||||
// receive echoed message
|
||||
@@ -1690,7 +1681,7 @@ public:
|
||||
BEAST_EXPECT(payload == "");
|
||||
}});
|
||||
c.ping(ws, "");
|
||||
ws.set_option(message_type(opcode::binary));
|
||||
ws.binary(true);
|
||||
c.write(ws, sbuf("Hello"));
|
||||
{
|
||||
// receive echoed message
|
||||
@@ -1756,9 +1747,9 @@ public:
|
||||
}
|
||||
|
||||
// cause ping
|
||||
ws.set_option(message_type(opcode::binary));
|
||||
ws.binary(true);
|
||||
c.write(ws, sbuf("PING"));
|
||||
ws.set_option(message_type(opcode::text));
|
||||
ws.binary(false);
|
||||
c.write(ws, sbuf("Hello"));
|
||||
{
|
||||
// receive echoed message
|
||||
@@ -1770,25 +1761,25 @@ public:
|
||||
}
|
||||
|
||||
// cause close
|
||||
ws.set_option(message_type(opcode::binary));
|
||||
ws.binary(true);
|
||||
c.write(ws, sbuf("CLOSE"));
|
||||
restart(error::closed);
|
||||
|
||||
// send bad utf8
|
||||
ws.set_option(message_type(opcode::binary));
|
||||
ws.binary(true);
|
||||
c.write(ws, buffer_cat(sbuf("TEXT"),
|
||||
cbuf(0x03, 0xea, 0xf0, 0x28, 0x8c, 0xbc)));
|
||||
restart(error::failed);
|
||||
|
||||
// cause bad utf8
|
||||
ws.set_option(message_type(opcode::binary));
|
||||
ws.binary(true);
|
||||
c.write(ws, buffer_cat(sbuf("TEXT"),
|
||||
cbuf(0x03, 0xea, 0xf0, 0x28, 0x8c, 0xbc)));
|
||||
c.write(ws, sbuf("Hello"));
|
||||
restart(error::failed);
|
||||
|
||||
// cause bad close
|
||||
ws.set_option(message_type(opcode::binary));
|
||||
ws.binary(true);
|
||||
c.write(ws, buffer_cat(sbuf("RAW"),
|
||||
cbuf(0x88, 0x02, 0x03, 0xed)));
|
||||
restart(error::failed);
|
||||
|
||||
@@ -332,9 +332,7 @@ private:
|
||||
else if(match(d.db, "TEXT"))
|
||||
{
|
||||
d.state = 1;
|
||||
d.ws.set_option(
|
||||
beast::websocket::message_type{
|
||||
beast::websocket::opcode::text});
|
||||
d.ws.binary(false);
|
||||
d.ws.async_write(
|
||||
d.db.data(), d.strand.wrap(std::move(*this)));
|
||||
return;
|
||||
@@ -359,8 +357,7 @@ private:
|
||||
}
|
||||
// write message
|
||||
d.state = 1;
|
||||
d.ws.set_option(
|
||||
beast::websocket::message_type(d.op));
|
||||
d.ws.binary(d.op == beast::websocket::opcode::binary);
|
||||
d.ws.async_write(d.db.data(),
|
||||
d.strand.wrap(std::move(*this)));
|
||||
return;
|
||||
|
||||
@@ -312,7 +312,7 @@ private:
|
||||
auto const s = ec.message();
|
||||
break;
|
||||
}
|
||||
ws.set_option(beast::websocket::message_type{op});
|
||||
ws.binary(op == beast::websocket::opcode::binary);
|
||||
if(match(b, "RAW"))
|
||||
{
|
||||
boost::asio::write(
|
||||
@@ -320,9 +320,7 @@ private:
|
||||
}
|
||||
else if(match(b, "TEXT"))
|
||||
{
|
||||
ws.set_option(
|
||||
beast::websocket::message_type{
|
||||
beast::websocket::opcode::text});
|
||||
ws.binary(false);
|
||||
ws.write(b.data(), ec);
|
||||
}
|
||||
else if(match(b, "PING"))
|
||||
|
||||
Reference in New Issue
Block a user