changeset 3052:e857e8316bf1

6952017: HttpURLConnection chunked encoding issue (Http request splitting) Reviewed-by: chegar
author michaelm
date Thu, 22 Jul 2010 17:26:33 +0100
parents e860d935e6e7
children 9fa1f8b38b6f
files src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java	Thu Jul 22 16:33:12 2010 +0100
+++ b/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java	Thu Jul 22 17:26:33 2010 +0100
@@ -463,9 +463,12 @@
                         "application/x-www-form-urlencoded");
             }
 
+            boolean chunked = false;
+
             if (streaming()) {
                 if (chunkLength != -1) {
                     requests.set ("Transfer-Encoding", "chunked");
+                    chunked = true;
                 } else { /* fixed content length */
                     if (fixedContentLengthLong != -1) {
                         requests.set ("Content-Length",
@@ -485,6 +488,16 @@
                 }
             }
 
+            if (!chunked) {
+                if (requests.findValue("Transfer-Encoding") != null) {
+                    requests.remove("Transfer-Encoding");
+                    if (logger.isLoggable(PlatformLogger.WARNING)) {
+                        logger.warning(
+                            "use streaming mode for chunked encoding");
+                    }
+                }
+            }
+
             // get applicable cookies based on the uri and request headers
             // add them to the existing request headers
             setCookieHeader();