summaryrefslogtreecommitdiff
path: root/libs/libcurl/src/content_encoding.c
diff options
context:
space:
mode:
Diffstat (limited to 'libs/libcurl/src/content_encoding.c')
-rw-r--r--libs/libcurl/src/content_encoding.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/libs/libcurl/src/content_encoding.c b/libs/libcurl/src/content_encoding.c
index 5f1a8089e9..b185890df9 100644
--- a/libs/libcurl/src/content_encoding.c
+++ b/libs/libcurl/src/content_encoding.c
@@ -65,12 +65,15 @@
/* allow no more than 5 "chained" compression steps */
#define MAX_ENCODE_STACK 5
+
+#if defined(HAVE_LIBZ) || defined(HAVE_BROTLI) || defined(HAVE_ZSTD)
#define DECOMPRESS_BUFFER_SIZE 16384 /* buffer size for decompressed data */
+#endif
#ifdef HAVE_LIBZ
-#if !defined(ZLIB_VERNUM) || (ZLIB_VERNUM < 0x1204)
-#error "requires zlib 1.2.0.4 or newer"
+#if !defined(ZLIB_VERNUM) || (ZLIB_VERNUM < 0x1252)
+#error "requires zlib 1.2.5.2 or newer"
#endif
typedef enum {
@@ -163,7 +166,7 @@ static CURLcode inflate_stream(struct Curl_easy *data,
struct zlib_writer *zp = (struct zlib_writer *) writer;
z_stream *z = &zp->z; /* zlib state structure */
uInt nread = z->avail_in;
- Bytef *orig_in = z->next_in;
+ z_const Bytef *orig_in = z->next_in;
bool done = FALSE;
CURLcode result = CURLE_OK; /* Curl_client_write status */
@@ -183,13 +186,7 @@ static CURLcode inflate_stream(struct Curl_easy *data,
z->next_out = (Bytef *) zp->buffer;
z->avail_out = DECOMPRESS_BUFFER_SIZE;
-#ifdef Z_BLOCK
- /* Z_BLOCK is only available in zlib ver. >= 1.2.0.5 */
status = inflate(z, Z_BLOCK);
-#else
- /* fallback for zlib ver. < 1.2.0.5 */
- status = inflate(z, Z_SYNC_FLUSH);
-#endif
/* Flush output data if some. */
if(z->avail_out != DECOMPRESS_BUFFER_SIZE) {
@@ -220,9 +217,7 @@ static CURLcode inflate_stream(struct Curl_easy *data,
/* some servers seem to not generate zlib headers, so this is an attempt
to fix and continue anyway */
if(zp->zlib_init == ZLIB_INIT) {
- /* Do not use inflateReset2(): only available since zlib 1.2.3.4. */
- (void) inflateEnd(z); /* do not care about the return code */
- if(inflateInit2(z, -MAX_WBITS) == Z_OK) {
+ if(inflateReset2(z, -MAX_WBITS) == Z_OK) {
z->next_in = orig_in;
z->avail_in = nread;
zp->zlib_init = ZLIB_INFLATING;
@@ -278,8 +273,8 @@ static CURLcode deflate_do_write(struct Curl_easy *data,
return Curl_cwriter_write(data, writer->next, type, buf, nbytes);
/* Set the compressed input when this function is called */
- z->next_in = (Bytef *) buf;
- z->avail_in = (uInt) nbytes;
+ z->next_in = (z_const Bytef *)buf;
+ z->avail_in = (uInt)nbytes;
if(zp->zlib_init == ZLIB_EXTERNAL_TRAILER)
return process_trailer(data, zp);
@@ -337,8 +332,8 @@ static CURLcode gzip_do_write(struct Curl_easy *data,
if(zp->zlib_init == ZLIB_INIT_GZIP) {
/* Let zlib handle the gzip decompression entirely */
- z->next_in = (Bytef *) buf;
- z->avail_in = (uInt) nbytes;
+ z->next_in = (z_const Bytef *)buf;
+ z->avail_in = (uInt)nbytes;
/* Now uncompress the data */
return inflate_stream(data, writer, type, ZLIB_INIT_GZIP);
}
@@ -755,7 +750,7 @@ CURLcode Curl_build_unencoding_stack(struct Curl_easy *data,
name = enclist;
for(namelen = 0; *enclist && *enclist != ','; enclist++)
- if(!ISSPACE(*enclist))
+ if(*enclist > ' ')
namelen = enclist - name + 1;
if(namelen) {