
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
The 'inflation' npm package is used to handle HTTP content encoding. It automatically decompresses HTTP responses that are compressed using gzip, deflate, or other supported algorithms. This is particularly useful in web applications and APIs where data compression is commonly used to reduce the size of the payload.
Automatic Decompression
This feature automatically decompresses incoming HTTP requests that are compressed using gzip, deflate, or other supported algorithms. The code sample demonstrates how to use the 'inflation' package to handle decompression in an HTTP server.
const http = require('http');
const inflation = require('inflation');
http.createServer((req, res) => {
req = inflation(req);
let data = '';
req.on('data', chunk => {
data += chunk;
});
req.on('end', () => {
res.end(data);
});
}).listen(3000);
The 'zlib' package is a core Node.js module that provides compression and decompression functionalities. Unlike 'inflation', which automatically handles HTTP content encoding, 'zlib' requires manual handling of streams and is more low-level. It supports gzip, deflate, and other compression algorithms.
The 'decompress' package is used for extracting compressed files. While it is not specifically designed for HTTP content encoding like 'inflation', it supports various compression formats such as zip, tar, and gzip. It is more suitable for file decompression rather than HTTP stream decompression.
The 'node-unzipper' package is used for unzipping files in Node.js. It is similar to 'decompress' but focuses on zip files. Unlike 'inflation', it is not designed for HTTP content encoding but for handling zip file decompression.
Automatically unzip an HTTP stream.
var inflate = require('inflation')
Returns a stream that emits inflated data from the given stream.
Options:
encoding
- The encoding of the stream (gzip
or deflate
).
If not given, will look in stream.headers['content-encoding']
.brotli
- BrotliOptions
to use for Brotli decompressionvar inflate = require('inflation')
var raw = require('raw-body')
http.createServer(function (req, res) {
raw(inflate(req), 'utf-8', function (err, string) {
console.dir(string)
})
})
dougwilson | bminer | fengmk2 |
---|
This project follows the git-contributor spec, auto updated at Sat Oct 14 2023 12:55:08 GMT+0800
.
FAQs
Easily unzip an HTTP stream
The npm package inflation receives a total of 701,397 weekly downloads. As such, inflation popularity was classified as popular.
We found that inflation demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.