Skip to content

Event on end of deflate stream #26603

@kingces95

Description

@kingces95

I expect the zlib InflateRaw stream to notify me somehow (maybe an 'error' event) that it has detected the end of the deflated stream and is now discarding any more bytes written to the stream. The zlib.net/zpipe.c annotated example code says

The outer do-loop ends when inflate() reports that it has reached the end of the input zlib stream, has completed the decompression and integrity check, and has provided all of the output. This is indicated by the inflate() return value Z_STREAM_END.

What zlib actually does is discard any bytes written to InflateRaw after then the end of the deflated stream has been identified; Zlib does not propagate the Z_STREAM_END notification to me.

I believe zlib will encounter Z_STREAM_END here. And here is where zlib needs to raise the error (I think), but only if there are additional bytes written after the end of the stream as that would indicate the stream user doesn't know where the end of the stream is.

Either way, the stream should also return false after encountering Z_STREAM_END instead of "consuming" by tossing the bytes.

I'm attempting to download and unzip a file in one pass. As the bytes are downloaded I detect the zip headers and start decompressing the stream. The stream is decompressed but as I'm not notified the decompression has reached the end of the deflated stream I'm forced to buffer the remainder of the file which defeats my goal of streaming decompression.

For example, see: #26624

See also my first issue (notes from when I was groping around trying to grock): #26332

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions