All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pdd.pop.ext.apache.http.impl.client.SystemDefaultHttpClient Maven / Gradle / Ivy

/*
 * ====================================================================
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * .
 *
 */

package com.pdd.pop.ext.apache.http.impl.client;

import java.net.ProxySelector;

import com.pdd.pop.ext.apache.http.ConnectionReuseStrategy;
import com.pdd.pop.ext.apache.http.annotation.Contract;
import com.pdd.pop.ext.apache.http.annotation.ThreadingBehavior;
import com.pdd.pop.ext.apache.http.conn.ClientConnectionManager;
import com.pdd.pop.ext.apache.http.conn.routing.HttpRoutePlanner;
import com.pdd.pop.ext.apache.http.impl.DefaultConnectionReuseStrategy;
import com.pdd.pop.ext.apache.http.impl.NoConnectionReuseStrategy;
import com.pdd.pop.ext.apache.http.impl.conn.PoolingClientConnectionManager;
import com.pdd.pop.ext.apache.http.impl.conn.ProxySelectorRoutePlanner;
import com.pdd.pop.ext.apache.http.impl.conn.SchemeRegistryFactory;
import com.pdd.pop.ext.apache.http.params.HttpParams;

/**
 * An extension of {@link DefaultHttpClient} pre-configured using system properties.
 * 

* The following system properties are taken into account by this class: *

    *
  • ssl.TrustManagerFactory.algorithm
  • *
  • javax.net.ssl.trustStoreType
  • *
  • javax.net.ssl.trustStore
  • *
  • javax.net.ssl.trustStoreProvider
  • *
  • javax.net.ssl.trustStorePassword
  • *
  • java.home
  • *
  • ssl.KeyManagerFactory.algorithm
  • *
  • javax.net.ssl.keyStoreType
  • *
  • javax.net.ssl.keyStore
  • *
  • javax.net.ssl.keyStoreProvider
  • *
  • javax.net.ssl.keyStorePassword
  • *
  • http.proxyHost
  • *
  • http.proxyPort
  • *
  • https.proxyHost
  • *
  • https.proxyPort
  • *
  • http.nonProxyHosts
  • *
  • http.keepAlive
  • *
  • http.maxConnections
  • *
*

*

* The following parameters can be used to customize the behavior of this * class: *

*
    *
  • {@link com.pdd.pop.ext.apache.http.params.CoreProtocolPNames#PROTOCOL_VERSION}
  • *
  • {@link com.pdd.pop.ext.apache.http.params.CoreProtocolPNames#STRICT_TRANSFER_ENCODING}
  • *
  • {@link com.pdd.pop.ext.apache.http.params.CoreProtocolPNames#HTTP_ELEMENT_CHARSET}
  • *
  • {@link com.pdd.pop.ext.apache.http.params.CoreProtocolPNames#USE_EXPECT_CONTINUE}
  • *
  • {@link com.pdd.pop.ext.apache.http.params.CoreProtocolPNames#WAIT_FOR_CONTINUE}
  • *
  • {@link com.pdd.pop.ext.apache.http.params.CoreProtocolPNames#USER_AGENT}
  • *
  • {@link com.pdd.pop.ext.apache.http.params.CoreConnectionPNames#TCP_NODELAY}
  • *
  • {@link com.pdd.pop.ext.apache.http.params.CoreConnectionPNames#SO_TIMEOUT}
  • *
  • {@link com.pdd.pop.ext.apache.http.params.CoreConnectionPNames#SO_LINGER}
  • *
  • {@link com.pdd.pop.ext.apache.http.params.CoreConnectionPNames#SO_REUSEADDR}
  • *
  • {@link com.pdd.pop.ext.apache.http.params.CoreConnectionPNames#SOCKET_BUFFER_SIZE}
  • *
  • {@link com.pdd.pop.ext.apache.http.params.CoreConnectionPNames#CONNECTION_TIMEOUT}
  • *
  • {@link com.pdd.pop.ext.apache.http.params.CoreConnectionPNames#MAX_LINE_LENGTH}
  • *
  • {@link com.pdd.pop.ext.apache.http.params.CoreConnectionPNames#MAX_HEADER_COUNT}
  • *
  • {@link com.pdd.pop.ext.apache.http.params.CoreConnectionPNames#STALE_CONNECTION_CHECK}
  • *
  • {@link com.pdd.pop.ext.apache.http.conn.params.ConnRoutePNames#FORCED_ROUTE}
  • *
  • {@link com.pdd.pop.ext.apache.http.conn.params.ConnRoutePNames#LOCAL_ADDRESS}
  • *
  • {@link com.pdd.pop.ext.apache.http.conn.params.ConnRoutePNames#DEFAULT_PROXY}
  • *
  • {@link com.pdd.pop.ext.apache.http.cookie.params.CookieSpecPNames#DATE_PATTERNS}
  • *
  • {@link com.pdd.pop.ext.apache.http.cookie.params.CookieSpecPNames#SINGLE_COOKIE_HEADER}
  • *
  • {@link com.pdd.pop.ext.apache.http.auth.params.AuthPNames#CREDENTIAL_CHARSET}
  • *
  • {@link com.pdd.pop.ext.apache.http.client.params.ClientPNames#COOKIE_POLICY}
  • *
  • {@link com.pdd.pop.ext.apache.http.client.params.ClientPNames#HANDLE_AUTHENTICATION}
  • *
  • {@link com.pdd.pop.ext.apache.http.client.params.ClientPNames#HANDLE_REDIRECTS}
  • *
  • {@link com.pdd.pop.ext.apache.http.client.params.ClientPNames#MAX_REDIRECTS}
  • *
  • {@link com.pdd.pop.ext.apache.http.client.params.ClientPNames#ALLOW_CIRCULAR_REDIRECTS}
  • *
  • {@link com.pdd.pop.ext.apache.http.client.params.ClientPNames#VIRTUAL_HOST}
  • *
  • {@link com.pdd.pop.ext.apache.http.client.params.ClientPNames#DEFAULT_HOST}
  • *
  • {@link com.pdd.pop.ext.apache.http.client.params.ClientPNames#DEFAULT_HEADERS}
  • *
  • {@link com.pdd.pop.ext.apache.http.client.params.ClientPNames#CONN_MANAGER_TIMEOUT}
  • *
* * @since 4.2 * * @deprecated (4.3) use {@link HttpClientBuilder} */ @Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL) @Deprecated public class SystemDefaultHttpClient extends DefaultHttpClient { public SystemDefaultHttpClient(final HttpParams params) { super(null, params); } public SystemDefaultHttpClient() { super(null, null); } @Override protected ClientConnectionManager createClientConnectionManager() { final PoolingClientConnectionManager connmgr = new PoolingClientConnectionManager( SchemeRegistryFactory.createSystemDefault()); String s = System.getProperty("http.keepAlive", "true"); if ("true".equalsIgnoreCase(s)) { s = System.getProperty("http.maxConnections", "5"); final int max = Integer.parseInt(s); connmgr.setDefaultMaxPerRoute(max); connmgr.setMaxTotal(2 * max); } return connmgr; } @Override protected HttpRoutePlanner createHttpRoutePlanner() { return new ProxySelectorRoutePlanner(getConnectionManager().getSchemeRegistry(), ProxySelector.getDefault()); } @Override protected ConnectionReuseStrategy createConnectionReuseStrategy() { final String s = System.getProperty("http.keepAlive", "true"); if ("true".equalsIgnoreCase(s)) { return new DefaultConnectionReuseStrategy(); } else { return new NoConnectionReuseStrategy(); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy