About webkit cookie

71 篇文章 0 订阅
1 篇文章 0 订阅

About webkit cookie

在libcurl中实现了cookie的管理,但是没有实现cache的管理,libsoup没有实现cookie的管理,但实现了cache的管理。通过查看这些网络库感觉还是winiet实现的比较全面。不知goole的网络库那块是否比较容易的portwebkit用。

通过网络接口操作的cookie已经交给网络库管理了,但是以下两种情况需要开发者实现CookieJar.h中对应库的接口,达到和网络库中的cookie的同步。

1> document.cookie = ...

2>  <head>
       <meta http-equiv="Set-Cookie" content="SomeCookie=SomeValue; expires=Sat, 01-Jan-2000 00:00:00 GMT; path=/"/>
     </head>


实现方式:

CURLOPT_COOKIE

CURLOPT_COOKIEFILE

CURLOPT_COOKIEJAR

CURLOPT_URL


curl* handle = curl_easy_init();

curl_easy_setopt(handle, CURLOPT_COOKIEFILE, cookieJarFileName);/* just to start the cookie engine */
curl_easy_setopt(handle, CURLOPT_COOKIEJAR, cookieJarFileName);

curl_easy_setopt(handle, CURLOPT_URL, url);

curl_easy_setopt(handle,CURLOPT_COOKIE, url);


//struct curl_slist *list;
//code = curl_easy_getinfo(curl,CURLINFO_COOKIELIST,&list);/*it include the stale cooike*/
//curl_slist_free_all (list);

curl_easy_cleanup(handle)


If you are using something like Curl then Curl handles cookies itself 
except I believe the CookieJarCurl.cpp code is wrong because it has the 
cookieJar HashMap below whereas really the functions below need to talk 
directly to the Curl cookie manager. The code below is of course also 
wrong because it doesn't understand expirations and paths, but I presume 
that's obvious to the cookie connoisseur. If you are implementing your 
cookie handling, then you need to have your transport handler either 
handle the cookies itself like Curl does or you need to have some 
independent cookie manager that listens to received headers and is 
called by the code below and which can write outgoing headers before 
your HTTP code sends them.


参考:

1. http://blog.sina.com.cn/s/blog_71b5e2520100ueh6.html

2. http://curl.haxx.se/libcurl/c/curl_easy_setopt.html

3. http://blog.csdn.net/xiangding/article/details/7430061 

4. http://www.cppblog.com/qiujian5628/archive/2008/06/28/54873.html

5.  http://curl.haxx.se/libcurl/c/cookie_interface.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值