IT Acumens - A Web Design Company

IT Acumens Website Designing - Discussion Community Board => Programming Discussions for Engineers => Interview FAQ's in Java => Topic started by: VelMurugan on Dec 23, 2008, 05:14 AM

Title: HttpURLConnection SetChunkedStreamingMode() Example
Post by: VelMurugan on Dec 23, 2008, 05:14 AM
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:-

Code: [Select]

/*
* @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
Title: Re: HttpURLConnection SetChunkedStreamingMode() Example
Post by: Eric Goff on Nov 02, 2011, 06:50 AM
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.