Code example for DefaultHttpRequestRetryHandler

0
		supportedSchemes.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
		supportedSchemes.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
		final HttpParams httpParams = createHttpParams();
		final ThreadSafeClientConnManager tccm = new ThreadSafeClientConnManager(httpParams, supportedSchemes);
		DefaultHttpClient client = new DefaultHttpClient(tccm, httpParams);
		client.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(2, true));
		return client;
	} 
	 
	private HttpParams createHttpParams() {
		final HttpParams params = new BasicHttpParams();
		HttpConnectionParams.setStaleCheckingEnabled(params, false);
		HttpConnectionParams.setConnectionTimeout(params, 45000);
		HttpConnectionParams.setSoTimeout(params, 100000);
		HttpConnectionParams.setSocketBufferSize(params, 8192);
		HttpConnectionParams.setTcpNoDelay(params, true);
		HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
		HttpProtocolParams.setUseExpectContinue(params, false);
		HttpClientParams.setRedirecting(params, false);
		ConnManagerParams.setMaxTotalConnections(params, 50);
		ConnManagerParams.setTimeout(params, 30000);