OSDN Git Service

WebResponse headers should be case-insensitive.
authorIain Merrick <husky@google.com>
Thu, 9 Dec 2010 16:59:21 +0000 (16:59 +0000)
committerIain Merrick <husky@google.com>
Thu, 9 Dec 2010 16:59:21 +0000 (16:59 +0000)
The CTS test WebViewTest.testSetDownloadListener was failing due to
a disagreement over the capitalization of "Content-Disposition". Rather
than making our stack exactly match the CTS server, it looks like the
headers should actually be case-insensitive. (Note that we still preserve
the case of the headers exactly as reported by the server, so hopefully
this won't break anything else.)

BUG=3242063
TEST=WebViewTest.testSetDownloadListener

Change-Id: I0931da98aab9080127e355e51d89ac3fde12e7c2

WebKit/android/WebCoreSupport/WebResponse.h

index 84a93ab..f03e4bb 100644 (file)
@@ -71,7 +71,15 @@ private:
     std::string m_mime;
     std::string m_url;
 
-    std::map<std::string, std::string> m_headerFields;
+    struct CaseInsensitiveLessThan {
+        bool operator()(const std::string& lhs, const std::string& rhs) const {
+            return strcasecmp(lhs.c_str(), rhs.c_str()) < 0;
+        }
+    };
+
+    // Header fields are case insensitive, so we use a case-insensitive map.
+    // See RFC 822, 3.4.7, "CASE INDEPENDENCE".
+    std::map<std::string, std::string, CaseInsensitiveLessThan> m_headerFields;
 
     void setMimeType(const std::string &mimeType);
 };