void HTTPResponse::getCookies(std::vector<HTTPCookie>& cookies) const { cookies.clear(); NameValueCollection::ConstIterator it = find(SET_COOKIE); while (it != end() && Poco::icompare(it->first, SET_COOKIE) == 0) { NameValueCollection nvc; splitParameters(it->second.begin(), it->second.end(), nvc); cookies.push_back(HTTPCookie(nvc)); ++it; } }
void cgicc::CgiEnvironment::parseCookie(const std::string& data) { // find the '=' separating the name and value std::string::size_type pos = data.find("=", 0); // if no '=' was found, return if(std::string::npos == pos) return; // skip leading whitespace - " \f\n\r\t\v" std::string::size_type wscount = 0; std::string::const_iterator data_iter; for(data_iter = data.begin(); data_iter != data.end(); ++data_iter,++wscount) if(0 == std::isspace(*data_iter)) break; // Per RFC 2091, do not unescape the data (thanks to [email protected]) std::string name = data.substr(wscount, pos - wscount); std::string value = data.substr(++pos); fCookies.push_back(HTTPCookie(name, value)); }
//------------------------------------------------------------------------------ void ofxHTTPBaseRequest::addCookie(const string& name, const string& value, bool isValueEscaped) { addCookie(HTTPCookie(name, isValueEscaped ? value : HTTPCookie::escape(value))); }