-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcors-test-0.htm
40 lines (34 loc) · 1.87 KB
/
cors-test-0.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!-- DOESN'T WORK with github releases -->
<!-- github releases: any number of files, each file < 2GB -->
<script>
let xhr = new XMLHttpRequest;
/*
https://github.uint.cloudmunity/t/can-releases-be-used-to-host-large-files-for-pages/135571/7
chrome --disable-web-security # disable CORS checks
g<cannot download github release asset because of CORS error>
https://github.uint.cloudmunity/t/github-api-bug-download-repository-zip-cors/168693
https://github.uint.cloudmunity/t/cannot-fetch-release-asset-binary-via-javascript/163118
https://github.com/octokit/rest.js/issues/12 "Cannot download private release asset"
https://stackoverflow.com/questions/63563948/fetch-github-source-tarball-without-cors-issues "It isn't possible"
g<get github authentication token>
*/
//xhr.open('GET', "https://github.com/stasoid/test/releases/download/aaa/test");
//https://docs.github.com/en/rest/releases/assets
//get asset id: https://github.uint.cloudmunity/t/getting-an-empty-list-of-release-assets-for-my-repo/208103 curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/stasoid/test/releases
xhr.open('GET', "https://api.github.com/repos/stasoid/test/releases/assets/65806411"); // fails with CORS error
xhr.responseType = "arraybuffer";
// Workaround for cache bug_ in Chrome that breaks tinycore boot in copy/v86.
// https://stackoverflow.com/a/2068407
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
/*xhr.setRequestHeader("Cache-Control", "no-cache, no-store, must-revalidate");
xhr.setRequestHeader("Pragma", "no-cache");
xhr.setRequestHeader("Expires", "0");
*/
xhr.setRequestHeader("Range", "bytes=0-256");
xhr.setRequestHeader("Origin", "https://stasoid.github.io");
xhr.setRequestHeader("Accept", "application/octet-stream");
xhr.onreadystatechange = () => {
if (xhr.readyState != XMLHttpRequest.DONE) return;
}
xhr.send();
</script>