Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions lib/content_encoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@

#ifdef HAVE_LIBZ

#if !defined(ZLIB_VERNUM) || (ZLIB_VERNUM < 0x1204)
#error "requires zlib 1.2.0.4 or newer"
#endif

typedef enum {
ZLIB_UNINIT, /* uninitialized */
ZLIB_INIT, /* initialized */
Expand Down Expand Up @@ -309,24 +313,15 @@ static CURLcode gzip_do_init(struct Curl_easy *data,
{
struct zlib_writer *zp = (struct zlib_writer *) writer;
z_stream *z = &zp->z; /* zlib state structure */
const char *v = zlibVersion();

/* Initialize zlib */
z->zalloc = (alloc_func) zalloc_cb;
z->zfree = (free_func) zfree_cb;

if(strcmp(v, "1.2.0.4") >= 0) {
/* zlib version >= 1.2.0.4 supports transparent gzip decompressing */
if(inflateInit2(z, MAX_WBITS + 32) != Z_OK) {
return process_zlib_error(data, z);
}
zp->zlib_init = ZLIB_INIT_GZIP; /* Transparent gzip decompress state */
}
else {
failf(data, "too old zlib version: %s", v);
return CURLE_FAILED_INIT;
}
if(inflateInit2(z, MAX_WBITS + 32) != Z_OK)
return process_zlib_error(data, z);

zp->zlib_init = ZLIB_INIT_GZIP; /* Transparent gzip decompress state */
return CURLE_OK;
}

Expand Down
Loading