summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGemini/GeminiJob.cpp
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2021-09-30 12:19:54 +0330
committerAndreas Kling <kling@serenityos.org>2021-09-30 11:46:37 +0200
commitb0a9c5673e7a8a100ddd827b780abe7d284802c1 (patch)
tree282c91f61d3f2f11f8661a193a27a8e4a7fc5ad8 /Userland/Libraries/LibGemini/GeminiJob.cpp
parentd16131b100aaf74e2d69207aea2c8a586bec6f1e (diff)
downloadserenity-b0a9c5673e7a8a100ddd827b780abe7d284802c1.zip
LibHTTP: Respect the 'Connection: close' header on keep-alive jobs
If the server responds with this header, we _must_ close the connection, as the server is allowed to ignore the socket and not respond to anything past that response. Fixes some RequestServer spins.
Diffstat (limited to 'Userland/Libraries/LibGemini/GeminiJob.cpp')
-rw-r--r--Userland/Libraries/LibGemini/GeminiJob.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/Userland/Libraries/LibGemini/GeminiJob.cpp b/Userland/Libraries/LibGemini/GeminiJob.cpp
index 64ff2dbee2..b459d81afd 100644
--- a/Userland/Libraries/LibGemini/GeminiJob.cpp
+++ b/Userland/Libraries/LibGemini/GeminiJob.cpp
@@ -58,13 +58,17 @@ void GeminiJob::start(NonnullRefPtr<Core::Socket> socket)
}
}
-void GeminiJob::shutdown()
+void GeminiJob::shutdown(ShutdownMode mode)
{
if (!m_socket)
return;
- m_socket->on_tls_ready_to_read = nullptr;
- m_socket->on_tls_connected = nullptr;
- m_socket = nullptr;
+ if (mode == ShutdownMode::CloseSocket) {
+ m_socket->close();
+ } else {
+ m_socket->on_tls_ready_to_read = nullptr;
+ m_socket->on_tls_connected = nullptr;
+ m_socket = nullptr;
+ }
}
void GeminiJob::read_while_data_available(Function<IterationDecision()> read)