Title: [262776] trunk
Revision
262776
Author
[email protected]
Date
2020-06-08 23:44:48 -0700 (Mon, 08 Jun 2020)

Log Message

XMLHTTPRequest.send should not send Content-Type headers when Blob has no type
https://bugs.webkit.org/show_bug.cgi?id=211999

Patch by Rob Buis <[email protected]> on 2020-06-08
Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

Update improved test expectation.

* web-platform-tests/xhr/send-blob-with-no-mime-type-expected.txt:

Source/WebCore:

XMLHTTPRequest.send should not send Content-Type headers when Blob has no type [1, 2].
This behavior overrides the behavior of the File API spec [3].

Behavior matches Firefox and Chrome.

Test: imported/w3c/web-platform-tests/xhr/send-blob-with-no-mime-type.html

[1] https://xhr.spec.whatwg.org/#dom-xmlhttprequest-send
[2] https://fetch.spec.whatwg.org/#concept-bodyinit-extract
[3] http://dev.w3.org/2006/webapi/FileAPI/#dfn-type

* platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm:
(-[WebCoreResourceHandleAsOperationQueueDelegate connection:willSendRequest:redirectResponse:]):
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::send):

LayoutTests:

Remove unneeded expectations.

* platform/ios/imported/w3c/web-platform-tests/xhr/send-blob-with-no-mime-type-expected.txt: Removed.
* platform/mac/imported/w3c/web-platform-tests/xhr/send-blob-with-no-mime-type-expected.txt: Removed.

Modified Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (262775 => 262776)


--- trunk/LayoutTests/ChangeLog	2020-06-09 05:37:19 UTC (rev 262775)
+++ trunk/LayoutTests/ChangeLog	2020-06-09 06:44:48 UTC (rev 262776)
@@ -1,3 +1,15 @@
+2020-06-08  Rob Buis  <[email protected]>
+
+        XMLHTTPRequest.send should not send Content-Type headers when Blob has no type
+        https://bugs.webkit.org/show_bug.cgi?id=211999
+
+        Reviewed by Alex Christensen.
+
+        Remove unneeded expectations.
+
+        * platform/ios/imported/w3c/web-platform-tests/xhr/send-blob-with-no-mime-type-expected.txt: Removed.
+        * platform/mac/imported/w3c/web-platform-tests/xhr/send-blob-with-no-mime-type-expected.txt: Removed.
+
 2020-06-08  Simon Fraser  <[email protected]>
 
         Horizontally scrolling elements are broken when revealed by toggling visibility

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (262775 => 262776)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-06-09 05:37:19 UTC (rev 262775)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-06-09 06:44:48 UTC (rev 262776)
@@ -1,3 +1,14 @@
+2020-06-08  Rob Buis  <[email protected]>
+
+        XMLHTTPRequest.send should not send Content-Type headers when Blob has no type
+        https://bugs.webkit.org/show_bug.cgi?id=211999
+
+        Reviewed by Alex Christensen.
+
+        Update improved test expectation.
+
+        * web-platform-tests/xhr/send-blob-with-no-mime-type-expected.txt:
+
 2020-06-05  Sergio Villar Senin  <[email protected]>
 
         [WebXR] Add missing interfaces from the AR module

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/xhr/send-blob-with-no-mime-type-expected.txt (262775 => 262776)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/xhr/send-blob-with-no-mime-type-expected.txt	2020-06-09 05:37:19 UTC (rev 262775)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/xhr/send-blob-with-no-mime-type-expected.txt	2020-06-09 06:44:48 UTC (rev 262776)
@@ -1,10 +1,10 @@
 
-FAIL Synchronous blob loading with no mime type [POST] assert_equals: expected "NO" but got ""
-FAIL Asynchronous blob loading with no mime type [POST] assert_equals: expected "NO" but got ""
-FAIL Synchronous blob loading with no mime type [PUT] assert_equals: expected "NO" but got ""
-FAIL Asynchronous blob loading with no mime type [PUT] assert_equals: expected "NO" but got ""
-FAIL Synchronous blob loading with invalid mime type [POST] assert_equals: expected "NO" but got ""
-FAIL Asynchronous blob loading with invalid mime type [POST] assert_equals: expected "NO" but got ""
-FAIL Synchronous blob loading with invalid mime type [PUT] assert_equals: expected "NO" but got ""
-FAIL Asynchronous blob loading with invalid mime type [PUT] assert_equals: expected "NO" but got ""
+PASS Synchronous blob loading with no mime type [POST] 
+PASS Asynchronous blob loading with no mime type [POST] 
+PASS Synchronous blob loading with no mime type [PUT] 
+PASS Asynchronous blob loading with no mime type [PUT] 
+PASS Synchronous blob loading with invalid mime type [POST] 
+PASS Asynchronous blob loading with invalid mime type [POST] 
+PASS Synchronous blob loading with invalid mime type [PUT] 
+PASS Asynchronous blob loading with invalid mime type [PUT] 
 

Deleted: trunk/LayoutTests/platform/ios/imported/w3c/web-platform-tests/xhr/send-blob-with-no-mime-type-expected.txt (262775 => 262776)


--- trunk/LayoutTests/platform/ios/imported/w3c/web-platform-tests/xhr/send-blob-with-no-mime-type-expected.txt	2020-06-09 05:37:19 UTC (rev 262775)
+++ trunk/LayoutTests/platform/ios/imported/w3c/web-platform-tests/xhr/send-blob-with-no-mime-type-expected.txt	2020-06-09 06:44:48 UTC (rev 262776)
@@ -1,10 +0,0 @@
-
-PASS Synchronous blob loading with no mime type [POST] 
-PASS Asynchronous blob loading with no mime type [POST] 
-PASS Synchronous blob loading with no mime type [PUT] 
-PASS Asynchronous blob loading with no mime type [PUT] 
-PASS Synchronous blob loading with invalid mime type [POST] 
-PASS Asynchronous blob loading with invalid mime type [POST] 
-PASS Synchronous blob loading with invalid mime type [PUT] 
-PASS Asynchronous blob loading with invalid mime type [PUT] 
-

Deleted: trunk/LayoutTests/platform/mac/imported/w3c/web-platform-tests/xhr/send-blob-with-no-mime-type-expected.txt (262775 => 262776)


--- trunk/LayoutTests/platform/mac/imported/w3c/web-platform-tests/xhr/send-blob-with-no-mime-type-expected.txt	2020-06-09 05:37:19 UTC (rev 262775)
+++ trunk/LayoutTests/platform/mac/imported/w3c/web-platform-tests/xhr/send-blob-with-no-mime-type-expected.txt	2020-06-09 06:44:48 UTC (rev 262776)
@@ -1,10 +0,0 @@
-
-FAIL Synchronous blob loading with no mime type [POST] assert_equals: expected "NO" but got ""
-FAIL Asynchronous blob loading with no mime type [POST] assert_equals: expected "NO" but got ""
-FAIL Synchronous blob loading with no mime type [PUT] assert_equals: expected "NO" but got ""
-FAIL Asynchronous blob loading with no mime type [PUT] assert_equals: expected "NO" but got ""
-FAIL Synchronous blob loading with invalid mime type [POST] assert_equals: expected "NO" but got ""
-FAIL Asynchronous blob loading with invalid mime type [POST] assert_equals: expected "NO" but got ""
-FAIL Synchronous blob loading with invalid mime type [PUT] assert_equals: expected "NO" but got ""
-FAIL Asynchronous blob loading with invalid mime type [PUT] assert_equals: expected "NO" but got ""
-

Modified: trunk/Source/WebCore/ChangeLog (262775 => 262776)


--- trunk/Source/WebCore/ChangeLog	2020-06-09 05:37:19 UTC (rev 262775)
+++ trunk/Source/WebCore/ChangeLog	2020-06-09 06:44:48 UTC (rev 262776)
@@ -1,3 +1,26 @@
+2020-06-08  Rob Buis  <[email protected]>
+
+        XMLHTTPRequest.send should not send Content-Type headers when Blob has no type
+        https://bugs.webkit.org/show_bug.cgi?id=211999
+
+        Reviewed by Alex Christensen.
+
+        XMLHTTPRequest.send should not send Content-Type headers when Blob has no type [1, 2].
+        This behavior overrides the behavior of the File API spec [3].
+
+        Behavior matches Firefox and Chrome.
+
+        Test: imported/w3c/web-platform-tests/xhr/send-blob-with-no-mime-type.html
+
+        [1] https://xhr.spec.whatwg.org/#dom-xmlhttprequest-send
+        [2] https://fetch.spec.whatwg.org/#concept-bodyinit-extract
+        [3] http://dev.w3.org/2006/webapi/FileAPI/#dfn-type
+
+        * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm:
+        (-[WebCoreResourceHandleAsOperationQueueDelegate connection:willSendRequest:redirectResponse:]):
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::send):
+
 2020-06-08  Simon Fraser  <[email protected]>
 
         Horizontally scrolling elements are broken when revealed by toggling visibility

Modified: trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm (262775 => 262776)


--- trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm	2020-06-09 05:37:19 UTC (rev 262775)
+++ trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm	2020-06-09 06:44:48 UTC (rev 262776)
@@ -121,8 +121,15 @@
     redirectResponse = synthesizeRedirectResponseIfNecessary([connection currentRequest], newRequest, redirectResponse);
 
     // See <rdar://problem/5380697>. This is a workaround for a behavior change in CFNetwork where willSendRequest gets called more often.
-    if (!redirectResponse)
+    if (!redirectResponse) {
+        // CFNetwork will add "application/x-www-form-urlencoded" content-type for POST, even if no Content-Type was specified, remove it in that case.
+        if (equalLettersIgnoringASCIICase(m_handle->firstRequest().httpMethod(), "post") && !m_handle->firstRequest().hasHTTPHeaderField(HTTPHeaderName::ContentType)) {
+            NSMutableURLRequest *modifiedRequest = [newRequest mutableCopy];
+            [modifiedRequest setValue:nil forHTTPHeaderField:@"Content-Type"];
+            return modifiedRequest;
+        }
         return newRequest;
+    }
 
 #if !LOG_DISABLED
     if ([redirectResponse isKindOfClass:[NSHTTPURLResponse class]])

Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (262775 => 262776)


--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp	2020-06-09 05:37:19 UTC (rev 262775)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp	2020-06-09 06:44:48 UTC (rev 262776)
@@ -530,10 +530,6 @@
             const String& blobType = body.type();
             if (!blobType.isEmpty() && isValidContentType(blobType))
                 m_requestHeaders.set(HTTPHeaderName::ContentType, blobType);
-            else {
-                // From FileAPI spec, whenever media type cannot be determined, empty string must be returned.
-                m_requestHeaders.set(HTTPHeaderName::ContentType, emptyString());
-            }
         }
 
         m_requestEntityBody = FormData::create();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to