Title: [151580] trunk/Source/WebCore
Revision
151580
Author
[email protected]
Date
2013-06-13 21:47:13 -0700 (Thu, 13 Jun 2013)

Log Message

[curl] Merge http response header values
https://bugs.webkit.org/show_bug.cgi?id=117342

Patch by Peter Gal <[email protected]> on 2013-06-13
Reviewed by Brent Fulgham.

According to the HTTP RFC some HTTP header values should be
merged if multiple entries for the same header exists.

* platform/network/curl/ResourceHandleManager.cpp:
(WebCore::isAppendableHeader):
(WebCore::headerCallback):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (151579 => 151580)


--- trunk/Source/WebCore/ChangeLog	2013-06-14 04:32:35 UTC (rev 151579)
+++ trunk/Source/WebCore/ChangeLog	2013-06-14 04:47:13 UTC (rev 151580)
@@ -1,3 +1,17 @@
+2013-06-13  Peter Gal  <[email protected]>
+
+        [curl] Merge http response header values
+        https://bugs.webkit.org/show_bug.cgi?id=117342
+
+        Reviewed by Brent Fulgham.
+
+        According to the HTTP RFC some HTTP header values should be
+        merged if multiple entries for the same header exists.
+
+        * platform/network/curl/ResourceHandleManager.cpp:
+        (WebCore::isAppendableHeader):
+        (WebCore::headerCallback):
+
 2013-06-13  Simon Fraser  <[email protected]>
 
         Should not call firePaintRelatedMilestones() for "update control tints" paint pass

Modified: trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.cpp (151579 => 151580)


--- trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.cpp	2013-06-14 04:32:35 UTC (rev 151579)
+++ trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.cpp	2013-06-14 04:47:13 UTC (rev 151580)
@@ -236,6 +236,48 @@
     return totalSize;
 }
 
+static bool isAppendableHeader(const String &key)
+{
+    static const char* appendableHeaders[] = {
+        "access-control-allow-headers",
+        "access-control-allow-methods",
+        "access-control-allow-origin",
+        "access-control-expose-headers",
+        "allow",
+        "cache-control",
+        "connection",
+        "content-encoding",
+        "content-language",
+        "if-match",
+        "if-none-match",
+        "keep-alive",
+        "pragma",
+        "proxy-authenticate",
+        "public",
+        "server",
+        "te",
+        "trailer",
+        "transfer-encoding",
+        "upgrade",
+        "user-agent",
+        "vary",
+        "via",
+        "warning",
+        "www-authenticate",
+        0
+    };
+
+    // Custom headers start with 'X-', and need no further checking.
+    if (key.startsWith("x-", /* caseSensitive */ false))
+        return true;
+
+    for (unsigned i = 0; appendableHeaders[i]; ++i)
+        if (equalIgnoringCase(key, appendableHeaders[i]))
+            return true;
+
+    return false;
+}
+
 /*
  * This is being called for each HTTP header in the response. This includes '\r\n'
  * for the last line of the header.
@@ -316,8 +358,15 @@
 
     } else {
         int splitPos = header.find(":");
-        if (splitPos != -1)
-            d->m_response.setHTTPHeaderField(header.left(splitPos), header.substring(splitPos+1).stripWhiteSpace());
+        if (splitPos != -1) {
+            String key = header.left(splitPos).stripWhiteSpace();
+            String value = header.substring(splitPos + 1).stripWhiteSpace();
+
+            if (isAppendableHeader(key))
+                d->m_response.addHTTPHeaderField(key, value);
+            else
+                d->m_response.setHTTPHeaderField(key, value);
+        }
     }
 
     return totalSize;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to