forked from boostorg/beast
async_read works with dynamic_buffer v2.
This commit is contained in:
committed by
Klemens Morgenstern
parent
73922b72f9
commit
606d776ebb
@@ -692,6 +692,25 @@ public:
|
|||||||
BEAST_EXPECTS(bt == 0, std::to_string(0));
|
BEAST_EXPECTS(bt == 0, std::to_string(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// bytes_transferred returns length of header
|
||||||
|
request_parser<string_body> p;
|
||||||
|
test::stream s(ioc);
|
||||||
|
s.append(string_view(hdr));
|
||||||
|
s.append(string_view(body));
|
||||||
|
std::string res ;
|
||||||
|
auto fb = asio::dynamic_buffer(res);
|
||||||
|
error_code ec;
|
||||||
|
auto bt = read_header(s, fb, p, ec);
|
||||||
|
BEAST_EXPECTS(!ec, ec.message());
|
||||||
|
BEAST_EXPECT(bt == hdr.size());
|
||||||
|
|
||||||
|
// next read should be zero-size, success
|
||||||
|
bt = read_header(s, fb, p, ec);
|
||||||
|
BEAST_EXPECTS(!ec, ec.message());
|
||||||
|
BEAST_EXPECTS(bt == 0, std::to_string(0));
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// incomplete header consumes all parsable header bytes
|
// incomplete header consumes all parsable header bytes
|
||||||
request_parser<string_body> p;
|
request_parser<string_body> p;
|
||||||
|
@@ -137,6 +137,30 @@ public:
|
|||||||
beast::error::timeout));
|
beast::error::timeout));
|
||||||
test::run(ioc);
|
test::run(ioc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
stream<tcp::socket> ws1(ioc);
|
||||||
|
stream<tcp::socket> ws2(ioc);
|
||||||
|
test::connect(ws1.next_layer(), ws2.next_layer());
|
||||||
|
ws1.async_handshake("test", "/", test::success_handler());
|
||||||
|
ws2.async_accept(test::success_handler());
|
||||||
|
test::run(ioc);
|
||||||
|
|
||||||
|
std::string res ;
|
||||||
|
auto b = asio::dynamic_buffer(res);
|
||||||
|
ws1.set_option(stream_base::timeout{
|
||||||
|
stream_base::none(),
|
||||||
|
std::chrono::milliseconds(50),
|
||||||
|
false});
|
||||||
|
ws1.async_read(b, test::success_handler());
|
||||||
|
ws2.async_write(net::const_buffer("Hello, world!", 13),
|
||||||
|
test::success_handler());
|
||||||
|
test::run(ioc);
|
||||||
|
|
||||||
|
BEAST_EXPECT(res == "Hello, world!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Reference in New Issue
Block a user