Title: [206901] trunk/Source/WebCore
Revision
206901
Author
[email protected]
Date
2016-10-06 23:01:24 -0700 (Thu, 06 Oct 2016)

Log Message

Add a place for common HTTP Header values
https://bugs.webkit.org/show_bug.cgi?id=163002

Patch by Youenn Fablet <[email protected]> on 2016-10-06
Reviewed by Alex Christensen.

No change of behavior.

Introducing HTTPHeaderValues with two Content-Type values.

* CMakeLists.txt:
* Modules/fetch/FetchBody.cpp:
(WebCore::FetchBody::extract):
* WebCore.xcodeproj/project.pbxproj:
* platform/network/HTTPHeaderValues.cpp: Added.
(WebCore::HTTPHeaderValues::TextPlainContentType):
(WebCore::HTTPHeaderValues::FormURLEncodedContentType):
* platform/network/HTTPHeaderValues.h: Added.
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::send):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (206900 => 206901)


--- trunk/Source/WebCore/CMakeLists.txt	2016-10-07 06:00:10 UTC (rev 206900)
+++ trunk/Source/WebCore/CMakeLists.txt	2016-10-07 06:01:24 UTC (rev 206901)
@@ -2343,6 +2343,7 @@
     platform/network/FormData.cpp
     platform/network/FormDataBuilder.cpp
     platform/network/HTTPHeaderMap.cpp
+    platform/network/HTTPHeaderValues.cpp
     platform/network/HTTPParsers.cpp
     platform/network/MIMEHeader.cpp
     platform/network/NetworkStateNotifier.cpp

Modified: trunk/Source/WebCore/ChangeLog (206900 => 206901)


--- trunk/Source/WebCore/ChangeLog	2016-10-07 06:00:10 UTC (rev 206900)
+++ trunk/Source/WebCore/ChangeLog	2016-10-07 06:01:24 UTC (rev 206901)
@@ -1,5 +1,27 @@
 2016-10-06  Youenn Fablet  <[email protected]>
 
+        Add a place for common HTTP Header values
+        https://bugs.webkit.org/show_bug.cgi?id=163002
+
+        Reviewed by Alex Christensen.
+
+        No change of behavior.
+
+        Introducing HTTPHeaderValues with two Content-Type values.
+
+        * CMakeLists.txt:
+        * Modules/fetch/FetchBody.cpp:
+        (WebCore::FetchBody::extract):
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/network/HTTPHeaderValues.cpp: Added.
+        (WebCore::HTTPHeaderValues::TextPlainContentType):
+        (WebCore::HTTPHeaderValues::FormURLEncodedContentType):
+        * platform/network/HTTPHeaderValues.h: Added.
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::send):
+
+2016-10-06  Youenn Fablet  <[email protected]>
+
         CachedResourceRequest should not need to store defer and preload options
         https://bugs.webkit.org/show_bug.cgi?id=163004
 

Modified: trunk/Source/WebCore/Modules/fetch/FetchBody.cpp (206900 => 206901)


--- trunk/Source/WebCore/Modules/fetch/FetchBody.cpp	2016-10-07 06:00:10 UTC (rev 206900)
+++ trunk/Source/WebCore/Modules/fetch/FetchBody.cpp	2016-10-07 06:01:24 UTC (rev 206901)
@@ -37,6 +37,7 @@
 #include "FetchHeaders.h"
 #include "FetchResponseSource.h"
 #include "FormData.h"
+#include "HTTPHeaderValues.h"
 #include "HTTPParsers.h"
 #include "JSBlob.h"
 #include "JSDOMFormData.h"
@@ -62,11 +63,11 @@
         return FetchBody(WTFMove(formData));
     }
     if (value.isString()) {
-        contentType = ASCIILiteral("text/plain;charset=UTF-8");
+        contentType = HTTPHeaderValues::TextPlainContentType();
         return FetchBody(value.toWTFString(&state));
     }
     if (value.inherits(JSURLSearchParams::info())) {
-        contentType = ASCIILiteral("application/x-www-form-urlencoded;charset=UTF-8");
+        contentType = HTTPHeaderValues::FormURLEncodedContentType();
         return FetchBody(*JSURLSearchParams::toWrapped(value));
     }
     if (value.inherits(JSReadableStream::info()))

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (206900 => 206901)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-10-07 06:00:10 UTC (rev 206900)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-10-07 06:01:24 UTC (rev 206901)
@@ -1520,6 +1520,8 @@
 		4150F9F212B6E0E70008C860 /* SliderThumbElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4150F9F012B6E0E70008C860 /* SliderThumbElement.cpp */; };
 		4157AF8012F1FB0400A8C6F5 /* MediaControlsApple.h in Headers */ = {isa = PBXBuildFile; fileRef = 4157AF7E12F1FB0400A8C6F5 /* MediaControlsApple.h */; };
 		4157AF8112F1FB0400A8C6F5 /* MediaControlsApple.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4157AF7F12F1FB0400A8C6F5 /* MediaControlsApple.cpp */; };
+		41614A781DA6423B004AD06F /* HTTPHeaderValues.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41614A761DA64236004AD06F /* HTTPHeaderValues.cpp */; };
+		41614A791DA64241004AD06F /* HTTPHeaderValues.h in Headers */ = {isa = PBXBuildFile; fileRef = 41614A771DA64236004AD06F /* HTTPHeaderValues.h */; };
 		4162A450101145AE00DFF3ED /* DedicatedWorkerGlobalScope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4162A44D101145AE00DFF3ED /* DedicatedWorkerGlobalScope.cpp */; };
 		4162A451101145AE00DFF3ED /* DedicatedWorkerGlobalScope.h in Headers */ = {isa = PBXBuildFile; fileRef = 4162A44E101145AE00DFF3ED /* DedicatedWorkerGlobalScope.h */; };
 		4162A454101145E300DFF3ED /* JSDedicatedWorkerGlobalScopeCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4162A453101145E300DFF3ED /* JSDedicatedWorkerGlobalScopeCustom.cpp */; };
@@ -8467,6 +8469,8 @@
 		4150F9F012B6E0E70008C860 /* SliderThumbElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SliderThumbElement.cpp; sourceTree = "<group>"; };
 		4157AF7E12F1FB0400A8C6F5 /* MediaControlsApple.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaControlsApple.h; sourceTree = "<group>"; };
 		4157AF7F12F1FB0400A8C6F5 /* MediaControlsApple.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaControlsApple.cpp; sourceTree = "<group>"; };
+		41614A761DA64236004AD06F /* HTTPHeaderValues.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTTPHeaderValues.cpp; sourceTree = "<group>"; };
+		41614A771DA64236004AD06F /* HTTPHeaderValues.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPHeaderValues.h; sourceTree = "<group>"; };
 		4162A44D101145AE00DFF3ED /* DedicatedWorkerGlobalScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DedicatedWorkerGlobalScope.cpp; sourceTree = "<group>"; };
 		4162A44E101145AE00DFF3ED /* DedicatedWorkerGlobalScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DedicatedWorkerGlobalScope.h; sourceTree = "<group>"; };
 		4162A44F101145AE00DFF3ED /* DedicatedWorkerGlobalScope.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DedicatedWorkerGlobalScope.idl; sourceTree = "<group>"; };
@@ -17042,6 +17046,8 @@
 				0B8C56D30F28627F000502E1 /* HTTPHeaderMap.cpp */,
 				514C765C0CE923A1007EF3CD /* HTTPHeaderMap.h */,
 				1AC900BF1943AF3D008625B5 /* HTTPHeaderNames.in */,
+				41614A761DA64236004AD06F /* HTTPHeaderValues.cpp */,
+				41614A771DA64236004AD06F /* HTTPHeaderValues.h */,
 				514C765D0CE923A1007EF3CD /* HTTPParsers.cpp */,
 				514C765E0CE923A1007EF3CD /* HTTPParsers.h */,
 				37DDCD9213844FD50008B793 /* MIMEHeader.cpp */,
@@ -27132,6 +27138,7 @@
 				976D6C7C122B8A3D001FD1F7 /* WebKitBlobBuilder.h in Headers */,
 				3106037014327D2E00ABF4BA /* WebKitCSSFilterValue.h in Headers */,
 				498391590F1E776900C23782 /* WebKitCSSMatrix.h in Headers */,
+				41614A791DA64241004AD06F /* HTTPHeaderValues.h in Headers */,
 				8AA61D00144D595B00F37350 /* WebKitCSSRegionRule.h in Headers */,
 				BC9ADD230CC4032600098C4C /* WebKitCSSTransformValue.h in Headers */,
 				3FFFF9A9159D9A550020BBD5 /* WebKitCSSViewportRule.h in Headers */,
@@ -30609,6 +30616,7 @@
 				E453904D0EAFD637003695C8 /* WidgetIOS.mm in Sources */,
 				9380F47809A11ACC001FDB34 /* WidgetMac.mm in Sources */,
 				939B02EE0EA2DBC400C54570 /* WidthIterator.cpp in Sources */,
+				41614A781DA6423B004AD06F /* HTTPHeaderValues.cpp in Sources */,
 				0F15ED5B1B7EC7C500EDDFEB /* WillChangeData.cpp in Sources */,
 				BC8243E80D0CFD7500460C8F /* WindowFeatures.cpp in Sources */,
 				7E99AF510B13846468FB01A5 /* WindowFocusAllowedIndicator.cpp in Sources */,

Added: trunk/Source/WebCore/platform/network/HTTPHeaderValues.cpp (0 => 206901)


--- trunk/Source/WebCore/platform/network/HTTPHeaderValues.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/network/HTTPHeaderValues.cpp	2016-10-07 06:01:24 UTC (rev 206901)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "HTTPHeaderValues.h"
+
+#include <wtf/NeverDestroyed.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+const String& HTTPHeaderValues::TextPlainContentType()
+{
+    static NeverDestroyed<const String> contentType(ASCIILiteral("text/plain;charset=UTF-8"));
+    return contentType;
+}
+
+const String& HTTPHeaderValues::FormURLEncodedContentType()
+{
+    static NeverDestroyed<const String> contentType(ASCIILiteral("application/x-www-form-urlencoded;charset=UTF-8"));
+    return contentType;
+}
+
+}

Added: trunk/Source/WebCore/platform/network/HTTPHeaderValues.h (0 => 206901)


--- trunk/Source/WebCore/platform/network/HTTPHeaderValues.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/network/HTTPHeaderValues.h	2016-10-07 06:01:24 UTC (rev 206901)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/Forward.h>
+
+namespace WebCore {
+
+struct HTTPHeaderValues {
+    static const String& TextPlainContentType();
+    static const String& FormURLEncodedContentType();
+};
+
+}

Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (206900 => 206901)


--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp	2016-10-07 06:00:10 UTC (rev 206900)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp	2016-10-07 06:01:24 UTC (rev 206901)
@@ -34,6 +34,7 @@
 #include "File.h"
 #include "HTMLDocument.h"
 #include "HTTPHeaderNames.h"
+#include "HTTPHeaderValues.h"
 #include "HTTPParsers.h"
 #include "InspectorInstrumentation.h"
 #include "JSDOMBinding.h"
@@ -566,7 +567,7 @@
                 m_requestHeaders.set(HTTPHeaderName::ContentType, ASCIILiteral("application/x-www-form-urlencoded"));
             else
 #endif
-                m_requestHeaders.set(HTTPHeaderName::ContentType, ASCIILiteral("text/plain;charset=UTF-8"));
+                m_requestHeaders.set(HTTPHeaderName::ContentType, HTTPHeaderValues::TextPlainContentType());
         } else {
             replaceCharsetInMediaType(contentType, "UTF-8");
             m_requestHeaders.set(HTTPHeaderName::ContentType, contentType);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to