zip.js: Fetch Range requests is using "header_range" header instead of "Range"; XHR Range not working (status on Uint8Array...; no return)

This is a correct definition: https://github.com/gildas-lormeau/zip.js/blob/bf322d19b387044e140b2a9a0aef0aedfb9d1141/lib/core/io.js#L39 It is used correctly by the XHRReader.readUint8Array: https://github.com/gildas-lormeau/zip.js/blob/bf322d19b387044e140b2a9a0aef0aedfb9d1141/lib/core/io.js#L301 However the FetchReader.readUint8Array uses HEADER_RANGE: https://github.com/gildas-lormeau/zip.js/blob/bf322d19b387044e140b2a9a0aef0aedfb9d1141/lib/core/io.js#L234 Resulting in a CORS Preflight with Access-Control-Request-Headers: header_range .

Working code using ES6 ComputedPropertyName would be:

	{[HTTP_HEADER_RANGE]: HTTP_RANGE_UNIT + "=" + index + "-" + (index + length - 1) }));

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 33 (23 by maintainers)

Commits related to this issue

Most upvoted comments

Great! I was reading a 1.79 GiB zip file*, so I could not get away with not using Range 🙃. Thanks a lot for the extremely fast response 🚀 (BTW I also tested the code before the PR’s)

* which supports CORS & Ranges, but not the combination, just send a request (🇳🇱) to fix that, that’s why I used a CORS proxy.

I tested the following code with the version 2.3.14 in Firefox and Chrome on Apache and it works as expected with useXHR: false and useXHR: true. In both browsers and both cases, the test runs fine and I see 206 responses in the Network panel.

const zipReader = new zip.ZipReader(new zip.HttpRangeReader("../data/lorem.zip", { useXHR: false }));
const entries = await zipReader.getEntries();
const dataBlobWriter = new zip.BlobWriter();
let data = await entries[0].getData(dataBlobWriter);
await zipReader.close();

edit: I used this page to do the tests: https://github.com/gildas-lormeau/zip.js/blob/master/tests/pages/test-http-range.html

Thank you for the fix, I’ll merge it ASAP. I thought I was testing the fetch implementation in /tests/pages/test-sw.html but since the header name was incorrect, the test was working without doing range requests. I confirm it has been tested and worked in the past, it’s a regression.

Thank you! I’m sorry, it looks like I fixed the issue just before your PR.