Go to the documentation of this file.00001 #include "cpr/cookies.h"
00002
00003 #include "cpr/util.h"
00004
00005 namespace cpr {
00006
00007 Cookies::Cookies(const std::initializer_list<std::pair<const std::string, std::string>>& pairs)
00008 : map_{pairs} {}
00009
00010 std::string Cookies::GetEncoded() const {
00011 std::stringstream stream;
00012 for (const auto& item : map_) {
00013 stream << cpr::util::urlEncode(item.first) << "=";
00014
00015
00016 if (!item.second.empty() && item.second.front() == '"' && item.second.back() == '"') {
00017 stream << item.second;
00018 } else {
00019 stream << cpr::util::urlEncode(item.second);
00020 }
00021 stream << "; ";
00022 }
00023 return stream.str();
00024 }
00025
00026 std::string& Cookies::operator[](const std::string& key) {
00027 return map_[key];
00028 }
00029
00030 }