/*******************************************************************************
* Copyright (c) 2011 Jordan Thoms.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package biz.shadowservices.DegreesToolbox;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
public class HttpClientSingleton {
// This allows us to keep track of a single instance of HttpClient, so the cookies get collected in it.
private static HttpClient instance = null;
private HttpClientSingleton() { }
public static HttpClient getInstance() {
if (instance == null) {
instance = new DefaultHttpClient();
HttpParams httpParams = instance.getParams();
HttpConnectionParams.setConnectionTimeout(httpParams, Values.TIMEOUT);
HttpConnectionParams.setSoTimeout(httpParams, Values.TIMEOUT);
}
return instance;
}
}