5
5
* | (__| |_| | _ <| |___
6
6
* \___|\___/|_| \_\_____|
8
* Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
8
* Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
10
10
* This software is licensed as described in the file COPYING, which
11
11
* you should have received as part of this distribution. The terms
18
18
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
19
* KIND, either express or implied.
21
* $Id: content_encoding.c,v 1.34 2009-08-29 03:42:13 gknauf Exp $
21
* $Id: content_encoding.c,v 1.36 2010-02-09 09:35:48 bagder Exp $
22
22
***************************************************************************/
40
40
(doing so will reduce code size slightly). */
41
41
#define OLD_ZLIB_SUPPORT 1
43
#define DSIZ 0x10000 /* buffer size for decompressed data */
43
#define DSIZ CURL_MAX_WRITE_SIZE /* buffer size for decompressed data */
45
45
#define GZIP_MAGIC_0 0x1f
46
46
#define GZIP_MAGIC_1 0x8b
282
282
if(strcmp(zlibVersion(), "1.2.0.4") >= 0) {
283
/* zlib ver. >= 1.2.0.4 supports transparent gzip decompressing */
284
if(inflateInit2(z, MAX_WBITS+32) != Z_OK) {
285
return process_zlib_error(conn, z);
287
k->zlib_init = ZLIB_INIT_GZIP; /* Transparent gzip decompress state */
290
/* we must parse the gzip header ourselves */
291
if(inflateInit2(z, -MAX_WBITS) != Z_OK) {
292
return process_zlib_error(conn, z);
294
k->zlib_init = ZLIB_INIT; /* Initial call state */
283
/* zlib ver. >= 1.2.0.4 supports transparent gzip decompressing */
284
if(inflateInit2(z, MAX_WBITS+32) != Z_OK) {
285
return process_zlib_error(conn, z);
287
k->zlib_init = ZLIB_INIT_GZIP; /* Transparent gzip decompress state */
290
/* we must parse the gzip header ourselves */
291
if(inflateInit2(z, -MAX_WBITS) != Z_OK) {
292
return process_zlib_error(conn, z);
294
k->zlib_init = ZLIB_INIT; /* Initial call state */
298
298
if(k->zlib_init == ZLIB_INIT_GZIP) {
299
/* Let zlib handle the gzip decompression entirely */
300
z->next_in = (Bytef *)k->str;
301
z->avail_in = (uInt)nread;
302
/* Now uncompress the data */
303
return inflate_stream(conn, k);
299
/* Let zlib handle the gzip decompression entirely */
300
z->next_in = (Bytef *)k->str;
301
z->avail_in = (uInt)nread;
302
/* Now uncompress the data */
303
return inflate_stream(conn, k);
306
306
#ifndef OLD_ZLIB_SUPPORT