You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Manish Moorjani <Ma...@infosys.com> on 2004/08/22 14:27:42 UTC

HttpClient Reading Partial Response

Hi,

I am using HttpClient for automatic login into third Party Applications and then fetching the page and displaying it to the end user.

The page I am trying to fetch queries the database based on a search key and fetches more than 2000 records to display on the screen.

I am using the following code to fetch the response

StringBuffer sReply =new StringBuffer("");
InputStream rbas = method.getResponseBodyAsStream();
InputStreamReader isr = new InputStreamReader (rbas, "UTF8" /* "UTF8" */);
BufferedReader br = new BufferedReader (isr);
    while ((temp = (br.readLine())) != null) {
            sReply.append(temp+ "\r\n");
        }
        String strReply=sReply.toString();
method.releaseConnection();
br.close();
isr.close();
rbas.close();
}

But as the response is large sometimes the request times out before the response is obtained.
Is there a way possible to read partial responses and displaying them on the screen ???
Or the only option is to set the timeout time to max possible ?

One more thing the records are fetched quite fast when I directly access the url

Regards,
Manish Moorjani
Infosys Technologies Ltd.
Phone: 91-44-24509530/40/50 Extn. 80395
"If you are still amazed by something you accomplished yesterday then today has been a waste"


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


Re: HttpClient Reading Partial Response

Posted by Michael Becke <be...@u.washington.edu>.
Hello Manish,

What you're doing here looks good.  It sounds like you're getting a 
socket read timeout which is caused by a large delay when reading the 
response.  I'm not sure what you mean by "read partial responses".  The 
only options I can think of are setting the SO_TIMEOUT to a higher 
value, or working on the server side to increase its performance.

Mike

On Aug 22, 2004, at 8:27 AM, Manish Moorjani wrote:

> Hi,
>
> I am using HttpClient for automatic login into third Party 
> Applications and then fetching the page and displaying it to the end 
> user.
>
> The page I am trying to fetch queries the database based on a search 
> key and fetches more than 2000 records to display on the screen.
>
> I am using the following code to fetch the response
>
> StringBuffer sReply =new StringBuffer("");
> InputStream rbas = method.getResponseBodyAsStream();
> InputStreamReader isr = new InputStreamReader (rbas, "UTF8" /* "UTF8" 
> */);
> BufferedReader br = new BufferedReader (isr);
>     while ((temp = (br.readLine())) != null) {
>             sReply.append(temp+ "\r\n");
>         }
>         String strReply=sReply.toString();
> method.releaseConnection();
> br.close();
> isr.close();
> rbas.close();
> }
>
> But as the response is large sometimes the request times out before 
> the response is obtained.
> Is there a way possible to read partial responses and displaying them 
> on the screen ???
> Or the only option is to set the timeout time to max possible ?
>
> One more thing the records are fetched quite fast when I directly 
> access the url
>
> Regards,
> Manish Moorjani
> Infosys Technologies Ltd.
> Phone: 91-44-24509530/40/50 Extn. 80395
> "If you are still amazed by something you accomplished yesterday then 
> today has been a waste"
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: 
> commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: 
> commons-httpclient-dev-help@jakarta.apache.org
>


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