commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Hufgard <christian.hufg...@gmx.de>
Subject Re: [httpclient]
Date Wed, 09 Aug 2006 15:28:11 GMT
Hi Trevor

> Needless to say, this does not work since by the time
> method.getResponseBodyAsStream () is called, the data has already been
> transferred.

I do not think so. This is the preferred way a response should be
read, since it does _not_ buffer the whole response in memory.

Are you shure that this code does not work? How do yo figure out the
overall response size?


Cheers,


Chris


Wednesday, August 9, 2006, 11:13:45 AM, you wrote:

> Hi All,

> I'm using HttpClient to download a simple XML document from a jsp
> page, I want to be able to show a progress bar if it takes a long
> time.

> In order to test this, i write a simple JSP with some calls to
> Thread.sleep to simulate network latency and used the following code:

>         HttpClient client = new HttpClient();
>         HttpMethod method = new
> GetMethod("http://localhost:8084/TestHTTPWeb/index.jsp");
>         try {
>             client.executeMethod (method);
>             System.out.println ("Connected, reading response.");
>             InputStream in = new BufferedInputStream(
>                           new ProgressMonitorInputStream(
>                                   this,
>                                   "Reading",
>                                   method.getResponseBodyAsStream ()));
>         } catch (IOException ex) {
>             ex.printStackTrace();
>         }

> Needless to say, this does not work since by the time
> method.getResponseBodyAsStream () is called, the data has already been
> transferred.

> Is there a way to do this?

> Regards,
> Trevor Miller

> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> commons-user-help@jakarta.apache.org



-- 
Best regards,
 Christian                            mailto:christian.hufgard@gmx.de


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message