I have the following code:
const URL = 'https://www.tophtml.com/snl/15.mp3';
window.addEventListener('load', function() {
const button_load = document.querySelector('.button_load');
button_load.addEventListener('click', async function() {
let url = URL + '?nocache='+(new Date()).getTime();
let arrayBuffer = await fetchData(url, 501, 510);
console.log('This is the response itself:');
console.log(arrayBuffer);
});
});
function fetchData(url, byte_from, byte_to) {
return new Promise((resolve, reject) => {
var request = new XMLHttpRequest();
request.responseType = 'arraybuffer';
request.open('GET', url, true);
request.setRequestHeader("Range", "bytes=" + byte_from + "-" + byte_to);
request.onload = function() {
resolve(request.response);
}
request.onreadystatechange = function() {
if (this.readyState == this.HEADERS_RECEIVED) {
console.log('These are the "Response Headers" visible to JavaScript:');
console.log(request.getAllResponseHeaders());
}
}
request.send();
});
}
<button class="button_load">Load</button>
which you can also find here:
https://codepen.io/anon/pen/OBJqZG?editors=1010
My problem is that for some reason, the Content-Range
response header is not visible for JavaScript
as you can see on the following image:
Any idea of what's going on here?
Thanks!