diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2021-09-19 02:31:11 +0430 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2021-09-19 21:10:23 +0430 |
commit | 436693c0c907b9a15bd6cccc07304e6332bc7b7b (patch) | |
tree | 494319887de437c6590d0cdc2c263e6510f8e953 /Tests/LibTLS | |
parent | d3ea0818f3dc6f744e6176e9bd1633e3085d6b71 (diff) | |
download | serenity-436693c0c907b9a15bd6cccc07304e6332bc7b7b.zip |
LibTLS: Use a setter for on_tls_ready_to_write with some more smarts
The callback should be called as soon as the connection is established,
and if we actually set the callback when it already is, we expect it to
be called immediately.
Diffstat (limited to 'Tests/LibTLS')
-rw-r--r-- | Tests/LibTLS/TestTLSHandshake.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Tests/LibTLS/TestTLSHandshake.cpp b/Tests/LibTLS/TestTLSHandshake.cpp index 761098c8f9..9494f258e8 100644 --- a/Tests/LibTLS/TestTLSHandshake.cpp +++ b/Tests/LibTLS/TestTLSHandshake.cpp @@ -70,10 +70,11 @@ TEST_CASE(test_TLS_hello_handshake) tls->set_root_certificates(s_root_ca_certificates); bool sent_request = false; ByteBuffer contents; - tls->on_tls_ready_to_write = [&](TLS::TLSv12& tls) { + tls->set_on_tls_ready_to_write([&](TLS::TLSv12& tls) { if (sent_request) return; sent_request = true; + Core::deferred_invoke([&tls] { tls.set_on_tls_ready_to_write(nullptr); }); if (!tls.write("GET / HTTP/1.1\r\nHost: "_b)) { FAIL("write(0) failed"); loop.quit(0); @@ -87,7 +88,7 @@ TEST_CASE(test_TLS_hello_handshake) FAIL("write(2) failed"); loop.quit(0); } - }; + }); tls->on_tls_ready_to_read = [&](TLS::TLSv12& tls) { auto data = tls.read(); if (!data.has_value()) { |