My question is if i make a request using the node-fetch library with header Accept-Encoding:'gzip', does node-fetch handle automatic decompression of the response data?
You don't even need to add the header yourself, it'll be added automatically by node for you.
This is easily tested by creating an index.mjs
file with the following content.
const response = await fetch('https://httpbin.org/headers');
const data = await response.json();
console.log(data.headers['Accept-Encoding']);
And running the following command node index.mjs
which returns br, gzip, deflate
under node 20.15.0 and windows 11.