Skip to content

Commit 04aeb5d

Browse files
authored
feat: support multiple byte-ranges (#207)
* fix: limit size of firstChunk * fix: set content-length if we have it * chore: fix lint errors * feat: all plugins support byte ranges * feat: support multiple byte ranges in request * test: gateway conformance passes * feat: remove old single-byterange code * feat: multi byterange support for unixfs data * fix: multi-range for unixfs * fix: revalidate byte ranges when size changes * chore: some cleanup * test: re-add multi-range test with expectations * chore: gwc update script recognizes all changes * test: update test suite success rate * test: increase gwc avg success rate * chore: fix lint and dont throwIfAborted * chore: add byteranges to dictionary
1 parent d0451ad commit 04aeb5d

21 files changed

+600
-184
lines changed

.github/dictionary.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ Cantarell
1616
Noto
1717
Consolas
1818
filev
19+
byteranges

packages/gateway-conformance/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
"@helia/http": "^2.1.1",
145145
"@helia/interface": "^5.3.1",
146146
"@helia/routers": "^3.1.1",
147-
"@helia/verified-fetch": "^2.0.0",
147+
"@helia/verified-fetch": "^3.0.2",
148148
"@libp2p/interface": "^2.10.1",
149149
"@libp2p/kad-dht": "^15.1.1",
150150
"@libp2p/logger": "^5.1.17",

packages/gateway-conformance/src/conformance.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ describe('@helia/verified-fetch - gateway conformance', function () {
154154
})
155155
}
156156

157-
const knownSuccessRate = 44.14
157+
const knownSuccessRate = 55.02
158158
it(`has expected success rate of ${knownSuccessRate}%`, () => {
159159
// check latest success rate with `SUCCESS_RATE=100 npm run test -- -g 'total'`
160160
const expectedSuccessRate = process.env.SUCCESS_RATE != null ? Number.parseFloat(process.env.SUCCESS_RATE) : knownSuccessRate

packages/gateway-conformance/src/expected-failing-tests.json

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
"TestPlainCodec/GET_plain_JSON_codec_without_Accept_or_format=_has_expected_%22json%22_Content-Type_and_body_as-is_-_single_range",
6464
"TestPlainCodec/GET_plain_JSON_codec_without_Accept_or_format=_has_expected_%22json%22_Content-Type_and_body_as-is_-_multi_range/Check_0/Header_Content-Disposition",
6565
"TestPlainCodec/GET_plain_JSON_codec_without_Accept_or_format=_has_expected_%22json%22_Content-Type_and_body_as-is_-_multi_range/Check_0",
66-
"TestPlainCodec/GET_plain_JSON_codec_without_Accept_or_format=_has_expected_%22json%22_Content-Type_and_body_as-is_-_multi_range/Check_1",
6766
"TestPlainCodec/GET_plain_JSON_codec_without_Accept_or_format=_has_expected_%22json%22_Content-Type_and_body_as-is_-_multi_range",
6867
"TestPlainCodec/GET_plain_JSON_codec_with_%3Fformat=_has_expected_json_Content-Type_and_body_as-is_-_full_request/Check_0/Header_Content-Disposition",
6968
"TestPlainCodec/GET_plain_JSON_codec_with_%3Fformat=_has_expected_json_Content-Type_and_body_as-is_-_full_request/Check_0",
@@ -73,7 +72,6 @@
7372
"TestPlainCodec/GET_plain_JSON_codec_with_%3Fformat=_has_expected_json_Content-Type_and_body_as-is_-_single_range",
7473
"TestPlainCodec/GET_plain_JSON_codec_with_%3Fformat=_has_expected_json_Content-Type_and_body_as-is_-_multi_range/Check_0/Header_Content-Disposition",
7574
"TestPlainCodec/GET_plain_JSON_codec_with_%3Fformat=_has_expected_json_Content-Type_and_body_as-is_-_multi_range/Check_0",
76-
"TestPlainCodec/GET_plain_JSON_codec_with_%3Fformat=_has_expected_json_Content-Type_and_body_as-is_-_multi_range/Check_1",
7775
"TestPlainCodec/GET_plain_JSON_codec_with_%3Fformat=_has_expected_json_Content-Type_and_body_as-is_-_multi_range",
7876
"TestPlainCodec/GET_plain_JSON_codec_with_Accept_has_expected_json_Content-Type_and_body_as-is%2C_with_single_range_request_-_full_request/Check_0/Header_Content-Disposition",
7977
"TestPlainCodec/GET_plain_JSON_codec_with_Accept_has_expected_json_Content-Type_and_body_as-is%2C_with_single_range_request_-_full_request/Check_0",
@@ -83,7 +81,6 @@
8381
"TestPlainCodec/GET_plain_JSON_codec_with_Accept_has_expected_json_Content-Type_and_body_as-is%2C_with_single_range_request_-_single_range",
8482
"TestPlainCodec/GET_plain_JSON_codec_with_Accept_has_expected_json_Content-Type_and_body_as-is%2C_with_single_range_request_-_multi_range/Check_0/Header_Content-Disposition",
8583
"TestPlainCodec/GET_plain_JSON_codec_with_Accept_has_expected_json_Content-Type_and_body_as-is%2C_with_single_range_request_-_multi_range/Check_0",
86-
"TestPlainCodec/GET_plain_JSON_codec_with_Accept_has_expected_json_Content-Type_and_body_as-is%2C_with_single_range_request_-_multi_range/Check_1",
8784
"TestPlainCodec/GET_plain_JSON_codec_with_Accept_has_expected_json_Content-Type_and_body_as-is%2C_with_single_range_request_-_multi_range",
8885
"TestPlainCodec/GET_plain_JSON_codec_with_format=dag-json_interprets_json_as_dag-%2A_variant_and_produces_expected_Content-Type_and_body/Header_Content-Disposition",
8986
"TestPlainCodec/GET_plain_JSON_codec_with_format=dag-json_interprets_json_as_dag-%2A_variant_and_produces_expected_Content-Type_and_body",
@@ -92,7 +89,6 @@
9289
"TestPlainCodec/GET_plain_JSON_codec_with_format=dag-json_interprets_json_as_dag-%2A_variant_and_produces_expected_Content-Type_and_body%2C_with_single_range_request_-_single_range",
9390
"TestPlainCodec/GET_plain_JSON_codec_with_format=dag-json_interprets_json_as_dag-%2A_variant_and_produces_expected_Content-Type_and_body%2C_with_single_range_request_-_multi_range/Check_0/Header_Content-Disposition",
9491
"TestPlainCodec/GET_plain_JSON_codec_with_format=dag-json_interprets_json_as_dag-%2A_variant_and_produces_expected_Content-Type_and_body%2C_with_single_range_request_-_multi_range/Check_0",
95-
"TestPlainCodec/GET_plain_JSON_codec_with_format=dag-json_interprets_json_as_dag-%2A_variant_and_produces_expected_Content-Type_and_body%2C_with_single_range_request_-_multi_range/Check_1",
9692
"TestPlainCodec/GET_plain_JSON_codec_with_format=dag-json_interprets_json_as_dag-%2A_variant_and_produces_expected_Content-Type_and_body%2C_with_single_range_request_-_multi_range",
9793
"TestPlainCodec/GET_plain_CBOR_codec_without_Accept_or_format=_has_expected_%22cbor%22_Content-Type_and_body_as-is_-_full_request/Check_0/Header_Content-Disposition",
9894
"TestPlainCodec/GET_plain_CBOR_codec_without_Accept_or_format=_has_expected_%22cbor%22_Content-Type_and_body_as-is_-_full_request/Check_0",
@@ -253,14 +249,6 @@
253249
"TestGatewaySymlink/Test_the_symlink/Body",
254250
"TestGatewaySymlink/Test_the_symlink",
255251
"TestGatewaySymlink",
256-
"TestGatewayUnixFSFileRanges/GET_for_%2Fipfs%2F_file_with_single_range_request_includes_correct_bytes/Header_Content-Range",
257-
"TestGatewayUnixFSFileRanges/GET_for_%2Fipfs%2F_file_with_single_range_request_includes_correct_bytes",
258-
"TestGatewayUnixFSFileRanges/GET_for_%2Fipfs%2F_file_with_suffix_range_request_includes_correct_bytes_from_the_end_of_file/Header_Content-Range",
259-
"TestGatewayUnixFSFileRanges/GET_for_%2Fipfs%2F_file_with_suffix_range_request_includes_correct_bytes_from_the_end_of_file/Body",
260-
"TestGatewayUnixFSFileRanges/GET_for_%2Fipfs%2F_file_with_suffix_range_request_includes_correct_bytes_from_the_end_of_file",
261-
"TestGatewayUnixFSFileRanges/GET_for_%2Fipfs%2F_file_with_multiple_range_request_returned_HTTP_206/Status_code",
262-
"TestGatewayUnixFSFileRanges/GET_for_%2Fipfs%2F_file_with_multiple_range_request_returned_HTTP_206",
263-
"TestGatewayUnixFSFileRanges",
264252
"TestRedirectsFileSupport/request_for_%7Bcid%7D.ipfs.example.com%2Fredirect-one_redirects_with_default_of_301%2C_per__redirects_file/Status_code",
265253
"TestRedirectsFileSupport/request_for_%7Bcid%7D.ipfs.example.com%2Fredirect-one_redirects_with_default_of_301%2C_per__redirects_file/Header_Location",
266254
"TestRedirectsFileSupport/request_for_%7Bcid%7D.ipfs.example.com%2Fredirect-one_redirects_with_default_of_301%2C_per__redirects_file",
@@ -569,6 +557,7 @@
569557
"TestTrustlessCarOrderAndDuplicates/GET_CAR_with_order=dfs_and_dups=n_of_UnixFS_Directory_With_Duplicate_Files",
570558
"TestTrustlessCarOrderAndDuplicates/GET_CAR_smoke-test_with_order=unk_of_UnixFS_Directory/Header_Content-Type#01",
571559
"TestTrustlessCarOrderAndDuplicates/GET_CAR_smoke-test_with_order=unk_of_UnixFS_Directory",
560+
"TestTrustlessCarOrderAndDuplicates/GET_CAR_with_order=dfs_and_dups=y_of_identity_CID/Header_Content-Type",
572561
"TestTrustlessCarOrderAndDuplicates/GET_CAR_with_order=dfs_and_dups=y_of_identity_CID/Header_Content-Type#01",
573562
"TestTrustlessCarOrderAndDuplicates/GET_CAR_with_order=dfs_and_dups=y_of_identity_CID/Body",
574563
"TestTrustlessCarOrderAndDuplicates/GET_CAR_with_order=dfs_and_dups=y_of_identity_CID",
@@ -592,8 +581,5 @@
592581
"TestTrustlessRaw/GET_with_application%2Fvnd.ipld.raw_header_returns_expected_response_headers",
593582
"TestTrustlessRaw/GET_with_application%2Fvnd.ipld.raw_header_returns_expected_caching_headers/Header_X-IPFS-Roots",
594583
"TestTrustlessRaw/GET_with_application%2Fvnd.ipld.raw_header_returns_expected_caching_headers",
595-
"TestTrustlessRaw",
596-
"TestTrustlessRawRanges/GET_with_application%2Fvnd.ipld.raw_with_range_request_includes_correct_bytes_-_multi_range/Check_1",
597-
"TestTrustlessRawRanges/GET_with_application%2Fvnd.ipld.raw_with_range_request_includes_correct_bytes_-_multi_range",
598-
"TestTrustlessRawRanges"
584+
"TestTrustlessRaw"
599585
]

packages/gateway-conformance/src/expected-passing-tests.json

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"TestPlainCodec/GET_plain_JSON_codec_without_Accept_or_format=_has_expected_%22json%22_Content-Type_and_body_as-is_-_multi_range/Check_1/Check_0",
4848
"TestPlainCodec/GET_plain_JSON_codec_without_Accept_or_format=_has_expected_%22json%22_Content-Type_and_body_as-is_-_multi_range/Check_1/Check_1",
4949
"TestPlainCodec/GET_plain_JSON_codec_without_Accept_or_format=_has_expected_%22json%22_Content-Type_and_body_as-is_-_multi_range/Check_1/Check_2",
50+
"TestPlainCodec/GET_plain_JSON_codec_without_Accept_or_format=_has_expected_%22json%22_Content-Type_and_body_as-is_-_multi_range/Check_1",
5051
"TestPlainCodec/GET_plain_JSON_codec_with_%3Fformat=_has_expected_json_Content-Type_and_body_as-is_-_full_request/Check_1/Status_code",
5152
"TestPlainCodec/GET_plain_JSON_codec_with_%3Fformat=_has_expected_json_Content-Type_and_body_as-is_-_full_request/Check_1/Body",
5253
"TestPlainCodec/GET_plain_JSON_codec_with_%3Fformat=_has_expected_json_Content-Type_and_body_as-is_-_full_request/Check_1",
@@ -56,6 +57,7 @@
5657
"TestPlainCodec/GET_plain_JSON_codec_with_%3Fformat=_has_expected_json_Content-Type_and_body_as-is_-_multi_range/Check_1/Check_0",
5758
"TestPlainCodec/GET_plain_JSON_codec_with_%3Fformat=_has_expected_json_Content-Type_and_body_as-is_-_multi_range/Check_1/Check_1",
5859
"TestPlainCodec/GET_plain_JSON_codec_with_%3Fformat=_has_expected_json_Content-Type_and_body_as-is_-_multi_range/Check_1/Check_2",
60+
"TestPlainCodec/GET_plain_JSON_codec_with_%3Fformat=_has_expected_json_Content-Type_and_body_as-is_-_multi_range/Check_1",
5961
"TestPlainCodec/GET_plain_JSON_codec_with_Accept_has_expected_json_Content-Type_and_body_as-is%2C_with_single_range_request_-_full_request/Check_1/Status_code",
6062
"TestPlainCodec/GET_plain_JSON_codec_with_Accept_has_expected_json_Content-Type_and_body_as-is%2C_with_single_range_request_-_full_request/Check_1/Body",
6163
"TestPlainCodec/GET_plain_JSON_codec_with_Accept_has_expected_json_Content-Type_and_body_as-is%2C_with_single_range_request_-_full_request/Check_1",
@@ -65,6 +67,7 @@
6567
"TestPlainCodec/GET_plain_JSON_codec_with_Accept_has_expected_json_Content-Type_and_body_as-is%2C_with_single_range_request_-_multi_range/Check_1/Check_0",
6668
"TestPlainCodec/GET_plain_JSON_codec_with_Accept_has_expected_json_Content-Type_and_body_as-is%2C_with_single_range_request_-_multi_range/Check_1/Check_1",
6769
"TestPlainCodec/GET_plain_JSON_codec_with_Accept_has_expected_json_Content-Type_and_body_as-is%2C_with_single_range_request_-_multi_range/Check_1/Check_2",
70+
"TestPlainCodec/GET_plain_JSON_codec_with_Accept_has_expected_json_Content-Type_and_body_as-is%2C_with_single_range_request_-_multi_range/Check_1",
6871
"TestPlainCodec/GET_plain_JSON_codec_with_format=dag-json_interprets_json_as_dag-%2A_variant_and_produces_expected_Content-Type_and_body/Status_code",
6972
"TestPlainCodec/GET_plain_JSON_codec_with_format=dag-json_interprets_json_as_dag-%2A_variant_and_produces_expected_Content-Type_and_body/Header_Content-Type",
7073
"TestPlainCodec/GET_plain_JSON_codec_with_format=dag-json_interprets_json_as_dag-%2A_variant_and_produces_expected_Content-Type_and_body/Body",
@@ -74,6 +77,7 @@
7477
"TestPlainCodec/GET_plain_JSON_codec_with_format=dag-json_interprets_json_as_dag-%2A_variant_and_produces_expected_Content-Type_and_body%2C_with_single_range_request_-_multi_range/Check_1/Check_0",
7578
"TestPlainCodec/GET_plain_JSON_codec_with_format=dag-json_interprets_json_as_dag-%2A_variant_and_produces_expected_Content-Type_and_body%2C_with_single_range_request_-_multi_range/Check_1/Check_1",
7679
"TestPlainCodec/GET_plain_JSON_codec_with_format=dag-json_interprets_json_as_dag-%2A_variant_and_produces_expected_Content-Type_and_body%2C_with_single_range_request_-_multi_range/Check_1/Check_2",
80+
"TestPlainCodec/GET_plain_JSON_codec_with_format=dag-json_interprets_json_as_dag-%2A_variant_and_produces_expected_Content-Type_and_body%2C_with_single_range_request_-_multi_range/Check_1",
7781
"TestPlainCodec/GET_plain_CBOR_codec_without_Accept_or_format=_has_expected_%22cbor%22_Content-Type_and_body_as-is_-_single_range/Check_1/Check_0",
7882
"TestPlainCodec/GET_plain_CBOR_codec_without_Accept_or_format=_has_expected_%22cbor%22_Content-Type_and_body_as-is_-_single_range/Check_1/Check_1",
7983
"TestPlainCodec/GET_plain_CBOR_codec_without_Accept_or_format=_has_expected_%22cbor%22_Content-Type_and_body_as-is_-_multi_range/Check_1/Check_0",
@@ -325,16 +329,28 @@
325329
"TestGatewayUnixFSFileRanges/GET_for_%2Fipfs%2F_file_includes_Accept-Ranges_header/Body",
326330
"TestGatewayUnixFSFileRanges/GET_for_%2Fipfs%2F_file_includes_Accept-Ranges_header",
327331
"TestGatewayUnixFSFileRanges/GET_for_%2Fipfs%2F_file_with_single_range_request_includes_correct_bytes/Status_code",
332+
"TestGatewayUnixFSFileRanges/GET_for_%2Fipfs%2F_file_with_single_range_request_includes_correct_bytes/Header_Content-Range",
328333
"TestGatewayUnixFSFileRanges/GET_for_%2Fipfs%2F_file_with_single_range_request_includes_correct_bytes/Body",
334+
"TestGatewayUnixFSFileRanges/GET_for_%2Fipfs%2F_file_with_single_range_request_includes_correct_bytes",
329335
"TestGatewayUnixFSFileRanges/GET_for_%2Fipfs%2F_file_with_suffix_range_request_includes_correct_bytes_from_the_end_of_file/Status_code",
336+
"TestGatewayUnixFSFileRanges/GET_for_%2Fipfs%2F_file_with_suffix_range_request_includes_correct_bytes_from_the_end_of_file/Header_Content-Range",
337+
"TestGatewayUnixFSFileRanges/GET_for_%2Fipfs%2F_file_with_suffix_range_request_includes_correct_bytes_from_the_end_of_file/Body",
338+
"TestGatewayUnixFSFileRanges/GET_for_%2Fipfs%2F_file_with_suffix_range_request_includes_correct_bytes_from_the_end_of_file",
339+
"TestGatewayUnixFSFileRanges/GET_for_%2Fipfs%2F_file_with_multiple_range_request_returned_HTTP_206/Status_code",
330340
"TestGatewayUnixFSFileRanges/GET_for_%2Fipfs%2F_file_with_multiple_range_request_returned_HTTP_206/Header_Content-Type",
331341
"TestGatewayUnixFSFileRanges/GET_for_%2Fipfs%2F_file_with_multiple_range_request_returned_HTTP_206/Header_Content-Range",
342+
"TestGatewayUnixFSFileRanges/GET_for_%2Fipfs%2F_file_with_multiple_range_request_returned_HTTP_206",
343+
"TestGatewayUnixFSFileRanges/GET_for_%2Fipfs%2F_file_with_multiple_range_request_includes_correct_bytes/Status_code",
344+
"TestGatewayUnixFSFileRanges/GET_for_%2Fipfs%2F_file_with_multiple_range_request_includes_correct_bytes/Header_Content-Type",
345+
"TestGatewayUnixFSFileRanges/GET_for_%2Fipfs%2F_file_with_multiple_range_request_includes_correct_bytes/Body",
346+
"TestGatewayUnixFSFileRanges/GET_for_%2Fipfs%2F_file_with_multiple_range_request_includes_correct_bytes",
332347
"TestGatewayUnixFSFileRanges/GET_Range_of_file_succeeds_even_if_the_gateway_is_missing_a_block_AFTER_the_requested_range/Status_code",
333348
"TestGatewayUnixFSFileRanges/GET_Range_of_file_succeeds_even_if_the_gateway_is_missing_a_block_AFTER_the_requested_range/Header_Content-Range",
334349
"TestGatewayUnixFSFileRanges/GET_Range_of_file_succeeds_even_if_the_gateway_is_missing_a_block_AFTER_the_requested_range",
335350
"TestGatewayUnixFSFileRanges/GET_Range_of_file_succeeds_even_if_the_gateway_is_missing_a_block_BEFORE_the_requested_range/Status_code",
336351
"TestGatewayUnixFSFileRanges/GET_Range_of_file_succeeds_even_if_the_gateway_is_missing_a_block_BEFORE_the_requested_range/Header_Content-Range",
337352
"TestGatewayUnixFSFileRanges/GET_Range_of_file_succeeds_even_if_the_gateway_is_missing_a_block_BEFORE_the_requested_range",
353+
"TestGatewayUnixFSFileRanges",
338354
"TestPathGatewayMiscellaneous/GET_for_%2Fipfs%2F_file_whose_filename_contains_percentage-encoded_characters_works/Body",
339355
"TestPathGatewayMiscellaneous/GET_for_%2Fipfs%2F_file_whose_filename_contains_percentage-encoded_characters_works",
340356
"TestPathGatewayMiscellaneous",
@@ -651,7 +667,6 @@
651667
"TestTrustlessCarOrderAndDuplicates/GET_CAR_smoke-test_with_order=unk_of_UnixFS_Directory/Header_Content-Type",
652668
"TestTrustlessCarOrderAndDuplicates/GET_CAR_smoke-test_with_order=unk_of_UnixFS_Directory/Body",
653669
"TestTrustlessCarOrderAndDuplicates/GET_CAR_with_order=dfs_and_dups=y_of_identity_CID/Status_code",
654-
"TestTrustlessCarOrderAndDuplicates/GET_CAR_with_order=dfs_and_dups=y_of_identity_CID/Header_Content-Type",
655670
"TestTrustlessCarOrderAndDuplicates/GET_CAR_with_Accept_and_%3Fformat%2C_specific_Accept_header_is_prioritized/Status_code",
656671
"TestTrustlessCarOrderAndDuplicates/GET_CAR_with_Accept_and_%3Fformat%2C_specific_Accept_header_is_prioritized/Header_Content-Type",
657672
"TestTrustlessCarOrderAndDuplicates/GET_CAR_with_Accept_and_%3Fformat%2C_specific_Accept_header_is_prioritized/Body",
@@ -693,5 +708,8 @@
693708
"TestTrustlessRawRanges/GET_with_application%2Fvnd.ipld.raw_with_range_request_includes_correct_bytes_-_multi_range/Check_0",
694709
"TestTrustlessRawRanges/GET_with_application%2Fvnd.ipld.raw_with_range_request_includes_correct_bytes_-_multi_range/Check_1/Check_0",
695710
"TestTrustlessRawRanges/GET_with_application%2Fvnd.ipld.raw_with_range_request_includes_correct_bytes_-_multi_range/Check_1/Check_1",
696-
"TestTrustlessRawRanges/GET_with_application%2Fvnd.ipld.raw_with_range_request_includes_correct_bytes_-_multi_range/Check_1/Check_2"
711+
"TestTrustlessRawRanges/GET_with_application%2Fvnd.ipld.raw_with_range_request_includes_correct_bytes_-_multi_range/Check_1/Check_2",
712+
"TestTrustlessRawRanges/GET_with_application%2Fvnd.ipld.raw_with_range_request_includes_correct_bytes_-_multi_range/Check_1",
713+
"TestTrustlessRawRanges/GET_with_application%2Fvnd.ipld.raw_with_range_request_includes_correct_bytes_-_multi_range",
714+
"TestTrustlessRawRanges"
697715
]

packages/gateway-conformance/src/update-expected-tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ if (failingTestAdditions.length > 0 || failingTestAdditions.length > 0) {
7272
console.warn('WARNING: There are previously passing tests that are now failing, is this expected?')
7373
}
7474

75-
if (failingTestAdditions.length > 0 || passingTestAdditions.length > 0) {
75+
if (passingTestRemovals.length + failingTestRemovals.length + passingTestAdditions.length + failingTestAdditions.length > 0) {
7676
const answer = await confirm('Are you sure you want to update the expected-passing-tests.json and expected-failing-tests.json files with the latest test results?')
7777

7878
if (!answer) {

packages/verified-fetch/src/plugins/plugin-handle-byte-range-context.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ByteRangeContext } from '../utils/byte-range-context.js'
2+
import { badRangeResponse } from '../utils/responses.js'
23
import { BasePlugin } from './plugin-base.js'
34
import type { PluginContext } from './types.js'
45

@@ -19,6 +20,11 @@ export class ByteRangeContextPlugin extends BasePlugin {
1920
context.byteRangeContext = new ByteRangeContext(this.pluginOptions.logger, context.options?.headers)
2021
context.modified++
2122

23+
if (context.byteRangeContext.isRangeRequest && !context.byteRangeContext.isValidRangeRequest) {
24+
// invalid range request.. fail
25+
return badRangeResponse(context.resource)
26+
}
27+
2228
return null
2329
}
2430
}

packages/verified-fetch/src/plugins/plugin-handle-car.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ export class CarPlugin extends BasePlugin {
9898

9999
context.byteRangeContext.setBody(toBrowserReadableStream(iter()))
100100

101-
const response = okRangeResponse(context.resource, context.byteRangeContext.getBody(), { byteRangeContext: context.byteRangeContext, log: this.log })
102-
response.headers.set('content-type', 'application/vnd.ipld.car; version=1')
101+
const response = okRangeResponse(context.resource, context.byteRangeContext.getBody('application/vnd.ipld.car; version=1'), { byteRangeContext: context.byteRangeContext, log: this.log })
102+
response.headers.set('content-type', context.byteRangeContext.getContentType() ?? 'application/vnd.ipld.car; version=1')
103103

104104
return response
105105
}

0 commit comments

Comments
 (0)