package com.commafeed.backend;

import java.io.IOException;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.params.CookiePolicy;
import org.apache.http.client.params.HttpClientParams;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpProtocolParams;
import org.apache.http.util.EntityUtils;

public class HttpGetter {

	public String get(String url) throws Exception {
		return new String(getBinary(url), "UTF-8");
	}

	public byte[] getBinary(String url) throws ClientProtocolException,
			IOException {
		byte[] content = null;

		HttpClient httpclient = new DefaultHttpClient();
		HttpParams params = httpclient.getParams();
		HttpClientParams.setCookiePolicy(params, CookiePolicy.IGNORE_COOKIES);
		HttpProtocolParams.setContentCharset(params, "UTF-8");
		HttpConnectionParams.setConnectionTimeout(params, 4000);
		HttpConnectionParams.setSoTimeout(params, 4000);

		try {
			HttpGet httpget = new HttpGet(url);
			httpget.addHeader("Pragma", "No-cache");
			httpget.addHeader("Cache-Control", "no-cache");
			HttpResponse response = httpclient.execute(httpget);
			HttpEntity entity = response.getEntity();
			if (entity != null) {
				content = EntityUtils.toByteArray(entity);
			}
		} finally {
			httpclient.getConnectionManager().shutdown();
		}
		return content;
	}
}

@@ -192,51 +192,8 @@
 n;%0D%0A
-import org.apache.http.client.HttpClient;%0D%0A
 impo
@@ -232,24 +232,24 @@
 s.HttpGet;%0D%0A
+
 import org.a
@@ -395,24 +395,92 @@
 ttpClient;%0D%0A
+import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;%0D%0A
 import org.a
@@ -905,24 +905,31 @@
  null;%0D%0A%0D%0A%09%09
+Default
 HttpClient h
@@ -1201,24 +1201,24 @@
 ms, 4000);%0D%0A
-
 %09%09HttpConnec
@@ -1256,16 +1256,118 @@
  4000);%0D
+%0A%09%09httpclient%0D%0A%09%09%09%09.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(%0D%0A%09%09%09%09%09%090, false));%0D
 %0A%0D%0A%09%09try

disable retry handler