forked from boostorg/beast
@@ -2,6 +2,7 @@
|
||||
|
||||
* Require Visual Studio 2015 Update 3 or later
|
||||
* Use fwrite return value in file_body
|
||||
* Add decorator unit test
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
@@ -109,26 +109,38 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
struct identity
|
||||
struct test_decorator
|
||||
{
|
||||
template<class Body, class Fields>
|
||||
void
|
||||
operator()(http::message<true, Body, Fields>&)
|
||||
int& what;
|
||||
|
||||
test_decorator(test_decorator const&) = default;
|
||||
|
||||
test_decorator(int& what_)
|
||||
: what(what_)
|
||||
{
|
||||
what = 0;
|
||||
}
|
||||
|
||||
template<class Body, class Fields>
|
||||
template<class Fields>
|
||||
void
|
||||
operator()(http::message<false, Body, Fields>&)
|
||||
operator()(http::header<true, Fields>&) const
|
||||
{
|
||||
what |= 1;
|
||||
}
|
||||
|
||||
template<class Fields>
|
||||
void
|
||||
operator()(http::header<false, Fields>&) const
|
||||
{
|
||||
what |= 2;
|
||||
}
|
||||
};
|
||||
|
||||
void testOptions()
|
||||
void
|
||||
testOptions()
|
||||
{
|
||||
stream<socket_type> ws(ios_);
|
||||
ws.set_option(auto_fragment{true});
|
||||
ws.set_option(decorate(identity{}));
|
||||
ws.set_option(keep_alive{false});
|
||||
ws.set_option(write_buffer_size{2048});
|
||||
ws.set_option(message_type{opcode::text});
|
||||
@@ -411,6 +423,24 @@ public:
|
||||
);
|
||||
}
|
||||
|
||||
void
|
||||
testDecorator(endpoint_type const& ep)
|
||||
{
|
||||
error_code ec;
|
||||
socket_type sock{ios_};
|
||||
sock.connect(ep, ec);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
return;
|
||||
stream<socket_type&> ws{sock};
|
||||
int what;
|
||||
ws.set_option(decorate(test_decorator{what}));
|
||||
BEAST_EXPECT(what == 0);
|
||||
ws.handshake("localhost", "/", ec);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
return;
|
||||
BEAST_EXPECT(what == 1);
|
||||
}
|
||||
|
||||
void testMask(endpoint_type const& ep,
|
||||
yield_context do_yield)
|
||||
{
|
||||
@@ -1257,6 +1287,7 @@ public:
|
||||
server.open(any, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
auto const ep = server.local_endpoint();
|
||||
testDecorator(ep);
|
||||
//testInvokable1(ep);
|
||||
testInvokable2(ep);
|
||||
testInvokable3(ep);
|
||||
|
Reference in New Issue
Block a user