To make HTTP requests with gzip/deflate compression with Node, we set the gzip
property.
For instance, we write
request(
{ method: "GET", uri: "http://www.example.com", gzip: true },
(error, response, body) => {
console.log(response.headers["content-encoding"]);
console.log(body);
}
);
to call request
with an object with the gzip
option set to true
to make request with gzip compression.
Then we get the response headers from response.headers
and the response body from body
.