Fetch: data: URL HEAD request should result in empty response body
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Oct 2019 12:51:36 +0000 (12:51 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Oct 2019 12:51:36 +0000 (12:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=175764

Patch by Rob Buis <rbuis@igalia.com> on 2019-10-08
Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

Update improved test results.

* web-platform-tests/fetch/api/basic/scheme-data.any.js:
* web-platform-tests/xhr/data-uri-expected.txt:

Source/WebCore:

Do not build the response body for HEAD requests for data urls:
https://fetch.spec.whatwg.org/#concept-main-fetch (Step 13)

Tests: imported/web-platform-tests/fetch/api/basic/scheme-data.any.js
       imported/web-platform-tests/xhr/data-uri.html

* loader/ResourceLoader.cpp:
(WebCore::ResourceLoader::loadDataURL):

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

LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-data.any.js
LayoutTests/imported/w3c/web-platform-tests/xhr/data-uri-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/loader/ResourceLoader.cpp

index 75e4f53..564f693 100644 (file)
@@ -1,3 +1,15 @@
+2019-10-08  Rob Buis  <rbuis@igalia.com>
+
+        Fetch: data: URL HEAD request should result in empty response body
+        https://bugs.webkit.org/show_bug.cgi?id=175764
+
+        Reviewed by Youenn Fablet.
+
+        Update improved test results.
+
+        * web-platform-tests/fetch/api/basic/scheme-data.any.js:
+        * web-platform-tests/xhr/data-uri-expected.txt:
+
 2019-10-08  Antti Koivisto  <antti@apple.com>
 
         [CSS Shadow Parts] Implement style invalidation
index b1d6741..2ff2545 100644 (file)
@@ -29,7 +29,7 @@ checkFetchResponse("data:image/png;base64,cmVzcG9uc2UncyBib2R5",
                    "response's body",
                    "image/png");
 checkFetchResponse("data:,response%27s%20body", "response's body", "text/plain;charset=US-ASCII", null, "POST");
-checkFetchResponse("data:,response%27s%20body", "response's body", "text/plain;charset=US-ASCII", null, "HEAD");
+checkFetchResponse("data:,response%27s%20body", "", "text/plain;charset=US-ASCII", null, "HEAD");
 
 function checkKoUrl(url, method, desc) {
   var cut = (url.length >= 40) ? "[...]" : "";
index d53f483..659d84c 100644 (file)
@@ -7,6 +7,6 @@ PASS XHR method GET with MIME type image/png
 PASS XHR method POST with MIME type text/plain 
 PASS XHR method PUT with MIME type text/plain 
 PASS XHR method DELETE with MIME type text/plain 
-FAIL XHR method HEAD with MIME type text/plain assert_equals: expected "" but got "Hello, World!"
+PASS XHR method HEAD with MIME type text/plain 
 PASS XHR method UNICORN with MIME type text/plain 
 
index 2d0d99a..3bc2a64 100644 (file)
@@ -1,3 +1,19 @@
+2019-10-08  Rob Buis  <rbuis@igalia.com>
+
+        Fetch: data: URL HEAD request should result in empty response body
+        https://bugs.webkit.org/show_bug.cgi?id=175764
+
+        Reviewed by Youenn Fablet.
+
+        Do not build the response body for HEAD requests for data urls:
+        https://fetch.spec.whatwg.org/#concept-main-fetch (Step 13)
+
+        Tests: imported/web-platform-tests/fetch/api/basic/scheme-data.any.js
+               imported/web-platform-tests/xhr/data-uri.html
+
+        * loader/ResourceLoader.cpp:
+        (WebCore::ResourceLoader::loadDataURL):
+
 2019-10-08  Antti Koivisto  <antti@apple.com>
 
         [CSS Shadow Parts] Implement style invalidation
index c66e789..e3e2629 100644 (file)
@@ -285,7 +285,7 @@ void ResourceLoader::loadDataURL()
         dataResponse.setHTTPHeaderField(HTTPHeaderName::ContentType, result.contentType);
         dataResponse.setSource(ResourceResponse::Source::Network);
         this->didReceiveResponse(dataResponse, [this, protectedThis = WTFMove(protectedThis), dataSize, data = result.data.releaseNonNull()]() mutable {
-            if (!this->reachedTerminalState() && dataSize)
+            if (!this->reachedTerminalState() && dataSize && m_request.httpMethod() != "HEAD")
                 this->didReceiveBuffer(WTFMove(data), dataSize, DataPayloadWholeResource);
 
             if (!this->reachedTerminalState()) {