Search in sources :

Example 6 with AbstractHttpClient

use of org.apache.http.impl.client.AbstractHttpClient in project coprhd-controller by CoprHD.

the class ClientHttpRequestFactory method createUnconfiguredClient.

private AbstractHttpClient createUnconfiguredClient() throws ClientGeneralException {
    AbstractHttpClient httpClient = null;
    try {
        httpClient = httpClientFactory.createHTTPClient();
        HttpProtocolParams.setUseExpectContinue(httpClient.getParams(), true);
        return httpClient;
    } catch (Exception ex) {
        LOGGER.error("Error initializing new HttpClient instance");
        throw new ClientGeneralException(ClientMessageKeys.UNEXPECTED_FAILURE, new String[] { ex.getMessage() });
    }
}
Also used : AbstractHttpClient(org.apache.http.impl.client.AbstractHttpClient)

Example 7 with AbstractHttpClient

use of org.apache.http.impl.client.AbstractHttpClient in project jmeter-plugins-manager by undera.

the class JARSourceHTTP method getHTTPClient.

private AbstractHttpClient getHTTPClient() {
    AbstractHttpClient client = new DefaultHttpClient();
    String proxyHost = System.getProperty("https.proxyHost", "");
    if (!proxyHost.isEmpty()) {
        int proxyPort = Integer.parseInt(System.getProperty("https.proxyPort", "-1"));
        log.info("Using proxy " + proxyHost + ":" + proxyPort);
        HttpParams params = client.getParams();
        HttpHost proxy = new HttpHost(proxyHost, proxyPort);
        params.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
        String proxyUser = System.getProperty(JMeter.HTTP_PROXY_USER, org.apache.jmeter.util.JMeterUtils.getProperty(JMeter.HTTP_PROXY_USER));
        if (proxyUser != null) {
            log.info("Using authenticated proxy with username: " + proxyUser);
            String proxyPass = System.getProperty(JMeter.HTTP_PROXY_PASS, JMeterUtils.getProperty(JMeter.HTTP_PROXY_PASS));
            String localHost;
            try {
                localHost = InetAddress.getLocalHost().getCanonicalHostName();
            } catch (Throwable e) {
                log.error("Failed to get local host name, defaulting to 'localhost'", e);
                localHost = "localhost";
            }
            AuthScope authscope = new AuthScope(proxyHost, proxyPort);
            String proxyDomain = JMeterUtils.getPropDefault("http.proxyDomain", "");
            NTCredentials credentials = new NTCredentials(proxyUser, proxyPass, localHost, proxyDomain);
            client.getCredentialsProvider().setCredentials(authscope, credentials);
        }
    }
    client.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(RETRY_COUNT, true));
    return client;
}
Also used : AbstractHttpClient(org.apache.http.impl.client.AbstractHttpClient) HttpParams(org.apache.http.params.HttpParams) HttpHost(org.apache.http.HttpHost) AuthScope(org.apache.http.auth.AuthScope) DefaultHttpRequestRetryHandler(org.apache.http.impl.client.DefaultHttpRequestRetryHandler) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) NTCredentials(org.apache.http.auth.NTCredentials)

Aggregations

AbstractHttpClient (org.apache.http.impl.client.AbstractHttpClient)7 DefaultHttpClient (org.apache.http.impl.client.DefaultHttpClient)4 HttpParams (org.apache.http.params.HttpParams)4 HttpHost (org.apache.http.HttpHost)3 AuthScope (org.apache.http.auth.AuthScope)3 NTCredentials (org.apache.http.auth.NTCredentials)3 ClientConnectionManager (org.apache.http.conn.ClientConnectionManager)2 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)2 DefaultHttpRequestRetryHandler (org.apache.http.impl.client.DefaultHttpRequestRetryHandler)2 ThreadSafeClientConnManager (org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager)2 ClientException (com.netflix.client.ClientException)1 AbstractSslContextFactory (com.netflix.client.ssl.AbstractSslContextFactory)1 ClientSslSocketFactoryException (com.netflix.client.ssl.ClientSslSocketFactoryException)1 URLSslContextFactory (com.netflix.client.ssl.URLSslContextFactory)1 NFHttpClient (com.netflix.http4.NFHttpClient)1 NFHttpMethodRetryHandler (com.netflix.http4.NFHttpMethodRetryHandler)1 KeyStoreAwareSocketFactory (com.netflix.http4.ssl.KeyStoreAwareSocketFactory)1 ApacheHttpClient4 (com.sun.jersey.client.apache4.ApacheHttpClient4)1 ApacheHttpClient4Handler (com.sun.jersey.client.apache4.ApacheHttpClient4Handler)1 SocketException (java.net.SocketException)1