| 28 | public: |
| 29 | template<bool deflateSupported, class Wrap> |
| 30 | void |
| 31 | doTestWrite(Wrap const& w) |
| 32 | { |
| 33 | permessage_deflate pmd; |
| 34 | pmd.client_enable = false; |
| 35 | pmd.server_enable = false; |
| 36 | |
| 37 | // already closed |
| 38 | { |
| 39 | echo_server es{log}; |
| 40 | stream<test::stream> ws{ioc_}; |
| 41 | ws.next_layer().connect(es.stream()); |
| 42 | ws.handshake("localhost", "/"); |
| 43 | ws.close({}); |
| 44 | try |
| 45 | { |
| 46 | w.write(ws, sbuf("")); |
| 47 | fail("", __FILE__, __LINE__); |
| 48 | } |
| 49 | catch(system_error const& se) |
| 50 | { |
| 51 | BEAST_EXPECTS( |
| 52 | se.code() == net::error::operation_aborted, |
| 53 | se.code().message()); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | // message |
| 58 | doTest<deflateSupported>(pmd, |
| 59 | [&](ws_type_t<deflateSupported>& ws) |
| 60 | { |
| 61 | ws.auto_fragment(false); |
| 62 | ws.binary(false); |
| 63 | std::string const s = "Hello, world!"; |
| 64 | w.write(ws, net::buffer(s)); |
| 65 | multi_buffer b; |
| 66 | w.read(ws, b); |
| 67 | BEAST_EXPECT(ws.got_text()); |
| 68 | BEAST_EXPECT(buffers_to_string(b.data()) == s); |
| 69 | }); |
| 70 | |
| 71 | // empty message |
| 72 | doTest<deflateSupported>(pmd, |
| 73 | [&](ws_type_t<deflateSupported>& ws) |
| 74 | { |
| 75 | ws.text(true); |
| 76 | w.write(ws, net::const_buffer{}); |
| 77 | multi_buffer b; |
| 78 | w.read(ws, b); |
| 79 | BEAST_EXPECT(ws.got_text()); |
| 80 | BEAST_EXPECT(b.size() == 0); |
| 81 | }); |
| 82 | |
| 83 | // fragmented message |
| 84 | doTest<deflateSupported>(pmd, |
| 85 | [&](ws_type_t<deflateSupported>& ws) |
| 86 | { |
| 87 | ws.auto_fragment(false); |
nothing calls this directly
no test coverage detected