hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Asynchronous GetMethod with getResponseBodyAsStream()
Date Sat, 19 Dec 2009 14:35:31 GMT
Alfredo Marchini wrote:
> Hi all,
> I need to find a solution for calling httpclient.executeMethod in
> non-blocking mode, so I can retrieve data with
> getResponseBodyAsStream() without waiting for the end of the execution
> of the method.
> 

HttpClient#executeMethod returns _immediately_ after having received a 
response head (that is, a status line and response headers). It does 
_not_ attempt to read the response body.


> The scenario is the following:
> I write in PHP a page that with flush method output some strings that I
> need to capture while the page are downloading.
> 
> I write in Java this code:
> 
> httpClient.executeMethod(method);
> BufferedReader reader = new BufferedReader(new
> InputStreamReader(method.getResponseBodyAsStream()));
> String line = null;
> 
> while((line = reader.readLine()) != null) {
>    System.out.println(line);
> }
> 
> This code does not resolve my problem, because the executeMethod blocks
> until all data is downloaded.

This is incorrect.

Oleg

> I need that executeMethod don't block, so I can retrieve output while
> executeMethod capture it.
> Is there a way to do this?
> Thank you very much.
> Alfredo
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message