1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:28:11 +00:00

WebServer: Close the socket if Connection: keep-alive isn't requested

This commit is contained in:
Ali Mohammad Pur 2022-02-18 14:17:51 +03:30 committed by Andreas Kling
parent 7ab4337721
commit 0e173da86f

View file

@ -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 {};
}