summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibHTTP
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2021-09-19 02:31:11 +0430
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-09-19 21:10:23 +0430
commit436693c0c907b9a15bd6cccc07304e6332bc7b7b (patch)
tree494319887de437c6590d0cdc2c263e6510f8e953 /Userland/Libraries/LibHTTP
parentd3ea0818f3dc6f744e6176e9bd1633e3085d6b71 (diff)
downloadserenity-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 'Userland/Libraries/LibHTTP')
-rw-r--r--Userland/Libraries/LibHTTP/HttpsJob.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/Userland/Libraries/LibHTTP/HttpsJob.cpp b/Userland/Libraries/LibHTTP/HttpsJob.cpp
index 0f249fc5fb..abaeb662f6 100644
--- a/Userland/Libraries/LibHTTP/HttpsJob.cpp
+++ b/Userland/Libraries/LibHTTP/HttpsJob.cpp
@@ -68,6 +68,7 @@ void HttpsJob::shutdown()
return;
m_socket->on_tls_ready_to_read = nullptr;
m_socket->on_tls_connected = nullptr;
+ m_socket->set_on_tls_ready_to_write(nullptr);
m_socket = nullptr;
}
@@ -97,9 +98,10 @@ void HttpsJob::register_on_ready_to_read(Function<void()> callback)
void HttpsJob::register_on_ready_to_write(Function<void()> callback)
{
- m_socket->on_tls_ready_to_write = [callback = move(callback)](auto&) {
+ m_socket->set_on_tls_ready_to_write([callback = move(callback)](auto& tls) {
+ Core::deferred_invoke([&tls] { tls.set_on_tls_ready_to_write(nullptr); });
callback();
- };
+ });
}
bool HttpsJob::can_read_line() const