/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* Request.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* +#+#+#+#+#+ +#+ */ /* */ /* ************************************************************************** */ #include "http/Request.hpp" #include #include namespace webserv { const char* toString(Method method) noexcept { switch (method) { case Method::Get: return "GET"; case Method::Post: return "POST"; case Method::Delete: return "DELETE"; } return "GET"; } bool headerNameEquals(std::string_view a, std::string_view b) noexcept { return std::ranges::equal(a, b, [](unsigned char x, unsigned char y) { return std::tolower(x) == std::tolower(y); }); } std::optional Request::header(std::string_view name) const noexcept { for (const auto& [fieldName, value] : headers) { if (headerNameEquals(fieldName, name)) { return std::string_view(value); } } return std::nullopt; } } // namespace webserv