Modified: trunk/Source/WebCore/ChangeLog (170022 => 170023)
--- trunk/Source/WebCore/ChangeLog 2014-06-16 19:27:46 UTC (rev 170022)
+++ trunk/Source/WebCore/ChangeLog 2014-06-16 19:46:36 UTC (rev 170023)
@@ -1,5 +1,22 @@
2014-06-16 Anders Carlsson <[email protected]>
+ Use HTTPHeaderName in more places
+ https://bugs.webkit.org/show_bug.cgi?id=133948
+
+ Reviewed by Andreas Kling.
+
+ * loader/cache/CachedRawResource.cpp:
+ (WebCore::shouldIgnoreHeaderForCacheReuse):
+ * platform/network/HTTPHeaderNames.in:
+ * xml/XMLHttpRequest.cpp:
+ (WebCore::isSetCookieHeader):
+ (WebCore::isForbiddenRequestHeader):
+ (WebCore::XMLHttpRequest::isAllowedHTTPHeader):
+ (WebCore::XMLHttpRequestStaticData::XMLHttpRequestStaticData): Deleted.
+ (WebCore::staticData): Deleted.
+
+2014-06-16 Anders Carlsson <[email protected]>
+
Add HTTPHeaderName overloads on ResourceResponseBase
https://bugs.webkit.org/show_bug.cgi?id=133946
Modified: trunk/Source/WebCore/loader/cache/CachedRawResource.cpp (170022 => 170023)
--- trunk/Source/WebCore/loader/cache/CachedRawResource.cpp 2014-06-16 19:27:46 UTC (rev 170022)
+++ trunk/Source/WebCore/loader/cache/CachedRawResource.cpp 2014-06-16 19:46:36 UTC (rev 170023)
@@ -29,10 +29,11 @@
#include "CachedRawResourceClient.h"
#include "CachedResourceClientWalker.h"
#include "CachedResourceLoader.h"
+#include "HTTPHeaderNames.h"
#include "ResourceBuffer.h"
#include "SubresourceLoader.h"
-#include <wtf/NeverDestroyed.h>
#include <wtf/PassRefPtr.h>
+#include <wtf/text/StringView.h>
namespace WebCore {
@@ -199,20 +200,25 @@
m_options.dataBufferingPolicy = dataBufferingPolicy;
}
-static bool shouldIgnoreHeaderForCacheReuse(AtomicString headerName)
+static bool shouldIgnoreHeaderForCacheReuse(const String& headerName)
{
+ HTTPHeaderName name;
+ if (!findHTTPHeaderName(headerName, name))
+ return false;
+
+ switch (name) {
// FIXME: This list of headers that don't affect cache policy almost certainly isn't complete.
- static NeverDestroyed<HashSet<AtomicString>> m_headers;
- if (m_headers.get().isEmpty()) {
- m_headers.get().add("Accept");
- m_headers.get().add("Cache-Control");
- m_headers.get().add("Origin");
- m_headers.get().add("Pragma");
- m_headers.get().add("Purpose");
- m_headers.get().add("Referer");
- m_headers.get().add("User-Agent");
+ case HTTPHeaderName::Accept:
+ case HTTPHeaderName::CacheControl:
+ case HTTPHeaderName::Pragma:
+ case HTTPHeaderName::Purpose:
+ case HTTPHeaderName::Referer:
+ case HTTPHeaderName::UserAgent:
+ return true;
+
+ default:
+ return false;
}
- return m_headers.get().contains(headerName);
}
bool CachedRawResource::canReuse(const ResourceRequest& newRequest) const
Modified: trunk/Source/WebCore/platform/network/HTTPHeaderNames.in (170022 => 170023)
--- trunk/Source/WebCore/platform/network/HTTPHeaderNames.in 2014-06-16 19:27:46 UTC (rev 170022)
+++ trunk/Source/WebCore/platform/network/HTTPHeaderNames.in 2014-06-16 19:46:36 UTC (rev 170023)
@@ -24,6 +24,8 @@
//
Accept
+Accept-Charset
+Accept-Encoding
Access-Control-Allow-Credentials
Access-Control-Allow-Headers
Access-Control-Allow-Methods
@@ -43,10 +45,14 @@
Content-Security-Policy
Content-Security-Policy-Report-Only
Content-Type
+Content-Transfer-Encoding
Cookie
+Cookie2
Date
+DNT
Default-Style
ETag
+Expect
Expires
Host
If-Match
@@ -54,6 +60,7 @@
If-None-Match
If-Range
If-Unmodified-Since
+Keep-Alive
Last-Event-ID
Last-Modified
Location
@@ -72,9 +79,13 @@
Sec-WebSocket-Version
Set-Cookie
Set-Cookie2
+TE
Timing-Allow-Origin
+Trailer
+Transfer-Encoding
Upgrade
User-Agent
+Via
X-DNS-Prefetch-Control
X-Frame-Options
X-WebKit-CSP
Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (170022 => 170023)
--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp 2014-06-16 19:27:46 UTC (rev 170022)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp 2014-06-16 19:46:36 UTC (rev 170023)
@@ -78,59 +78,8 @@
XMLHttpRequestSendArrayBufferOrViewMax,
};
-struct XMLHttpRequestStaticData {
- WTF_MAKE_NONCOPYABLE(XMLHttpRequestStaticData); WTF_MAKE_FAST_ALLOCATED;
-public:
- XMLHttpRequestStaticData();
- const String m_proxyHeaderPrefix;
- const String m_secHeaderPrefix;
- const HashSet<String, CaseFoldingHash> m_forbiddenRequestHeaders;
-};
-
-XMLHttpRequestStaticData::XMLHttpRequestStaticData()
- : m_proxyHeaderPrefix("proxy-")
- , m_secHeaderPrefix("sec-")
- , m_forbiddenRequestHeaders({
- "accept-charset",
- "accept-encoding",
- "access-control-request-headers",
- "access-control-request-method",
- "connection",
- "content-length",
- "content-transfer-encoding",
- "cookie",
- "cookie2",
- "date",
- "dnt",
- "expect",
- "host",
- "keep-alive",
- "origin",
- "referer",
- "te",
- "trailer",
- "transfer-encoding",
- "upgrade",
- "user-agent",
- "via",
- })
+static bool isSetCookieHeader(const String& name)
{
-}
-
-static const XMLHttpRequestStaticData& staticData()
-{
- static std::once_flag onceFlag;
- static LazyNeverDestroyed<XMLHttpRequestStaticData> staticData;
-
- std::call_once(onceFlag, [] {
- staticData.construct();
- });
-
- return staticData;
-}
-
-static bool isSetCookieHeader(const AtomicString& name)
-{
return equalIgnoringCase(name, "set-cookie") || equalIgnoringCase(name, "set-cookie2");
}
@@ -457,10 +406,54 @@
return method;
}
+static bool isForbiddenRequestHeader(const String& name)
+{
+ HTTPHeaderName headerName;
+ if (!findHTTPHeaderName(name, headerName))
+ return false;
+
+ switch (headerName) {
+ case HTTPHeaderName::AcceptCharset:
+ case HTTPHeaderName::AcceptEncoding:
+ case HTTPHeaderName::AccessControlRequestHeaders:
+ case HTTPHeaderName::AccessControlRequestMethod:
+ case HTTPHeaderName::Connection:
+ case HTTPHeaderName::ContentLength:
+ case HTTPHeaderName::ContentTransferEncoding:
+ case HTTPHeaderName::Cookie:
+ case HTTPHeaderName::Cookie2:
+ case HTTPHeaderName::Date:
+ case HTTPHeaderName::DNT:
+ case HTTPHeaderName::Expect:
+ case HTTPHeaderName::Host:
+ case HTTPHeaderName::KeepAlive:
+ case HTTPHeaderName::Origin:
+ case HTTPHeaderName::Referer:
+ case HTTPHeaderName::TE:
+ case HTTPHeaderName::Trailer:
+ case HTTPHeaderName::TransferEncoding:
+ case HTTPHeaderName::Upgrade:
+ case HTTPHeaderName::UserAgent:
+ case HTTPHeaderName::Via:
+ return true;
+
+ default:
+ return false;
+ }
+}
+
bool XMLHttpRequest::isAllowedHTTPHeader(const String& name)
{
- return !staticData().m_forbiddenRequestHeaders.contains(name) && !name.startsWith(staticData().m_proxyHeaderPrefix, false)
- && !name.startsWith(staticData().m_secHeaderPrefix, false);
+ if (isForbiddenRequestHeader(name))
+ return false;
+
+ if (name.startsWith("proxy-", false))
+ return false;
+
+ if (name.startsWith("sec-", false))
+ return false;
+
+ return true;
}
void XMLHttpRequest::open(const String& method, const URL& url, ExceptionCode& ec)