https://bugs.webkit.org/show_bug.cgi?id=109285
Patch by peavo@outlook.com <peavo@outlook.com> 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.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@142574
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2013-02-11 peavo@outlook.com <peavo@outlook.com>
+
+ [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 <hayato@chromium.org>
Split each RuleSet and feature out from StyleResolver into its own class.
#include "Cookie.h"
#include "KURL.h"
+#include "ResourceHandleManager.h"
+
#include <wtf/HashMap.h>
#include <wtf/text/StringHash.h>
#include <wtf/text/WTFString.h>
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)
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;
static ResourceHandleManager* sharedInstance();
void add(ResourceHandle*);
void cancel(ResourceHandle*);
+
+ CURLSH* getCurlShareHandle() const;
+
void setCookieJarFileName(const char* cookieJarFileName);
+ const char* getCookieJarFileName() const;
void dispatchSynchronousJob(ResourceHandle*);