About webkit cookie

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

你可能感兴趣的:(About webkit cookie)