aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/README.encoding4
-rw-r--r--lib/content_encoding.h10
-rw-r--r--lib/transfer.c4
-rw-r--r--lib/url.c9
4 files changed, 25 insertions, 2 deletions
diff --git a/lib/README.encoding b/lib/README.encoding
index 5f878038e..d81cf50fe 100644
--- a/lib/README.encoding
+++ b/lib/README.encoding
@@ -42,7 +42,9 @@ Currently, libcurl only understands how to process responses that use the
that will work (besides "identity," which does nothing) are "deflate" and
"gzip" If a response is encoded using the "compress" or methods, libcurl will
return an error indicating that the response could not be decoded. If
-<string> is NULL or empty no Accept-Encoding header is generated.
+<string> is NULL no Accept-Encoding header is generated. If <string> is a
+zero-length string, then an Accept-Encoding header containing all supported
+encodings will be generated.
The CURLOPT_ENCODING must be set to any non-NULL value for content to be
automatically decoded. If it is not set and the server still sends encoded
diff --git a/lib/content_encoding.h b/lib/content_encoding.h
index 348ceb154..dfc7097c4 100644
--- a/lib/content_encoding.h
+++ b/lib/content_encoding.h
@@ -20,6 +20,16 @@
*
* $Id$
***************************************************************************/
+#include "setup.h"
+
+/*
+ * Comma-separated list all supported Content-Encodings ('identity' is implied)
+ */
+#ifdef HAVE_LIBZ
+#define ALL_CONTENT_ENCODINGS "deflate, gzip"
+#else
+#define ALL_CONTENT_ENCODINGS "identity"
+#endif
CURLcode Curl_unencode_deflate_write(struct SessionHandle *data,
struct Curl_transfer_keeper *k,
diff --git a/lib/transfer.c b/lib/transfer.c
index c5c2787a2..9befa5585 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -893,7 +893,9 @@ CURLcode Curl_readwrite(struct connectdata *conn,
if(k->badheader < HEADER_ALLBAD) {
/* This switch handles various content encodings. If there's an
error here, be sure to check over the almost identical code
- in http_chunks.c. 08/29/02 jhrg */
+ in http_chunks.c. 08/29/02 jhrg
+ Make sure that ALL_CONTENT_ENCODINGS contains all the
+ encodings handled here. */
#ifdef HAVE_LIBZ
switch (k->content_encoding) {
case IDENTITY:
diff --git a/lib/url.c b/lib/url.c
index 0cb690c0c..64d4c2a2d 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -106,6 +106,7 @@
#include "escape.h"
#include "strtok.h"
#include "share.h"
+#include "content_encoding.h"
/* And now for the protocols */
#include "ftp.h"
@@ -825,8 +826,16 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, ...)
case CURLOPT_ENCODING:
/*
* String to use at the value of Accept-Encoding header. 08/28/02 jhrg
+ *
+ * If the encoding is set to "" we use an Accept-Encoding header that
+ * encompasses all the encodings we support.
+ * If the encoding is set to NULL we don't send an Accept-Encoding header
+ * and ignore an received Content-Encoding header.
+ *
*/
data->set.encoding = va_arg(param, char *);
+ if(data->set.encoding && !*data->set.encoding)
+ data->set.encoding = (char*)ALL_CONTENT_ENCODINGS;
break;
case CURLOPT_USERPWD: