cookies.cpp
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         // special case version 1 cookies, which can be distinguished by
00015         // beginning and trailing quotes
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 } // namespace cpr


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:02