diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2022-02-18 14:17:51 +0330 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-02-18 13:19:26 +0100 |
commit | 0e173da86fe93fd0c87257e8f68cc6fedc4c59e7 (patch) | |
tree | 3e774e19c06f28f2e431e73e670044b3c4a45ed1 /Userland/Services | |
parent | 7ab43377211f62c06a0e6f639cbefa65b5464622 (diff) | |
download | serenity-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.cpp | 8 |
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 {}; } |