| 91 | namespace |
| 92 | { |
| 93 | bool tryAddHTTPOptionHeadersFromConfig(HTTPServerResponse & response, const Poco::Util::LayeredConfiguration & config) |
| 94 | { |
| 95 | if (config.has("http_options_response")) |
| 96 | { |
| 97 | Strings config_keys; |
| 98 | config.keys("http_options_response", config_keys); |
| 99 | for (const std::string & config_key : config_keys) |
| 100 | { |
| 101 | if (config_key == "header" || config_key.starts_with("header[")) |
| 102 | { |
| 103 | /// If there is empty header name, it will not be processed and message about it will be in logs |
| 104 | if (config.getString("http_options_response." + config_key + ".name", "").empty()) |
| 105 | LOG_WARNING(getLogger("processOptionsRequest"), "Empty header was found in config. It will not be processed."); |
| 106 | else |
| 107 | response.add(config.getString("http_options_response." + config_key + ".name", ""), |
| 108 | config.getString("http_options_response." + config_key + ".value", "")); |
| 109 | |
| 110 | } |
| 111 | } |
| 112 | return true; |
| 113 | } |
| 114 | return false; |
| 115 | } |
| 116 | |
| 117 | /// Process options request. Useful for CORS. |
| 118 | void processOptionsRequest(HTTPServerResponse & response, const Poco::Util::LayeredConfiguration & config) |