Paul Querna fixed libcurl to better deal with deflate content encoding when
the stream (wrongly) lacks a proper zlib header. This seems to be the case on too many actual server implementations.
This commit is contained in:
5
CHANGES
5
CHANGES
@@ -6,6 +6,11 @@
|
|||||||
|
|
||||||
Changelog
|
Changelog
|
||||||
|
|
||||||
|
Daniel (25 April 2006)
|
||||||
|
- Paul Querna fixed libcurl to better deal with deflate content encoding
|
||||||
|
when the stream (wrongly) lacks a proper zlib header. This seems to be the
|
||||||
|
case on too many actual server implementations.
|
||||||
|
|
||||||
Daniel (21 April 2006)
|
Daniel (21 April 2006)
|
||||||
- Ale Vesely fixed CURLOPT_INTERFACE when using a hostname.
|
- Ale Vesely fixed CURLOPT_INTERFACE when using a hostname.
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ This release includes the following changes:
|
|||||||
|
|
||||||
This release includes the following bugfixes:
|
This release includes the following bugfixes:
|
||||||
|
|
||||||
|
o deflate code survives lack of zlib header
|
||||||
o CURLOPT_INTERFACE works with hostname
|
o CURLOPT_INTERFACE works with hostname
|
||||||
o configure runs fine with ICC
|
o configure runs fine with ICC
|
||||||
o closed control connection with FTP when easy handle was removed from multi
|
o closed control connection with FTP when easy handle was removed from multi
|
||||||
@@ -42,6 +43,6 @@ advice from friends like these:
|
|||||||
|
|
||||||
Dan Fandrich, Ilja van Sprundel, David McCreedy, Tor Arntsen, Xavier Bouchoux,
|
Dan Fandrich, Ilja van Sprundel, David McCreedy, Tor Arntsen, Xavier Bouchoux,
|
||||||
David Byron, Michele Bini, Ates Goral, Katie Wang, Robson Braga Araujo,
|
David Byron, Michele Bini, Ates Goral, Katie Wang, Robson Braga Araujo,
|
||||||
Ale Vesely
|
Ale Vesely, Paul Querna
|
||||||
|
|
||||||
Thanks! (and sorry if I forgot to mention someone)
|
Thanks! (and sorry if I forgot to mention someone)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@@ -87,7 +87,10 @@ static CURLcode
|
|||||||
inflate_stream(struct SessionHandle *data,
|
inflate_stream(struct SessionHandle *data,
|
||||||
struct Curl_transfer_keeper *k)
|
struct Curl_transfer_keeper *k)
|
||||||
{
|
{
|
||||||
|
int allow_restart = 1;
|
||||||
z_stream *z = &k->z; /* zlib state structure */
|
z_stream *z = &k->z; /* zlib state structure */
|
||||||
|
uInt nread = z->avail_in;
|
||||||
|
Bytef *orig_in = z->next_in;
|
||||||
int status; /* zlib status */
|
int status; /* zlib status */
|
||||||
CURLcode result = CURLE_OK; /* Curl_client_write status */
|
CURLcode result = CURLE_OK; /* Curl_client_write status */
|
||||||
char *decomp; /* Put the decompressed data here. */
|
char *decomp; /* Put the decompressed data here. */
|
||||||
@@ -108,6 +111,7 @@ inflate_stream(struct SessionHandle *data,
|
|||||||
|
|
||||||
status = inflate(z, Z_SYNC_FLUSH);
|
status = inflate(z, Z_SYNC_FLUSH);
|
||||||
if (status == Z_OK || status == Z_STREAM_END) {
|
if (status == Z_OK || status == Z_STREAM_END) {
|
||||||
|
allow_restart = 0;
|
||||||
if(DSIZ - z->avail_out) {
|
if(DSIZ - z->avail_out) {
|
||||||
result = Curl_client_write(data, CLIENTWRITE_BODY, decomp,
|
result = Curl_client_write(data, CLIENTWRITE_BODY, decomp,
|
||||||
DSIZ - z->avail_out);
|
DSIZ - z->avail_out);
|
||||||
@@ -133,6 +137,19 @@ inflate_stream(struct SessionHandle *data,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (allow_restart && status == Z_DATA_ERROR) {
|
||||||
|
/* some servers seem to not generate zlib headers, so this is an attempt
|
||||||
|
to fix and continue anyway */
|
||||||
|
|
||||||
|
inflateReset(z);
|
||||||
|
if (inflateInit2(z, -MAX_WBITS) != Z_OK) {
|
||||||
|
return process_zlib_error(data, z);
|
||||||
|
}
|
||||||
|
z->next_in = orig_in;
|
||||||
|
z->avail_in = nread;
|
||||||
|
allow_restart = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
else { /* Error; exit loop, handle below */
|
else { /* Error; exit loop, handle below */
|
||||||
free(decomp);
|
free(decomp);
|
||||||
return exit_zlib(z, &k->zlib_init, process_zlib_error(data, z));
|
return exit_zlib(z, &k->zlib_init, process_zlib_error(data, z));
|
||||||
|
|||||||
Reference in New Issue
Block a user