public HttpClientProvider() { httpClient = SystemUtils.createHttpClient(); HttpConnectionParams.setConnectionTimeout(httpClient.getParams(), DEFAULT_CONNECT_TIMEOUT); HttpConnectionParams.setSoTimeout(httpClient.getParams(), DEFAULT_SOCKET_TIMEOUT); ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner(httpClient.getConnectionManager().getSchemeRegistry(), ProxySelector.getDefault()); httpClient.setRoutePlanner(routePlanner); httpClient.setKeepAliveStrategy(new ConnectionKeepAliveStrategy(DEFAULT_CONNECTION_KEEP_ALIVE_DURATION)); cachingHttpClient = new EtagCachingHttpClient(httpClient, createStorage()); }
private void setDefaultProxy() { HttpHost currentProxy = ( HttpHost )client.getParams().getParameter( ConnRoutePNames.DEFAULT_PROXY ); if ( currentProxy == null ) { ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner( client.getConnectionManager().getSchemeRegistry(), ProxySelector.getDefault() ); client.setRoutePlanner( routePlanner ); } }
private static HttpClient newDefaultHttpClient(SSLSocketFactory socketFactory, HttpParams params, ProxySelector proxySelector) { SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); registry.register(new Scheme("https", socketFactory, 443)); ClientConnectionManager connectionManager = new ThreadSafeClientConnManager(params, registry); DefaultHttpClient httpClient = new DefaultHttpClient(connectionManager, params); httpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(0, false)); httpClient.setRoutePlanner(new ProxySelectorRoutePlanner(registry, proxySelector)); return httpClient; }
public static DefaultHttpClient createHttpClient() { HttpParams httpParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParams, 60000);// was 10000 HttpConnectionParams.setSoTimeout(httpParams, 60000);// was 30000 DefaultHttpClient httpClient = new DefaultHttpClient(httpParams); // http-proxy ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner( httpClient.getConnectionManager().getSchemeRegistry(), ProxySelector.getDefault()); httpClient.setRoutePlanner(routePlanner); return httpClient; }
public NominatimGeocoderService() { // Honor the JRE's HTTP proxy settings final ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner( m_httpClient.getConnectionManager().getSchemeRegistry(), ProxySelector.getDefault() ); m_httpClient.setRoutePlanner(routePlanner); }
/** * Configures the HTTP client. By default, it try to set the retry handler. * * @param httpClient * The HTTP client to configure. */ protected void configure(DefaultHttpClient httpClient) { if (getRetryHandler() != null) { try { HttpRequestRetryHandler retryHandler = (HttpRequestRetryHandler) Engine.loadClass(getRetryHandler()).newInstance(); this.httpClient.setHttpRequestRetryHandler(retryHandler); } catch (Exception e) { getLogger().log(Level.WARNING, "An error occurred during the instantiation of the retry handler.", e); } } ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner(httpClient.getConnectionManager().getSchemeRegistry(), ProxySelector .getDefault()); httpClient.setRoutePlanner(routePlanner); }
private void initProxyAwareClient() { ClientConnectionManager connectionManager = httpclient.getConnectionManager(); SchemeRegistry schemeRegistry = connectionManager.getSchemeRegistry(); ProxySelector defaultProxySelector = ProxySelector.getDefault(); ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner(schemeRegistry, defaultProxySelector); httpclient.setRoutePlanner(routePlanner); httpclient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, timeout); }
@Override protected HttpRoutePlanner createHttpRoutePlanner() { return new ProxySelectorRoutePlanner(getConnectionManager().getSchemeRegistry(), ProxySelector.getDefault()); }
private DefaultHttpClient createHttpClientWithProxy() { DefaultHttpClient client = new DefaultHttpClient(); ProxySelector proxySelector = ProxySelector.getDefault(); client.setRoutePlanner(new ProxySelectorRoutePlanner(client.getConnectionManager().getSchemeRegistry(), proxySelector)); return client; }