Dan Fandrich changed CURLOPT_ENCODING to select all supported encodings if
authorDaniel Stenberg <daniel@haxx.se>
Mon, 12 May 2003 12:45:14 +0000 (12:45 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 12 May 2003 12:45:14 +0000 (12:45 +0000)
 set to "".  This frees the application from having to know which encodings
 the library supports.

lib/README.encoding
lib/content_encoding.h
lib/transfer.c
lib/url.c

index 5f87803..d81cf50 100644 (file)
@@ -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
index 348ceb1..dfc7097 100644 (file)
  *
  * $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, 
index c5c2787..9befa55 100644 (file)
@@ -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:
index 0cb690c..64d4c2a 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
 #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: