| 122 | } |
| 123 | |
| 124 | std::optional<HttpHeaders> convertStringToHeaders( |
| 125 | const std::string& serializedHeaders, |
| 126 | const std::shared_ptr<spdlog::logger>& pLogger) { |
| 127 | rapidjson::Document document; |
| 128 | document.Parse(serializedHeaders.c_str()); |
| 129 | if (document.HasParseError()) { |
| 130 | SPDLOG_LOGGER_ERROR( |
| 131 | pLogger, |
| 132 | "Unable to parse http header string from cache."); |
| 133 | return std::nullopt; |
| 134 | } |
| 135 | std::optional<HttpHeaders> headers = std::make_optional<HttpHeaders>(); |
| 136 | for (rapidjson::Document::ConstMemberIterator it = document.MemberBegin(); |
| 137 | it != document.MemberEnd(); |
| 138 | ++it) { |
| 139 | headers->insert({it->name.GetString(), it->value.GetString()}); |
| 140 | } |
| 141 | return headers; |
| 142 | } |
| 143 | |
| 144 | } // namespace |
| 145 | |