1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 08:47:17 +01:00
SqMod/vendor/CPR/cpr/cookies.cpp
Sandu Liviu Catalin 4a6bfc086c Major plugin refactor and cleanup.
Switched to POCO library for unified platform/library interface.
Deprecated the external module API. It was creating more problems than solving.
Removed most built-in libraries in favor of system libraries for easier maintenance.
Cleaned and secured code with help from static analyzers.
2021-01-30 08:51:39 +02:00

52 lines
1.4 KiB
C++

#include "cpr/cookies.h"
namespace cpr {
std::string Cookies::GetEncoded(const CurlHolder& holder) const {
std::stringstream stream;
for (const std::pair<const std::string, std::string>& item : map_) {
// Depending on if encoding is set to "true", we will URL-encode cookies
stream << (encode ? holder.urlEncode(item.first) : item.first) << "=";
// special case version 1 cookies, which can be distinguished by
// beginning and trailing quotes
if (!item.second.empty() && item.second.front() == '"' && item.second.back() == '"') {
stream << item.second;
} else {
// Depending on if encoding is set to "true", we will URL-encode cookies
stream << (encode ? holder.urlEncode(item.second) : item.second);
}
stream << "; ";
}
return stream.str();
}
std::string& Cookies::operator[](const std::string& key) {
return map_[key];
}
Cookies::iterator Cookies::begin() {
return map_.begin();
}
Cookies::iterator Cookies::end() {
return map_.end();
}
Cookies::const_iterator Cookies::begin() const {
return map_.begin();
}
Cookies::const_iterator Cookies::end() const {
return map_.end();
}
Cookies::const_iterator Cookies::cbegin() const {
return map_.cbegin();
}
Cookies::const_iterator Cookies::cend() const {
return map_.cend();
}
} // namespace cpr