如何从 curlpp 请求中检索响应 cookie?
我想存储 HTTP GET 请求的 PHP session 。这是我当前的代码:
void Grooveshark::Connection::processPHPCookie()
{
std::ostringstream buffer;
gsDebug("Processing PHP cookie...");
try {
request.setOpt<cURLpp::Options::Url>("http://listen.grooveshark.com");
request.setOpt<cURLpp::Options::WriteStream>(&buffer);
request.perform();
// Get the PHP Session cookie here..
} catch (cURLpp::LogicError& exception) {
gsError(exception.what());
} catch (cURLpp::RuntimeError& exception) {
gsError(exception.what());
}
gsDebug("Processing complete...");
}
request
是一个 cURLpp::Easy
实例。如果您需要更多详细信息,可以找到我的源代码 here
提前致谢。
最佳答案
首先,设置exEasy.setOpt(curlpp::options::CookieFile("")
然后调用exEasy.perform()
,
然后循环
std::list<std::string> cookies;
curlpp::infos::CookieList::get(exEasy, cookies);
关于c++ - 如何通过 curlpp 检索响应 cookie?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4356911/