我使用的quick版本是3.2rc1版本
在lua代码中设置cookie的使用方法
local tr = network.createHTTPRequest(onRequestFinished, completeUrl, method)
tr:setCookieString(cc.FileUtils:getInstance():getWritablePath()..'cookie.txt')tr:start()
按此方法设置之后发现每次返回的cookie列表是变化的
原因如下:
libquick 的c++代码:
void HTTPRequest::setCookieString(const char *cookie)
{
CCAssert(m_state == kCCHTTPRequestStateIdle, "HTTPRequest::setAcceptEncoding() - request not idle");
curl_easy_setopt(m_curl, CURLOPT_COOKIE, cookie ? cookie : ""))
}
修改为
void HTTPRequest::setCookieString(const char *cookie)
{
CCAssert(m_state == kCCHTTPRequestStateIdle, "HTTPRequest::setAcceptEncoding() - request not idle");
if (cookie) {
if (CURLE_OK !=curl_easy_setopt(m_curl,CURLOPT_COOKIEFILE, cookie)) {
printf("cookie enable failed");
}
if (CURLE_OK !=curl_easy_setopt(m_curl,CURLOPT_COOKIEJAR, cookie)) {
printf("cookie enable failed");
}
}
}
这样就保证每次返回的cookie都一致了。