changeset 437:3f8ebe7db6e0

6952017: HttpURLConnection chunked encoding issue (Http request splitting) Reviewed-by: chegar
author michaelm
date Mon, 26 Jul 2010 10:56:06 +0100
parents 7fe7aa39b5dc
children 5789c4246c0c
files src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java
diffstat 1 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java	Mon Jul 26 10:40:22 2010 +0100
+++ b/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java	Mon Jul 26 10:56:06 2010 +0100
@@ -422,9 +422,12 @@
                         "application/x-www-form-urlencoded");
             }
 
+            boolean chunked = false;
+
             if (streaming()) {
                 if (chunkLength != -1) {
                     requests.set ("Transfer-Encoding", "chunked");
+                    chunked = true;
                 } else {
                     requests.set ("Content-Length", String.valueOf(fixedContentLength));
                 }
@@ -438,6 +441,16 @@
                 }
             }
 
+            if (!chunked) {
+                if (requests.findValue("Transfer-Encoding") != null) {
+                    requests.remove("Transfer-Encoding");
+                    if (logger.isLoggable(Level.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();
@@ -562,7 +575,7 @@
         if (instProxy instanceof sun.net.ApplicationProxy) {
             /* Application set Proxies should not have access to cookies
              * in a secure environment unless explicitly allowed. */
-            try { 
+            try {
                 cookieHandler = CookieHandler.getDefault();
             } catch (SecurityException se) { /* swallow exception */ }
         } else {