Make better use of HTTPHeaderValues constants
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Jan 2020 11:25:53 +0000 (11:25 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Jan 2020 11:25:53 +0000 (11:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=205672

Patch by Rob Buis <rbuis@igalia.com> on 2020-01-01
Reviewed by Youenn Fablet.

Use HTTPHeaderValues constants instead of allocating
temporary strings.

* Modules/websockets/ThreadableWebSocketChannel.cpp:
(WebCore::ThreadableWebSocketChannel::webSocketConnectRequest):
* Modules/websockets/WebSocketHandshake.cpp:
(WebCore::WebSocketHandshake::clientHandshakeRequest const):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::addExtraFieldsToRequest):
* loader/PingLoader.cpp:
(WebCore::PingLoader::loadImage):
(WebCore::PingLoader::sendPing):
* loader/appcache/ApplicationCacheGroup.cpp:
(WebCore::ApplicationCacheGroup::createRequest):
* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::load):

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

Source/WebCore/ChangeLog
Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp
Source/WebCore/Modules/websockets/WebSocketHandshake.cpp
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/PingLoader.cpp
Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp
Source/WebCore/loader/cache/CachedResource.cpp

index 2a19c0e..4e5c36f 100644 (file)
@@ -1,3 +1,27 @@
+2020-01-01  Rob Buis  <rbuis@igalia.com>
+
+        Make better use of HTTPHeaderValues constants
+        https://bugs.webkit.org/show_bug.cgi?id=205672
+
+        Reviewed by Youenn Fablet.
+
+        Use HTTPHeaderValues constants instead of allocating
+        temporary strings.
+
+        * Modules/websockets/ThreadableWebSocketChannel.cpp:
+        (WebCore::ThreadableWebSocketChannel::webSocketConnectRequest):
+        * Modules/websockets/WebSocketHandshake.cpp:
+        (WebCore::WebSocketHandshake::clientHandshakeRequest const):
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::addExtraFieldsToRequest):
+        * loader/PingLoader.cpp:
+        (WebCore::PingLoader::loadImage):
+        (WebCore::PingLoader::sendPing):
+        * loader/appcache/ApplicationCacheGroup.cpp:
+        (WebCore::ApplicationCacheGroup::createRequest):
+        * loader/cache/CachedResource.cpp:
+        (WebCore::CachedResource::load):
+
 2019-12-31  Peng Liu  <peng.liu6@apple.com>
 
         Add remote media resource loader for the GPU process
index 43d38a9..fb6d885 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "ContentRuleListResults.h"
 #include "Document.h"
+#include "HTTPHeaderValues.h"
 #include "Page.h"
 #include "RuntimeEnabledFeatures.h"
 #include "ScriptExecutionContext.h"
@@ -117,8 +118,8 @@ Optional<ResourceRequest> ThreadableWebSocketChannel::webSocketConnectRequest(Do
     // There are some proxies that rewrite "Connection: upgrade"
     // to "Connection: close" in the response if a request doesn't contain
     // these headers.
-    request.addHTTPHeaderField(HTTPHeaderName::Pragma, "no-cache");
-    request.addHTTPHeaderField(HTTPHeaderName::CacheControl, "no-cache");
+    request.addHTTPHeaderField(HTTPHeaderName::Pragma, HTTPHeaderValues::noCache());
+    request.addHTTPHeaderField(HTTPHeaderName::CacheControl, HTTPHeaderValues::noCache());
 
     return request;
 }
index 4240b95..9926cef 100644 (file)
@@ -37,6 +37,7 @@
 #include "CookieJar.h"
 #include "HTTPHeaderMap.h"
 #include "HTTPHeaderNames.h"
+#include "HTTPHeaderValues.h"
 #include "HTTPParsers.h"
 #include "InspectorInstrumentation.h"
 #include "Logging.h"
@@ -238,8 +239,8 @@ ResourceRequest WebSocketHandshake::clientHandshakeRequest(Function<String(const
             request.setHTTPHeaderField(HTTPHeaderName::Cookie, cookie);
     }
 
-    request.setHTTPHeaderField(HTTPHeaderName::Pragma, "no-cache");
-    request.setHTTPHeaderField(HTTPHeaderName::CacheControl, "no-cache");
+    request.setHTTPHeaderField(HTTPHeaderName::Pragma, HTTPHeaderValues::noCache());
+    request.setHTTPHeaderField(HTTPHeaderName::CacheControl, HTTPHeaderValues::noCache());
 
     request.setHTTPHeaderField(HTTPHeaderName::SecWebSocketKey, m_secWebSocketKey);
     request.setHTTPHeaderField(HTTPHeaderName::SecWebSocketVersion, "13");
index 22eb8d0..9a72b90 100644 (file)
@@ -77,6 +77,7 @@
 #include "HTMLObjectElement.h"
 #include "HTMLParserIdioms.h"
 #include "HTTPHeaderNames.h"
+#include "HTTPHeaderValues.h"
 #include "HTTPParsers.h"
 #include "HistoryController.h"
 #include "HistoryItem.h"
@@ -2947,10 +2948,10 @@ void FrameLoader::addExtraFieldsToRequest(ResourceRequest& request, FrameLoadTyp
 
     if (!hasSpecificCachePolicy && request.cachePolicy() == ResourceRequestCachePolicy::ReloadIgnoringCacheData) {
         if (loadType == FrameLoadType::Reload)
-            request.setHTTPHeaderField(HTTPHeaderName::CacheControl, "max-age=0");
+            request.setHTTPHeaderField(HTTPHeaderName::CacheControl, HTTPHeaderValues::maxAge0());
         else if (loadType == FrameLoadType::ReloadFromOrigin) {
-            request.setHTTPHeaderField(HTTPHeaderName::CacheControl, "no-cache");
-            request.setHTTPHeaderField(HTTPHeaderName::Pragma, "no-cache");
+            request.setHTTPHeaderField(HTTPHeaderName::CacheControl, HTTPHeaderValues::noCache());
+            request.setHTTPHeaderField(HTTPHeaderName::Pragma, HTTPHeaderValues::noCache());
         }
     }
 
index 050e2ad..9f17976 100644 (file)
@@ -42,6 +42,7 @@
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "FrameLoaderClient.h"
+#include "HTTPHeaderValues.h"
 #include "InspectorInstrumentation.h"
 #include "LoaderStrategy.h"
 #include "NetworkLoadMetrics.h"
@@ -97,7 +98,7 @@ void PingLoader::loadImage(Frame& frame, const URL& url)
 
     document.contentSecurityPolicy()->upgradeInsecureRequestIfNeeded(request, ContentSecurityPolicy::InsecureRequestType::Load);
 
-    request.setHTTPHeaderField(HTTPHeaderName::CacheControl, "max-age=0");
+    request.setHTTPHeaderField(HTTPHeaderName::CacheControl, HTTPHeaderValues::maxAge0());
 
     HTTPHeaderMap originalRequestHeader = request.httpHeaderFields();
 
@@ -129,7 +130,7 @@ void PingLoader::sendPing(Frame& frame, const URL& pingURL, const URL& destinati
     request.setHTTPMethod("POST");
     request.setHTTPContentType("text/ping");
     request.setHTTPBody(FormData::create("PING"));
-    request.setHTTPHeaderField(HTTPHeaderName::CacheControl, "max-age=0");
+    request.setHTTPHeaderField(HTTPHeaderName::CacheControl, HTTPHeaderValues::maxAge0());
 
     HTTPHeaderMap originalRequestHeader = request.httpHeaderFields();
 
index 044d7c8..60c24bf 100644 (file)
@@ -40,6 +40,7 @@
 #include "FrameLoader.h"
 #include "FrameLoaderClient.h"
 #include "HTTPHeaderNames.h"
+#include "HTTPHeaderValues.h"
 #include "InspectorInstrumentation.h"
 #include "ManifestParser.h"
 #include "NavigationScheduler.h"
@@ -463,7 +464,7 @@ ResourceRequest ApplicationCacheGroup::createRequest(URL&& url, ApplicationCache
 {
     ResourceRequest request { WTFMove(url) };
     m_frame->loader().applyUserAgentIfNeeded(request);
-    request.setHTTPHeaderField(HTTPHeaderName::CacheControl, "max-age=0");
+    request.setHTTPHeaderField(HTTPHeaderName::CacheControl, HTTPHeaderValues::maxAge0());
 
     if (resource) {
         const String& lastModified = resource->response().httpHeaderField(HTTPHeaderName::LastModified);
index 696ad8b..fc9cbbc 100644 (file)
@@ -38,6 +38,7 @@
 #include "FrameLoader.h"
 #include "FrameLoaderClient.h"
 #include "HTTPHeaderNames.h"
+#include "HTTPHeaderValues.h"
 #include "InspectorInstrumentation.h"
 #include "LegacySchemeRegistry.h"
 #include "LoaderStrategy.h"
@@ -244,7 +245,7 @@ void CachedResource::load(CachedResourceLoader& cachedResourceLoader)
         if (!lastModified.isEmpty() || !eTag.isEmpty()) {
             ASSERT(cachedResourceLoader.cachePolicy(type(), url()) != CachePolicyReload);
             if (cachedResourceLoader.cachePolicy(type(), url()) == CachePolicyRevalidate)
-                m_resourceRequest.setHTTPHeaderField(HTTPHeaderName::CacheControl, "max-age=0");
+                m_resourceRequest.setHTTPHeaderField(HTTPHeaderName::CacheControl, HTTPHeaderValues::maxAge0());
             if (!lastModified.isEmpty())
                 m_resourceRequest.setHTTPHeaderField(HTTPHeaderName::IfModifiedSince, lastModified);
             if (!eTag.isEmpty())