2008-04-14 Xan Lopez <xan@gnome.org>
authoralp@webkit.org <alp@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Apr 2008 20:18:18 +0000 (20:18 +0000)
committeralp@webkit.org <alp@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Apr 2008 20:18:18 +0000 (20:18 +0000)
        Reviewed by Alp Toker.

        http://bugs.webkit.org/show_bug.cgi?id=17917
        Bug 17917: Cookie support for HTTP soup backend

        Initial implementation of cookies for the http soup backend.

        Moved CookieJarGtk to CookieJarSoup in network/soup and left the original
        one as CookieJarCurl in network/curl.

        Bumped the libsoup required version to 2.23 for cookie support.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@31878 268f45cc-cd09-0410-ab3c-d52691b4dbfc

ChangeLog
WebCore/ChangeLog
WebCore/GNUmakefile.am
WebCore/platform/CookieJar.h
WebCore/platform/network/curl/CookieJarCurl.cpp [moved from WebCore/platform/gtk/CookieJarGtk.cpp with 100% similarity]
WebCore/platform/network/soup/CookieJarSoup.cpp [new file with mode: 0644]
WebCore/platform/network/soup/ResourceHandleSoup.cpp
configure.ac

index 9f4b780..b99ebc7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2008-04-14  Xan Lopez  <xan@gnome.org>
+
+        Reviewed by Alp Toker.
+
+        http://bugs.webkit.org/show_bug.cgi?id=17917
+        Bug 17917: Cookie support for HTTP soup backend
+
+        Bumped the libsoup required version to 2.23 for cookie support.
+
+        * configure.ac:
+
 2008-04-11  Mark Rowe  <mrowe@apple.com>
 
         Rubber-stamped by Anders Carlsson.
index ac8d9b5..8307d8e 100644 (file)
@@ -1,3 +1,27 @@
+2008-04-14  Xan Lopez  <xan@gnome.org>
+
+        Reviewed by Alp Toker.
+
+        http://bugs.webkit.org/show_bug.cgi?id=17917
+        Bug 17917: Cookie support for HTTP soup backend
+
+        Initial implementation of cookies for the http soup backend.
+
+        Moved CookieJarGtk to CookieJarSoup in network/soup and left the original
+        one as CookieJarCurl in network/curl.
+
+        * GNUmakefile.am:
+        * platform/CookieJar.h:
+        * platform/network/curl/CookieJarCurl.cpp: Renamed from WebCore/platform/gtk/CookieJarGtk.cpp.
+        (WebCore::setCookies):
+        (WebCore::cookies):
+        * platform/network/soup/CookieJarSoup.cpp: Added.
+        (WebCore::getCookieJar):
+        (WebCore::setCookies):
+        (WebCore::cookies):
+        * platform/network/soup/ResourceHandleSoup.cpp:
+        (WebCore::ResourceHandle::start):
+
 2008-04-14  Holger Freyther  <zecke@selfish.org>
 
         Reviewed by Alp Toker.
index 4b587b7..92db9bb 100644 (file)
@@ -990,7 +990,6 @@ webkitgtk_sources += \
        WebCore/page/gtk/FrameGtk.cpp \
        WebCore/page/gtk/DragControllerGtk.cpp \
        WebCore/platform/gtk/ClipboardGtk.cpp \
-       WebCore/platform/gtk/CookieJarGtk.cpp \
        WebCore/platform/gtk/CursorGtk.cpp \
        WebCore/platform/gtk/ContextMenuGtk.cpp \
        WebCore/platform/gtk/ContextMenuItemGtk.cpp \
@@ -1052,6 +1051,7 @@ webcore_cppflags += \
        -I$(srcdir)/WebCore/platform/network/curl
 
 webcore_sources += \
+       WebCore/platform/network/curl/CookieJarCurl.cpp \
        WebCore/platform/network/curl/ResourceHandleCurl.cpp \
        WebCore/platform/network/curl/ResourceHandleManager.cpp
 
@@ -1063,6 +1063,7 @@ webcore_cppflags += \
        -I$(srcdir)/WebCore/platform/network/soup
 
 webcore_sources += \
+       WebCore/platform/network/soup/CookieJarSoup.cpp \
        WebCore/platform/network/soup/ResourceHandleSoup.cpp
 endif
 
index 38efd04..22627f2 100644 (file)
 #ifndef CookieJar_h
 #define CookieJar_h
 
+#if USE(SOUP)
+#include <libsoup/soup.h>
+#endif
+
 namespace WebCore {
 
     class KURL;
@@ -35,7 +39,9 @@ namespace WebCore {
     String cookies(const Document* document, const KURL&);
     void setCookies(Document* document, const KURL&, const KURL& policyBaseURL, const String&);
     bool cookiesEnabled(const Document* document);
-
+#if USE(SOUP)
+    SoupCookieJar* getCookieJar(void);
+#endif
 }
 
 #endif
diff --git a/WebCore/platform/network/soup/CookieJarSoup.cpp b/WebCore/platform/network/soup/CookieJarSoup.cpp
new file mode 100644 (file)
index 0000000..af86153
--- /dev/null
@@ -0,0 +1,75 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; -*- */
+/*
+ *  Copyright (C) 2008 Xan Lopez <xan@gnome.org>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+#include "CString.h"
+#include "CookieJar.h"
+
+#include "KURL.h"
+#include "PlatformString.h"
+#include "StringHash.h"
+
+#include <libsoup/soup.h>
+
+namespace WebCore {
+
+SoupCookieJar* getCookieJar()
+{
+    static SoupCookieJar* jar = NULL;
+
+    if (!jar)
+        jar = soup_cookie_jar_new();
+
+    return jar;
+}
+
+void setCookies(Document* /*document*/, const KURL& url, const KURL& /*policyURL*/, const String& value)
+{
+    SoupCookieJar* jar = getCookieJar();
+    if (!jar)
+        return;
+
+    SoupURI* origin = soup_uri_new(url.string().utf8().data());
+
+    soup_cookie_jar_set_cookie(jar, origin, value.utf8().data());
+    soup_uri_free(origin);
+}
+
+String cookies(const Document* /*document*/, const KURL& url)
+{
+    SoupCookieJar* jar = getCookieJar();
+    if (!jar)
+        return String();
+
+    SoupURI* uri = soup_uri_new(url.string().utf8().data());
+    char* cookies = soup_cookie_jar_get_cookies(jar, uri, FALSE);
+    soup_uri_free(uri);
+
+    String result(cookies);
+    g_free(cookies);
+
+    return result;
+}
+
+bool cookiesEnabled(const Document* /*document*/)
+{
+    return getCookieJar();
+}
+
+}
index c5406e9..3c5b362 100644 (file)
@@ -32,6 +32,7 @@
 #include "ResourceHandleClient.h"
 #include "ResourceHandleInternal.h"
 #include "ResourceResponse.h"
+#include "CookieJar.h"
 
 #include <libsoup/soup.h>
 #include <libsoup/soup-message.h>
@@ -285,6 +286,9 @@ bool ResourceHandle::start(Frame* frame)
 
     if (!session) {
         session = soup_session_async_new();
+
+        soup_session_add_feature(session, SOUP_SESSION_FEATURE(getCookieJar()));
+
         const char* soup_debug = g_getenv("WEBKIT_SOUP_LOGGING");
         if (soup_debug) {
             int soup_debug_level = atoi(soup_debug);
index 3ab2baf..4e9e12b 100644 (file)
@@ -223,7 +223,7 @@ GTK_REQUIRED_VERSION=2.8
 
 # optional modules
 LIBCURL_REQUIRED_VERSION=7.15
-LIBSOUP_REQUIRED_VERSION=2.4
+LIBSOUP_REQUIRED_VERSION=2.23
 LIBXSLT_REQUIRED_VERSION=1.1.7
 SQLITE_REQUIRED_VERSION=3.0
 GSTREAMER_REQUIRED_VERSION=0.10