Skip to content

Instantly share code, notes, and snippets.

@ejhayes
Last active March 14, 2018 10:15
Show Gist options
  • Save ejhayes/eca784925800d8417ece to your computer and use it in GitHub Desktop.
Save ejhayes/eca784925800d8417ece to your computer and use it in GitHub Desktop.
Request partial byte range of png using 206 partial content request
// PNG file structure
// taken from: http://www.w3.org/TR/REC-png-961001#Structure
var xhr = new XMLHttpRequest;
xhr.onreadystatechange = function () {
if (xhr.readyState != 4) {
return;
}
debugger;
console.log(xhr); // xhr.response (the byte range of the png)
};
xhr.open('GET', 'http://pngimg.com/upload/dog_PNG161.png', true);
xhr.setRequestHeader('Range', 'bytes=100-200');
xhr.send(null);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment