Title: [291622] trunk
Revision
291622
Author
jer.no...@apple.com
Date
2022-03-22 08:45:59 -0700 (Tue, 22 Mar 2022)

Log Message

Fetching a Blob URL with an unbounded Range header do not generate a Content-Range response header
https://bugs.webkit.org/show_bug.cgi?id=238170

Reviewed by Eric Carlson.

Source/WebCore:

Test: fetch/fetch-blob-unbounded-range.html

Handle the case where the request contains an unbounded range, and property calculate the rangeEnd
to pass into ParsedContentRange.

* platform/network/BlobResourceHandle.cpp:
(WebCore::BlobResourceHandle::notifyResponseOnSuccess):

Source/WebKit:

Handle the case where the request contains an unbounded range, and property calculate the rangeEnd
to pass into ParsedContentRange.

* NetworkProcess/NetworkDataTaskBlob.cpp:
(WebKit::NetworkDataTaskBlob::dispatchDidReceiveResponse):

LayoutTests:

* fetch/fetch-blob-unbounded-range-expected.txt: Added.
* fetch/fetch-blob-unbounded-range.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (291621 => 291622)


--- trunk/LayoutTests/ChangeLog	2022-03-22 15:37:25 UTC (rev 291621)
+++ trunk/LayoutTests/ChangeLog	2022-03-22 15:45:59 UTC (rev 291622)
@@ -1,3 +1,13 @@
+2022-03-22  Jer Noble  <jer.no...@apple.com>
+
+        Fetching a Blob URL with an unbounded Range header do not generate a Content-Range response header
+        https://bugs.webkit.org/show_bug.cgi?id=238170
+
+        Reviewed by Eric Carlson.
+
+        * fetch/fetch-blob-unbounded-range-expected.txt: Added.
+        * fetch/fetch-blob-unbounded-range.html: Added.
+
 2022-03-22  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [GTK][WPE] Remove the ATK implementation

Added: trunk/LayoutTests/fetch/fetch-blob-unbounded-range-expected.txt (0 => 291622)


--- trunk/LayoutTests/fetch/fetch-blob-unbounded-range-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fetch/fetch-blob-unbounded-range-expected.txt	2022-03-22 15:45:59 UTC (rev 291622)
@@ -0,0 +1,4 @@
+
+PASS Bounded range request
+PASS Unbounded range request
+

Added: trunk/LayoutTests/fetch/fetch-blob-unbounded-range.html (0 => 291622)


--- trunk/LayoutTests/fetch/fetch-blob-unbounded-range.html	                        (rev 0)
+++ trunk/LayoutTests/fetch/fetch-blob-unbounded-range.html	2022-03-22 15:45:59 UTC (rev 291622)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<script src=''></script>
+<script src=''></script>
+<script>
+
+let buffer = Uint8Array.from([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
+let blob = new Blob([buffer]);
+let blobURL = URL.createObjectURL(blob);
+
+promise_test(async () => {
+    let response = await fetch(blobURL, {headers: new Headers({'Range': 'bytes=0-1'})});
+    assert_equals(response.status, 206);
+    assert_equals(response.headers.get('Content-Length'), '2');
+    assert_equals(response.headers.get('Content-Range'), 'bytes 0-1/10');
+}, "Bounded range request");
+
+promise_test(async () => {
+    let response = await fetch(blobURL, {headers: new Headers({'Range': 'bytes=8-'})});
+    assert_equals(response.status, 206);
+    assert_equals(response.headers.get('Content-Length'), '2');
+    assert_equals(response.headers.get('Content-Range'), 'bytes 8-9/10');
+}, "Unbounded range request");
+
+</script>

Modified: trunk/Source/WebCore/ChangeLog (291621 => 291622)


--- trunk/Source/WebCore/ChangeLog	2022-03-22 15:37:25 UTC (rev 291621)
+++ trunk/Source/WebCore/ChangeLog	2022-03-22 15:45:59 UTC (rev 291622)
@@ -1,3 +1,18 @@
+2022-03-22  Jer Noble  <jer.no...@apple.com>
+
+        Fetching a Blob URL with an unbounded Range header do not generate a Content-Range response header
+        https://bugs.webkit.org/show_bug.cgi?id=238170
+
+        Reviewed by Eric Carlson.
+
+        Test: fetch/fetch-blob-unbounded-range.html
+
+        Handle the case where the request contains an unbounded range, and property calculate the rangeEnd
+        to pass into ParsedContentRange.
+
+        * platform/network/BlobResourceHandle.cpp:
+        (WebCore::BlobResourceHandle::notifyResponseOnSuccess):
+
 2022-03-22  Zan Dobersek  <zdober...@igalia.com>
 
         Move TextureMapper member variables, types and code out of GraphicsContextGLANGLE

Modified: trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp (291621 => 291622)


--- trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp	2022-03-22 15:37:25 UTC (rev 291621)
+++ trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp	2022-03-22 15:45:59 UTC (rev 291622)
@@ -579,8 +579,13 @@
     addCrossOriginOpenerPolicyHeaders(response, m_blobData->policyContainer().crossOriginOpenerPolicy);
     addCrossOriginEmbedderPolicyHeaders(response, m_blobData->policyContainer().crossOriginEmbedderPolicy);
 
-    if (isRangeRequest)
-        response.setHTTPHeaderField(HTTPHeaderName::ContentRange, ParsedContentRange(m_rangeOffset, m_rangeEnd, m_totalSize).headerValue());
+    if (isRangeRequest) {
+        auto rangeEnd = m_rangeEnd;
+        if (rangeEnd == kPositionNotSpecified)
+            rangeEnd = m_totalSize - 1;
+
+        response.setHTTPHeaderField(HTTPHeaderName::ContentRange, ParsedContentRange(m_rangeOffset, rangeEnd, m_totalSize).headerValue());
+    }
     // FIXME: If a resource identified with a blob: URL is a File object, user agents must use that file's name attribute,
     // as if the response had a Content-Disposition header with the filename parameter set to the File's name attribute.
     // Notably, this will affect a name suggested in "File Save As".

Modified: trunk/Source/WebKit/ChangeLog (291621 => 291622)


--- trunk/Source/WebKit/ChangeLog	2022-03-22 15:37:25 UTC (rev 291621)
+++ trunk/Source/WebKit/ChangeLog	2022-03-22 15:45:59 UTC (rev 291622)
@@ -1,3 +1,16 @@
+2022-03-22  Jer Noble  <jer.no...@apple.com>
+
+        Fetching a Blob URL with an unbounded Range header do not generate a Content-Range response header
+        https://bugs.webkit.org/show_bug.cgi?id=238170
+
+        Reviewed by Eric Carlson.
+
+        Handle the case where the request contains an unbounded range, and property calculate the rangeEnd
+        to pass into ParsedContentRange.
+
+        * NetworkProcess/NetworkDataTaskBlob.cpp:
+        (WebKit::NetworkDataTaskBlob::dispatchDidReceiveResponse):
+
 2022-03-22  Miguel Gomez  <mago...@igalia.com>
 
         Ensure that proxies are invalidated before destroying them.

Modified: trunk/Source/WebKit/NetworkProcess/NetworkDataTaskBlob.cpp (291621 => 291622)


--- trunk/Source/WebKit/NetworkProcess/NetworkDataTaskBlob.cpp	2022-03-22 15:37:25 UTC (rev 291621)
+++ trunk/Source/WebKit/NetworkProcess/NetworkDataTaskBlob.cpp	2022-03-22 15:45:59 UTC (rev 291622)
@@ -270,8 +270,13 @@
         addCrossOriginOpenerPolicyHeaders(response, m_blobData->policyContainer().crossOriginOpenerPolicy);
         addCrossOriginEmbedderPolicyHeaders(response, m_blobData->policyContainer().crossOriginEmbedderPolicy);
 
-        if (isRangeRequest)
-            response.setHTTPHeaderField(HTTPHeaderName::ContentRange, ParsedContentRange(m_rangeOffset, m_rangeEnd, m_totalSize).headerValue());
+        if (isRangeRequest) {
+            auto rangeEnd = m_rangeEnd;
+            if (rangeEnd == kPositionNotSpecified)
+                rangeEnd = m_totalSize - 1;
+
+            response.setHTTPHeaderField(HTTPHeaderName::ContentRange, ParsedContentRange(m_rangeOffset, rangeEnd, m_totalSize).headerValue());
+        }
         // FIXME: If a resource identified with a blob: URL is a File object, user agents must use that file's name attribute,
         // as if the response had a Content-Disposition header with the filename parameter set to the File's name attribute.
         // Notably, this will affect a name suggested in "File Save As".
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to