Mathias,
It is a well known problem. In prehistorical times getResponseBody method has been 
made to silently discard I/O exceptions instead of propagating them back to the 
caller. We can't fix the problem without breaking the 2.0 API, so its resolution will 
have to wait until 3.0 release

We encourage HttpClient users to use getResponseBodyAsStream to process the response 
content for the time being

Oleg

-----Original Message-----
From: Mathias Cianci [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 12, 2004 3:33 PM
To: Commons HttpClient Project
Subject: Re: timeout while waiting from reponse body ?


Ok, so if I can ask stupid questions, I will not obstruct myself :o)

Here is a light version of my code :

    HttpClient client = new HttpClient();
    client.setTimeout(60000);
          
    HttpMethod method = null;
    try {
        method = new MyGetMethod(adresse);
    } catch(Exception e) {
        new Erreur("21;Erreur lors du d�codage de l'URL
    "+e.getMessage(), "Pas de code source", this);
    }

    // Execute the method.
    int statusCode = -1;
    // We will retry up to 3 times.
    for (int attempt = 0; statusCode == -1 && attempt < 3; attempt++) {
        try {
            statusCode = client.executeMethod(method);
        } catch (HttpRecoverableException e) {
            System.err.println("A recoverable exception occurred,
    retrying." + e.getMessage());
        } catch (IOException e) {
            System.err.println("Failed to download file.");
        }
    }

    // Check that we didn't run out of retries.
    if (statusCode == -1) {
        System.err.println("Failed to recover from exception.");
    }

    // Read the response body.
    try {
        byte[] responseBody = method.getResponseBody();
        leCode.set(new String(responseBody, this.getCodageUrl()));
    } catch (SocketTimeoutException e) {
        System.err.println("timeout error" + e.getMessage());
    } catch (Exception e) {
        System.out.println("mauvais encodage");
    }

    // Release the connection.
    method.releaseConnection();


The problem is that hte method.getReponseBody can't throw a
SocketTimeoutException but that's this method who is giving me problems



Kalnichevski, Oleg a �crit :

>You are more than welcome to ask any kind of HttpClient related questions
>
>Oleg
>
>-----Original Message-----
>From: Mathias Cianci [mailto:[EMAIL PROTECTED]
>Sent: Thursday, August 12, 2004 3:02 PM
>To: Commons HttpClient Project
>Subject: Re: timeout while waiting from reponse body ?
>
>
>Thank you Oleg and excuse me for asking such questions.
>I was searching with the TimeoutController class, and I've not seen the
>
>obvious answer.
>
>Kalnichevski, Oleg a �crit :
>
> 
>
>>Setting socket timeout to a positive value will do the trick
>>
>>HttpClient client = new HttpClient();
>>client.setTimeout(60000); // 60 sec timeout
>>   
>>

***************************************************************************************************
The information in this email is confidential and may be legally privileged.  Access 
to this email by anyone other than the intended addressee is unauthorized.  If you are 
not the intended recipient of this message, any review, disclosure, copying, 
distribution, retention, or any action taken or omitted to be taken in reliance on it 
is prohibited and may be unlawful.  If you are not the intended recipient, please 
reply to or forward a copy of this message to the sender and delete the message, any 
attachments, and any copies thereof from your system.
***************************************************************************************************

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to