Remove uses of deprecated methods in websocket tests

This enables tests to be built without BOOST_BEAST_ALLOW_DEPRECATED.

Close #1612

Signed-off-by: Damian Jarek <damian.jarek93@gmail.com>
This commit is contained in:
Damian Jarek
2019-05-18 23:01:19 +02:00
parent c254b4fcfb
commit cefb744794
3 changed files with 33 additions and 21 deletions

View File

@ -1,6 +1,7 @@
Version 256: Version 256:
* Remove uses of the deprecated `buffers` function * Remove uses of the deprecated `buffers` function
* Remove uses of deprecated methods in websocket tests
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

@ -126,7 +126,9 @@ public:
"\r\n"); "\r\n");
ws.next_layer().read_size(20); ws.next_layer().read_size(20);
bool called = false; bool called = false;
api.accept_ex(ws, res_decorator{called}); ws.set_option(stream_base::decorator(
res_decorator{called}));
api.accept(ws);
BEAST_EXPECT(called); BEAST_EXPECT(called);
}); });
@ -148,15 +150,16 @@ public:
fail_loop([&](stream<test::stream>& ws) fail_loop([&](stream<test::stream>& ws)
{ {
bool called = false; bool called = false;
api.accept_ex(ws, sbuf( ws.set_option(stream_base::decorator(
res_decorator{called}));
api.accept(ws, sbuf(
"GET / HTTP/1.1\r\n" "GET / HTTP/1.1\r\n"
"Host: localhost\r\n" "Host: localhost\r\n"
"Upgrade: websocket\r\n" "Upgrade: websocket\r\n"
"Connection: upgrade\r\n" "Connection: upgrade\r\n"
"Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n" "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"
"Sec-WebSocket-Version: 13\r\n" "Sec-WebSocket-Version: 13\r\n"
"\r\n"), "\r\n"));
res_decorator{called});
BEAST_EXPECT(called); BEAST_EXPECT(called);
}); });
@ -187,11 +190,12 @@ public:
"\r\n"); "\r\n");
ws.next_layer().read_size(16); ws.next_layer().read_size(16);
bool called = false; bool called = false;
api.accept_ex(ws, sbuf( ws.set_option(stream_base::decorator(
res_decorator{called}));
api.accept(ws, sbuf(
"GET / HTTP/1.1\r\n" "GET / HTTP/1.1\r\n"
"Host: localhost\r\n" "Host: localhost\r\n"
"Upgrade: websocket\r\n"), "Upgrade: websocket\r\n"));
res_decorator{called});
BEAST_EXPECT(called); BEAST_EXPECT(called);
}); });
@ -228,8 +232,9 @@ public:
fail_loop([&](stream<test::stream>& ws) fail_loop([&](stream<test::stream>& ws)
{ {
bool called = false; bool called = false;
api.accept_ex(ws, req, ws.set_option(stream_base::decorator(
res_decorator{called}); res_decorator{called}));
api.accept(ws, req);
BEAST_EXPECT(called); BEAST_EXPECT(called);
}); });
} }
@ -343,7 +348,9 @@ public:
try try
{ {
bool called = false; bool called = false;
api.accept_ex(ws, res_decorator{called}); ws.set_option(stream_base::decorator(
res_decorator{called}));
api.accept(ws);
BEAST_FAIL(); BEAST_FAIL();
} }
catch(system_error const& se) catch(system_error const& se)
@ -388,7 +395,9 @@ public:
try try
{ {
bool called = false; bool called = false;
api.accept_ex(ws, net::buffer( ws.set_option(stream_base::decorator(
res_decorator{called}));
api.accept(ws, net::buffer(
"GET / HTTP/1.1\r\n" "GET / HTTP/1.1\r\n"
"Host: localhost\r\n" "Host: localhost\r\n"
"Upgrade: websocket\r\n" "Upgrade: websocket\r\n"
@ -396,8 +405,7 @@ public:
"Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n" "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"
"Sec-WebSocket-Version: 13\r\n" "Sec-WebSocket-Version: 13\r\n"
+ big + + big +
"\r\n"), "\r\n"));
res_decorator{called});
BEAST_FAIL(); BEAST_FAIL();
} }
catch(system_error const& se) catch(system_error const& se)
@ -446,11 +454,12 @@ public:
try try
{ {
bool called = false; bool called = false;
api.accept_ex(ws, websocket_test_suite::sbuf( ws.set_option(stream_base::decorator(
res_decorator{called}));
api.accept(ws, websocket_test_suite::sbuf(
"GET / HTTP/1.1\r\n" "GET / HTTP/1.1\r\n"
"Host: localhost\r\n" "Host: localhost\r\n"
"Upgrade: websocket\r\n"), "Upgrade: websocket\r\n"));
res_decorator{called});
BEAST_FAIL(); BEAST_FAIL();
} }
catch(system_error const& se) catch(system_error const& se)

View File

@ -97,8 +97,9 @@ public:
bool called = false; bool called = false;
try try
{ {
w.handshake_ex(ws, "localhost", "/", ws.set_option(stream_base::decorator(
req_decorator{called}); req_decorator{called}));
w.handshake(ws, "localhost", "/");
BEAST_EXPECT(called); BEAST_EXPECT(called);
} }
catch(...) catch(...)
@ -119,8 +120,9 @@ public:
response_type res; response_type res;
try try
{ {
w.handshake_ex(ws, res, "localhost", "/", ws.set_option(stream_base::decorator(
req_decorator{called}); req_decorator{called}));
w.handshake(ws, res, "localhost", "/");
// VFALCO validate res? // VFALCO validate res?
BEAST_EXPECT(called); BEAST_EXPECT(called);
} }
@ -355,7 +357,7 @@ public:
po.client_max_window_bits = 0; po.client_max_window_bits = 0;
po.server_no_context_takeover = false; po.server_no_context_takeover = false;
po.client_no_context_takeover = false; po.client_no_context_takeover = false;
check("permessage-deflate"); check("permessage-deflate");
po.server_max_window_bits = 10; po.server_max_window_bits = 10;