2011-04-28 Arno Renevier <arno@renevier.net>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Apr 2011 17:49:20 +0000 (17:49 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Apr 2011 17:49:20 +0000 (17:49 +0000)
        Reviewed by Gustavo Noronha Silva.

        [Soup] does not load css stylesheets without content-type
        https://bugs.webkit.org/show_bug.cgi?id=59697

        * platform/gtk/Skipped: Enable now passing tests:
         - http/tests/mime/standard-mode-loads-stylesheet-with-empty-content-type.html
         - http/tests/mime/standard-mode-loads-stylesheet-with-text-css-and-invalid-type.html
2011-04-28  Arno Renevier  <arno@renevier.net>

        Reviewed by Gustavo Noronha Silva.

        [Soup] does not load css stylesheets without content-type
        https://bugs.webkit.org/show_bug.cgi?id=59697

        When sniffing content type, do not replace http Content-Type header in
        soup message anymore, but keep sniffed content type in a separate
        variable.

        * platform/network/soup/ResourceHandleSoup.cpp:
        (WebCore::contentSniffedCallback):
        * platform/network/soup/ResourceResponse.h:
        (WebCore::ResourceResponse::sniffedContentType):
        (WebCore::ResourceResponse::setSniffedContentType):
        * platform/network/soup/ResourceResponseSoup.cpp:
        (WebCore::ResourceResponse::updateFromSoupMessage):

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

LayoutTests/ChangeLog
LayoutTests/platform/gtk/Skipped
Source/WebCore/ChangeLog
Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp
Source/WebCore/platform/network/soup/ResourceResponse.h
Source/WebCore/platform/network/soup/ResourceResponseSoup.cpp

index 627a966..8516927 100644 (file)
@@ -1,3 +1,14 @@
+2011-04-28  Arno Renevier  <arno@renevier.net>
+
+        Reviewed by Gustavo Noronha Silva.
+
+        [Soup] does not load css stylesheets without content-type
+        https://bugs.webkit.org/show_bug.cgi?id=59697
+
+        * platform/gtk/Skipped: Enable now passing tests:
+         - http/tests/mime/standard-mode-loads-stylesheet-with-empty-content-type.html
+         - http/tests/mime/standard-mode-loads-stylesheet-with-text-css-and-invalid-type.html
+
 2011-04-28  Adam Roben  <aroben@apple.com>
 
         Update expected results for a hyphenation test
index dd152f9..7698d90 100644 (file)
@@ -515,8 +515,6 @@ http/tests/loading/text-content-type-with-binary-extension.html
 http/tests/media/video-play-stall-seek.html
 http/tests/media/video-play-stall.html
 http/tests/media/video-seekable-stall.html
-http/tests/mime/standard-mode-loads-stylesheet-with-empty-content-type.html
-http/tests/mime/standard-mode-loads-stylesheet-with-text-css-and-invalid-type.html
 http/tests/misc/acid3.html
 http/tests/misc/link-rel-prefetch-and-subresource.html
 http/tests/misc/policy-delegate-called-twice.html
@@ -1398,4 +1396,4 @@ fast/events/keydown-1.html
 
 # Unskip when https://bugs.webkit.org/show_bug.cgi?id=59571 is fixed
 fast/dom/shadow/gc-shadow.html
-fast/dom/shadow/no-renderers-for-light-children.html
\ No newline at end of file
+fast/dom/shadow/no-renderers-for-light-children.html
index 71ac98e..f602988 100644 (file)
@@ -1,3 +1,22 @@
+2011-04-28  Arno Renevier  <arno@renevier.net>
+
+        Reviewed by Gustavo Noronha Silva.
+
+        [Soup] does not load css stylesheets without content-type
+        https://bugs.webkit.org/show_bug.cgi?id=59697
+
+        When sniffing content type, do not replace http Content-Type header in
+        soup message anymore, but keep sniffed content type in a separate
+        variable.
+
+        * platform/network/soup/ResourceHandleSoup.cpp:
+        (WebCore::contentSniffedCallback):
+        * platform/network/soup/ResourceResponse.h:
+        (WebCore::ResourceResponse::sniffedContentType):
+        (WebCore::ResourceResponse::setSniffedContentType):
+        * platform/network/soup/ResourceResponseSoup.cpp:
+        (WebCore::ResourceResponse::updateFromSoupMessage):
+
 2011-04-28  Yael Aharon  <yael.aharon@nokia.com>
 
         Reviewed by Andreas Kling.
index dc22fca..c7ddc75 100644 (file)
@@ -316,12 +316,6 @@ static void wroteBodyDataCallback(SoupMessage*, SoupBuffer* buffer, gpointer dat
 // This callback will not be called if the content sniffer is disabled in startHTTPRequest.
 static void contentSniffedCallback(SoupMessage* msg, const char* sniffedType, GHashTable *params, gpointer data)
 {
-    if (sniffedType) {
-        const char* officialType = soup_message_headers_get_one(msg->response_headers, "Content-Type");
-
-        if (!officialType || strcmp(officialType, sniffedType))
-            soup_message_headers_set_content_type(msg->response_headers, sniffedType, params);
-    }
 
     if (statusWillBeHandledBySoup(msg->status_code))
         return;
@@ -338,6 +332,24 @@ static void contentSniffedCallback(SoupMessage* msg, const char* sniffedType, GH
 
     ASSERT(d->m_response.isNull());
 
+    if (sniffedType) {
+        const char* officialType = soup_message_headers_get_one(msg->response_headers, "Content-Type");
+        if (!officialType || strcmp(officialType, sniffedType)) {
+            GString* str = g_string_new(sniffedType);
+            if (params) {
+                GHashTableIter iter;
+                gpointer key, value;
+                g_hash_table_iter_init(&iter, params);
+                while (g_hash_table_iter_next(&iter, &key, &value)) {
+                    g_string_append(str, "; ");
+                    soup_header_g_string_append_param(str, static_cast<const char*>(key), static_cast<const char*>(value));
+                }
+            }
+            d->m_response.setSniffedContentType(str->str);
+            g_string_free(str, TRUE);
+        }
+    }
+
     fillResponseFromMessage(msg, &d->m_response);
     client->didReceiveResponse(handle.get(), d->m_response);
 }
index e7213f5..6ebba8b 100644 (file)
@@ -58,10 +58,14 @@ public:
     SoupMessageFlags soupMessageFlags() const { return m_soupFlags; }
     void setSoupMessageFlags(SoupMessageFlags soupFlags) { m_soupFlags = soupFlags; }
 
+    const String& sniffedContentType() const { return m_sniffedContentType; }
+    void setSniffedContentType(const String& value) { m_sniffedContentType = value; }
+
 private:
     friend class ResourceResponseBase;
 
     SoupMessageFlags m_soupFlags;
+    String m_sniffedContentType;
 
     void doUpdateResourceResponse() { }
 
index 3bcdcc4..2c24e6d 100644 (file)
@@ -71,7 +71,11 @@ void ResourceResponse::updateFromSoupMessage(SoupMessage* soupMessage)
 
     m_soupFlags = soup_message_get_flags(soupMessage);
 
-    String contentType = soup_message_headers_get_one(soupMessage->response_headers, "Content-Type");
+    String contentType;
+    if (sniffedContentType().isEmpty())
+        contentType = soup_message_headers_get_one(soupMessage->response_headers, "Content-Type");
+    else
+        contentType = this->sniffedContentType();
     setMimeType(extractMIMETypeFromMediaType(contentType));
 
     setTextEncodingName(extractCharsetFromMediaType(contentType));