Commit c0197f19 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

Dan Fandrich changed CURLOPT_ENCODING to select all supported encodings if

 set to "".  This frees the application from having to know which encodings
 the library supports.
parent 3994d67e
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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
+10 −0
Original line number Diff line number Diff line
@@ -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, 
+3 −1
Original line number Diff line number Diff line
@@ -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:
+9 −0
Original line number Diff line number Diff line
@@ -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: