diff options
author | Roland Reichwein <mail@reichwein.it> | 2020-04-18 16:50:31 +0200 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2020-04-18 16:50:31 +0200 |
commit | d60210d4862f792c1e04ee143bad59bb162fb789 (patch) | |
tree | dcb193c9258963a33a3ca0448db3710dde3673b6 /plugins | |
parent | a31b91482d0f0ffce7408fa0498d34ce22b9c244 (diff) |
Bugfix: Case insensitive matching for CGI result headers
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/cgi/cgi.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
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 <boost/coroutine2/coroutine.hpp> #include <boost/process.hpp> +#include <algorithm> #include <filesystem> #include <fstream> #include <iostream> @@ -95,11 +96,11 @@ namespace { } std::unordered_map<std::string, std::function<void(std::string&, CGIContext&)>> 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; |