from time to time (especially when I have a bad connection) I obtain NonRepeatableRequestException while
sending image to server. Here is my code:
HttpParams params = new BasicHttpParams();
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("http",
PlainSocketFactory.getSocketFactory(), 80));
DefaultHttpClient httpclient = new DefaultHttpClient(new
ThreadSafeClientConnManager(params, registry), params);
HttpPost httpPost = new HttpPost(uri);
SimpleMultipartEntity multipartContent = new SimpleMultipartEntity();
multipartContent.addPart(propName, filename, inputStream,
contentType);
httpPost.setEntity(multipartContent);
httpclient.getParams().setParameter("http.protocol.expect-continue",
false);
java.util.logging.Logger.getLogger("httpclient.wire.header").setLevel(java.util.logging.Level.FINEST);
java.util.logging.Logger.getLogger("httpclient.wire.content").setLevel(java.util.logging.Level.FINEST);
HttpResponse response = httpclient.execute(httpPost);
I realized that InputStream is non-repeatable type, but have no idea how to create request properly and avoid this exception.
Any help is greatly appreciated.
found that I can add my own DefaultHttpRequestRetryHandler for my httpclient: