Title: [142574] trunk/Source/WebCore
- Revision
- 142574
- Author
- [email protected]
- Date
- 2013-02-11 20:34:21 -0800 (Mon, 11 Feb 2013)
Log Message
[Curl] setCookiesFromDOM function does not save cookies to disk.
https://bugs.webkit.org/show_bug.cgi?id=109285
Patch by [email protected] <[email protected]> on 2013-02-11
Reviewed by Brent Fulgham.
Write cookies to disk by using the Curl easy api.
* platform/network/curl/CookieJarCurl.cpp:
(WebCore::setCookiesFromDOM):Write cookie to disk.
* platform/network/curl/ResourceHandleManager.cpp:
(WebCore::ResourceHandleManager::getCurlShareHandle): Added method to get Curl share handle.
(WebCore::ResourceHandleManager::getCookieJarFileName): Added method to get cookie file name.
* platform/network/curl/ResourceHandleManager.h: Added methods to get cookie file name, and Curl share handle.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (142573 => 142574)
--- trunk/Source/WebCore/ChangeLog 2013-02-12 04:32:05 UTC (rev 142573)
+++ trunk/Source/WebCore/ChangeLog 2013-02-12 04:34:21 UTC (rev 142574)
@@ -1,3 +1,19 @@
+2013-02-11 [email protected] <[email protected]>
+
+ [Curl] setCookiesFromDOM function does not save cookies to disk.
+ https://bugs.webkit.org/show_bug.cgi?id=109285
+
+ Reviewed by Brent Fulgham.
+
+ Write cookies to disk by using the Curl easy api.
+
+ * platform/network/curl/CookieJarCurl.cpp:
+ (WebCore::setCookiesFromDOM):Write cookie to disk.
+ * platform/network/curl/ResourceHandleManager.cpp:
+ (WebCore::ResourceHandleManager::getCurlShareHandle): Added method to get Curl share handle.
+ (WebCore::ResourceHandleManager::getCookieJarFileName): Added method to get cookie file name.
+ * platform/network/curl/ResourceHandleManager.h: Added methods to get cookie file name, and Curl share handle.
+
2013-02-11 Hayato Ito <[email protected]>
Split each RuleSet and feature out from StyleResolver into its own class.
Modified: trunk/Source/WebCore/platform/network/curl/CookieJarCurl.cpp (142573 => 142574)
--- trunk/Source/WebCore/platform/network/curl/CookieJarCurl.cpp 2013-02-12 04:32:05 UTC (rev 142573)
+++ trunk/Source/WebCore/platform/network/curl/CookieJarCurl.cpp 2013-02-12 04:34:21 UTC (rev 142574)
@@ -19,6 +19,8 @@
#include "Cookie.h"
#include "KURL.h"
+#include "ResourceHandleManager.h"
+
#include <wtf/HashMap.h>
#include <wtf/text/StringHash.h>
#include <wtf/text/WTFString.h>
@@ -30,6 +32,30 @@
void setCookiesFromDOM(const NetworkStorageSession&, const KURL&, const KURL& url, const String& value)
{
cookieJar.set(url.string(), value);
+
+ CURL* curl = curl_easy_init();
+
+ if (!curl)
+ return;
+
+ const char* cookieJarFileName = ResourceHandleManager::sharedInstance()->getCookieJarFileName();
+ CURLSH* curlsh = ResourceHandleManager::sharedInstance()->getCurlShareHandle();
+
+ curl_easy_setopt(curl, CURLOPT_COOKIEJAR, cookieJarFileName);
+ curl_easy_setopt(curl, CURLOPT_COOKIEFILE, cookieJarFileName);
+ curl_easy_setopt(curl, CURLOPT_SHARE, curlsh);
+
+ String cookie("Set-Cookie: ");
+ if (value.is8Bit())
+ cookie.append(value);
+ else
+ cookie.append(String::make8BitFrom16BitSource(value.characters16(), value.length()));
+
+ CString strCookie(reinterpret_cast<const char*>(cookie.characters8()), cookie.length());
+
+ curl_easy_setopt(curl, CURLOPT_COOKIELIST, strCookie.data());
+
+ curl_easy_cleanup(curl);
}
String cookiesForDOM(const NetworkStorageSession&, const KURL&, const KURL& url)
Modified: trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.cpp (142573 => 142574)
--- trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.cpp 2013-02-12 04:32:05 UTC (rev 142573)
+++ trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.cpp 2013-02-12 04:34:21 UTC (rev 142574)
@@ -151,11 +151,21 @@
curl_global_cleanup();
}
+CURLSH* ResourceHandleManager::getCurlShareHandle() const
+{
+ return m_curlShareHandle;
+}
+
void ResourceHandleManager::setCookieJarFileName(const char* cookieJarFileName)
{
m_cookieJarFileName = fastStrDup(cookieJarFileName);
}
+const char* ResourceHandleManager::getCookieJarFileName() const
+{
+ return m_cookieJarFileName;
+}
+
ResourceHandleManager* ResourceHandleManager::sharedInstance()
{
static ResourceHandleManager* sharedInstance = 0;
Modified: trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.h (142573 => 142574)
--- trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.h 2013-02-12 04:32:05 UTC (rev 142573)
+++ trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.h 2013-02-12 04:34:21 UTC (rev 142574)
@@ -56,7 +56,11 @@
static ResourceHandleManager* sharedInstance();
void add(ResourceHandle*);
void cancel(ResourceHandle*);
+
+ CURLSH* getCurlShareHandle() const;
+
void setCookieJarFileName(const char* cookieJarFileName);
+ const char* getCookieJarFileName() const;
void dispatchSynchronousJob(ResourceHandle*);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes