6952017: HttpURLConnection chunked encoding issue (Http request splitting)
authormichaelm
Mon Jul 26 10:56:06 2010 +0100 (2 years ago)
changeset 4373f8ebe7db6e0
parent 4367fe7aa39b5dc
child 4385789c4246c0c
6952017: HttpURLConnection chunked encoding issue (Http request splitting)
Reviewed-by: chegar
src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java
--- 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 @@ public class HttpURLConnection extends j
"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));
}
@@ -435,6 +438,16 @@ public class HttpURLConnection extends j
poster.close();
requests.set("Content-Length",
String.valueOf(poster.size()));
+ }
+ }
+
+ 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");
+ }
}
}
@@ -562,7 +575,7 @@ public class HttpURLConnection extends j
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 {