Add Content Range Header and add one for blob end range (#34797)

Signed-off-by: rayguo17 <rayguo17@gmail.com>
This commit is contained in:
TIN TUN AUNG 2025-01-14 08:21:29 +08:00 committed by GitHub
parent faf30176f1
commit 55ac1887dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 75 additions and 95 deletions

View file

@ -1,18 +1,18 @@
[blob.any.html]
[A simple blob range request.]
expected: FAIL
expected: PASS
[A blob range request with no end.]
expected: FAIL
expected: PASS
[A blob range request with no start.]
expected: FAIL
expected: PASS
[A simple blob range request with whitespace.]
expected: FAIL
expected: PASS
[Blob content with short content and a large range end]
expected: FAIL
expected: PASS
[Blob range with whitespace before and after hyphen]
expected: FAIL
@ -60,7 +60,7 @@
expected: FAIL
[Blob content with short content and a range end matching content length]
expected: FAIL
expected: PASS
[Blob range with no value]
expected: FAIL
@ -83,19 +83,19 @@
[blob.any.worker.html]
[A simple blob range request.]
expected: FAIL
expected: PASS
[A blob range request with no end.]
expected: FAIL
expected: PASS
[A blob range request with no start.]
expected: FAIL
expected: PASS
[A simple blob range request with whitespace.]
expected: FAIL
expected: PASS
[Blob content with short content and a large range end]
expected: FAIL
expected: PASS
[Blob range with whitespace before and after hyphen]
expected: FAIL
@ -143,7 +143,7 @@
expected: FAIL
[Blob content with short content and a range end matching content length]
expected: FAIL
expected: PASS
[Blob range with no value]
expected: FAIL

View file

@ -1,24 +1,24 @@
[blob-range.any.worker.html]
[A simple blob range request.]
expected: FAIL
expected: PASS
[A blob range request with no type.]
expected: FAIL
[A blob range request with no end.]
expected: FAIL
expected: PASS
[A blob range request with no start.]
expected: FAIL
expected: PASS
[A simple blob range request with whitespace.]
expected: FAIL
[Blob content with short content and a large range end]
expected: FAIL
expected: PASS
[Blob content with short content and a range end matching content length]
expected: FAIL
expected: PASS
[Blob range with whitespace before and after hyphen]
expected: FAIL
@ -83,25 +83,25 @@
[blob-range.any.html]
[A simple blob range request.]
expected: FAIL
expected: PASS
[A blob range request with no type.]
expected: FAIL
[A blob range request with no end.]
expected: FAIL
expected: PASS
[A blob range request with no start.]
expected: FAIL
expected: PASS
[A simple blob range request with whitespace.]
expected: FAIL
[Blob content with short content and a large range end]
expected: FAIL
expected: PASS
[Blob content with short content and a range end matching content length]
expected: FAIL
expected: PASS
[Blob range with whitespace before and after hyphen]
expected: FAIL

View file

@ -13905,13 +13905,6 @@
{}
]
],
"range_request_blob_url.html": [
"075397620e989dafc814c0ed2bca46bd476bccf6",
[
null,
{}
]
],
"range_request_file_url.html": [
"4fd4ddc8b1a9959e90b243795267c220d6a05f5e",
[

View file

@ -1,60 +0,0 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
[{
range: "bytes=0-",
status: 206,
expected: "abcdefghijklmnopqrstuvwxyz"
}, {
range: "bytes=0-9",
status: 206,
expected: "abcdefghi"
}, {
range: "bytes=1-9",
status: 206,
expected: "bcdefghi"
}, {
range: "bytes=-10",
status: 206,
expected: "qrstuvwxyz"
}, {
range: "bytes=0-100",
status: 206,
expected: "abcdefghijklmnopqrstuvwxyz"
}, {
range: "bytes=100-",
status: 416,
expected: ""
}, {
range: "bytes=-100",
status: 206,
expected: "abcdefghijklmnopqrstuvwxyz"
}].forEach(test => {
promise_test(function() {
const abc = "abcdefghijklmnopqrstuvwxyz";
const blob = new Blob([abc], { "type": "text/plain" });
return fetch(URL.createObjectURL(blob), {
headers: {
"Range": test.range
}
})
.then(response => {
assert_equals(response.status, test.status);
if (response.status != 206) {
return "";
}
return response.text();
})
.then(response => {
assert_equals(response, test.expected);
});
});
});
</script>
</head>
</body>
</html>