libcurl cookie在Android上有效
libcurl cookie expiry on android
我在Android下看到Libcurls Cookie引擎的怪异行为,而它在iOS中正常工作。
当到期年度2038年或更高时,Cookie到期日期的解析似乎在Android中起作用。我知道Unix Timestamps的INT溢出问题,但这只能在2038年1月19日发生。与Libcurl一起,我一旦我去2038年1月1日00:00 AM就会发生问题。
。以下不是确切的原始代码,因为这更复杂。但是cookie字符串和卷发呼叫完全相同。
// ...create the curl handle...
// Add test cookies in Set-Cookie syntax, because the issue seems to have to do with expiry parsing
static const std::string border = "Tue, 19-Jan-2087 03:14:08 GMT";
static const std::string borderP1 = "Fri, 01-Jan-2038 00:00:00 GMT";
static const std::string borderM1 = "Thu, 31-Dec-2037 23:59:59 GMT";
curl_easy_setopt(curlHandle, CURLOPT_COOKIELIST, ("Set-Cookie: my1=border;Domain=10.101.32.24;Path=/;Expires=" + border).c_str());
curl_easy_setopt(curlHandle, CURLOPT_COOKIELIST, ("Set-Cookie: my2=borderP1;Domain=10.101.32.24;Path=/;Expires=" + borderP1).c_str());
curl_easy_setopt(curlHandle, CURLOPT_COOKIELIST, ("Set-Cookie: my3=borderM1;Domain=10.101.32.24;Path=/;Expires=" + borderM1).c_str());
// Add another cookie in netscape syntax to compare (this one expires on July 10, 3145 9:20:00 AM)
curl_easy_setopt(curlHandle, CURLOPT_COOKIELIST, "10.101.32.24tFALSEt/tFALSEt37095873600ttesttcookie")
// Code to print all cookies known to curl for test purposes:
struct curl_slist *cookies;
curl_easy_getinfo(curlHandle, CURLINFO_COOKIELIST, &cookies);
for (auto c = cookies; c; c = c->next) {
LogStream::debug("Cookie") << c->data;
}
curl_slist_free_all(cookies);
日志中的结果线看起来像:
Cookie: 10.101.32.24 FALSE / FALSE 0 my1 border
Cookie: 10.101.32.24 FALSE / FALSE 0 my2 borderP1
Cookie: 10.101.32.24 FALSE / FALSE 2145916799 my3 borderM1
Cookie: 10.101.32.24 FALSE / FALSE 37095873600 test cookie
因此,对于2038年或以上的前2个cookie,到期的结果为0。这意味着它们被视为会话cookie,这对我不利。奇怪的是,这似乎不是由32位int溢出引起的,因为使用Netscape语法,支持更大的到期值。
我无法共享libcurl的确切构建设置,但它是从这里使用的脚本派生的,并且仍然相当相似:https://github.com/gcesarmza/curl-android-ios。我们使用此设置来构建Libcurl的iOS和Android二进制文件(版本7.62.0(。同样,使用iOS二进制文件,它可以正常工作(所有饼干都有正确的到期(。
在实际代码中,我还验证了curl_easy_setopt
的返回,并且成功。如果您需要更多的设置代码,我可以尝试整理一个更完整的示例,但这需要一些时间。
有人知道是什么原因?
curl_setopt
调用 Curl_cookie_add
,又调用" set-cookie"式输入的 curl_getdate
。此功能最终以以下代码结束:
/* a signed 32 bit time_t can only hold dates to the beginning of 2038 */
if(yearnum > 2037) {
*output = TIME_T_MAX;
return PARSEDATE_LATER;
}
相关文章:
- 使用C++库在Android项目中修改gradle中的cmake参数,用于插入指令的测试
- 如何使用ndk-build.cmd构建Android.so文件
- 欧拉项目#8答案是大以获得有效答案
- Android NDK传感器向事件队列报告奇怪的间隔
- 调整大小后指向元素值的指针unordered_map有效?
- 为什么是0;C++中的有效语句
- 最高有效数字侧的第N位
- GCC对可能有效的代码抛出init list生存期警告
- 有效地使用std::unordered_map来插入或增加键的值
- c++中O(n^(1/3))中一个数的除数的有效计数
- 使用无符号字符数组有效存储内存
- 自定义先决条件对移动分配运算符有效吗
- Android P-9.0.0_r53 Logcat主缓冲区超出定义大小
- 为什么将值返回函数传递给重载=运算符对运算符函数有效,而对其他运算符无效
- OpenCV Android C++ imwrite not found
- libcurl cookie在Android上有效
- 在 Android NDK 中使用比 Android 清单中最低 API 更高的 API 是否有效?
- 在 OpenGL ES for Android 中运行时创建大型纹理的最有效方法
- Eclipse上带有Android的本机c++-在stdlib上出现错误,但有效
- Android ndk:不是有效的ELF可执行文件