Index: docs/libcurl/curl_easy_setopt.3
===================================================================
RCS file: /cvsroot/curl/curl/docs/libcurl/curl_easy_setopt.3,v
retrieving revision 1.168
diff -u -r1.168 curl_easy_setopt.3
--- docs/libcurl/curl_easy_setopt.3	5 Feb 2007 22:51:32 -0000	1.168
+++ docs/libcurl/curl_easy_setopt.3	6 Feb 2007 16:08:05 -0000
@@ -816,6 +816,16 @@
 progress, and will simply stop the download when the server ends the
 connection. (added in 7.14.1)
 .RE
+.IP CURLOPT_HTTP_TRANSFER_DECODING      
+Pass a long set to 0 to disable libcurl's internal decoding of transfer
+encoded data. By default, libcurl will automatically decode chunked transfer
+encoded streams. (Added in 7.16.2)
+.IP CURLOPT_HTTP_CONTENT_DECODING
+Pass a long set to 0 to disable libcurl's internal decoding of content encoded
+data. By default, libcurl will not automatically decode content encoded
+streams but will only do so if \fICURLOPT_ENCODING\fP is used, but
+\fICURLOPT_HTTP_CONTENT_ENCODING\fP set to 0 will override that one. (Added in
+7.16.2)
 .SH FTP OPTIONS
 .IP CURLOPT_FTPPORT
 Pass a pointer to a zero terminated string as parameter. It will be used to
Index: include/curl/curl.h
===================================================================
RCS file: /cvsroot/curl/curl/include/curl/curl.h,v
retrieving revision 1.314
diff -u -r1.314 curl.h
--- include/curl/curl.h	5 Feb 2007 22:51:32 -0000	1.314
+++ include/curl/curl.h	6 Feb 2007 16:08:05 -0000
@@ -1058,6 +1058,11 @@
   CINIT(TIMEOUT_MS, LONG, 155),
   CINIT(CONNECTTIMEOUT_MS, LONG, 156),
 
+  /* set to zero to disable the libcurl's decoding and thus pass the raw body
+     data to the appliction even when it is encoded/compressed */
+  CINIT(HTTP_TRANSFER_DECODING, LONG, 157),
+  CINIT(HTTP_CONTENT_DECODING, LONG, 158),
+
   CURLOPT_LASTENTRY /* the last unused */
 } CURLoption;
 
Index: lib/http_chunks.c
===================================================================
RCS file: /cvsroot/curl/curl/lib/http_chunks.c,v
retrieving revision 1.33
diff -u -r1.33 http_chunks.c
--- lib/http_chunks.c	16 Jan 2007 22:26:50 -0000	1.33
+++ lib/http_chunks.c	6 Feb 2007 16:08:06 -0000
@@ -113,6 +113,8 @@
   size_t piece;
   size_t length = (size_t)datalen;
   size_t *wrote = (size_t *)wrotep;
+  size_t origdatalen = datalen;
+  char* origdatap = datap;
 
   *wrote = 0; /* nothing's written yet */
 
@@ -206,12 +208,24 @@
 
       /* Write the data portion available */
 #ifdef HAVE_LIBZ
-      switch (data->reqdata.keep.content_encoding) {
+      switch (conn->data->set.http_ce_skip?
+              IDENTITY : data->reqdata.keep.content_encoding) {
         case IDENTITY:
 #endif
-          if(!k->ignorebody)
-            result = Curl_client_write(conn, CLIENTWRITE_BODY, datap,
-                                       piece);
+          if(!k->ignorebody) {
+            if ( !data->set.http_te_skip )
+              result = Curl_client_write(conn, CLIENTWRITE_BODY, datap,
+                                         piece);
+            else {
+              if ( origdatalen ) {
+                result = Curl_client_write(conn, CLIENTWRITE_BODY,
+                                           origdatap, origdatalen);
+                origdatalen = 0; /* to avoid writing twice */
+              }
+              else
+                result = CURLE_OK;
+            }
+          }
 #ifdef HAVE_LIBZ
           break;
 
@@ -334,8 +348,13 @@
             return(CHUNKE_BAD_CHUNK);
           }
 #endif /* CURL_DOES_CONVERSIONS */
-          Curl_client_write(conn, CLIENTWRITE_HEADER,
-                            conn->trailer, conn->trlPos);
+          if ( !data->set.http_te_skip )
+            Curl_client_write(conn, CLIENTWRITE_HEADER,
+                              conn->trailer, conn->trlPos);
+          else if ( origdatalen ) {
+            Curl_client_write(conn, CLIENTWRITE_BODY, origdatap,origdatalen);
+            origdatalen = 0; /* to avoid writing twice */
+          }
         }
         ch->state = CHUNK_TRAILER;
         conn->trlPos=0;
Index: lib/transfer.c
===================================================================
RCS file: /cvsroot/curl/curl/lib/transfer.c,v
retrieving revision 1.333
diff -u -r1.333 transfer.c
--- lib/transfer.c	5 Feb 2007 22:51:33 -0000	1.333
+++ lib/transfer.c	6 Feb 2007 16:08:06 -0000
@@ -1286,7 +1286,8 @@
                  Make sure that ALL_CONTENT_ENCODINGS contains all the
                  encodings handled here. */
 #ifdef HAVE_LIBZ
-              switch (k->content_encoding) {
+              switch (conn->data->set.http_ce_skip ?
+                      IDENTITY : k->content_encoding) {
               case IDENTITY:
 #endif
                 /* This is the default when the server sends no
Index: lib/url.c
===================================================================
RCS file: /cvsroot/curl/curl/lib/url.c,v
retrieving revision 1.583
diff -u -r1.583 url.c
--- lib/url.c	5 Feb 2007 22:51:33 -0000	1.583
+++ lib/url.c	6 Feb 2007 16:08:07 -0000
@@ -1725,6 +1725,19 @@
     data->set.ssh_private_key = va_arg(param, char *);
     break;
 
+  case CURLOPT_HTTP_TRANSFER_DECODING:
+    /*
+     * disable libcurl transfer encoding is used
+     */
+    data->set.http_te_skip = (bool)(0 == va_arg(param, long));
+    break;
+
+  case CURLOPT_HTTP_CONTENT_DECODING:
+    /*
+     * raw data passed to the application when content encoding is used
+     */
+    data->set.http_ce_skip = (bool)(0 == va_arg(param, long));
+    break;
   default:
     /* unknown tag and its companion, just ignore: */
     result = CURLE_FAILED_INIT; /* correct this */
Index: lib/urldata.h
===================================================================
RCS file: /cvsroot/curl/curl/lib/urldata.h,v
retrieving revision 1.318
diff -u -r1.318 urldata.h
--- lib/urldata.h	5 Feb 2007 22:51:34 -0000	1.318
+++ lib/urldata.h	6 Feb 2007 16:08:08 -0000
@@ -1288,10 +1288,14 @@
                             us */
   bool connect_only;     /* make connection, let application use the socket */
   long ssh_auth_types;   /* allowed SSH auth types */
-  char *ssh_public_key;   /* the path to the public key file for
-                             authentication */
-  char *ssh_private_key;  /* the path to the private key file for
-                             authentication */
+  char *ssh_public_key;  /* the path to the public key file for
+                            authentication */
+  char *ssh_private_key; /* the path to the private key file for
+                            authentication */
+  bool http_te_skip;     /* pass the raw body data to the user, even when
+                            transfer-encoded (chunked, compressed) */
+  bool http_ce_skip;     /* pass the raw body data to the user, even when
+                            content-encoded (chunked, compressed) */
 };
 
 struct Names {
Index: src/main.c
===================================================================
RCS file: /cvsroot/curl/curl/src/main.c,v
retrieving revision 1.390
diff -u -r1.390 main.c
--- src/main.c	27 Jan 2007 23:02:18 -0000	1.390
+++ src/main.c	6 Feb 2007 16:08:09 -0000
@@ -453,24 +453,19 @@
   bool ftp_ssl_reqd;
   bool ftp_ssl_control;
   bool ftp_ssl_ccc;
-
   char *socksproxy; /* set to server string */
   int socksver;     /* set to CURLPROXY_SOCKS* define */
-
   bool tcp_nodelay;
   long req_retry;   /* number of retries */
   long retry_delay; /* delay between retries (in seconds) */
   long retry_maxtime; /* maximum time to keep retrying */
-
   char *ftp_account; /* for ACCT */
   char *ftp_alternative_to_user; /* send command if USER/PASS fails */
   int ftp_filemethod;
-
   bool ignorecl; /* --ignore-content-length */
   bool disable_sessionid;
-
   char *libcurl; /* output libcurl code to this file name */
-
+  bool raw;
   struct OutStruct *outs;
 };
 
@@ -683,6 +678,7 @@
     " -Q/--quote <cmd>   Send command(s) to server before file transfer (F)",
     " -r/--range <range> Retrieve a byte range from a HTTP/1.1 or FTP server",
     "    --random-file <file> File for reading random data from (SSL)",
+    "    --raw           Pass HTTP \"raw\", without any transfer decoding (H)",
     " -R/--remote-time   Set the remote file's time on the local output",
     "    --retry <num>   Retry request <num> times if transient problems occur",
     "    --retry-delay <seconds> When retrying, wait this many seconds between each",
@@ -1473,6 +1469,7 @@
     {"$x", "ftp-ssl-control", FALSE},
     {"$y", "ftp-ssl-ccc", FALSE},
     {"$z", "libcurl",    TRUE},
+    {"$#", "raw",        FALSE},
 
     {"0", "http1.0",     FALSE},
     {"1", "tlsv1",       FALSE},
@@ -1903,6 +1900,9 @@
       case 'z': /* --libcurl */
         GetStr(&config->libcurl, nextarg);
         break;
+      case '#': /* --raw */
+        config->raw ^= TRUE;
+        break;
       }
       break;
     case '#': /* --progress-bar */
@@ -4253,6 +4253,12 @@
         my_setopt(curl, CURLOPT_SSL_SESSIONID_CACHE,
                   !config->disable_sessionid);
 
+        /* curl 7.16.2 */
+        if(config->raw) {
+          my_setopt(curl, CURLOPT_HTTP_CONTENT_DECODING, FALSE);
+          my_setopt(curl, CURLOPT_HTTP_TRANSFER_DECODING, FALSE);
+        }
+
         retry_numretries = config->req_retry;
 
         retrystart = curlx_tvnow();
