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
- Use correct Range header in fetch (fix #269) — committed to bwbroersma/zip.js by bwbroersma 3 years ago
- fix "Range" header (cf #269) — committed to gildas-lormeau/zip.js by gildas-lormeau 3 years ago
- Make XHR + range working (fix #269 v2) — committed to bwbroersma/zip.js by bwbroersma 3 years ago
- Merge pull request #271 from bwbroersma/gh-269-v2 Make XHR + range working (fix #269 v2) — committed to gildas-lormeau/zip.js by gildas-lormeau 3 years ago
@bwbroersma Here is a basic implementation of the
unzipcommand: https://gist.github.com/gildas-lormeau/731485821c9237b638d01bb4074a6369Great! 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.14in Firefox and Chrome on Apache and it works as expected withuseXHR: falseanduseXHR: true. In both browsers and both cases, the test runs fine and I see 206 responses in the Network panel.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.htmlbut 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.