Help us understand the problem. What is going on with this article?


More than 5 years have passed since last update.
 * HttpClientUtitlity
public class HttpClientUtil extends DefaultHttpClient {
    private DefaultHttpClient httpClient;

    public static HttpClientUtil getInstance() {
        return new HttpClientUtil();

    private HttpClientUtil() {
        // httpsにも対応する
        SchemeRegistry schReg = new SchemeRegistry();
        schReg.register(new Scheme(HttpHost.DEFAULT_SCHEME_NAME, PlainSocketFactory.getSocketFactory(), 80));
        schReg.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));

        HttpParams httpParams;
        httpParams = new BasicHttpParams();
        HttpProtocolParams.setVersion(httpParams, HttpVersion.HTTP_1_1);
        HttpProtocolParams.setContentCharset(httpParams, HTTP.UTF_8);
        HttpConnectionParams.setConnectionTimeout(httpParams, 20000);
        HttpConnectionParams.setSoTimeout(httpParams, 20000);

        httpClient = new DefaultHttpClient(new ThreadSafeClientConnManager(httpParams, schReg), httpParams);

    public DefaultHttpClient getHttpCllient() {
        return this.httpClient;


HttpClientUtil http_util = HttpClientUtil.getInstance();
DefaultHttpClient client = http_util.getHttpCllient();
HttpGet method = new HttpGet("");
    HttpResponse response = client.execute(method);
    if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
}catch(Exception e){}
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away