Search in sources :

Example 51 with HttpParams

use of org.apache.http.params.HttpParams in project SeaStar by 13120241790.

the class SyncHttpClient method setMaxConnections.

/**
	 * Sets maximum limit of parallel connections
	 * 
	 * @param maxConnections
	 *            maximum parallel connections, must be at least 1
	 */
public void setMaxConnections(int maxConnections) {
    if (maxConnections < 1)
        maxConnections = DEFAULT_MAX_CONNECTIONS;
    this.maxConnections = maxConnections;
    final HttpParams httpParams = this.httpClient.getParams();
    ConnManagerParams.setMaxConnectionsPerRoute(httpParams, new ConnPerRouteBean(this.maxConnections));
}
Also used : BasicHttpParams(org.apache.http.params.BasicHttpParams) HttpParams(org.apache.http.params.HttpParams) ConnPerRouteBean(org.apache.http.conn.params.ConnPerRouteBean)

Example 52 with HttpParams

use of org.apache.http.params.HttpParams in project SeaStar by 13120241790.

the class SyncHttpClient method setProxy.

/**
	 * Sets the Proxy by it's hostname and port
	 * 
	 * @param hostname
	 *            the hostname (IP or DNS name)
	 * @param port
	 *            the port number. -1 indicates the scheme default port.
	 */
public void setProxy(String hostname, int port) {
    final HttpHost proxy = new HttpHost(hostname, port);
    final HttpParams httpParams = this.httpClient.getParams();
    httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
}
Also used : BasicHttpParams(org.apache.http.params.BasicHttpParams) HttpParams(org.apache.http.params.HttpParams) HttpHost(org.apache.http.HttpHost)

Example 53 with HttpParams

use of org.apache.http.params.HttpParams in project nhin-d by DirectProject.

the class HttpClientFactory method createHttpClient.

/**
	 * Creates an HttpClient with the default connection timeout and SO timeout.
	 * @return The HTTP client.
	 */
public static HttpClient createHttpClient() {
    final HttpClient client = new DefaultHttpClient(conMgr);
    final HttpParams httpParams = client.getParams();
    HttpConnectionParams.setConnectionTimeout(httpParams, DEFAULT_CON_TIMEOUT);
    HttpConnectionParams.setSoTimeout(httpParams, DEFAULT_SO_TIMEOUT);
    return client;
}
Also used : HttpParams(org.apache.http.params.HttpParams) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) HttpClient(org.apache.http.client.HttpClient) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient)

Example 54 with HttpParams

use of org.apache.http.params.HttpParams in project nhin-d by DirectProject.

the class HttpClientFactory method createHttpClient.

/**
	 * Creates an HttpClient with a specific connection timeout and SO timeout.
	 * @return The HTTP client.
	 */
public static HttpClient createHttpClient(int conTimeOut, int soTimeout) {
    final HttpClient client = new DefaultHttpClient(conMgr);
    final HttpParams httpParams = client.getParams();
    HttpConnectionParams.setConnectionTimeout(httpParams, conTimeOut);
    HttpConnectionParams.setSoTimeout(httpParams, soTimeout);
    return client;
}
Also used : HttpParams(org.apache.http.params.HttpParams) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) HttpClient(org.apache.http.client.HttpClient) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient)

Example 55 with HttpParams

use of org.apache.http.params.HttpParams in project xUtils by wyouflf.

the class HttpUtils method configSoTimeout.

public HttpUtils configSoTimeout(int timeout) {
    final HttpParams httpParams = this.httpClient.getParams();
    HttpConnectionParams.setSoTimeout(httpParams, timeout);
    return this;
}
Also used : BasicHttpParams(org.apache.http.params.BasicHttpParams) HttpParams(org.apache.http.params.HttpParams)

Aggregations

HttpParams (org.apache.http.params.HttpParams)122 BasicHttpParams (org.apache.http.params.BasicHttpParams)86 DefaultHttpClient (org.apache.http.impl.client.DefaultHttpClient)44 SchemeRegistry (org.apache.http.conn.scheme.SchemeRegistry)32 Scheme (org.apache.http.conn.scheme.Scheme)31 ClientConnectionManager (org.apache.http.conn.ClientConnectionManager)29 IOException (java.io.IOException)28 ThreadSafeClientConnManager (org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager)28 HttpResponse (org.apache.http.HttpResponse)24 HttpHost (org.apache.http.HttpHost)23 Header (org.apache.http.Header)18 HttpGet (org.apache.http.client.methods.HttpGet)13 SSLSocketFactory (org.apache.http.conn.ssl.SSLSocketFactory)11 URI (java.net.URI)10 HttpRequest (org.apache.http.HttpRequest)10 HttpClient (org.apache.http.client.HttpClient)10 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)10 Socket (java.net.Socket)9 ClientProtocolException (org.apache.http.client.ClientProtocolException)9 GeneralSecurityException (java.security.GeneralSecurityException)8