Package org.apache.http.impl.client

Examples of org.apache.http.impl.client.HttpClientBuilder.build()


        if (proxySettings != NO_PROXY) {
            HttpHost proxyHost = new HttpHost(proxySettings.host(), proxySettings.port());
            builder.setProxy(proxyHost);
        }

        return builder.build();
  }

    private static SSLContext buildAllowAnythingSSLContext() {
        try {
            return new SSLContextBuilder().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build();
View Full Code Here


                build();

        clientBuilder.setRetryHandler(datasyncDefaultHandler);
        clientBuilder.setKeepAliveStrategy(datasyncDefaultKeepAliveStrategy);
        clientBuilder.setDefaultRequestConfig(requestConfig);
        httpClient = clientBuilder.build();
    }

    /**
     * Conducts a basic get, passing the auth information in the header.
     * @param uri the uri from which the get will be made
View Full Code Here

                    .setConnectTimeout(timeoutms)
                    .setSocketTimeout(timeoutms).build();
            builder.setDefaultRequestConfig(config);
        }
        CloseableHttpResponse response = null;
        try (CloseableHttpClient client = builder.build()) {
            response = client.execute(request);
            return new HttpResponse(response);
        } finally {
            if (response != null) {
                response.close();
View Full Code Here

                    .setConnectTimeout(timeoutms)
                    .setSocketTimeout(timeoutms).build();
            builder.setDefaultRequestConfig(config);
        }
        CloseableHttpResponse response = null;
        try (CloseableHttpClient client = builder.build()) {
            response = client.execute(request);
            return new HttpResponse(response);
        } finally {
            if (response != null) {
                response.close();
View Full Code Here

                    new DefaultHttpRequestRetryHandler(numRetries, false);
            builder = builder.setRetryHandler(retryHandler);
        }
        List<Method> responses = new ArrayList<>();
        ExecutorService executor = Executors.newFixedThreadPool(Math.min(numThreads, requests.size()));
        CloseableHttpClient client = builder.build();
        try {
            for (int i = 0; i < requests.size(); i++) {
                Method method = new Method(client, requests.get(i), timeoutms);
                responses.add(i, method);
                executor.execute(method);
View Full Code Here

    configBuilder.setConnectionRequestTimeout(timeout);
    builder.setDefaultRequestConfig(configBuilder.build());

    builder.setDefaultConnectionConfig(ConnectionConfig.custom().setCharset(Consts.ISO_8859_1).build());

    return builder.build();
  }

  public static class NotModifiedException extends Exception {
    private static final long serialVersionUID = 1L;
View Full Code Here

        UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(usernameValue, passwordValue);
        provider.setCredentials(new AuthScope("localhost", -1, "mule-realm"), credentials);
        clientBuilder.setDefaultCredentialsProvider(provider);
      }
     
      HttpClient client = clientBuilder.build();
     
      HttpPost request = new HttpPost(endpointUrlValue);
     
      try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
View Full Code Here

        if (!followRedirects) {
            httpClientBuilder.disableRedirectHandling();
        }

        httpClient = httpClientBuilder.build();

        httpAsyncClient = HttpAsyncClients.custom()
                .setDefaultRequestConfig(requestConfig)
                .setMaxConnPerRoute(metadata.getMaxConnectionsPerAddress())
                .setMaxConnTotal(metadata.getMaxConnectionsTotal())
View Full Code Here

  public synchronized HttpClient getHttpClient() {
    if (myHttpClient == null) {
      PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
      HttpClientBuilder builder = HttpClientBuilder.create();
      builder.setConnectionManager(connectionManager);
      myHttpClient = builder.build();
    }
    return myHttpClient;
  }

  /**
 
View Full Code Here

    final SocketConfig socketConfig = SocketConfig.custom()
        .setSoTimeout(60000).setTcpNoDelay(true).build();
    builder.setDefaultSocketConfig(socketConfig);
   
    // generate httpclient
    httpClient = builder.build();
  }
 
 
  /**
   * Gets the.
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.