HttpURLConnection SetChunkedStreamingMode() Example

Started by VelMurugan, Dec 22, 2008, 11:44 PM

Previous topic - Next topic

VelMurugan

HttpURLConnection SetChunkedStreamingMode() Example

This method is used to enable streaming of a HTTP request body without internal buffering, when the content length is not known in advance.

HttpURLConnectionclass SetChunkedStreamingMode() method example. This example shows you how to use SetChunkedStreamingMode() method.This method is used to enable streaming of a HTTP request body without internal buffering, when the content length is not known in advance.

Here is the code:-


/*
* @Program that is used to enable streaming of a HTTP request body without
    internal buffering, when the content length is not known in advance.
* SetChunkedStreamingMode.java
* Author:-RoseIndia Team
* Date:-25-Jun-2008
*/

import java.net.*;

public class SetChunkedStreamingMode {
public static void main(String[] args) throws Exception {
        URL url = new URL("http://192.168.10.211:8080");
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        //enable streaming of a HTTP request body without internal buffering
        connection.setChunkedStreamingMode(1);
        System.out.println("HTTP request body without internal buffering is set");
}
}


Output of the program:-

HTTP request body without internal buffering is set

Source : codingdiary

Eric Goff

According to documentation, setChunkedStreamingMode's parameter is a "chunklen"
and is not a boolean type parameter.

So using "1" sounds like it is trying to send chunks "one" byte at a time.