Index: lib/http_chunks.c
===================================================================
--- lib/http_chunks.c	(revision 4)
+++ lib/http_chunks.c	(working copy)
@@ -109,6 +109,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 */
 
@@ -187,12 +189,23 @@
 
       /* Write the data portion available */
 #ifdef HAVE_LIBZ
-      switch (data->reqdata.keep.content_encoding) {
+      switch (conn->data->set.http_ce_raw ? 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_raw )
+				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;
 
@@ -304,8 +317,17 @@
           return CHUNKE_STOP;
         }
         else {
-          Curl_client_write(conn, CLIENTWRITE_HEADER,
-                            conn->trailer, conn->trlPos);
+			if ( !data->set.http_te_raw )
+				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/urldata.h
===================================================================
--- lib/urldata.h	(revision 4)
+++ lib/urldata.h	(working copy)
@@ -1250,6 +1250,9 @@
   bool ftp_skip_ip;      /* skip the IP address the FTP server passes on to
                             us */
   bool connect_only;     /* make connection, let application use the socket */
+  
+  bool http_te_raw;    /* pass the raw body data to the user, even when encoded (chunked, compressed) */
+  bool http_ce_raw;    /* pass the raw body data to the user, even when encoded (chunked, compressed) */
 };
 
 struct Names {
Index: lib/transfer.c
===================================================================
--- lib/transfer.c	(revision 4)
+++ lib/transfer.c	(working copy)
@@ -836,8 +836,12 @@
                */
               conn->bits.close = TRUE; /* close when done */
             }
+#if 1
             else if (Curl_compareheader(k->p,
                                         "Transfer-Encoding:", "chunked")) {
+#else 
+			 else if ( 0 ) {
+#endif
               /*
                * [RFC 2616, section 3.6.1] A 'chunked' transfer encoding
                * means that the server will send a series of "chunks". Each
@@ -1177,7 +1181,7 @@
                  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_raw ? IDENTITY : k->content_encoding) {
               case IDENTITY:
 #endif
                 /* This is the default when the server sends no
Index: lib/url.c
===================================================================
--- lib/url.c	(revision 4)
+++ lib/url.c	(working copy)
@@ -1673,6 +1673,21 @@
     data->set.ssl.sessionid = (bool)(0 != va_arg(param, long));
     break;
 
+  case CURLOPT_HTTP_TRANSFER_ENCODING_RAW:
+    /*
+     * raw data passed to the application when chunked transfer encoding is used
+     */
+    data->set.http_te_raw = (bool)(0 != va_arg(param, long));
+    break;
+
+  case CURLOPT_HTTP_CONTENT_ENCODING_RAW:
+    /*
+     * raw data passed to the application when content encoding is used
+     */
+    data->set.http_ce_raw = (bool)(0 != va_arg(param, long));
+    break;
+
+
   default:
     /* unknown tag and its companion, just ignore: */
     result = CURLE_FAILED_INIT; /* correct this */
Index: include/curl/curl.h
===================================================================
--- include/curl/curl.h	(revision 4)
+++ include/curl/curl.h	(working copy)
@@ -1029,6 +1029,11 @@
      enabled (== 1) */
   CINIT(SSL_SESSIONID_CACHE, LONG, 150),
 
+  /* set to non-zero to pass the raw body data to the appliction even when
+     it is encoded/compressed */
+  CINIT(HTTP_TRANSFER_ENCODING_RAW, LONG, 151),
+  CINIT(HTTP_CONTENT_ENCODING_RAW, LONG, 152),
+
   CURLOPT_LASTENTRY /* the last unused */
 } CURLoption;
 
