Support for content-encoding: deflate raw
See original GitHub issueHow does one ask Express to process a POST with a header for ‘content-encoding: deflate’ where the data is raw (without the data headers and footers)?
I’m noticing there’s code in express node-fetch that checks for magic bytes in the first block to decide between createInflate() and createInflateRaw() but it’s not in body-parser.
body-parser read.js
switch (encoding) {
case 'deflate':
stream = zlib.createInflate()
req.pipe(stream)
break
case 'gzip':
...
node-fetch index.js
const raw = res.pipe(new PassThrough$1());
raw.once('data', function (chunk) {
// see http://stackoverflow.com/questions/37519828
if ((chunk[0] & 0x0F) === 0x08) {
body = body.pipe(zlib.createInflate());
} else {
body = body.pipe(zlib.createInflateRaw());
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Content-Encoding - HTTP - MDN Web Docs
The Content-Encoding representation header lists any encodings that have been applied to the representation (message payload), ...
Read more >Handling HTTP ContentEncoding "deflate" - Stack Overflow
After this I have suggested the archive manager I'm using to support decoding raw deflate data so I can just try to open...
Read more >invalid header check when Content-Encoding: deflate and it's ...
Because this method detects based on the binary header. But I encountered deflate responses without headers, which only inflateRaw could ...
Read more >Content Encoding - Everything curl
The deflate , gzip , zstd and br content encodings are supported by libcurl. ... is returned in its raw form and the...
Read more >Dubious HTTP II - Unusual HTTP Content-Encodings
The Content-Encoding header is usually used to specify a compression of the content. The usual values are either gzip (RFC1952) and deflate ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m not sure what leads you to believe that the expressjs project manages node-fetch. We only manage the projets in our expresssjs github organization. I’m not even sure who manages node-fetch, but it is certainly unrelated to expressjs.
We don’t manage the standards, just implement them. If you think the standards should be changed, you should reach out to the standard organization that manages that particular one and have them update it.
Sorry, I missed this direct question at the top 😅. There isn’t really a good way to do this with body-parser currently. You can always use the raw() parser and delete req.headers[‘content-encoding’] . But perhaps a better method would be someone who needs this feature can contribute an API to define custom decoders based on the content-encoding (and override existing ones with their custom impls).