Title: [139423] trunk/Source/WebCore
Revision
139423
Author
mary...@torchmobile.com.cn
Date
2013-01-11 03:12:18 -0800 (Fri, 11 Jan 2013)

Log Message

[BlackBerry] Enable concatenating headers with same field name
https://bugs.webkit.org/show_bug.cgi?id=106625

Reviewed by Rob Buis.

RFC 2616 specifies that headers could concatenate with comma if they have
same field name. We should enable this if the header allows multiple values.

RIM PR# 275508, internally reviewed by Joe Mason

(WebCore):
(WebCore::isAppendableHeader):
(WebCore::NetworkJob::handleNotifyHeaderReceived):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (139422 => 139423)


--- trunk/Source/WebCore/ChangeLog	2013-01-11 10:31:42 UTC (rev 139422)
+++ trunk/Source/WebCore/ChangeLog	2013-01-11 11:12:18 UTC (rev 139423)
@@ -1,3 +1,19 @@
+2013-01-11  Mary Wu  <mary...@torchmobile.com.cn>
+
+        [BlackBerry] Enable concatenating headers with same field name
+        https://bugs.webkit.org/show_bug.cgi?id=106625
+
+        Reviewed by Rob Buis.
+
+        RFC 2616 specifies that headers could concatenate with comma if they have
+        same field name. We should enable this if the header allows multiple values.
+
+        RIM PR# 275508, internally reviewed by Joe Mason
+
+        (WebCore):
+        (WebCore::isAppendableHeader):
+        (WebCore::NetworkJob::handleNotifyHeaderReceived):
+
 2013-01-11  Jochen Eisinger  <joc...@chromium.org>
 
         Connect UserGestureIndicator for mousedown and mouseup events

Modified: trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp (139422 => 139423)


--- trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp	2013-01-11 10:31:42 UTC (rev 139422)
+++ trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp	2013-01-11 11:12:18 UTC (rev 139423)
@@ -63,6 +63,22 @@
     return statusCode == 401;
 }
 
+static char* const appendableHeaders[] = {"access-control-allow-origin", "allow",
+    "set-cookie", "set-cookie2", "vary", "via", "warning"};
+
+static bool isAppendableHeader(const String& key)
+{
+    // Non-standard header fields are conventionally marked by prefixing the field name with X-.
+    if (key.startsWith("x-"))
+        return true;
+
+    for (int i = 0; i < sizeof(appendableHeaders) /sizeof(char*); i++)
+        if (key == appendableHeaders[i])
+            return true;
+
+    return false;
+}
+
 NetworkJob::NetworkJob()
     : FrameDestructionObserver(0)
     , m_playerId(0)
@@ -336,20 +352,17 @@
         m_contentType = value.lower();
     else if (lowerKey == "content-disposition")
         m_contentDisposition = value;
-    else if (lowerKey == "set-cookie") {
-        if (m_frame && m_frame->loader() && m_frame->loader()->client()
-            && static_cast<FrameLoaderClientBlackBerry*>(m_frame->loader()->client())->cookiesEnabled()) {
-            handleSetCookieHeader(value);
-            // If there are several "Set-Cookie" headers, we should combine the following ones with the first.
-            if (m_response.httpHeaderFields().contains("Set-Cookie")) {
-                m_response.setHTTPHeaderField(key, m_response.httpHeaderField(key) + ", " + value);
-                return;
-            }
-        }
-    } else if (equalIgnoringCase(key, BlackBerry::Platform::NetworkRequest::HEADER_BLACKBERRY_FTP))
+    else if (lowerKey == "set-cookie" && m_frame && m_frame->loader() && m_frame->loader()->client()
+        && static_cast<FrameLoaderClientBlackBerry*>(m_frame->loader()->client())->cookiesEnabled())
+        handleSetCookieHeader(value);
+    else if (equalIgnoringCase(key, BlackBerry::Platform::NetworkRequest::HEADER_BLACKBERRY_FTP))
         handleFTPHeader(value);
 
-    m_response.setHTTPHeaderField(key, value);
+    if (m_response.httpHeaderFields().contains(key.utf8().data()) && isAppendableHeader(lowerKey)) {
+        // If there are several headers with same key, we should combine the following ones with the first.
+        m_response.setHTTPHeaderField(key, m_response.httpHeaderField(key) + ", " + value);
+    } else
+        m_response.setHTTPHeaderField(key, value);
 }
 
 void NetworkJob::handleNotifyMultipartHeaderReceived(const String& key, const String& value)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to