Package org.apache.http.impl.client

Examples of org.apache.http.impl.client.HttpClientBuilder


        } catch (Exception e) {
            LOGGER.error("can't set TLS Support. Error is: {}", e, e);
        }

        HttpClientBuilder httpClientBuilder = HttpClientBuilder.create()
                .setMaxConnPerRoute(metadata.getMaxConnectionsPerAddress())
                .setMaxConnTotal(metadata.getMaxConnectionsTotal())
                .setDefaultRequestConfig(requestConfig)
                .setKeepAliveStrategy(new InfraConnectionKeepAliveStrategy(metadata.getIdleTimeout()))
                .setSslcontext(sslContext);

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

        httpClient = httpClientBuilder.build();

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


        } catch (Exception e) {
            LOGGER.error("can't set TLS Support. Error is: {}", e, e);
        }

        HttpClientBuilder httpClientBuilder = HttpClientBuilder.create()
                .setMaxConnPerRoute(metadata.getMaxConnectionsPerAddress())
                .setMaxConnTotal(metadata.getMaxConnectionsTotal())
                .setDefaultRequestConfig(requestConfig)
                .setKeepAliveStrategy(new InfraConnectionKeepAliveStrategy(metadata.getIdleTimeout()))
                .setSslcontext(sslContext);

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

        httpClient = httpClientBuilder.build();

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

     * Builds the {@link HttpClient}.
     *
     * @return an {@link HttpClient}
     */
    public HttpClient build(String name, UrsusHttpClientConfiguration configuration) {
        HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
        setStrategiesForClient(httpClientBuilder, configuration);

        SocketConfig socketConfig = SocketConfig.copy(SocketConfig.DEFAULT)
                .setSoTimeout(configuration.getTimeout())
                .setTcpNoDelay(true)
                .setSoReuseAddress(true).build();

        ConnectionConfig connectionConfig = ConnectionConfig.copy(ConnectionConfig.DEFAULT)
                .setBufferSize(configuration.getBufferSize()).build();

        httpClientBuilder.setDefaultSocketConfig(socketConfig);
        httpClientBuilder.setDefaultConnectionConfig(connectionConfig);
        return httpClientBuilder.build();
    }
View Full Code Here

       */
      if( isSet(System.getProperty(HTTP_PROXY_HOST)) ) {
        LOG.warn("http.proxyHost = " + System.getProperty(HTTP_PROXY_HOST) );
        LOG.warn("http.proxyPort = " + System.getProperty(HTTP_PROXY_PORT));
       
        HttpClientBuilder hcBuilder = HttpClients.custom();

          // Set HTTP proxy, if specified in system properties
          if( isSet(System.getProperty(HTTP_PROXY_HOST)) ) {
              int port = 80;
              if( isSet(System.getProperty(HTTP_PROXY_PORT)) ) {
                  port = Integer.parseInt(System.getProperty(HTTP_PROXY_PORT));
              }
              HttpHost proxy = new HttpHost(System.getProperty(HTTP_PROXY_HOST), port, HTTP);
              DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);
              hcBuilder.setRoutePlanner(routePlanner);
          }

          httpClient = hcBuilder.build();

      }
    return httpClient;
  }
View Full Code Here

            @Override
            public <S> HttpClientBuilder create(String profile,
                    Class<S> service, Builder builder,
                    Map<String, Object> properties) {

                HttpClientBuilder httpClientBuilder = HttpClients.custom();
                ApacheConfigSettings settings = builder.build(profile, service,
                        ApacheConfigSettings.class, properties);

                return settings.applyConfig(httpClientBuilder);
            }
View Full Code Here

TOP

Related Classes of org.apache.http.impl.client.HttpClientBuilder

Copyright © 2018 www.massapicom. 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.