| 104 | const std::string CLEAR_ALL_SQL = "DELETE FROM " + CACHE_TABLE; |
| 105 | |
| 106 | std::string convertHeadersToString(const HttpHeaders& headers) { |
| 107 | rapidjson::Document document; |
| 108 | rapidjson::Document::AllocatorType& allocator = document.GetAllocator(); |
| 109 | rapidjson::Value root(rapidjson::kObjectType); |
| 110 | rapidjson::Value key(rapidjson::kStringType); |
| 111 | rapidjson::Value value(rapidjson::kStringType); |
| 112 | for (const std::pair<const std::string, std::string>& header : headers) { |
| 113 | key.SetString(header.first.c_str(), allocator); |
| 114 | value.SetString(header.second.c_str(), allocator); |
| 115 | root.AddMember(key, value, allocator); |
| 116 | } |
| 117 | |
| 118 | rapidjson::StringBuffer buffer; |
| 119 | rapidjson::Writer<rapidjson::StringBuffer> writer(buffer); |
| 120 | root.Accept(writer); |
| 121 | return buffer.GetString(); |
| 122 | } |
| 123 | |
| 124 | std::optional<HttpHeaders> convertStringToHeaders( |
| 125 | const std::string& serializedHeaders, |