JDK-6960404 : setChunkedStreamingMode does not affect chunk size when app runs on Window
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 6u10
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2010-06-10
  • Updated: 2022-07-04
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [5.1.2600]

A DESCRIPTION OF THE PROBLEM :
When trying to transfer data using chunked transfer encoding with HttpURLConnection, the value of setChunkedStreamingMode is ignored and the data is sent in one large chunk.  This only occurs on Windows platform and not Linux.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile executable test case
3. Run test case on Windows XP
4. Use network analyzer tool (e.g. tcpdump) to examine actual HTTP chunk size

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Chunk size header should be 7f9.  This translates to 2041 bytes which is 2048 bytes minus 7 bytes reserved for chunk size header and CRLF.  (This result is only found when running on Linux.)
ACTUAL -
Chunk size header is 2800.  This translates to 10240 bytes.  In other words,  all the data is sent in one chunk.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.io.*;
import java.net.*;

public class ChunkTester extends Thread {

    public static void main(String[] args) throws Exception {
        ChunkTester threadA = new ChunkTester();
        threadA.start();
    }

    public void run() {

        try {
            URL url = new URL("http://localhost:80/chunkyserver");
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setDoOutput(true);
            conn.setRequestMethod("POST");
            conn.setChunkedStreamingMode(2 * 1024); // Value here is ignored
            OutputStream os = conn.getOutputStream();
            for (int i=0; i < (10 * 1024); i++) {
                os.write('X');
            }
            os.close();
            conn.disconnect();
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Don't use Windows