summaryrefslogtreecommitdiff
path: root/Userland/Services
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2022-02-18 14:17:51 +0330
committerAndreas Kling <kling@serenityos.org>2022-02-18 13:19:26 +0100
commit0e173da86fe93fd0c87257e8f68cc6fedc4c59e7 (patch)
tree3e774e19c06f28f2e431e73e670044b3c4a45ed1 /Userland/Services
parent7ab43377211f62c06a0e6f639cbefa65b5464622 (diff)
downloadserenity-0e173da86fe93fd0c87257e8f68cc6fedc4c59e7.zip
WebServer: Close the socket if Connection: keep-alive isn't requested
Diffstat (limited to 'Userland/Services')
-rw-r--r--Userland/Services/WebServer/Client.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/Userland/Services/WebServer/Client.cpp b/Userland/Services/WebServer/Client.cpp
index cfdfe6aab7..95dc899560 100644
--- a/Userland/Services/WebServer/Client.cpp
+++ b/Userland/Services/WebServer/Client.cpp
@@ -203,6 +203,14 @@ ErrorOr<void> Client::send_response(InputStream& response, HTTP::HttpRequest con
}
} while (true);
+ auto keep_alive = false;
+ if (auto it = request.headers().find_if([](auto& header) { return header.name.equals_ignoring_case("Connection"); }); !it.is_end()) {
+ if (it->value.trim_whitespace().equals_ignoring_case("keep-alive"))
+ keep_alive = true;
+ }
+ if (!keep_alive)
+ m_socket->close();
+
return {};
}