List of usage examples for org.apache.http.params HttpProtocolParams setVersion
public static void setVersion(HttpParams httpParams, ProtocolVersion protocolVersion)
From source file:com.supremainc.biostar2.sdk.volley.toolbox.HttpClientStack.java
public HttpClient getNewHttpClient() { try {//from ww w.j a v a 2 s . c om KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType()); trustStore.load(null, null); SSLSocketFactory sf = new MySSLSocketFactory(trustStore); sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); HttpParams params = new BasicHttpParams(); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, HTTP.UTF_8); SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); registry.register(new Scheme("https", sf, 443)); ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry); return new DefaultHttpClient(ccm, params); } catch (Exception e) { return 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:com.amalto.workbench.utils.HttpClientUtil.java
private static DefaultHttpClient createClient() { HttpParams params = new BasicHttpParams(); params.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, CONNECT_TIMEOUT); params.setParameter(CoreConnectionPNames.SO_TIMEOUT, SOCKET_TIMEOUT); params.setParameter(CoreConnectionPNames.TCP_NODELAY, false); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); return new DefaultHttpClient(cm, params); }
From source file:com.prey.net.PreyRestHttpClient.java
private PreyRestHttpClient(Context ctx) { this.ctx = ctx; httpclient = new PreyDefaultHttpClient((DefaultHttpClient) HttpUtils.getNewHttpClient()); httpclientDefault = new PreyDefaultHttpClient((DefaultHttpClient) HttpUtils.getNewHttpClient()); HttpParams params = new BasicHttpParams(); // Set the timeout in milliseconds until a connection is established. int timeoutConnection = 30000; HttpConnectionParams.setConnectionTimeout(params, timeoutConnection); // Set the default socket timeout (SO_TIMEOUT) // in milliseconds which is the timeout for waiting for data. int timeoutSocket = 50000; HttpConnectionParams.setSoTimeout(params, timeoutSocket); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, "UTF_8"); HttpProtocolParams.setUseExpectContinue(params, false); HttpParams paramsDefault = params;/*from w ww. ja va 2s . c om*/ httpclientDefault.setParams(paramsDefault); HttpProtocolParams.setUserAgent(params, getUserAgent()); httpclient.setParams(params); }
From source file:com.mymed.android.myjam.controller.CallManager.java
/** * Private constructor./*from ww w . j a v a 2 s. co m*/ * * @throws KeyManagementException * @throws NoSuchAlgorithmException * @throws KeyStoreException * @throws UnrecoverableKeyException */ private CallManager(Context context) throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException { // Create and initialize HTTP parameters HttpParams httpParams = new BasicHttpParams(); /** Sets the version of the HTTP protocol to 1.1 */ HttpProtocolParams.setVersion(httpParams, HttpVersion.HTTP_1_1); /** Sets a timeout until a request is established. [ms] */ HttpConnectionParams.setConnectionTimeout(httpParams, 10000); /** Sets a timeout for waiting for data. [ms] */ HttpConnectionParams.setSoTimeout(httpParams, 5000); /** Set the maximum number of total connections. */ ConnManagerParams.setMaxTotalConnections(httpParams, lpPoolSize + 1); /** Set the maximum number of connections per route. */ ConnManagerParams.setMaxConnectionsPerRoute(httpParams, new ConnPerRouteBean(lpPoolSize + 1)); SchemeRegistry schemeRegistry = createSchemeRegistry(context); ThreadSafeClientConnManager connManager = new ThreadSafeClientConnManager(httpParams, schemeRegistry); httpClient = new DefaultHttpClient(connManager, httpParams); lowPriorityPool = Executors.newFixedThreadPool(lpPoolSize); // highPriorityPool = Executors.newFixedThreadPool(hpPoolSize); Log.i(TAG, "Executor pool created"); }
From source file:org.accesointeligente.server.robots.SGS.java
public SGS() { client = new DefaultHttpClient(); HttpProtocolParams.setUserAgent(client.getParams(), "Mozilla/5.0 (X11; U; Linux x86_64; es-CL; rv:1.9.2.12) Gecko/20101027 Ubuntu/10.10 (maverick) Firefox/3.6.12"); HttpProtocolParams.setVersion(client.getParams(), HttpVersion.HTTP_1_0); cleaner = new HtmlCleaner(); }
From source file:org.accesointeligente.server.robots.SGSOnemi.java
public SGSOnemi() { client = new DefaultHttpClient(); HttpProtocolParams.setUserAgent(client.getParams(), "Mozilla/5.0 (X11; U; Linux x86_64; es-CL; rv:1.9.2.12) Gecko/20101027 Ubuntu/10.10 (maverick) Firefox/3.6.12"); HttpProtocolParams.setVersion(client.getParams(), HttpVersion.HTTP_1_0); cleaner = new HtmlCleaner(); }
From source file:org.silvertunnel_ng.demo.download_tool.ApacheHttpComponentsClient.java
/** * Initialize HttpComponents Client/* w w w .j a v a 2s.c om*/ * * @param lowerNetLayer TCP/IP compatible layer; * layer for SSL/TLS/https connections * will be created inside this class * and may not be passed as argument here */ public ApacheHttpComponentsClient(NetLayer lowerNetLayer) { // register the "http" protocol scheme, it is required // by the default operator to look up socket factories. SchemeRegistry schemeRegistry = new SchemeRegistry(); final int DEFAULT_PORT_HTTP = 80; schemeRegistry.register(new Scheme("http", new NetlibSocketFactory(lowerNetLayer), DEFAULT_PORT_HTTP)); /* TODO - DOES CURRENTLY NOT WORK: register the "https" protocol scheme final int DEFAULT_PORT_HTTPS = 443; NetLayer httpsLowerNetLayer = new TLSNetLayer(lowerNetLayer); schemeRegistry.register(new Scheme("https", new NetlibSocketFactory(httpsLowerNetLayer), DEFAULT_PORT_HTTPS)); */ // set http(s) client parameters HttpParams params = new BasicHttpParams(); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, "UTF-8"); if (USER_AGENT != null) { HttpProtocolParams.setUserAgent(params, USER_AGENT); } // create http(s) client ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, schemeRegistry); httpClient = new DefaultHttpClient(ccm, params); log.info("HttpComponents Client/httpClient initialized=" + httpClient.toString()); }
From source file:com.k42b3.aletheia.protocol.http.HttpProtocol.java
public HttpProtocol() { // http settings params = new SyncBasicHttpParams(); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, "UTF-8"); HttpProtocolParams.setUseExpectContinue(params, true); HttpRequestInterceptor[] interceptors = { new RequestContent(true), new RequestTargetHost(), new RequestConnControl(), new RequestExpectContinue() }; httpproc = new ImmutableHttpProcessor(interceptors); httpexecutor = new HttpRequestExecutor(); }
From source file:ch.cyberduck.core.http.HttpSession.java
protected AbstractHttpClient http(final String hostname) { if (!clients.containsKey(hostname)) { final HttpParams params = new BasicHttpParams(); HttpProtocolParams.setVersion(params, org.apache.http.HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, getEncoding()); HttpProtocolParams.setUserAgent(params, getUserAgent()); AuthParams.setCredentialCharset(params, Preferences.instance().getProperty("http.credentials.charset")); HttpConnectionParams.setTcpNoDelay(params, true); HttpConnectionParams.setSoTimeout(params, timeout()); HttpConnectionParams.setConnectionTimeout(params, timeout()); HttpConnectionParams.setSocketBufferSize(params, Preferences.instance().getInteger("http.socket.buffer")); HttpConnectionParams.setStaleCheckingEnabled(params, true); HttpClientParams.setRedirecting(params, true); HttpClientParams.setAuthenticating(params, true); HttpClientParams.setCookiePolicy(params, CookiePolicy.BEST_MATCH); // Sets the timeout in milliseconds used when retrieving a connection from the ClientConnectionManager HttpClientParams.setConnectionManagerTimeout(params, Preferences.instance().getLong("http.manager.timeout")); SchemeRegistry registry = new SchemeRegistry(); // Always register HTTP for possible use with proxy registry.register(new Scheme(ch.cyberduck.core.Scheme.http.toString(), host.getPort(), PlainSocketFactory.getSocketFactory())); registry.register(new Scheme(ch.cyberduck.core.Scheme.https.toString(), host.getPort(), new SSLSocketFactory( new CustomTrustSSLProtocolSocketFactory(this.getTrustManager()).getSSLContext(), new X509HostnameVerifier() { @Override public void verify(String host, SSLSocket ssl) throws IOException { log.warn("Hostname verification disabled for:" + host); }/*from w ww .j a v a2 s . c o m*/ @Override public void verify(String host, X509Certificate cert) throws SSLException { log.warn("Hostname verification disabled for:" + host); } @Override public void verify(String host, String[] cns, String[] subjectAlts) throws SSLException { log.warn("Hostname verification disabled for:" + host); } @Override public boolean verify(String s, javax.net.ssl.SSLSession sslSession) { log.warn("Hostname verification disabled for:" + s); return true; } }))); if (Preferences.instance().getBoolean("connection.proxy.enable")) { final Proxy proxy = ProxyFactory.get(); if (ch.cyberduck.core.Scheme.https.equals(this.getHost().getProtocol().getScheme())) { if (proxy.isHTTPSProxyEnabled(host)) { ConnRouteParams.setDefaultProxy(params, new HttpHost(proxy.getHTTPSProxyHost(host), proxy.getHTTPSProxyPort(host))); } } if (ch.cyberduck.core.Scheme.http.equals(this.getHost().getProtocol().getScheme())) { if (proxy.isHTTPProxyEnabled(host)) { ConnRouteParams.setDefaultProxy(params, new HttpHost(proxy.getHTTPProxyHost(host), proxy.getHTTPProxyPort(host))); } } } PoolingClientConnectionManager manager = new PoolingClientConnectionManager(registry); manager.setMaxTotal(Preferences.instance().getInteger("http.connections.total")); manager.setDefaultMaxPerRoute(Preferences.instance().getInteger("http.connections.route")); AbstractHttpClient http = new DefaultHttpClient(manager, params); this.configure(http); clients.put(hostname, http); } return clients.get(hostname); }