List of usage examples for org.apache.http.impl.client HttpClientBuilder setUserAgent
public final HttpClientBuilder setUserAgent(final String userAgent)
From source file:org.dasein.cloud.qingcloud.util.requester.QingCloudHttpClientBuilderFactory.java
static public HttpClientBuilder newHttpClientBuilder() { HttpClientBuilder builder = HttpClientBuilder.create(); builder.setUserAgent("Dasein Cloud"); //HttpProtocolParams.setContentCharset(params, Consts.UTF_8.toString()); return builder; }
From source file:de.geeksfactory.opacclient.networking.HTTPClient.java
public static HttpClient getNewHttpClient(boolean customssl, boolean disguise_app) { HttpClientBuilder builder = HttpClientBuilder.create(); builder.setRedirectStrategy(new CustomRedirectStrategy()); if (disguise_app) { builder.setUserAgent("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, " + "like Gecko) Chrome/43.0.2357.130 Safari/537.36\t"); } else {/*from w ww .ja va 2s . c o m*/ builder.setUserAgent("OpacApp/" + OpacClient.versionName); } if (customssl) { try { if (trustStore == null) { trustStore = KeyStore.getInstance("BKS"); final InputStream in = OpacClient.context.getResources().openRawResource(R.raw.ssl_trust_store); try { trustStore.load(in, "ro5eivoijeeGohsh0daequoo5Zeepaen".toCharArray()); } finally { in.close(); } } ConnectionSocketFactory sf = AdditionalKeyStoresSSLSocketFactory.create(trustStore); Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create() .register("http", PlainConnectionSocketFactory.getSocketFactory()).register("https", sf) .build(); HttpClientConnectionManager ccm = new PoolingHttpClientConnectionManager(registry); builder.setConnectionManager(ccm); return builder.build(); } catch (Exception e) { e.printStackTrace(); return builder.build(); } } else { return builder.build(); } }
From source file:securitytools.common.http.HttpClientFactory.java
public static CloseableHttpClient build(ClientConfiguration clientConfiguration) throws NoSuchAlgorithmException { HttpClientBuilder builder = HttpClients.custom(); // Certificate Validation if (clientConfiguration.isCertificateValidationEnabled()) { builder.setSSLSocketFactory(new SSLConnectionSocketFactory(SSLContext.getDefault(), SSLConnectionSocketFactory.STRICT_HOSTNAME_VERIFIER)); } else {/*w w w . j a v a 2 s . c o m*/ // Disable builder.setSSLSocketFactory(new TrustingSSLConnectionSocketFactory()); } // Timeouts RequestConfig.Builder requestConfigBuilder = RequestConfig.custom(); requestConfigBuilder.setConnectTimeout(clientConfiguration.getConnectionTimeout()); requestConfigBuilder.setConnectionRequestTimeout(clientConfiguration.getConnectionTimeout()); requestConfigBuilder.setSocketTimeout(clientConfiguration.getSocketTimeout()); builder.setDefaultRequestConfig(requestConfigBuilder.build()); // User Agent builder.setUserAgent(clientConfiguration.getUserAgent()); // Proxy if (clientConfiguration.getProxyHost() != null) { builder.setProxy(clientConfiguration.getProxyHost()); } return builder.build(); }
From source file:org.wildfly.camel.test.http4.subA.Http4ClientConfigurer.java
@Override public void configureHttpClient(HttpClientBuilder httpClientBuilder) { httpClientBuilder.setUserAgent("WildFly-Camel v1.0"); }
From source file:co.tuzza.clicksend4j.http.HttpClientUtils.java
public HttpClient getHttpClient() { HttpClientBuilder httpClientBuilder = HttpClientBuilder.create(); httpClientBuilder.setUserAgent("ClickSend4J 0.0.1"); httpClientBuilder.setConnectionManager(clientConnectionManager); httpClientBuilder.setDefaultRequestConfig(buildRequestConfig()); return httpClientBuilder.build(); }
From source file:org.xwiki.contrib.jira.macro.internal.source.HTTPJIRAFetcher.java
protected HttpClientBuilder createHttpClientBuilder(JIRAServer jiraServer) { // Allows system properties to override our default config (by calling useSystemProperties() first). HttpClientBuilder builder = HttpClientBuilder.create().useSystemProperties(); return builder.setUserAgent("XWikiJIRAMacro"); }
From source file:com.google.cloud.metrics.MetricsSender.java
/** * @param analyticsId The Google Analytics ID to which reports will be sent. * @param clientBuilder A builder for HTTP client objects. This injection is for testing; most * clients should never need to bind anything but the default implementation here. * @param random A random number generator for cache-busting. This injection is for testing; most * clients should never need to bind anything but the default implementation here. */// w ww .j a v a 2 s. c o m @Inject public MetricsSender(@GoogleAnalyticsId String analyticsId, HttpClientBuilder clientBuilder, Random random) { this.analyticsId = analyticsId; this.random = random; this.client = clientBuilder.setUserAgent(MetricsUtils.USER_AGENT).build(); }
From source file:co.tuzza.swipehq.transport.ManagedHttpTransport.java
private HttpClient getHttpClient() { HttpClientBuilder httpClientBuilder = HttpClientBuilder.create(); httpClientBuilder.setUserAgent("SwipeHQClient " + SwipeHQClient.VERSION); httpClientBuilder.setConnectionManager(clientConnectionManager); httpClientBuilder.setDefaultRequestConfig(getRequestConfig()); httpClientBuilder.setSSLContext(sslContext); return httpClientBuilder.build(); }
From source file:basedefense.client.version.ModificationVersionCheck.java
public ModificationVersionCheck() { HttpClientBuilder builder = HttpClientBuilder.create(); builder.disableCookieManagement();// ww w. ja v a 2s. c o m builder.disableRedirectHandling(); builder.setUserAgent(String.format(USER_AGENT_PATTERN, BaseDefenseModification.getInstance().getVersion())); builder.setDefaultHeaders(Lists.newArrayList(new BasicHeader("Accept", "application/vnd.github.v3+json"))); this.httpClient = builder.build(); }
From source file:synapticloop.getcookie.api.GetCookieApiClient.java
public GetCookieApiClient() { HttpClientBuilder httpBuilder = HttpClients.custom(); httpBuilder.setUserAgent(Constants.USER_AGENT); this.httpclient = httpBuilder.build(); }