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	12 Feb 2007 10:43:42 -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	12 Feb 2007 10:43:42 -0000
@@ -116,6 +116,12 @@
 
   *wrote = 0; /* nothing's written yet */
 
+  /* the original data is written to the client, but we go on with the
+     chunk read process, to properly calculate the content length*/
+  if ( data->set.http_te_skip )
+    Curl_client_write(conn, CLIENTWRITE_BODY, datap,datalen);
+
+
   while(length) {
     switch(ch->state) {
     case CHUNK_HEX:
@@ -206,12 +212,17 @@
 
       /* 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
+              result = CURLE_OK;
+          }
 #ifdef HAVE_LIBZ
           break;
 
@@ -334,6 +345,7 @@
             return(CHUNKE_BAD_CHUNK);
           }
 #endif /* CURL_DOES_CONVERSIONS */
+          if ( !data->set.http_te_skip )
           Curl_client_write(conn, CLIENTWRITE_HEADER,
                             conn->trailer, conn->trlPos);
         }
Index: lib/transfer.c
===================================================================
RCS file: /cvsroot/curl/curl/lib/transfer.c,v
retrieving revision 1.334
diff -u -r1.334 transfer.c
--- lib/transfer.c	6 Feb 2007 18:06:37 -0000	1.334
+++ lib/transfer.c	12 Feb 2007 10:43:44 -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	12 Feb 2007 10:43:49 -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	12 Feb 2007 10:43:51 -0000
@@ -1292,6 +1292,10 @@
                              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  12 Feb 2007 11:04:55 -0000
@@ -20,7 +20,6 @@
  *
  * $Id: main.c,v 1.390 2007-01-27 23:02:18 bagder Exp $
  ***************************************************************************/
-
 #include "setup.h"
 
 #include <stdio.h>
@@ -470,7 +469,7 @@
   bool disable_sessionid;
 
   char *libcurl; /* output libcurl code to this file name */
-
+  bool raw;
   struct OutStruct *outs;
 };
 
@@ -683,6 +682,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 +1473,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 +1904,9 @@
       case 'z': /* --libcurl */
         GetStr(&config->libcurl, nextarg);
         break;
+      case '#': /* --raw */
+        config->raw ^= TRUE;
+        break;
       }
       break;
     case '#': /* --progress-bar */
@@ -4253,6 +4257,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();
