I have a device I need to download a file from. In certain cases, the file may have an incorrect content-encoding
. Particularly, it may have a content-encoding of "gzip", when it is not gzipped, or compressed in any way.
So, when the file is gzipped, it's simple to get the content using a basic ajax GET:
$.ajax({
url: 'http://' + IP + '/test.txt',
type: 'GET'
})
.done(function(data) {
alert(data);
});
But this fails, as you might expect, when the content-encoding is wrong.
To be clear, I'm not looking for a solution to bypass the ERR_CONTENT_DECODING_FAILED
when simply navigating to the given url in a browser. I want to be able to load, for instance, a csv, into a string in javascript for further parsing.
Can I GET the file, and force it to skip attempting decoding, or override the content-encoding of the response, or some such?