From d60210d4862f792c1e04ee143bad59bb162fb789 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sat, 18 Apr 2020 16:50:31 +0200 Subject: Bugfix: Case insensitive matching for CGI result headers --- plugins/cgi/cgi.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'plugins/cgi/cgi.cpp') diff --git a/plugins/cgi/cgi.cpp b/plugins/cgi/cgi.cpp index 232abff..9b06f7a 100644 --- a/plugins/cgi/cgi.cpp +++ b/plugins/cgi/cgi.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -95,11 +96,11 @@ namespace { } std::unordered_map> headerMap { - { "Cache-control", [](std::string& v, CGIContext& c){ c.SetResponseHeader("cache_control", v); } }, + { "CACHE-CONTROL", [](std::string& v, CGIContext& c){ c.SetResponseHeader("cache_control", v); } }, - { "Content-Type", [](std::string& v, CGIContext& c){ c.SetResponseHeader("content_type", v); } }, + { "CONTENT-TYPE", [](std::string& v, CGIContext& c){ c.SetResponseHeader("content_type", v); } }, - { "Status", [](std::string& v, CGIContext& c) { + { "STATUS", [](std::string& v, CGIContext& c) { std::string status{"500"}; if (v.size() >= 3) { status = v.substr(0, 3); @@ -117,7 +118,7 @@ namespace { std::string key {s.substr(0, pos)}; std::string value {s.substr(pos + 2)}; - + std::transform(key.begin(), key.end(), key.begin(), ::toupper); auto it {headerMap.find(key)}; if (it == headerMap.end()) std::cout << "Warning: Unhandled CGI header: " << s << std::endl; -- cgit v1.2.3