On Tue, 2009-03-24 at 08:51 +0530, Subhash Chandran wrote:
> We are getting this Exception:
> 
> <quote>
> Exception in thread "main" org.apache.http.client.ClientProtocolException
>       at 
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:557)
>       at 
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
>       at 
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
>       at it.sella.iq.Main.main(Main.java:63)
> Caused by: org.apache.http.client.NonRepeatableRequestException:
> Cannot retry request with a non-repeatable request entity
>       at 
> org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:402)
>       at 
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
>       ... 3 more
> </quote>
> 
> when we are trying to send Multi-part messages like this:
> 
> <quote>
> File f = ...;
> DefaultHttpClient httpclient = new DefaultHttpClient();
> 
> MultipartEntity entity = new MultipartEntity();
> 
> entity.addPart("file", new InputStreamBody(new FileInputStream(f),
> f.getName()));
> </quote>
> 
> We tried adding:
> 
> <quote>
> httpclient.setHttpRequestRetryHandler(new
> DefaultHttpRequestRetryHandler(0, false));
> </quote>
> 
> This also does not help. How do we fix this?
> 
> Additional Info: when we are using FileBody instead of
> InputStreamBody, the code is working fine.
> 

This exception makes perfect sense. FileBody is repeatable, as a File
can be read from multiple times. InputStreamBody is not repeatable,
because an InputStream can be read from only once.

You basically have two options: (1) use repeatable ContentBody
implementations only or (2) make sure the request does not need to be
retried. Please note the latter is not always possible. Request retries
due to authentication failures can be avoided, but those due to I/O
errors cannot.

Hope this helps.

Oleg



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to