Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
decompress-response
Advanced tools
The decompress-response npm package is used to decompress HTTP responses that are compressed. This is useful when making HTTP requests and the server responds with compressed data, such as gzip or deflate. The package automatically detects the encoding and decompresses the response so that it can be easily processed in its uncompressed form.
Decompressing HTTP responses
This code sample demonstrates how to use decompress-response to decompress an HTTP response. The 'http.get' method is used to make a GET request to a server. The response is then passed through the decompressResponse function, which returns a stream with the decompressed response. Finally, the decompressed data is piped to the standard output.
const http = require('http');
const decompressResponse = require('decompress-response');
http.get('http://example.com', (res) => {
res = decompressResponse(res);
res.pipe(process.stdout);
});
The pump package is a small node module that pipes streams together and destroys all of them if one of them closes. While it does not provide decompression functionality by itself, it can be used in conjunction with stream-compression modules to handle errors and clean up streams properly after decompression.
Got is a human-friendly and powerful HTTP request library for Node.js. Got supports decompression of HTTP responses out of the box, similar to decompress-response, but it also provides a much richer set of features for making HTTP requests, such as retries, pagination, and more.
node-fetch is a light-weight module that brings the Fetch API to Node.js. It allows you to make HTTP requests similar to the way you would in a browser. The Fetch API supports transparent decompression of responses, which is a feature also provided by decompress-response, but node-fetch offers a broader feature set for making requests and handling responses.
Axios is a promise-based HTTP client for the browser and Node.js. It supports response data decompression, much like decompress-response. However, axios provides a wide range of features such as interceptors, automatic transforms for JSON data, and client-side protection against XSRF.
Decompress a HTTP response if needed
Decompresses the response from http.request
if it's gzipped or deflated, otherwise just passes it through.
Used by got
.
$ npm install decompress-response
const http = require('http');
const decompressResponse = require('decompress-response');
http.get('http://sindresorhus.com', response => {
response = decompressResponse(response);
});
MIT © Sindre Sorhus
FAQs
Decompress a HTTP response if needed
The npm package decompress-response receives a total of 14,038,813 weekly downloads. As such, decompress-response popularity was classified as popular.
We found that decompress-response demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.