From a4d0d3215a18f9dbee92d023eea3b5904672d10a Mon Sep 17 00:00:00 2001 From: Karim Shamazov Date: Tue, 7 Apr 2026 21:49:48 +0300 Subject: [PATCH 1/3] [k2] case insensitive comparing of connection header --- runtime-light/server/http/init-functions.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/runtime-light/server/http/init-functions.cpp b/runtime-light/server/http/init-functions.cpp index 21d14756c1..db01ff52a7 100644 --- a/runtime-light/server/http/init-functions.cpp +++ b/runtime-light/server/http/init-functions.cpp @@ -161,9 +161,13 @@ std::string_view process_headers(const tl::K2InvokeHttp& invoke_http, PhpScriptB http_server_instance_st.encoding |= HttpServerInstanceState::ENCODING_DEFLATE; } } else if (h_name == kphp::http::headers::CONNECTION) { - if (h_value == CONNECTION_KEEP_ALIVE) [[likely]] { + auto iequals{[](std::string_view s1, std::string_view s2) noexcept { + return std::ranges::equal(s1, s2, [](char a, char b) { return std::tolower(a, std::locale::classic()) == std::tolower(b, std::locale::classic()); }); + }}; + + if (iequals(h_value, CONNECTION_KEEP_ALIVE)) [[likely]] { http_server_instance_st.connection_kind = kphp::http::connection_kind::keep_alive; - } else if (h_value == CONNECTION_CLOSE) [[likely]] { + } else if (iequals(h_value, CONNECTION_CLOSE)) [[likely]] { http_server_instance_st.connection_kind = kphp::http::connection_kind::close; } else { kphp::log::error("unexpected connection header: {}", h_value); From 93bb50bcd5fc7f6e78539c037b2e7d6086f25792 Mon Sep 17 00:00:00 2001 From: Karim Shamazov Date: Wed, 8 Apr 2026 17:24:17 +0300 Subject: [PATCH 2/3] add noexcept --- runtime-light/server/http/init-functions.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime-light/server/http/init-functions.cpp b/runtime-light/server/http/init-functions.cpp index db01ff52a7..e04bf86c40 100644 --- a/runtime-light/server/http/init-functions.cpp +++ b/runtime-light/server/http/init-functions.cpp @@ -162,7 +162,8 @@ std::string_view process_headers(const tl::K2InvokeHttp& invoke_http, PhpScriptB } } else if (h_name == kphp::http::headers::CONNECTION) { auto iequals{[](std::string_view s1, std::string_view s2) noexcept { - return std::ranges::equal(s1, s2, [](char a, char b) { return std::tolower(a, std::locale::classic()) == std::tolower(b, std::locale::classic()); }); + return std::ranges::equal(s1, s2, + [](char a, char b) noexcept { return std::tolower(a, std::locale::classic()) == std::tolower(b, std::locale::classic()); }); }}; if (iequals(h_value, CONNECTION_KEEP_ALIVE)) [[likely]] { From 7d6fe062ce86634a1c34664344c0298dd5a77b9a Mon Sep 17 00:00:00 2001 From: Karim Shamazov Date: Wed, 8 Apr 2026 17:37:43 +0300 Subject: [PATCH 3/3] IEQUALS --- runtime-light/server/http/init-functions.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime-light/server/http/init-functions.cpp b/runtime-light/server/http/init-functions.cpp index e04bf86c40..7ded360ceb 100644 --- a/runtime-light/server/http/init-functions.cpp +++ b/runtime-light/server/http/init-functions.cpp @@ -161,14 +161,14 @@ std::string_view process_headers(const tl::K2InvokeHttp& invoke_http, PhpScriptB http_server_instance_st.encoding |= HttpServerInstanceState::ENCODING_DEFLATE; } } else if (h_name == kphp::http::headers::CONNECTION) { - auto iequals{[](std::string_view s1, std::string_view s2) noexcept { + static constexpr auto IEQUALS{[](std::string_view s1, std::string_view s2) noexcept { return std::ranges::equal(s1, s2, [](char a, char b) noexcept { return std::tolower(a, std::locale::classic()) == std::tolower(b, std::locale::classic()); }); }}; - if (iequals(h_value, CONNECTION_KEEP_ALIVE)) [[likely]] { + if (IEQUALS(h_value, CONNECTION_KEEP_ALIVE)) [[likely]] { http_server_instance_st.connection_kind = kphp::http::connection_kind::keep_alive; - } else if (iequals(h_value, CONNECTION_CLOSE)) [[likely]] { + } else if (IEQUALS(h_value, CONNECTION_CLOSE)) [[likely]] { http_server_instance_st.connection_kind = kphp::http::connection_kind::close; } else { kphp::log::error("unexpected connection header: {}", h_value);