Index: CHANGES
===================================================================
RCS file: /cvsroot/curl/curl/CHANGES,v
retrieving revision 1.303
diff -u -r1.303 CHANGES
--- CHANGES	30 Apr 2003 20:01:22 -0000	1.303
+++ CHANGES	9 May 2003 23:32:08 -0000
@@ -6,6 +6,11 @@
 
                                   Changelog
 
+Daniel (9 May)
+- Changed CURLOPT_ENCODING to select all supported encodings if set to "".
+  This frees the application from having to know which encodings the library
+  supports.
+
 Daniel (30 Apr)
 - David Balazic made curl more RFC1738-compliant for FTP URLs, by fixing so
   that libcurl now uses one CWD command for each path part. A bunch of test
Index: docs/curl.1
===================================================================
RCS file: /cvsroot/curl/curl/docs/curl.1,v
retrieving revision 1.90
diff -u -r1.90 curl.1
--- docs/curl.1	16 Apr 2003 12:46:20 -0000	1.90
+++ docs/curl.1	9 May 2003 23:32:08 -0000
@@ -96,6 +96,10 @@
 .I http://www.openssl.org/docs/apps/ciphers.html (Option added in curl 7.9)
 
 If this option is used several times, the last one will override the others.
+.IP "--compressed"
+(HTTP) Request a compressed response using the deflate or gzip
+algorithms and return the uncompressed document.  If this option is used
+and the server sends an unsupported encoding, Curl will report an error.
 .IP "--connect-timeout <seconds>"
 Maximum time in seconds that you allow the connection to the server to take.
 This only limits the connection phase, once curl has connected this option is
Index: docs/libcurl/curl_easy_setopt.3
===================================================================
RCS file: /cvsroot/curl/curl/docs/libcurl/curl_easy_setopt.3,v
retrieving revision 1.38
diff -u -r1.38 curl_easy_setopt.3
--- docs/libcurl/curl_easy_setopt.3	11 Apr 2003 08:51:24 -0000	1.38
+++ docs/libcurl/curl_easy_setopt.3	9 May 2003 23:32:08 -0000
@@ -335,13 +335,18 @@
 .SH HTTP OPTIONS
 .TP 0.4i
 .B CURLOPT_ENCODING
-Three encodings are supported: \fIidentity\fP, which does nothing,
-\fIdeflate\fP which requests the server to compress its response using the
-zlib algorithm, and \fIgzip\fP which requests the gzip algorithm. This
-is a request, not an order; the server may or may not do it.  This
-option must be set (to any value) or else any unsolicited encoding done
-by the server is ignored. See the special file lib/README.encoding for
-details.
+Sets the contents of the Accept-Encoding: header sent in an HTTP
+request, and enables decoding of a response when a Content-Encoding:
+header is received.  Three encodings are supported: \fIidentity\fP,
+which does nothing, \fIdeflate\fP which requests the server to
+compress its response using the zlib algorithm, and \fIgzip\fP which
+requests the gzip algorithm.  If a zero-length string is set, then an
+Accept-Encoding: header containing all supported encodings is sent.
+
+This is a request, not an order; the server may or may not do it.  This
+option must be set (to any non-NULL value) or else any unsolicited
+encoding done by the server is ignored. See the special file
+lib/README.encoding for details.
 .TP
 .B CURLOPT_FOLLOWLOCATION
 A non-zero parameter tells the library to follow any Location: header that the
Index: lib/README.encoding
===================================================================
RCS file: /cvsroot/curl/curl/lib/README.encoding,v
retrieving revision 1.2
diff -u -r1.2 README.encoding
--- lib/README.encoding	11 Apr 2003 08:49:20 -0000	1.2
+++ lib/README.encoding	9 May 2003 23:32:08 -0000
@@ -42,7 +42,9 @@
 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
Index: lib/content_encoding.h
===================================================================
RCS file: /cvsroot/curl/curl/lib/content_encoding.h,v
retrieving revision 1.5
diff -u -r1.5 content_encoding.h
--- lib/content_encoding.h	11 Apr 2003 08:49:21 -0000	1.5
+++ lib/content_encoding.h	9 May 2003 23:32:08 -0000
@@ -20,6 +20,16 @@
  *
  * $Id: content_encoding.h,v 1.5 2003/04/11 08:49:21 bagder Exp $
  ***************************************************************************/
+#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, 
Index: lib/transfer.c
===================================================================
RCS file: /cvsroot/curl/curl/lib/transfer.c,v
retrieving revision 1.148
diff -u -r1.148 transfer.c
--- lib/transfer.c	1 May 2003 17:49:47 -0000	1.148
+++ lib/transfer.c	9 May 2003 23:32:08 -0000
@@ -893,7 +893,9 @@
             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:
Index: lib/url.c
===================================================================
RCS file: /cvsroot/curl/curl/lib/url.c,v
retrieving revision 1.274
diff -u -r1.274 url.c
--- lib/url.c	9 May 2003 07:39:29 -0000	1.274
+++ lib/url.c	9 May 2003 23:32:09 -0000
@@ -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 @@
   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 = ALL_CONTENT_ENCODINGS;
     break;
 
   case CURLOPT_USERPWD:
Index: src/main.c
===================================================================
RCS file: /cvsroot/curl/curl/src/main.c,v
retrieving revision 1.172
diff -u -r1.172 main.c
--- src/main.c	9 May 2003 07:39:50 -0000	1.172
+++ src/main.c	9 May 2003 23:32:09 -0000
@@ -2952,7 +2952,7 @@
 
       /* new in curl 7.10 */
       curl_easy_setopt(curl, CURLOPT_ENCODING, 
-                       (config->encoding) ? "deflate, gzip" : NULL);
+                       (config->encoding) ? "" : NULL);
 
       res = curl_easy_perform(curl);
         

