Skip to content

Gzip decoder too strict #5761

Closed
Closed
@peterkooijmans

Description

@peterkooijmans
  • Version: 5.9.0
  • Platform: Windows 7 64 bit
  • Subsystem: zlib

While talking to a web server on an embedded device, asking for gzip content encoding I get responses that are considered OK by all major browsers (Chrome, Firefox, IE) and also cURL. However, the Node zlibmodule considers the gzip stream incomplete and throws an error. The error returned by the zlib module reads: Error: unexpected end of file at Zlib._handle.onerror (zlib.js:363:17). Inspecting the gzip response it seems to be missing a footer detailing the CRC and the length of the compressed data.

A small program that reproduces this with an actual response from the device in it:

var buffer = require("buffer");
var stream = require("stream");
var fs = require("fs");
var zlib = require("zlib");

var s = new stream.Readable();
var b = new buffer.Buffer([
    0x1F, 0x8B, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xB2, 0xB1,
    0xAF, 0xC8, 0xCD, 0x51, 0x28, 0x4B, 0x2D, 0x2A, 0xCE, 0xCC, 0xCF, 0xB3,
    0x55, 0x32, 0xD4, 0x33, 0x50, 0x52, 0x48, 0xCD, 0x4B, 0xCE, 0x4F, 0xC9,
    0xCC, 0x4B, 0xB7, 0x55, 0x2A, 0x2D, 0x49, 0xD3, 0xB5, 0x50, 0x52, 0xB0,
    0xB7, 0xE3, 0xE5, 0xB2, 0x49, 0xCC, 0x49, 0x2C, 0xCA, 0x2D, 0x56, 0x48,
    0x4E, 0x4C, 0xCE, 0x48, 0xCD, 0x4C, 0xB1, 0x55, 0xB2, 0x54, 0x52, 0x50,
    0xD0, 0x07, 0x4A, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF
]);

s.push(b);
s.push(null);
s.pipe(zlib.createGunzip()).pipe(process.stdout);

Would it be possible to make the Node gzip decoder more lenient and behave more like all major browsers and cURL do?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionIssues that look for answers.zlibIssues and PRs related to the zlib subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions