List of usage examples for org.apache.http.impl.conn SingleClientConnManager SingleClientConnManager
@Deprecated public SingleClientConnManager(final HttpParams params, final SchemeRegistry schreg)
From source file:fr.dudie.nominatim.client.JsonNominatimClientTest.java
/** * Instantiates the test./*from w w w .j a v a2 s . c o m*/ * * @throws IOException * an error occurred during initialization */ public JsonNominatimClientTest() throws IOException { LOGGER.info("Loading configuration file {}", PROPS_PATH); final InputStream in = JsonNominatimClientTest.class.getResourceAsStream(PROPS_PATH); PROPS.load(in); LOGGER.info("Preparing http client"); final SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("http", new PlainSocketFactory(), 80)); final ClientConnectionManager connexionManager = new SingleClientConnManager(null, registry); final HttpClient httpClient = new DefaultHttpClient(connexionManager, null); final String baseUrl = PROPS.getProperty("nominatim.server.url"); final String email = PROPS.getProperty("nominatim.headerEmail"); nominatimClient = new JsonNominatimClient(baseUrl, httpClient, email); }
From source file:com.decody.android.core.json.JSONClient.java
public JSONClient(GsonFactory factory, boolean https) { this.factory = factory; if (https) {// w w w .j a v a 2 s .c om HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER; DefaultHttpClient client = new DefaultHttpClient(); SchemeRegistry registry = new SchemeRegistry(); SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory(); socketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier); registry.register(new Scheme("https", socketFactory, 443)); SingleClientConnManager mgr = new SingleClientConnManager(client.getParams(), registry); this.client = new DefaultHttpClient(mgr, client.getParams()); } else { client = new DefaultHttpClient(); } }
From source file:devza.app.android.droidnetkey.UsageAction.java
public UsageAction(Context context, TextView usage, TextView cost) { this.context = context; this.cost = cost; this.usage = usage; SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); registry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443)); //HTTP Paramaters HttpParams params = new BasicHttpParams(); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, "UTF-8"); HttpProtocolParams.setUserAgent(params, USER_AGENT); HttpConnectionParams.setConnectionTimeout(params, TIMEOUT); HttpConnectionParams.setSoTimeout(params, TIMEOUT); SingleClientConnManager cm = new SingleClientConnManager(params, registry); this.client = new DefaultHttpClient(cm, params); }
From source file:info.ajaxplorer.client.http.AjxpHttpClient.java
@Override protected ClientConnectionManager createClientConnectionManager() { SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); if (trustSelfSignedSSL) { //HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER; //socketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier); //HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier); /*/*www . j a v a2s .c o m*/ HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { public boolean verify(String hostname, SSLSession session) { return true; } });*/ registry.register(new Scheme("https", new AjxpSSLSocketFactory(), 443)); } else { SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory(); registry.register(new Scheme("https", socketFactory, 443)); } return new SingleClientConnManager(getParams(), registry); }
From source file:org.openihs.seendroid.lib.Connection.java
/** * //w w w .ja v a2 s.c om * @param message * @return * @throws ClientProtocolException * @throws IOException */ public HttpResponse query(HttpRequestBase message) throws ClientProtocolException, IOException, UnknownHostException { // SSL fixes (javax.net.ssl.SSLPeerUnverifiedException: No peer certificate) // From http://www.virtualzone.de/2011-02-27/how-to-use-apache-httpclient-with-httpsssl-on-android/ SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); schemeRegistry.register(new Scheme("https", new EasySSLSocketFactory(), 443)); HttpParams params = new BasicHttpParams(); params.setParameter(ConnManagerPNames.MAX_TOTAL_CONNECTIONS, 30); params.setParameter(ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, new ConnPerRouteBean(30)); params.setParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, false); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); ClientConnectionManager cm = new SingleClientConnManager(params, schemeRegistry); // Real code: DefaultHttpClient client = new DefaultHttpClient(cm, params); HttpResponse response = client.execute(message); return response; }
From source file:com.jute.fed4j.engine.component.http.HttpDispatcherImpl_Jakarta.java
/** * get a connection manager/*w w w .j av a 2 s.c om*/ * @param params * @return */ private ClientConnectionManager getConnectionManager(HttpParams params, boolean enablePersistentConnection) { ClientConnectionManager connectionManager; if (enablePersistentConnection) { //be careful, somehow the ThreadSafeClientConnManager dosn't perform well with high traffic if (sharedConnectionManager == null) { synchronized (locker) { if (sharedConnectionManager == null) { ConnManagerParams.setMaxTotalConnections(params, 100); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); ConnManagerParams.setTimeout(params, 10); sharedConnectionManager = new ThreadSafeClientConnManager(params, schemeRegistry); } } } connectionManager = sharedConnectionManager; } else { connectionManager = new SingleClientConnManager(params, schemeRegistry); } return connectionManager; }
From source file:de.incoherent.suseconferenceclient.app.HTTPWrapper.java
public static JSONObject get(String url) throws IllegalStateException, SocketException, UnsupportedEncodingException, IOException, JSONException { HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER; DefaultHttpClient client = new DefaultHttpClient(); SchemeRegistry registry = new SchemeRegistry(); SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory(); socketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier); registry.register(new Scheme("https", socketFactory, 443)); registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); SingleClientConnManager mgr = new SingleClientConnManager(client.getParams(), registry); DefaultHttpClient httpClient = new DefaultHttpClient(mgr, client.getParams()); HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier); HttpGet get = new HttpGet(url); HttpResponse response = httpClient.execute(get); StatusLine statusLine = response.getStatusLine(); int statusCode = statusLine.getStatusCode(); if (statusCode >= 200 && statusCode <= 299) { return HTTPWrapper.parseResponse(response); } else {/*from w w w. j a va 2 s. com*/ throw new HttpResponseException(statusCode, statusLine.getReasonPhrase()); } }
From source file:com.eTilbudsavis.etasdk.network.impl.DefaultHttpNetwork.java
private void setHostNameVerifierAndRoutePlanner(DefaultHttpClient httpClient) { // Use custom HostVerifier to accept our wildcard SSL Certificates: *.etilbudsavis.dk HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER; SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory(); socketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier); SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); registry.register(new Scheme("https", socketFactory, 443)); SingleClientConnManager mgr = new SingleClientConnManager(httpClient.getParams(), registry); httpClient = new DefaultHttpClient(mgr, httpClient.getParams()); // Change RoutePlanner to avoid SchemeRegistry causing IllegalStateException. // Some devices with faults in their default route planner httpClient.setRoutePlanner(new DefaultHttpRoutePlanner(registry)); HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier); }
From source file:Main.java
public static DefaultHttpClient setHttpPostProxyParams() { Log.d(TAG, "() default called "); SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); //schemeRegistry.register(new Scheme("https", new EasySSLSocketFactory(), 443)); HttpParams params = new BasicHttpParams(); //Log.d(TAG, "----Add Proxy---"); /*HttpHost proxy = new HttpHost(Constants.PROXY_HOST.trim(), Constants.PROXY_PORT);//from w w w . j a va 2 s .c o m params.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);*/ params.setParameter(ConnManagerPNames.MAX_TOTAL_CONNECTIONS, 30); params.setParameter(ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, new ConnPerRouteBean(30)); params.setParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, false); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); ClientConnectionManager cm = new SingleClientConnManager(params, schemeRegistry); DefaultHttpClient mHttpClient = new DefaultHttpClient(cm, params); return mHttpClient; }
From source file:pydio.sdk.java.http.AjxpHttpClient.java
@Override protected ClientConnectionManager createClientConnectionManager() { SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); if (trustSelfSignedSSL) { //HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER; //socketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier); //HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier); /*/*from w w w . j ava2s .c om*/ HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { public boolean verify(String hostname, SSLSession session) { return true; } });*/ registry.register(new Scheme("https", new AjxpSSLSocketFactory(), 443)); } else { SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory(); registry.register(new Scheme("https", socketFactory, 443)); } return new SingleClientConnManager(getParams(), registry); }