Changeset 142574 in webkit


Ignore:
Timestamp:
Feb 11, 2013 8:34:21 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[Curl] setCookiesFromDOM function does not save cookies to disk.
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.
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r142573 r142574  
     12013-02-11  peavo@outlook.com  <peavo@outlook.com>
     2
     3        [Curl] setCookiesFromDOM function does not save cookies to disk.
     4        https://bugs.webkit.org/show_bug.cgi?id=109285
     5
     6        Reviewed by Brent Fulgham.
     7
     8        Write cookies to disk by using the Curl easy api.
     9
     10        * platform/network/curl/CookieJarCurl.cpp:
     11        (WebCore::setCookiesFromDOM):Write cookie to disk.
     12        * platform/network/curl/ResourceHandleManager.cpp:
     13        (WebCore::ResourceHandleManager::getCurlShareHandle): Added method to get Curl share handle.
     14        (WebCore::ResourceHandleManager::getCookieJarFileName): Added method to get cookie file name.
     15        * platform/network/curl/ResourceHandleManager.h: Added methods to get cookie file name, and Curl share handle.
     16
    1172013-02-11  Hayato Ito  <hayato@chromium.org>
    218
  • trunk/Source/WebCore/platform/network/curl/CookieJarCurl.cpp

    r138413 r142574  
    2020#include "Cookie.h"
    2121#include "KURL.h"
     22#include "ResourceHandleManager.h"
     23
    2224#include <wtf/HashMap.h>
    2325#include <wtf/text/StringHash.h>
     
    3133{
    3234    cookieJar.set(url.string(), value);
     35
     36    CURL* curl = curl_easy_init();
     37
     38    if (!curl)
     39        return;
     40
     41    const char* cookieJarFileName = ResourceHandleManager::sharedInstance()->getCookieJarFileName();
     42    CURLSH* curlsh = ResourceHandleManager::sharedInstance()->getCurlShareHandle();
     43
     44    curl_easy_setopt(curl, CURLOPT_COOKIEJAR, cookieJarFileName);
     45    curl_easy_setopt(curl, CURLOPT_COOKIEFILE, cookieJarFileName);
     46    curl_easy_setopt(curl, CURLOPT_SHARE, curlsh);
     47
     48    String cookie("Set-Cookie: ");
     49    if (value.is8Bit())
     50        cookie.append(value);
     51    else
     52        cookie.append(String::make8BitFrom16BitSource(value.characters16(), value.length()));
     53
     54    CString strCookie(reinterpret_cast<const char*>(cookie.characters8()), cookie.length());
     55
     56    curl_easy_setopt(curl, CURLOPT_COOKIELIST, strCookie.data());
     57
     58    curl_easy_cleanup(curl);
    3359}
    3460
  • trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.cpp

    r141464 r142574  
    152152}
    153153
     154CURLSH* ResourceHandleManager::getCurlShareHandle() const
     155{
     156    return m_curlShareHandle;
     157}
     158
    154159void ResourceHandleManager::setCookieJarFileName(const char* cookieJarFileName)
    155160{
    156161    m_cookieJarFileName = fastStrDup(cookieJarFileName);
     162}
     163
     164const char* ResourceHandleManager::getCookieJarFileName() const
     165{
     166    return m_cookieJarFileName;
    157167}
    158168
  • trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.h

    r127757 r142574  
    5757    void add(ResourceHandle*);
    5858    void cancel(ResourceHandle*);
     59
     60    CURLSH* getCurlShareHandle() const;
     61
    5962    void setCookieJarFileName(const char* cookieJarFileName);
     63    const char* getCookieJarFileName() const;
    6064
    6165    void dispatchSynchronousJob(ResourceHandle*);
Note: See TracChangeset for help on using the changeset viewer.