apache/libcloud — comment on commit 63b59c20beb2eb35ca651845a001840241604f3a
File: libcloud/utils/compression.py line 32
By bobveznat:

I don't think you need to break this out separately for zlib and gzip. zlib can do both. You can tell zlib to autodetect zlib vs. gzip by flipping the fifth bit in wbits. From zlib.h:

windowBits can also be greater than 15 for optional gzip decoding. Add
32 to windowBits to enable zlib and gzip decoding with automatic header
detection, or add 16 to decode only the gzip format (the zlib format will
return a Z_DATA_ERROR).

In python it looks like:

zlib.decompress(gzipped, zlib.MAX_WBITS + 32)