Skip to content

EventMachine::HttpDecoders::GzipHeader is unnecessary, Zlib::Inflate can do this for you #312

@drbrain

Description

@drbrain

Zlib provides automatic gzip detection for you so you don't need to skip over it by hand. From inflateInit2 in the zlib manual (also reflected in the Zlib::Inflate.new documentation):

Add 32 to windowBits to enable zlib and gzip decoding with automatic header detection, or add 16 to decode only the gzip format.

So you can replace L228 of EventMachine::HttpDecoders::Gzip with:

# zlib with automatic gzip detection
@zstream ||= Zlib::Inflate.new(32 + Zlib::MAX_WBITS)

And delete the code in GzipHeader to prevent bugs like #284/#301

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions