I have a library, published via npm as “by-request”, which can, among other things, auto-decompress web content. Part of the code to handle this situation looks like this: The code had been working pretty well until I tried to read a file of astronomical info from here: https://cdsarc.cds.unistra.fr/viz-bin/nph-Cat/txt.gz?VII/118/names.dat I was hitting the reject(UNSUPPORTED_MEDIA_TYPE) error handler because I hadn’t specifically handled
Tag: gzip
I want to decompress a GZIP string with JavaScript
I have this GZIPed string: H4sIAAAAAAAA//NIzcnJVyguSUzOzi9LLUrLyS/XUSjJSMzLLlZIyy9SSMwpT6wsVshIzSnIzEtXBACs78K6LwAAAA== I created that with this website: http://www.txtwizard.net/compression I have tried using pako to ungzip it. The issue is that Pako throws the error: incorrect header check What am I missing here? A JSbin Answer The “H4sIAAAAAAAA//NIzcnJVyguSUzOzi9LLUrLyS/XUSjJSMzLLlZIyy9SSMwpT6wsVshIzSnIzEtXBACs78K6LwAAAA==” is a base64 encoded string, you first need to decode that into a buffer. textEncoder.encode just encodes that